diff options
-rw-r--r-- | src/com/android/launcher3/Hotseat.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 61 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherCallbacks.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherStateTransitionAnimation.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsRecyclerView.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/folder/Folder.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/logging/UserEventDispatcher.java (renamed from src/com/android/launcher3/logging/UserEventLogger.java) | 16 | ||||
-rw-r--r-- | src/com/android/launcher3/testing/LauncherExtension.java | 4 |
9 files changed, 55 insertions, 50 deletions
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index 1af76682f..bb70be697 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -27,12 +27,12 @@ import android.view.ViewDebug; import android.widget.FrameLayout; import android.widget.TextView; -import com.android.launcher3.logging.UserEventLogger; +import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; public class Hotseat extends FrameLayout - implements UserEventLogger.LaunchSourceProvider{ + implements UserEventDispatcher.LaunchSourceProvider{ private CellLayout mContent; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index f3f19e043..50b3d4983 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -109,7 +109,7 @@ import com.android.launcher3.dynamicui.ExtractedColors; import com.android.launcher3.folder.Folder; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.logging.LoggerUtils; -import com.android.launcher3.logging.UserEventLogger; +import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.util.ComponentKey; @@ -360,7 +360,7 @@ public class Launcher extends Activity int appWidgetId; } - private UserEventLogger mUserEventLogger; + private UserEventDispatcher mUserEventDispatcher; public FocusIndicatorView mFocusHandler; private boolean mRotationEnabled = false; @@ -419,8 +419,6 @@ public class Launcher extends Activity mDragController = new DragController(this); mStateTransitionAnimation = new LauncherStateTransitionAnimation(this); - initLogger(); - mAppWidgetManager = AppWidgetManagerCompat.getInstance(this); mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID); @@ -636,31 +634,36 @@ public class Launcher extends 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 (!DEBUG_LOGGING) { - return; - } - 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]), - ev.elapsedContainerMillis, - ev.elapsedSessionMillis)); + private UserEventDispatcher createUserEventDispatcher() { + return new UserEventDispatcher() { + @Override + public void dispatchUserEvent(LauncherLogProto.LauncherEvent ev, Intent intent) { + if (!DEBUG_LOGGING) { + return; } - }; - } + 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]), + ev.elapsedContainerMillis, + ev.elapsedSessionMillis)); + } + }; } - public UserEventLogger getLogger() { - return mUserEventLogger; + public UserEventDispatcher getUserEventDispatcher() { + if (mLauncherCallbacks != null) { + UserEventDispatcher dispatcher = mLauncherCallbacks.getUserEventDispatcher(); + if (dispatcher != null) { + return dispatcher; + } + } + + if (mUserEventDispatcher == null) { + mUserEventDispatcher = createUserEventDispatcher(); + } + return mUserEventDispatcher; } public boolean isDraggingEnabled() { @@ -990,7 +993,7 @@ public class Launcher extends Activity } super.onResume(); - mUserEventLogger.resetElapsedSessionMillis(); + getUserEventDispatcher().resetElapsedSessionMillis(); // Restore the previous launcher state if (mOnResumeState == State.WORKSPACE) { @@ -2688,7 +2691,7 @@ public class Launcher extends Activity } boolean success = startActivitySafely(v, intent, tag); - mUserEventLogger.logLaunch(v, intent); + getUserEventDispatcher().logAppLaunch(v, intent); if (success && v instanceof BubbleTextView) { mWaitingForResume = (BubbleTextView) v; @@ -3460,7 +3463,7 @@ public class Launcher extends Activity List<ComponentKey> apps = mLauncherCallbacks.getPredictedApps(); if (apps != null) { mAppsView.setPredictedApps(apps); - mUserEventLogger.setPredictedApps(apps); + getUserEventDispatcher().setPredictedApps(apps); } } } diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java index 32ecdf64e..89eef60ad 100644 --- a/src/com/android/launcher3/LauncherCallbacks.java +++ b/src/com/android/launcher3/LauncherCallbacks.java @@ -7,7 +7,7 @@ import android.view.Menu; import android.view.View; import com.android.launcher3.allapps.AllAppsSearchBarController; -import com.android.launcher3.logging.UserEventLogger; +import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.util.ComponentKey; import java.io.FileDescriptor; @@ -76,7 +76,7 @@ public interface LauncherCallbacks { /* * Extensions points for adding / replacing some other aspects of the Launcher experience. */ - public UserEventLogger getLogger(); + public UserEventDispatcher getUserEventDispatcher(); 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 c5ae9da8e..5692046fb 100644 --- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java +++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java @@ -148,7 +148,7 @@ public class LauncherStateTransitionAnimation { } @Override void onTransitionComplete() { - mLauncher.getLogger().resetElapsedContainerMillis(); + mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); if (startSearchAfterTransition) { toView.startAppsSearch(); } @@ -171,7 +171,7 @@ public class LauncherStateTransitionAnimation { new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS){ @Override void onTransitionComplete() { - mLauncher.getLogger().resetElapsedContainerMillis(); + mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); } }); } @@ -470,7 +470,7 @@ public class LauncherStateTransitionAnimation { } @Override void onTransitionComplete() { - mLauncher.getLogger().resetElapsedContainerMillis(); + mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); } }; // Only animate the search bar if animating to spring loaded mode from all apps @@ -500,7 +500,7 @@ public class LauncherStateTransitionAnimation { } @Override void onTransitionComplete() { - mLauncher.getLogger().resetElapsedContainerMillis(); + mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); } }; mCurrentAnimation = startAnimationToWorkspaceFromOverlay( diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 6b38f648c..d55e1244c 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -72,7 +72,7 @@ import com.android.launcher3.dragndrop.DragView; import com.android.launcher3.dragndrop.SpringLoadedDragController; import com.android.launcher3.folder.Folder; import com.android.launcher3.folder.FolderIcon; -import com.android.launcher3.logging.UserEventLogger; +import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.LongArrayMap; @@ -94,7 +94,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class Workspace extends PagedView implements DropTarget, DragSource, DragScroller, View.OnTouchListener, DragController.DragListener, LauncherTransitionable, ViewGroup.OnHierarchyChangeListener, - Insettable, DropTargetSource, AccessibilityDragSource, UserEventLogger.LaunchSourceProvider { + Insettable, DropTargetSource, AccessibilityDragSource, UserEventDispatcher.LaunchSourceProvider { private static final String TAG = "Launcher.Workspace"; private static boolean ENFORCE_DRAG_EVENT_ORDER = false; diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 32d444d8f..8d5ade3fe 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.DeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.logging.UserEventLogger.LaunchSourceProvider; +import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import java.util.List; diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index b6be8e04c..7dc815529 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -77,7 +77,7 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragController.DragListener; import com.android.launcher3.dragndrop.DragLayer; -import com.android.launcher3.logging.UserEventLogger.LaunchSourceProvider; +import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.Thunk; diff --git a/src/com/android/launcher3/logging/UserEventLogger.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 606d34364..89ad07515 100644 --- a/src/com/android/launcher3/logging/UserEventLogger.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -21,7 +21,6 @@ import android.view.View; import android.view.ViewParent; import com.android.launcher3.ItemInfo; -import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; @@ -29,7 +28,10 @@ import com.android.launcher3.util.ComponentKey; import java.util.List; -public abstract class UserEventLogger { +/** + * Manages the creation of {@link LauncherEvent}. + */ +public abstract class UserEventDispatcher { private final static int MAXIMUM_VIEW_HIERARCHY_LEVEL = 5; /** @@ -70,7 +72,7 @@ public abstract class UserEventLogger { return null; } - private String TAG = "UserEventLogger"; + private String TAG = "UserEvent"; private long mElapsedContainerMillis; private long mElapsedSessionMillis; @@ -86,7 +88,7 @@ public abstract class UserEventLogger { // intentHash required // -------------------------------------------------------------- - protected LauncherEvent createLogEvent(View v) { + protected LauncherEvent createLauncherEvent(View v) { LauncherEvent event = LoggerUtils.initLauncherEvent( Action.TOUCH, Target.ITEM, Target.CONTAINER); event.action.touch = Action.TAP; @@ -105,8 +107,8 @@ public abstract class UserEventLogger { return event; } - public void logLaunch(View v, Intent intent) { - processEvent(createLogEvent(v)); + public void logAppLaunch(View v, Intent intent) { + dispatchUserEvent(createLauncherEvent(v), intent); } public void logTap(View v) { @@ -142,7 +144,7 @@ public abstract class UserEventLogger { mActionDurationMillis = System.currentTimeMillis(); } - public abstract void processEvent(LauncherLogProto.LauncherEvent ev); + public abstract void dispatchUserEvent(LauncherEvent ev, Intent intent); public int getPredictedRank(ComponentKey key) { if (mPredictedApps == null) return -1; diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java index 0f8391cf2..8b6f5cd1f 100644 --- a/src/com/android/launcher3/testing/LauncherExtension.java +++ b/src/com/android/launcher3/testing/LauncherExtension.java @@ -12,7 +12,7 @@ import com.android.launcher3.AppInfo; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherCallbacks; import com.android.launcher3.allapps.AllAppsSearchBarController; -import com.android.launcher3.logging.UserEventLogger; +import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.util.ComponentKey; import java.io.FileDescriptor; @@ -189,7 +189,7 @@ public class LauncherExtension extends Launcher { } @Override - public UserEventLogger getLogger() { return null; } + public UserEventDispatcher getUserEventDispatcher() { return null; } @Override public View getQsbBar() { |