Add getUserEventLogger to LauncherCallbacks
b/26494415

Change-Id: I8abaaf1269c12435a523e31bf769991018ea5c02
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index fc828da..752567b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -82,7 +82,6 @@
 import android.view.View.OnClickListener;
 import android.view.View.OnLongClickListener;
 import android.view.ViewGroup;
-import android.view.ViewStub;
 import android.view.ViewTreeObserver;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
@@ -109,8 +108,10 @@
 import com.android.launcher3.dragndrop.DragView;
 import com.android.launcher3.folder.Folder;
 import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.logging.UserEventLogger;
 import com.android.launcher3.model.WidgetsModel;
-import com.android.launcher3.userevent.Logger;
+import com.android.launcher3.logging.LoggerUtils;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
 import com.android.launcher3.util.ComponentKey;
 import com.android.launcher3.util.LongArrayMap;
 import com.android.launcher3.util.TestingUtils;
@@ -131,6 +132,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * Default launcher application.
@@ -366,7 +368,7 @@
     }
 
     private Stats mStats;
-    private Logger mUserEventLogger;
+    private UserEventLogger mUserEventLogger;
 
     public FocusIndicatorView mFocusHandler;
     private boolean mRotationEnabled = false;
@@ -425,8 +427,8 @@
         mDragController = new DragController(this);
         mStateTransitionAnimation = new LauncherStateTransitionAnimation(this);
 
-        mUserEventLogger = new Logger(this);
         mStats = new Stats(this);
+        initLogger();
 
         mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);
 
@@ -536,7 +538,7 @@
             private boolean mWorkspaceImportanceStored = false;
             private boolean mHotseatImportanceStored = false;
             private int mWorkspaceImportanceForAccessibility =
-                View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
+                    View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
             private int mHotseatImportanceForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
 
             @Override
@@ -632,7 +634,35 @@
     public Stats getStats() {
         return mStats;
     }
-    public Logger getLogger() {return mUserEventLogger; }
+
+    /**
+     * Logger object is a singleton and does not have to be coupled with the foreground activity.
+     * Since most user event logging is done on the UI, the object is retrieved from the
+     * callback for convenience.
+     */
+    private void initLogger() {
+        if (mLauncherCallbacks != null) {
+            mUserEventLogger = mLauncherCallbacks.getLogger();
+        }
+        if (mUserEventLogger == null) {
+            mUserEventLogger = new UserEventLogger() {
+                @Override
+                public void processEvent(LauncherLogProto.LauncherEvent ev) {
+                    if (ev.action.touch == LauncherLogProto.Action.TAP && ev.srcTarget.itemType == LauncherLogProto.APP_ICON) {
+                        Log.d(TAG, String.format(Locale.US, "action:%s target:%s\n\telapsed container %d ms session %d ms",
+                                LoggerUtils.getActionStr(ev.action),
+                                LoggerUtils.getTargetStr(ev.srcTarget),
+                                ev.elapsedContainerMillis,
+                                ev.elapsedSessionMillis));
+                    }
+                }
+            };
+        }
+    }
+
+    public UserEventLogger getLogger() {
+        return mUserEventLogger;
+    }
 
     public boolean isDraggingEnabled() {
         // We prevent dragging when we are loading the workspace as it is possible to pick up a view
@@ -3302,7 +3332,6 @@
             getWindow().getDecorView()
                     .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
         }
-        mUserEventLogger.resetElapsedContainerMillis();
         return changed;
     }
 
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index 0be45c3..fc7ff70 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -8,6 +8,7 @@
 import android.view.View;
 import android.view.ViewGroup;
 import com.android.launcher3.allapps.AllAppsSearchBarController;
+import com.android.launcher3.logging.UserEventLogger;
 import com.android.launcher3.util.ComponentKey;
 
 import java.io.FileDescriptor;
@@ -97,6 +98,7 @@
     /*
      * Extensions points for adding / replacing some other aspects of the Launcher experience.
      */
+    public UserEventLogger getLogger();
     public Intent getFirstRunActivity();
     public boolean hasFirstRunActivity();
     public boolean hasDismissableIntroScreen();
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 54945be..303785d 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -148,6 +148,7 @@
             }
             @Override
             void onTransitionComplete() {
+                mLauncher.getLogger().resetElapsedContainerMillis();
                 if (startSearchAfterTransition) {
                     toView.startAppsSearch();
                 }
@@ -167,7 +168,12 @@
         final View buttonView = mLauncher.getWidgetsButton();
         mCurrentAnimation = startAnimationToOverlay(fromWorkspaceState,
                 Workspace.State.OVERVIEW_HIDDEN, buttonView, toView, animated,
-                new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS));
+                new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS){
+                    @Override
+                    void onTransitionComplete() {
+                        mLauncher.getLogger().resetElapsedContainerMillis();
+                    }
+                });
     }
 
     /**
@@ -462,6 +468,10 @@
                     }
                 };
             }
+            @Override
+            void onTransitionComplete() {
+                mLauncher.getLogger().resetElapsedContainerMillis();
+            }
         };
         // Only animate the search bar if animating to spring loaded mode from all apps
         mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState, toWorkspaceState,
@@ -488,6 +498,10 @@
                     }
                 };
             }
+            @Override
+            void onTransitionComplete() {
+                mLauncher.getLogger().resetElapsedContainerMillis();
+            }
         };
         mCurrentAnimation = startAnimationToWorkspaceFromOverlay(
                 fromWorkspaceState, toWorkspaceState,
diff --git a/src/com/android/launcher3/Stats.java b/src/com/android/launcher3/Stats.java
index 2873828..fdb2ff4 100644
--- a/src/com/android/launcher3/Stats.java
+++ b/src/com/android/launcher3/Stats.java
@@ -26,7 +26,6 @@
 import android.view.ViewParent;
 
 import com.android.launcher3.config.ProviderConfig;
-import com.android.launcher3.userevent.Logger;
 
 public class Stats {
 
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 07bbc46..9d5afb4 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -47,7 +47,6 @@
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.Workspace;
-import com.android.launcher3.userevent.Logger;
 import com.android.launcher3.util.ComponentKey;
 
 import java.nio.charset.Charset;
@@ -313,7 +312,6 @@
                 icon.getMeasuredHeight());
 
         updateBackgroundAndPaddings();
-        mLauncher.getLogger().resetElapsedContainerMillis();
     }
 
     @Override
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java
new file mode 100644
index 0000000..4b30384
--- /dev/null
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -0,0 +1,117 @@
+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.Stats;
+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}.
+ * Note: switch statement cannot be replaced with reflection as proguard strips the constants
+ */
+public class LoggerUtils {
+    private static final String TAG = "LoggerUtils";
+    private static final boolean DEBUG = false;
+
+    static int getContainerType(ShortcutInfo shortcut) {
+        switch ((int) shortcut.container) {
+            case LauncherSettings.Favorites.CONTAINER_DESKTOP: return LauncherLogProto.WORKSPACE;
+            case LauncherSettings.Favorites.CONTAINER_HOTSEAT: return LauncherLogProto.HOTSEAT;
+            default:
+                return (int) shortcut.container;
+        }
+    }
+
+    public static String getActionStr(LauncherLogProto.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";
+            default: return "UNKNOWN";
+        }
+    }
+
+    public static String getTargetStr(Target t) {
+        String typeStr;
+        switch (t.type) {
+            case Target.ITEM:
+                return getItemStr(t);
+            case Target.CONTROL:
+                return getControlStr(t);
+            case Target.CONTAINER:
+                return getContainerStr(t);
+            default:
+                return "UNKNOWN TARGET TYPE";
+        }
+    }
+
+    private static String getItemStr(Target t) {
+        String typeStr = "";
+        switch(t.itemType){
+            case LauncherLogProto.APP_ICON: typeStr = "ICON"; break;
+            case LauncherLogProto.SHORTCUT: typeStr = "SHORTCUT"; break;
+            case LauncherLogProto.WIDGET: typeStr = "WIDGET"; break;
+            default: typeStr = "UNKNOWN";
+        }
+
+        return typeStr + " " + t.packageNameHash + " grid=(" + t.gridX + "," + t.gridY + ") "
+                + getContainerStr(t.parent);
+    }
+
+    private static String getControlStr(Target t) {
+        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";
+            case LauncherLogProto.FAST_SCROLL_HANDLE: return "FAST_SCROLL_HANDLE";
+            default: return "UNKNOWN";
+        }
+    }
+
+    private static String getContainerStr(LauncherLogProto.Target t) {
+        String str;
+        Log.d(TAG, "t.containerType" + t.containerType);
+        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;
+            default:
+                str = "UNKNOWN";
+        }
+        return str + " id=" + t.pageIndex;
+    }
+}
diff --git a/src/com/android/launcher3/logging/UserEventLogger.java b/src/com/android/launcher3/logging/UserEventLogger.java
index d05b683..4e5b2c1 100644
--- a/src/com/android/launcher3/logging/UserEventLogger.java
+++ b/src/com/android/launcher3/logging/UserEventLogger.java
@@ -1,4 +1,97 @@
 package com.android.launcher3.logging;
 
+import android.os.Bundle;
+import android.util.Log;
+
+import com.android.launcher3.ShortcutInfo;
+import com.android.launcher3.Stats;
+import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
+
+import java.util.Locale;
+
 public abstract class UserEventLogger {
+
+    private String TAG = "UserEventLogger";
+    private boolean DEBUG = false;
+
+    private long mElapsedContainerMillis;
+    private long mElapsedSessionMillis;
+    private long mActionDurationMillis;
+
+
+    public final void logAppLaunch(String provider, ShortcutInfo shortcut, Bundle bundle) {
+        if (FeatureFlags.LAUNCHER3_LEGACY_LOGGING) return;
+
+        LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent();
+        event.action = new LauncherLogProto.Action();
+        event.action.type = LauncherLogProto.Action.TOUCH;
+        event.action.touch = LauncherLogProto.Action.TAP;
+
+        event.srcTarget = new LauncherLogProto.Target();
+        event.srcTarget.type = LauncherLogProto.Target.ITEM;
+        event.srcTarget.itemType = LauncherLogProto.APP_ICON;
+        // TODO: package hash name should be different per device.
+        event.srcTarget.packageNameHash = provider.hashCode();
+
+        event.srcTarget.parent = new LauncherLogProto.Target();
+        String subContainer = bundle.getString(Stats.SOURCE_EXTRA_SUB_CONTAINER);
+
+        if (shortcut != null) {
+            event.srcTarget.parent.containerType = LoggerUtils.getContainerType(shortcut);
+            event.srcTarget.pageIndex = (int) shortcut.screenId;
+            event.srcTarget.gridX = shortcut.cellX;
+            event.srcTarget.gridX = shortcut.cellY;
+        }
+        if (subContainer != null) {
+            event.srcTarget.parent.type = LauncherLogProto.Target.CONTAINER;
+            if (subContainer.equals(Stats.SUB_CONTAINER_FOLDER)) {
+                event.srcTarget.parent.containerType = LauncherLogProto.FOLDER;
+            } else if (subContainer.equals(Stats.SUB_CONTAINER_ALL_APPS_A_Z)) {
+                event.srcTarget.parent.containerType = LauncherLogProto.ALLAPPS;
+            } else if (subContainer.equals(Stats.CONTAINER_HOTSEAT)) {
+                event.srcTarget.parent.containerType = LauncherLogProto.HOTSEAT;
+            } else if (subContainer.equals(Stats.SUB_CONTAINER_ALL_APPS_PREDICTION)) {
+                event.srcTarget.parent.containerType = LauncherLogProto.PREDICTION;
+            }
+
+            if (DEBUG) {
+                Log.d(TAG, String.format("parent bundle: %s %s %s %s",
+                        bundle.getString(Stats.SOURCE_EXTRA_CONTAINER),
+                        bundle.getString(Stats.SOURCE_EXTRA_CONTAINER_PAGE),
+                        bundle.getString(Stats.SOURCE_EXTRA_SUB_CONTAINER),
+                        bundle.getString(Stats.SOURCE_EXTRA_SUB_CONTAINER_PAGE)));
+            }
+        }
+        event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
+        event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
+        processEvent(event);
+    }
+
+    /**
+     * Currently logs following containers: workspace, allapps, widget tray.
+     */
+    public final void resetElapsedContainerMillis() {
+        mElapsedContainerMillis = System.currentTimeMillis();
+        if(DEBUG) {
+            Log.d(TAG, "resetElapsedContainerMillis " + mElapsedContainerMillis);
+        }
+    }
+
+    public final void resetElapsedSessionMillis() {
+        mElapsedSessionMillis = System.currentTimeMillis();
+        mElapsedContainerMillis = System.currentTimeMillis();
+        if(DEBUG) {
+            Log.d(TAG, "resetElapsedSessionMillis " + mElapsedSessionMillis);
+        }
+    }
+
+    public final void resetActionDurationMillis() {
+        mActionDurationMillis = System.currentTimeMillis();
+        if(DEBUG) {
+            Log.d(TAG, "resetElapsedContainerMillis " + mElapsedContainerMillis);
+        }
+    }
+
+    public abstract void processEvent(LauncherLogProto.LauncherEvent ev);
 }
\ No newline at end of file
diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
index 475762f..d5a340d 100644
--- a/src/com/android/launcher3/testing/LauncherExtension.java
+++ b/src/com/android/launcher3/testing/LauncherExtension.java
@@ -11,6 +11,7 @@
 import com.android.launcher3.AppInfo;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherCallbacks;
+import com.android.launcher3.logging.UserEventLogger;
 import com.android.launcher3.allapps.AllAppsSearchBarController;
 import com.android.launcher3.util.ComponentKey;
 
@@ -225,6 +226,9 @@
         }
 
         @Override
+        public UserEventLogger getLogger() { return null; }
+
+        @Override
         public View getQsbBar() {
             return null;
         }
diff --git a/src/com/android/launcher3/userevent/Logger.java b/src/com/android/launcher3/userevent/Logger.java
deleted file mode 100644
index ae9041a..0000000
--- a/src/com/android/launcher3/userevent/Logger.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.android.launcher3.userevent;
-
-import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.LauncherSettings;
-import com.android.launcher3.Stats;
-import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
-import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.util.Log;
-
-import java.util.Locale;
-
-/**
- * Creates {@LauncherLogProto} nano protobuf object that can be used for user event
- * metrics analysis.
- */
-public class Logger {
-
-    private static final String TAG = "UserEventLogger";
-    private static final boolean DEBUG = false;
-
-    private long mActionDurationMillis;
-    private long mElapsedContainerMillis;
-    private long mElapsedSessionMillis;
-
-    private Context mContext;
-
-    public Logger(Context context) {
-        mContext = context;
-    }
-
-    public void logAppLaunch(String provider, ShortcutInfo shortcut, Bundle bundle) {
-        LauncherEvent event = new LauncherEvent();
-        event.action = new Action();
-        event.action.type = Action.TOUCH;
-        event.action.touch = Action.TAP;
-
-        event.srcTarget = new Target();
-        event.srcTarget.type = Target.ITEM;
-        event.srcTarget.itemType = LauncherLogProto.APP_ICON;
-        // TODO: package hash name should be different per device.
-        event.srcTarget.packageNameHash = provider.hashCode();
-
-        event.srcTarget.parent = new Target();
-        String subContainer = bundle.getString(Stats.SOURCE_EXTRA_SUB_CONTAINER);
-
-        if (shortcut != null) {
-            event.srcTarget.parent.containerType = getContainerType(shortcut);
-            event.srcTarget.pageIndex = (int) shortcut.screenId;
-            event.srcTarget.gridX = shortcut.cellX;
-            event.srcTarget.gridX = shortcut.cellY;
-        }
-        if (subContainer != null) {
-            event.srcTarget.parent.type = Target.CONTAINER;
-            if (subContainer.equals(Stats.SUB_CONTAINER_FOLDER)) {
-                event.srcTarget.parent.containerType = LauncherLogProto.FOLDER;
-            } else if (subContainer.equals(Stats.SUB_CONTAINER_ALL_APPS_A_Z)) {
-                event.srcTarget.parent.containerType = LauncherLogProto.ALLAPPS;
-            } else if (subContainer.equals(Stats.CONTAINER_HOTSEAT)) {
-                event.srcTarget.parent.containerType = LauncherLogProto.HOTSEAT;
-            } else if (subContainer.equals(Stats.SUB_CONTAINER_ALL_APPS_PREDICTION)) {
-                event.srcTarget.parent.containerType = LauncherLogProto.PREDICTION;
-            }
-
-            if (DEBUG) {
-                Log.d(TAG, String.format("parent bundle: %s %s %s %s",
-                        bundle.getString(Stats.SOURCE_EXTRA_CONTAINER),
-                        bundle.getString(Stats.SOURCE_EXTRA_CONTAINER_PAGE),
-                        bundle.getString(Stats.SOURCE_EXTRA_SUB_CONTAINER),
-                        bundle.getString(Stats.SOURCE_EXTRA_SUB_CONTAINER_PAGE)));
-            }
-        }
-
-
-        // Assign timeToAction
-        event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
-        event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
-
-        // Debug
-        processLauncherEvent(event);
-    }
-
-    public void resetElapsedContainerMillis() {
-        mElapsedContainerMillis = System.currentTimeMillis();
-    }
-
-    public void resetElapsedSessionMillis() {
-        mElapsedSessionMillis = System.currentTimeMillis();
-    }
-
-    //
-    // 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
-
-    private static void processLauncherEvent(LauncherEvent ev) {
-        if (DEBUG) {
-            if (ev.action.touch == Action.TAP && ev.srcTarget.itemType == LauncherLogProto.APP_ICON) {
-                Log.d(TAG, String.format(Locale.US, "action:%s target:%s\n\telapsed container %d ms session %d ms",
-                        getActionStr(ev.action),
-                        getTargetStr(ev.srcTarget),
-                        ev.elapsedContainerMillis,
-                        ev.elapsedSessionMillis));
-            }
-        }
-    }
-
-    private static int getContainerType(ShortcutInfo shortcut) {
-        switch ((int) shortcut.container) {
-            case LauncherSettings.Favorites.CONTAINER_DESKTOP: return LauncherLogProto.WORKSPACE;
-            case LauncherSettings.Favorites.CONTAINER_HOTSEAT: return LauncherLogProto.HOTSEAT;
-            default:
-                return (int) shortcut.container;
-        }
-    }
-
-    private static String getActionStr(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";
-            default: return "UNKNOWN";
-        }
-    }
-
-    private static String getTargetStr(Target t) {
-        String typeStr;
-        switch (t.type) {
-            case LauncherLogProto.Target.ITEM:
-                return getItemStr(t);
-            case LauncherLogProto.Target.CONTROL:
-                return getControlStr(t);
-            case LauncherLogProto.Target.CONTAINER:
-                return getContainerStr(t);
-            default:
-                return "UNKNOWN TARGET TYPE";
-        }
-    }
-
-    private static String getItemStr(Target t) {
-        String typeStr = "";
-        switch(t.itemType){
-            case LauncherLogProto.APP_ICON: typeStr = "ICON"; break;
-            case LauncherLogProto.SHORTCUT: typeStr = "SHORTCUT"; break;
-            case LauncherLogProto.WIDGET: typeStr = "WIDGET"; break;
-            default: typeStr = "UNKNOWN";
-        }
-
-        return typeStr + " " + t.packageNameHash + " grid=(" + t.gridX + "," + t.gridY + ") "
-                + getContainerStr(t.parent);
-    }
-
-    private static String getControlStr(Target t) {
-        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";
-            case LauncherLogProto.FAST_SCROLL_HANDLE: return "FAST_SCROLL_HANDLE";
-            default: return "UNKNOWN";
-        }
-    }
-
-    private static String getContainerStr(Target t) {
-        String str;
-        Log.d(TAG, "t.containerType" + t.containerType);
-        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;
-            default:
-                str = "UNKNOWN";
-        }
-        return str + " id=" + t.pageIndex;
-    }
-}
-