From a00bcf326c2b6e3299b9df7a5bdffb975df2e99f Mon Sep 17 00:00:00 2001 From: thiruram Date: Tue, 2 Jun 2020 15:01:56 -0700 Subject: [PATCH] Log tap on app info within task menu. Override TaskShortcutFactory.dummyInfo to logs 'task -> app info' as TaskEvent and 'app icon -> app info' as AppEvent. Bug: 157770913 Sample Log: https://docs.google.com/document/d/1FXi_jY1B63aMSjNyomAmoN1nSTtVbvculNGX7TKdRRw/edit#bookmark=id.j2cziephk9fy Change-Id: I448a489fcc93324f6082eba2857644feb5d6bca3 --- .../com/android/quickstep/TaskShortcutFactory.java | 12 +++++++++++- .../src/com/android/quickstep/views/TaskView.java | 4 +++- src/com/android/launcher3/popup/SystemShortcut.java | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskShortcutFactory.java index cdaa6555a0..5b15c5501a 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskShortcutFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskShortcutFactory.java @@ -37,6 +37,7 @@ import android.view.View; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; +import com.android.launcher3.logger.LauncherAtom; import com.android.launcher3.logging.StatsLogManager.LauncherEvent; import com.android.launcher3.model.WellbeingModel; import com.android.launcher3.model.data.WorkspaceItemInfo; @@ -71,7 +72,16 @@ public interface TaskShortcutFactory { static WorkspaceItemInfo dummyInfo(TaskView view) { Task task = view.getTask(); - WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo(); + WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo(){ + /** + * Helps to log events as {@link LauncherAtom.Task} + * instead of {@link LauncherAtom.ItemInfo}. + */ + @Override + public LauncherAtom.ItemInfo buildProto() { + return view.buildProto(); + } + }; dummyInfo.intent = new Intent(); ComponentName component = task.getTopComponent(); dummyInfo.getIntent().setComponent(component); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index af9d7f76bc..212f6bf7e4 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -223,7 +223,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { setOutlineProvider(mOutlineProvider); } - /** Builds proto for logging */ + /** + * Builds proto for logging + */ public LauncherAtom.ItemInfo buildProto() { ComponentKey componentKey = TaskUtils.getLaunchComponentKeyForTask(getTask().key); LauncherAtom.ItemInfo.Builder itemBuilder = LauncherAtom.ItemInfo.newBuilder(); diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 58ed5e8132..ea8caf55de 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -29,6 +29,7 @@ import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.widget.WidgetsBottomSheet; import java.util.List; + /** * Represents a system shortcut for a given app. The shortcut should have a label and icon, and an * onClickListener that depends on the item that the shortcut services. @@ -142,8 +143,8 @@ public abstract class SystemShortcut extends Ite mTarget.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP, ControlType.APPINFO_TARGET, view); // TODO(thiruram): Fix missing container info when item is inside folder. - mTarget.getStatsLogManager().log(LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP, - mItemInfo.buildProto()); + mTarget.getStatsLogManager() + .log(LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP, mItemInfo.buildProto()); } }