diff options
Diffstat (limited to 'src/com/android/launcher3')
8 files changed, 70 insertions, 18 deletions
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index e1a3ad0d6..410d590ad 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -38,11 +38,16 @@ public abstract class BaseActivity extends Activity { public final UserEventDispatcher getUserEventDispatcher() { if (mUserEventDispatcher == null) { - mUserEventDispatcher = UserEventDispatcher.get(this); + mUserEventDispatcher = UserEventDispatcher.newInstance(this, + isInMultiWindowModeCompat()); } return mUserEventDispatcher; } + public boolean isInMultiWindowModeCompat() { + return Utilities.ATLEAST_NOUGAT && isInMultiWindowMode(); + } + public static BaseActivity fromContext(Context context) { if (context instanceof BaseActivity) { return (BaseActivity) context; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 3be6225fc..0a1810a47 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -365,7 +365,7 @@ public class Launcher extends BaseActivity // Load configuration-specific DeviceProfile mDeviceProfile = app.getInvariantDeviceProfile().getDeviceProfile(this); - if (Utilities.ATLEAST_NOUGAT && isInMultiWindowMode()) { + if (isInMultiWindowModeCompat()) { Display display = getWindowManager().getDefaultDisplay(); Point mwSize = new Point(); display.getSize(mwSize); @@ -2267,6 +2267,9 @@ public class Launcher extends BaseActivity if (v instanceof Workspace) { if (mWorkspace.isInOverviewMode()) { + getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.Type.TOUCH, + LauncherLogProto.Action.Direction.NONE, + LauncherLogProto.ContainerType.OVERVIEW, mWorkspace.getCurrentPage()); showWorkspace(true); } return; diff --git a/src/com/android/launcher3/compat/ShortcutConfigActivityInfo.java b/src/com/android/launcher3/compat/ShortcutConfigActivityInfo.java index ebe95d680..4a55e8ca0 100644 --- a/src/com/android/launcher3/compat/ShortcutConfigActivityInfo.java +++ b/src/com/android/launcher3/compat/ShortcutConfigActivityInfo.java @@ -33,6 +33,7 @@ import android.util.Log; import android.widget.Toast; import com.android.launcher3.IconCache; +import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; @@ -61,6 +62,10 @@ public abstract class ShortcutConfigActivityInfo { return mUser; } + public int getItemType() { + return LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; + } + public abstract CharSequence getLabel(); public abstract Drawable getFullResIcon(IconCache cache); diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java index 629f78ab3..09592a846 100644 --- a/src/com/android/launcher3/dragndrop/AddItemActivity.java +++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java @@ -16,6 +16,11 @@ package com.android.launcher3.dragndrop; +import static com.android.launcher3.logging.LoggerUtils.newCommandAction; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; +import static com.android.launcher3.logging.LoggerUtils.newItemTarget; +import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent; + import android.annotation.TargetApi; import android.app.ActivityOptions; import android.appwidget.AppWidgetHost; @@ -32,7 +37,9 @@ import android.os.Build; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; -import android.view.View.*; +import android.view.View.DragShadowBuilder; +import android.view.View.OnLongClickListener; +import android.view.View.OnTouchListener; import com.android.launcher3.BaseActivity; import com.android.launcher3.InstallShortcutReceiver; @@ -46,6 +53,9 @@ import com.android.launcher3.compat.AppWidgetManagerCompat; import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.model.WidgetItem; import com.android.launcher3.shortcuts.ShortcutInfoCompat; +import com.android.launcher3.userevent.nano.LauncherLogProto.Action; +import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; +import com.android.launcher3.widget.PendingAddShortcutInfo; import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.WidgetHostViewLoader; import com.android.launcher3.widget.WidgetImageView; @@ -104,6 +114,12 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener mWidgetCell.setOnTouchListener(this); mWidgetCell.setOnLongClickListener(this); + + // savedInstanceState is null when the activity is created the first time (i.e., avoids + // duplicate logging during rotation) + if (savedInstanceState == null) { + logCommand(Action.Command.ENTRY); + } } @Override @@ -166,7 +182,10 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener } private void setupShortcut() { - WidgetItem item = new WidgetItem(new PinShortcutRequestActivityInfo(mRequest, this)); + PinShortcutRequestActivityInfo shortcutInfo = + new PinShortcutRequestActivityInfo(mRequest, this); + WidgetItem item = new WidgetItem(shortcutInfo); + mWidgetCell.getWidgetView().setTag(new PendingAddShortcutInfo(shortcutInfo)); mWidgetCell.applyFromCellItem(item, mApp.getWidgetCache()); mWidgetCell.ensurePreview(); } @@ -189,6 +208,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener mWidgetOptions = WidgetHostViewLoader.getDefaultOptionsForWidget(this, mPendingWidgetInfo); WidgetItem item = new WidgetItem(widgetInfo, getPackageManager(), mIdp); + mWidgetCell.getWidgetView().setTag(mPendingWidgetInfo); mWidgetCell.applyFromCellItem(item, mApp.getWidgetCache()); mWidgetCell.ensurePreview(); return true; @@ -198,6 +218,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener * Called when the cancel button is clicked. */ public void onCancelClick(View v) { + logCommand(Action.Command.CANCEL); finish(); } @@ -208,6 +229,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) { InstallShortcutReceiver.queueShortcut( new ShortcutInfoCompat(mRequest.getShortcutInfo()), this); + logCommand(Action.Command.CONFIRM); mRequest.accept(); finish(); return; @@ -235,10 +257,17 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener InstallShortcutReceiver.queueWidget(mRequest.getAppWidgetProviderInfo(this), widgetId, this); mWidgetOptions.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId); mRequest.accept(mWidgetOptions); + logCommand(Action.Command.CONFIRM); finish(); } @Override + public void onBackPressed() { + logCommand(Action.Command.BACK); + super.onBackPressed(); + } + + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_BIND_APPWIDGET) { int widgetId = data != null @@ -268,4 +297,11 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener mPendingBindWidgetId = savedInstanceState .getInt(STATE_EXTRA_WIDGET_ID, mPendingBindWidgetId); } + + private void logCommand(int command) { + getUserEventDispatcher().dispatchUserEvent(newLauncherEvent( + newCommandAction(command), + newItemTarget(mWidgetCell.getWidgetView()), + newContainerTarget(ContainerType.PINITEM)), null); + } } diff --git a/src/com/android/launcher3/dragndrop/PinItemDragListener.java b/src/com/android/launcher3/dragndrop/PinItemDragListener.java index e71477861..4b402f4ac 100644 --- a/src/com/android/launcher3/dragndrop/PinItemDragListener.java +++ b/src/com/android/launcher3/dragndrop/PinItemDragListener.java @@ -43,6 +43,7 @@ import com.android.launcher3.R; import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.folder.Folder; import com.android.launcher3.userevent.nano.LauncherLogProto; +import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.widget.PendingAddShortcutInfo; import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.PendingItemDragHelper; @@ -241,7 +242,7 @@ public class PinItemDragListener @Override public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, LauncherLogProto.Target targetParent) { - // TODO: We should probably log something + targetParent.containerType = ContainerType.PINITEM; } private void postCleanup() { diff --git a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java index 6a8c19f4b..26460d776 100644 --- a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java +++ b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java @@ -27,6 +27,7 @@ import android.os.Build; import com.android.launcher3.IconCache; import com.android.launcher3.LauncherAppState; +import com.android.launcher3.LauncherSettings; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.compat.ShortcutConfigActivityInfo; @@ -55,6 +56,11 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo { } @Override + public int getItemType() { + return LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; + } + + @Override public CharSequence getLabel() { return mInfo.getShortLabel(); } diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 90e453117..07e99c693 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -30,7 +30,6 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.R; 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; @@ -63,17 +62,11 @@ public class UserEventDispatcher { private static final boolean IS_VERBOSE = ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT); - private static UserEventDispatcher sInstance; - private static final Object LOCK = new Object(); - - public static UserEventDispatcher get(Context context) { - synchronized (LOCK) { - if (sInstance == null) { - sInstance = Utilities.getOverrideObject(UserEventDispatcher.class, - context.getApplicationContext(), R.string.user_event_dispatcher_class); - } - return sInstance; - } + public static UserEventDispatcher newInstance(Context context, boolean isInMultiWindowMode) { + UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class, + context.getApplicationContext(), R.string.user_event_dispatcher_class); + ued.mIsInMultiWindowMode = isInMultiWindowMode; + return ued; } /** @@ -118,6 +111,7 @@ public class UserEventDispatcher { private long mElapsedContainerMillis; private long mElapsedSessionMillis; private long mActionDurationMillis; + private boolean mIsInMultiWindowMode; // Used for filling in predictedRank on {@link Target}s. private List<ComponentKey> mPredictedApps; @@ -302,6 +296,7 @@ public class UserEventDispatcher { } public void dispatchUserEvent(LauncherEvent ev, Intent intent) { + ev.isInMultiWindowMode = mIsInMultiWindowMode; ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis; ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis; @@ -320,6 +315,7 @@ public class UserEventDispatcher { ev.elapsedContainerMillis, ev.elapsedSessionMillis, ev.actionDurationMillis); + log += "\n isInMultiWindowMode " + ev.isInMultiWindowMode; Log.d(TAG, log); } diff --git a/src/com/android/launcher3/widget/PendingAddShortcutInfo.java b/src/com/android/launcher3/widget/PendingAddShortcutInfo.java index 7eeb8bf57..e8f13a13c 100644 --- a/src/com/android/launcher3/widget/PendingAddShortcutInfo.java +++ b/src/com/android/launcher3/widget/PendingAddShortcutInfo.java @@ -32,6 +32,6 @@ public class PendingAddShortcutInfo extends PendingAddItemInfo { this.activityInfo = activityInfo; componentName = activityInfo.getComponent(); user = activityInfo.getUser(); - itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; + itemType = activityInfo.getItemType(); } } |