diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto index 055ade58eb..8f413dc8a5 100644 --- a/protos/launcher_log.proto +++ b/protos/launcher_log.proto @@ -57,6 +57,7 @@ message Target { optional TargetExtension extension = 16; optional TipType tip_type = 17; optional int32 search_query_length = 18; + optional bool is_work_app = 19; } // Used to define what type of item a Target would represent. diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java index 8e5ed1a3ea..a466f12b0d 100644 --- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java +++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java @@ -17,30 +17,34 @@ package com.android.quickstep.logging; import static android.stats.launcher.nano.Launcher.ALLAPPS; +import static android.stats.launcher.nano.Launcher.BACKGROUND; +import static android.stats.launcher.nano.Launcher.DISMISS_TASK; import static android.stats.launcher.nano.Launcher.HOME; import static android.stats.launcher.nano.Launcher.LAUNCH_APP; import static android.stats.launcher.nano.Launcher.LAUNCH_TASK; -import static android.stats.launcher.nano.Launcher.DISMISS_TASK; -import static android.stats.launcher.nano.Launcher.BACKGROUND; import static android.stats.launcher.nano.Launcher.OVERVIEW; import android.content.Context; import android.content.Intent; +import android.os.UserHandle; import android.stats.launcher.nano.Launcher; import android.stats.launcher.nano.LauncherExtension; import android.stats.launcher.nano.LauncherTarget; import android.util.Log; import android.view.View; +import androidx.annotation.Nullable; + import com.android.launcher3.ItemInfo; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.logging.StatsLogUtils; -import com.android.launcher3.userevent.nano.LauncherLogProto.Target; -import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType; +import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType; +import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.ComponentKey; import com.android.systemui.shared.system.StatsLogCompat; + import com.google.protobuf.nano.MessageNano; /** @@ -60,7 +64,7 @@ public class StatsLogCompatManager extends StatsLogManager { public StatsLogCompatManager(Context context) { } @Override - public void logAppLaunch(View v, Intent intent) { + public void logAppLaunch(View v, Intent intent, @Nullable UserHandle userHandle) { LauncherExtension ext = new LauncherExtension(); ext.srcTarget = new LauncherTarget[SUPPORTED_TARGET_DEPTH]; int srcState = mStateProvider.getCurrentState(); diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index 893f64a1ba..21c819abb8 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -174,8 +174,8 @@ public abstract class BaseDraggingActivity extends BaseActivity AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(), user, sourceContainer); } - getUserEventDispatcher().logAppLaunch(v, intent); - getStatsLogManager().logAppLaunch(v, intent); + getUserEventDispatcher().logAppLaunch(v, intent, user); + getStatsLogManager().logAppLaunch(v, intent, user); return true; } catch (NullPointerException|ActivityNotFoundException|SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java index 598792abce..f352b46e0b 100644 --- a/src/com/android/launcher3/logging/LoggerUtils.java +++ b/src/com/android/launcher3/logging/LoggerUtils.java @@ -142,8 +142,10 @@ public class LoggerUtils { typeStr += ", grid(" + t.gridX + "," + t.gridY + ")"; } else if ((t.packageNameHash != 0 || t.componentHash != 0 || t.intentHash != 0) && t.itemType != ItemType.TASK) { - typeStr += ", predictiveRank=" + t.predictedRank + ", grid(" + t.gridX + "," + t.gridY - + "), span(" + t.spanX + "," + t.spanY + "), pageIdx=" + t.pageIndex; + typeStr += + ", isWorkApp=" + t.isWorkApp + ", predictiveRank=" + t.predictedRank + ", grid(" + + t.gridX + "," + t.gridY + "), span(" + t.spanX + "," + t.spanY + + "), pageIdx=" + t.pageIndex; } if (t.searchQueryLength != 0) { typeStr += ", searchQueryLength=" + t.searchQueryLength; diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index cad95b0d24..9dfd7ab943 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -17,12 +17,15 @@ package com.android.launcher3.logging; import android.content.Context; import android.content.Intent; +import android.os.UserHandle; import android.view.View; +import androidx.annotation.Nullable; + import com.android.launcher3.R; +import com.android.launcher3.logging.StatsLogUtils.LogStateProvider; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.ResourceBasedOverride; -import com.android.launcher3.logging.StatsLogUtils.LogStateProvider; /** * Handles the user event logging in Q. @@ -38,7 +41,10 @@ public class StatsLogManager implements ResourceBasedOverride { return mgr; } - public void logAppLaunch(View v, Intent intent) { } + /** + * Logs app launches + */ + public void logAppLaunch(View v, Intent intent, @Nullable UserHandle userHandle) { } public void logTaskLaunch(View v, ComponentKey key) { } public void logTaskDismiss(View v, ComponentKey key) { } public void logSwipeOnContainer(boolean isSwipingToLeft, int pageId) { } diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 99906fe1ac..499cd2a7cd 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -33,7 +33,9 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Process; import android.os.SystemClock; +import android.os.UserHandle; import android.util.Log; import android.view.View; @@ -135,7 +137,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { // -------------------------------------------------------------- @Deprecated - public void logAppLaunch(View v, Intent intent) { + public void logAppLaunch(View v, Intent intent, @Nullable UserHandle userHandle) { LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP), newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); @@ -143,7 +145,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { if (mDelegate != null) { mDelegate.modifyUserEvent(event); } - fillIntentInfo(event.srcTarget[0], intent); + fillIntentInfo(event.srcTarget[0], intent, userHandle); } dispatchUserEvent(event, intent); mAppOrTaskLaunch = true; @@ -171,8 +173,9 @@ public class UserEventDispatcher implements ResourceBasedOverride { mAppOrTaskLaunch = true; } - protected void fillIntentInfo(Target target, Intent intent) { + protected void fillIntentInfo(Target target, Intent intent, @Nullable UserHandle userHandle) { target.intentHash = intent.hashCode(); + target.isWorkApp = userHandle != null && !userHandle.equals(Process.myUserHandle()); fillComponentInfo(target, intent.getComponent()); }