diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 5dd8f74e05708..4c392f0906aa6 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -5154,6 +5154,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Task#ensureActivitiesVisible will bring the activity to a proper // active state. if (!isState(STARTED, RESUMED, PAUSED, STOPPED, STOPPING) + // TODO (b/185876784) Check could we remove the check condition + // mTranslucentActivityWaiting != null here || getRootTask().mTranslucentActivityWaiting != null) { return false; } @@ -7802,7 +7804,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A configChangeFlags = 0; return; } - + // Do not waiting for translucent activity if it is going to relaunch. + final Task rootTask = getRootTask(); + if (rootTask != null && rootTask.mTranslucentActivityWaiting == this) { + rootTask.checkTranslucentActivityWaiting(null); + } final boolean andResume = shouldBeResumed(null /*activeActivity*/); List pendingResults = null; List pendingNewIntents = null; diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 8cede6df491df..bd143f8a5c35a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -386,6 +386,27 @@ public class ActivityRecordTests extends WindowTestsBase { activity.mRelaunchReason); } + @Test + public void testRelaunchClearTopWaitingTranslucent() { + final ActivityRecord activity = createActivityWithTask(); + final Task task = activity.getTask(); + activity.setState(Task.ActivityState.RESUMED, "Testing"); + + task.onRequestedOverrideConfigurationChanged(task.getConfiguration()); + activity.setLastReportedConfiguration(new MergedConfiguration(new Configuration(), + activity.getConfiguration())); + + activity.info.configChanges &= ~CONFIG_ORIENTATION; + final Configuration newConfig = new Configuration(task.getConfiguration()); + newConfig.orientation = newConfig.orientation == ORIENTATION_PORTRAIT + ? ORIENTATION_LANDSCAPE + : ORIENTATION_PORTRAIT; + task.onRequestedOverrideConfigurationChanged(newConfig); + task.mTranslucentActivityWaiting = activity; + ensureActivityConfiguration(activity); + assertNull(task.mTranslucentActivityWaiting); + } + @Test public void testSetsRelaunchReason_NonResizeConfigChanges() { final ActivityRecord activity = createActivityWithTask();