summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk3
-rw-r--r--build.gradle1
-rw-r--r--proguard.flags3
-rw-r--r--src/com/android/launcher3/Hotseat.java4
-rw-r--r--src/com/android/launcher3/Launcher.java54
-rw-r--r--src/com/android/launcher3/OverviewButtonClickListener.java8
-rw-r--r--src/com/android/launcher3/PinchAnimationManager.java11
-rw-r--r--src/com/android/launcher3/Workspace.java18
-rw-r--r--src/com/android/launcher3/allapps/AllAppsRecyclerView.java8
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java14
-rw-r--r--src/com/android/launcher3/folder/Folder.java4
-rw-r--r--src/com/android/launcher3/logging/LoggerUtils.java192
-rw-r--r--src/com/android/launcher3/logging/UserEventDispatcher.java78
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java7
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java3
-rw-r--r--src_config/com/android/launcher3/config/ProviderConfig.java2
16 files changed, 177 insertions, 233 deletions
diff --git a/Android.mk b/Android.mk
index 28beff24b..713d0828a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -41,6 +41,8 @@ LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
+
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.v7.recyclerview \
@@ -66,6 +68,7 @@ LOCAL_SRC_FILES := $(call all-proto-files-under, protos)
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := launcher_proto_lib
diff --git a/build.gradle b/build.gradle
index 4629caae3..982ae2ee4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -85,6 +85,7 @@ protobuf {
remove java
javanano {
option "java_package=launcher_log.proto|com.android.launcher3.userevent.nano"
+ option "enum_style=java"
}
}
}
diff --git a/proguard.flags b/proguard.flags
index f1a3eaf2f..6cbab08e2 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -91,3 +91,6 @@
#}
-keep class android.support.v7.widget.RecyclerView { *; }
+-keep interface com.android.launcher3.userevent.nano.LauncherLogProto.** {
+ *;
+}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 3648fb793..4a8a27278 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -38,7 +38,7 @@ import android.widget.TextView;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dynamicui.ExtractedColors;
import com.android.launcher3.logging.UserEventDispatcher;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
public class Hotseat extends FrameLayout
@@ -175,7 +175,7 @@ public class Hotseat extends FrameLayout
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
target.gridX = info.cellX;
target.gridY = info.cellY;
- targetParent.containerType = LauncherLogProto.HOTSEAT;
+ targetParent.containerType = ContainerType.HOTSEAT;
}
public void updateColor(ExtractedColors extractedColors, boolean animate) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8bb4a5b8f..75534b2f5 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -111,7 +111,9 @@ import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.shortcuts.ShortcutKey;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.util.ActivityResultInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
@@ -1350,7 +1352,7 @@ public class Launcher extends Activity
// Bind wallpaper button actions
View wallpaperButton = findViewById(R.id.wallpaper_button);
- new OverviewButtonClickListener(LauncherLogProto.WALLPAPER_BUTTON) {
+ new OverviewButtonClickListener(ControlType.WALLPAPER_BUTTON) {
@Override
public void handleViewClick(View view) {
onClickWallpaperPicker(view);
@@ -1360,7 +1362,7 @@ public class Launcher extends Activity
// Bind widget button actions
mWidgetsButton = findViewById(R.id.widget_button);
- new OverviewButtonClickListener(LauncherLogProto.WIDGETS_BUTTON) {
+ new OverviewButtonClickListener(ControlType.WIDGETS_BUTTON) {
@Override
public void handleViewClick(View view) {
onClickAddWidgetButton(view);
@@ -1372,7 +1374,7 @@ public class Launcher extends Activity
View settingsButton = findViewById(R.id.settings_button);
boolean hasSettings = hasSettings();
if (hasSettings) {
- new OverviewButtonClickListener(LauncherLogProto.SETTINGS_BUTTON) {
+ new OverviewButtonClickListener(ControlType.SETTINGS_BUTTON) {
@Override
public void handleViewClick(View view) {
onClickSettingsButton(view);
@@ -1694,13 +1696,13 @@ public class Launcher extends Activity
AbstractFloatingView topOpenView = AbstractFloatingView.getTopOpenView(this);
if (topOpenView instanceof DeepShortcutsContainer) {
- ued.logActionCommand(LauncherLogProto.Action.HOME_INTENT,
- topOpenView.getExtendedTouchView(), LauncherLogProto.DEEPSHORTCUTS);
+ ued.logActionCommand(Action.Command.HOME_INTENT,
+ topOpenView.getExtendedTouchView(), ContainerType.DEEPSHORTCUTS);
} else if (topOpenView instanceof Folder) {
- ued.logActionCommand(LauncherLogProto.Action.HOME_INTENT,
- ((Folder) topOpenView).getFolderIcon(), LauncherLogProto.FOLDER);
+ ued.logActionCommand(Action.Command.HOME_INTENT,
+ ((Folder) topOpenView).getFolderIcon(), ContainerType.FOLDER);
} else if (alreadyOnHome) {
- ued.logActionCommand(LauncherLogProto.Action.HOME_INTENT,
+ ued.logActionCommand(Action.Command.HOME_INTENT,
mWorkspace.getState().containerType, mWorkspace.getCurrentPage());
}
@@ -2216,22 +2218,22 @@ public class Launcher extends Activity
topView.getActiveTextView().dispatchBackKey();
} else {
if (topView instanceof DeepShortcutsContainer) {
- ued.logActionCommand(LauncherLogProto.Action.BACK,
- topView.getExtendedTouchView(), LauncherLogProto.DEEPSHORTCUTS);
+ ued.logActionCommand(Action.Command.BACK,
+ topView.getExtendedTouchView(), ContainerType.DEEPSHORTCUTS);
} else if (topView instanceof Folder) {
- ued.logActionCommand(LauncherLogProto.Action.BACK,
- ((Folder) topView).getFolderIcon(), LauncherLogProto.FOLDER);
+ ued.logActionCommand(Action.Command.BACK,
+ ((Folder) topView).getFolderIcon(), ContainerType.FOLDER);
}
topView.close(true);
}
} else if (isAppsViewVisible()) {
- ued.logActionCommand(LauncherLogProto.Action.BACK, LauncherLogProto.ALLAPPS);
+ ued.logActionCommand(Action.Command.BACK, ContainerType.ALLAPPS);
showWorkspace(true);
} else if (isWidgetsViewVisible()) {
- ued.logActionCommand(LauncherLogProto.Action.BACK, LauncherLogProto.WIDGETS);
+ ued.logActionCommand(Action.Command.BACK, ContainerType.WIDGETS);
showOverviewMode(true);
} else if (mWorkspace.isInOverviewMode()) {
- ued.logActionCommand(LauncherLogProto.Action.BACK, LauncherLogProto.OVERVIEW);
+ ued.logActionCommand(Action.Command.BACK, ContainerType.OVERVIEW);
showWorkspace(true);
} else {
// TODO: Log this case.
@@ -2365,8 +2367,8 @@ public class Launcher extends Activity
protected void onClickAllAppsButton(View v) {
if (LOGD) Log.d(TAG, "onClickAllAppsButton");
if (!isAppsViewVisible()) {
- getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.TAP,
- LauncherLogProto.ALL_APPS_BUTTON);
+ getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
+ ControlType.ALL_APPS_BUTTON);
showAppsView(true /* animated */, true /* updatePredictedApps */,
false /* focusSearchBar */);
}
@@ -2375,8 +2377,8 @@ public class Launcher extends Activity
protected void onLongClickAllAppsButton(View v) {
if (LOGD) Log.d(TAG, "onLongClickAllAppsButton");
if (!isAppsViewVisible()) {
- getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.LONGPRESS,
- LauncherLogProto.ALL_APPS_BUTTON);
+ getUserEventDispatcher().logActionOnControl(Action.Touch.LONGPRESS,
+ ControlType.ALL_APPS_BUTTON);
showAppsView(true /* animated */,
true /* updatePredictedApps */, true /* focusSearchBar */);
}
@@ -2759,8 +2761,8 @@ public class Launcher extends Activity
if (v instanceof Workspace) {
if (!mWorkspace.isInOverviewMode()) {
if (!mWorkspace.isTouchActive() && !ignoreLongPressToOverview) {
- getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.LONGPRESS,
- LauncherLogProto.Action.NONE, LauncherLogProto.WORKSPACE,
+ getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
+ Action.Direction.NONE, ContainerType.WORKSPACE,
mWorkspace.getCurrentPage());
showOverviewMode(true);
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
@@ -2790,14 +2792,14 @@ public class Launcher extends Activity
// User long pressed on empty space
if (mWorkspace.isInOverviewMode()) {
mWorkspace.startReordering(v);
- getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.LONGPRESS,
- LauncherLogProto.Action.NONE, LauncherLogProto.OVERVIEW);
+ getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
+ Action.Direction.NONE, ContainerType.OVERVIEW);
} else {
if (ignoreLongPressToOverview) {
return false;
}
- getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.LONGPRESS,
- LauncherLogProto.Action.NONE, LauncherLogProto.WORKSPACE,
+ getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
+ Action.Direction.NONE, ContainerType.WORKSPACE,
mWorkspace.getCurrentPage());
showOverviewMode(true);
}
diff --git a/src/com/android/launcher3/OverviewButtonClickListener.java b/src/com/android/launcher3/OverviewButtonClickListener.java
index c98f1d7bc..dd670d2a7 100644
--- a/src/com/android/launcher3/OverviewButtonClickListener.java
+++ b/src/com/android/launcher3/OverviewButtonClickListener.java
@@ -2,7 +2,7 @@ package com.android.launcher3;
import android.view.View;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
/**
* A specialized listener for Overview buttons where both clicks and long clicks are logged
@@ -11,7 +11,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto;
public abstract class OverviewButtonClickListener implements View.OnClickListener,
View.OnLongClickListener {
- private int mControlType; /** ControlType enum as defined in {@link LauncherLogProto} */
+ private int mControlType; /** ControlType enum as defined in {@link Action.Touch} */
public OverviewButtonClickListener(int controlType) {
mControlType = controlType;
@@ -25,14 +25,14 @@ public abstract class OverviewButtonClickListener implements View.OnClickListene
@Override
public void onClick(View view) {
if (shouldPerformClick(view)) {
- handleViewClick(view, LauncherLogProto.Action.TAP);
+ handleViewClick(view, Action.Touch.TAP);
}
}
@Override
public boolean onLongClick(View view) {
if (shouldPerformClick(view)) {
- handleViewClick(view, LauncherLogProto.Action.LONGPRESS);
+ handleViewClick(view, Action.Touch.LONGPRESS);
}
return true;
}
diff --git a/src/com/android/launcher3/PinchAnimationManager.java b/src/com/android/launcher3/PinchAnimationManager.java
index 41074bea0..bae246e9e 100644
--- a/src/com/android/launcher3/PinchAnimationManager.java
+++ b/src/com/android/launcher3/PinchAnimationManager.java
@@ -24,7 +24,8 @@ import android.util.Log;
import android.view.View;
import android.view.animation.LinearInterpolator;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import static com.android.launcher3.Workspace.State.NORMAL;
import static com.android.launcher3.Workspace.State.OVERVIEW;
@@ -164,14 +165,14 @@ public class PinchAnimationManager {
// Passing threshold 3 ends the pinch and snaps to the new state.
if (startState == OVERVIEW && goingTowards == NORMAL) {
mLauncher.getUserEventDispatcher().logActionOnContainer(
- LauncherLogProto.Action.PINCH, LauncherLogProto.Action.NONE,
- LauncherLogProto.OVERVIEW, mWorkspace.getCurrentPage());
+ Action.Touch.PINCH, Action.Direction.NONE,
+ ContainerType.OVERVIEW, mWorkspace.getCurrentPage());
mLauncher.showWorkspace(true);
mWorkspace.snapToPage(mWorkspace.getCurrentPage());
} else if (startState == NORMAL && goingTowards == OVERVIEW) {
mLauncher.getUserEventDispatcher().logActionOnContainer(
- LauncherLogProto.Action.PINCH, LauncherLogProto.Action.NONE,
- LauncherLogProto.WORKSPACE, mWorkspace.getCurrentPage());
+ Action.Touch.PINCH, Action.Direction.NONE,
+ ContainerType.WORKSPACE, mWorkspace.getCurrentPage());
mLauncher.showOverviewMode(true);
}
} else {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 6520a2b6f..3cfb3e1eb 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -73,7 +73,7 @@ import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.shortcuts.DeepShortcutsContainer;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LongArrayMap;
@@ -188,11 +188,11 @@ public class Workspace extends PagedView
// in all apps or customize mode)
public enum State {
- NORMAL (false, false, LauncherLogProto.WORKSPACE),
- NORMAL_HIDDEN (false, false, LauncherLogProto.ALLAPPS),
- SPRING_LOADED (false, true, LauncherLogProto.WORKSPACE),
- OVERVIEW (true, true, LauncherLogProto.OVERVIEW),
- OVERVIEW_HIDDEN (true, false, LauncherLogProto.WIDGETS);
+ NORMAL (false, false, ContainerType.WORKSPACE),
+ NORMAL_HIDDEN (false, false, ContainerType.ALLAPPS),
+ SPRING_LOADED (false, true, ContainerType.WORKSPACE),
+ OVERVIEW (true, true, ContainerType.OVERVIEW),
+ OVERVIEW_HIDDEN (true, false, ContainerType.WIDGETS);
public final boolean shouldUpdateWidget;
public final boolean hasMultipleVisiblePages;
@@ -4155,12 +4155,12 @@ public class Workspace extends PagedView
target.gridX = info.cellX;
target.gridY = info.cellY;
target.pageIndex = getCurrentPage();
- targetParent.containerType = LauncherLogProto.WORKSPACE;
+ targetParent.containerType = ContainerType.WORKSPACE;
if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
target.rank = info.rank;
- targetParent.containerType = LauncherLogProto.HOTSEAT;
+ targetParent.containerType = ContainerType.HOTSEAT;
} else if (info.container >= 0) {
- targetParent.containerType = LauncherLogProto.FOLDER;
+ targetParent.containerType = ContainerType.FOLDER;
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index ab34287eb..10d4c1506 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -29,7 +29,7 @@ import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import java.util.List;
@@ -184,7 +184,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
public int getContainerType(View v) {
if (mApps.hasFilter()) {
- return LauncherLogProto.SEARCHRESULT;
+ return ContainerType.SEARCHRESULT;
} else {
if (v instanceof BubbleTextView) {
BubbleTextView icon = (BubbleTextView) v;
@@ -193,11 +193,11 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
AlphabeticalAppsList.AdapterItem item = items.get(position);
if (item.viewType == AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON) {
- return LauncherLogProto.PREDICTION;
+ return ContainerType.PREDICTION;
}
}
}
- return LauncherLogProto.ALLAPPS;
+ return ContainerType.ALLAPPS;
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 4667806ff..99cac4193 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -27,6 +27,8 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.TouchController;
/**
@@ -225,9 +227,9 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
if (!mLauncher.isAllAppsVisible()) {
mLauncher.getUserEventDispatcher().logActionOnContainer(
- LauncherLogProto.Action.FLING,
- LauncherLogProto.Action.UP,
- LauncherLogProto.HOTSEAT);
+ Action.Touch.FLING,
+ Action.Direction.UP,
+ ContainerType.HOTSEAT);
}
mLauncher.showAppsView(true /* animated */,
false /* updatePredictedApps */,
@@ -245,9 +247,9 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
calculateDuration(velocity, Math.abs(mAppsView.getTranslationY()));
if (!mLauncher.isAllAppsVisible()) {
mLauncher.getUserEventDispatcher().logActionOnContainer(
- LauncherLogProto.Action.SWIPE,
- LauncherLogProto.Action.UP,
- LauncherLogProto.HOTSEAT);
+ Action.Touch.SWIPE,
+ Action.Direction.UP,
+ ContainerType.HOTSEAT);
}
mLauncher.showAppsView(true, /* animated */
false /* updatePredictedApps */,
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 7018811d5..52c6abc21 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -76,7 +76,7 @@ import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.pageindicators.PageIndicatorDots;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.CircleRevealOutlineProvider;
import com.android.launcher3.util.Thunk;
@@ -1448,7 +1448,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
target.gridX = info.cellX;
target.gridY = info.cellY;
target.pageIndex = mContent.getCurrentPage();
- targetParent.containerType = LauncherLogProto.FOLDER;
+ targetParent.containerType = ContainerType.FOLDER;
}
private class OnScrollHintListener implements OnAlarmListener {
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java
index f1a12ff22..c13e8b336 100644
--- a/src/com/android/launcher3/logging/LoggerUtils.java
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -1,5 +1,7 @@
package com.android.launcher3.logging;
+import android.util.ArrayMap;
+import android.util.SparseArray;
import android.view.View;
import com.android.launcher3.ButtonDropTarget;
@@ -8,81 +10,73 @@ import com.android.launcher3.InfoDropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.UninstallDropTarget;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType;
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
/**
- * Debugging helper methods.
- * toString() cannot be overriden inside auto generated {@link LauncherLogProto}.
- * Note: switch statement cannot be replaced with reflection as proguard strips the constants
+ * Helper methods for logging.
*/
public class LoggerUtils {
- private static final String TAG = "LoggerUtils";
-
- private static String getCommandStr(Action action) {
- switch (action.command) {
- case Action.HOME_INTENT: return "HOME_INTENT";
- case Action.BACK: return "BACK";
- default: return "UNKNOWN";
- }
- }
-
- private static String getTouchStr(Action action) {
- switch (action.touch) {
- case Action.TAP: return "TAP";
- 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 getActionStr(LauncherLogProto.Action action) {
+ private static final ArrayMap<Class, SparseArray<String>> sNameCache = new ArrayMap<>();
+ private static final String UNKNOWN = "UNKNOWN";
+
+ private static String getFieldName(int value, Class c) {
+ SparseArray<String> cache;
+ synchronized (sNameCache) {
+ cache = sNameCache.get(c);
+ if (cache == null) {
+ cache = new SparseArray<>();
+ for (Field f : c.getDeclaredFields()) {
+ if (f.getType() == int.class && Modifier.isStatic(f.getModifiers())) {
+ try {
+ f.setAccessible(true);
+ cache.put(f.getInt(null), f.getName());
+ } catch (IllegalAccessException e) {
+ // Ignore
+ }
+ }
+ }
+ sNameCache.put(c, cache);
+ }
+ }
+ String result = cache.get(value);
+ return result != null ? result : UNKNOWN;
+ }
+
+ public static String getActionStr(Action action) {
switch (action.type) {
- case Action.TOUCH: return getTouchStr(action);
- case Action.COMMAND: return getCommandStr(action);
- default: return "UNKNOWN";
+ case Action.Type.TOUCH: return getFieldName(action.touch, Action.Touch.class);
+ case Action.Type.COMMAND: return getFieldName(action.command, Action.Command.class);
+ default: return UNKNOWN;
}
}
public static String getTargetStr(Target t) {
- String typeStr = "";
if (t == null){
- return typeStr;
+ return "";
}
switch (t.type) {
- case Target.ITEM:
+ case Target.Type.ITEM:
return getItemStr(t);
- case Target.CONTROL:
- return getControlStr(t);
- case Target.CONTAINER:
- return getContainerStr(t);
+ case Target.Type.CONTROL:
+ return getFieldName(t.controlType, ControlType.class);
+ case Target.Type.CONTAINER:
+ return getFieldName(t.containerType, ContainerType.class)
+ + " id=" + t.pageIndex;
default:
return "UNKNOWN TARGET TYPE";
}
}
private static String getItemStr(Target t) {
- String typeStr = "";
- if (t == null){
- return typeStr;
- }
- switch(t.itemType){
- 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;
- case LauncherLogProto.SEARCHBOX: typeStr = "SEARCHBOX"; break;
- case LauncherLogProto.EDITTEXT: typeStr = "EDITTEXT"; break;
-
- default: typeStr = "UNKNOWN";
- }
-
+ String typeStr = getFieldName(t.itemType, ItemType.class);
if (t.packageNameHash != 0) {
typeStr += ", packageHash=" + t.packageNameHash;
}
@@ -95,88 +89,32 @@ public class LoggerUtils {
if (t.spanX != 0) {
typeStr += ", spanX=" + t.spanX;
}
- return typeStr += ", grid=(" + t.gridX + "," + t.gridY + "), id=" + t.pageIndex;
- }
-
- 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";
- case LauncherLogProto.WALLPAPER_BUTTON: return "WALLPAPER_BUTTON";
- case LauncherLogProto.SETTINGS_BUTTON: return "SETTINGS_BUTTON";
- case LauncherLogProto.REMOVE_TARGET: return "REMOVE_TARGET";
- case LauncherLogProto.UNINSTALL_TARGET: return "UNINSTALL_TARGET";
- case LauncherLogProto.APPINFO_TARGET: return "APPINFO_TARGET";
- case LauncherLogProto.RESIZE_HANDLE: return "RESIZE_HANDLE";
- default: return "UNKNOWN";
- }
- }
-
- private static String getContainerStr(LauncherLogProto.Target t) {
- String str = "";
- if (t == null) {
- return str;
- }
- switch (t.containerType) {
- case LauncherLogProto.WORKSPACE:
- str = "WORKSPACE";
- break;
- case LauncherLogProto.HOTSEAT:
- str = "HOTSEAT";
- break;
- case LauncherLogProto.FOLDER:
- str = "FOLDER";
- break;
- case LauncherLogProto.ALLAPPS:
- str = "ALLAPPS";
- break;
- case LauncherLogProto.WIDGETS:
- str = "WIDGETS";
- break;
- case LauncherLogProto.OVERVIEW:
- str = "OVERVIEW";
- break;
- case LauncherLogProto.PREDICTION:
- str = "PREDICTION";
- break;
- case LauncherLogProto.SEARCHRESULT:
- str = "SEARCHRESULT";
- break;
- case LauncherLogProto.DEEPSHORTCUTS:
- str = "DEEPSHORTCUTS";
- break;
- default:
- str = "UNKNOWN";
- }
- return str + " id=" + t.pageIndex;
+ return typeStr + ", grid=(" + t.gridX + "," + t.gridY + "), id=" + t.pageIndex;
}
public static Target newItemTarget(View v) {
return (v.getTag() instanceof ItemInfo)
? newItemTarget((ItemInfo) v.getTag())
- : newTarget(Target.ITEM);
+ : newTarget(Target.Type.ITEM);
}
public static Target newItemTarget(ItemInfo info) {
- Target t = newTarget(Target.ITEM);
+ Target t = newTarget(Target.Type.ITEM);
switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
- t.itemType = LauncherLogProto.APP_ICON;
+ t.itemType = ItemType.APP_ICON;
break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
- t.itemType = LauncherLogProto.SHORTCUT;
+ t.itemType = ItemType.SHORTCUT;
break;
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
- t.itemType = LauncherLogProto.FOLDER_ICON;
+ t.itemType = ItemType.FOLDER_ICON;
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
- t.itemType = LauncherLogProto.WIDGET;
+ t.itemType = ItemType.WIDGET;
break;
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
- t.itemType = LauncherLogProto.DEEPSHORTCUT;
+ t.itemType = ItemType.DEEPSHORTCUT;
break;
}
return t;
@@ -184,26 +122,26 @@ public class LoggerUtils {
public static Target newDropTarget(View v) {
if (!(v instanceof ButtonDropTarget)) {
- return newTarget(Target.CONTAINER);
+ return newTarget(Target.Type.CONTAINER);
}
- Target t = newTarget(Target.CONTROL);
+ Target t = newTarget(Target.Type.CONTROL);
if (v instanceof InfoDropTarget) {
- t.controlType = LauncherLogProto.APPINFO_TARGET;
+ t.controlType = ControlType.APPINFO_TARGET;
} else if (v instanceof UninstallDropTarget) {
- t.controlType = LauncherLogProto.UNINSTALL_TARGET;
+ t.controlType = ControlType.UNINSTALL_TARGET;
} else if (v instanceof DeleteDropTarget) {
- t.controlType = LauncherLogProto.REMOVE_TARGET;
+ t.controlType = ControlType.REMOVE_TARGET;
}
return t;
}
public static Target newTarget(int targetType) {
- Target t = new LauncherLogProto.Target();
+ Target t = new Target();
t.type = targetType;
return t;
}
public static Target newContainerTarget(int containerType) {
- Target t = newTarget(Target.CONTAINER);
+ Target t = newTarget(Target.Type.CONTAINER);
t.containerType = containerType;
return t;
}
@@ -214,18 +152,18 @@ public class LoggerUtils {
return a;
}
public static Action newCommandAction(int command) {
- Action a = newAction(Action.COMMAND);
+ Action a = newAction(Action.Type.COMMAND);
a.command = command;
return a;
}
public static Action newTouchAction(int touch) {
- Action a = newAction(Action.TOUCH);
+ Action a = newAction(Action.Type.TOUCH);
a.touch = touch;
return a;
}
public static LauncherEvent newLauncherEvent(Action action, Target... srcTargets) {
- LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent();
+ LauncherEvent event = new LauncherEvent();
event.srcTarget = srcTargets;
event.action = action;
return event;
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 4bc581938..8ded6b8f6 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -27,8 +27,8 @@ import com.android.launcher3.DropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.ProviderConfig;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.ComponentKey;
@@ -54,7 +54,9 @@ public class UserEventDispatcher {
private final static int MAXIMUM_VIEW_HIERARCHY_LEVEL = 5;
- private final boolean mIsVerbose;
+ private static final String TAG = "UserEvent";
+ private static final boolean IS_VERBOSE =
+ ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(TAG);
/**
* Implemented by containers to provide a container source for a given child.
@@ -76,8 +78,7 @@ public class UserEventDispatcher {
* Recursively finds the parent of the given child which implements IconLogInfoProvider
*/
public static LogContainerProvider getLaunchProviderRecursive(View v) {
- ViewParent parent = null;
-
+ ViewParent parent;
if (v != null) {
parent = v.getParent();
} else {
@@ -96,8 +97,6 @@ public class UserEventDispatcher {
return null;
}
- private String TAG = "UserEvent";
-
private long mElapsedContainerMillis;
private long mElapsedSessionMillis;
private long mActionDurationMillis;
@@ -105,14 +104,6 @@ public class UserEventDispatcher {
// Used for filling in predictedRank on {@link Target}s.
private List<ComponentKey> mPredictedApps;
- public UserEventDispatcher() {
- if (ProviderConfig.IS_DOGFOOD_BUILD) {
- mIsVerbose = Utilities.isPropertyEnabled(TAG);
- } else {
- mIsVerbose = false;
- }
- }
-
// APP_ICON SHORTCUT WIDGET
// --------------------------------------------------------------
// packageNameHash required optional required
@@ -121,8 +112,8 @@ public class UserEventDispatcher {
// --------------------------------------------------------------
protected LauncherEvent createLauncherEvent(View v, Intent intent) {
- LauncherEvent event = newLauncherEvent(newTouchAction(Action.TAP),
- newItemTarget(v), newTarget(Target.CONTAINER));
+ LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP),
+ newItemTarget(v), newTarget(Target.Type.CONTAINER));
// TODO: make idx percolate up the view hierarchy if needed.
int idx = 0;
@@ -176,20 +167,21 @@ public class UserEventDispatcher {
* TODO: Make this function work when a container view is passed as the 2nd param.
*/
public void logActionCommand(int command, View itemView, int containerType) {
- LauncherEvent event = newLauncherEvent(
- newCommandAction(command), newItemTarget(itemView), newTarget(Target.CONTAINER));
+ LauncherEvent event = newLauncherEvent(newCommandAction(command),
+ newItemTarget(itemView), newTarget(Target.Type.CONTAINER));
if (fillInLogContainerData(event, itemView)) {
// TODO: Remove the following two lines once fillInLogContainerData can take in a
// container view.
- event.srcTarget[0].type = Target.CONTAINER;
+ event.srcTarget[0].type = Target.Type.CONTAINER;
event.srcTarget[0].containerType = containerType;
}
dispatchUserEvent(event, null);
}
public void logActionOnControl(int action, int controlType) {
- LauncherEvent event = newLauncherEvent(newTouchAction(action), newTarget(Target.CONTROL));
+ LauncherEvent event = newLauncherEvent(
+ newTouchAction(action), newTarget(Target.Type.CONTROL));
event.srcTarget[0].controlType = controlType;
dispatchUserEvent(event, null);
}
@@ -212,8 +204,8 @@ public class UserEventDispatcher {
return;
}
ItemInfo info = (ItemInfo) icon.getTag();
- LauncherEvent event = newLauncherEvent(
- newTouchAction(Action.LONGPRESS), newItemTarget(info), newTarget(Target.CONTAINER));
+ LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.LONGPRESS),
+ newItemTarget(info), newTarget(Target.Type.CONTAINER));
provider.fillInLogContainerData(icon, info, event.srcTarget[0], event.srcTarget[1]);
dispatchUserEvent(event, null);
@@ -227,16 +219,16 @@ public class UserEventDispatcher {
/* Currently we are only interested in whether this event happens or not and don't
* care about which screen moves to where. */
public void logOverviewReorder() {
- LauncherEvent event = newLauncherEvent(newTouchAction(Action.DRAGDROP),
- newContainerTarget(LauncherLogProto.WORKSPACE),
- newContainerTarget(LauncherLogProto.OVERVIEW));
+ LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP),
+ newContainerTarget(ContainerType.WORKSPACE),
+ newContainerTarget(ContainerType.OVERVIEW));
dispatchUserEvent(event, null);
}
public void logDragNDrop(DropTarget.DragObject dragObj, View dropTargetAsView) {
- LauncherEvent event = newLauncherEvent(newTouchAction(Action.DRAGDROP),
- newItemTarget(dragObj.originalDragInfo), newTarget(Target.CONTAINER));
- event.destTarget = new LauncherLogProto.Target[] {
+ LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP),
+ newItemTarget(dragObj.originalDragInfo), newTarget(Target.Type.CONTAINER));
+ event.destTarget = new Target[] {
newItemTarget(dragObj.originalDragInfo), newDropTarget(dropTargetAsView)
};
@@ -272,26 +264,26 @@ public class UserEventDispatcher {
ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
- if (!mIsVerbose) {
+ if (!IS_VERBOSE) {
return;
}
- Log.d(TAG, String.format(Locale.US,
- "\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 != null && ev.srcTarget.length > 1 ?
- ev.srcTarget[1] : null)));
+ String log = "action:" + LoggerUtils.getActionStr(ev.action);
+ if (ev.srcTarget != null && ev.srcTarget.length > 0) {
+ log += "\n Source " + getTargetsStr(ev.srcTarget);
+ }
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 != null && ev.destTarget.length > 1 ?
- ev.destTarget[1] : null)));
+ log += "\n Destination " + getTargetsStr(ev.destTarget);
}
- Log.d(TAG, String.format(Locale.US,
- " Elapsed container %d ms session %d ms action %d ms",
+ log += String.format(Locale.US,
+ "\n Elapsed container %d ms session %d ms action %d ms",
ev.elapsedContainerMillis,
ev.elapsedSessionMillis,
- ev.actionDurationMillis));
+ ev.actionDurationMillis);
+ Log.d(TAG, log);
+ }
+
+ private static String getTargetsStr(Target[] targets) {
+ return "child:" + LoggerUtils.getTargetStr(targets[0]) +
+ (targets.length > 1 ? "\tparent:" + LoggerUtils.getTargetStr(targets[1]) : "");
}
}
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
index a2534926f..9cbd5f8f2 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
@@ -66,7 +66,8 @@ import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.graphics.TriangleShape;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import java.util.Collections;
@@ -523,9 +524,9 @@ public class DeepShortcutsContainer extends AbstractFloatingView
@Override
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
- target.itemType = LauncherLogProto.DEEPSHORTCUT;
+ target.itemType = ItemType.DEEPSHORTCUT;
// TODO: add target.rank
- targetParent.containerType = LauncherLogProto.DEEPSHORTCUTS;
+ targetParent.containerType = ContainerType.DEEPSHORTCUTS;
}
@Override
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index d0ead487a..310c1dfb9 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -46,6 +46,7 @@ import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.Thunk;
@@ -309,6 +310,6 @@ public class WidgetsContainerView extends BaseContainerView
@Override
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
- targetParent.containerType = LauncherLogProto.WIDGETS;
+ targetParent.containerType = ContainerType.WIDGETS;
}
} \ No newline at end of file
diff --git a/src_config/com/android/launcher3/config/ProviderConfig.java b/src_config/com/android/launcher3/config/ProviderConfig.java
index 1d964b1b2..491fa657a 100644
--- a/src_config/com/android/launcher3/config/ProviderConfig.java
+++ b/src_config/com/android/launcher3/config/ProviderConfig.java
@@ -20,5 +20,5 @@ public class ProviderConfig {
public static final String AUTHORITY = "com.android.launcher3.settings".intern();
- public static boolean IS_DOGFOOD_BUILD = true;
+ public static final boolean IS_DOGFOOD_BUILD = true;
}