Merge changes from topics "TaskbarLogging", "taskbar-log" into sc-v2-dev am: 2908eb70fc

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15720731

Change-Id: I9886a307206a76109a7932cc1cf22aa8b0e7a956
This commit is contained in:
Tony Wickham
2021-09-15 16:40:36 +00:00
committed by Automerger Merge Worker
11 changed files with 172 additions and 17 deletions
+12
View File
@@ -59,6 +59,7 @@ message ContainerInfo {
SettingsContainer settings_container = 9; SettingsContainer settings_container = 9;
PredictedHotseatContainer predicted_hotseat_container = 10; PredictedHotseatContainer predicted_hotseat_container = 10;
TaskSwitcherContainer task_switcher_container = 11; TaskSwitcherContainer task_switcher_container = 11;
TaskBarContainer task_bar_container = 12;
ExtendedContainers extended_containers = 20; ExtendedContainers extended_containers = 20;
} }
} }
@@ -100,6 +101,16 @@ message SettingsContainer {
message TaskSwitcherContainer { message TaskSwitcherContainer {
} }
// Container for taskbar.
// Configured to show up on large screens(tablet-sized) such as foldables in expanded state, within
// an app view(not in launcher screen).
message TaskBarContainer {
optional int32 index = 1;
// Bit encoded value to capture pinned and predicted taskbar positions.
optional int32 cardinality = 2;
}
enum Attribute { enum Attribute {
UNKNOWN = 0; UNKNOWN = 0;
DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat
@@ -230,6 +241,7 @@ message FolderContainer {
oneof ParentContainer { oneof ParentContainer {
WorkspaceContainer workspace = 4; WorkspaceContainer workspace = 4;
HotseatContainer hotseat = 5; HotseatContainer hotseat = 5;
TaskBarContainer taskbar = 6;
} }
} }
@@ -16,6 +16,8 @@
package com.android.launcher3.taskbar; package com.android.launcher3.taskbar;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS; import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP; import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME; import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
@@ -36,7 +38,10 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities; import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorListeners; import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.OnboardingPrefs; import com.android.launcher3.util.OnboardingPrefs;
@@ -262,6 +267,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
@Override @Override
protected void onStashedInAppChanged() { protected void onStashedInAppChanged() {
onStashedInAppChanged(mLauncher.getDeviceProfile()); onStashedInAppChanged(mLauncher.getDeviceProfile());
if (mControllers.taskbarStashController.isStashedInApp()) {
mContext.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_HIDE);
} else {
mContext.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_SHOW);
}
} }
private void onStashedInAppChanged(DeviceProfile deviceProfile) { private void onStashedInAppChanged(DeviceProfile deviceProfile) {
@@ -306,6 +316,12 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
mControllers.taskbarEduController.hideEdu(); mControllers.taskbarEduController.hideEdu();
} }
@Override
public void onTaskbarIconLaunched(WorkspaceItemInfo item) {
InstanceId instanceId = new InstanceIdSequence().newInstanceId();
mLauncher.logAppLaunch(mContext.getStatsLogManager(), item, instanceId);
}
private final class TaskBarRecentsAnimationListener implements RecentsAnimationListener { private final class TaskBarRecentsAnimationListener implements RecentsAnimationListener {
private final RecentsAnimationCallbacks mCallbacks; private final RecentsAnimationCallbacks mCallbacks;
@@ -19,6 +19,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT; import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR; import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
@@ -52,6 +53,7 @@ import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.folder.Folder; import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.taskbar.contextual.RotationButtonController; import com.android.launcher3.taskbar.contextual.RotationButtonController;
@@ -231,6 +233,60 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
return false; return false;
} }
/**
* Change from hotseat/predicted hotseat to taskbar container.
*/
@Override
public void applyOverwritesToLogItem(LauncherAtom.ItemInfo.Builder itemInfoBuilder) {
if (!itemInfoBuilder.hasContainerInfo()) {
return;
}
LauncherAtom.ContainerInfo oldContainer = itemInfoBuilder.getContainerInfo();
if (oldContainer.hasPredictedHotseatContainer()) {
LauncherAtom.PredictedHotseatContainer predictedHotseat =
oldContainer.getPredictedHotseatContainer();
LauncherAtom.TaskBarContainer.Builder taskbarBuilder =
LauncherAtom.TaskBarContainer.newBuilder();
if (predictedHotseat.hasIndex()) {
taskbarBuilder.setIndex(predictedHotseat.getIndex());
}
if (predictedHotseat.hasCardinality()) {
taskbarBuilder.setCardinality(predictedHotseat.getCardinality());
}
itemInfoBuilder.setContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
.setTaskBarContainer(taskbarBuilder));
} else if (oldContainer.hasHotseat()) {
LauncherAtom.HotseatContainer hotseat = oldContainer.getHotseat();
LauncherAtom.TaskBarContainer.Builder taskbarBuilder =
LauncherAtom.TaskBarContainer.newBuilder();
if (hotseat.hasIndex()) {
taskbarBuilder.setIndex(hotseat.getIndex());
}
itemInfoBuilder.setContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
.setTaskBarContainer(taskbarBuilder));
} else if (oldContainer.hasFolder() && oldContainer.getFolder().hasHotseat()) {
LauncherAtom.FolderContainer.Builder folderBuilder = oldContainer.getFolder()
.toBuilder();
LauncherAtom.HotseatContainer hotseat = folderBuilder.getHotseat();
LauncherAtom.TaskBarContainer.Builder taskbarBuilder =
LauncherAtom.TaskBarContainer.newBuilder();
if (hotseat.hasIndex()) {
taskbarBuilder.setIndex(hotseat.getIndex());
}
folderBuilder.setTaskbar(taskbarBuilder);
folderBuilder.clearHotseat();
itemInfoBuilder.setContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
.setFolder(folderBuilder));
}
}
/** /**
* Sets a new data-source for this taskbar instance * Sets a new data-source for this taskbar instance
*/ */
@@ -328,6 +384,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
getDragLayer().post(() -> { getDragLayer().post(() -> {
folder.animateOpen(); folder.animateOpen();
getStatsLogManager().logger().withItemInfo(folder.mInfo).log(LAUNCHER_FOLDER_OPEN);
folder.iterateOverItems((itemInfo, itemView) -> { folder.iterateOverItems((itemInfo, itemView) -> {
mControllers.taskbarViewController mControllers.taskbarViewController
@@ -365,6 +422,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
getSystemService(LauncherApps.class).startMainActivity( getSystemService(LauncherApps.class).startMainActivity(
intent.getComponent(), info.user, intent.getSourceBounds(), null); intent.getComponent(), info.user, intent.getSourceBounds(), null);
} }
mControllers.uiController.onTaskbarIconLaunched(info);
} catch (NullPointerException | ActivityNotFoundException | SecurityException e) { } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT) Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT)
.show(); .show();
@@ -34,6 +34,8 @@ import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.android.internal.logging.InstanceId;
import com.android.internal.logging.InstanceIdSequence;
import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BubbleTextView; import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DragSource; import com.android.launcher3.DragSource;
@@ -48,6 +50,7 @@ import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.dragndrop.DraggableView; import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.graphics.DragPreviewProvider; import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.icons.FastBitmapDrawable; import com.android.launcher3.icons.FastBitmapDrawable;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.Task;
@@ -284,10 +287,22 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
} }
if (clipDescription != null && intent != null) { if (clipDescription != null && intent != null) {
// Need to share the same InstanceId between launcher3 and WM Shell (internal).
InstanceId internalInstanceId = new InstanceIdSequence(
com.android.launcher3.logging.InstanceId.INSTANCE_ID_MAX).newInstanceId();
com.android.launcher3.logging.InstanceId launcherInstanceId =
new com.android.launcher3.logging.InstanceId(internalInstanceId.getId());
intent.putExtra(ClipDescription.EXTRA_LOGGING_INSTANCE_ID, internalInstanceId);
ClipData clipData = new ClipData(clipDescription, new ClipData.Item(intent)); ClipData clipData = new ClipData(clipDescription, new ClipData.Item(intent));
if (btv.startDragAndDrop(clipData, shadowBuilder, null /* localState */, if (btv.startDragAndDrop(clipData, shadowBuilder, null /* localState */,
View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_OPAQUE)) { View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_OPAQUE)) {
onSystemDragStarted(); onSystemDragStarted();
mActivity.getStatsLogManager().logger().withItemInfo(mDragObject.dragInfo)
.withInstanceId(launcherInstanceId)
.log(StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
} }
} }
} }
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar;
import android.graphics.Rect; import android.graphics.Rect;
import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -43,4 +44,6 @@ public class TaskbarUIController {
public Stream<ItemInfoWithIcon> getAppIconsForEdu() { public Stream<ItemInfoWithIcon> getAppIconsForEdu() {
return Stream.empty(); return Stream.empty();
} }
public void onTaskbarIconLaunched(WorkspaceItemInfo item) { }
} }
@@ -51,6 +51,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.appprediction.PredictionRowView; import com.android.launcher3.appprediction.PredictionRowView;
import com.android.launcher3.hybridhotseat.HotseatPredictionController; import com.android.launcher3.hybridhotseat.HotseatPredictionController;
import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.logging.StatsLogManager.StatsLogger; import com.android.launcher3.logging.StatsLogManager.StatsLogger;
import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.BgDataModel.FixedContainerItems;
import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfo;
@@ -104,7 +105,8 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
} }
@Override @Override
protected void logAppLaunch(ItemInfo info, InstanceId instanceId) { public void logAppLaunch(StatsLogManager statsLogManager, ItemInfo info,
InstanceId instanceId) {
// If the app launch is from any of the surfaces in AllApps then add the InstanceId from // If the app launch is from any of the surfaces in AllApps then add the InstanceId from
// LiveSearchManager to recreate the AllApps session on the server side. // LiveSearchManager to recreate the AllApps session on the server side.
if (mAllAppsSessionLogId != null && ALL_APPS.equals( if (mAllAppsSessionLogId != null && ALL_APPS.equals(
@@ -112,8 +114,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
instanceId = mAllAppsSessionLogId; instanceId = mAllAppsSessionLogId;
} }
StatsLogger logger = getStatsLogManager() StatsLogger logger = statsLogManager.logger().withItemInfo(info).withInstanceId(instanceId);
.logger().withItemInfo(info).withInstanceId(instanceId);
if (mAllAppsPredictions != null if (mAllAppsPredictions != null
&& (info.itemType == ITEM_TYPE_APPLICATION && (info.itemType == ITEM_TYPE_APPLICATION
@@ -58,6 +58,7 @@ import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.Executors; import com.android.launcher3.util.Executors;
import com.android.launcher3.util.LogConfig; import com.android.launcher3.util.LogConfig;
import com.android.launcher3.views.ActivityContext;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.shared.system.SysUiStatsLog;
@@ -99,7 +100,7 @@ public class StatsLogCompatManager extends StatsLogManager {
@Override @Override
protected StatsLogger createLogger() { protected StatsLogger createLogger() {
return new StatsCompatLogger(mContext); return new StatsCompatLogger(mContext, mActivityContext);
} }
/** /**
@@ -173,7 +174,8 @@ public class StatsLogCompatManager extends StatsLogManager {
private static final ItemInfo DEFAULT_ITEM_INFO = new ItemInfo(); private static final ItemInfo DEFAULT_ITEM_INFO = new ItemInfo();
private Context mContext; private final Context mContext;
private final Optional<ActivityContext> mActivityContext;
private ItemInfo mItemInfo = DEFAULT_ITEM_INFO; private ItemInfo mItemInfo = DEFAULT_ITEM_INFO;
private InstanceId mInstanceId = DEFAULT_INSTANCE_ID; private InstanceId mInstanceId = DEFAULT_INSTANCE_ID;
private OptionalInt mRank = OptionalInt.empty(); private OptionalInt mRank = OptionalInt.empty();
@@ -186,8 +188,9 @@ public class StatsLogCompatManager extends StatsLogManager {
private SliceItem mSliceItem; private SliceItem mSliceItem;
private LauncherAtom.Slice mSlice; private LauncherAtom.Slice mSlice;
StatsCompatLogger(Context context) { StatsCompatLogger(Context context, ActivityContext activityContext) {
mContext = context; mContext = context;
mActivityContext = Optional.ofNullable(activityContext);
} }
@Override @Override
@@ -339,6 +342,9 @@ public class StatsLogCompatManager extends StatsLogManager {
mRank.ifPresent(itemInfoBuilder::setRank); mRank.ifPresent(itemInfoBuilder::setRank);
mContainerInfo.ifPresent(itemInfoBuilder::setContainerInfo); mContainerInfo.ifPresent(itemInfoBuilder::setContainerInfo);
mActivityContext.ifPresent(activityContext ->
activityContext.applyOverwritesToLogItem(itemInfoBuilder));
if (mFromState.isPresent() || mToState.isPresent() || mEditText.isPresent()) { if (mFromState.isPresent() || mToState.isPresent() || mEditText.isPresent()) {
FolderIcon.Builder folderIconBuilder = itemInfoBuilder FolderIcon.Builder folderIconBuilder = itemInfoBuilder
.getFolderIcon() .getFolderIcon()
@@ -407,6 +413,8 @@ public class StatsLogCompatManager extends StatsLogManager {
switch (info.getContainerInfo().getContainerCase()) { switch (info.getContainerInfo().getContainerCase()) {
case PREDICTED_HOTSEAT_CONTAINER: case PREDICTED_HOTSEAT_CONTAINER:
return info.getContainerInfo().getPredictedHotseatContainer().getCardinality(); return info.getContainerInfo().getPredictedHotseatContainer().getCardinality();
case TASK_BAR_CONTAINER:
return info.getContainerInfo().getTaskBarContainer().getCardinality();
case SEARCH_RESULT_CONTAINER: case SEARCH_RESULT_CONTAINER:
return info.getContainerInfo().getSearchResultContainer().getQueryLength(); return info.getContainerInfo().getSearchResultContainer().getQueryLength();
case EXTENDED_CONTAINERS: case EXTENDED_CONTAINERS:
@@ -493,6 +501,8 @@ public class StatsLogCompatManager extends StatsLogManager {
return info.getContainerInfo().getHotseat().getIndex(); return info.getContainerInfo().getHotseat().getIndex();
case PREDICTED_HOTSEAT_CONTAINER: case PREDICTED_HOTSEAT_CONTAINER:
return info.getContainerInfo().getPredictedHotseatContainer().getIndex(); return info.getContainerInfo().getPredictedHotseatContainer().getIndex();
case TASK_BAR_CONTAINER:
return info.getContainerInfo().getTaskBarContainer().getIndex();
default: default:
return info.getContainerInfo().getWorkspace().getPageIndex(); return info.getContainerInfo().getWorkspace().getPageIndex();
} }
@@ -55,6 +55,7 @@ import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence; import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.touch.ItemClickHandler; import com.android.launcher3.touch.ItemClickHandler;
@@ -224,7 +225,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
} }
if (item != null) { if (item != null) {
InstanceId instanceId = new InstanceIdSequence().newInstanceId(); InstanceId instanceId = new InstanceIdSequence().newInstanceId();
logAppLaunch(item, instanceId); logAppLaunch(getStatsLogManager(), item, instanceId);
} }
return true; return true;
} catch (NullPointerException | ActivityNotFoundException | SecurityException e) { } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
@@ -234,8 +235,12 @@ public abstract class BaseDraggingActivity extends BaseActivity
return false; return false;
} }
protected void logAppLaunch(ItemInfo info, InstanceId instanceId) { /**
getStatsLogManager().logger().withItemInfo(info).withInstanceId(instanceId) * Creates and logs a new app launch event.
*/
public void logAppLaunch(StatsLogManager statsLogManager, ItemInfo info,
InstanceId instanceId) {
statsLogManager.logger().withItemInfo(info).withInstanceId(instanceId)
.log(LAUNCHER_APP_LAUNCH_TAP); .log(LAUNCHER_APP_LAUNCH_TAP);
} }
@@ -36,10 +36,10 @@ import androidx.annotation.VisibleForTesting;
*/ */
public final class InstanceId implements Parcelable { public final class InstanceId implements Parcelable {
// At most 20 bits: ~1m possibilities, ~0.5% probability of collision in 100 values // At most 20 bits: ~1m possibilities, ~0.5% probability of collision in 100 values
static final int INSTANCE_ID_MAX = 1 << 20; public static final int INSTANCE_ID_MAX = 1 << 20;
private final int mId; private final int mId;
InstanceId(int id) { public InstanceId(int id) {
mId = min(max(0, id), INSTANCE_ID_MAX); mId = min(max(0, id), INSTANCE_ID_MAX);
} }
@@ -33,6 +33,7 @@ import com.android.launcher3.logger.LauncherAtom.FromState;
import com.android.launcher3.logger.LauncherAtom.ToState; import com.android.launcher3.logger.LauncherAtom.ToState;
import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ResourceBasedOverride; import com.android.launcher3.util.ResourceBasedOverride;
import com.android.launcher3.views.ActivityContext;
/** /**
* Handles the user event logging in R+. * Handles the user event logging in R+.
@@ -53,6 +54,9 @@ public class StatsLogManager implements ResourceBasedOverride {
public static final int LAUNCHER_STATE_UNCHANGED = 5; public static final int LAUNCHER_STATE_UNCHANGED = 5;
private InstanceId mInstanceId; private InstanceId mInstanceId;
protected @Nullable ActivityContext mActivityContext = null;
/** /**
* Returns event enum based on the two state transition information when swipe * Returns event enum based on the two state transition information when swipe
* gesture happens(to be removed during UserEventDispatcher cleanup). * gesture happens(to be removed during UserEventDispatcher cleanup).
@@ -281,6 +285,9 @@ public class StatsLogManager implements ResourceBasedOverride {
@UiEvent(doc = "User tapped on the share button on overview") @UiEvent(doc = "User tapped on the share button on overview")
LAUNCHER_OVERVIEW_ACTIONS_SHARE(582), LAUNCHER_OVERVIEW_ACTIONS_SHARE(582),
@UiEvent(doc = "User tapped on the split screen button on overview")
LAUNCHER_OVERVIEW_ACTIONS_SPLIT(895),
@UiEvent(doc = "User tapped on the close button in select mode") @UiEvent(doc = "User tapped on the close button in select mode")
LAUNCHER_SELECT_MODE_CLOSE(583), LAUNCHER_SELECT_MODE_CLOSE(583),
@@ -505,7 +512,13 @@ public class StatsLogManager implements ResourceBasedOverride {
LAUNCHER_TURN_OFF_WORK_APPS_TAP(839), LAUNCHER_TURN_OFF_WORK_APPS_TAP(839),
@UiEvent(doc = "Launcher item drop failed since there was not enough room on the screen.") @UiEvent(doc = "Launcher item drop failed since there was not enough room on the screen.")
LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE(872); LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE(872),
@UiEvent(doc = "User long pressed on the taskbar background to hide the taskbar")
LAUNCHER_TASKBAR_LONGPRESS_HIDE(896),
@UiEvent(doc = "User long pressed on the taskbar gesture handle to show the taskbar")
LAUNCHER_TASKBAR_LONGPRESS_SHOW(897);
// ADD MORE // ADD MORE
@@ -645,7 +658,7 @@ public class StatsLogManager implements ResourceBasedOverride {
public StatsLogger logger() { public StatsLogger logger() {
StatsLogger logger = createLogger(); StatsLogger logger = createLogger();
if (mInstanceId != null) { if (mInstanceId != null) {
return logger.withInstanceId(mInstanceId); logger.withInstanceId(mInstanceId);
} }
return logger; return logger;
} }
@@ -668,7 +681,9 @@ public class StatsLogManager implements ResourceBasedOverride {
* Creates a new instance of {@link StatsLogManager} based on provided context. * Creates a new instance of {@link StatsLogManager} based on provided context.
*/ */
public static StatsLogManager newInstance(Context context) { public static StatsLogManager newInstance(Context context) {
return Overrides.getObject(StatsLogManager.class, StatsLogManager manager = Overrides.getObject(StatsLogManager.class,
context.getApplicationContext(), R.string.stats_log_manager_class); context.getApplicationContext(), R.string.stats_log_manager_class);
manager.mActivityContext = ActivityContext.lookupContextNoThrow(context);
return manager;
} }
} }
@@ -27,6 +27,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.dot.DotInfo; import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ViewCache; import com.android.launcher3.util.ViewCache;
@@ -122,15 +123,33 @@ public interface ActivityContext {
} }
/** /**
* Returns the ActivityContext associated with the given Context. * Called just before logging the given item.
*/
default void applyOverwritesToLogItem(LauncherAtom.ItemInfo.Builder itemInfoBuilder) { }
/**
* Returns the ActivityContext associated with the given Context, or throws an exception if
* the Context is not associated with any ActivityContext.
*/ */
static <T extends Context & ActivityContext> T lookupContext(Context context) { static <T extends Context & ActivityContext> T lookupContext(Context context) {
T activityContext = lookupContextNoThrow(context);
if (activityContext == null) {
throw new IllegalArgumentException("Cannot find ActivityContext in parent tree");
}
return activityContext;
}
/**
* Returns the ActivityContext associated with the given Context, or null if
* the Context is not associated with any ActivityContext.
*/
static <T extends Context & ActivityContext> T lookupContextNoThrow(Context context) {
if (context instanceof ActivityContext) { if (context instanceof ActivityContext) {
return (T) context; return (T) context;
} else if (context instanceof ContextWrapper) { } else if (context instanceof ContextWrapper) {
return lookupContext(((ContextWrapper) context).getBaseContext()); return lookupContextNoThrow(((ContextWrapper) context).getBaseContext());
} else { } else {
throw new IllegalArgumentException("Cannot find ActivityContext in parent tree"); return null;
} }
} }
} }