Merge "Do not resume activities that were launched behind" into qt-dev

am: 35885e0769

Change-Id: Ifd866c6957b3cd9cfdb979c76b42396d57984943
This commit is contained in:
Louis Chang
2019-06-05 06:23:51 -07:00
committed by android-build-merger
2 changed files with 42 additions and 1 deletions

View File

@@ -2383,7 +2383,11 @@ class ActivityStack extends ConfigurationContainer {
r.setVisible(true); r.setVisible(true);
} }
if (r != starting) { if (r != starting) {
mStackSupervisor.startSpecificActivityLocked(r, andResume, true /* checkConfig */); // We should not resume activities that being launched behind because these
// activities are actually behind other fullscreen activities, but still required
// to be visible (such as performing Recents animation).
mStackSupervisor.startSpecificActivityLocked(r, andResume && !r.mLaunchTaskBehind,
true /* checkConfig */);
return true; return true;
} }
} }

View File

@@ -24,14 +24,18 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; 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.doCallRealMethod;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.eq; import static com.android.dx.mockito.inline.extended.ExtendedMockito.eq;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.times;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.ActivityStack.ActivityState.PAUSED;
import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE; import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
@@ -106,6 +110,39 @@ public class RecentsAnimationTest extends ActivityTestsBase {
assertFalse(recentActivity.visible); assertFalse(recentActivity.visible);
} }
@Test
public void testRestartRecentsActivity() throws Exception {
// Have a recents activity that is not attached to its process (ActivityRecord.app = null).
ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
ActivityStack recentsStack = display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
ActivityRecord recentActivity = new ActivityBuilder(mService).setComponent(
mRecentsComponent).setCreateTask(true).setStack(recentsStack).build();
WindowProcessController app = recentActivity.app;
recentActivity.app = null;
// Start an activity on top.
new ActivityBuilder(mService).setCreateTask(true).build().getActivityStack().moveToFront(
"testRestartRecentsActivity");
doCallRealMethod().when(mRootActivityContainer).ensureActivitiesVisible(
any() /* starting */, anyInt() /* configChanges */,
anyBoolean() /* preserveWindows */);
doReturn(app).when(mService).getProcessController(eq(recentActivity.processName), anyInt());
ClientLifecycleManager lifecycleManager = mService.getLifecycleManager();
doNothing().when(lifecycleManager).scheduleTransaction(any());
AppWarnings appWarnings = mService.getAppWarningsLocked();
spyOn(appWarnings);
doNothing().when(appWarnings).onStartActivity(any());
startRecentsActivity();
// Recents activity must be restarted, but not be resumed while running recents animation.
verify(mRootActivityContainer.mStackSupervisor).startSpecificActivityLocked(
eq(recentActivity), eq(false), anyBoolean());
assertThat(recentActivity.getState()).isEqualTo(PAUSED);
}
@Test @Test
public void testSetLaunchTaskBehindOfTargetActivity() { public void testSetLaunchTaskBehindOfTargetActivity() {
ActivityDisplay display = mRootActivityContainer.getDefaultDisplay(); ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();