Loading core/java/android/app/ActivityManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -3099,7 +3099,8 @@ public class ActivityManager { /** * Flag for {@link #moveTaskToFront(int, int)}: also move the "home" * activity along with the task, so it is positioned immediately behind * the task. * the task. This flag is ignored if the task's windowing mode is * {@link WindowConfiguration#WINDOWING_MODE_MULTI_WINDOW}. */ public static final int MOVE_TASK_WITH_HOME = 0x00000001; Loading services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +14 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.content.Intent.ACTION_VIEW; Loading Loading @@ -1634,16 +1635,19 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { } } private void moveHomeRootTaskToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea, @VisibleForTesting void moveHomeRootTaskToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea, String reason) { final Task focusedRootTask = taskDisplayArea.getFocusedRootTask(); if ((taskDisplayArea.getWindowingMode() == WINDOWING_MODE_FULLSCREEN && (flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) || (focusedRootTask != null && focusedRootTask.isActivityTypeRecents())) { || (focusedRootTask != null && focusedRootTask.isActivityTypeRecents() && focusedRootTask.getWindowingMode() != WINDOWING_MODE_MULTI_WINDOW)) { // We move root home task to front when we are on a fullscreen display area and // caller has requested the home activity to move with it. Or the previous root task // is recents. // is recents and we are not on multi-window mode. taskDisplayArea.moveHomeRootTaskToFront(reason); } } Loading Loading @@ -2830,6 +2834,13 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { "startActivityFromRecents: Task " + taskId + " not found."); } if (task.getRootTask() != null && task.getRootTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW) { // Don't move home forward if task is in multi window mode moveHomeTaskForward = false; } if (moveHomeTaskForward) { // We always want to return to the home activity instead of the recents // activity from whatever is started from the recents activity, so move Loading services/tests/wmtests/src/com/android/server/wm/ActivityTaskSupervisorTests.java +58 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.app.ActivityManager.START_DELIVERED_TO_TOP; import static android.app.ActivityManager.START_TASK_TO_FRONT; import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; Loading Loading @@ -82,6 +83,8 @@ import java.util.concurrent.TimeUnit; @RunWith(WindowTestRunner.class) public class ActivityTaskSupervisorTests extends WindowTestsBase { private static final long TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10); private static final int DEFAULT_CALLING_PID = -1; private static final int DEFAULT_CALLING_UID = -1; /** * Ensures that an activity is removed from the stopping activities list once it is resumed. Loading Loading @@ -408,7 +411,8 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase { doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(-1, -1, activity.getRootTaskId(), safeOptions); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); assertThat(activity.mLaunchCookie).isEqualTo(launchCookie); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); Loading @@ -426,12 +430,62 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase { doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(-1, -1, activity.getRootTaskId(), safeOptions); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); assertThat(activity.mLaunchCookie).isNull(); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); } /** Verifies that launch from recents doesn't set the launch cookie on the activity. */ @Test public void testStartActivityFromRecents_inMultiWindowRootTask_homeNotMoved() { final Task multiWindowRootTask = new TaskBuilder(mSupervisor).setWindowingMode( WINDOWING_MODE_MULTI_WINDOW).setOnTop(true).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setParentTask( multiWindowRootTask).setCreateTask(true).build(); SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle( ActivityOptions.makeBasic().toBundle(), Binder.getCallingPid(), Binder.getCallingUid()); doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); verify(mRootWindowContainer.getDefaultTaskDisplayArea(), never()).moveHomeRootTaskToFront( any()); verify(multiWindowRootTask.getDisplayArea(), never()).moveHomeRootTaskToFront(any()); } /** Verifies that launch from recents doesn't set the launch cookie on the activity. */ @Test public void testStartActivityFromRecents_inFullScreenRootTask_homeMovedToFront() { final Task fullscreenRootTask = new TaskBuilder(mSupervisor).setWindowingMode( WINDOWING_MODE_FULLSCREEN).setOnTop(true).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setParentTask( fullscreenRootTask).setCreateTask(true).build(); SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle( ActivityOptions.makeBasic().toBundle(), Binder.getCallingPid(), Binder.getCallingUid()); doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); verify(mRootWindowContainer.getDefaultTaskDisplayArea()).moveHomeRootTaskToFront(any()); verify(fullscreenRootTask.getDisplayArea()).moveHomeRootTaskToFront(any()); } @Test public void testOpaque_leafTask_occludingActivity_isOpaque() { final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build(); Loading Loading
core/java/android/app/ActivityManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -3099,7 +3099,8 @@ public class ActivityManager { /** * Flag for {@link #moveTaskToFront(int, int)}: also move the "home" * activity along with the task, so it is positioned immediately behind * the task. * the task. This flag is ignored if the task's windowing mode is * {@link WindowConfiguration#WINDOWING_MODE_MULTI_WINDOW}. */ public static final int MOVE_TASK_WITH_HOME = 0x00000001; Loading
services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +14 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.content.Intent.ACTION_VIEW; Loading Loading @@ -1634,16 +1635,19 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { } } private void moveHomeRootTaskToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea, @VisibleForTesting void moveHomeRootTaskToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea, String reason) { final Task focusedRootTask = taskDisplayArea.getFocusedRootTask(); if ((taskDisplayArea.getWindowingMode() == WINDOWING_MODE_FULLSCREEN && (flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) || (focusedRootTask != null && focusedRootTask.isActivityTypeRecents())) { || (focusedRootTask != null && focusedRootTask.isActivityTypeRecents() && focusedRootTask.getWindowingMode() != WINDOWING_MODE_MULTI_WINDOW)) { // We move root home task to front when we are on a fullscreen display area and // caller has requested the home activity to move with it. Or the previous root task // is recents. // is recents and we are not on multi-window mode. taskDisplayArea.moveHomeRootTaskToFront(reason); } } Loading Loading @@ -2830,6 +2834,13 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { "startActivityFromRecents: Task " + taskId + " not found."); } if (task.getRootTask() != null && task.getRootTask().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW) { // Don't move home forward if task is in multi window mode moveHomeTaskForward = false; } if (moveHomeTaskForward) { // We always want to return to the home activity instead of the recents // activity from whatever is started from the recents activity, so move Loading
services/tests/wmtests/src/com/android/server/wm/ActivityTaskSupervisorTests.java +58 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.app.ActivityManager.START_DELIVERED_TO_TOP; import static android.app.ActivityManager.START_TASK_TO_FRONT; import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; Loading Loading @@ -82,6 +83,8 @@ import java.util.concurrent.TimeUnit; @RunWith(WindowTestRunner.class) public class ActivityTaskSupervisorTests extends WindowTestsBase { private static final long TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10); private static final int DEFAULT_CALLING_PID = -1; private static final int DEFAULT_CALLING_UID = -1; /** * Ensures that an activity is removed from the stopping activities list once it is resumed. Loading Loading @@ -408,7 +411,8 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase { doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(-1, -1, activity.getRootTaskId(), safeOptions); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); assertThat(activity.mLaunchCookie).isEqualTo(launchCookie); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); Loading @@ -426,12 +430,62 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase { doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(-1, -1, activity.getRootTaskId(), safeOptions); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); assertThat(activity.mLaunchCookie).isNull(); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); } /** Verifies that launch from recents doesn't set the launch cookie on the activity. */ @Test public void testStartActivityFromRecents_inMultiWindowRootTask_homeNotMoved() { final Task multiWindowRootTask = new TaskBuilder(mSupervisor).setWindowingMode( WINDOWING_MODE_MULTI_WINDOW).setOnTop(true).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setParentTask( multiWindowRootTask).setCreateTask(true).build(); SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle( ActivityOptions.makeBasic().toBundle(), Binder.getCallingPid(), Binder.getCallingUid()); doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); verify(mRootWindowContainer.getDefaultTaskDisplayArea(), never()).moveHomeRootTaskToFront( any()); verify(multiWindowRootTask.getDisplayArea(), never()).moveHomeRootTaskToFront(any()); } /** Verifies that launch from recents doesn't set the launch cookie on the activity. */ @Test public void testStartActivityFromRecents_inFullScreenRootTask_homeMovedToFront() { final Task fullscreenRootTask = new TaskBuilder(mSupervisor).setWindowingMode( WINDOWING_MODE_FULLSCREEN).setOnTop(true).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setParentTask( fullscreenRootTask).setCreateTask(true).build(); SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle( ActivityOptions.makeBasic().toBundle(), Binder.getCallingPid(), Binder.getCallingUid()); doNothing().when(mSupervisor.mService).moveTaskToFrontLocked(eq(null), eq(null), anyInt(), anyInt(), any()); mSupervisor.startActivityFromRecents(DEFAULT_CALLING_PID, DEFAULT_CALLING_UID, activity.getRootTaskId(), safeOptions); verify(mAtm).moveTaskToFrontLocked(any(), eq(null), anyInt(), anyInt(), eq(safeOptions)); verify(mRootWindowContainer.getDefaultTaskDisplayArea()).moveHomeRootTaskToFront(any()); verify(fullscreenRootTask.getDisplayArea()).moveHomeRootTaskToFront(any()); } @Test public void testOpaque_leafTask_occludingActivity_isOpaque() { final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build(); Loading