From 01cffc296b1c40c3fbc7533c9ef885807a8dbc6c Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Thu, 7 Sep 2017 14:17:05 -0700 Subject: [PATCH] Make sure top activity is stopped on sleep if paused. Currently we have logic in place to handle moving a top resumed activity to paused and eventually stopped if entering sleep. However, we do not handle the case when the top activity is already paused. This changelist addresses this issue by identifying this condition and moving the activity to the stopped state. Change-Id: I8d6f9282ff863cf8017f6d64ab60911fb1c376c2 Fixes: 65457314 Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerDisplayTests#testExternalDisplayActivityTurnPrimaryOff --- services/core/java/com/android/server/am/ActivityStack.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index d62d9357e43f0..35ba591b3adf0 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -1214,6 +1214,11 @@ class ActivityStack extends ConfigurationContai // Still waiting for something to pause; can't sleep yet. if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Sleep still waiting to pause " + mPausingActivity); shouldSleep = false; + } else if (mLastPausedActivity == topActivity()) { + // Our top activity is currently paused, we need to ensure we move it to the stopped + // state. + stopActivityLocked(mLastPausedActivity); + shouldSleep = false; } if (!shuttingDown) {