diff options
| author | 2019-10-31 01:36:49 +0000 | |
|---|---|---|
| committer | 2019-10-31 01:36:49 +0000 | |
| commit | 92d5b68e29e404ba29ecd31e41566eaaef71381a (patch) | |
| tree | 2de830a9c0659525f152aafcbd843278c35dedd6 | |
| parent | 0dcae0eb6f02dfb6d1fabed372f7c48a4b1d8c90 (diff) | |
| parent | 4c9824a5ae801bacbd5633900da624c4e2482637 (diff) | |
Merge "Return resume result in resumeFocusedStacksTopActivities"
| -rw-r--r-- | services/core/java/com/android/server/wm/RootActivityContainer.java | 2 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java | 39 |
2 files changed, 38 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/RootActivityContainer.java b/services/core/java/com/android/server/wm/RootActivityContainer.java index 9db6dc263944..51a3e7205489 100644 --- a/services/core/java/com/android/server/wm/RootActivityContainer.java +++ b/services/core/java/com/android/server/wm/RootActivityContainer.java @@ -1154,7 +1154,7 @@ class RootActivityContainer extends ConfigurationContainer // activity is started and resumed, and no recursion occurs. final ActivityStack focusedStack = display.getFocusedStack(); if (focusedStack != null) { - focusedStack.resumeTopActivityUncheckedLocked(target, targetOptions); + result |= focusedStack.resumeTopActivityUncheckedLocked(target, targetOptions); } } } 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 99ecdcb002a1..38d6c9c1e4db 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -836,6 +836,14 @@ public class ActivityRecordTests extends ActivityTestsBase { // Set process to 'null' to allow immediate removal, but don't call mActivity.setProcess() - // this will cause NPE when updating task's process. mActivity.app = null; + + // Put a visible activity on top, so the finishing activity doesn't have to wait until the + // next activity reports idle to destroy it. + final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); + topActivity.visible = true; + topActivity.nowVisible = true; + topActivity.setState(RESUMED, "test"); + assertEquals("Activity outside of task/stack cannot be finished", FINISH_RESULT_REMOVED, mActivity.finishIfPossible("test", false /* oomAdj */)); assertTrue(mActivity.finishing); @@ -1131,8 +1139,11 @@ public class ActivityRecordTests extends ActivityTestsBase { // Add another stack to become focused and make the activity there visible. This way it // simulates finishing in non-focused stack in split-screen. final ActivityStack stack = new StackBuilder(mRootActivityContainer).build(); - stack.getChildAt(0).getChildAt(0).nowVisible = true; - stack.getChildAt(0).getChildAt(0).visible = true; + final ActivityRecord focusedActivity = stack.getChildAt(0).getChildAt(0); + focusedActivity.nowVisible = true; + focusedActivity.visible = true; + focusedActivity.setState(RESUMED, "test"); + stack.mResumedActivity = focusedActivity; topActivity.completeFinishing("test"); @@ -1180,6 +1191,30 @@ public class ActivityRecordTests extends ActivityTestsBase { } /** + * Verify that complete finish request for visible activity must resume next home stack before + * destroying it immediately if it is the last running activity on a display with a home stack. + * We must wait for home activity to come up to avoid a black flash in this case. + */ + @Test + public void testCompleteFinishing_lastActivityAboveEmptyHomeStack() { + // Empty the home stack. + final ActivityStack homeStack = mActivity.getDisplay().getHomeStack(); + for (TaskRecord t : homeStack.getAllTasks()) { + homeStack.removeTask(t, "test", REMOVE_TASK_MODE_DESTROYING); + } + mActivity.finishing = true; + spyOn(mStack); + + // Try to finish the last activity above the home stack. + mActivity.completeFinishing("test"); + + // Verify that the activity is not destroyed immediately, but waits for next one to come up. + verify(mActivity, never()).destroyImmediately(eq(true) /* removeFromApp */, anyString()); + assertEquals(FINISHING, mActivity.getState()); + assertTrue(mActivity.mStackSupervisor.mFinishingActivities.contains(mActivity)); + } + + /** * Test that the activity will be moved to destroying state and the message to destroy will be * sent to the client. */ |