Log launcher settings whenever launcher layout is logged using pull atom.
* Whenever launcher setting is changed, only log the changed setting instead of all Bug: 181703659 Test: wwdebug && wwlogcat AND statsd_testdrive 10108 Change-Id: I9c6b7a17d653038a91f885df455e5ebbb401b49a Merged-In: I9c6b7a17d653038a91f885df455e5ebbb401b49a (cherry picked from commit f7ebfb9a7fc2151621567008acfe103c76a6ef0d)
This commit is contained in:
parent
d0b4d10f0e
commit
7d04782532
|
@ -64,6 +64,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo;
|
|||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.util.IntSparseArrayMap;
|
||||
import com.android.launcher3.util.PersistedItemArray;
|
||||
import com.android.quickstep.logging.SettingsChangeLogger;
|
||||
import com.android.quickstep.logging.StatsLogCompatManager;
|
||||
import com.android.systemui.shared.system.SysUiStatsLog;
|
||||
|
||||
|
@ -97,10 +98,12 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
|||
private final InvariantDeviceProfile mIDP;
|
||||
private final AppEventProducer mAppEventProducer;
|
||||
private final StatsManager mStatsManager;
|
||||
private final Context mContext;
|
||||
|
||||
protected boolean mActive = false;
|
||||
|
||||
public QuickstepModelDelegate(Context context) {
|
||||
mContext = context;
|
||||
mAppEventProducer = new AppEventProducer(context, this::onAppTargetEvent);
|
||||
|
||||
mIDP = InvariantDeviceProfile.INSTANCE.get(context);
|
||||
|
@ -210,6 +213,7 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
|||
"Successfully logged %d workspace items with instanceId=%d",
|
||||
itemsIdMap.size(), instanceId.getId()));
|
||||
additionalSnapshotEvents(instanceId);
|
||||
SettingsChangeLogger.INSTANCE.get(mContext).logSnapshot(instanceId);
|
||||
return StatsManager.PULL_SUCCESS;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -24,8 +24,6 @@ import android.util.Log;
|
|||
|
||||
import com.android.launcher3.BuildConfig;
|
||||
import com.android.launcher3.MainProcessInitializer;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.quickstep.logging.SettingsChangeLogger;
|
||||
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
|
||||
import com.android.systemui.shared.system.ThreadedRendererCompat;
|
||||
|
||||
|
@ -62,9 +60,5 @@ public class QuickstepProcessInitializer extends MainProcessInitializer {
|
|||
// Elevate GPU priority for Quickstep and Remote animations.
|
||||
ThreadedRendererCompat.setContextPriority(
|
||||
ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG);
|
||||
|
||||
// Initialize settings logger after a default timeout
|
||||
Executors.MAIN_EXECUTOR.getHandler()
|
||||
.postDelayed(() -> new SettingsChangeLogger(context), SETUP_DELAY_MILLIS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,10 +40,11 @@ import android.util.Xml;
|
|||
import com.android.launcher3.AutoInstallsLayout;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.logging.InstanceIdSequence;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
|
||||
import com.android.launcher3.model.DeviceGridState;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.SysUINavigationMode.Mode;
|
||||
|
@ -53,12 +54,19 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Utility class to log launcher settings changes
|
||||
*/
|
||||
public class SettingsChangeLogger implements
|
||||
NavigationModeChangeListener, OnSharedPreferenceChangeListener {
|
||||
|
||||
/**
|
||||
* Singleton instance
|
||||
*/
|
||||
public static MainThreadInitializedObject<SettingsChangeLogger> INSTANCE =
|
||||
new MainThreadInitializedObject<>(SettingsChangeLogger::new);
|
||||
|
||||
private static final String TAG = "SettingsChangeLogger";
|
||||
private static final String ROOT_TAG = "androidx.preference.PreferenceScreen";
|
||||
|
@ -66,12 +74,15 @@ public class SettingsChangeLogger implements
|
|||
|
||||
private final Context mContext;
|
||||
private final ArrayMap<String, LoggablePref> mLoggablePrefs;
|
||||
private final StatsLogManager mStatsLogManager;
|
||||
|
||||
private Mode mNavMode;
|
||||
private boolean mNotificationDotsEnabled;
|
||||
private StatsLogManager.LauncherEvent mNotificationDotsEvent;
|
||||
private StatsLogManager.LauncherEvent mHomeScreenSuggestionEvent;
|
||||
|
||||
public SettingsChangeLogger(Context context) {
|
||||
private SettingsChangeLogger(Context context) {
|
||||
mContext = context;
|
||||
mStatsLogManager = StatsLogManager.newInstance(mContext);
|
||||
mLoggablePrefs = loadPrefKeys(context);
|
||||
mNavMode = SysUINavigationMode.INSTANCE.get(context).addModeChangeListener(this);
|
||||
|
||||
|
@ -118,14 +129,21 @@ public class SettingsChangeLogger implements
|
|||
}
|
||||
|
||||
private void onNotificationDotsChanged(boolean isDotsEnabled) {
|
||||
mNotificationDotsEnabled = isDotsEnabled;
|
||||
dispatchUserEvent();
|
||||
StatsLogManager.LauncherEvent mEvent =
|
||||
isDotsEnabled ? LAUNCHER_NOTIFICATION_DOT_ENABLED
|
||||
: LAUNCHER_NOTIFICATION_DOT_DISABLED;
|
||||
|
||||
// Log only when the setting is actually changed and not during initialization.
|
||||
if (mNotificationDotsEvent != null && mNotificationDotsEvent != mEvent) {
|
||||
mStatsLogManager.logger().log(mNotificationDotsEvent);
|
||||
}
|
||||
mNotificationDotsEvent = mEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationModeChanged(Mode newMode) {
|
||||
mNavMode = newMode;
|
||||
dispatchUserEvent();
|
||||
mStatsLogManager.logger().log(newMode.launcherEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,27 +152,27 @@ public class SettingsChangeLogger implements
|
|||
|| KEY_WORKSPACE_SIZE.equals(key)
|
||||
|| KEY_THEMED_ICONS.equals(key)
|
||||
|| mLoggablePrefs.containsKey(key)) {
|
||||
dispatchUserEvent();
|
||||
|
||||
mHomeScreenSuggestionEvent = getDevicePrefs(mContext)
|
||||
.getBoolean(LAST_PREDICTION_ENABLED_STATE, true)
|
||||
? LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED
|
||||
: LAUNCHER_HOME_SCREEN_SUGGESTIONS_DISABLED;
|
||||
|
||||
mStatsLogManager.logger().log(mHomeScreenSuggestionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchUserEvent() {
|
||||
StatsLogger logger = StatsLogManager.newInstance(mContext).logger()
|
||||
.withInstanceId(new InstanceIdSequence().newInstanceId());
|
||||
/**
|
||||
* Takes snapshot of all eligible launcher settings and log them with the provided instance ID.
|
||||
*/
|
||||
public void logSnapshot(InstanceId snapshotInstanceId) {
|
||||
StatsLogger logger = mStatsLogManager.logger().withInstanceId(snapshotInstanceId);
|
||||
|
||||
logger.log(mNotificationDotsEnabled
|
||||
? LAUNCHER_NOTIFICATION_DOT_ENABLED
|
||||
: LAUNCHER_NOTIFICATION_DOT_DISABLED);
|
||||
logger.log(mNavMode.launcherEvent);
|
||||
logger.log(getDevicePrefs(mContext).getBoolean(LAST_PREDICTION_ENABLED_STATE, true)
|
||||
? LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED
|
||||
: LAUNCHER_HOME_SCREEN_SUGGESTIONS_DISABLED);
|
||||
|
||||
StatsLogManager.LauncherEvent gridSizeChangedEvent =
|
||||
new DeviceGridState(mContext).getWorkspaceSizeEvent();
|
||||
if (gridSizeChangedEvent != null) {
|
||||
logger.log(gridSizeChangedEvent);
|
||||
}
|
||||
Optional.ofNullable(mNotificationDotsEvent).ifPresent(logger::log);
|
||||
Optional.ofNullable(mNavMode).map(mode -> mode.launcherEvent).ifPresent(logger::log);
|
||||
Optional.ofNullable(mHomeScreenSuggestionEvent).ifPresent(logger::log);
|
||||
Optional.ofNullable(new DeviceGridState(mContext).getWorkspaceSizeEvent()).ifPresent(
|
||||
logger::log);
|
||||
|
||||
SharedPreferences prefs = getPrefs(mContext);
|
||||
if (FeatureFlags.ENABLE_THEMED_ICONS.get()) {
|
||||
|
|
Loading…
Reference in New Issue