Loading services/core/java/com/android/server/wm/ActivityStarter.java +2 −2 Original line number Diff line number Diff line Loading @@ -2081,8 +2081,8 @@ class ActivityStarter { final ActivityRecord curTop = (focusStack == null) ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); final TaskRecord topTask = curTop != null ? curTop.getTaskRecord() : null; differentTopTask = topTask != null && (topTask != intentActivity.getTaskRecord() || topTask != focusStack.topTask()); differentTopTask = topTask != intentActivity.getTaskRecord() || (focusStack != null && topTask != focusStack.topTask()); } else { // The existing task should always be different from those in other displays. differentTopTask = true; Loading services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +30 −0 Original line number Diff line number Diff line Loading @@ -698,6 +698,36 @@ public class ActivityStarterTests extends ActivityTestsBase { verify(options, times(shouldHaveAborted ? 1 : 0)).abort(); } /** * This test ensures that {@link ActivityStarter#setTargetStackAndMoveToFrontIfNeeded} will * move the existing task to front if the current focused stack doesn't have running task. */ @Test public void testBringTaskToFrontWhenFocusedStackIsFinising() { // Put 2 tasks in the same stack (simulate the behavior of home stack). final ActivityRecord activity = new ActivityBuilder(mService) .setCreateTask(true).build(); new ActivityBuilder(mService) .setStack(activity.getActivityStack()) .setCreateTask(true).build(); // Create a top finishing activity. final ActivityRecord finishingTopActivity = new ActivityBuilder(mService) .setCreateTask(true).build(); finishingTopActivity.getActivityStack().moveToFront("finishingTopActivity"); assertEquals(finishingTopActivity, mRootActivityContainer.topRunningActivity()); finishingTopActivity.finishing = true; // Launch the bottom task of the target stack. prepareStarter(FLAG_ACTIVITY_NEW_TASK, false /* mockGetLaunchStack */) .setReason("testBringTaskToFrontWhenTopStackIsFinising") .setIntent(activity.intent) .execute(); // The hierarchies of the activity should move to front. assertEquals(activity, mRootActivityContainer.topRunningActivity()); } /** * This test ensures that when starting an existing single task activity on secondary display * which is not the top focused display, it should deliver new intent to the activity and not Loading Loading
services/core/java/com/android/server/wm/ActivityStarter.java +2 −2 Original line number Diff line number Diff line Loading @@ -2081,8 +2081,8 @@ class ActivityStarter { final ActivityRecord curTop = (focusStack == null) ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); final TaskRecord topTask = curTop != null ? curTop.getTaskRecord() : null; differentTopTask = topTask != null && (topTask != intentActivity.getTaskRecord() || topTask != focusStack.topTask()); differentTopTask = topTask != intentActivity.getTaskRecord() || (focusStack != null && topTask != focusStack.topTask()); } else { // The existing task should always be different from those in other displays. differentTopTask = true; Loading
services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +30 −0 Original line number Diff line number Diff line Loading @@ -698,6 +698,36 @@ public class ActivityStarterTests extends ActivityTestsBase { verify(options, times(shouldHaveAborted ? 1 : 0)).abort(); } /** * This test ensures that {@link ActivityStarter#setTargetStackAndMoveToFrontIfNeeded} will * move the existing task to front if the current focused stack doesn't have running task. */ @Test public void testBringTaskToFrontWhenFocusedStackIsFinising() { // Put 2 tasks in the same stack (simulate the behavior of home stack). final ActivityRecord activity = new ActivityBuilder(mService) .setCreateTask(true).build(); new ActivityBuilder(mService) .setStack(activity.getActivityStack()) .setCreateTask(true).build(); // Create a top finishing activity. final ActivityRecord finishingTopActivity = new ActivityBuilder(mService) .setCreateTask(true).build(); finishingTopActivity.getActivityStack().moveToFront("finishingTopActivity"); assertEquals(finishingTopActivity, mRootActivityContainer.topRunningActivity()); finishingTopActivity.finishing = true; // Launch the bottom task of the target stack. prepareStarter(FLAG_ACTIVITY_NEW_TASK, false /* mockGetLaunchStack */) .setReason("testBringTaskToFrontWhenTopStackIsFinising") .setIntent(activity.intent) .execute(); // The hierarchies of the activity should move to front. assertEquals(activity, mRootActivityContainer.topRunningActivity()); } /** * This test ensures that when starting an existing single task activity on secondary display * which is not the top focused display, it should deliver new intent to the activity and not Loading