Loading services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +20 −0 Original line number Diff line number Diff line Loading @@ -932,6 +932,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { // a resume. r.setState(RESUMED, "realStartActivityLocked"); r.completeResumeLocked(); makeNonTopVisibleActivitiesActiveIfNeeded(r, task); } else if (r.isVisibleRequested()) { // This activity is not starting in the resumed state... which should look like we asked // it to pause+stop (but remain visible), and it has done so and reported back the Loading @@ -940,6 +941,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { + "(starting in paused state)", r); r.setState(PAUSED, "realStartActivityLocked"); mRootWindowContainer.executeAppTransitionForAllDisplay(); makeNonTopVisibleActivitiesActiveIfNeeded(r, task); } else { // This activity is starting while invisible, so it should be stopped. r.setState(STOPPING, "realStartActivityLocked"); Loading Loading @@ -1081,6 +1083,24 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { return null; } /** * Sends lifecycle item (e.g. StartActivityItem) to non-top visible activities in the same task * of the launched activity if ensureActivitiesVisible was called with notifyClients=false. */ private static void makeNonTopVisibleActivitiesActiveIfNeeded(@NonNull ActivityRecord launched, @NonNull Task task) { if (!task.inMultiWindowMode() || (launched.occludesParent() && !launched.isEmbedded())) { // Skip if this activity may trigger other activities to pause, because activityPaused // will call ensureActivitiesVisible with notifyClients=true. return; } task.forAllActivities(r -> { if (r != launched && r.isVisibleRequested()) { r.makeActiveIfNeeded(null /* activeActivity */); } }); } void updateHomeProcessIfNeeded(@NonNull ActivityRecord r) { if (!r.isActivityTypeHome()) return; // Make sure that we use the bottom most activity from the same package, because the home Loading services/tests/wmtests/src/com/android/server/wm/ActivityTaskSupervisorTests.java +31 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ 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; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doCallRealMethod; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.never; import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset; Loading @@ -38,6 +39,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -257,6 +259,35 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase { verify(activity).getFilteredReferrer(eq("other.package2")); } /** * Ensures that {@link ActivityRecord#makeActiveIfNeeded(ActivityRecord)} is called for non-top * visible activities when launching an activity into an existing task which won't make other * activities pause (i.e. no subsequent ensureActivitiesVisible with notifyClients=true). */ @Test public void testNonTopVisibleActivitiesActiveWhenLaunchingTranslucent() { final Task freeformTask = new TaskBuilder(mSupervisor) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(freeformTask) .setVisible(false).build(); activity.setState(ActivityRecord.State.STOPPED, "test"); final ActivityRecord translucentTop = new ActivityBuilder(mAtm).setTask(freeformTask) .setActivityTheme(android.R.style.Theme_Translucent) .setVisible(false).build(); doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible( any() /* starting */, anyBoolean() /* notifyClients */); try { mSupervisor.realStartActivityLocked(translucentTop, translucentTop.app, true /* andResume */, true /* checkConfig */); } catch (RemoteException ignored) { } assertTrue(activity.isVisibleRequested()); assertTrue(translucentTop.isVisibleRequested()); assertEquals(ActivityRecord.State.RESUMED, translucentTop.getState()); assertEquals(ActivityRecord.State.STARTED, activity.getState()); } /** * Ensures that notify focus task changes. */ Loading Loading
services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +20 −0 Original line number Diff line number Diff line Loading @@ -932,6 +932,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { // a resume. r.setState(RESUMED, "realStartActivityLocked"); r.completeResumeLocked(); makeNonTopVisibleActivitiesActiveIfNeeded(r, task); } else if (r.isVisibleRequested()) { // This activity is not starting in the resumed state... which should look like we asked // it to pause+stop (but remain visible), and it has done so and reported back the Loading @@ -940,6 +941,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { + "(starting in paused state)", r); r.setState(PAUSED, "realStartActivityLocked"); mRootWindowContainer.executeAppTransitionForAllDisplay(); makeNonTopVisibleActivitiesActiveIfNeeded(r, task); } else { // This activity is starting while invisible, so it should be stopped. r.setState(STOPPING, "realStartActivityLocked"); Loading Loading @@ -1081,6 +1083,24 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { return null; } /** * Sends lifecycle item (e.g. StartActivityItem) to non-top visible activities in the same task * of the launched activity if ensureActivitiesVisible was called with notifyClients=false. */ private static void makeNonTopVisibleActivitiesActiveIfNeeded(@NonNull ActivityRecord launched, @NonNull Task task) { if (!task.inMultiWindowMode() || (launched.occludesParent() && !launched.isEmbedded())) { // Skip if this activity may trigger other activities to pause, because activityPaused // will call ensureActivitiesVisible with notifyClients=true. return; } task.forAllActivities(r -> { if (r != launched && r.isVisibleRequested()) { r.makeActiveIfNeeded(null /* activeActivity */); } }); } void updateHomeProcessIfNeeded(@NonNull ActivityRecord r) { if (!r.isActivityTypeHome()) return; // Make sure that we use the bottom most activity from the same package, because the home Loading
services/tests/wmtests/src/com/android/server/wm/ActivityTaskSupervisorTests.java +31 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ 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; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doCallRealMethod; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.never; import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset; Loading @@ -38,6 +39,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -257,6 +259,35 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase { verify(activity).getFilteredReferrer(eq("other.package2")); } /** * Ensures that {@link ActivityRecord#makeActiveIfNeeded(ActivityRecord)} is called for non-top * visible activities when launching an activity into an existing task which won't make other * activities pause (i.e. no subsequent ensureActivitiesVisible with notifyClients=true). */ @Test public void testNonTopVisibleActivitiesActiveWhenLaunchingTranslucent() { final Task freeformTask = new TaskBuilder(mSupervisor) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(freeformTask) .setVisible(false).build(); activity.setState(ActivityRecord.State.STOPPED, "test"); final ActivityRecord translucentTop = new ActivityBuilder(mAtm).setTask(freeformTask) .setActivityTheme(android.R.style.Theme_Translucent) .setVisible(false).build(); doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible( any() /* starting */, anyBoolean() /* notifyClients */); try { mSupervisor.realStartActivityLocked(translucentTop, translucentTop.app, true /* andResume */, true /* checkConfig */); } catch (RemoteException ignored) { } assertTrue(activity.isVisibleRequested()); assertTrue(translucentTop.isVisibleRequested()); assertEquals(ActivityRecord.State.RESUMED, translucentTop.getState()); assertEquals(ActivityRecord.State.STARTED, activity.getState()); } /** * Ensures that notify focus task changes. */ Loading