If COLD startup occurs while launcher is backgrounded, do not wait until user goes to home to end startup session.

Fix: 305243183
Test: lock screen, force stop launcher, verify COLD startup is logged before user unlocks screen
Flag: N/A
Change-Id: I2d93dc3346e1aec82555162c9bb868cc4ddb621b
This commit is contained in:
Fengjiang Li
2023-10-14 07:10:10 -07:00
parent a96537fa65
commit 6dff0925c0
+14 -16
View File
@@ -2631,26 +2631,24 @@ public class Launcher extends StatefulActivity<LauncherState>
Trace.endAsyncSection(DISPLAY_WORKSPACE_TRACE_METHOD_NAME,
DISPLAY_WORKSPACE_TRACE_COOKIE);
}
mStartupLatencyLogger
.logCardinality(workspaceItemCount)
.logEnd(isBindSync
? LAUNCHER_LATENCY_STARTUP_WORKSPACE_LOADER_SYNC
: LAUNCHER_LATENCY_STARTUP_WORKSPACE_LOADER_ASYNC);
// In the first rootview's onDraw after onInitialBindComplete(), log end of startup latency.
MAIN_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
mStartupLatencyLogger
.logCardinality(workspaceItemCount)
.logEnd(isBindSync
? LAUNCHER_LATENCY_STARTUP_WORKSPACE_LOADER_SYNC
: LAUNCHER_LATENCY_STARTUP_WORKSPACE_LOADER_ASYNC)
.logEnd(LAUNCHER_LATENCY_STARTUP_TOTAL_DURATION)
.log()
.reset();
if (mIsColdStartupAfterReboot) {
Trace.endAsyncSection(COLD_STARTUP_TRACE_METHOD_NAME,
COLD_STARTUP_TRACE_COOKIE);
}
});
getRootView().getViewTreeObserver().addOnDrawListener(
new ViewTreeObserver.OnDrawListener() {
@Override
public void onDraw() {
mStartupLatencyLogger
.logEnd(LAUNCHER_LATENCY_STARTUP_TOTAL_DURATION)
.log()
.reset();
if (mIsColdStartupAfterReboot) {
Trace.endAsyncSection(COLD_STARTUP_TRACE_METHOD_NAME,
COLD_STARTUP_TRACE_COOKIE);
}
MAIN_EXECUTOR.getHandler().postAtFrontOfQueue(
() -> getRootView().getViewTreeObserver()
.removeOnDrawListener(this));