summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/logging
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-08-15 16:22:20 -0700
committerHyunyoung Song <hyunyoungs@google.com>2016-08-15 16:22:20 -0700
commit8ce6063c4a5bd90810f0a21c946e5bbad3ce9de4 (patch)
tree7579e484f8666028576a1b5140a8ee8d1fa6761f /src/com/android/launcher3/logging
parentc9a0a7c62f92bf54f5d63202fd85f1125d72df21 (diff)
downloadandroid_packages_apps_Trebuchet-8ce6063c4a5bd90810f0a21c946e5bbad3ce9de4.tar.gz
android_packages_apps_Trebuchet-8ce6063c4a5bd90810f0a21c946e5bbad3ce9de4.tar.bz2
android_packages_apps_Trebuchet-8ce6063c4a5bd90810f0a21c946e5bbad3ce9de4.zip
Set launch source target correctly for user event logging
Before, everything is set to APP_ICON With this changed, pinned shortcuts are set to DEEPSHORTCUT Change-Id: I3e17de63f58693525236290ef5cb1f909f1d6098
Diffstat (limited to 'src/com/android/launcher3/logging')
-rw-r--r--src/com/android/launcher3/logging/LoggerUtils.java61
-rw-r--r--src/com/android/launcher3/logging/UserEventDispatcher.java38
2 files changed, 75 insertions, 24 deletions
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java
index aad266b7b..dc045977d 100644
--- a/src/com/android/launcher3/logging/LoggerUtils.java
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -1,5 +1,9 @@
package com.android.launcher3.logging;
+import android.view.View;
+
+import com.android.launcher3.ItemInfo;
+import com.android.launcher3.LauncherSettings;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -47,17 +51,25 @@ public class LoggerUtils {
return typeStr;
}
switch(t.itemType){
- case LauncherLogProto.APP_ICON: typeStr = "ICON"; break;
+ case LauncherLogProto.APP_ICON: typeStr = "APPICON"; break;
case LauncherLogProto.SHORTCUT: typeStr = "SHORTCUT"; break;
case LauncherLogProto.WIDGET: typeStr = "WIDGET"; break;
case LauncherLogProto.DEEPSHORTCUT: typeStr = "DEEPSHORTCUT"; break;
+ case LauncherLogProto.FOLDER_ICON: typeStr = "FOLDERICON"; break;
+
default: typeStr = "UNKNOWN";
}
- return typeStr + ", packageHash=" + t.packageNameHash
- + ", componentHash=" + t.componentHash
- + ", intentHash=" + t.intentHash
- + ", grid=(" + t.gridX + "," + t.gridY + "), id=" + t.pageIndex;
+ if (t.packageNameHash != 0) {
+ typeStr += ", packageHash=" + t.packageNameHash;
+ }
+ if (t.componentHash != 0) {
+ typeStr += ", componentHash=" + t.componentHash;
+ }
+ if (t.intentHash != 0) {
+ typeStr += ", intentHash=" + t.intentHash;
+ }
+ return typeStr += ", grid=(" + t.gridX + "," + t.gridY + "), id=" + t.pageIndex;
}
private static String getControlStr(Target t) {
@@ -116,16 +128,17 @@ public class LoggerUtils {
return str + " id=" + t.pageIndex;
}
-
+ /**
+ * Used for launching an event by tapping on an icon.
+ */
public static LauncherLogProto.LauncherEvent initLauncherEvent(
int actionType,
- int childTargetType,
+ View v,
int parentTargetType){
LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent();
event.srcTarget = new LauncherLogProto.Target[2];
- event.srcTarget[0] = new LauncherLogProto.Target();
- event.srcTarget[0].type = childTargetType;
+ event.srcTarget[0] = initTarget(v);
event.srcTarget[1] = new LauncherLogProto.Target();
event.srcTarget[1].type = parentTargetType;
@@ -134,6 +147,9 @@ public class LoggerUtils {
return event;
}
+ /**
+ * Used for clicking on controls and buttons.
+ */
public static LauncherLogProto.LauncherEvent initLauncherEvent(
int actionType,
int childTargetType){
@@ -147,4 +163,31 @@ public class LoggerUtils {
event.action.type = actionType;
return event;
}
+
+ private static Target initTarget(View v) {
+ Target t = new LauncherLogProto.Target();
+ t.type = Target.ITEM;
+ if (!(v.getTag() instanceof ItemInfo)) {
+ return t;
+ }
+ ItemInfo itemInfo = (ItemInfo) v.getTag();
+ switch (itemInfo.itemType) {
+ case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
+ t.itemType = LauncherLogProto.APP_ICON;
+ break;
+ case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
+ t.itemType = LauncherLogProto.SHORTCUT;
+ break;
+ case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
+ t.itemType = LauncherLogProto.FOLDER_ICON;
+ break;
+ case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
+ t.itemType = LauncherLogProto.WIDGET;
+ break;
+ case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
+ t.itemType = LauncherLogProto.DEEPSHORTCUT;
+ break;
+ }
+ return t;
+ }
}
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 64a5f573d..e4cc182cf 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -97,13 +97,16 @@ public class UserEventDispatcher {
protected LauncherEvent createLauncherEvent(View v, Intent intent) {
LauncherEvent event = LoggerUtils.initLauncherEvent(
- Action.TOUCH, Target.ITEM, Target.CONTAINER);
+ Action.TOUCH, v, Target.CONTAINER);
event.action.touch = Action.TAP;
// Fill in grid(x,y), pageIndex of the child and container type of the parent
// TODO: make this percolate up the view hierarchy if needed.
int idx = 0;
LaunchSourceProvider provider = getLaunchProviderRecursive(v);
+ if (!(v.getTag() instanceof ItemInfo)) {
+ return null;
+ }
ItemInfo itemInfo = (ItemInfo) v.getTag();
provider.fillInLaunchSourceData(v, itemInfo, event.srcTarget[idx], event.srcTarget[idx + 1]);
@@ -125,7 +128,11 @@ public class UserEventDispatcher {
}
public void logAppLaunch(View v, Intent intent) {
- dispatchUserEvent(createLauncherEvent(v, intent), intent);
+ LauncherEvent ev = createLauncherEvent(v, intent);
+ if (ev == null) {
+ return;
+ }
+ dispatchUserEvent(ev, intent);
}
public void logActionOnControl(int action, int controlType) {
@@ -149,21 +156,19 @@ public class UserEventDispatcher {
public void logDeepShortcutsOpen(View icon) {
LauncherEvent event = LoggerUtils.initLauncherEvent(
- Action.TOUCH, Target.ITEM, Target.CONTAINER);
+ Action.TOUCH, icon, Target.CONTAINER);
LaunchSourceProvider provider = getLaunchProviderRecursive(icon);
+ if (!(icon.getTag() instanceof ItemInfo)) {
+ return;
+ }
ItemInfo info = (ItemInfo) icon.getTag();
provider.fillInLaunchSourceData(icon, info, event.srcTarget[0], event.srcTarget[1]);
- event.srcTarget[0].itemType = LauncherLogProto.DEEPSHORTCUT;
event.action.touch = Action.LONGPRESS;
event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
dispatchUserEvent(event, null);
}
- public void logDragNDrop() {
- // TODO
- }
-
public void setPredictedApps(List<ComponentKey> predictedApps) {
mPredictedApps = predictedApps;
}
@@ -187,17 +192,20 @@ public class UserEventDispatcher {
public void dispatchUserEvent(LauncherEvent ev, Intent intent) {
if (DEBUG_LOGGING) {
Log.d(TAG, String.format(Locale.US,
- "action:%s\nchild:%s\nparent:%s\nelapsed container %d ms session %d ms",
+ "\naction:%s\n Source child:%s\tparent:%s",
LoggerUtils.getActionStr(ev.action),
LoggerUtils.getTargetStr(ev.srcTarget != null ? ev.srcTarget[0] : null),
- LoggerUtils.getTargetStr(ev.srcTarget.length > 1 ? ev.srcTarget[1] : null),
+ LoggerUtils.getTargetStr(ev.srcTarget.length > 1 ? ev.srcTarget[1] : null)));
+ if (ev.destTarget != null && ev.destTarget.length > 0) {
+ Log.d(TAG, String.format(Locale.US,
+ " Destination child:%s\tparent:%s",
+ LoggerUtils.getTargetStr(ev.destTarget != null ? ev.destTarget[0] : null),
+ LoggerUtils.getTargetStr(ev.destTarget.length > 1 ? ev.destTarget[1] : null)));
+ }
+ Log.d(TAG, String.format(Locale.US,
+ " Elapsed container %d ms session %d ms",
ev.elapsedContainerMillis,
ev.elapsedSessionMillis));
}
}
-
- public int getPredictedRank(ComponentKey key) {
- if (mPredictedApps == null) return -1;
- return mPredictedApps.indexOf(key);
- }
}