diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionRowView.java index 834e6cf0fb..8faec46580 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionRowView.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionRowView.java @@ -1,5 +1,5 @@ -/** - * Copyright (C) 2019 The Android Open Source Project +/* + * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,11 @@ package com.android.launcher3.appprediction; +import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; +import static com.android.launcher3.logging.LoggerUtils.newTarget; import android.annotation.TargetApi; import android.content.Context; @@ -44,6 +47,7 @@ import com.android.launcher3.ItemInfoWithIcon; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; +import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.WorkspaceItemInfo; import com.android.launcher3.allapps.AllAppsStore; @@ -187,7 +191,7 @@ public class PredictionRowView extends LinearLayout implements public int getExpectedHeight() { return getVisibility() == GONE ? 0 : Launcher.getLauncher(getContext()).getDeviceProfile().allAppsCellHeightPx - + getPaddingTop() + getPaddingBottom(); + + getPaddingTop() + getPaddingBottom(); } @Override @@ -282,7 +286,8 @@ public class PredictionRowView extends LinearLayout implements mParent.onHeightUpdated(); } - private List processPredictedAppComponents(List components) { + private List processPredictedAppComponents( + List components) { if (getAppsStore().getApps().length == 0) { // Apps have not been bound yet. return Collections.emptyList(); @@ -309,16 +314,26 @@ public class PredictionRowView extends LinearLayout implements } @Override - public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, - LauncherLogProto.Target targetParent) { + public void fillInLogContainerData(ItemInfo childInfo, LauncherLogProto.Target child, + ArrayList parents) { for (int i = 0; i < mPredictedApps.size(); i++) { ItemInfoWithIcon appInfo = mPredictedApps.get(i); - if (appInfo == info) { - targetParent.containerType = LauncherLogProto.ContainerType.PREDICTION; - target.predictedRank = i; + if (appInfo == childInfo) { + child.predictedRank = i; break; } } + parents.add(newContainerTarget(LauncherLogProto.ContainerType.PREDICTION)); + + // include where the prediction is coming this used to be Launcher#modifyUserEvent + LauncherLogProto.Target parent = newTarget(LauncherLogProto.Target.Type.CONTAINER); + LauncherState state = mLauncher.getStateManager().getState(); + if (state == LauncherState.ALL_APPS) { + parent.containerType = LauncherLogProto.ContainerType.ALLAPPS; + } else if (state == OVERVIEW) { + parent.containerType = LauncherLogProto.ContainerType.TASKSWITCHER; + } + parents.add(parent); } public void setTextAlpha(int textAlpha) { diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 0b054277e1..ff4bb74425 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -575,9 +575,9 @@ public class HotseatPredictionController implements DragController.DragListener, } @Override - public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, - LauncherLogProto.Target targetParent) { - mHotseat.fillInLogContainerData(v, info, target, targetParent); + public void fillInLogContainerData(ItemInfo childInfo, LauncherLogProto.Target child, + ArrayList parents) { + mHotseat.fillInLogContainerData(childInfo, child, parents); } private class PinPrediction extends SystemShortcut { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/logging/UserEventDispatcherAppPredictionExtension.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/logging/UserEventDispatcherAppPredictionExtension.java index b251f9e697..b9ef57eaa3 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/logging/UserEventDispatcherAppPredictionExtension.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/logging/UserEventDispatcherAppPredictionExtension.java @@ -23,6 +23,8 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.appprediction.PredictionUiStateManager; import com.android.launcher3.userevent.nano.LauncherLogProto; +import java.util.ArrayList; + /** * This class handles AOSP MetricsLogger function calls and logging around * quickstep interactions and app launches. @@ -41,7 +43,7 @@ public class UserEventDispatcherAppPredictionExtension extends UserEventDispatch @Override protected void onFillInLogContainerData( @NonNull ItemInfo itemInfo, @NonNull LauncherLogProto.Target target, - @NonNull LauncherLogProto.Target targetParent) { + @NonNull ArrayList targets) { PredictionUiStateManager.fillInPredictedRank(itemInfo, target); } } diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java index 53859ad5bf..22fe2e13eb 100644 --- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java +++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java @@ -24,6 +24,8 @@ import static android.stats.launcher.nano.Launcher.LAUNCH_APP; import static android.stats.launcher.nano.Launcher.LAUNCH_TASK; import static android.stats.launcher.nano.Launcher.OVERVIEW; +import static com.android.launcher3.logging.UserEventDispatcher.makeTargetsList; + import android.content.Context; import android.content.Intent; import android.os.UserHandle; @@ -47,6 +49,8 @@ import com.android.systemui.shared.system.SysUiStatsLog; import com.google.protobuf.nano.MessageNano; +import java.util.ArrayList; + /** * This method calls the StatsLog hidden method until they are made available public. * @@ -61,7 +65,8 @@ public class StatsLogCompatManager extends StatsLogManager { private static final String TAG = "StatsLogCompatManager"; private static final boolean DEBUG = false; - public StatsLogCompatManager(Context context) { } + public StatsLogCompatManager(Context context) { + } @Override public void logAppLaunch(View v, Intent intent, @Nullable UserHandle userHandle) { @@ -120,14 +125,17 @@ public class StatsLogCompatManager extends StatsLogManager { return false; } - ItemInfo itemInfo = (ItemInfo) v.getTag(); Target child = new Target(); - Target parent = new Target(); - provider.fillInLogContainerData(v, itemInfo, child, parent); - extension.srcTarget[0] = new LauncherTarget(); - extension.srcTarget[1] = new LauncherTarget(); - copy(child, extension.srcTarget[0]); - copy(parent, extension.srcTarget[1]); + ArrayList targets = makeTargetsList(child); + targets.add(child); + provider.fillInLogContainerData((ItemInfo) v.getTag(), child, targets); + + int maxDepth = Math.min(SUPPORTED_TARGET_DEPTH, targets.size()); + extension.srcTarget = new LauncherTarget[maxDepth]; + for (int i = 0; i < maxDepth; i++) { + extension.srcTarget[i] = new LauncherTarget(); + copy(targets.get(i), extension.srcTarget[i]); + } return true; } @@ -238,10 +246,10 @@ public class StatsLogCompatManager extends StatsLogManager { @Override public void verify() { - if(!(StatsLogUtils.LAUNCHER_STATE_ALLAPPS == ALLAPPS && - StatsLogUtils.LAUNCHER_STATE_BACKGROUND == BACKGROUND && - StatsLogUtils.LAUNCHER_STATE_OVERVIEW == OVERVIEW && - StatsLogUtils.LAUNCHER_STATE_HOME == HOME)) { + if (!(StatsLogUtils.LAUNCHER_STATE_ALLAPPS == ALLAPPS + && StatsLogUtils.LAUNCHER_STATE_BACKGROUND == BACKGROUND + && StatsLogUtils.LAUNCHER_STATE_OVERVIEW == OVERVIEW + && StatsLogUtils.LAUNCHER_STATE_HOME == HOME)) { throw new IllegalStateException( "StatsLogUtil constants doesn't match enums in launcher.proto"); } diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index 217a41c083..814b72882b 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -40,7 +40,6 @@ import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.logging.StatsLogUtils; import com.android.launcher3.logging.StatsLogUtils.LogStateProvider; import com.android.launcher3.logging.UserEventDispatcher; -import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.userevent.nano.LauncherLogProto; @@ -52,8 +51,10 @@ import java.io.PrintWriter; import java.lang.annotation.Retention; import java.util.ArrayList; -public abstract class BaseActivity extends Activity - implements UserEventDelegate, LogStateProvider, ActivityContext { +/** + * Launcher BaseActivity + */ +public abstract class BaseActivity extends Activity implements LogStateProvider, ActivityContext { private static final String TAG = "BaseActivity"; @@ -155,7 +156,7 @@ public abstract class BaseActivity extends Activity public final UserEventDispatcher getUserEventDispatcher() { if (mUserEventDispatcher == null) { - mUserEventDispatcher = UserEventDispatcher.newInstance(this, this); + mUserEventDispatcher = UserEventDispatcher.newInstance(this); } return mUserEventDispatcher; } diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index b89e727207..76cfe1c59e 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -16,12 +16,13 @@ package com.android.launcher3; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; + import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.view.Gravity; import android.view.MotionEvent; -import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -32,6 +33,8 @@ import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.views.Transposable; +import java.util.ArrayList; + public class Hotseat extends CellLayout implements LogContainerProvider, Insettable, Transposable { @ViewDebug.ExportedProperty(category = "launcher") @@ -75,10 +78,12 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta } @Override - public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) { - target.gridX = info.cellX; - target.gridY = info.cellY; - targetParent.containerType = LauncherLogProto.ContainerType.HOTSEAT; + public void fillInLogContainerData(ItemInfo childInfo, Target child, + ArrayList parents) { + child.rank = childInfo.rank; + child.gridX = childInfo.cellX; + child.gridY = childInfo.cellY; + parents.add(newContainerTarget(LauncherLogProto.ContainerType.HOTSEAT)); } @Override diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 20ebc7a27d..b78d2f30de 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -30,7 +30,6 @@ import static com.android.launcher3.LauncherState.OVERVIEW_PEEK; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD; import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; -import static com.android.launcher3.logging.LoggerUtils.newTarget; import static com.android.launcher3.popup.SystemShortcut.APP_INFO; import static com.android.launcher3.popup.SystemShortcut.INSTALL; import static com.android.launcher3.popup.SystemShortcut.WIDGETS; @@ -110,7 +109,6 @@ import com.android.launcher3.keyboard.ViewGroupFocusHelper; import com.android.launcher3.logging.FileLog; import com.android.launcher3.logging.StatsLogUtils; import com.android.launcher3.logging.UserEventDispatcher; -import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate; import com.android.launcher3.model.AppLaunchTracker; import com.android.launcher3.model.BgDataModel.Callbacks; import com.android.launcher3.model.ModelWriter; @@ -126,7 +124,6 @@ import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.touch.AllAppsSwipeController; import com.android.launcher3.touch.ItemClickHandler; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; -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.Target; @@ -183,8 +180,7 @@ import java.util.stream.Stream; * Default launcher application. */ public class Launcher extends BaseDraggingActivity implements LauncherExterns, - Callbacks, UserEventDelegate, - InvariantDeviceProfile.OnIDPChangeListener, PluginListener { + Callbacks, InvariantDeviceProfile.OnIDPChangeListener, PluginListener { public static final String TAG = "Launcher"; public static final ActivityTracker ACTIVITY_TRACKER = new ActivityTracker<>(); @@ -1889,24 +1885,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, return StatsLogUtils.LAUNCHER_STATE_HOME; } - @Override - public void modifyUserEvent(LauncherLogProto.LauncherEvent event) { - if (event.srcTarget != null && event.srcTarget.length > 0 && - event.srcTarget[1].containerType == ContainerType.PREDICTION) { - Target[] targets = new Target[3]; - targets[0] = event.srcTarget[0]; - targets[1] = event.srcTarget[1]; - targets[2] = newTarget(Target.Type.CONTAINER); - event.srcTarget = targets; - LauncherState state = mStateManager.getState(); - if (state == LauncherState.ALL_APPS) { - event.srcTarget[2].containerType = ContainerType.ALLAPPS; - } else if (state == OVERVIEW) { - event.srcTarget[2].containerType = ContainerType.TASKSWITCHER; - } - } - } - @Override public boolean startActivitySafely(View v, Intent intent, ItemInfo item, @Nullable String sourceContainer) { diff --git a/src/com/android/launcher3/SecondaryDropTarget.java b/src/com/android/launcher3/SecondaryDropTarget.java index 184113413b..2430d5e87d 100644 --- a/src/com/android/launcher3/SecondaryDropTarget.java +++ b/src/com/android/launcher3/SecondaryDropTarget.java @@ -41,6 +41,7 @@ import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.Themes; import java.net.URISyntaxException; +import java.util.ArrayList; /** * Drop target which provides a secondary option for an item. @@ -322,9 +323,9 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList } @Override - public void fillInLogContainerData(View v, ItemInfo info, Target target, - Target targetParent) { - mOriginal.fillInLogContainerData(v, info, target, targetParent); + public void fillInLogContainerData(ItemInfo childInfo, Target child, + ArrayList parents) { + mOriginal.fillInLogContainerData(childInfo, child, parents); } @Override diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 590c620020..fc1a074501 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -24,6 +24,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.SPRING_LOADED; import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM; import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -3309,17 +3310,21 @@ public class Workspace extends PagedView } @Override - public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) { - target.gridX = info.cellX; - target.gridY = info.cellY; - target.pageIndex = getCurrentPage(); - targetParent.containerType = ContainerType.WORKSPACE; - if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { - target.rank = info.rank; - targetParent.containerType = ContainerType.HOTSEAT; - } else if (info.container >= 0) { - targetParent.containerType = ContainerType.FOLDER; + public void fillInLogContainerData(ItemInfo childInfo, Target child, + ArrayList parents) { + if (childInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT + || childInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) { + getHotseat().fillInLogContainerData(childInfo, child, parents); + return; + } else if (childInfo.container >= 0) { + FolderIcon icon = (FolderIcon) getHomescreenIconByItemId(childInfo.container); + icon.getFolder().fillInLogContainerData(childInfo, child, parents); + return; } + child.gridX = childInfo.cellX; + child.gridY = childInfo.cellY; + child.pageIndex = getCurrentPage(); + parents.add(newContainerTarget(ContainerType.WORKSPACE)); } /** diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index afb72172b8..a2957bc08d 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -18,6 +18,8 @@ package com.android.launcher3.allapps; import static android.view.View.MeasureSpec.EXACTLY; import static android.view.View.MeasureSpec.makeMeasureSpec; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; + import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Canvas; @@ -65,6 +67,8 @@ import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.SpringRelativeLayout; import com.android.launcher3.views.WorkFooterContainer; +import java.util.ArrayList; + /** * The all apps view container. */ @@ -327,12 +331,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo } @Override - public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) { - if (getApps().hasFilter()) { - targetParent.containerType = ContainerType.SEARCHRESULT; - } else { - targetParent.containerType = ContainerType.ALLAPPS; - } + public void fillInLogContainerData(ItemInfo childInfo, Target child, + ArrayList parents) { + parents.add(newContainerTarget( + getApps().hasFilter() ? ContainerType.SEARCHRESULT : ContainerType.ALLAPPS)); } @Override diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index b6744cff58..c228ddf88c 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -17,6 +17,8 @@ package com.android.launcher3.allapps; import static android.view.View.MeasureSpec.UNSPECIFIED; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; + import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; @@ -40,6 +42,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.views.RecyclerViewFastScroller; +import java.util.ArrayList; import java.util.List; /** @@ -145,12 +148,10 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine } @Override - public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) { - if (mApps.hasFilter()) { - targetParent.containerType = ContainerType.SEARCHRESULT; - } else { - targetParent.containerType = ContainerType.ALLAPPS; - } + public void fillInLogContainerData(ItemInfo childInfo, Target child, + ArrayList parents) { + parents.add(newContainerTarget( + getApps().hasFilter() ? ContainerType.SEARCHRESULT : ContainerType.ALLAPPS)); } public void onSearchResultsChanged() { diff --git a/src/com/android/launcher3/dragndrop/PinItemDragListener.java b/src/com/android/launcher3/dragndrop/PinItemDragListener.java index 869dd948ba..77c630638b 100644 --- a/src/com/android/launcher3/dragndrop/PinItemDragListener.java +++ b/src/com/android/launcher3/dragndrop/PinItemDragListener.java @@ -16,6 +16,8 @@ package com.android.launcher3.dragndrop; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; + import android.annotation.TargetApi; import android.appwidget.AppWidgetManager; import android.content.pm.LauncherApps.PinItemRequest; @@ -38,6 +40,8 @@ import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.PendingItemDragHelper; import com.android.launcher3.widget.WidgetAddFlowHandler; +import java.util.ArrayList; + /** * {@link DragSource} for handling drop from a different window. This object is initialized * in the source window and is passed on to the Launcher activity as an Intent extra. @@ -103,9 +107,9 @@ public class PinItemDragListener extends BaseItemDragListener { } @Override - public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, - LauncherLogProto.Target targetParent) { - targetParent.containerType = LauncherLogProto.ContainerType.PINITEM; + public void fillInLogContainerData(ItemInfo childInfo, LauncherLogProto.Target child, + ArrayList parents) { + parents.add(newContainerTarget(LauncherLogProto.ContainerType.PINITEM)); } @Override diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 69f93de55e..2be8ff463d 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -27,6 +27,7 @@ import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent; import static com.android.launcher3.config.FeatureFlags.ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import static com.android.launcher3.userevent.LauncherLogProto.Target.FromFolderLabelState.FROM_CUSTOM; import static com.android.launcher3.userevent.LauncherLogProto.Target.FromFolderLabelState.FROM_EMPTY; import static com.android.launcher3.userevent.LauncherLogProto.Target.FromFolderLabelState.FROM_FOLDER_LABEL_STATE_UNSPECIFIED; @@ -89,7 +90,6 @@ import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragController.DragListener; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragOptions; -import com.android.launcher3.logging.LoggerUtils; import com.android.launcher3.pageindicators.PageIndicatorDots; import com.android.launcher3.userevent.LauncherLogProto.Action; import com.android.launcher3.userevent.LauncherLogProto.ContainerType; @@ -1459,12 +1459,24 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo } @Override - public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, - LauncherLogProto.Target targetParent) { - target.gridX = info.cellX; - target.gridY = info.cellY; - target.pageIndex = mContent.getCurrentPage(); - targetParent.containerType = LauncherLogProto.ContainerType.FOLDER; + public void fillInLogContainerData(ItemInfo childInfo, LauncherLogProto.Target child, + ArrayList targets) { + child.gridX = childInfo.cellX; + child.gridY = childInfo.cellY; + child.pageIndex = mContent.getCurrentPage(); + + LauncherLogProto.Target target = newContainerTarget(LauncherLogProto.ContainerType.FOLDER); + target.pageIndex = mInfo.screenId; + target.gridX = mInfo.cellX; + target.gridY = mInfo.cellY; + targets.add(target); + + // continue to parent + if (mInfo.container == CONTAINER_HOTSEAT) { + mLauncher.getHotseat().fillInLogContainerData(mInfo, target, targets); + } else { + mLauncher.getWorkspace().fillInLogContainerData(mInfo, target, targets); + } } private class OnScrollHintListener implements OnAlarmListener { @@ -1597,7 +1609,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo } } else { mLauncher.getUserEventDispatcher().logActionTapOutside( - LoggerUtils.newContainerTarget(LauncherLogProto.ContainerType.FOLDER)); + newContainerTarget(LauncherLogProto.ContainerType.FOLDER)); close(true); return true; } diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java index b004edf8fd..a9d10d775d 100644 --- a/src/com/android/launcher3/logging/LoggerUtils.java +++ b/src/com/android/launcher3/logging/LoggerUtils.java @@ -37,6 +37,7 @@ import com.android.launcher3.util.InstantAppResolver; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.util.ArrayList; /** * Helper methods for logging. @@ -255,4 +256,13 @@ public class LoggerUtils { event.action = action; return event; } + + /** + * Creates LauncherEvent using Action and ArrayList of Targets + */ + public static LauncherEvent newLauncherEvent(Action action, ArrayList targets) { + Target[] targetsArray = new Target[targets.size()]; + targets.toArray(targetsArray); + return newLauncherEvent(action, targetsArray); + } } diff --git a/src/com/android/launcher3/logging/StatsLogUtils.java b/src/com/android/launcher3/logging/StatsLogUtils.java index b02a0504ff..844961205e 100644 --- a/src/com/android/launcher3/logging/StatsLogUtils.java +++ b/src/com/android/launcher3/logging/StatsLogUtils.java @@ -5,11 +5,13 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerTyp import android.view.View; import android.view.ViewParent; +import androidx.annotation.Nullable; + import com.android.launcher3.ItemInfo; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; -import androidx.annotation.Nullable; +import java.util.ArrayList; public class StatsLogUtils { @@ -35,14 +37,9 @@ public class StatsLogUtils { public interface LogContainerProvider { /** - * Copies data from the source to the destination proto. - * - * @param v source of the data - * @param info source of the data - * @param target dest of the data - * @param targetParent dest of the data + * Populates parent container targets for an item */ - void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent); + void fillInLogContainerData(ItemInfo childInfo, Target child, ArrayList parents); } /** diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index afa3f6d9e7..513bf6256f 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -57,6 +57,7 @@ import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.LogConfig; import com.android.launcher3.util.ResourceBasedOverride; +import java.util.ArrayList; import java.util.Locale; import java.util.UUID; @@ -72,8 +73,10 @@ public class UserEventDispatcher implements ResourceBasedOverride { private static final boolean IS_VERBOSE = Utilities.isPropertyEnabled(LogConfig.USEREVENT); private static final String UUID_STORAGE = "uuid"; - public static UserEventDispatcher newInstance(Context context, - UserEventDelegate delegate) { + /** + * A factory method for UserEventDispatcher + */ + public static UserEventDispatcher newInstance(Context context) { SharedPreferences sharedPrefs = Utilities.getDevicePrefs(context); String uuidStr = sharedPrefs.getString(UUID_STORAGE, null); if (uuidStr == null) { @@ -82,41 +85,31 @@ public class UserEventDispatcher implements ResourceBasedOverride { } UserEventDispatcher ued = Overrides.getObject(UserEventDispatcher.class, context.getApplicationContext(), R.string.user_event_dispatcher_class); - ued.mDelegate = delegate; ued.mUuidStr = uuidStr; ued.mInstantAppResolver = InstantAppResolver.newInstance(context); return ued; } - public static UserEventDispatcher newInstance(Context context) { - return newInstance(context, null); - } - - public interface UserEventDelegate { - void modifyUserEvent(LauncherEvent event); - } /** * Fills in the container data on the given event if the given view is not null. * * @return whether container data was added. */ - public boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) { - // Fill in grid(x,y), pageIndex of the child and container type of the parent - LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(v); - if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) { + public boolean fillLogContainer(@Nullable View v, Target child, + @Nullable ArrayList targets) { + LogContainerProvider firstParent = StatsLogUtils.getLaunchProviderRecursive(v); + if (v == null || !(v.getTag() instanceof ItemInfo) || firstParent == null) { return false; } final ItemInfo itemInfo = (ItemInfo) v.getTag(); - final Target target = event.srcTarget[0]; - final Target targetParent = event.srcTarget[1]; - onFillInLogContainerData(itemInfo, target, targetParent); - provider.fillInLogContainerData(v, itemInfo, target, targetParent); + firstParent.fillInLogContainerData(itemInfo, child, targets); return true; } - protected void onFillInLogContainerData( - @NonNull ItemInfo itemInfo, @NonNull Target target, @NonNull Target targetParent) { } + protected void onFillInLogContainerData(@NonNull ItemInfo itemInfo, @NonNull Target target, + @NonNull ArrayList targets) { + } private boolean mSessionStarted; private long mElapsedContainerMillis; @@ -125,7 +118,6 @@ public class UserEventDispatcher implements ResourceBasedOverride { private String mUuidStr; protected InstantAppResolver mInstantAppResolver; private boolean mAppOrTaskLaunch; - private UserEventDelegate mDelegate; private boolean mPreviousHomeGesture; // APP_ICON SHORTCUT WIDGET @@ -136,16 +128,15 @@ public class UserEventDispatcher implements ResourceBasedOverride { // -------------------------------------------------------------- @Deprecated - public void logAppLaunch(View v, Intent intent, @Nullable UserHandle userHandle) { - LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP), - newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); - - if (fillInLogContainerData(event, v)) { - if (mDelegate != null) { - mDelegate.modifyUserEvent(event); - } - fillIntentInfo(event.srcTarget[0], intent, userHandle); + public void logAppLaunch(View v, Intent intent, @Nullable UserHandle userHandle) { + Target itemTarget = newItemTarget(v, mInstantAppResolver); + Action action = newTouchAction(Action.Touch.TAP); + ArrayList targets = makeTargetsList(itemTarget); + if (fillLogContainer(v, itemTarget, targets)) { + onFillInLogContainerData((ItemInfo) v.getTag(), itemTarget, targets); + fillIntentInfo(itemTarget, intent, userHandle); } + LauncherEvent event = newLauncherEvent(action, targets); ItemInfo info = (ItemInfo) v.getTag(); if (info != null && Utilities.IS_DEBUG_DEVICE && FeatureFlags.ENABLE_HYBRID_HOTSEAT.get()) { FileLog.d(TAG, "appLaunch: packageName:" + info.getTargetComponent().getPackageName() @@ -194,8 +185,11 @@ public class UserEventDispatcher implements ResourceBasedOverride { public void logNotificationLaunch(View v, PendingIntent intent) { LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP), newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); - if (fillInLogContainerData(event, v)) { - event.srcTarget[0].packageNameHash = (mUuidStr + intent.getCreatorPackage()).hashCode(); + Target itemTarget = newItemTarget(v, mInstantAppResolver); + ArrayList targets = makeTargetsList(itemTarget); + + if (fillLogContainer(v, itemTarget, targets)) { + itemTarget.packageNameHash = (mUuidStr + intent.getCreatorPackage()).hashCode(); } dispatchUserEvent(event, null); } @@ -241,50 +235,45 @@ public class UserEventDispatcher implements ResourceBasedOverride { LauncherEvent event = newLauncherEvent(newCommandAction(command), newItemTarget(itemView, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); - if (fillInLogContainerData(event, itemView)) { + Target itemTarget = newItemTarget(itemView, mInstantAppResolver); + ArrayList targets = makeTargetsList(itemTarget); + + if (fillLogContainer(itemView, itemTarget, targets)) { // TODO: Remove the following two lines once fillInLogContainerData can take in a // container view. - event.srcTarget[0].type = Target.Type.CONTAINER; - event.srcTarget[0].containerType = srcContainerType; + itemTarget.type = Target.Type.CONTAINER; + itemTarget.containerType = srcContainerType; } dispatchUserEvent(event, null); } public void logActionOnControl(int action, int controlType) { - logActionOnControl(action, controlType, null, -1); + logActionOnControl(action, controlType, null); } public void logActionOnControl(int action, int controlType, int parentContainerType) { logActionOnControl(action, controlType, null, parentContainerType); } - public void logActionOnControl(int action, int controlType, @Nullable View controlInContainer) { - logActionOnControl(action, controlType, controlInContainer, -1); - } + /** + * Logs control action with proper parent hierarchy + */ + public void logActionOnControl(int actionType, int controlType, + @Nullable View controlInContainer, int... parentTypes) { + Target control = newTarget(Target.Type.CONTROL); + control.controlType = controlType; + Action action = newAction(actionType); - public void logActionOnControl(int action, int controlType, int parentContainer, - int grandParentContainer) { - LauncherEvent event = newLauncherEvent(newTouchAction(action), - newControlTarget(controlType), - newContainerTarget(parentContainer), - newContainerTarget(grandParentContainer)); - dispatchUserEvent(event, null); - } - - public void logActionOnControl(int action, int controlType, @Nullable View controlInContainer, - int parentContainerType) { - final LauncherEvent event = (controlInContainer == null && parentContainerType < 0) - ? newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL)) - : newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL), - newTarget(Target.Type.CONTAINER)); - event.srcTarget[0].controlType = controlType; + ArrayList targets = makeTargetsList(control); if (controlInContainer != null) { - fillInLogContainerData(event, controlInContainer); + fillLogContainer(controlInContainer, control, targets); } - if (parentContainerType >= 0) { - event.srcTarget[1].containerType = parentContainerType; + for (int parentContainerType : parentTypes) { + if (parentContainerType < 0) continue; + targets.add(newContainerTarget(parentContainerType)); } - if (action == Action.Touch.DRAGDROP) { + LauncherEvent event = newLauncherEvent(action, targets); + if (actionType == Action.Touch.DRAGDROP) { event.actionDurationMillis = SystemClock.uptimeMillis() - mActionDurationMillis; } dispatchUserEvent(event, null); @@ -375,15 +364,16 @@ public class UserEventDispatcher implements ResourceBasedOverride { * Logs proto lite version of LauncherEvent object to clearcut. */ public void logLauncherEvent( - com.android.launcher3.userevent.LauncherLogProto.LauncherEvent launcherEvent) { + com.android.launcher3.userevent.LauncherLogProto.LauncherEvent launcherEvent) { if (mPreviousHomeGesture) { mPreviousHomeGesture = false; } mAppOrTaskLaunch = false; launcherEvent.toBuilder() - .setElapsedContainerMillis(SystemClock.uptimeMillis() - mElapsedContainerMillis) - .setElapsedSessionMillis(SystemClock.uptimeMillis() - mElapsedSessionMillis).build(); + .setElapsedContainerMillis(SystemClock.uptimeMillis() - mElapsedContainerMillis) + .setElapsedSessionMillis( + SystemClock.uptimeMillis() - mElapsedSessionMillis).build(); if (!IS_VERBOSE) { return; } @@ -391,36 +381,35 @@ public class UserEventDispatcher implements ResourceBasedOverride { } public void logDeepShortcutsOpen(View icon) { - LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(icon); - if (icon == null || !(icon.getTag() instanceof ItemInfo || provider == null)) { - return; - } ItemInfo info = (ItemInfo) icon.getTag(); - LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.LONGPRESS), - newItemTarget(info, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); - provider.fillInLogContainerData(icon, info, event.srcTarget[0], event.srcTarget[1]); - dispatchUserEvent(event, null); - + Target child = newItemTarget(info, mInstantAppResolver); + ArrayList targets = makeTargetsList(child); + fillLogContainer(icon, child, targets); + dispatchUserEvent(newLauncherEvent(newTouchAction(Action.Touch.TAP), targets), null); resetElapsedContainerMillis("deep shortcut open"); } public void logDragNDrop(DropTarget.DragObject dragObj, View dropTargetAsView) { - LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP), - newItemTarget(dragObj.originalDragInfo, mInstantAppResolver), - newTarget(Target.Type.CONTAINER)); - event.destTarget = new Target[]{ - newItemTarget(dragObj.originalDragInfo, mInstantAppResolver), - newDropTarget(dropTargetAsView) - }; + Target srcChild = newItemTarget(dragObj.originalDragInfo, mInstantAppResolver); + ArrayList srcTargets = makeTargetsList(srcChild); - dragObj.dragSource.fillInLogContainerData(null, dragObj.originalDragInfo, - event.srcTarget[0], event.srcTarget[1]); + Target destChild = newItemTarget(dragObj.originalDragInfo, mInstantAppResolver); + ArrayList destTargets = makeTargetsList(destChild); + + dragObj.dragSource.fillInLogContainerData(dragObj.originalDragInfo, srcChild, srcTargets); if (dropTargetAsView instanceof LogContainerProvider) { - ((LogContainerProvider) dropTargetAsView).fillInLogContainerData(null, - dragObj.dragInfo, event.destTarget[0], event.destTarget[1]); - + ((LogContainerProvider) dropTargetAsView).fillInLogContainerData(dragObj.dragInfo, + destChild, destTargets); } + else { + destTargets.add(newDropTarget(dropTargetAsView)); + } + LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP), srcTargets); + Target[] destTargetsArray = new Target[destTargets.size()]; + destTargets.toArray(destTargetsArray); + event.destTarget = destTargetsArray; + event.actionDurationMillis = SystemClock.uptimeMillis() - mActionDurationMillis; dispatchUserEvent(event, null); } @@ -444,8 +433,6 @@ public class UserEventDispatcher implements ResourceBasedOverride { /** * Currently logs following containers: workspace, allapps, widget tray. - * - * @param reason */ public final void resetElapsedContainerMillis(String reason) { mElapsedContainerMillis = SystemClock.uptimeMillis(); @@ -515,4 +502,15 @@ public class UserEventDispatcher implements ResourceBasedOverride { } return result; } + + /** + * Constructs an ArrayList with targets + */ + public static ArrayList makeTargetsList(Target... targets) { + ArrayList result = new ArrayList<>(); + for (Target target : targets) { + result.add(target); + } + return result; + } } diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 445acca5c9..5af5ebb4f5 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -18,6 +18,7 @@ package com.android.launcher3.popup; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import static com.android.launcher3.notification.NotificationMainView.NOTIFICATION_ITEM_INFO; import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS; import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS_IF_NOTIFICATIONS; @@ -58,7 +59,6 @@ import com.android.launcher3.dot.DotInfo; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.dragndrop.DragView; -import com.android.launcher3.logging.LoggerUtils; import com.android.launcher3.notification.NotificationInfo; import com.android.launcher3.notification.NotificationItemView; import com.android.launcher3.notification.NotificationKeyData; @@ -172,7 +172,7 @@ public class PopupContainerWithArrow extends Arr BaseDragLayer dl = getPopupContainer(); if (!dl.isEventOverView(this, ev)) { mLauncher.getUserEventDispatcher().logActionTapOutside( - LoggerUtils.newContainerTarget(ContainerType.DEEPSHORTCUTS)); + newContainerTarget(ContainerType.DEEPSHORTCUTS)); close(true); // We let touches on the original icon go through so that users can launch @@ -485,14 +485,15 @@ public class PopupContainerWithArrow extends Arr } @Override - public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) { - if (info == NOTIFICATION_ITEM_INFO) { - target.itemType = ItemType.NOTIFICATION; + public void fillInLogContainerData(ItemInfo childInfo, Target child, + ArrayList parents) { + if (childInfo == NOTIFICATION_ITEM_INFO) { + child.itemType = ItemType.NOTIFICATION; } else { - target.itemType = ItemType.DEEPSHORTCUT; - target.rank = info.rank; + child.itemType = ItemType.DEEPSHORTCUT; + child.rank = childInfo.rank; } - targetParent.containerType = ContainerType.DEEPSHORTCUTS; + parents.add(newContainerTarget(ContainerType.DEEPSHORTCUTS)); } @Override diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java index df1a4696db..73a061594f 100644 --- a/src/com/android/launcher3/widget/BaseWidgetSheet.java +++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java @@ -41,6 +41,8 @@ import com.android.launcher3.util.SystemUiController; import com.android.launcher3.util.Themes; import com.android.launcher3.views.AbstractSlideInView; +import java.util.ArrayList; + /** * Base class for various widgets popup */ @@ -144,9 +146,11 @@ abstract class BaseWidgetSheet extends AbstractSlideInView } @Override - public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) { - targetParent.containerType = ContainerType.WIDGETS; - targetParent.cardinality = getElementsRowCount(); + public void fillInLogContainerData(ItemInfo childInfo, Target child, + ArrayList parents) { + Target target = newContainerTarget(ContainerType.WIDGETS); + target.cardinality = getElementsRowCount(); + parents.add(target); } @Override