[AA+] Log LAUNCHER_ONSTOP & LAUNCHER_ONRESUME events with AllApps session InstanceId.
* Transitions between AllApps and App screen logs LAUNCHER_ONSTOP & LAUNCHER_ONRESUME events. This change add InstanceId specific to the current AllApps session to these logs; this will help to regenerate AllApps session from logs on the server side. This should only affect logs from AllApps screen, but not others. * Removes LiveSearchManager.allAppsLogger method as it may create confusion with 2 methods for logging into Statsd * Moved AllApps entry and exit logs to Launcher. Bug: 178562918 Test: Manual Change-Id: I5fab941777a3dfd2e9b19c0efd5b06d3884222ef
This commit is contained in:
1 parent
c860448bca
commit
c96873caad
7 files changed
+58
-55
No files matched your search
@@ -81,7 +81,6 @@ import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
@@ -106,10 +105,9 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
protected void logAppLaunch(ItemInfo info, InstanceId instanceId) {
|
||||
// If the app launch is from any of the surfaces in AllApps then add the InstanceId from
|
||||
// LiveSearchManager to recreate the AllApps session on the server side.
|
||||
Optional<InstanceId> logInstanceId = this.getLiveSearchManager().getLogInstanceId();
|
||||
if (logInstanceId.isPresent() && ALL_APPS.equals(
|
||||
if (mAllAppsSessionLogId != null && ALL_APPS.equals(
|
||||
getStateManager().getCurrentStableState())) {
|
||||
instanceId = logInstanceId.get();
|
||||
instanceId = mAllAppsSessionLogId;
|
||||
}
|
||||
|
||||
StatsLogger logger = getStatsLogManager()
|
||||
|
||||
@@ -88,7 +88,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatsLogger logger() {
|
||||
protected StatsLogger createLogger() {
|
||||
return new StatsCompatLogger();
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,10 @@ public abstract class BaseActivity extends Activity implements ActivityContext {
|
||||
return mDeviceProfile;
|
||||
}
|
||||
|
||||
public final StatsLogManager getStatsLogManager() {
|
||||
/**
|
||||
* Returns {@link StatsLogManager} for user event logging.
|
||||
*/
|
||||
public StatsLogManager getStatsLogManager() {
|
||||
if (mStatsLogManager == null) {
|
||||
mStatsLogManager = StatsLogManager.newInstance(this);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ import static com.android.launcher3.Utilities.postAsyncCallback;
|
||||
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_EXIT;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONRESUME;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONSTOP;
|
||||
import static com.android.launcher3.model.ItemInstallQueue.FLAG_ACTIVITY_PAUSED;
|
||||
@@ -124,6 +126,8 @@ import com.android.launcher3.keyboard.CustomActionsPopup;
|
||||
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.InstanceIdSequence;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
import com.android.launcher3.model.ItemInstallQueue;
|
||||
@@ -352,6 +356,13 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
|
||||
private SafeCloseable mUserChangedCallbackCloseable;
|
||||
|
||||
// New InstanceId is assigned to mAllAppsSessionLogId for each AllApps sessions.
|
||||
// When Launcher is not in AllApps state mAllAppsSessionLogId will be null.
|
||||
// User actions within AllApps state are logged with this InstanceId, to recreate AllApps
|
||||
// session on the server side.
|
||||
protected InstanceId mAllAppsSessionLogId;
|
||||
private LauncherState mPrevLauncherState;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Object traceToken = TraceHelper.INSTANCE.beginSection(ON_CREATE_EVT,
|
||||
@@ -1027,6 +1038,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
}
|
||||
// When multiple pages are visible, show persistent page indicator
|
||||
mWorkspace.getPageIndicator().setShouldAutoHide(!state.hasFlag(FLAG_MULTI_PAGE));
|
||||
mPrevLauncherState = mStateManager.getCurrentStableState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1050,6 +1062,17 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
// Clear any rotation locks when going to normal state
|
||||
getRotationHelper().setCurrentStateRequest(REQUEST_NONE);
|
||||
}
|
||||
|
||||
if (ALL_APPS.equals(state)) {
|
||||
// creates new instance ID since new all apps session is started.
|
||||
mAllAppsSessionLogId = new InstanceIdSequence().newInstanceId();
|
||||
getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_ENTRY);
|
||||
} else if (ALL_APPS.equals(mPrevLauncherState)
|
||||
// Check if mLogInstanceId is not null to make sure exit event is logged only once.
|
||||
&& mAllAppsSessionLogId != null) {
|
||||
getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_EXIT);
|
||||
mAllAppsSessionLogId = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2818,4 +2841,9 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
public Configuration config;
|
||||
public Bitmap snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatsLogManager getStatsLogManager() {
|
||||
return super.getStatsLogManager().withDefaultInstanceId(mAllAppsSessionLogId);
|
||||
}
|
||||
}
|
||||
@@ -90,10 +90,9 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView {
|
||||
public void onTabChanged(int pos) {
|
||||
super.onTabChanged(pos);
|
||||
if (mUsingTabs) {
|
||||
|
||||
// Log tab switches only when the launcher is in AllApps state
|
||||
if (mLauncher.getStateManager().getCurrentStableState() == LauncherState.ALL_APPS) {
|
||||
mLauncher.getLiveSearchManager().allAppsLogger()
|
||||
mLauncher.getStatsLogManager().logger()
|
||||
.log(pos == AdapterHolder.WORK ? LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB
|
||||
: LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB);
|
||||
}
|
||||
@@ -109,6 +108,6 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView {
|
||||
@Override
|
||||
protected void hideIme() {
|
||||
super.hideIme();
|
||||
mLauncher.getLiveSearchManager().allAppsLogger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED);
|
||||
mLauncher.getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED);
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,6 @@
|
||||
package com.android.launcher3.allapps.search;
|
||||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_EXIT;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
@@ -47,9 +45,6 @@ import androidx.slice.SliceViewManager.SliceCallback;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.InstanceIdSequence;
|
||||
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
|
||||
import com.android.launcher3.statemanager.StateManager.StateListener;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
@@ -57,7 +52,6 @@ import com.android.launcher3.widget.PendingAddWidgetInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Manages Lifecycle for Live search results
|
||||
@@ -74,8 +68,6 @@ public class LiveSearchManager implements StateListener<LauncherState> {
|
||||
private final HashMap<ComponentKey, SearchWidgetInfoContainer> mWidgetPlaceholders =
|
||||
new HashMap<>();
|
||||
private SearchWidgetHost mSearchWidgetHost;
|
||||
private InstanceId mLogInstanceId;
|
||||
private LauncherState mPrevLauncherState;
|
||||
|
||||
public LiveSearchManager(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
@@ -138,11 +130,6 @@ public class LiveSearchManager implements StateListener<LauncherState> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateTransitionStart(LauncherState toState) {
|
||||
mPrevLauncherState = mLauncher.getStateManager().getCurrentStableState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
if (finalState != ALL_APPS) {
|
||||
@@ -152,18 +139,6 @@ public class LiveSearchManager implements StateListener<LauncherState> {
|
||||
|
||||
clearWidgetHost();
|
||||
}
|
||||
|
||||
if (ALL_APPS.equals(finalState)) {
|
||||
// creates new instance ID since new all apps session is started.
|
||||
mLogInstanceId = new InstanceIdSequence().newInstanceId();
|
||||
allAppsLogger().log(LAUNCHER_ALLAPPS_ENTRY);
|
||||
} else if (ALL_APPS.equals(mPrevLauncherState)
|
||||
// Check if mLogInstanceId is not null; to avoid NPE when LAUNCHER_ALLAPPS_EXIT is
|
||||
// triggered multiple times
|
||||
&& mLogInstanceId != null) {
|
||||
allAppsLogger().log(LAUNCHER_ALLAPPS_EXIT);
|
||||
mLogInstanceId = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,14 +156,6 @@ public class LiveSearchManager implements StateListener<LauncherState> {
|
||||
return () -> sliceLifeCycle.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link InstanceId} that should be used for logging events within search session, if
|
||||
* available.
|
||||
*/
|
||||
public Optional<InstanceId> getLogInstanceId() {
|
||||
return Optional.ofNullable(mLogInstanceId);
|
||||
}
|
||||
|
||||
static class SearchWidgetHost extends AppWidgetHost {
|
||||
SearchWidgetHost(Context context) {
|
||||
super(context, SEARCH_APPWIDGET_HOST_ID);
|
||||
@@ -316,15 +283,4 @@ public class LiveSearchManager implements StateListener<LauncherState> {
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new instance of {@link StatsLogger} pre-populated with details required to log
|
||||
* AllApps specific user events.
|
||||
*/
|
||||
public StatsLogger allAppsLogger() {
|
||||
return getLogInstanceId()
|
||||
.map(instanceId -> mLauncher.getStatsLogManager().logger()
|
||||
.withInstanceId(instanceId))
|
||||
.orElse(mLauncher.getStatsLogManager().logger());
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
||||
import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||
@@ -29,6 +31,8 @@ import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Handles the user event logging in R+.
|
||||
*
|
||||
@@ -47,6 +51,7 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
public static final int LAUNCHER_STATE_ALLAPPS = 4;
|
||||
public static final int LAUNCHER_STATE_UNCHANGED = 5;
|
||||
|
||||
private InstanceId mInstanceId;
|
||||
/**
|
||||
* Returns event enum based on the two state transition information when swipe
|
||||
* gesture happens(to be removed during UserEventDispatcher cleanup).
|
||||
@@ -480,16 +485,30 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
* Returns new logger object.
|
||||
*/
|
||||
public StatsLogger logger() {
|
||||
StatsLogger logger = createLogger();
|
||||
Optional.ofNullable(mInstanceId).ifPresent(logger::withInstanceId);
|
||||
return logger;
|
||||
}
|
||||
|
||||
protected StatsLogger createLogger() {
|
||||
return new StatsLogger() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link StatsLogManager} based on provided context.
|
||||
*/
|
||||
public static StatsLogManager newInstance(Context context) {
|
||||
StatsLogManager mgr = Overrides.getObject(StatsLogManager.class,
|
||||
return Overrides.getObject(StatsLogManager.class,
|
||||
context.getApplicationContext(), R.string.stats_log_manager_class);
|
||||
return mgr;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user