Log when App info or Widgets system shortcuts are tapped
Sample output:
D/UserEvent: action:LONGPRESS
Source child:APP_ICON, grid(1,3), span(1,1), pageIdx=0 parent:WORKSPACE id=0
Elapsed container 135 ms session 7984 ms action 0 ms
isInLandscapeMode false
isInMultiWindowMode false
D/UserEvent: action:TAP
Source child:WIDGETS_BUTTON parent:DEEPSHORTCUTS
Elapsed container 41 ms session 8906 ms action 0 ms
isInLandscapeMode false
isInMultiWindowMode false
D/UserEvent: action:LONGPRESS
Source child:APP_ICON, grid(1,3), span(1,1), pageIdx=0 parent:WORKSPACE id=0
Elapsed container 184 ms session 11297 ms action 0 ms
isInLandscapeMode false
isInMultiWindowMode false
D/UserEvent: action:TAP
Source child:APPINFO_TARGET parent:DEEPSHORTCUTS
Elapsed container 678 ms session 11976 ms action 0 ms
isInLandscapeMode false
isInMultiWindowMode false
Bug: 37430954
Change-Id: I526edbf1eea551eb8eaddbb27e52058804fee874
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 7585be6..edbb88c 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
+import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;
@@ -90,7 +91,7 @@
/**
* Recursively finds the parent of the given child which implements IconLogInfoProvider
*/
- public static LogContainerProvider getLaunchProviderRecursive(View v) {
+ public static LogContainerProvider getLaunchProviderRecursive(@Nullable View v) {
ViewParent parent;
if (v != null) {
parent = v.getParent();
@@ -147,7 +148,11 @@
return event;
}
- public boolean fillInLogContainerData(LauncherEvent event, View v) {
+ /**
+ * Fills in the container data on the given event if the given view is not null.
+ * @return whether container data was added.
+ */
+ private boolean fillInLogContainerData(LauncherEvent event, @Nullable View v) {
// Fill in grid(x,y), pageIndex of the child and container type of the parent
LogContainerProvider provider = getLaunchProviderRecursive(v);
if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) {
@@ -203,9 +208,16 @@
}
public void logActionOnControl(int action, int controlType) {
- LauncherEvent event = newLauncherEvent(
- newTouchAction(action), newTarget(Target.Type.CONTROL));
+ logActionOnControl(action, controlType, null);
+ }
+
+ public void logActionOnControl(int action, int controlType, @Nullable View controlInContainer) {
+ final LauncherEvent event = controlInContainer == null
+ ? newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL))
+ : newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL),
+ newTarget(Target.Type.CONTAINER));
event.srcTarget[0].controlType = controlType;
+ fillInLogContainerData(event, controlInContainer);
dispatchUserEvent(event, null);
}
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index a52d1d4..6254d2d 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -13,18 +13,20 @@
import com.android.launcher3.R;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.util.PackageUserKey;
-import com.android.launcher3.util.Themes;
import com.android.launcher3.widget.WidgetsBottomSheet;
import java.util.List;
+import static com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
+
/**
* Represents a system shortcut for a given app. The shortcut should have a static label and
* icon, and an onClickListener that depends on the item that the shortcut services.
*
* Example system shortcuts, defined as inner classes, include Widgets and AppInfo.
*/
-public abstract class SystemShortcut {
+public abstract class SystemShortcut extends ItemInfo {
private final int mIconResId;
private final int mLabelResId;
@@ -66,6 +68,8 @@
(WidgetsBottomSheet) launcher.getLayoutInflater().inflate(
R.layout.widgets_bottom_sheet, launcher.getDragLayer(), false);
widgetsBottomSheet.populateAndShow(itemInfo);
+ launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
+ ControlType.WIDGETS_BUTTON, view);
}
};
}
@@ -85,6 +89,8 @@
Rect sourceBounds = launcher.getViewBounds(view);
Bundle opts = launcher.getActivityLaunchOptions(view);
InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, null, sourceBounds, opts);
+ launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
+ ControlType.APPINFO_TARGET, view);
}
};
}