Loading services/core/java/com/android/server/wm/RootWindowContainer.java +8 −0 Original line number Diff line number Diff line Loading @@ -3323,6 +3323,14 @@ class RootWindowContainer extends WindowContainer<DisplayContent> * @return {@code true} if the top activity looks like it belongs to {@param userId}. */ private void taskTopActivityIsUser(Task task, @UserIdInt int userId) { // TODO(b/80414790): having utilities to loop for all leaf tasks from caller vs. checking // leaf tasks here. if (!task.isLeafTask()) { // No op if not a leaf task since we don't want to report root tasks to // TaskStackListeners. return; } // To handle the case that work app is in the task but just is not the top one. final ActivityRecord activityRecord = task.getTopNonFinishingActivity(); final ActivityRecord resultTo = (activityRecord != null ? activityRecord.resultTo : null); Loading services/core/java/com/android/server/wm/Task.java +25 −7 Original line number Diff line number Diff line Loading @@ -1431,18 +1431,27 @@ class Task extends WindowContainer<WindowContainer> { } /** * @return whether or not there are ONLY task overlay activities in the stack. * @return whether or not there are ONLY task overlay activities in the task. * If {@param includeFinishing} is set, then don't ignore finishing activities in the * check. If there are no task overlay activities, this call returns false. */ boolean onlyHasTaskOverlayActivities(boolean includeFinishing) { if (getChildCount() == 0) { int count = 0; for (int i = getChildCount() - 1; i >= 0; i--) { final ActivityRecord r = getChildAt(i).asActivityRecord(); if (r == null) { // Has a child that is other than Activity. return false; } if (!includeFinishing && r.finishing) { continue; } if (!r.isTaskOverlay()) { return false; } if (includeFinishing) { return getActivity((r) -> r.isTaskOverlay()) != null; count++; } return getActivity((r) -> !r.finishing && r.isTaskOverlay()) != null; return count > 0; } private boolean autoRemoveFromRecents() { Loading Loading @@ -2369,6 +2378,15 @@ class Task extends WindowContainer<WindowContainer> { return getRootTask() == this; } boolean isLeafTask() { for (int i = mChildren.size() - 1; i >= 0; --i) { if (mChildren.get(i).asTask() != null) { return false; } } return true; } int getDescendantTaskCount() { final int[] currentCount = {0}; final PooledConsumer c = PooledLambda.obtainConsumer((t, count) -> { count[0]++; }, Loading services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.WindowManager.TRANSIT_TASK_CLOSE; import static com.android.dx.mockito.inline.extended.ExtendedMockito.any; import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean; import static com.android.dx.mockito.inline.extended.ExtendedMockito.atLeast; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; Loading Loading @@ -139,6 +140,19 @@ public class ActivityRecordTests extends ActivityTestsBase { assertNull(mService.mRootWindowContainer.getStack(mStack.mTaskId)); } @Test public void testRemoveChildWithOverlayActivity() { final ActivityRecord overlayActivity = new ActivityBuilder(mService).setTask(mTask).build(); overlayActivity.setTaskOverlay(true); final ActivityRecord overlayActivity2 = new ActivityBuilder(mService).setTask(mTask).build(); overlayActivity2.setTaskOverlay(true); mTask.removeChild(overlayActivity2, "test"); verify(mSupervisor, never()).removeTask(any(), anyBoolean(), anyBoolean(), any()); } @Test public void testNoCleanupMovingActivityInSameStack() { final Task newTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build(); Loading Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +8 −0 Original line number Diff line number Diff line Loading @@ -3323,6 +3323,14 @@ class RootWindowContainer extends WindowContainer<DisplayContent> * @return {@code true} if the top activity looks like it belongs to {@param userId}. */ private void taskTopActivityIsUser(Task task, @UserIdInt int userId) { // TODO(b/80414790): having utilities to loop for all leaf tasks from caller vs. checking // leaf tasks here. if (!task.isLeafTask()) { // No op if not a leaf task since we don't want to report root tasks to // TaskStackListeners. return; } // To handle the case that work app is in the task but just is not the top one. final ActivityRecord activityRecord = task.getTopNonFinishingActivity(); final ActivityRecord resultTo = (activityRecord != null ? activityRecord.resultTo : null); Loading
services/core/java/com/android/server/wm/Task.java +25 −7 Original line number Diff line number Diff line Loading @@ -1431,18 +1431,27 @@ class Task extends WindowContainer<WindowContainer> { } /** * @return whether or not there are ONLY task overlay activities in the stack. * @return whether or not there are ONLY task overlay activities in the task. * If {@param includeFinishing} is set, then don't ignore finishing activities in the * check. If there are no task overlay activities, this call returns false. */ boolean onlyHasTaskOverlayActivities(boolean includeFinishing) { if (getChildCount() == 0) { int count = 0; for (int i = getChildCount() - 1; i >= 0; i--) { final ActivityRecord r = getChildAt(i).asActivityRecord(); if (r == null) { // Has a child that is other than Activity. return false; } if (!includeFinishing && r.finishing) { continue; } if (!r.isTaskOverlay()) { return false; } if (includeFinishing) { return getActivity((r) -> r.isTaskOverlay()) != null; count++; } return getActivity((r) -> !r.finishing && r.isTaskOverlay()) != null; return count > 0; } private boolean autoRemoveFromRecents() { Loading Loading @@ -2369,6 +2378,15 @@ class Task extends WindowContainer<WindowContainer> { return getRootTask() == this; } boolean isLeafTask() { for (int i = mChildren.size() - 1; i >= 0; --i) { if (mChildren.get(i).asTask() != null) { return false; } } return true; } int getDescendantTaskCount() { final int[] currentCount = {0}; final PooledConsumer c = PooledLambda.obtainConsumer((t, count) -> { count[0]++; }, Loading
services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.WindowManager.TRANSIT_TASK_CLOSE; import static com.android.dx.mockito.inline.extended.ExtendedMockito.any; import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean; import static com.android.dx.mockito.inline.extended.ExtendedMockito.atLeast; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; Loading Loading @@ -139,6 +140,19 @@ public class ActivityRecordTests extends ActivityTestsBase { assertNull(mService.mRootWindowContainer.getStack(mStack.mTaskId)); } @Test public void testRemoveChildWithOverlayActivity() { final ActivityRecord overlayActivity = new ActivityBuilder(mService).setTask(mTask).build(); overlayActivity.setTaskOverlay(true); final ActivityRecord overlayActivity2 = new ActivityBuilder(mService).setTask(mTask).build(); overlayActivity2.setTaskOverlay(true); mTask.removeChild(overlayActivity2, "test"); verify(mSupervisor, never()).removeTask(any(), anyBoolean(), anyBoolean(), any()); } @Test public void testNoCleanupMovingActivityInSameStack() { final Task newTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build(); Loading