diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
deleted file mode 100644
index 5c2aff6585..0000000000
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ /dev/null
@@ -1,950 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.quickstep.logging;
-
-import static android.view.Surface.ROTATION_180;
-import static android.view.Surface.ROTATION_270;
-import static android.view.Surface.ROTATION_90;
-
-import static androidx.core.util.Preconditions.checkNotNull;
-import static androidx.core.util.Preconditions.checkState;
-
-import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_NON_ACTIONABLE;
-import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.ALL_APPS_CONTAINER;
-import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.EXTENDED_CONTAINERS;
-import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.FOLDER;
-import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.SEARCH_RESULT_CONTAINER;
-import static com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers.ContainerCase.DEVICE_SEARCH_RESULT_CONTAINER;
-import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_SNAPSHOT;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_0;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_180;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_270;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_90;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__ALLAPPS;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__BACKGROUND;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__HOME;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__OVERVIEW;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__LANDSCAPE;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__PORTRAIT;
-import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__SEASCAPE;
-
-import android.content.Context;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.StatsEvent;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.WorkerThread;
-import androidx.slice.SliceItem;
-
-import com.android.internal.jank.Cuj;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.Utilities;
-import com.android.launcher3.logger.LauncherAtom;
-import com.android.launcher3.logger.LauncherAtom.Attribute;
-import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
-import com.android.launcher3.logger.LauncherAtom.FolderContainer.ParentContainerCase;
-import com.android.launcher3.logger.LauncherAtom.FolderIcon;
-import com.android.launcher3.logger.LauncherAtom.FromState;
-import com.android.launcher3.logger.LauncherAtom.LauncherAttributes;
-import com.android.launcher3.logger.LauncherAtom.ToState;
-import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer;
-import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes;
-import com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers;
-import com.android.launcher3.logging.InstanceId;
-import com.android.launcher3.logging.StatsLogManager;
-import com.android.launcher3.model.data.CollectionInfo;
-import com.android.launcher3.model.data.ItemInfo;
-import com.android.launcher3.util.DisplayController;
-import com.android.launcher3.util.Executors;
-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.SysUiStatsLog;
-
-import java.util.Optional;
-import java.util.OptionalInt;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.inject.Inject;
-
-/**
- * This class calls StatsLog compile time generated methods.
- *
- * To see if the logs are properly sent to statsd, execute following command.
- *
- * $ wwdebug (to turn on the logcat printout)
- * $ wwlogcat (see logcat with grep filter on)
- * $ statsd_testdrive (see how ww is writing the proto to statsd buffer)
- *
- */
-public class StatsLogCompatManager extends StatsLogManager {
-
- private static final String TAG = "StatsLog";
- private static final String LATENCY_TAG = "StatsLatencyLog";
- private static final String IMPRESSION_TAG = "StatsImpressionLog";
- private static final boolean IS_VERBOSE = Utilities.isPropertyEnabled(LogConfig.STATSLOG);
- private static final boolean DEBUG = !Utilities.isRunningInTestHarness();
- private static final InstanceId DEFAULT_INSTANCE_ID = InstanceId.fakeInstanceId(0);
- // LauncherAtom.ItemInfo.getDefaultInstance() should be used but until launcher proto migrates
- // from nano to lite, bake constant to prevent robo test failure.
- private static final int DEFAULT_PAGE_INDEX = -2;
- private static final int FOLDER_HIERARCHY_OFFSET = 100;
- private static final int SEARCH_RESULT_HIERARCHY_OFFSET = 200;
- private static final int EXTENDED_CONTAINERS_HIERARCHY_OFFSET = 300;
- private static final int ALL_APPS_HIERARCHY_OFFSET = 400;
-
- /**
- * Flags for converting SearchAttribute to integer value.
- */
- private static final int SEARCH_ATTRIBUTES_CORRECTED_QUERY = 1 << 0;
- private static final int SEARCH_ATTRIBUTES_DIRECT_MATCH = 1 << 1;
- private static final int SEARCH_ATTRIBUTES_ENTRY_STATE_ALL_APPS = 1 << 2;
- private static final int SEARCH_ATTRIBUTES_ENTRY_STATE_QSB = 1 << 3;
- private static final int SEARCH_ATTRIBUTES_ENTRY_STATE_OVERVIEW = 1 << 4;
- private static final int SEARCH_ATTRIBUTES_ENTRY_STATE_TASKBAR = 1 << 5;
-
- public static final CopyOnWriteArrayList LOGS_CONSUMER =
- new CopyOnWriteArrayList<>();
-
- private StatsLogCompatManager(Context context) {
- super(context);
- }
-
- /**
- * This class is purely used to support dagger bindings to be overridden in launcher variants.
- * Very similar to {@link dagger.assisted.AssistedFactory}. But
- * {@link dagger.assisted.AssistedFactory} cannot be overridden and this makes dagger binding
- * difficult.
- */
- public static class StatsLogCompatManagerFactory extends StatsLogManagerFactory {
- @Inject
- StatsLogCompatManagerFactory() {
- super();
- }
-
- public StatsLogManager create(Context context) {
- return new StatsLogCompatManager(context);
- }
- }
-
- @Override
- protected StatsLogger createLogger() {
- return new StatsCompatLogger(mContext, mActivityContext);
- }
-
- @Override
- protected StatsLatencyLogger createLatencyLogger() {
- return new StatsCompatLatencyLogger();
- }
-
- @Override
- protected StatsImpressionLogger createImpressionLogger() {
- return new StatsCompatImpressionLogger();
- }
-
- /**
- * Synchronously writes an itemInfo to stats log
- */
- @WorkerThread
- public static void writeSnapshot(LauncherAtom.ItemInfo info, InstanceId instanceId) {
- if (IS_VERBOSE) {
- Log.d(TAG, String.format("\nwriteSnapshot(%d):\n%s", instanceId.getId(), info));
- }
- if (Utilities.isRunningInTestHarness()) {
- return;
- }
- SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_SNAPSHOT,
- LAUNCHER_WORKSPACE_SNAPSHOT.getId() /* event_id */,
- info.getItemCase().getNumber() /* target_id */,
- instanceId.getId() /* instance_id */,
- 0 /* uid */,
- getPackageName(info) /* package_name */,
- getComponentName(info) /* component_name */,
- getGridX(info, false) /* grid_x */,
- getGridY(info, false) /* grid_y */,
- getPageId(info) /* page_id */,
- getGridX(info, true) /* grid_x_parent */,
- getGridY(info, true) /* grid_y_parent */,
- getParentPageId(info) /* page_id_parent */,
- getHierarchy(info) /* hierarchy */,
- info.getIsWork() /* is_work_profile */,
- 0 /* origin */,
- getCardinality(info) /* cardinality */,
- info.getWidget().getSpanX(),
- info.getWidget().getSpanY(),
- getFeatures(info),
- getAttributes(info) /* attributes */
- );
- }
-
- private static byte[] getAttributes(LauncherAtom.ItemInfo itemInfo) {
- LauncherAttributes.Builder responseBuilder = LauncherAttributes.newBuilder();
- itemInfo.getItemAttributesList().stream().map(Attribute::getNumber).forEach(
- responseBuilder::addItemAttributes);
- return responseBuilder.build().toByteArray();
- }
-
- /**
- * Builds {@link StatsEvent} from {@link LauncherAtom.ItemInfo}. Used for pulled atom callback
- * implementation.
- */
- public static StatsEvent buildStatsEvent(LauncherAtom.ItemInfo info,
- @Nullable InstanceId instanceId) {
- return SysUiStatsLog.buildStatsEvent(
- SysUiStatsLog.LAUNCHER_LAYOUT_SNAPSHOT, // atom ID,
- LAUNCHER_WORKSPACE_SNAPSHOT.getId(), // event_id = 1;
- info.getItemCase().getNumber(), // item_id = 2;
- instanceId == null ? 0 : instanceId.getId(), //instance_id = 3;
- 0, //uid = 4 [(is_uid) = true];
- getPackageName(info), // package_name = 5;
- getComponentName(info), // component_name = 6;
- getGridX(info, false), //grid_x = 7 [default = -1];
- getGridY(info, false), //grid_y = 8 [default = -1];
- getPageId(info), // page_id = 9 [default = -2];
- getGridX(info, true), //grid_x_parent = 10 [default = -1];
- getGridY(info, true), //grid_y_parent = 11 [default = -1];
- getParentPageId(info), //page_id_parent = 12 [default = -2];
- getHierarchy(info), // container_id = 13;
- info.getIsWork(), // is_work_profile = 14;
- 0, // attribute_id = 15;
- getCardinality(info), // cardinality = 16;
- info.getWidget().getSpanX(), // span_x = 17 [default = 1];
- info.getWidget().getSpanY(), // span_y = 18 [default = 1];
- getAttributes(info) /* attributes = 19 [(log_mode) = MODE_BYTES] */,
- info.getIsKidsMode() /* is_kids_mode = 20 */
- );
- }
-
- /**
- * Helps to construct and write statsd compatible log message.
- */
- private static class StatsCompatLogger implements StatsLogger {
-
- private static final ItemInfo DEFAULT_ITEM_INFO = new ItemInfo();
- static {
- DEFAULT_ITEM_INFO.itemType = ITEM_TYPE_NON_ACTIONABLE;
- }
- private final Context mContext;
- private final Optional mActivityContext;
- private ItemInfo mItemInfo = DEFAULT_ITEM_INFO;
- private InstanceId mInstanceId = DEFAULT_INSTANCE_ID;
- private OptionalInt mRank = OptionalInt.empty();
- private Optional mContainerInfo = Optional.empty();
- private int mSrcState = LAUNCHER_STATE_UNSPECIFIED;
- private int mDstState = LAUNCHER_STATE_UNSPECIFIED;
- private Optional mFromState = Optional.empty();
- private Optional mToState = Optional.empty();
- private Optional mEditText = Optional.empty();
- private SliceItem mSliceItem;
- private LauncherAtom.Slice mSlice;
- private Optional mCardinality = Optional.empty();
- private int mInputType = SysUiStatsLog.LAUNCHER_UICHANGED__INPUT_TYPE__UNKNOWN;
- private Optional mFeatures = Optional.empty();
- private Optional mPackageName = Optional.empty();
- /**
- * Indicates the current rotation of the display. Uses {@link android.view.Surface values.}
- */
- private final int mDisplayRotation;
-
- StatsCompatLogger(Context context, ActivityContext activityContext) {
- mContext = context;
- mActivityContext = Optional.ofNullable(activityContext);
- mDisplayRotation = DisplayController.INSTANCE.get(mContext).getInfo().rotation;
- }
-
- @Override
- public StatsLogger withItemInfo(ItemInfo itemInfo) {
- if (mContainerInfo.isPresent()) {
- throw new IllegalArgumentException(
- "ItemInfo and ContainerInfo are mutual exclusive; cannot log both.");
- }
- this.mItemInfo = itemInfo;
- return this;
- }
-
- @Override
- public StatsLogger withInstanceId(InstanceId instanceId) {
- this.mInstanceId = instanceId;
- return this;
- }
-
- @Override
- public StatsLogger withRank(int rank) {
- this.mRank = OptionalInt.of(rank);
- return this;
- }
-
- @Override
- public StatsLogger withSrcState(int srcState) {
- this.mSrcState = srcState;
- return this;
- }
-
- @Override
- public StatsLogger withDstState(int dstState) {
- this.mDstState = dstState;
- return this;
- }
-
- @Override
- public StatsLogger withContainerInfo(ContainerInfo containerInfo) {
- checkState(mItemInfo == DEFAULT_ITEM_INFO,
- "ItemInfo and ContainerInfo are mutual exclusive; cannot log both.");
- this.mContainerInfo = Optional.of(containerInfo);
- return this;
- }
-
- @Override
- public StatsLogger withFromState(FromState fromState) {
- this.mFromState = Optional.of(fromState);
- return this;
- }
-
- @Override
- public StatsLogger withToState(ToState toState) {
- this.mToState = Optional.of(toState);
- return this;
- }
-
- @Override
- public StatsLogger withEditText(String editText) {
- this.mEditText = Optional.of(editText);
- return this;
- }
-
- @Override
- public StatsLogger withSliceItem(@NonNull SliceItem sliceItem) {
- checkState(mItemInfo == DEFAULT_ITEM_INFO && mSlice == null,
- "ItemInfo, Slice and SliceItem are mutual exclusive; cannot set more than one"
- + " of them.");
- this.mSliceItem = checkNotNull(sliceItem, "expected valid sliceItem but received null");
- return this;
- }
-
- @Override
- public StatsLogger withSlice(LauncherAtom.Slice slice) {
- checkState(mItemInfo == DEFAULT_ITEM_INFO && mSliceItem == null,
- "ItemInfo, Slice and SliceItem are mutual exclusive; cannot set more than one"
- + " of them.");
- checkNotNull(slice, "expected valid slice but received null");
- checkNotNull(slice.getUri(), "expected valid slice uri but received null");
- this.mSlice = slice;
- return this;
- }
-
- @Override
- public StatsLogger withCardinality(int cardinality) {
- this.mCardinality = Optional.of(cardinality);
- return this;
- }
-
- @Override
- public StatsLogger withInputType(int inputType) {
- this.mInputType = inputType;
- return this;
- }
-
- @Override
- public StatsLogger withFeatures(int feature) {
- this.mFeatures = Optional.of(feature);
- return this;
- }
-
- @Override
- public StatsLogger withPackageName(@Nullable String packageName) {
- mPackageName = Optional.ofNullable(packageName);
- return this;
- }
-
- @Override
- public void log(EventEnum event) {
- if (DEBUG) {
- String name = (event instanceof Enum) ? ((Enum) event).name() :
- event.getId() + "";
- Log.d(TAG, name);
- }
-
- if (mSlice == null && mSliceItem != null) {
- mSlice = LauncherAtom.Slice.newBuilder().setUri(
- mSliceItem.getSlice().getUri().toString()).build();
- }
-
- if (mSlice != null) {
- Executors.MODEL_EXECUTOR.execute(
- () -> {
- LauncherAtom.ItemInfo.Builder itemInfoBuilder =
- LauncherAtom.ItemInfo.newBuilder().setSlice(mSlice);
- mContainerInfo.ifPresent(itemInfoBuilder::setContainerInfo);
- write(event, applyOverwrites(itemInfoBuilder.build()));
- });
- return;
- }
-
- if (mItemInfo == null) {
- return;
- }
-
- // Item is inside a collection, fetch collection info in a BG thread
- // and then write to StatsLog.
- if (mItemInfo.container < 0) {
- LauncherAppState.INSTANCE.get(mContext).getModel().enqueueModelUpdateTask(
- (taskController, dataModel, apps) -> write(event, applyOverwrites(
- mItemInfo.buildProto(
- (CollectionInfo) dataModel.itemsIdMap
- .get(mItemInfo.container),
- mContext))));
- }
- }
-
- @Override
- public void sendToInteractionJankMonitor(EventEnum event, View view) {
- if (!(event instanceof LauncherEvent)) {
- return;
- }
- switch ((LauncherEvent) event) {
- case LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN:
- InteractionJankMonitorWrapper.begin(
- view,
- Cuj.CUJ_LAUNCHER_ALL_APPS_SCROLL);
- break;
- case LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END:
- InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_ALL_APPS_SCROLL);
- break;
- case LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_BEGIN:
- InteractionJankMonitorWrapper.begin(view, Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_LOCK);
- break;
- case LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_END:
- InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_LOCK);
- break;
- case LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_BEGIN:
- InteractionJankMonitorWrapper.begin(
- view,
- Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_UNLOCK);
- break;
- case LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_END:
- InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_UNLOCK);
- break;
- case LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_BEGIN:
- InteractionJankMonitorWrapper.begin(
- view,
- Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_EXPAND);
- break;
- case LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_END:
- InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_EXPAND);
- break;
- case LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_BEGIN:
- InteractionJankMonitorWrapper.begin(
- view,
- Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_SHRINK);
- break;
- case LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_END:
- InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_SHRINK);
- break;
- default:
- break;
- }
- }
-
- private LauncherAtom.ItemInfo applyOverwrites(LauncherAtom.ItemInfo atomInfo) {
- LauncherAtom.ItemInfo.Builder itemInfoBuilder = atomInfo.toBuilder();
-
- mRank.ifPresent(itemInfoBuilder::setRank);
- mContainerInfo.ifPresent(itemInfoBuilder::setContainerInfo);
-
- mActivityContext.ifPresent(activityContext ->
- activityContext.applyOverwritesToLogItem(itemInfoBuilder));
-
- if (mFromState.isPresent() || mToState.isPresent() || mEditText.isPresent()) {
- FolderIcon.Builder folderIconBuilder = itemInfoBuilder
- .getFolderIcon()
- .toBuilder();
- mFromState.ifPresent(folderIconBuilder::setFromLabelState);
- mToState.ifPresent(folderIconBuilder::setToLabelState);
- mEditText.ifPresent(folderIconBuilder::setLabelInfo);
- itemInfoBuilder.setFolderIcon(folderIconBuilder);
- }
- return itemInfoBuilder.build();
- }
-
- @WorkerThread
- private void write(EventEnum event, LauncherAtom.ItemInfo atomInfo) {
- InstanceId instanceId = mInstanceId;
- int srcState = mSrcState;
- int dstState = mDstState;
- int inputType = mInputType;
- String packageName = mPackageName.orElseGet(() -> getPackageName(atomInfo));
- if (IS_VERBOSE) {
- String name = (event instanceof Enum) ? ((Enum) event).name() :
- event.getId() + "";
- StringBuilder logStringBuilder = new StringBuilder("\n");
- if (instanceId != DEFAULT_INSTANCE_ID) {
- logStringBuilder.append(String.format("InstanceId:%s ", instanceId));
- }
- logStringBuilder.append(name);
- if (srcState != LAUNCHER_STATE_UNSPECIFIED
- || dstState != LAUNCHER_STATE_UNSPECIFIED) {
- logStringBuilder.append(
- String.format("(State:%s->%s)", getStateString(srcState),
- getStateString(dstState)));
- }
- if (atomInfo.hasContainerInfo()) {
- logStringBuilder.append("\n").append(atomInfo);
- }
- if (!TextUtils.isEmpty(packageName)) {
- logStringBuilder.append(String.format("\nPackage name: %s", packageName));
- }
- Log.d(TAG, logStringBuilder.toString());
- }
-
- for (StatsLogConsumer consumer : LOGS_CONSUMER) {
- consumer.consume(event, atomInfo);
- }
-
- // TODO: remove this when b/231648228 is fixed.
- if (Utilities.isRunningInTestHarness()) {
- return;
- }
- int cardinality = mCardinality.orElseGet(() -> getCardinality(atomInfo));
- int features = mFeatures.orElseGet(() -> getFeatures(atomInfo));
- SysUiStatsLog.write(
- SysUiStatsLog.LAUNCHER_EVENT,
- SysUiStatsLog.LAUNCHER_UICHANGED__ACTION__DEFAULT_ACTION /* deprecated */,
- srcState,
- dstState,
- null /* launcher extensions, deprecated */,
- false /* quickstep_enabled, deprecated */,
- event.getId() /* event_id */,
- atomInfo.getItemCase().getNumber() /* target_id */,
- instanceId.getId() /* instance_id TODO */,
- 0 /* uid TODO */,
- packageName /* package_name */,
- getComponentName(atomInfo) /* component_name */,
- getGridX(atomInfo, false) /* grid_x */,
- getGridY(atomInfo, false) /* grid_y */,
- getPageId(atomInfo) /* page_id */,
- getGridX(atomInfo, true) /* grid_x_parent */,
- getGridY(atomInfo, true) /* grid_y_parent */,
- getParentPageId(atomInfo) /* page_id_parent */,
- getHierarchy(atomInfo) /* hierarchy */,
- false /* is_work_profile, deprecated */,
- atomInfo.getRank() /* rank */,
- atomInfo.getFolderIcon().getFromLabelState().getNumber() /* fromState */,
- atomInfo.getFolderIcon().getToLabelState().getNumber() /* toState */,
- atomInfo.getFolderIcon().getLabelInfo() /* edittext */,
- cardinality /* cardinality */,
- features /* features */,
- getSearchAttributes(atomInfo) /* searchAttributes */,
- getAttributes(atomInfo) /* attributes */,
- inputType /* input_type */,
- atomInfo.getUserType() /* user_type */,
- getDisplayRotation() /* display_rotation */,
- getRecentsOrientationHandler(atomInfo) /* recents_orientation_handler */);
- }
-
- private int getDisplayRotation() {
- return switch (mDisplayRotation) {
- case ROTATION_90 -> LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_90;
- case ROTATION_180 -> LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_180;
- case ROTATION_270 -> LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_270;
- default -> LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_0;
- };
- }
-
- private int getRecentsOrientationHandler(LauncherAtom.ItemInfo itemInfo) {
- var orientationHandler =
- itemInfo.getContainerInfo().getTaskSwitcherContainer().getOrientationHandler();
- return switch (orientationHandler) {
- case PORTRAIT -> LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__PORTRAIT;
- case LANDSCAPE -> LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__LANDSCAPE;
- case SEASCAPE -> LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__SEASCAPE;
- };
- }
- }
-
- /**
- * Helps to construct and log statsd compatible latency events.
- */
- private static class StatsCompatLatencyLogger implements StatsLatencyLogger {
- private InstanceId mInstanceId = DEFAULT_INSTANCE_ID;
- private LatencyType mType = LatencyType.UNKNOWN;
- private int mPackageId = 0;
- private long mLatencyInMillis;
- private int mQueryLength = -1;
- private int mSubEventType = 0;
- private int mCardinality = -1;
-
- @Override
- public StatsLatencyLogger withInstanceId(InstanceId instanceId) {
- this.mInstanceId = instanceId;
- return this;
- }
-
- @Override
- public StatsLatencyLogger withType(LatencyType type) {
- this.mType = type;
- return this;
- }
-
- @Override
- public StatsLatencyLogger withPackageId(int packageId) {
- this.mPackageId = packageId;
- return this;
- }
-
- @Override
- public StatsLatencyLogger withLatency(long latencyInMillis) {
- this.mLatencyInMillis = latencyInMillis;
- return this;
- }
-
- @Override
- public StatsLatencyLogger withQueryLength(int queryLength) {
- this.mQueryLength = queryLength;
- return this;
- }
-
- @Override
- public StatsLatencyLogger withSubEventType(int type) {
- this.mSubEventType = type;
- return this;
- }
-
- @Override
- public StatsLatencyLogger withCardinality(int cardinality) {
- this.mCardinality = cardinality;
- return this;
- }
-
- @Override
- public void log(EventEnum event) {
- if (IS_VERBOSE) {
- String name = (event instanceof Enum) ? ((Enum) event).name() :
- event.getId() + "";
- StringBuilder logStringBuilder = new StringBuilder("\n");
- logStringBuilder.append(String.format("InstanceId:%s ", mInstanceId));
- logStringBuilder.append(String.format("%s=%sms", name, mLatencyInMillis));
- Log.d(LATENCY_TAG, logStringBuilder.toString());
- }
-
- SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_LATENCY,
- event.getId(), // event_id
- mInstanceId.getId(), // instance_id
- mPackageId, // package_id
- mLatencyInMillis, // latency_in_millis
- mType.getId(), //type
- mQueryLength, // query_length
- mSubEventType, // sub_event_type
- mCardinality // cardinality
- );
- }
- }
-
- /**
- * Helps to construct and log statsd compatible impression events.
- */
- private static class StatsCompatImpressionLogger implements StatsImpressionLogger {
- private InstanceId mInstanceId = DEFAULT_INSTANCE_ID;
- private State mLauncherState = State.UNKNOWN;
- private int mQueryLength = -1;
-
- // Fields used for Impression Logging V2.
- private int mResultType;
- private boolean mAboveKeyboard = false;
- private int mUid;
- private int mResultSource;
-
- @Override
- public StatsImpressionLogger withInstanceId(InstanceId instanceId) {
- this.mInstanceId = instanceId;
- return this;
- }
-
- @Override
- public StatsImpressionLogger withState(State state) {
- this.mLauncherState = state;
- return this;
- }
-
- @Override
- public StatsImpressionLogger withQueryLength(int queryLength) {
- this.mQueryLength = queryLength;
- return this;
- }
-
- @Override
- public StatsImpressionLogger withResultType(int resultType) {
- mResultType = resultType;
- return this;
- }
-
-
- @Override
- public StatsImpressionLogger withAboveKeyboard(boolean aboveKeyboard) {
- mAboveKeyboard = aboveKeyboard;
- return this;
- }
-
- @Override
- public StatsImpressionLogger withUid(int uid) {
- mUid = uid;
- return this;
- }
-
- @Override
- public StatsImpressionLogger withResultSource(int resultSource) {
- mResultSource = resultSource;
- return this;
- }
-
- @Override
- public void log(EventEnum event) {
- if (IS_VERBOSE) {
- String name = (event instanceof Enum) ? ((Enum) event).name() :
- event.getId() + "";
- StringBuilder logStringBuilder = new StringBuilder("\n");
- logStringBuilder.append(String.format("InstanceId:%s ", mInstanceId));
- logStringBuilder.append(String.format("ImpressionEvent:%s ", name));
- logStringBuilder.append(String.format("\n\tLauncherState = %s ", mLauncherState));
- logStringBuilder.append(String.format("\tQueryLength = %s ", mQueryLength));
- logStringBuilder.append(String.format(
- "\n\t ResultType = %s is_above_keyboard = %s"
- + " uid = %s result_source = %s",
- mResultType,
- mAboveKeyboard, mUid, mResultSource));
-
- Log.d(IMPRESSION_TAG, logStringBuilder.toString());
- }
-
-
- SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_IMPRESSION_EVENT_V2,
- event.getId(), // event_id
- mInstanceId.getId(), // instance_id
- mLauncherState.getLauncherState(), // state
- mQueryLength, // query_length
- mResultType, //result type
- mAboveKeyboard, // above keyboard
- mUid, // uid
- mResultSource // result source
-
- );
- }
- }
-
- private static int getCardinality(LauncherAtom.ItemInfo info) {
- if (Utilities.isRunningInTestHarness()) {
- return 0;
- }
- switch (info.getContainerInfo().getContainerCase()) {
- case PREDICTED_HOTSEAT_CONTAINER:
- return info.getContainerInfo().getPredictedHotseatContainer().getCardinality();
- case TASK_BAR_CONTAINER:
- return info.getContainerInfo().getTaskBarContainer().getCardinality();
- case SEARCH_RESULT_CONTAINER:
- return info.getContainerInfo().getSearchResultContainer().getQueryLength();
- case EXTENDED_CONTAINERS:
- ExtendedContainers extendedCont = info.getContainerInfo().getExtendedContainers();
- if (extendedCont.getContainerCase() == DEVICE_SEARCH_RESULT_CONTAINER) {
- DeviceSearchResultContainer deviceSearchResultCont = extendedCont
- .getDeviceSearchResultContainer();
- return deviceSearchResultCont.hasQueryLength() ? deviceSearchResultCont
- .getQueryLength() : -1;
- }
- default:
- return switch (info.getItemCase()) {
- case FOLDER_ICON -> info.getFolderIcon().getCardinality();
- case TASK_VIEW -> info.getTaskView().getCardinality();
- default -> 0;
- };
- }
- }
-
- private static String getPackageName(LauncherAtom.ItemInfo info) {
- return switch (info.getItemCase()) {
- case APPLICATION -> info.getApplication().getPackageName();
- case SHORTCUT -> info.getShortcut().getShortcutName();
- case WIDGET -> info.getWidget().getPackageName();
- case TASK -> info.getTask().getPackageName();
- case SEARCH_ACTION_ITEM -> info.getSearchActionItem().getPackageName();
- default -> null;
- };
- }
-
- private static String getComponentName(LauncherAtom.ItemInfo info) {
- return switch (info.getItemCase()) {
- case APPLICATION -> info.getApplication().getComponentName();
- case SHORTCUT -> info.getShortcut().getShortcutName();
- case WIDGET -> info.getWidget().getComponentName();
- case TASK -> info.getTask().getComponentName();
- case TASK_VIEW -> info.getTaskView().getComponentName();
- case SEARCH_ACTION_ITEM -> info.getSearchActionItem().getTitle();
- case SLICE -> info.getSlice().getUri();
- default -> null;
- };
- }
-
- private static int getGridX(LauncherAtom.ItemInfo info, boolean parent) {
- ContainerInfo containerInfo = info.getContainerInfo();
- if (containerInfo.getContainerCase() == FOLDER) {
- if (parent) {
- return containerInfo.getFolder().getWorkspace().getGridX();
- } else {
- return containerInfo.getFolder().getGridX();
- }
- } else if (containerInfo.getContainerCase() == EXTENDED_CONTAINERS) {
- return containerInfo.getExtendedContainers()
- .getDeviceSearchResultContainer().getGridX();
- } else {
- return containerInfo.getWorkspace().getGridX();
- }
- }
-
- private static int getGridY(LauncherAtom.ItemInfo info, boolean parent) {
- if (info.getContainerInfo().getContainerCase() == FOLDER) {
- if (parent) {
- return info.getContainerInfo().getFolder().getWorkspace().getGridY();
- } else {
- return info.getContainerInfo().getFolder().getGridY();
- }
- } else {
- return info.getContainerInfo().getWorkspace().getGridY();
- }
- }
-
- private static int getPageId(LauncherAtom.ItemInfo info) {
- return switch (info.getItemCase()) {
- case TASK -> info.getTask().getIndex();
- case TASK_VIEW -> info.getTaskView().getIndex();
- default -> getPageIdFromContainerInfo(info.getContainerInfo());
- };
- }
-
- private static int getPageIdFromContainerInfo(LauncherAtom.ContainerInfo containerInfo) {
- return switch (containerInfo.getContainerCase()) {
- case FOLDER -> containerInfo.getFolder().getPageIndex();
- case HOTSEAT -> containerInfo.getHotseat().getIndex();
- case PREDICTED_HOTSEAT_CONTAINER ->
- containerInfo.getPredictedHotseatContainer().getIndex();
- case TASK_BAR_CONTAINER -> containerInfo.getTaskBarContainer().getIndex();
- default -> containerInfo.getWorkspace().getPageIndex();
- };
- }
-
- private static int getParentPageId(LauncherAtom.ItemInfo info) {
- return switch (info.getContainerInfo().getContainerCase()) {
- case FOLDER -> {
- if (info.getContainerInfo().getFolder().getParentContainerCase()
- == ParentContainerCase.HOTSEAT) {
- yield info.getContainerInfo().getFolder().getHotseat().getIndex();
- }
- yield info.getContainerInfo().getFolder().getWorkspace().getPageIndex();
- }
- case SEARCH_RESULT_CONTAINER ->
- info.getContainerInfo().getSearchResultContainer().getWorkspace()
- .getPageIndex();
- default -> info.getContainerInfo().getWorkspace().getPageIndex();
- };
- }
-
- private static int getHierarchy(LauncherAtom.ItemInfo info) {
- if (Utilities.isRunningInTestHarness()) {
- return 0;
- }
- if (info.getContainerInfo().getContainerCase() == FOLDER) {
- return info.getContainerInfo().getFolder().getParentContainerCase().getNumber()
- + FOLDER_HIERARCHY_OFFSET;
- } else if (info.getContainerInfo().getContainerCase() == SEARCH_RESULT_CONTAINER) {
- return info.getContainerInfo().getSearchResultContainer().getParentContainerCase()
- .getNumber() + SEARCH_RESULT_HIERARCHY_OFFSET;
- } else if (info.getContainerInfo().getContainerCase() == EXTENDED_CONTAINERS) {
- return info.getContainerInfo().getExtendedContainers().getContainerCase().getNumber()
- + EXTENDED_CONTAINERS_HIERARCHY_OFFSET;
- } else if (info.getContainerInfo().getContainerCase() == ALL_APPS_CONTAINER) {
- return info.getContainerInfo().getAllAppsContainer().getParentContainerCase()
- .getNumber() + ALL_APPS_HIERARCHY_OFFSET;
- } else {
- return info.getContainerInfo().getContainerCase().getNumber();
- }
- }
-
- private static String getStateString(int state) {
- return switch (state) {
- case LAUNCHER_UICHANGED__DST_STATE__BACKGROUND -> "BACKGROUND";
- case LAUNCHER_UICHANGED__DST_STATE__HOME -> "HOME";
- case LAUNCHER_UICHANGED__DST_STATE__OVERVIEW -> "OVERVIEW";
- case LAUNCHER_UICHANGED__DST_STATE__ALLAPPS -> "ALLAPPS";
- default -> "INVALID";
- };
- }
-
- private static int getFeatures(LauncherAtom.ItemInfo info) {
- return switch (info.getItemCase()) {
- case WIDGET -> info.getWidget().getWidgetFeatures();
- case TASK_VIEW -> info.getTaskView().getType();
- default -> 0;
- };
- }
-
- private static int getSearchAttributes(LauncherAtom.ItemInfo info) {
- if (Utilities.isRunningInTestHarness()) {
- return 0;
- }
- ContainerInfo containerInfo = info.getContainerInfo();
- if (containerInfo.getContainerCase() == EXTENDED_CONTAINERS
- && containerInfo.getExtendedContainers().getContainerCase()
- == DEVICE_SEARCH_RESULT_CONTAINER
- && containerInfo.getExtendedContainers()
- .getDeviceSearchResultContainer().hasSearchAttributes()
- ) {
- return searchAttributesToInt(containerInfo.getExtendedContainers()
- .getDeviceSearchResultContainer().getSearchAttributes());
- }
- return 0;
- }
-
- private static int searchAttributesToInt(SearchAttributes searchAttributes) {
- int response = 0;
- if (searchAttributes.getCorrectedQuery()) {
- response = response | SEARCH_ATTRIBUTES_CORRECTED_QUERY;
- }
- if (searchAttributes.getDirectMatch()) {
- response = response | SEARCH_ATTRIBUTES_DIRECT_MATCH;
- }
- if (searchAttributes.getEntryState() == SearchAttributes.EntryState.ALL_APPS) {
- response = response | SEARCH_ATTRIBUTES_ENTRY_STATE_ALL_APPS;
- } else if (searchAttributes.getEntryState() == SearchAttributes.EntryState.QSB) {
- response = response | SEARCH_ATTRIBUTES_ENTRY_STATE_QSB;
- } else if (searchAttributes.getEntryState() == SearchAttributes.EntryState.OVERVIEW) {
- response = response | SEARCH_ATTRIBUTES_ENTRY_STATE_OVERVIEW;
- } else if (searchAttributes.getEntryState() == SearchAttributes.EntryState.TASKBAR) {
- response = response | SEARCH_ATTRIBUTES_ENTRY_STATE_TASKBAR;
- }
-
- return response;
- }
-
- /**
- * Interface to get stats log while it is dispatched to the system
- */
- public interface StatsLogConsumer {
-
- @WorkerThread
- void consume(EventEnum event, LauncherAtom.ItemInfo atomInfo);
- }
-}
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.kt b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.kt
new file mode 100644
index 0000000000..e1d35fdffe
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.kt
@@ -0,0 +1,798 @@
+/*
+ * Copyright (C) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.quickstep.logging
+
+import android.content.Context
+import android.util.Log
+import android.util.StatsEvent
+import android.view.Surface
+import android.view.View
+import androidx.annotation.WorkerThread
+import androidx.slice.SliceItem
+import com.android.internal.jank.Cuj
+import com.android.launcher3.LauncherAppState
+import com.android.launcher3.LauncherSettings.Favorites
+import com.android.launcher3.Utilities
+import com.android.launcher3.logger.LauncherAtom
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.ALL_APPS_CONTAINER
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.EXTENDED_CONTAINERS
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.FOLDER
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.HOTSEAT
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.PREDICTED_HOTSEAT_CONTAINER
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.SEARCH_RESULT_CONTAINER
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.TASK_BAR_CONTAINER
+import com.android.launcher3.logger.LauncherAtom.FolderContainer.ParentContainerCase
+import com.android.launcher3.logger.LauncherAtom.FromState
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.APPLICATION
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.FOLDER_ICON
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.SEARCH_ACTION_ITEM
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.SHORTCUT
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.SLICE
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.TASK
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.TASK_VIEW
+import com.android.launcher3.logger.LauncherAtom.ItemInfo.ItemCase.WIDGET
+import com.android.launcher3.logger.LauncherAtom.LauncherAttributes
+import com.android.launcher3.logger.LauncherAtom.Slice
+import com.android.launcher3.logger.LauncherAtom.TaskSwitcherContainer.OrientationHandler.LANDSCAPE
+import com.android.launcher3.logger.LauncherAtom.TaskSwitcherContainer.OrientationHandler.PORTRAIT
+import com.android.launcher3.logger.LauncherAtom.TaskSwitcherContainer.OrientationHandler.SEASCAPE
+import com.android.launcher3.logger.LauncherAtom.ToState
+import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes
+import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes.EntryState.ALL_APPS
+import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes.EntryState.OVERVIEW
+import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes.EntryState.QSB
+import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes.EntryState.TASKBAR
+import com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers.ContainerCase.DEVICE_SEARCH_RESULT_CONTAINER
+import com.android.launcher3.logging.InstanceId
+import com.android.launcher3.logging.StatsLogManager
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_BEGIN
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_END
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_BEGIN
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_END
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_SNAPSHOT
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_BEGIN
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_END
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_BEGIN
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_END
+import com.android.launcher3.logging.StatsLogManager.StatsImpressionLogger.State
+import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.LatencyType
+import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.LatencyType.UNKNOWN
+import com.android.launcher3.model.data.CollectionInfo
+import com.android.launcher3.model.data.ItemInfo
+import com.android.launcher3.util.DisplayController
+import com.android.launcher3.util.Executors
+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.SysUiStatsLog
+import java.util.concurrent.CopyOnWriteArrayList
+import javax.inject.Inject
+
+/**
+ * This class calls StatsLog compile time generated methods.
+ *
+ * To see if the logs are properly sent to statsd, execute following command.
+ *
+ * $ wwdebug (to turn on the logcat printout) $ wwlogcat (see logcat with grep filter on) $
+ * statsd_testdrive (see how ww is writing the proto to statsd buffer)
+ */
+class StatsLogCompatManager private constructor(context: Context) : StatsLogManager(context) {
+ /**
+ * This class is purely used to support dagger bindings to be overridden in launcher variants.
+ * Very similar to [dagger.assisted.AssistedFactory]. But [dagger.assisted.AssistedFactory]
+ * cannot be overridden and this makes dagger binding difficult.
+ */
+ class StatsLogCompatManagerFactory @Inject internal constructor() : StatsLogManagerFactory() {
+ override fun create(context: Context): StatsLogManager {
+ return StatsLogCompatManager(context)
+ }
+ }
+
+ override fun createLogger(): StatsLogger {
+ return StatsCompatLogger(mContext, mActivityContext)
+ }
+
+ override fun createLatencyLogger(): StatsLatencyLogger {
+ return StatsCompatLatencyLogger()
+ }
+
+ override fun createImpressionLogger(): StatsImpressionLogger {
+ return StatsCompatImpressionLogger()
+ }
+
+ /** Helps to construct and write statsd compatible log message. */
+ private class StatsCompatLogger(
+ private val context: Context,
+ private val activityContext: ActivityContext?,
+ ) : StatsLogger {
+
+ private var mItemInfo: ItemInfo? = DEFAULT_ITEM_INFO
+ private var mInstanceId: InstanceId? = DEFAULT_INSTANCE_ID
+ private var mRank: Int? = null
+ private var mContainerInfo: ContainerInfo? = null
+ private var mSrcState = LAUNCHER_STATE_UNSPECIFIED
+ private var mDstState = LAUNCHER_STATE_UNSPECIFIED
+ private var mFromState: FromState? = null
+ private var mToState: ToState? = null
+ private var mEditText: String? = null
+ private var mSliceItem: SliceItem? = null
+ private var mSlice: Slice? = null
+ private var mCardinality: Int? = null
+ private var mInputType = SysUiStatsLog.LAUNCHER_UICHANGED__INPUT_TYPE__UNKNOWN
+ private var mFeatures: Int? = null
+ private var mPackageName: String? = null
+
+ /** Indicates the current rotation of the display. Uses [values.][android.view.Surface] */
+ private val mDisplayRotation = DisplayController.INSTANCE[context].info.rotation
+
+ override fun withItemInfo(itemInfo: ItemInfo?) = apply {
+ require(mContainerInfo == null) {
+ "ItemInfo and ContainerInfo are mutual exclusive; cannot log both."
+ }
+ mItemInfo = itemInfo
+ }
+
+ override fun withInstanceId(instanceId: InstanceId?) = apply { mInstanceId = instanceId }
+
+ override fun withRank(rank: Int) = apply { mRank = rank }
+
+ override fun withSrcState(srcState: Int) = apply { mSrcState = srcState }
+
+ override fun withDstState(dstState: Int) = apply { mDstState = dstState }
+
+ override fun withContainerInfo(containerInfo: ContainerInfo?) = apply {
+ require(mItemInfo === DEFAULT_ITEM_INFO) {
+ "ItemInfo and ContainerInfo are mutual exclusive; cannot log both."
+ }
+ this.mContainerInfo = containerInfo
+ }
+
+ override fun withFromState(fromState: FromState?) = apply { this.mFromState = fromState }
+
+ override fun withToState(toState: ToState?) = apply { this.mToState = toState }
+
+ override fun withEditText(editText: String?) = apply { this.mEditText = editText }
+
+ override fun withSliceItem(sliceItem: SliceItem) = apply {
+ require(mItemInfo === DEFAULT_ITEM_INFO && mSlice == null) {
+ "ItemInfo, Slice and SliceItem are mutual exclusive; cannot set more than one of them."
+ }
+ this.mSliceItem = sliceItem
+ }
+
+ override fun withSlice(slice: Slice) = apply {
+ require(mItemInfo === DEFAULT_ITEM_INFO && mSliceItem == null) {
+ "ItemInfo, Slice and SliceItem are mutual exclusive; cannot set more than one of them."
+ }
+ this.mSlice = slice
+ }
+
+ override fun withCardinality(cardinality: Int) = apply { this.mCardinality = cardinality }
+
+ override fun withInputType(inputType: Int) = apply { this.mInputType = inputType }
+
+ override fun withFeatures(feature: Int) = apply { this.mFeatures = feature }
+
+ override fun withPackageName(packageName: String?) = apply { mPackageName = packageName }
+
+ override fun log(event: EventEnum) {
+ if (DEBUG) {
+ val name = if (event is Enum<*>) event.name else event.id.toString() + ""
+ Log.d(TAG, name)
+ }
+
+ if (mSlice == null && mSliceItem != null)
+ mSlice = Slice.newBuilder().setUri(mSliceItem!!.slice!!.uri.toString()).build()
+
+ if (mSlice != null) {
+ Executors.MODEL_EXECUTOR.execute {
+ val itemInfoBuilder = LauncherAtom.ItemInfo.newBuilder().setSlice(mSlice)
+ mContainerInfo?.let { itemInfoBuilder.setContainerInfo(it) }
+ write(event, applyOverwrites(itemInfoBuilder.build()))
+ }
+ return
+ }
+
+ val info = mItemInfo ?: return
+
+ // If the item is inside a collection, fetch collection info in a BG thread
+ // and then write to StatsLog.
+ LauncherAppState.INSTANCE[context].model.enqueueModelUpdateTask { _, dataModel, _ ->
+ write(
+ event,
+ applyOverwrites(
+ info.buildProto(
+ dataModel.itemsIdMap[info.container] as CollectionInfo?,
+ context,
+ )
+ ),
+ )
+ }
+ }
+
+ override fun sendToInteractionJankMonitor(event: EventEnum?, view: View?) {
+ if (event !is LauncherEvent) return
+ when (event) {
+ LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN ->
+ InteractionJankMonitorWrapper.begin(view, Cuj.CUJ_LAUNCHER_ALL_APPS_SCROLL)
+
+ LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END ->
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_ALL_APPS_SCROLL)
+ LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_BEGIN ->
+ InteractionJankMonitorWrapper.begin(view, Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_LOCK)
+
+ LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_END ->
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_LOCK)
+ LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_BEGIN ->
+ InteractionJankMonitorWrapper.begin(view, Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_UNLOCK)
+
+ LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_END ->
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_PRIVATE_SPACE_UNLOCK)
+ LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_BEGIN ->
+ InteractionJankMonitorWrapper.begin(
+ view,
+ Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_EXPAND,
+ )
+
+ LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_END ->
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_EXPAND)
+
+ LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_BEGIN ->
+ InteractionJankMonitorWrapper.begin(
+ view,
+ Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_SHRINK,
+ )
+
+ LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_END ->
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_WORK_UTILITY_VIEW_SHRINK)
+
+ else -> {}
+ }
+ }
+
+ fun applyOverwrites(atomInfo: LauncherAtom.ItemInfo): LauncherAtom.ItemInfo =
+ atomInfo
+ .toBuilder()
+ .apply {
+ mRank?.let { setRank(it) }
+ mContainerInfo?.let { setContainerInfo(it) }
+ activityContext?.applyOverwritesToLogItem(this)
+
+ if (mFromState != null || mToState != null || mEditText != null) {
+ val folderIconBuilder = folderIcon.toBuilder()
+ mFromState?.let { folderIconBuilder.setFromLabelState(it) }
+ mToState?.let { folderIconBuilder.setToLabelState(it) }
+ mEditText?.let { folderIconBuilder.setLabelInfo(it) }
+
+ setFolderIcon(folderIconBuilder)
+ }
+ }
+ .build()
+
+ @WorkerThread
+ fun write(event: EventEnum, atomInfo: LauncherAtom.ItemInfo) {
+ val instanceId = mInstanceId
+ val srcState = mSrcState
+ val dstState = mDstState
+ val inputType = mInputType
+ val packageName = mPackageName ?: getPackageName(atomInfo)
+
+ if (IS_VERBOSE) {
+ val name =
+ if (event is Enum<*>) (event as Enum<*>).name else event.id.toString() + ""
+ val logStringBuilder = StringBuilder("\n")
+ if (instanceId !== DEFAULT_INSTANCE_ID)
+ logStringBuilder.append("InstanceId:$instanceId")
+
+ logStringBuilder.append(name)
+
+ if (
+ srcState != LAUNCHER_STATE_UNSPECIFIED || dstState != LAUNCHER_STATE_UNSPECIFIED
+ ) {
+ logStringBuilder.append(
+ "(State:${getStateString(srcState)}->${getStateString(dstState)})"
+ )
+ }
+
+ if (atomInfo.hasContainerInfo()) logStringBuilder.append("\n$atomInfo")
+ packageName?.let { logStringBuilder.append("\nPackage name: $it") }
+
+ Log.d(TAG, logStringBuilder.toString())
+ }
+
+ for (consumer in LOGS_CONSUMER) {
+ consumer.consume(event, atomInfo)
+ }
+
+ // TODO: remove this when b/231648228 is fixed.
+ if (Utilities.isRunningInTestHarness()) {
+ return
+ }
+ val cardinality = mCardinality ?: getCardinality(atomInfo)
+
+ val features = mFeatures ?: getFeatures(atomInfo)
+
+ SysUiStatsLog.write(
+ SysUiStatsLog.LAUNCHER_EVENT,
+ SysUiStatsLog.LAUNCHER_UICHANGED__ACTION__DEFAULT_ACTION, /* deprecated */
+ srcState,
+ dstState,
+ null, /* launcher extensions, deprecated */
+ false, /* quickstep_enabled, deprecated */
+ event.id, /* event_id */
+ atomInfo.itemCase.number, /* target_id */
+ instanceId!!.id, /* instance_id TODO */
+ 0, /* uid TODO */
+ packageName, /* package_name */
+ getComponentName(atomInfo), /* component_name */
+ getGridX(atomInfo, false), /* grid_x */
+ getGridY(atomInfo, false), /* grid_y */
+ getPageId(atomInfo), /* page_id */
+ getGridX(atomInfo, true), /* grid_x_parent */
+ getGridY(atomInfo, true), /* grid_y_parent */
+ getParentPageId(atomInfo), /* page_id_parent */
+ getHierarchy(atomInfo), /* hierarchy */
+ false, /* is_work_profile, deprecated */
+ atomInfo.rank, /* rank */
+ atomInfo.folderIcon.fromLabelState.number, /* fromState */
+ atomInfo.folderIcon.toLabelState.number, /* toState */
+ atomInfo.folderIcon.labelInfo, /* edittext */
+ cardinality, /* cardinality */
+ features, /* features */
+ getSearchAttributes(atomInfo), /* searchAttributes */
+ getAttributes(atomInfo), /* attributes */
+ inputType, /* input_type */
+ atomInfo.userType, /* user_type */
+ displayRotation, /* display_rotation */
+ getRecentsOrientationHandler(atomInfo), /* recents_orientation_handler */
+ )
+ }
+
+ val displayRotation: Int
+ get() =
+ when (mDisplayRotation) {
+ Surface.ROTATION_90 ->
+ SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_90
+ Surface.ROTATION_180 ->
+ SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_180
+ Surface.ROTATION_270 ->
+ SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_270
+ else -> SysUiStatsLog.LAUNCHER_UICHANGED__DISPLAY_ROTATION__ROTATION_0
+ }
+
+ fun getRecentsOrientationHandler(itemInfo: LauncherAtom.ItemInfo): Int {
+ val orientationHandler = itemInfo.containerInfo.taskSwitcherContainer.orientationHandler
+ return when (orientationHandler) {
+ PORTRAIT -> SysUiStatsLog.LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__PORTRAIT
+ LANDSCAPE ->
+ SysUiStatsLog.LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__LANDSCAPE
+ SEASCAPE -> SysUiStatsLog.LAUNCHER_UICHANGED__RECENTS_ORIENTATION_HANDLER__SEASCAPE
+ }
+ }
+
+ companion object {
+ private val DEFAULT_ITEM_INFO = ItemInfo()
+
+ init {
+ DEFAULT_ITEM_INFO.itemType = Favorites.ITEM_TYPE_NON_ACTIONABLE
+ }
+ }
+ }
+
+ /** Helps to construct and log statsd compatible latency events. */
+ private class StatsCompatLatencyLogger : StatsLatencyLogger {
+ private var mInstanceId: InstanceId? = DEFAULT_INSTANCE_ID
+ private var mType: LatencyType? = UNKNOWN
+ private var mPackageId = 0
+ private var mLatencyInMillis: Long = 0
+ private var mQueryLength = -1
+ private var mSubEventType = 0
+ private var mCardinality = -1
+
+ override fun withInstanceId(instanceId: InstanceId?) = apply {
+ this.mInstanceId = instanceId
+ }
+
+ override fun withType(type: LatencyType?) = apply { this.mType = type }
+
+ override fun withPackageId(packageId: Int) = apply { this.mPackageId = packageId }
+
+ override fun withLatency(latencyInMillis: Long) = apply {
+ this.mLatencyInMillis = latencyInMillis
+ }
+
+ override fun withQueryLength(queryLength: Int) = apply { this.mQueryLength = queryLength }
+
+ override fun withSubEventType(type: Int) = apply { this.mSubEventType = type }
+
+ override fun withCardinality(cardinality: Int) = apply { this.mCardinality = cardinality }
+
+ override fun log(event: EventEnum) {
+ if (IS_VERBOSE) {
+ val name =
+ if (event is Enum<*>) (event as Enum<*>).name else event.id.toString() + ""
+ Log.d(LATENCY_TAG, "InstanceId=$mInstanceId $name=${mLatencyInMillis}ms")
+ }
+
+ SysUiStatsLog.write(
+ SysUiStatsLog.LAUNCHER_LATENCY,
+ event.id, // event_id
+ mInstanceId!!.id, // instance_id
+ mPackageId, // package_id
+ mLatencyInMillis, // latency_in_millis
+ mType!!.id, // type
+ mQueryLength, // query_length
+ mSubEventType, // sub_event_type
+ mCardinality, // cardinality
+ )
+ }
+ }
+
+ /** Helps to construct and log statsd compatible impression events. */
+ private class StatsCompatImpressionLogger : StatsImpressionLogger {
+ private var mInstanceId: InstanceId? = DEFAULT_INSTANCE_ID
+ private var mLauncherState: State? = State.UNKNOWN
+ private var mQueryLength = -1
+
+ // Fields used for Impression Logging V2.
+ private var mResultType = 0
+ private var mAboveKeyboard = false
+ private var mUid = 0
+ private var mResultSource = 0
+
+ override fun withInstanceId(instanceId: InstanceId?) = apply {
+ this.mInstanceId = instanceId
+ }
+
+ override fun withState(state: State?) = apply { this.mLauncherState = state }
+
+ override fun withQueryLength(queryLength: Int) = apply { this.mQueryLength = queryLength }
+
+ override fun withResultType(resultType: Int) = apply { mResultType = resultType }
+
+ override fun withAboveKeyboard(aboveKeyboard: Boolean) = apply {
+ mAboveKeyboard = aboveKeyboard
+ }
+
+ override fun withUid(uid: Int) = apply { mUid = uid }
+
+ override fun withResultSource(resultSource: Int) = apply { mResultSource = resultSource }
+
+ override fun log(event: EventEnum) {
+ if (IS_VERBOSE) {
+ val name =
+ if (event is Enum<*>) (event as Enum<*>).name else event.id.toString() + ""
+ Log.d(
+ IMPRESSION_TAG,
+ """"
+ |InstanceId:$mInstanceId
+ |ImpressionEvent:$name
+ | LauncherState = $mLauncherState
+ | QueryLength = $mQueryLength
+ | ResultType=$mResultType is_above_keyboard=$mAboveKeyboard mUid=$mUid
+ | result_source=$mResultSource
+ |"""
+ .trimMargin(),
+ )
+ }
+
+ SysUiStatsLog.write(
+ SysUiStatsLog.LAUNCHER_IMPRESSION_EVENT_V2,
+ event.id, // event_id
+ mInstanceId!!.id, // instance_id
+ mLauncherState!!.launcherState, // state
+ mQueryLength, // query_length
+ mResultType, // result type
+ mAboveKeyboard, // above keyboard
+ mUid, // uid
+ mResultSource, // result source
+ )
+ }
+ }
+
+ /** Interface to get stats log while it is dispatched to the system */
+ interface StatsLogConsumer {
+ @WorkerThread fun consume(event: EventEnum?, atomInfo: LauncherAtom.ItemInfo?)
+ }
+
+ companion object {
+ private const val TAG = "StatsLog"
+ private const val LATENCY_TAG = "StatsLatencyLog"
+ private const val IMPRESSION_TAG = "StatsImpressionLog"
+ private val IS_VERBOSE = Utilities.isPropertyEnabled(LogConfig.STATSLOG)
+ private val DEBUG = !Utilities.isRunningInTestHarness()
+ private val DEFAULT_INSTANCE_ID: InstanceId = InstanceId.fakeInstanceId(0)
+
+ // LauncherAtom.ItemInfo.getDefaultInstance() should be used but until launcher proto
+ // migrates
+ // from nano to lite, bake constant to prevent robo test failure.
+ private const val DEFAULT_PAGE_INDEX = -2
+ private const val FOLDER_HIERARCHY_OFFSET = 100
+ private const val SEARCH_RESULT_HIERARCHY_OFFSET = 200
+ private const val EXTENDED_CONTAINERS_HIERARCHY_OFFSET = 300
+ private const val ALL_APPS_HIERARCHY_OFFSET = 400
+
+ /** Flags for converting SearchAttribute to integer value. */
+ private const val SEARCH_ATTRIBUTES_CORRECTED_QUERY = 1 shl 0
+ private const val SEARCH_ATTRIBUTES_DIRECT_MATCH = 1 shl 1
+ private const val SEARCH_ATTRIBUTES_ENTRY_STATE_ALL_APPS = 1 shl 2
+ private const val SEARCH_ATTRIBUTES_ENTRY_STATE_QSB = 1 shl 3
+ private const val SEARCH_ATTRIBUTES_ENTRY_STATE_OVERVIEW = 1 shl 4
+ private const val SEARCH_ATTRIBUTES_ENTRY_STATE_TASKBAR = 1 shl 5
+
+ @JvmField val LOGS_CONSUMER: CopyOnWriteArrayList = CopyOnWriteArrayList()
+
+ /** Synchronously writes an itemInfo to stats log */
+ @WorkerThread
+ @JvmStatic
+ fun writeSnapshot(info: LauncherAtom.ItemInfo, instanceId: InstanceId) {
+ if (IS_VERBOSE) {
+ Log.d(TAG, String.format("\nwriteSnapshot(%d):\n%s", instanceId.id, info))
+ }
+ if (Utilities.isRunningInTestHarness()) {
+ return
+ }
+ SysUiStatsLog.write(
+ SysUiStatsLog.LAUNCHER_SNAPSHOT,
+ LAUNCHER_WORKSPACE_SNAPSHOT.id, /* event_id */
+ info.itemCase.number, /* target_id */
+ instanceId.id, /* instance_id */
+ 0, /* uid */
+ getPackageName(info), /* package_name */
+ getComponentName(info), /* component_name */
+ getGridX(info, false), /* grid_x */
+ getGridY(info, false), /* grid_y */
+ getPageId(info), /* page_id */
+ getGridX(info, true), /* grid_x_parent */
+ getGridY(info, true), /* grid_y_parent */
+ getParentPageId(info), /* page_id_parent */
+ getHierarchy(info), /* hierarchy */
+ info.isWork, /* is_work_profile */
+ 0, /* origin */
+ getCardinality(info), /* cardinality */
+ info.widget.spanX,
+ info.widget.spanY,
+ getFeatures(info),
+ getAttributes(info), /* attributes */
+ )
+ }
+
+ private fun getAttributes(itemInfo: LauncherAtom.ItemInfo): ByteArray =
+ LauncherAttributes.newBuilder()
+ .apply { itemInfo.itemAttributesList.forEach { addItemAttributes(it.number) } }
+ .build()
+ .toByteArray()
+
+ /**
+ * Builds [StatsEvent] from [LauncherAtom.ItemInfo]. Used for pulled atom callback
+ * implementation.
+ */
+ @JvmStatic
+ fun buildStatsEvent(info: LauncherAtom.ItemInfo, instanceId: InstanceId?): StatsEvent {
+ return SysUiStatsLog.buildStatsEvent(
+ SysUiStatsLog.LAUNCHER_LAYOUT_SNAPSHOT, // atom ID,
+ LAUNCHER_WORKSPACE_SNAPSHOT.id, // event_id = 1;
+ info.itemCase.number, // item_id = 2;
+ instanceId?.id ?: 0, // instance_id = 3;
+ 0, // uid = 4 [(is_uid) = true];
+ getPackageName(info), // package_name = 5;
+ getComponentName(info), // component_name = 6;
+ getGridX(info, false), // grid_x = 7 [default = -1];
+ getGridY(info, false), // grid_y = 8 [default = -1];
+ getPageId(info), // page_id = 9 [default = -2];
+ getGridX(info, true), // grid_x_parent = 10 [default = -1];
+ getGridY(info, true), // grid_y_parent = 11 [default = -1];
+ getParentPageId(info), // page_id_parent = 12 [default = -2];
+ getHierarchy(info), // container_id = 13;
+ info.isWork, // is_work_profile = 14;
+ 0, // attribute_id = 15;
+ getCardinality(info), // cardinality = 16;
+ info.widget.spanX, // span_x = 17 [default = 1];
+ info.widget.spanY, // span_y = 18 [default = 1];
+ getAttributes(info), /* attributes = 19 [(log_mode) = MODE_BYTES] */
+ info.isKidsMode, /* is_kids_mode = 20 */
+ )
+ }
+
+ private fun getCardinality(info: LauncherAtom.ItemInfo): Int {
+ if (Utilities.isRunningInTestHarness()) return 0
+
+ when (info.containerInfo.containerCase) {
+ PREDICTED_HOTSEAT_CONTAINER ->
+ return info.containerInfo.predictedHotseatContainer.cardinality
+ TASK_BAR_CONTAINER -> return info.containerInfo.taskBarContainer.cardinality
+ SEARCH_RESULT_CONTAINER ->
+ return info.containerInfo.searchResultContainer.queryLength
+ EXTENDED_CONTAINERS -> {
+ val extendedCont = info.containerInfo.extendedContainers
+ if (extendedCont.containerCase == DEVICE_SEARCH_RESULT_CONTAINER) {
+ val deviceSearchResultCont = extendedCont.deviceSearchResultContainer
+ return if (deviceSearchResultCont.hasQueryLength())
+ deviceSearchResultCont.queryLength
+ else -1
+ }
+ return when (info.itemCase) {
+ FOLDER_ICON -> info.folderIcon.cardinality
+ TASK_VIEW -> info.taskView.cardinality
+ else -> 0
+ }
+ }
+
+ else ->
+ return when (info.itemCase) {
+ FOLDER_ICON -> info.folderIcon.cardinality
+ TASK_VIEW -> info.taskView.cardinality
+ else -> 0
+ }
+ }
+ }
+
+ private fun getPackageName(info: LauncherAtom.ItemInfo): String? =
+ when (info.itemCase) {
+ APPLICATION -> info.application.packageName
+ SHORTCUT -> info.shortcut.shortcutName
+ WIDGET -> info.widget.packageName
+ TASK -> info.task.packageName
+ SEARCH_ACTION_ITEM -> info.searchActionItem.packageName
+ else -> null
+ }
+
+ private fun getComponentName(info: LauncherAtom.ItemInfo): String? =
+ when (info.itemCase) {
+ APPLICATION -> info.application.componentName
+ SHORTCUT -> info.shortcut.shortcutName
+ WIDGET -> info.widget.componentName
+ TASK -> info.task.componentName
+ TASK_VIEW -> info.taskView.componentName
+ SEARCH_ACTION_ITEM -> info.searchActionItem.title
+ SLICE -> info.slice.uri
+ else -> null
+ }
+
+ private fun getGridX(info: LauncherAtom.ItemInfo, parent: Boolean): Int {
+ val containerInfo = info.containerInfo
+ return if (containerInfo.containerCase == FOLDER) {
+ if (parent) {
+ containerInfo.folder.workspace.gridX
+ } else {
+ containerInfo.folder.gridX
+ }
+ } else if (containerInfo.containerCase == EXTENDED_CONTAINERS) {
+ containerInfo.extendedContainers.deviceSearchResultContainer.gridX
+ } else {
+ containerInfo.workspace.gridX
+ }
+ }
+
+ private fun getGridY(info: LauncherAtom.ItemInfo, parent: Boolean): Int =
+ if (info.containerInfo.containerCase == FOLDER) {
+ if (parent) {
+ info.containerInfo.folder.workspace.gridY
+ } else {
+ info.containerInfo.folder.gridY
+ }
+ } else {
+ info.containerInfo.workspace.gridY
+ }
+
+ private fun getPageId(info: LauncherAtom.ItemInfo): Int =
+ when (info.itemCase) {
+ TASK -> info.task.index
+ TASK_VIEW -> info.taskView.index
+ else -> getPageIdFromContainerInfo(info.containerInfo)
+ }
+
+ private fun getPageIdFromContainerInfo(containerInfo: ContainerInfo): Int =
+ when (containerInfo.containerCase) {
+ FOLDER -> containerInfo.folder.pageIndex
+ HOTSEAT -> containerInfo.hotseat.index
+ PREDICTED_HOTSEAT_CONTAINER -> containerInfo.predictedHotseatContainer.index
+ TASK_BAR_CONTAINER -> containerInfo.taskBarContainer.index
+ else -> containerInfo.workspace.pageIndex
+ }
+
+ private fun getParentPageId(info: LauncherAtom.ItemInfo): Int =
+ info.containerInfo.run {
+ when {
+ containerCase == FOLDER &&
+ folder.parentContainerCase == ParentContainerCase.HOTSEAT ->
+ folder.hotseat.index
+
+ containerCase == FOLDER -> folder.workspace.pageIndex
+ containerCase == SEARCH_RESULT_CONTAINER ->
+ searchResultContainer.workspace.pageIndex
+
+ else -> workspace.pageIndex
+ }
+ }
+
+ private fun getHierarchy(info: LauncherAtom.ItemInfo): Int {
+ if (Utilities.isRunningInTestHarness()) return 0
+
+ return info.containerInfo.run {
+ when (containerCase) {
+ FOLDER -> folder.parentContainerCase.number + FOLDER_HIERARCHY_OFFSET
+ SEARCH_RESULT_CONTAINER ->
+ searchResultContainer.parentContainerCase.number +
+ SEARCH_RESULT_HIERARCHY_OFFSET
+ EXTENDED_CONTAINERS ->
+ extendedContainers.containerCase.number +
+ EXTENDED_CONTAINERS_HIERARCHY_OFFSET
+ ALL_APPS_CONTAINER ->
+ allAppsContainer.parentContainerCase.number + ALL_APPS_HIERARCHY_OFFSET
+ else -> containerCase.number
+ }
+ }
+ }
+
+ private fun getStateString(state: Int): String =
+ when (state) {
+ SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__BACKGROUND -> "BACKGROUND"
+ SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__HOME -> "HOME"
+ SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__OVERVIEW -> "OVERVIEW"
+ SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__ALLAPPS -> "ALLAPPS"
+ else -> "INVALID"
+ }
+
+ private fun getFeatures(info: LauncherAtom.ItemInfo): Int =
+ when (info.itemCase) {
+ WIDGET -> info.widget.widgetFeatures
+ TASK_VIEW -> info.taskView.type
+ else -> 0
+ }
+
+ private fun getSearchAttributes(info: LauncherAtom.ItemInfo): Int {
+ if (Utilities.isRunningInTestHarness()) return 0
+
+ val containerInfo = info.containerInfo
+ if (
+ containerInfo.containerCase == EXTENDED_CONTAINERS &&
+ (containerInfo.extendedContainers.containerCase ==
+ DEVICE_SEARCH_RESULT_CONTAINER) &&
+ containerInfo.extendedContainers.deviceSearchResultContainer
+ .hasSearchAttributes()
+ ) {
+ return searchAttributesToInt(
+ containerInfo.extendedContainers.deviceSearchResultContainer.searchAttributes
+ )
+ }
+ return 0
+ }
+
+ private fun searchAttributesToInt(searchAttributes: SearchAttributes): Int {
+ var response = 0
+ if (searchAttributes.correctedQuery)
+ response = response or SEARCH_ATTRIBUTES_CORRECTED_QUERY
+
+ if (searchAttributes.directMatch) response = response or SEARCH_ATTRIBUTES_DIRECT_MATCH
+
+ response =
+ response or
+ when (searchAttributes.entryState) {
+ ALL_APPS -> SEARCH_ATTRIBUTES_ENTRY_STATE_ALL_APPS
+ QSB -> SEARCH_ATTRIBUTES_ENTRY_STATE_QSB
+ OVERVIEW -> SEARCH_ATTRIBUTES_ENTRY_STATE_OVERVIEW
+ TASKBAR -> SEARCH_ATTRIBUTES_ENTRY_STATE_TASKBAR
+ else -> 0
+ }
+
+ return response
+ }
+ }
+}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
index 9c655a70cd..5e22012b45 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
@@ -40,20 +40,25 @@ import com.android.launcher3.util.SettingsCache
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Before
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import org.mockito.Answers
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mock
-import org.mockito.MockitoAnnotations
-import org.mockito.kotlin.any
+import org.mockito.junit.MockitoJUnit
import org.mockito.kotlin.atLeastOnce
+import org.mockito.kotlin.capture
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
@RunWith(AndroidJUnit4::class)
class SettingsChangeLoggerTest {
+
+ @get:Rule val mockito = MockitoJUnit.rule()
+
private val mContext: Context = ApplicationProvider.getApplicationContext()
private val mInstanceId = InstanceId.fakeInstanceId(1)
@@ -64,7 +69,8 @@ class SettingsChangeLoggerTest {
@Mock private lateinit var mStatsLogManager: StatsLogManager
- @Mock private lateinit var mMockLogger: StatsLogManager.StatsLogger
+ @Mock(answer = Answers.RETURNS_SELF)
+ private lateinit var mMockLogger: StatsLogManager.StatsLogger
@Mock private lateinit var mTracker: DaggerSingletonTracker
private var displayController: DisplayController = DisplayController.INSTANCE.get(mContext)
private var settingsCache: SettingsCache = SettingsCache.INSTANCE.get(mContext)
@@ -79,10 +85,8 @@ class SettingsChangeLoggerTest {
@Before
fun setUp() {
- MockitoAnnotations.initMocks(this)
whenever(mStatsLogFactory.create(mContext)).doReturn(mStatsLogManager)
whenever(mStatsLogManager.logger()).doReturn(mMockLogger)
- whenever(mStatsLogManager.logger().withInstanceId(any())).doReturn(mMockLogger)
mDefaultThemedIcons = themeManager.isMonoThemeEnabled
mDefaultAllowRotation = LauncherPrefs.get(mContext).get(ALLOW_ROTATION)
// To match the default value of THEMED_ICONS
@@ -128,7 +132,7 @@ class SettingsChangeLoggerTest {
fun logSnapshot_defaultValue() {
mSystemUnderTest.logSnapshot(mInstanceId)
- verify(mMockLogger, atLeastOnce()).log(mEventCaptor.capture())
+ verify(mMockLogger, atLeastOnce()).log(capture(mEventCaptor))
val capturedEvents = mEventCaptor.allValues
assertThat(capturedEvents.isNotEmpty()).isTrue()
verifyDefaultEvent(capturedEvents)
@@ -144,7 +148,7 @@ class SettingsChangeLoggerTest {
SettingsChangeLogger(mContext, mTracker, displayController, settingsCache, mStatsLogFactory)
.logSnapshot(mInstanceId)
- verify(mMockLogger, atLeastOnce()).log(mEventCaptor.capture())
+ verify(mMockLogger, atLeastOnce()).log(capture(mEventCaptor))
val capturedEvents = mEventCaptor.allValues
assertThat(capturedEvents.isNotEmpty()).isTrue()
verifyDefaultEvent(capturedEvents)
diff --git a/src/com/android/launcher3/logging/StartupLatencyLogger.kt b/src/com/android/launcher3/logging/StartupLatencyLogger.kt
index 9b0c1bfa9f..901e8c34d5 100644
--- a/src/com/android/launcher3/logging/StartupLatencyLogger.kt
+++ b/src/com/android/launcher3/logging/StartupLatencyLogger.kt
@@ -27,7 +27,7 @@ import com.android.launcher3.LauncherConstants.TraceEvents.SINGLE_TRACE_COOKIE
import com.android.launcher3.logging.StatsLogManager.LauncherLatencyEvent
import com.android.launcher3.logging.StatsLogManager.LauncherLatencyEvent.LAUNCHER_LATENCY_STARTUP_TOTAL_DURATION
import com.android.launcher3.logging.StatsLogManager.LauncherLatencyEvent.LAUNCHER_LATENCY_STARTUP_WORKSPACE_LOADER_ASYNC
-import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.LAUNCHER_LATENCY_PACKAGE_ID
+import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.Companion.LAUNCHER_LATENCY_PACKAGE_ID
import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.LatencyType
import com.android.launcher3.util.Executors
import com.android.launcher3.util.LockedUserState
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.kt
similarity index 60%
rename from src/com/android/launcher3/logging/StatsLogManager.java
rename to src/com/android/launcher3/logging/StatsLogManager.kt
index 8ea5fb9b62..61e947ebcc 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.kt
@@ -13,1145 +13,723 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.logging;
+package com.android.launcher3.logging
-import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_CLOSE_DOWN;
-import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_OPEN_UP;
-import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
-import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_OVERVIEW_GESTURE;
-
-import android.content.Context;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.slice.SliceItem;
-
-import com.android.launcher3.R;
-import com.android.launcher3.dagger.LauncherComponentProvider;
-import com.android.launcher3.logger.LauncherAtom;
-import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
-import com.android.launcher3.logger.LauncherAtom.FromState;
-import com.android.launcher3.logger.LauncherAtom.ToState;
-import com.android.launcher3.model.data.ItemInfo;
-import com.android.launcher3.views.ActivityContext;
-
-import javax.inject.Inject;
+import android.content.Context
+import android.view.View
+import androidx.slice.SliceItem
+import com.android.launcher3.R
+import com.android.launcher3.dagger.LauncherComponentProvider.appComponent
+import com.android.launcher3.logger.LauncherAtom
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo
+import com.android.launcher3.logger.LauncherAtom.FromState
+import com.android.launcher3.logger.LauncherAtom.Slice
+import com.android.launcher3.logger.LauncherAtom.ToState
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_CLOSE_DOWN
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_OPEN_UP
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_OVERVIEW_GESTURE
+import com.android.launcher3.model.data.ItemInfo
+import com.android.launcher3.views.ActivityContext
+import javax.inject.Inject
/**
* Handles the user event logging in R+.
- *
*
* All of the event ids are defined here.
* Most of the methods are placeholder methods for Launcher3
* Actual call happens only for Launcher variant that implements QuickStep.
- *
+ * *
*/
-public class StatsLogManager {
+open class StatsLogManager protected constructor(@JvmField protected val mContext: Context) {
+ @JvmField
+ protected val mActivityContext: ActivityContext? =
+ ActivityContext.lookupContextNoThrow(mContext)
- public static final int LAUNCHER_STATE_UNSPECIFIED = 0;
- public static final int LAUNCHER_STATE_BACKGROUND = 1;
- public static final int LAUNCHER_STATE_HOME = 2;
- public static final int LAUNCHER_STATE_OVERVIEW = 3;
- public static final int LAUNCHER_STATE_ALLAPPS = 4;
- public static final int LAUNCHER_STATE_UNCHANGED = 5;
-
- @NonNull
- protected final Context mContext;
- @Nullable
- protected final ActivityContext mActivityContext;
-
- private KeyboardStateManager mKeyboardStateManager;
- private InstanceId mInstanceId;
-
-
- protected StatsLogManager(@NonNull Context context) {
- mContext = context;
- mActivityContext = ActivityContext.lookupContextNoThrow(context);
- }
+ private var mKeyboardStateManager: KeyboardStateManager? = null
+ private var mInstanceId: InstanceId? = null
/**
* This class is purely used to support dagger bindings to be overridden in launcher variants.
- * Very similar to {@link dagger.assisted.AssistedFactory}. But
- * {@link dagger.assisted.AssistedFactory} cannot be overridden and this makes dagger binding
- * difficult.
+ * Very similar to [dagger.assisted.AssistedFactory]. But [dagger.assisted.AssistedFactory]
+ * cannot be overridden and this makes dagger binding difficult.
*/
- public static class StatsLogManagerFactory {
- @Inject
- public StatsLogManagerFactory() {
- }
+ open class StatsLogManagerFactory @Inject constructor() {
- public StatsLogManager create(Context context) {
- return new StatsLogManager(context);
+ open fun create(context: Context): StatsLogManager {
+ return StatsLogManager(context)
}
}
- /**
- * Returns event enum based on the two state transition information when swipe
- * gesture happens(to be removed during UserEventDispatcher cleanup).
- */
- public static EventEnum getLauncherAtomEvent(int startState,
- int targetState, EventEnum fallbackEvent) {
- if (startState == LAUNCHER_STATE_HOME
- && targetState == LAUNCHER_STATE_HOME) {
- return LAUNCHER_HOME_GESTURE;
- } else if (startState != LAUNCHER_STATE_OVERVIEW
- && targetState == LAUNCHER_STATE_OVERVIEW) {
- return LAUNCHER_OVERVIEW_GESTURE;
- } else if (startState != LAUNCHER_STATE_ALLAPPS
- && targetState == LAUNCHER_STATE_ALLAPPS) {
- return LAUNCHER_ALLAPPS_OPEN_UP;
- } else if (startState == LAUNCHER_STATE_ALLAPPS
- && targetState != LAUNCHER_STATE_ALLAPPS) {
- return LAUNCHER_ALLAPPS_CLOSE_DOWN;
- }
- return fallbackEvent; // TODO fix
+ interface EventEnum {
+
+ val id: Int
}
- public interface EventEnum {
-
- /**
- * Tag used to request new UI Event IDs via presubmit analysis.
- *
- * Use RESERVE_NEW_UI_EVENT_ID as the constructor parameter for a new {@link EventEnum}
- * to signal the presubmit analyzer to reserve a new ID for the event. The new ID will be
- * returned as a Gerrit presubmit finding. Do not submit {@code RESERVE_NEW_UI_EVENT_ID} as
- * the constructor parameter for any event.
- *
- *
- * @UiEvent(doc = "Briefly describe the interaction when this event will be logged")
- * UNIQUE_EVENT_NAME(RESERVE_NEW_UI_EVENT_ID);
- *
- */
- int RESERVE_NEW_UI_EVENT_ID = Integer.MIN_VALUE; // Negative IDs are ignored by the logger.
-
- int getId();
- }
-
- public enum LauncherEvent implements EventEnum {
+ enum class LauncherEvent(override val id: Int) : EventEnum {
/* Used to prevent double logging. */
IGNORE(-1),
-
@UiEvent(doc = "App launched from workspace, hotseat or folder in launcher")
LAUNCHER_APP_LAUNCH_TAP(338),
-
- @UiEvent(doc = "Task launched from overview using TAP")
- LAUNCHER_TASK_LAUNCH_TAP(339),
-
+ @UiEvent(doc = "Task launched from overview using TAP") LAUNCHER_TASK_LAUNCH_TAP(339),
@UiEvent(doc = "User tapped on notification inside popup context menu.")
LAUNCHER_NOTIFICATION_LAUNCH_TAP(516),
-
@UiEvent(doc = "Task launched from overview using SWIPE DOWN")
LAUNCHER_TASK_LAUNCH_SWIPE_DOWN(340),
-
@UiEvent(doc = "App launched by dragging and dropping, probably from taskbar")
LAUNCHER_APP_LAUNCH_DRAGDROP(1552),
-
@UiEvent(doc = "TASK dismissed from overview using SWIPE UP")
LAUNCHER_TASK_DISMISS_SWIPE_UP(341),
-
- @UiEvent(doc = "User dragged a launcher item")
- LAUNCHER_ITEM_DRAG_STARTED(383),
-
- @UiEvent(doc = "A dragged launcher item is successfully dropped onto workspace, hotseat "
- + "open folder etc")
+ @UiEvent(doc = "User dragged a launcher item") LAUNCHER_ITEM_DRAG_STARTED(383),
+ @UiEvent(
+ doc =
+ ("A dragged launcher item is successfully dropped onto workspace, hotseat " +
+ "open folder etc")
+ )
LAUNCHER_ITEM_DROP_COMPLETED(385),
-
@UiEvent(doc = "A dragged launcher item is successfully dropped onto a folder icon.")
LAUNCHER_ITEM_DROP_COMPLETED_ON_FOLDER_ICON(697),
-
- @UiEvent(doc = "A dragged launcher item is successfully dropped on another item "
- + "resulting in a new folder creation")
+ @UiEvent(
+ doc =
+ ("A dragged launcher item is successfully dropped on another item " +
+ "resulting in a new folder creation")
+ )
LAUNCHER_ITEM_DROP_FOLDER_CREATED(386),
-
@UiEvent(doc = "Folder's label is automatically assigned.")
LAUNCHER_FOLDER_AUTO_LABELED(591),
-
@UiEvent(doc = "Could not auto-label a folder because primary suggestion is null or empty.")
LAUNCHER_FOLDER_AUTO_LABELING_SKIPPED_EMPTY_PRIMARY(592),
-
@UiEvent(doc = "Could not auto-label a folder because no suggestions exist.")
LAUNCHER_FOLDER_AUTO_LABELING_SKIPPED_EMPTY_SUGGESTIONS(593),
-
@UiEvent(doc = "User manually updated the folder label.")
LAUNCHER_FOLDER_LABEL_UPDATED(460),
-
@UiEvent(doc = "User long pressed on the workspace empty space.")
LAUNCHER_WORKSPACE_LONGPRESS(461),
-
@UiEvent(doc = "User tapped or long pressed on a wallpaper icon inside launcher settings.")
LAUNCHER_WALLPAPER_BUTTON_TAP_OR_LONGPRESS(462),
-
@UiEvent(doc = "User tapped or long pressed on settings icon inside launcher settings.")
LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS(463),
-
@UiEvent(doc = "User tapped or long pressed on apps icon inside launcher settings.")
LAUNCHER_ALL_APPS_TAP_OR_LONGPRESS(2204),
-
@UiEvent(doc = "User tapped or long pressed on widget tray icon inside launcher settings.")
LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS(464),
-
@UiEvent(doc = "User expanded the list of widgets for a single app in the widget picker.")
LAUNCHER_WIDGETSTRAY_APP_EXPANDED(818),
-
@UiEvent(doc = "User searched for a widget in the widget picker.")
LAUNCHER_WIDGETSTRAY_SEARCHED(819),
-
- @UiEvent(doc = "User clicked on view all button to expand the displayed list in the "
- + "widget picker.")
+ @UiEvent(
+ doc =
+ ("User clicked on view all button to expand the displayed list in the " +
+ "widget picker.")
+ )
LAUNCHER_WIDGETSTRAY_EXPAND_PRESS(1978),
-
@UiEvent(doc = "A dragged item is dropped on 'Remove' button in the target bar")
LAUNCHER_ITEM_DROPPED_ON_REMOVE(465),
-
@UiEvent(doc = "A dragged item is dropped on 'Cancel' button in the target bar")
LAUNCHER_ITEM_DROPPED_ON_CANCEL(466),
-
- @UiEvent(doc = "A predicted item is dragged and dropped on 'Don't suggest app'"
- + " button in the target bar")
+ @UiEvent(
+ doc =
+ ("A predicted item is dragged and dropped on 'Don't suggest app'" +
+ " button in the target bar")
+ )
LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST(467),
-
@UiEvent(doc = "A dragged item is dropped on 'Uninstall' button in target bar")
LAUNCHER_ITEM_DROPPED_ON_UNINSTALL(468),
-
- @UiEvent(doc = "User completed uninstalling the package after dropping on "
- + "the icon onto 'Uninstall' button in the target bar")
+ @UiEvent(
+ doc =
+ ("User completed uninstalling the package after dropping on " +
+ "the icon onto 'Uninstall' button in the target bar")
+ )
LAUNCHER_ITEM_UNINSTALL_COMPLETED(469),
-
- @UiEvent(doc = "User cancelled uninstalling the package after dropping on "
- + "the icon onto 'Uninstall' button in the target bar")
+ @UiEvent(
+ doc =
+ ("User cancelled uninstalling the package after dropping on " +
+ "the icon onto 'Uninstall' button in the target bar")
+ )
LAUNCHER_ITEM_UNINSTALL_CANCELLED(470),
-
- @UiEvent(doc = "User tapped or long pressed on the task icon(aka package icon) "
- + "from overview to open task menu.")
+ @UiEvent(
+ doc =
+ ("User tapped or long pressed on the task icon(aka package icon) " +
+ "from overview to open task menu.")
+ )
LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS(517),
-
- @UiEvent(doc = "User opened package specific widgets list by tapping on widgets system "
- + "shortcut inside popup context menu.")
+ @UiEvent(
+ doc =
+ ("User opened package specific widgets list by tapping on widgets system " +
+ "shortcut inside popup context menu.")
+ )
LAUNCHER_SYSTEM_SHORTCUT_WIDGETS_TAP(514),
-
@UiEvent(doc = "User tapped on app info system shortcut.")
LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP(515),
-
- /**
- * @deprecated Use {@link #LAUNCHER_APP_ICON_MENU_SPLIT_LEFT_TOP} or
- * {@link #LAUNCHER_APP_ICON_MENU_SPLIT_RIGHT_BOTTOM}
- */
- @Deprecated
@UiEvent(doc = "User tapped on split screen icon on a task menu.")
+ @Deprecated(
+ """Use {@link #LAUNCHER_APP_ICON_MENU_SPLIT_LEFT_TOP} or
+ {@link #LAUNCHER_APP_ICON_MENU_SPLIT_RIGHT_BOTTOM}"""
+ )
LAUNCHER_SYSTEM_SHORTCUT_SPLIT_SCREEN_TAP(518),
-
@UiEvent(doc = "User tapped on free form icon on a task menu.")
LAUNCHER_SYSTEM_SHORTCUT_FREE_FORM_TAP(519),
-
@UiEvent(doc = "User tapped on desktop icon on a task menu.")
LAUNCHER_SYSTEM_SHORTCUT_DESKTOP_TAP(1706),
-
@UiEvent(doc = "User tapped on external display icon on a task menu,")
LAUNCHER_SYSTEM_SHORTCUT_EXTERNAL_DISPLAY_TAP(1957),
-
@UiEvent(doc = "User tapped on close app on a task menu,")
LAUNCHER_SYSTEM_SHORTCUT_CLOSE_APP_TAP(2081),
-
@UiEvent(doc = "User tapped on pause app system shortcut.")
LAUNCHER_SYSTEM_SHORTCUT_PAUSE_TAP(521),
-
- @UiEvent(doc = "User tapped on pin system shortcut.")
- LAUNCHER_SYSTEM_SHORTCUT_PIN_TAP(522),
-
+ @UiEvent(doc = "User tapped on pin system shortcut.") LAUNCHER_SYSTEM_SHORTCUT_PIN_TAP(522),
@UiEvent(doc = "User tapped on don't suggest app system shortcut.")
LAUNCHER_SYSTEM_SHORTCUT_DONT_SUGGEST_APP_TAP(1603),
-
- @UiEvent(doc = "User is shown All Apps education view.")
- LAUNCHER_ALL_APPS_EDU_SHOWN(523),
-
- @UiEvent(doc = "User opened a folder.")
- LAUNCHER_FOLDER_OPEN(551),
-
- @UiEvent(doc = "Hotseat education half sheet seen")
- LAUNCHER_HOTSEAT_EDU_SEEN(479),
-
- @UiEvent(doc = "Hotseat migration accepted")
- LAUNCHER_HOTSEAT_EDU_ACCEPT(480),
-
- @UiEvent(doc = "Hotseat migration denied")
- LAUNCHER_HOTSEAT_EDU_DENY(481),
-
- @UiEvent(doc = "Hotseat education tip shown")
- LAUNCHER_HOTSEAT_EDU_ONLY_TIP(482),
-
- /**
- * @deprecated LauncherUiChanged.rank field is repurposed to store all apps rank, so no
- * separate event is required.
- */
- @Deprecated
+ @UiEvent(doc = "User is shown All Apps education view.") LAUNCHER_ALL_APPS_EDU_SHOWN(523),
+ @UiEvent(doc = "User opened a folder.") LAUNCHER_FOLDER_OPEN(551),
+ @UiEvent(doc = "Hotseat education half sheet seen") LAUNCHER_HOTSEAT_EDU_SEEN(479),
+ @UiEvent(doc = "Hotseat migration accepted") LAUNCHER_HOTSEAT_EDU_ACCEPT(480),
+ @UiEvent(doc = "Hotseat migration denied") LAUNCHER_HOTSEAT_EDU_DENY(481),
+ @UiEvent(doc = "Hotseat education tip shown") LAUNCHER_HOTSEAT_EDU_ONLY_TIP(482),
@UiEvent(doc = "App launch ranking logged for all apps predictions")
+ @Deprecated(
+ """LauncherUiChanged.rank field is repurposed to store all apps rank, so no
+ separate event is required."""
+ )
LAUNCHER_ALL_APPS_RANKED(552),
-
@UiEvent(doc = "App launch ranking logged for hotseat predictions)")
LAUNCHER_HOTSEAT_RANKED(553),
@UiEvent(doc = "Launcher is now in background. e.g., Screen off event")
LAUNCHER_ONSTOP(562),
-
@UiEvent(doc = "Launcher is now in foreground. e.g., Screen on event, back button")
LAUNCHER_ONRESUME(563),
-
@UiEvent(doc = "User swipes or fling in LEFT direction on workspace.")
LAUNCHER_SWIPELEFT(564),
-
@UiEvent(doc = "User swipes or fling in RIGHT direction on workspace.")
LAUNCHER_SWIPERIGHT(565),
-
@UiEvent(doc = "User swipes or fling in UP direction in unknown way.")
LAUNCHER_UNKNOWN_SWIPEUP(566),
-
@UiEvent(doc = "User swipes or fling in DOWN direction in unknown way.")
LAUNCHER_UNKNOWN_SWIPEDOWN(567),
-
@UiEvent(doc = "User swipes or fling in UP direction to open apps drawer.")
LAUNCHER_ALLAPPS_OPEN_UP(568),
-
@UiEvent(doc = "User swipes or fling in DOWN direction to close apps drawer.")
LAUNCHER_ALLAPPS_CLOSE_DOWN(569),
-
@UiEvent(doc = "User tap outside apps drawer sheet to close apps drawer.")
LAUNCHER_ALLAPPS_CLOSE_TAP_OUTSIDE(941),
-
@UiEvent(doc = "User swipes or fling in UP direction and hold from the bottom bazel area")
LAUNCHER_OVERVIEW_GESTURE(570),
-
@UiEvent(doc = "User swipes or fling in LEFT direction on the bottom bazel area.")
LAUNCHER_QUICKSWITCH_LEFT(571),
-
@UiEvent(doc = "User swipes or fling in RIGHT direction on the bottom bazel area.")
LAUNCHER_QUICKSWITCH_RIGHT(572),
-
@UiEvent(doc = "User swipes or fling on the bottom bazel area to enter Desktop mode.")
LAUNCHER_QUICKSWITCH_ENTER_DESKTOP_MODE(2025),
-
@UiEvent(doc = "User swipes or fling on the bottom bazel area to exit Desktop mode.")
LAUNCHER_QUICKSWITCH_EXIT_DESKTOP_MODE(2026),
-
@UiEvent(doc = "User swipes or fling in DOWN direction on the bottom bazel area.")
LAUNCHER_SWIPEDOWN_NAVBAR(573),
-
@UiEvent(doc = "User deep presses on the bottom bezel area.")
LAUNCHER_DEEP_PRESS_NAVBAR(1543),
-
@UiEvent(doc = "User long presses on the bottom bezel area.")
LAUNCHER_LONG_PRESS_NAVBAR(1544),
-
@UiEvent(doc = "User deep presses on the stashed taskbar")
LAUNCHER_DEEP_PRESS_STASHED_TASKBAR(1602),
-
@UiEvent(doc = "User long presses on the stashed taskbar")
LAUNCHER_LONG_PRESS_STASHED_TASKBAR(1592),
-
@UiEvent(doc = "User swipes or fling in UP direction from bottom bazel area.")
LAUNCHER_HOME_GESTURE(574),
-
@UiEvent(doc = "User's workspace layout information is snapshot in the background.")
LAUNCHER_WORKSPACE_SNAPSHOT(579),
-
@UiEvent(doc = "User tapped on the screenshot button on overview)")
LAUNCHER_OVERVIEW_ACTIONS_SCREENSHOT(580),
-
@UiEvent(doc = "User tapped on the select button on overview)")
LAUNCHER_OVERVIEW_ACTIONS_SELECT(581),
-
@UiEvent(doc = "User tapped on the share button on overview")
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")
LAUNCHER_SELECT_MODE_CLOSE(583),
-
@UiEvent(doc = "User tapped on the highlight items in select mode")
LAUNCHER_SELECT_MODE_ITEM(584),
-
@UiEvent(doc = "Notification dot on app icon enabled.")
LAUNCHER_NOTIFICATION_DOT_ENABLED(611),
-
@UiEvent(doc = "Notification dot on app icon disabled.")
LAUNCHER_NOTIFICATION_DOT_DISABLED(612),
-
@UiEvent(doc = "For new apps, add app icons to home screen enabled.")
LAUNCHER_ADD_NEW_APPS_TO_HOME_SCREEN_ENABLED(613),
-
@UiEvent(doc = "For new apps, add app icons to home screen disabled.")
LAUNCHER_ADD_NEW_APPS_TO_HOME_SCREEN_DISABLED(614),
-
@UiEvent(doc = "Home screen rotation is enabled when phone is rotated.")
LAUNCHER_HOME_SCREEN_ROTATION_ENABLED(615),
-
@UiEvent(doc = "Home screen rotation is disabled when phone is rotated.")
LAUNCHER_HOME_SCREEN_ROTATION_DISABLED(616),
-
@UiEvent(doc = "Suggestions in all apps list enabled.")
LAUNCHER_ALL_APPS_SUGGESTIONS_ENABLED(619),
-
@UiEvent(doc = "Suggestions in all apps list disabled.")
LAUNCHER_ALL_APPS_SUGGESTIONS_DISABLED(620),
-
@UiEvent(doc = "Suggestions on home screen is enabled.")
LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED(621),
-
@UiEvent(doc = "Suggestions on home screen is disabled.")
LAUNCHER_HOME_SCREEN_SUGGESTIONS_DISABLED(622),
-
@UiEvent(doc = "System navigation is 3 button mode.")
LAUNCHER_NAVIGATION_MODE_3_BUTTON(623),
-
@UiEvent(doc = "System navigation mode is 2 button mode.")
LAUNCHER_NAVIGATION_MODE_2_BUTTON(624),
-
@UiEvent(doc = "System navigation mode is 0 button mode/gesture navigation mode .")
LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON(625),
-
@UiEvent(doc = "User tapped on image content in Overview Select mode.")
LAUNCHER_SELECT_MODE_IMAGE(627),
-
@UiEvent(doc = "User tapped on barcode content in Overview Select mode.")
LAUNCHER_SELECT_MODE_BARCODE(1531),
-
@UiEvent(doc = "Highlight gleams for barcode content in Overview Select mode.")
LAUNCHER_SELECT_MODE_SHOW_BARCODE_REGIONS(1532),
-
@UiEvent(doc = "Activity to add external item was started")
LAUNCHER_ADD_EXTERNAL_ITEM_START(641),
-
@UiEvent(doc = "Activity to add external item was cancelled")
LAUNCHER_ADD_EXTERNAL_ITEM_CANCELLED(642),
-
@UiEvent(doc = "Activity to add external item was backed out")
LAUNCHER_ADD_EXTERNAL_ITEM_BACK(643),
-
@UiEvent(doc = "Item was placed automatically in external item addition flow")
LAUNCHER_ADD_EXTERNAL_ITEM_PLACED_AUTOMATICALLY(644),
-
@UiEvent(doc = "Item was dragged in external item addition flow")
LAUNCHER_ADD_EXTERNAL_ITEM_DRAGGED(645),
-
@UiEvent(doc = "A folder was replaced by a single item")
LAUNCHER_FOLDER_CONVERTED_TO_ICON(646),
-
@UiEvent(doc = "A hotseat prediction item was pinned")
LAUNCHER_HOTSEAT_PREDICTION_PINNED(647),
-
- @UiEvent(doc = "Undo event was tapped.")
- LAUNCHER_UNDO(648),
-
- @UiEvent(doc = "Task switcher clear all target was tapped.")
- LAUNCHER_TASK_CLEAR_ALL(649),
-
- @UiEvent(doc = "Task preview was long pressed.")
- LAUNCHER_TASK_PREVIEW_LONGPRESS(650),
-
+ @UiEvent(doc = "Undo event was tapped.") LAUNCHER_UNDO(648),
+ @UiEvent(doc = "Task switcher clear all target was tapped.") LAUNCHER_TASK_CLEAR_ALL(649),
+ @UiEvent(doc = "Task preview was long pressed.") LAUNCHER_TASK_PREVIEW_LONGPRESS(650),
@UiEvent(doc = "User swiped down on workspace (triggering noti shade to open).")
LAUNCHER_SWIPE_DOWN_WORKSPACE_NOTISHADE_OPEN(651),
-
@UiEvent(doc = "Notification dismissed by swiping right.")
LAUNCHER_NOTIFICATION_DISMISSED(652),
-
- @UiEvent(doc = "Current grid size is changed to 2x2")
- LAUNCHER_GRID_SIZE_2_BY_2(2181),
-
- @UiEvent(doc = "Current grid size is changed to 3x3")
- LAUNCHER_GRID_SIZE_3_BY_3(2182),
-
- @UiEvent(doc = "Current grid size is changed to 4x4")
- LAUNCHER_GRID_SIZE_4_BY_4(2183),
-
- @UiEvent(doc = "Current grid size is changed to 4x5")
- LAUNCHER_GRID_SIZE_4_BY_5(2184),
-
- @UiEvent(doc = "Current grid size is changed to 4x6")
- LAUNCHER_GRID_SIZE_4_BY_6(2185),
-
- @UiEvent(doc = "Current grid size is changed to 5x5")
- LAUNCHER_GRID_SIZE_5_BY_5(2186),
-
- @UiEvent(doc = "Current grid size is changed to 5x6")
- LAUNCHER_GRID_SIZE_5_BY_6(2187),
-
- @UiEvent(doc = "Current grid size is changed to 6x5")
- LAUNCHER_GRID_SIZE_6_BY_5(2188),
-
- @UiEvent(doc = "App icon shape changed to Circle")
- LAUNCHER_ICON_SHAPE_CIRCLE(2229),
-
- @UiEvent(doc = "App icon shape changed to Square")
- LAUNCHER_ICON_SHAPE_SQUARE(2230),
-
+ @UiEvent(doc = "Current grid size is changed to 2x2") LAUNCHER_GRID_SIZE_2_BY_2(2181),
+ @UiEvent(doc = "Current grid size is changed to 3x3") LAUNCHER_GRID_SIZE_3_BY_3(2182),
+ @UiEvent(doc = "Current grid size is changed to 4x4") LAUNCHER_GRID_SIZE_4_BY_4(2183),
+ @UiEvent(doc = "Current grid size is changed to 4x5") LAUNCHER_GRID_SIZE_4_BY_5(2184),
+ @UiEvent(doc = "Current grid size is changed to 4x6") LAUNCHER_GRID_SIZE_4_BY_6(2185),
+ @UiEvent(doc = "Current grid size is changed to 5x5") LAUNCHER_GRID_SIZE_5_BY_5(2186),
+ @UiEvent(doc = "Current grid size is changed to 5x6") LAUNCHER_GRID_SIZE_5_BY_6(2187),
+ @UiEvent(doc = "Current grid size is changed to 6x5") LAUNCHER_GRID_SIZE_6_BY_5(2188),
+ @UiEvent(doc = "App icon shape changed to Circle") LAUNCHER_ICON_SHAPE_CIRCLE(2229),
+ @UiEvent(doc = "App icon shape changed to Square") LAUNCHER_ICON_SHAPE_SQUARE(2230),
@UiEvent(doc = "App icon shape changed to 4-sided Cookie")
LAUNCHER_ICON_SHAPE_FOUR_SIDED_COOKIE(2231),
-
@UiEvent(doc = "App icon shape changed to 7-sided Cookie")
LAUNCHER_ICON_SHAPE_SEVEN_SIDED_COOKIE(2232),
-
- @UiEvent(doc = "App icon shape changed to Arch")
- LAUNCHER_ICON_SHAPE_ARCH(2233),
-
- @UiEvent(doc = "Launcher entered into AllApps state.")
- LAUNCHER_ALLAPPS_ENTRY(692),
-
- @UiEvent(doc = "Launcher exited from AllApps state.")
- LAUNCHER_ALLAPPS_EXIT(693),
-
- @UiEvent(doc = "User closed the AllApps keyboard.")
- LAUNCHER_ALLAPPS_KEYBOARD_CLOSED(694),
-
+ @UiEvent(doc = "App icon shape changed to Arch") LAUNCHER_ICON_SHAPE_ARCH(2233),
+ @UiEvent(doc = "Launcher entered into AllApps state.") LAUNCHER_ALLAPPS_ENTRY(692),
+ @UiEvent(doc = "Launcher exited from AllApps state.") LAUNCHER_ALLAPPS_EXIT(693),
+ @UiEvent(doc = "User closed the AllApps keyboard.") LAUNCHER_ALLAPPS_KEYBOARD_CLOSED(694),
@UiEvent(doc = "User switched to AllApps Main/Personal tab by swiping left.")
LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB(695),
-
@UiEvent(doc = "User switched to AllApps Work tab by swiping right.")
LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB(696),
-
- @UiEvent(doc = "Default event when dedicated UI event is not available for the user action"
- + " on slice .")
+ @UiEvent(
+ doc =
+ ("Default event when dedicated UI event is not available for the user action" +
+ " on slice .")
+ )
LAUNCHER_SLICE_DEFAULT_ACTION(700),
-
- @UiEvent(doc = "User toggled-on a Slice item.")
- LAUNCHER_SLICE_TOGGLE_ON(701),
-
- @UiEvent(doc = "User toggled-off a Slice item.")
- LAUNCHER_SLICE_TOGGLE_OFF(702),
-
+ @UiEvent(doc = "User toggled-on a Slice item.") LAUNCHER_SLICE_TOGGLE_ON(701),
+ @UiEvent(doc = "User toggled-off a Slice item.") LAUNCHER_SLICE_TOGGLE_OFF(702),
@UiEvent(doc = "User acted on a Slice item with a button.")
LAUNCHER_SLICE_BUTTON_ACTION(703),
-
@UiEvent(doc = "User acted on a Slice item with a slider.")
LAUNCHER_SLICE_SLIDER_ACTION(704),
-
@UiEvent(doc = "User tapped on the entire row of a Slice.")
LAUNCHER_SLICE_CONTENT_ACTION(705),
-
@UiEvent(doc = "User tapped on the see more button of a Slice.")
LAUNCHER_SLICE_SEE_MORE_ACTION(706),
-
@UiEvent(doc = "User selected from a selection row of Slice.")
LAUNCHER_SLICE_SELECTION_ACTION(707),
-
@UiEvent(doc = "IME is used for selecting the focused item on the AllApps screen.")
LAUNCHER_ALLAPPS_FOCUSED_ITEM_SELECTED_WITH_IME(718),
-
@UiEvent(doc = "User long-pressed on an AllApps item.")
LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED(719),
-
@UiEvent(doc = "Launcher entered into AllApps state with device search enabled.")
LAUNCHER_ALLAPPS_ENTRY_WITH_DEVICE_SEARCH(720),
-
@UiEvent(doc = "User switched to AllApps Main/Personal tab by tapping on it.")
LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB(721),
-
@UiEvent(doc = "User switched to AllApps Work tab by tapping on it.")
LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB(722),
-
@UiEvent(doc = "All apps vertical fling started.")
LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN(724),
-
- @UiEvent(doc = "All apps vertical fling ended.")
- LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END(725),
-
+ @UiEvent(doc = "All apps vertical fling ended.") LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END(725),
@UiEvent(doc = "Show URL indicator for Overview Sharing")
LAUNCHER_OVERVIEW_SHARING_SHOW_URL_INDICATOR(764),
-
@UiEvent(doc = "Show image indicator for Overview Sharing")
LAUNCHER_OVERVIEW_SHARING_SHOW_IMAGE_INDICATOR(765),
-
@UiEvent(doc = "User taps URL indicator in Overview")
LAUNCHER_OVERVIEW_SHARING_URL_INDICATOR_TAP(766),
-
@UiEvent(doc = "User taps image indicator in Overview")
LAUNCHER_OVERVIEW_SHARING_IMAGE_INDICATOR_TAP(767),
-
@UiEvent(doc = "User long presses an image in Overview")
LAUNCHER_OVERVIEW_SHARING_IMAGE_LONG_PRESS(768),
-
- @UiEvent(doc = "User drags a URL in Overview")
- LAUNCHER_OVERVIEW_SHARING_URL_DRAG(769),
-
- @UiEvent(doc = "User drags an image in Overview")
- LAUNCHER_OVERVIEW_SHARING_IMAGE_DRAG(770),
-
+ @UiEvent(doc = "User drags a URL in Overview") LAUNCHER_OVERVIEW_SHARING_URL_DRAG(769),
+ @UiEvent(doc = "User drags an image in Overview") LAUNCHER_OVERVIEW_SHARING_IMAGE_DRAG(770),
@UiEvent(doc = "User drops URL to a direct share target")
LAUNCHER_OVERVIEW_SHARING_DROP_URL_TO_TARGET(771),
-
@UiEvent(doc = "User drops an image to a direct share target")
LAUNCHER_OVERVIEW_SHARING_DROP_IMAGE_TO_TARGET(772),
-
@UiEvent(doc = "User drops URL to the More button")
LAUNCHER_OVERVIEW_SHARING_DROP_URL_TO_MORE(773),
-
@UiEvent(doc = "User drops an image to the More button")
LAUNCHER_OVERVIEW_SHARING_DROP_IMAGE_TO_MORE(774),
-
@UiEvent(doc = "User taps a share target to share URL")
LAUNCHER_OVERVIEW_SHARING_TAP_TARGET_TO_SHARE_URL(775),
-
@UiEvent(doc = "User taps a share target to share an image")
LAUNCHER_OVERVIEW_SHARING_TAP_TARGET_TO_SHARE_IMAGE(776),
-
@UiEvent(doc = "User taps the More button to share URL")
LAUNCHER_OVERVIEW_SHARING_TAP_MORE_TO_SHARE_URL(777),
-
@UiEvent(doc = "User taps the More button to share an image")
LAUNCHER_OVERVIEW_SHARING_TAP_MORE_TO_SHARE_IMAGE(778),
-
@UiEvent(doc = "Show Barode indicator for overview sharing")
LAUNCHER_OVERVIEW_SHARING_SHOW_BARCODE_INDICATOR(1533),
-
@UiEvent(doc = "User taps barcode indicator in overview")
LAUNCHER_OVERVIEW_SHARING_BARCODE_INDICATOR_TAP(1534),
-
@UiEvent(doc = "Configure barcode region for long_press action for overview sharing")
LAUNCHER_OVERVIEW_SHARING_CONFIGURE_BARCODE_REGION_LONG_PRESS(1535),
-
@UiEvent(doc = "User long presses a barcode region in overview")
LAUNCHER_OVERVIEW_SHARING_BARCODE_REGION_LONG_PRESS(1536),
-
@UiEvent(doc = "User drags a barcode region in overview")
LAUNCHER_OVERVIEW_SHARING_BARCODE_REGION_DRAG(1537),
-
@UiEvent(doc = "User started resizing a widget on their home screen.")
LAUNCHER_WIDGET_RESIZE_STARTED(820),
-
@UiEvent(doc = "User finished resizing a widget on their home screen.")
LAUNCHER_WIDGET_RESIZE_COMPLETED(824),
-
@UiEvent(doc = "User reconfigured a widget on their home screen.")
LAUNCHER_WIDGET_RECONFIGURED(821),
-
@UiEvent(doc = "User enabled themed icons option in wallpaper & style settings.")
LAUNCHER_THEMED_ICON_ENABLED(836),
-
@UiEvent(doc = "User disabled themed icons option in wallpaper & style settings.")
LAUNCHER_THEMED_ICON_DISABLED(837),
-
@UiEvent(doc = "User tapped on 'Turn on work apps' button in all apps window.")
LAUNCHER_TURN_ON_WORK_APPS_TAP(838),
-
@UiEvent(doc = "User tapped on 'Turn off work apps' button in all apps window.")
LAUNCHER_TURN_OFF_WORK_APPS_TAP(839),
-
@UiEvent(doc = "Launcher item drop failed since there was not enough room on the screen.")
LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE(872),
-
@UiEvent(doc = "User clicks on the search icon on header to launch search in app.")
LAUNCHER_ALLAPPS_SEARCHINAPP_LAUNCH(913),
-
@UiEvent(doc = "User is shown the back gesture navigation tutorial step.")
LAUNCHER_GESTURE_TUTORIAL_BACK_STEP_SHOWN(959),
-
@UiEvent(doc = "User is shown the home gesture navigation tutorial step.")
LAUNCHER_GESTURE_TUTORIAL_HOME_STEP_SHOWN(960),
-
@UiEvent(doc = "User is shown the overview gesture navigation tutorial step.")
LAUNCHER_GESTURE_TUTORIAL_OVERVIEW_STEP_SHOWN(961),
-
@UiEvent(doc = "User completed the back gesture navigation tutorial step.")
LAUNCHER_GESTURE_TUTORIAL_BACK_STEP_COMPLETED(962),
-
@UiEvent(doc = "User completed the home gesture navigation tutorial step.")
LAUNCHER_GESTURE_TUTORIAL_HOME_STEP_COMPLETED(963),
-
@UiEvent(doc = "User completed the overview gesture navigation tutorial step.")
LAUNCHER_GESTURE_TUTORIAL_OVERVIEW_STEP_COMPLETED(964),
-
@UiEvent(doc = "User skips the gesture navigation tutorial.")
LAUNCHER_GESTURE_TUTORIAL_SKIPPED(965),
-
- @UiEvent(doc = "User scrolled on one of the all apps surfaces such as A-Z list, search "
- + "result page etc.")
+ @UiEvent(
+ doc =
+ ("User scrolled on one of the all apps surfaces such as A-Z list, search " +
+ "result page etc.")
+ )
LAUNCHER_ALLAPPS_SCROLLED(985),
-
@UiEvent(doc = "User scrolled up on the all apps personal A-Z list.")
LAUNCHER_ALLAPPS_PERSONAL_SCROLLED_UP(1287),
-
@UiEvent(doc = "User scrolled down on the all apps personal A-Z list.")
LAUNCHER_ALLAPPS_PERSONAL_SCROLLED_DOWN(1288),
-
- @UiEvent(doc = "User scrolled on one of the all apps surfaces such as A-Z list, search "
- + "result page etc and we don't know the direction since user came back to "
- + "original position from which they scrolled.")
+ @UiEvent(
+ doc =
+ ("User scrolled on one of the all apps surfaces such as A-Z list, search " +
+ "result page etc and we don't know the direction since user came back to " +
+ "original position from which they scrolled.")
+ )
LAUNCHER_ALLAPPS_SCROLLED_UNKNOWN_DIRECTION(1231),
-
- @UiEvent(doc = "User tapped taskbar home button")
- LAUNCHER_TASKBAR_HOME_BUTTON_TAP(1003),
-
- @UiEvent(doc = "User tapped taskbar back button")
- LAUNCHER_TASKBAR_BACK_BUTTON_TAP(1004),
-
+ @UiEvent(doc = "User tapped taskbar home button") LAUNCHER_TASKBAR_HOME_BUTTON_TAP(1003),
+ @UiEvent(doc = "User tapped taskbar back button") LAUNCHER_TASKBAR_BACK_BUTTON_TAP(1004),
@UiEvent(doc = "User tapped taskbar overview/recents button")
LAUNCHER_TASKBAR_OVERVIEW_BUTTON_TAP(1005),
-
@UiEvent(doc = "User tapped taskbar IME switcher button")
LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_TAP(1006),
-
- @UiEvent(doc = "User tapped taskbar a11y button")
- LAUNCHER_TASKBAR_A11Y_BUTTON_TAP(1007),
-
+ @UiEvent(doc = "User tapped taskbar a11y button") LAUNCHER_TASKBAR_A11Y_BUTTON_TAP(1007),
@UiEvent(doc = "User tapped taskbar home button")
LAUNCHER_TASKBAR_HOME_BUTTON_LONGPRESS(1008),
-
@UiEvent(doc = "User tapped taskbar back button")
LAUNCHER_TASKBAR_BACK_BUTTON_LONGPRESS(1009),
-
@UiEvent(doc = "User tapped taskbar overview/recents button")
LAUNCHER_TASKBAR_OVERVIEW_BUTTON_LONGPRESS(1010),
-
@UiEvent(doc = "User tapped taskbar a11y button")
LAUNCHER_TASKBAR_A11Y_BUTTON_LONGPRESS(1011),
-
@UiEvent(doc = "Show an 'Undo' snackbar when users dismiss a predicted hotseat item")
LAUNCHER_DISMISS_PREDICTION_UNDO(1035),
-
@UiEvent(doc = "User clicked on IME quicksearch button.")
LAUNCHER_ALLAPPS_QUICK_SEARCH_WITH_IME(1047),
-
@UiEvent(doc = "User tapped taskbar All Apps button.")
LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP(1057),
-
@UiEvent(doc = "User long pressed taskbar All Apps button.")
LAUNCHER_TASKBAR_ALLAPPS_BUTTON_LONG_PRESS(1607),
-
@UiEvent(doc = "User tapped on Share app system shortcut.")
LAUNCHER_SYSTEM_SHORTCUT_APP_SHARE_TAP(1075),
-
@UiEvent(doc = "User has invoked split to right half from an app icon menu")
LAUNCHER_APP_ICON_MENU_SPLIT_RIGHT_BOTTOM(1199),
-
@UiEvent(doc = "User has invoked split to left half from an app icon menu")
LAUNCHER_APP_ICON_MENU_SPLIT_LEFT_TOP(1200),
-
@UiEvent(doc = "Number of apps in A-Z list (personal and work profile)")
LAUNCHER_ALLAPPS_COUNT(1225),
-
@UiEvent(doc = "User has invoked split to right half with a keyboard shortcut.")
LAUNCHER_KEYBOARD_SHORTCUT_SPLIT_RIGHT_BOTTOM(1232),
-
@UiEvent(doc = "User has invoked split to left half with a keyboard shortcut.")
LAUNCHER_KEYBOARD_SHORTCUT_SPLIT_LEFT_TOP(1233),
-
@UiEvent(doc = "User has invoked split to right half from desktop mode.")
LAUNCHER_DESKTOP_MODE_SPLIT_RIGHT_BOTTOM(1412),
-
@UiEvent(doc = "User has invoked split to left half from desktop mode.")
LAUNCHER_DESKTOP_MODE_SPLIT_LEFT_TOP(1464),
-
- @UiEvent(doc = "User has collapsed the work FAB button by scrolling down in the all apps"
- + " work A-Z list.")
+ @UiEvent(
+ doc =
+ ("User has collapsed the work FAB button by scrolling down in the all apps" +
+ " work A-Z list.")
+ )
LAUNCHER_WORK_FAB_BUTTON_COLLAPSE(1276),
-
- @UiEvent(doc = "User has collapsed the work FAB button by scrolling up in the all apps"
- + " work A-Z list.")
+ @UiEvent(
+ doc =
+ ("User has collapsed the work FAB button by scrolling up in the all apps" +
+ " work A-Z list.")
+ )
LAUNCHER_WORK_FAB_BUTTON_EXTEND(1277),
-
@UiEvent(doc = "User scrolled down on the search result page.")
LAUNCHER_ALLAPPS_SEARCH_SCROLLED_DOWN(1285),
-
@UiEvent(doc = "User scrolled up on the search result page.")
LAUNCHER_ALLAPPS_SEARCH_SCROLLED_UP(1286),
-
@UiEvent(doc = "User or automatic timeout has hidden transient taskbar.")
LAUNCHER_TRANSIENT_TASKBAR_HIDE(1330),
-
@UiEvent(doc = "User has swiped upwards from the gesture handle to show transient taskbar.")
LAUNCHER_TRANSIENT_TASKBAR_SHOW(1331),
-
@UiEvent(doc = "User has clicked an app pair and launched directly into split screen.")
LAUNCHER_APP_PAIR_LAUNCH(1374),
-
- @UiEvent(doc = "User saved an app pair.")
- LAUNCHER_APP_PAIR_SAVE(1456),
-
+ @UiEvent(doc = "User saved an app pair.") LAUNCHER_APP_PAIR_SAVE(1456),
@UiEvent(doc = "App launched through pending intent")
LAUNCHER_APP_LAUNCH_PENDING_INTENT(1394),
-
@UiEvent(doc = "User long pressed on taskbar divider icon to open popup menu")
LAUNCHER_TASKBAR_DIVIDER_MENU_OPEN(1488),
-
@UiEvent(doc = "User long pressed on taskbar divider icon to close popup menu")
LAUNCHER_TASKBAR_DIVIDER_MENU_CLOSE(1489),
-
@UiEvent(doc = "User has pinned taskbar using taskbar divider menu")
LAUNCHER_TASKBAR_PINNED(1490),
-
@UiEvent(doc = "User has unpinned taskbar using taskbar divider menu")
LAUNCHER_TASKBAR_UNPINNED(1491),
-
@UiEvent(doc = "User tapped private space lock button")
LAUNCHER_PRIVATE_SPACE_LOCK_TAP(1548),
-
@UiEvent(doc = "User tapped private space unlock button")
LAUNCHER_PRIVATE_SPACE_UNLOCK_TAP(1549),
-
@UiEvent(doc = "User tapped private space settings button")
LAUNCHER_PRIVATE_SPACE_SETTINGS_TAP(1550),
-
@UiEvent(doc = "User tapped on install to private space system shortcut.")
LAUNCHER_PRIVATE_SPACE_INSTALL_SYSTEM_SHORTCUT_TAP(1565),
-
@UiEvent(doc = "User tapped private space install app button.")
LAUNCHER_PRIVATE_SPACE_INSTALL_APP_BUTTON_TAP(1605),
-
@UiEvent(doc = "User attempted to create split screen with a widget")
LAUNCHER_SPLIT_WIDGET_ATTEMPT(1604),
-
@UiEvent(doc = "User tapped on private space uninstall system shortcut.")
LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP(1608),
-
- @UiEvent(doc = "User initiated split selection")
- LAUNCHER_SPLIT_SELECTION_INITIATED(1618),
-
+ @UiEvent(doc = "User initiated split selection") LAUNCHER_SPLIT_SELECTION_INITIATED(1618),
@UiEvent(doc = "User finished a split selection session")
LAUNCHER_SPLIT_SELECTION_COMPLETE(1619),
-
@UiEvent(doc = "User selected both apps for split screen")
LAUNCHER_SPLIT_SELECTED_SECOND_APP(1609),
-
- @UiEvent(doc = "User exited split selection by going home via swipe, button, or state "
- + "transition")
+ @UiEvent(
+ doc =
+ ("User exited split selection by going home via swipe, button, or state " +
+ "transition")
+ )
LAUNCHER_SPLIT_SELECTION_EXIT_HOME(1610),
-
@UiEvent(doc = "User exited split selection by tapping cancel in split instructions view")
LAUNCHER_SPLIT_SELECTION_EXIT_CANCEL_BUTTON(1611),
-
- @UiEvent(doc = "User exited split selection when another activity/app came to foreground"
- + " after first app had been selected OR if user long-pressed on home. Default exit"
- + " metric.")
+ @UiEvent(
+ doc =
+ ("User exited split selection when another activity/app came to foreground" +
+ " after first app had been selected OR if user long-pressed on home. Default exit" +
+ " metric.")
+ )
LAUNCHER_SPLIT_SELECTION_EXIT_INTERRUPTED(1612),
-
@UiEvent(doc = "User tapped add widget button in widget sheet.")
LAUNCHER_WIDGET_ADD_BUTTON_TAP(1622),
-
@UiEvent(doc = "Number of user installed Private profile apps, shown above separator line")
LAUNCHER_PRIVATE_SPACE_USER_INSTALLED_APPS_COUNT(1672),
-
@UiEvent(doc = "Number of preinstalled Private profile apps, shown under separator line")
LAUNCHER_PRIVATE_SPACE_PREINSTALLED_APPS_COUNT(1673),
-
@UiEvent(doc = "Private space lock animation started")
LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_BEGIN(1725),
-
@UiEvent(doc = "Private space lock animation finished")
LAUNCHER_PRIVATE_SPACE_LOCK_ANIMATION_END(1726),
-
@UiEvent(doc = "Private space unlock animation started")
LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_BEGIN(1727),
-
@UiEvent(doc = "Private space unlock animation finished")
LAUNCHER_PRIVATE_SPACE_UNLOCK_ANIMATION_END(1728),
-
@UiEvent(doc = "User rotates whilst in Overview / RecentsView")
LAUNCHER_OVERVIEW_ORIENTATION_CHANGED(1762),
-
@UiEvent(doc = "User launches Overview from 3 button navigation")
LAUNCHER_OVERVIEW_SHOW_OVERVIEW_FROM_3_BUTTON(1763),
-
@UiEvent(doc = "User launches Overview from alt+tab keyboard quick switch")
LAUNCHER_OVERVIEW_SHOW_OVERVIEW_FROM_KEYBOARD_QUICK_SWITCH(1764),
-
@UiEvent(doc = "User launches Overview from meta+tab keyboard shortcut")
LAUNCHER_OVERVIEW_SHOW_OVERVIEW_FROM_KEYBOARD_SHORTCUT(1765),
-
@UiEvent(doc = "User long pressed on the taskbar IME switcher button")
LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS(1798),
-
@UiEvent(doc = "Failed to launch assistant due to Google assistant not available")
LAUNCHER_LAUNCH_ASSISTANT_FAILED_NOT_AVAILABLE(1465),
-
@UiEvent(doc = "Failed to launch assistant due to service error")
LAUNCHER_LAUNCH_ASSISTANT_FAILED_SERVICE_ERROR(1466),
-
@UiEvent(doc = "User launched assistant by long-pressing nav handle")
LAUNCHER_LAUNCH_ASSISTANT_SUCCESSFUL_NAV_HANDLE(1467),
-
@UiEvent(doc = "Failed to launch due to Contextual Search not available")
LAUNCHER_LAUNCH_OMNI_FAILED_NOT_AVAILABLE(1471),
-
@UiEvent(doc = "Failed to launch due to Contextual Search setting disabled")
LAUNCHER_LAUNCH_OMNI_FAILED_SETTING_DISABLED(1632),
-
@UiEvent(doc = "User launched Contextual Search by long-pressing home in 3-button mode")
LAUNCHER_LAUNCH_OMNI_SUCCESSFUL_HOME(1481),
-
@UiEvent(doc = "User launched Contextual Search by using accessibility System Action")
LAUNCHER_LAUNCH_OMNI_SUCCESSFUL_SYSTEM_ACTION(1492),
-
@UiEvent(doc = "User launched Contextual Search by long pressing the meta key")
LAUNCHER_LAUNCH_OMNI_SUCCESSFUL_META(1606),
-
@UiEvent(doc = "Contextual Search invocation was attempted over the notification shade")
LAUNCHER_LAUNCH_OMNI_ATTEMPTED_OVER_NOTIFICATION_SHADE(1485),
-
@UiEvent(doc = "The Contextual Search all entrypoints toggle value in Settings")
LAUNCHER_SETTINGS_OMNI_ALL_ENTRYPOINTS_TOGGLE_VALUE(1633),
-
@UiEvent(doc = "Contextual Search invocation was attempted over the keyguard")
LAUNCHER_LAUNCH_OMNI_ATTEMPTED_OVER_KEYGUARD(1501),
-
@UiEvent(doc = "Contextual Search invocation was attempted while splitscreen is active")
LAUNCHER_LAUNCH_OMNI_ATTEMPTED_SPLITSCREEN(1505),
-
@UiEvent(doc = "User long press nav handle and a long press runnable was created.")
LAUNCHER_OMNI_GET_LONG_PRESS_RUNNABLE(1545),
-
@UiEvent(doc = "User tapped on \"change aspect ratio\" system shortcut.")
LAUNCHER_ASPECT_RATIO_SETTINGS_SYSTEM_SHORTCUT_TAP(2219),
// One Grid Flags
@UiEvent(doc = "User sets the device in Fixed Landscape")
FIXED_LANDSCAPE_TOGGLE_ENABLE(2014),
-
@UiEvent(doc = "User sets the device in Fixed Landscape")
FIXED_LANDSCAPE_TOGGLE_DISABLED(2020),
-
@UiEvent(doc = "Work utility view expand animation started")
LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_BEGIN(2075),
-
@UiEvent(doc = "Work utility view expand animation ended")
LAUNCHER_WORK_UTILITY_VIEW_EXPAND_ANIMATION_END(2076),
-
@UiEvent(doc = "Work utility view shrink animation started")
LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_BEGIN(2077),
-
@UiEvent(doc = "Work utility view shrink animation ended")
LAUNCHER_WORK_UTILITY_VIEW_SHRINK_ANIMATION_END(2078),
-
- @UiEvent(doc = "Standard grid migration occurred")
- LAUNCHER_STANDARD_GRID_MIGRATION(2200),
-
- @UiEvent(doc = "Row shift grid migration occurred")
- LAUNCHER_ROW_SHIFT_GRID_MIGRATION(2201),
-
+ @UiEvent(doc = "Standard grid migration occurred") LAUNCHER_STANDARD_GRID_MIGRATION(2200),
+ @UiEvent(doc = "Row shift grid migration occurred") LAUNCHER_ROW_SHIFT_GRID_MIGRATION(2201),
@UiEvent(doc = "Do standard migration when upgrading to one grid")
LAUNCHER_STANDARD_ONE_GRID_MIGRATION(2205),
-
@UiEvent(doc = "Do row shift migration when upgrading to one grid")
LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION(2206),
-
@UiEvent(doc = "User has pinned taskbar in desktop mode using taskbar divider menu")
LAUNCHER_DESKTOP_MODE_TASKBAR_PINNED(2241),
-
@UiEvent(doc = "User has unpinned taskbar in desktop mode using taskbar divider menu")
LAUNCHER_DESKTOP_MODE_TASKBAR_UNPINNED(2242),
-
// ADD MORE
- ;
-
- private final int mId;
-
- LauncherEvent(int id) {
- mId = id;
- }
-
- public int getId() {
- return mId;
- }
}
/** Launcher's latency events. */
- public enum LauncherLatencyEvent implements EventEnum {
+ enum class LauncherLatencyEvent(override val id: Int) : EventEnum {
// Details of below 6 events with prefix of "LAUNCHER_LATENCY_STARTUP_" are discussed in
// go/launcher-startup-latency
@UiEvent(doc = "The total duration of launcher startup latency.")
LAUNCHER_LATENCY_STARTUP_TOTAL_DURATION(1362),
-
@UiEvent(doc = "The duration of launcher activity's onCreate().")
LAUNCHER_LATENCY_STARTUP_ACTIVITY_ON_CREATE(1363),
-
- @UiEvent(doc =
- "The duration to inflate launcher root view in launcher activity's onCreate().")
+ @UiEvent(
+ doc = "The duration to inflate launcher root view in launcher activity's onCreate()."
+ )
LAUNCHER_LATENCY_STARTUP_VIEW_INFLATION(1364),
-
@UiEvent(doc = "The duration of asynchronous loading workspace")
LAUNCHER_LATENCY_STARTUP_WORKSPACE_LOADER_ASYNC(1367),
-
- @UiEvent(doc = "Time passed between Contextual Search runnable creation and execution. This"
- + " ensures that Recent animations have finished before Contextual Search starts.")
+ @UiEvent(
+ doc =
+ ("Time passed between Contextual Search runnable creation and execution. This" +
+ " ensures that Recent animations have finished before Contextual Search starts.")
+ )
LAUNCHER_LATENCY_OMNI_RUNNABLE(1546),
-
- @UiEvent(doc = "Time passed between nav handle touch down and cancellation without "
- + "triggering Contextual Search")
+ @UiEvent(
+ doc =
+ ("Time passed between nav handle touch down and cancellation without " +
+ "triggering Contextual Search")
+ )
LAUNCHER_LATENCY_CONTEXTUAL_SEARCH_LPNH_ABANDON(2171),
- ;
-
- private final int mId;
-
- LauncherLatencyEvent(int id) {
- mId = id;
- }
-
- @Override
- public int getId() {
- return mId;
- }
}
- /**
- * Launcher specific ranking related events.
- */
- public enum LauncherRankingEvent implements EventEnum {
-
- UNKNOWN(0);
- // ADD MORE
-
- private final int mId;
-
- LauncherRankingEvent(int id) {
- mId = id;
- }
-
- public int getId() {
- return mId;
- }
+ /** Launcher specific ranking related events. */
+ enum class LauncherRankingEvent(override val id: Int) : EventEnum {
+ UNKNOWN(0) // ADD MORE
}
- /**
- * Helps to construct and log launcher event.
- */
- public interface StatsLogger {
+ /** Helps to construct and log launcher event. */
+ interface StatsLogger {
+ /** Sets log fields from provided [ItemInfo]. */
+ fun withItemInfo(itemInfo: ItemInfo?) = this
- /**
- * Sets log fields from provided {@link ItemInfo}.
- */
- default StatsLogger withItemInfo(ItemInfo itemInfo) {
- return this;
- }
+ /** Sets [InstanceId] of log message. */
+ fun withInstanceId(instanceId: InstanceId?) = this
+ /** Sets rank field of log message. */
+ fun withRank(rank: Int) = this
- /**
- * Sets {@link InstanceId} of log message.
- */
- default StatsLogger withInstanceId(InstanceId instanceId) {
- return this;
- }
+ /** Sets source launcher state field of log message. */
+ fun withSrcState(srcState: Int) = this
- /**
- * Sets rank field of log message.
- */
- default StatsLogger withRank(int rank) {
- return this;
- }
+ /** Sets destination launcher state field of log message. */
+ fun withDstState(dstState: Int) = this
- /**
- * Sets source launcher state field of log message.
- */
- default StatsLogger withSrcState(int srcState) {
- return this;
- }
+ /** Sets FromState field of log message. */
+ fun withFromState(fromState: FromState?) = this
- /**
- * Sets destination launcher state field of log message.
- */
- default StatsLogger withDstState(int dstState) {
- return this;
- }
+ /** Sets ToState field of log message. */
+ fun withToState(toState: ToState?) = this
- /**
- * Sets FromState field of log message.
- */
- default StatsLogger withFromState(FromState fromState) {
- return this;
- }
-
- /**
- * Sets ToState field of log message.
- */
- default StatsLogger withToState(ToState toState) {
- return this;
- }
-
- /**
- * Sets editText field of log message.
- */
- default StatsLogger withEditText(String editText) {
- return this;
- }
+ /** Sets editText field of log message. */
+ fun withEditText(editText: String?) = this
/**
* Sets the final value for container related fields of log message.
*
- * By default container related fields are derived from {@link ItemInfo}, this method would
+ * By default container related fields are derived from [ItemInfo], this method would
* override those values.
*/
- default StatsLogger withContainerInfo(ContainerInfo containerInfo) {
- return this;
- }
+ fun withContainerInfo(containerInfo: ContainerInfo?) = this
+
+ /** Sets logging fields from provided [SliceItem]. */
+ fun withSliceItem(sliceItem: SliceItem) = this
+
+ /** Sets logging fields from provided [LauncherAtom.Slice]. */
+ fun withSlice(slice: Slice) = this
+
+ /** Sets cardinality of log message. */
+ fun withCardinality(cardinality: Int) = this
+
+ /** Sets the input type of the log message. */
+ fun withInputType(inputType: Int) = this
+
+ /** Set the features of the log message. */
+ fun withFeatures(feature: Int) = this
+
+ /** Set the package name of the log message. */
+ fun withPackageName(packageName: String?) = this
+
+ /** Builds the final message and logs it as [EventEnum]. */
+ fun log(event: EventEnum) {}
/**
- * Sets logging fields from provided {@link SliceItem}.
+ * Builds the final message and logs it to two different atoms, one for event tracking and
+ * the other for jank tracking.
*/
- default StatsLogger withSliceItem(SliceItem sliceItem) {
- return this;
- }
-
- /**
- * Sets logging fields from provided {@link LauncherAtom.Slice}.
- */
- default StatsLogger withSlice(LauncherAtom.Slice slice) {
- return this;
- }
-
- /**
- * Sets cardinality of log message.
- */
- default StatsLogger withCardinality(int cardinality) {
- return this;
- }
-
- /**
- * Sets the input type of the log message.
- */
- default StatsLogger withInputType(int inputType) {
- return this;
- }
-
- /**
- * Set the features of the log message.
- */
- default StatsLogger withFeatures(int feature) {
- return this;
- }
-
- /**
- * Set the package name of the log message.
- */
- default StatsLogger withPackageName(@Nullable String packageName) {
- return this;
- }
-
- /**
- * Builds the final message and logs it as {@link EventEnum}.
- */
- default void log(EventEnum event) {
- }
-
- /**
- * Builds the final message and logs it to two different atoms, one for
- * event tracking and the other for jank tracking.
- */
- default void sendToInteractionJankMonitor(EventEnum event, View v) {
- }
+ fun sendToInteractionJankMonitor(event: EventEnum?, v: View?) {}
}
- /**
- * Helps to construct and log latency event.
- */
- public interface StatsLatencyLogger {
-
- /** Package Id for Launcher */
- int LAUNCHER_LATENCY_PACKAGE_ID = 3;
-
+ /** Helps to construct and log latency event. */
+ interface StatsLatencyLogger {
/**
* Should be in sync with:
* google3/wireless/android/sysui/aster/asterstats/launcher_event_processed.proto
*/
- enum LatencyType {
+ enum class LatencyType(val id: Int) {
UNKNOWN(0),
+
// example: launcher restart that happens via daily backup and restore
COLD(1),
HOT(2),
@@ -1161,229 +739,176 @@ public class StatsLogManager {
ATOMIC(6),
CONTROLLED(7),
CACHED(8),
+
// example: device is rebooting via power key or shell command `adb reboot`
COLD_DEVICE_REBOOTING(9),
+
// Tracking warm startup latency:
// https://developer.android.com/topic/performance/vitals/launch-time#warm
- WARM(10);
- private final int mId;
-
- LatencyType(int id) {
- this.mId = id;
- }
-
- public int getId() {
- return mId;
- }
+ WARM(10),
}
- /**
- * Sets {@link InstanceId} of log message.
- */
- default StatsLatencyLogger withInstanceId(InstanceId instanceId) {
- return this;
- }
+ /** Sets [InstanceId] of log message. */
+ fun withInstanceId(instanceId: InstanceId?) = this
+ /** Sets latency of the event. */
+ fun withLatency(latencyInMillis: Long) = this
- /**
- * Sets latency of the event.
- */
- default StatsLatencyLogger withLatency(long latencyInMillis) {
- return this;
- }
+ /** Sets [LatencyType] of log message. */
+ fun withType(type: LatencyType?) = this
- /**
- * Sets {@link LatencyType} of log message.
- */
- default StatsLatencyLogger withType(LatencyType type) {
- return this;
- }
-
- /**
- * Sets query length of the event.
- */
- default StatsLatencyLogger withQueryLength(int queryLength) {
- return this;
- }
-
- /**
- * Sets sub event type.
- */
- default StatsLatencyLogger withSubEventType(int type) {
- return this;
- }
+ /** Sets query length of the event. */
+ fun withQueryLength(queryLength: Int) = this
+ /** Sets sub event type. */
+ fun withSubEventType(type: Int) = this
/** Sets cardinality of the event. */
- default StatsLatencyLogger withCardinality(int cardinality) {
- return this;
- }
+ fun withCardinality(cardinality: Int) = this
- /**
- * Sets packageId of log message.
- */
- default StatsLatencyLogger withPackageId(int packageId) {
- return this;
- }
+ /** Sets packageId of log message. */
+ fun withPackageId(packageId: Int) = this
- /**
- * Builds the final message and logs it as {@link EventEnum}.
- */
- default void log(EventEnum event) {
+ /** Builds the final message and logs it as [EventEnum]. */
+ fun log(event: EventEnum) {}
+
+ companion object {
+ /** Package Id for Launcher */
+ const val LAUNCHER_LATENCY_PACKAGE_ID: Int = 3
}
}
- /**
- * Helps to construct and log impression event.
- */
- public interface StatsImpressionLogger {
+ /** Helps to construct and log impression event. */
+ interface StatsImpressionLogger {
- enum State {
+ enum class State(val launcherState: Int) {
UNKNOWN(0),
ALLAPPS(1),
- SEARCHBOX_WIDGET(2);
- private final int mLauncherState;
-
- State(int id) {
- this.mLauncherState = id;
- }
-
- public int getLauncherState() {
- return mLauncherState;
- }
+ SEARCHBOX_WIDGET(2),
}
+ /** Sets [InstanceId] of log message. */
+ fun withInstanceId(instanceId: InstanceId?) = this
+
+ /** Sets [State] of impression event. */
+ fun withState(state: State?) = this
+
+ /** Sets query length of the event. */
+ fun withQueryLength(queryLength: Int) = this
+
+ /** Sets [com.android.app.search.ResultType] for the impression event. */
+ fun withResultType(resultType: Int) = this
+
/**
- * Sets {@link InstanceId} of log message.
+ * Sets boolean for each of [com.android.app.search.ResultType] that indicates if this
+ * result is above keyboard or not for the impression event.
*/
- default StatsImpressionLogger withInstanceId(InstanceId instanceId) {
- return this;
- }
+ fun withAboveKeyboard(aboveKeyboard: Boolean) = this
/**
- * Sets {@link State} of impression event.
+ * Sets uid for each of [com.android.app.search.ResultType] that indicates package name for
+ * the impression event.
*/
- default StatsImpressionLogger withState(State state) {
- return this;
- }
+ fun withUid(uid: Int) = this
- /**
- * Sets query length of the event.
- */
- default StatsImpressionLogger withQueryLength(int queryLength) {
- return this;
- }
+ /** Sets result source that indicates the origin of the result for the impression event. */
+ fun withResultSource(resultSource: Int) = this
- /**
- * Sets {@link com.android.app.search.ResultType} for the impression event.
- */
- default StatsImpressionLogger withResultType(int resultType) {
- return this;
- }
-
- /**
- * Sets boolean for each of {@link com.android.app.search.ResultType} that indicates
- * if this result is above keyboard or not for the impression event.
- */
- default StatsImpressionLogger withAboveKeyboard(boolean aboveKeyboard) {
- return this;
- }
-
- /**
- * Sets uid for each of {@link com.android.app.search.ResultType} that indicates
- * package name for the impression event.
- */
- default StatsImpressionLogger withUid(int uid) {
- return this;
- }
-
- /**
- * Sets result source that indicates the origin of the result for the impression event.
- */
- default StatsImpressionLogger withResultSource(int resultSource) {
- return this;
- }
-
- /**
- * Builds the final message and logs it as {@link EventEnum}.
- */
- default void log(EventEnum event) {
- }
+ /** Builds the final message and logs it as [EventEnum]. */
+ fun log(event: EventEnum) {}
}
- /**
- * Returns new logger object.
- */
- public StatsLogger logger() {
- StatsLogger logger = createLogger();
+ /** Returns new logger object. */
+ fun logger(): StatsLogger {
+ val logger = createLogger()
if (mInstanceId != null) {
- logger.withInstanceId(mInstanceId);
+ logger.withInstanceId(mInstanceId)
}
- return logger;
+ return logger
}
- /**
- * Returns new latency logger object.
- */
- public StatsLatencyLogger latencyLogger() {
- StatsLatencyLogger logger = createLatencyLogger();
+ /** Returns new latency logger object. */
+ fun latencyLogger(): StatsLatencyLogger {
+ val logger = createLatencyLogger()
if (mInstanceId != null) {
- logger.withInstanceId(mInstanceId);
+ logger.withInstanceId(mInstanceId)
}
- return logger;
+ return logger
}
- /**
- * Returns new impression logger object.
- */
- public StatsImpressionLogger impressionLogger() {
- StatsImpressionLogger logger = createImpressionLogger();
+ /** Returns new impression logger object. */
+ fun impressionLogger(): StatsImpressionLogger {
+ val logger = createImpressionLogger()
if (mInstanceId != null) {
- logger.withInstanceId(mInstanceId);
+ logger.withInstanceId(mInstanceId)
}
- return logger;
+ return logger
}
- /**
- * Returns a singleton KeyboardStateManager.
- */
- public KeyboardStateManager keyboardStateManager() {
+ /** Returns a singleton KeyboardStateManager. */
+ fun keyboardStateManager(): KeyboardStateManager {
if (mKeyboardStateManager == null) {
- mKeyboardStateManager = new KeyboardStateManager(
- mContext != null ? mContext.getResources().getDimensionPixelSize(
- R.dimen.default_ime_height) : 0);
+ mKeyboardStateManager =
+ KeyboardStateManager(
+ mContext.resources?.getDimensionPixelSize(R.dimen.default_ime_height) ?: 0
+ )
}
- return mKeyboardStateManager;
+ return mKeyboardStateManager!!
}
- protected StatsLogger createLogger() {
- return new StatsLogger() {
- };
+ protected open fun createLogger(): StatsLogger {
+ return object : StatsLogger {}
}
- protected StatsLatencyLogger createLatencyLogger() {
- return new StatsLatencyLogger() {
- };
+ protected open fun createLatencyLogger(): StatsLatencyLogger {
+ return object : StatsLatencyLogger {}
}
- protected StatsImpressionLogger createImpressionLogger() {
- return new StatsImpressionLogger() {
- };
+ protected open fun createImpressionLogger(): StatsImpressionLogger {
+ return object : StatsImpressionLogger {}
}
- /**
- * Sets InstanceId to every new {@link StatsLogger} object returned by {@link #logger()} when
- * not-null.
- */
- public StatsLogManager withDefaultInstanceId(@Nullable InstanceId instanceId) {
- this.mInstanceId = instanceId;
- return this;
+ /** Sets InstanceId to every new [StatsLogger] object returned by [.logger] when not-null. */
+ fun withDefaultInstanceId(instanceId: InstanceId?): StatsLogManager {
+ this.mInstanceId = instanceId
+ return this
}
- /**
- * Creates a new instance of {@link StatsLogManager} based on provided context.
- */
- public static StatsLogManager newInstance(Context context) {
- return LauncherComponentProvider.get(context).getStatsLogManagerFactory().create(context);
+ companion object {
+ const val LAUNCHER_STATE_UNSPECIFIED: Int = 0
+ const val LAUNCHER_STATE_BACKGROUND: Int = 1
+ const val LAUNCHER_STATE_HOME: Int = 2
+ const val LAUNCHER_STATE_OVERVIEW: Int = 3
+ const val LAUNCHER_STATE_ALLAPPS: Int = 4
+ const val LAUNCHER_STATE_UNCHANGED: Int = 5
+
+ /**
+ * Returns event enum based on the two state transition information when swipe gesture
+ * happens(to be removed during UserEventDispatcher cleanup).
+ */
+ @JvmStatic
+ fun getLauncherAtomEvent(
+ startState: Int,
+ targetState: Int,
+ fallbackEvent: EventEnum,
+ ): EventEnum {
+ return when {
+ startState == LAUNCHER_STATE_HOME && targetState == LAUNCHER_STATE_HOME ->
+ LAUNCHER_HOME_GESTURE
+ startState != LAUNCHER_STATE_OVERVIEW && targetState == LAUNCHER_STATE_OVERVIEW ->
+ LAUNCHER_OVERVIEW_GESTURE
+ startState != LAUNCHER_STATE_ALLAPPS && targetState == LAUNCHER_STATE_ALLAPPS ->
+ LAUNCHER_ALLAPPS_OPEN_UP
+ startState == LAUNCHER_STATE_ALLAPPS && targetState != LAUNCHER_STATE_ALLAPPS ->
+ LAUNCHER_ALLAPPS_CLOSE_DOWN
+ else -> fallbackEvent // TODO fix
+ }
+ }
+
+ /** Creates a new instance of [StatsLogManager] based on provided context. */
+ @JvmStatic
+ fun newInstance(context: Context): StatsLogManager {
+ return context.appComponent.statsLogManagerFactory.create(context)
+ }
}
}
diff --git a/tests/multivalentTests/src/com/android/launcher3/logging/StartupLatencyLoggerTest.kt b/tests/multivalentTests/src/com/android/launcher3/logging/StartupLatencyLoggerTest.kt
index 3630e8f506..7fd3570b80 100644
--- a/tests/multivalentTests/src/com/android/launcher3/logging/StartupLatencyLoggerTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/logging/StartupLatencyLoggerTest.kt
@@ -25,7 +25,7 @@ import com.android.launcher3.logging.StatsLogManager.LauncherLatencyEvent.LAUNCH
import com.android.launcher3.logging.StatsLogManager.LauncherLatencyEvent.LAUNCHER_LATENCY_STARTUP_VIEW_INFLATION
import com.android.launcher3.logging.StatsLogManager.LauncherLatencyEvent.LAUNCHER_LATENCY_STARTUP_WORKSPACE_LOADER_ASYNC
import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger
-import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.LAUNCHER_LATENCY_PACKAGE_ID
+import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.Companion.LAUNCHER_LATENCY_PACKAGE_ID
import com.android.launcher3.logging.StatsLogManager.StatsLatencyLogger.LatencyType
import com.android.launcher3.util.Executors.MAIN_EXECUTOR
import com.android.launcher3.util.LauncherMultivalentJUnit