From 9b7a8272d83cbcaa7dbb0dff80b013bc47f927db Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Mon, 10 Apr 2017 08:05:41 -0700 Subject: [PATCH] Don't ensure config for activity that is about to be invisible We were relaunching an activity in the docked stack that is been dismissed because we call ensure configuration on it due to the resize of it been moved to the fullscreen stack. This isn't needed as the activity is about to become invisible since it is been moved to a stack that isn't visible. We now ensuring the configuration if: - The stack the activity is in shouldn't be visible. - The activity is currently stopped or stopping. Change-Id: I6adac6b11a0db4b100e623e4074e169660206567 Fixes: 37118176 Test: Activity in docked stack isn't relaunched when dismissed. --- .../com/android/server/am/ActivityRecord.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 2b953adfde180..85a74b2197f30 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -97,6 +97,7 @@ import static com.android.server.am.ActivityStack.ActivityState.STOPPING; import static com.android.server.am.ActivityStack.LAUNCH_TICK; import static com.android.server.am.ActivityStack.LAUNCH_TICK_MSG; import static com.android.server.am.ActivityStack.PAUSE_TIMEOUT_MSG; +import static com.android.server.am.ActivityStack.STACK_INVISIBLE; import static com.android.server.am.ActivityStack.STOP_TIMEOUT_MSG; import static com.android.server.am.EventLogTags.AM_ACTIVITY_FULLY_DRAWN_TIME; import static com.android.server.am.EventLogTags.AM_ACTIVITY_LAUNCH_TIME; @@ -2269,6 +2270,20 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo return true; } + // Skip updating configuration for activity that are stopping or stopped. + if (state == STOPPING || state == STOPPED) { + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, + "Skipping config check stopped or stopping: " + this); + return true; + } + + // Skip updating configuration for activity is a stack that shouldn't be visible. + if (stack.shouldBeVisible(null /* starting */) == STACK_INVISIBLE) { + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, + "Skipping config check invisible stack: " + this); + return true; + } + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Ensuring correct configuration: " + this);