From b1de42de9fefc0ca81ce89da4468ec0e77dcc3ec Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Mon, 28 Jan 2019 09:49:51 -0800 Subject: [PATCH] AML: Handle NoDisplayActivities correctly There is a race when trying to determine if the launching activity is a trampoline activity or if its a NoDisplay activity that will never draw on screen. If the activity becomes invisible, its visible state in ActivityRecord may not change to invisible before the activity finishes. This is a quick fix to also check if ActivityRecord is finishing to determine if the activity is no longer visible. Bug: 80380150 Test: atest CtsActivityManagerDeviceTestCases:ActivityMetricsLoggerTests Change-Id: I55251f03db7390d6a3465eff851c4635680a2e07 (cherry picked from commit 6397dd1c922697b4cf09dd23124f67d0578328b4) --- .../java/com/android/server/wm/ActivityMetricsLogger.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java index 102318262798..c0924511384a 100644 --- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java @@ -544,6 +544,16 @@ class ActivityMetricsLogger { mHandler.obtainMessage(MSG_CHECK_VISIBILITY, args).sendToTarget(); } + private boolean hasVisibleNonFinishingActivity(TaskRecord t) { + for (int i = t.mActivities.size() - 1; i >= 0; --i) { + final ActivityRecord r = t.mActivities.get(i); + if (r.visible && !r.finishing) { + return true; + } + } + return false; + } + private void checkVisibility(TaskRecord t, ActivityRecord r) { synchronized (mSupervisor.mService.mGlobalLock) { @@ -552,7 +562,7 @@ class ActivityMetricsLogger { // If we have an active transition that's waiting on a certain activity that will be // invisible now, we'll never get onWindowsDrawn, so abort the transition if necessary. - if (info != null && !t.isVisible()) { + if (info != null && !hasVisibleNonFinishingActivity(t)) { if (DEBUG_METRICS) Slog.i(TAG, "notifyVisibilityChanged to invisible" + " activity=" + r); logAppTransitionCancel(info); -- 2.11.0