Loading services/core/java/com/android/server/wm/ActivityDisplay.java +7 −4 Original line number Diff line number Diff line Loading @@ -1323,14 +1323,17 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> } } /** Returns true if the focus activity was adjusted to the home stack top activity. */ boolean moveHomeActivityToTop(String reason) { /** * Moves the focusable home activity to top. If there is no such activity, the home stack will * still move to top. */ void moveHomeActivityToTop(String reason) { final ActivityRecord top = getHomeActivity(); if (top == null) { return false; moveHomeStackToFront(reason); return; } top.moveFocusableActivityToTop(reason); return true; } @Nullable Loading services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java +17 −0 Original line number Diff line number Diff line Loading @@ -929,6 +929,23 @@ public class ActivityStackTests extends ActivityTestsBase { assertThat(mStack.getAllTasks()).isEmpty(); } @Test public void testAdjustFocusedStackToHomeWhenNoActivity() { final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); mStack.moveToFront("testAdjustFocusedStack"); final ActivityStack homeStask = mDefaultDisplay.getHomeStack(); final TaskRecord homeTask = homeStask.topTask(); // Simulate that home activity has not been started or is force-stopped. homeStask.removeTask(homeTask, "testAdjustFocusedStack", REMOVE_TASK_MODE_DESTROYING); // Finish the only activity. mStack.finishActivityLocked(topActivity, 0 /* resultCode */, null /* resultData */, "testAdjustFocusedStack", false /* oomAdj */); // Although home stack is empty, it should still be the focused stack. assertEquals(homeStask, mDefaultDisplay.getFocusedStack()); } @Test public void testWontFinishHomeStackImmediately() { final ActivityStack homeStack = createStackForShouldBeVisibleTest(mDefaultDisplay, Loading Loading
services/core/java/com/android/server/wm/ActivityDisplay.java +7 −4 Original line number Diff line number Diff line Loading @@ -1323,14 +1323,17 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> } } /** Returns true if the focus activity was adjusted to the home stack top activity. */ boolean moveHomeActivityToTop(String reason) { /** * Moves the focusable home activity to top. If there is no such activity, the home stack will * still move to top. */ void moveHomeActivityToTop(String reason) { final ActivityRecord top = getHomeActivity(); if (top == null) { return false; moveHomeStackToFront(reason); return; } top.moveFocusableActivityToTop(reason); return true; } @Nullable Loading
services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java +17 −0 Original line number Diff line number Diff line Loading @@ -929,6 +929,23 @@ public class ActivityStackTests extends ActivityTestsBase { assertThat(mStack.getAllTasks()).isEmpty(); } @Test public void testAdjustFocusedStackToHomeWhenNoActivity() { final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); mStack.moveToFront("testAdjustFocusedStack"); final ActivityStack homeStask = mDefaultDisplay.getHomeStack(); final TaskRecord homeTask = homeStask.topTask(); // Simulate that home activity has not been started or is force-stopped. homeStask.removeTask(homeTask, "testAdjustFocusedStack", REMOVE_TASK_MODE_DESTROYING); // Finish the only activity. mStack.finishActivityLocked(topActivity, 0 /* resultCode */, null /* resultData */, "testAdjustFocusedStack", false /* oomAdj */); // Although home stack is empty, it should still be the focused stack. assertEquals(homeStask, mDefaultDisplay.getFocusedStack()); } @Test public void testWontFinishHomeStackImmediately() { final ActivityStack homeStack = createStackForShouldBeVisibleTest(mDefaultDisplay, Loading