diff options
Diffstat (limited to 'src/com/android/launcher3/logging')
-rw-r--r-- | src/com/android/launcher3/logging/LoggerUtils.java | 39 | ||||
-rw-r--r-- | src/com/android/launcher3/logging/UserEventDispatcher.java | 35 |
2 files changed, 53 insertions, 21 deletions
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java index 584e38e9e..9e927218b 100644 --- a/src/com/android/launcher3/logging/LoggerUtils.java +++ b/src/com/android/launcher3/logging/LoggerUtils.java @@ -1,15 +1,9 @@ package com.android.launcher3.logging; -import android.os.Bundle; -import android.util.Log; - -import com.android.launcher3.LauncherSettings; -import com.android.launcher3.ShortcutInfo; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; - /** * Debugging helper methods. * toString() cannot be overriden inside auto generated {@link LauncherLogProto}. @@ -24,12 +18,17 @@ public class LoggerUtils { case Action.LONGPRESS: return "LONGPRESS"; case Action.DRAGDROP: return "DRAGDROP"; case Action.PINCH: return "PINCH"; + case Action.SWIPE: return "SWIPE"; + case Action.FLING: return "FLING"; default: return "UNKNOWN"; } } public static String getTargetStr(Target t) { - String typeStr; + String typeStr = ""; + if (t == null){ + return typeStr; + } switch (t.type) { case Target.ITEM: return getItemStr(t); @@ -44,6 +43,9 @@ public class LoggerUtils { private static String getItemStr(Target t) { String typeStr = ""; + if (t == null){ + return typeStr; + } switch(t.itemType){ case LauncherLogProto.APP_ICON: typeStr = "ICON"; break; case LauncherLogProto.SHORTCUT: typeStr = "SHORTCUT"; break; @@ -58,6 +60,9 @@ public class LoggerUtils { } private static String getControlStr(Target t) { + if (t == null){ + return ""; + } switch(t.controlType) { case LauncherLogProto.ALL_APPS_BUTTON: return "ALL_APPS_BUTTON"; case LauncherLogProto.WIDGETS_BUTTON: return "WIDGETS_BUTTON"; @@ -72,8 +77,10 @@ public class LoggerUtils { } private static String getContainerStr(LauncherLogProto.Target t) { - String str; - Log.d(TAG, "t.containerType" + t.containerType); + String str = ""; + if (t == null) { + return str; + } switch (t.containerType) { case LauncherLogProto.WORKSPACE: str = "WORKSPACE"; @@ -122,4 +129,18 @@ public class LoggerUtils { event.action.type = actionType; return event; } + + public static LauncherLogProto.LauncherEvent initLauncherEvent( + int actionType, + int childTargetType){ + LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent(); + + event.srcTarget = new LauncherLogProto.Target[1]; + event.srcTarget[0] = new LauncherLogProto.Target(); + event.srcTarget[0].type = childTargetType; + + event.action = new LauncherLogProto.Action(); + event.action.type = actionType; + return event; + } } diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 0deee57ca..f67f48791 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -37,8 +37,8 @@ import java.util.Locale; public class UserEventDispatcher { private static final boolean DEBUG_LOGGING = false; - private final static int MAXIMUM_VIEW_HIERARCHY_LEVEL = 5; + /** * Implemented by containers to provide a launch source for a given child. */ @@ -46,10 +46,11 @@ public class UserEventDispatcher { /** * Copies data from the source to the destination proto. - * @param v source of the data - * @param info source of the data - * @param target dest of the data - * @param targetParent dest of the data + * + * @param v source of the data + * @param info source of the data + * @param target dest of the data + * @param targetParent dest of the data */ void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent); } @@ -126,12 +127,23 @@ public class UserEventDispatcher { dispatchUserEvent(createLauncherEvent(v, intent), intent); } - public void logTap(View v) { - // TODO + public void logActionOnControl(int action, int controlType) { + LauncherEvent event = LoggerUtils.initLauncherEvent(Action.TOUCH, Target.CONTROL); + event.action.touch = action; + event.srcTarget[0].controlType = controlType; + event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis; + event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis; + dispatchUserEvent(event, null); } - public void logLongPress() { - // TODO + public void logActionOnContainer(int action, int dir, int containerType) { + LauncherEvent event = LoggerUtils.initLauncherEvent(Action.TOUCH, Target.CONTAINER); + event.action.touch = action; + event.action.dir = dir; + event.srcTarget[0].containerType = containerType; + event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis; + event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis; + dispatchUserEvent(event, null); } public void logDragNDrop() { @@ -152,7 +164,6 @@ public class UserEventDispatcher { public final void resetElapsedSessionMillis() { mElapsedSessionMillis = System.currentTimeMillis(); mElapsedContainerMillis = System.currentTimeMillis(); - } public final void resetActionDurationMillis() { @@ -164,8 +175,8 @@ public class UserEventDispatcher { Log.d("UserEvent", String.format(Locale.US, "action:%s\nchild:%s\nparent:%s\nelapsed container %d ms session %d ms", LoggerUtils.getActionStr(ev.action), - LoggerUtils.getTargetStr(ev.srcTarget[0]), - LoggerUtils.getTargetStr(ev.srcTarget[1]), + LoggerUtils.getTargetStr(ev.srcTarget != null ? ev.srcTarget[0] : null), + LoggerUtils.getTargetStr(ev.srcTarget.length > 1 ? ev.srcTarget[1] : null), ev.elapsedContainerMillis, ev.elapsedSessionMillis)); } |