From 91cc2b25977947594f2f4bcdfd4c2ec6bcccb9c7 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 24 Jun 2021 00:50:51 +0800 Subject: [PATCH] Separate trace of trampoline launch with different packages The trace of app launch is "launching: $packageName". Previously, if a caller uses its trampoline activity to launch another app, the trace name will still show the package of caller. So now if the packages are different, start a new trace for it. Also update last transition info so it won't miss the fully-drawn from the last launched activity. Bug: 191765029 Test: Use Searchbox to launch other apps. The trace should show two slices including launcher as trampoline and the target app. Change-Id: I3f2f19323089385d262a258f70b510f18e9943c3 --- .../server/wm/ActivityMetricsLogger.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java index f6217bc2ffd24..c088358e52ecf 100644 --- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java @@ -609,13 +609,27 @@ class ActivityMetricsLogger { return; } + // If the launched activity is started from an existing active transition, it will be put + // into the transition info. if (info != null && info.canCoalesce(launchedActivity)) { - // If we are already in an existing transition on the same display, only update the - // activity name, but not the other attributes. + if (DEBUG_METRICS) Slog.i(TAG, "notifyActivityLaunched consecutive launch"); - if (DEBUG_METRICS) Slog.i(TAG, "notifyActivityLaunched update launched activity"); + final boolean crossPackage = + !info.mLastLaunchedActivity.packageName.equals(launchedActivity.packageName); + // The trace name uses package name so different packages should be separated. + if (crossPackage) { + stopLaunchTrace(info); + } + + mLastTransitionInfo.remove(info.mLastLaunchedActivity); // Coalesce multiple (trampoline) activities from a single sequence together. info.setLatestLaunchedActivity(launchedActivity); + // Update the latest one so it can be found when reporting fully-drawn. + mLastTransitionInfo.put(launchedActivity, info); + + if (crossPackage) { + startLaunchTrace(info); + } return; }