Loading services/core/java/com/android/server/wm/Task.java +2 −1 Original line number Diff line number Diff line Loading @@ -1274,7 +1274,8 @@ class Task extends TaskFragment { if (!isLeafTaskFragment()) { final ActivityRecord top = topRunningActivity(); final ActivityRecord resumedActivity = getResumedActivity(); if (resumedActivity != null && top.getTaskFragment() != this) { if (resumedActivity != null && (top.getTaskFragment() != this || !canBeResumed(resuming))) { // Pausing the resumed activity because it is occluded by other task fragment. if (startPausing(false /* uiSleeping*/, resuming, reason)) { someActivityPaused[0]++; Loading services/tests/wmtests/src/com/android/server/wm/TaskTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -1945,6 +1945,21 @@ public class TaskTests extends WindowTestsBase { assertEquals(2, finishCount[0]); } @Test public void testPauseActivityWhenHasEmptyLeafTaskFragment() { // Creating a task that has a RESUMED activity and an empty TaskFragment. final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build(); final ActivityRecord activity = task.getTopMostActivity(); new TaskFragmentBuilder(mAtm).setParentTask(task).build(); activity.setState(ActivityRecord.State.RESUMED, "test"); // Ensure the activity is paused if cannot be resumed. doReturn(false).when(task).canBeResumed(any()); mSupervisor.mUserLeaving = true; task.pauseActivityIfNeeded(null /* resuming */, "test"); verify(task).startPausing(eq(true) /* userLeaving */, anyBoolean(), any(), any()); } private Task getTestTask() { return new TaskBuilder(mSupervisor).setCreateActivity(true).build(); } Loading Loading
services/core/java/com/android/server/wm/Task.java +2 −1 Original line number Diff line number Diff line Loading @@ -1274,7 +1274,8 @@ class Task extends TaskFragment { if (!isLeafTaskFragment()) { final ActivityRecord top = topRunningActivity(); final ActivityRecord resumedActivity = getResumedActivity(); if (resumedActivity != null && top.getTaskFragment() != this) { if (resumedActivity != null && (top.getTaskFragment() != this || !canBeResumed(resuming))) { // Pausing the resumed activity because it is occluded by other task fragment. if (startPausing(false /* uiSleeping*/, resuming, reason)) { someActivityPaused[0]++; Loading
services/tests/wmtests/src/com/android/server/wm/TaskTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -1945,6 +1945,21 @@ public class TaskTests extends WindowTestsBase { assertEquals(2, finishCount[0]); } @Test public void testPauseActivityWhenHasEmptyLeafTaskFragment() { // Creating a task that has a RESUMED activity and an empty TaskFragment. final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build(); final ActivityRecord activity = task.getTopMostActivity(); new TaskFragmentBuilder(mAtm).setParentTask(task).build(); activity.setState(ActivityRecord.State.RESUMED, "test"); // Ensure the activity is paused if cannot be resumed. doReturn(false).when(task).canBeResumed(any()); mSupervisor.mUserLeaving = true; task.pauseActivityIfNeeded(null /* resuming */, "test"); verify(task).startPausing(eq(true) /* userLeaving */, anyBoolean(), any(), any()); } private Task getTestTask() { return new TaskBuilder(mSupervisor).setCreateActivity(true).build(); } Loading