Refactor logging to capture Target hierarchy
Instead of creating a fixed number of targets, we now pass an ArrayList
of targets to. Any class implementing
LogContainerProviders#fillInLogContainerData can setup it's own target
and add it to the ArrayList, It can also pass the ArrayList to other
LogContainerProvider to capture full Target hierarchy.
Bug: 147305863
Change-Id: I0063c692120fb9e1cff2d8902c5da972d0623418
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 217a41c..814b728 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -40,7 +40,6 @@
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.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 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 b89e727..76cfe1c 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.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 @@
}
@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<Target> 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 20ebc7a..b78d2f3 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -30,7 +30,6 @@
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.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.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 @@
* Default launcher application.
*/
public class Launcher extends BaseDraggingActivity implements LauncherExterns,
- Callbacks, UserEventDelegate,
- InvariantDeviceProfile.OnIDPChangeListener, PluginListener<OverlayPlugin> {
+ Callbacks, InvariantDeviceProfile.OnIDPChangeListener, PluginListener<OverlayPlugin> {
public static final String TAG = "Launcher";
public static final ActivityTracker<Launcher> ACTIVITY_TRACKER = new ActivityTracker<>();
@@ -1890,24 +1886,6 @@
}
@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) {
if (!hasBeenResumed()) {
diff --git a/src/com/android/launcher3/SecondaryDropTarget.java b/src/com/android/launcher3/SecondaryDropTarget.java
index 1841134..2430d5e 100644
--- a/src/com/android/launcher3/SecondaryDropTarget.java
+++ b/src/com/android/launcher3/SecondaryDropTarget.java
@@ -41,6 +41,7 @@
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 @@
}
@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<Target> parents) {
+ mOriginal.fillInLogContainerData(childInfo, child, parents);
}
@Override
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 590c620..fc1a074 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.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 @@
}
@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<Target> 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 afb7217..a2957bc 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -18,6 +18,8 @@
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.SpringRelativeLayout;
import com.android.launcher3.views.WorkFooterContainer;
+import java.util.ArrayList;
+
/**
* The all apps view container.
*/
@@ -327,12 +331,10 @@
}
@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<Target> 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 b6744cf..c228ddf 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -17,6 +17,8 @@
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.Target;
import com.android.launcher3.views.RecyclerViewFastScroller;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -145,12 +148,10 @@
}
@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<Target> 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 869dd94..77c6306 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.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 @@
}
@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<LauncherLogProto.Target> 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 69f93de..2be8ff4 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.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.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 @@
}
@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<LauncherLogProto.Target> 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 @@
}
} 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 b004edf..a9d10d7 100644
--- a/src/com/android/launcher3/logging/LoggerUtils.java
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -37,6 +37,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.ArrayList;
/**
* Helper methods for logging.
@@ -255,4 +256,13 @@
event.action = action;
return event;
}
+
+ /**
+ * Creates LauncherEvent using Action and ArrayList of Targets
+ */
+ public static LauncherEvent newLauncherEvent(Action action, ArrayList<Target> 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 b02a050..8449612 100644
--- a/src/com/android/launcher3/logging/StatsLogUtils.java
+++ b/src/com/android/launcher3/logging/StatsLogUtils.java
@@ -5,11 +5,13 @@
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 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<Target> parents);
}
/**
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index afa3f6d..513bf62 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.LogConfig;
import com.android.launcher3.util.ResourceBasedOverride;
+import java.util.ArrayList;
import java.util.Locale;
import java.util.UUID;
@@ -72,8 +73,10 @@
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 @@
}
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<Target> 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<Target> targets) {
+ }
private boolean mSessionStarted;
private long mElapsedContainerMillis;
@@ -125,7 +118,6 @@
private String mUuidStr;
protected InstantAppResolver mInstantAppResolver;
private boolean mAppOrTaskLaunch;
- private UserEventDelegate mDelegate;
private boolean mPreviousHomeGesture;
// APP_ICON SHORTCUT WIDGET
@@ -136,16 +128,15 @@
// --------------------------------------------------------------
@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<Target> 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 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<Target> targets = makeTargetsList(itemTarget);
+
+ if (fillLogContainer(v, itemTarget, targets)) {
+ itemTarget.packageNameHash = (mUuidStr + intent.getCreatorPackage()).hashCode();
}
dispatchUserEvent(event, null);
}
@@ -241,50 +235,45 @@
LauncherEvent event = newLauncherEvent(newCommandAction(command),
newItemTarget(itemView, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
- if (fillInLogContainerData(event, itemView)) {
+ Target itemTarget = newItemTarget(itemView, mInstantAppResolver);
+ ArrayList<Target> 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<Target> 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 @@
* 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 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<Target> 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<Target> srcTargets = makeTargetsList(srcChild);
- dragObj.dragSource.fillInLogContainerData(null, dragObj.originalDragInfo,
- event.srcTarget[0], event.srcTarget[1]);
+ Target destChild = newItemTarget(dragObj.originalDragInfo, mInstantAppResolver);
+ ArrayList<Target> 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 @@
/**
* Currently logs following containers: workspace, allapps, widget tray.
- *
- * @param reason
*/
public final void resetElapsedContainerMillis(String reason) {
mElapsedContainerMillis = SystemClock.uptimeMillis();
@@ -515,4 +502,15 @@
}
return result;
}
+
+ /**
+ * Constructs an ArrayList with targets
+ */
+ public static ArrayList<Target> makeTargetsList(Target... targets) {
+ ArrayList<Target> 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 445acca..5af5ebb 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -18,6 +18,7 @@
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.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 @@
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 @@
}
@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<Target> 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 df1a469..73a0615 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.Themes;
import com.android.launcher3.views.AbstractSlideInView;
+import java.util.ArrayList;
+
/**
* Base class for various widgets popup
*/
@@ -144,9 +146,11 @@
}
@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<Target> parents) {
+ Target target = newContainerTarget(ContainerType.WIDGETS);
+ target.cardinality = getElementsRowCount();
+ parents.add(target);
}
@Override