From fefe2c8374400cc3645960acfd3a7994e57c5d3c Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Tue, 3 Sep 2019 14:39:50 -0700 Subject: plugin for user event logging Bug: 140243695 Change-Id: If9c620aa10334b26ad9b489d6544201d38439fea --- src/com/android/launcher3/logging/UserEventDispatcher.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/com/android/launcher3/logging/UserEventDispatcher.java') diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index c72b07a7f..21ca74e12 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -427,10 +427,16 @@ public class UserEventDispatcher implements ResourceBasedOverride { mAppOrTaskLaunch = false; ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis; ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis; - if (!IS_VERBOSE) { return; } + Log.d(TAG, generateLog(ev)); + } + + /** + * Returns a human-readable log for given user event. + */ + public static String generateLog(LauncherEvent ev) { String log = "\n-----------------------------------------------------" + "\naction:" + LoggerUtils.getActionStr(ev.action); if (ev.srcTarget != null && ev.srcTarget.length > 0) { @@ -445,8 +451,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { ev.elapsedSessionMillis, ev.actionDurationMillis); log += "\n\n"; - Log.d(TAG, log); - return; + return log; } private static String getTargetsStr(Target[] targets) { -- cgit v1.2.3 From aea8820229945539390a4cd94fe4bf582ecc449e Mon Sep 17 00:00:00 2001 From: Thiru Ramasamy Date: Wed, 6 Nov 2019 15:43:30 -0800 Subject: Fixes missing LauncherEvent for TAP action on FOLDER_ICON Bug: 143969621 Change-Id: I8d08d1c55f90c6aeacd63ced8235de851ec2cad9 --- .../launcher3/logging/UserEventDispatcher.java | 62 ++++++++++++++-------- 1 file changed, 41 insertions(+), 21 deletions(-) (limited to 'src/com/android/launcher3/logging/UserEventDispatcher.java') diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 21ca74e12..8c2451efc 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -26,6 +26,8 @@ import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent; import static com.android.launcher3.logging.LoggerUtils.newTarget; import static com.android.launcher3.logging.LoggerUtils.newTouchAction; +import static java.util.Optional.ofNullable; + import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; @@ -58,7 +60,7 @@ import java.util.UUID; /** * Manages the creation of {@link LauncherEvent}. * To debug this class, execute following command before side loading a new apk. - * + *

* $ adb shell setprop log.tag.UserEvent VERBOSE */ public class UserEventDispatcher implements ResourceBasedOverride { @@ -94,6 +96,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { /** * Fills in the container data on the given event if the given view is not null. + * * @return whether container data was added. */ public static boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) { @@ -139,7 +142,11 @@ public class UserEventDispatcher implements ResourceBasedOverride { mAppOrTaskLaunch = true; } - public void logActionTip(int actionType, int viewType) { } + /** + * Dummy method. + */ + public void logActionTip(int actionType, int viewType) { + } @Deprecated public void logTaskLaunchOrDismiss(int action, int direction, int taskIndex, @@ -184,15 +191,15 @@ public class UserEventDispatcher implements ResourceBasedOverride { public void logActionCommand(int command, int srcContainerType, int dstContainerType) { logActionCommand(command, newContainerTarget(srcContainerType), - dstContainerType >=0 ? newContainerTarget(dstContainerType) : null); + dstContainerType >= 0 ? newContainerTarget(dstContainerType) : null); } public void logActionCommand(int command, int srcContainerType, int dstContainerType, - int pageIndex) { + int pageIndex) { Target srcTarget = newContainerTarget(srcContainerType); srcTarget.pageIndex = pageIndex; logActionCommand(command, srcTarget, - dstContainerType >=0 ? newContainerTarget(dstContainerType) : null); + dstContainerType >= 0 ? newContainerTarget(dstContainerType) : null); } public void logActionCommand(int command, Target srcTarget, Target dstTarget) { @@ -241,7 +248,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { } public void logActionOnControl(int action, int controlType, int parentContainer, - int grandParentContainer){ + int grandParentContainer) { LauncherEvent event = newLauncherEvent(newTouchAction(action), newControlTarget(controlType), newContainerTarget(parentContainer), @@ -250,11 +257,11 @@ public class UserEventDispatcher implements ResourceBasedOverride { } public void logActionOnControl(int action, int controlType, @Nullable View controlInContainer, - int parentContainerType) { + int parentContainerType) { final LauncherEvent event = (controlInContainer == null && parentContainerType < 0) ? newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL)) : newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL), - newTarget(Target.Type.CONTAINER)); + newTarget(Target.Type.CONTAINER)); event.srcTarget[0].controlType = controlType; if (controlInContainer != null) { fillInLogContainerData(event, controlInContainer); @@ -301,9 +308,9 @@ public class UserEventDispatcher implements ResourceBasedOverride { * (1) WORKSPACE: if the launcher is the foreground activity * (2) APP: if another app was the foreground activity */ - public void logStateChangeAction(int action, int dir, int downX, int downY, int srcChildTargetType, - int srcParentContainerType, int dstContainerType, - int pageIndex) { + public void logStateChangeAction(int action, int dir, int downX, int downY, + int srcChildTargetType, int srcParentContainerType, int dstContainerType, + int pageIndex) { LauncherEvent event; if (srcChildTargetType == LauncherLogProto.ItemType.TASK) { event = newLauncherEvent(newTouchAction(action), @@ -326,9 +333,25 @@ public class UserEventDispatcher implements ResourceBasedOverride { } public void logActionOnItem(int action, int dir, int itemType) { + logActionOnItem(action, dir, itemType, null, null); + } + + /** + * Creates new {@link LauncherEvent} of ITEM target type with input arguments and dispatches it. + * + * @param touchAction ENUM value of {@link LauncherLogProto.Action.Touch} Action + * @param dir ENUM value of {@link LauncherLogProto.Action.Direction} Action + * @param itemType ENUM value of {@link LauncherLogProto.ItemType} + * @param gridX Nullable X coordinate of item's position on the workspace grid + * @param gridY Nullable Y coordinate of item's position on the workspace grid + */ + public void logActionOnItem(int touchAction, int dir, int itemType, + @Nullable Integer gridX, @Nullable Integer gridY) { Target itemTarget = newTarget(Target.Type.ITEM); itemTarget.itemType = itemType; - LauncherEvent event = newLauncherEvent(newTouchAction(action), itemTarget); + ofNullable(gridX).ifPresent(value -> itemTarget.gridX = value); + ofNullable(gridY).ifPresent(value -> itemTarget.gridY = value); + LauncherEvent event = newLauncherEvent(newTouchAction(touchAction), itemTarget); event.action.dir = dir; dispatchUserEvent(event, null); } @@ -351,7 +374,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP), newItemTarget(dragObj.originalDragInfo, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); - event.destTarget = new Target[] { + event.destTarget = new Target[]{ newItemTarget(dragObj.originalDragInfo, mInstantAppResolver), newDropTarget(dropTargetAsView) }; @@ -373,14 +396,10 @@ public class UserEventDispatcher implements ResourceBasedOverride { int actionTouch = isButton ? Action.Touch.TAP : Action.Touch.SWIPE; Action action = newCommandAction(actionTouch); action.command = Action.Command.BACK; - action.dir = isButton - ? Action.Direction.NONE - : gestureSwipeLeft - ? Action.Direction.LEFT - : Action.Direction.RIGHT; - Target target = newControlTarget(isButton - ? LauncherLogProto.ControlType.BACK_BUTTON - : LauncherLogProto.ControlType.BACK_GESTURE); + action.dir = isButton ? Action.Direction.NONE : + gestureSwipeLeft ? Action.Direction.LEFT : Action.Direction.RIGHT; + Target target = newControlTarget(isButton ? LauncherLogProto.ControlType.BACK_BUTTON : + LauncherLogProto.ControlType.BACK_GESTURE); target.spanX = downX; target.spanY = downY; target.cardinality = completed ? 1 : 0; @@ -391,6 +410,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { /** * Currently logs following containers: workspace, allapps, widget tray. + * * @param reason */ public final void resetElapsedContainerMillis(String reason) { -- cgit v1.2.3 From 1397a42fc23ab8ec4c96268015b357e798d6f8ed Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Mon, 11 Nov 2019 15:55:27 -0800 Subject: include predicted_rank in app launch logging Test: 1. . build/envsetup.sh && tapas NexusLauncher 2. ccdebug && cclogcat 3. launch from workspace any app that is also in predicted apps 4. verify in terminal it has correct predicted_rank Bug: 143855018 Change-Id: I07a62f07057537a6c09384cf944bbc5aa5888d22 Merged-In: I07a62f07057537a6c09384cf944bbc5aa5888d22 --- src/com/android/launcher3/logging/UserEventDispatcher.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/com/android/launcher3/logging/UserEventDispatcher.java') diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 21ca74e12..7b06d3ba9 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -35,6 +35,7 @@ import android.os.SystemClock; import android.util.Log; import android.view.View; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.DropTarget; @@ -96,17 +97,23 @@ public class UserEventDispatcher implements ResourceBasedOverride { * Fills in the container data on the given event if the given view is not null. * @return whether container data was added. */ - public static boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) { + public boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) { // Fill in grid(x,y), pageIndex of the child and container type of the parent LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(v); if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) { return false; } - ItemInfo itemInfo = (ItemInfo) v.getTag(); - provider.fillInLogContainerData(v, itemInfo, event.srcTarget[0], event.srcTarget[1]); + final ItemInfo itemInfo = (ItemInfo) v.getTag(); + final Target target = event.srcTarget[0]; + final Target targetParent = event.srcTarget[1]; + onFillInLogContainerData(itemInfo, target, targetParent); + provider.fillInLogContainerData(v, itemInfo, target, targetParent); return true; } + protected void onFillInLogContainerData( + @NonNull ItemInfo itemInfo, @NonNull Target target, @NonNull Target targetParent) { } + private boolean mSessionStarted; private long mElapsedContainerMillis; private long mElapsedSessionMillis; -- cgit v1.2.3