Logs system navigation details part of launcher snapshot logging.

Bug: 157997545
Change-Id: I18e908dc62bb790c3a77e1aacd0236a7d84e8ce5
Merged-In: I18e908dc62bb790c3a77e1aacd0236a7d84e8ce5
This commit is contained in:
thiruram 2020-07-23 16:13:54 -07:00
parent c3e4d2c7ab
commit b6d0607d8b
3 changed files with 73 additions and 20 deletions

View File

@ -16,6 +16,9 @@
package com.android.quickstep;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_2_BUTTON;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_3_BUTTON;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON;
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
import android.content.BroadcastReceiver;
@ -24,6 +27,7 @@ import android.content.Intent;
import android.content.res.Resources;
import android.util.Log;
import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.MainThreadInitializedObject;
@ -37,16 +41,18 @@ import java.util.List;
public class SysUINavigationMode {
public enum Mode {
THREE_BUTTONS(false, 0),
TWO_BUTTONS(true, 1),
NO_BUTTON(true, 2);
THREE_BUTTONS(false, 0, LAUNCHER_NAVIGATION_MODE_3_BUTTON),
TWO_BUTTONS(true, 1, LAUNCHER_NAVIGATION_MODE_2_BUTTON),
NO_BUTTON(true, 2, LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON);
public final boolean hasGestures;
public final int resValue;
public final LauncherEvent launcherEvent;
Mode(boolean hasGestures, int resValue) {
Mode(boolean hasGestures, int resValue, LauncherEvent launcherEvent) {
this.hasGestures = hasGestures;
this.resValue = resValue;
this.launcherEvent = launcherEvent;
}
}
@ -147,7 +153,6 @@ public class SysUINavigationMode {
}
public interface NavigationModeChangeListener {
void onNavigationModeChanged(Mode newMode);
}
}

View File

@ -59,6 +59,7 @@ import com.android.launcher3.util.LogConfig;
import com.android.systemui.shared.system.SysUiStatsLog;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
@ -110,21 +111,22 @@ public class StatsLogCompatManager extends StatsLogManager {
}
/**
* Logs the workspace layout information on the model thread.
* Logs impression of the current workspace with additional launcher events.
*/
@Override
public void logSnapshot() {
public void logSnapshot(List<EventEnum> extraEvents) {
LauncherAppState.getInstance(mContext).getModel().enqueueModelUpdateTask(
new SnapshotWorker());
new SnapshotWorker(extraEvents));
}
private class SnapshotWorker extends BaseModelUpdateTask {
private final InstanceId mInstanceId;
private final List<EventEnum> mExtraEvents;
SnapshotWorker() {
mInstanceId = new InstanceIdSequence(
1 << 20 /*InstanceId.INSTANCE_ID_MAX*/).newInstanceId();
SnapshotWorker(List<EventEnum> extraEvents) {
mInstanceId = new InstanceIdSequence(1 << 20 /*InstanceId.INSTANCE_ID_MAX*/)
.newInstanceId();
this.mExtraEvents = extraEvents;
}
@Override
@ -165,6 +167,9 @@ public class StatsLogCompatManager extends StatsLogManager {
LauncherAtom.ItemInfo atomInfo = info.buildProto(null);
writeSnapshot(atomInfo, mInstanceId);
}
mExtraEvents
.forEach(eventName -> logger().withInstanceId(mInstanceId).log(eventName));
getDevicePrefs(mContext).edit()
.putLong(LAST_SNAPSHOT_TIME_MILLIS, currentTimeMillis()).apply();
}

View File

@ -33,11 +33,16 @@ import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.userevent.LauncherLogProto;
import com.android.launcher3.util.ResourceBasedOverride;
import java.util.List;
/**
* Handles the user event logging in R+.
*
* <pre>
* All of the event ids are defined here.
* Most of the methods are dummy methods for Launcher3
* Actual call happens only for Launcher variant that implements QuickStep.
* </pre>
*/
public class StatsLogManager implements ResourceBasedOverride {
@ -49,8 +54,8 @@ public class StatsLogManager implements ResourceBasedOverride {
public static final int LAUNCHER_STATE_UNCHANGED = 5;
/**
* Returns proper launcher state enum for {@link StatsLogManager}
* (to be removed during UserEventDispatcher cleanup)
* Returns proper launcher state enum for {@link StatsLogManager}(to be removed during
* UserEventDispatcher cleanup)
*/
public static int containerTypeToAtomState(int containerType) {
switch (containerType) {
@ -67,9 +72,8 @@ public class StatsLogManager implements ResourceBasedOverride {
}
/**
* Returns event enum based on the two {@link ContainerType} transition information when
* swipe gesture happens.
* (to be removed during UserEventDispatcher cleanup)
* Returns event enum based on the two {@link ContainerType} transition information when swipe
* gesture happens(to be removed during UserEventDispatcher cleanup).
*/
public static EventEnum getLauncherAtomEvent(int startContainerType,
int targetContainerType, EventEnum fallbackEvent) {
@ -273,7 +277,46 @@ public class StatsLogManager implements ResourceBasedOverride {
LAUNCHER_SELECT_MODE_CLOSE(583),
@UiEvent(doc = "User tapped on the highlight items in select mode")
LAUNCHER_SELECT_MODE_ITEM(584);
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);
// ADD MORE
@ -417,8 +460,8 @@ public class StatsLogManager implements ResourceBasedOverride {
}
/**
* Logs snapshot, or impression of the current workspace.
* Logs impression of the current workspace with additional launcher events.
*/
public void logSnapshot() {
public void logSnapshot(List<EventEnum> additionalEvents) {
}
}