[AA+] Add WW logging for Slice actions.

Bug: 178562918
Test: Manual
Change-Id: I515ee3c0990dea2c30e68d5919568dc1773912ee
This commit is contained in:
thiruram 2021-02-17 19:37:25 -08:00
parent 97710ffbb2
commit d0ab1a0eed
3 changed files with 70 additions and 3 deletions

View File

@ -29,6 +29,7 @@ message ItemInfo {
Shortcut shortcut = 3;
Widget widget = 4;
FolderIcon folder_icon = 9;
Slice slice = 10;
SearchActionItem search_action_item = 11;
}
// When used for launch event, stores the global predictive rank
@ -170,6 +171,11 @@ message FolderIcon {
optional string label_info = 4;
}
// Contains Slice details for logging.
message Slice{
optional string uri = 1;
}
// Represents SearchAction with in launcher
message SearchActionItem{
optional string package_name = 1;

View File

@ -16,6 +16,9 @@
package com.android.quickstep.logging;
import static androidx.core.util.Preconditions.checkNotNull;
import static androidx.core.util.Preconditions.checkState;
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;
@ -29,7 +32,9 @@ import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGE
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.WorkerThread;
import androidx.slice.SliceItem;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.Utilities;
@ -140,6 +145,7 @@ public class StatsLogCompatManager extends StatsLogManager {
private Optional<FromState> mFromState = Optional.empty();
private Optional<ToState> mToState = Optional.empty();
private Optional<String> mEditText = Optional.empty();
private SliceItem mSliceItem;
@Override
public StatsLogger withItemInfo(ItemInfo itemInfo) {
@ -177,10 +183,8 @@ public class StatsLogCompatManager extends StatsLogManager {
@Override
public StatsLogger withContainerInfo(ContainerInfo containerInfo) {
if (mItemInfo != DEFAULT_ITEM_INFO) {
throw new IllegalArgumentException(
checkState(mItemInfo == DEFAULT_ITEM_INFO,
"ItemInfo and ContainerInfo are mutual exclusive; cannot log both.");
}
this.mContainerInfo = Optional.of(containerInfo);
return this;
}
@ -203,6 +207,14 @@ public class StatsLogCompatManager extends StatsLogManager {
return this;
}
@Override
public StatsLogger withSliceItem(@NonNull SliceItem sliceItem) {
this.mSliceItem = checkNotNull(sliceItem, "expected valid sliceItem but received null");
checkState(mItemInfo == DEFAULT_ITEM_INFO,
"ItemInfo and SliceItem are mutual exclusive; cannot log both.");
return this;
}
@Override
public void log(EventEnum event) {
if (!Utilities.ATLEAST_R) {
@ -210,6 +222,20 @@ public class StatsLogCompatManager extends StatsLogManager {
}
LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
if (mSliceItem != null) {
Executors.MODEL_EXECUTOR.execute(
() -> {
LauncherAtom.ItemInfo.Builder itemInfoBuilder =
LauncherAtom.ItemInfo.newBuilder().setSlice(
LauncherAtom.Slice.newBuilder().setUri(
mSliceItem.getSlice().getUri().toString()));
mContainerInfo.ifPresent(itemInfoBuilder::setContainerInfo);
write(event, applyOverwrites(itemInfoBuilder.build()));
});
return;
}
if (mItemInfo.container < 0 || appState == null) {
// Write log on the model thread so that logs do not go out of order
// (for eg: drop comes after drag)
@ -346,6 +372,8 @@ public class StatsLogCompatManager extends StatsLogManager {
return info.getTask().getComponentName();
case SEARCH_ACTION_ITEM:
return info.getSearchActionItem().getTitle();
case SLICE:
return info.getSlice().getUri();
default:
return null;
}

View File

@ -23,6 +23,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.slice.SliceItem;
import com.android.launcher3.R;
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
@ -366,6 +367,31 @@ public class StatsLogManager implements ResourceBasedOverride {
@UiEvent(doc = "User switched to Work tab in AllApps screen.")
LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB(696),
@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 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),
;
// ADD MORE
@ -472,6 +498,13 @@ public class StatsLogManager implements ResourceBasedOverride {
return this;
}
/**
* Sets logging fields from provided {@link SliceItem}.
*/
default StatsLogger withSliceItem(SliceItem sliceItem) {
return this;
}
/**
* Builds the final message and logs it as {@link EventEnum}.
*/