Resume next activity if pausing app died am: 9c62ef63fd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12343635

Change-Id: Iaacc56f1227007e11bed6c9cfe1662ac5c517110
This commit is contained in:
Riddle Hsu
2020-08-11 14:04:15 +00:00
committed by Automerger Merge Worker
2 changed files with 27 additions and 2 deletions

View File

@@ -2726,13 +2726,15 @@ class ActivityStack extends Task {
/** /**
* Reset local parameters because an app's activity died. * Reset local parameters because an app's activity died.
* @param app The app of the activity that died. * @param app The app of the activity that died.
* @return result from removeHistoryRecordsForAppLocked. * @return {@code true} if the process has any visible activity.
*/ */
boolean handleAppDied(WindowProcessController app) { boolean handleAppDied(WindowProcessController app) {
boolean isPausingDied = false;
if (mPausingActivity != null && mPausingActivity.app == app) { if (mPausingActivity != null && mPausingActivity.app == app) {
if (DEBUG_PAUSE || DEBUG_CLEANUP) Slog.v(TAG_PAUSE, if (DEBUG_PAUSE || DEBUG_CLEANUP) Slog.v(TAG_PAUSE,
"App died while pausing: " + mPausingActivity); "App died while pausing: " + mPausingActivity);
mPausingActivity = null; mPausingActivity = null;
isPausingDied = true;
} }
if (mLastPausedActivity != null && mLastPausedActivity.app == app) { if (mLastPausedActivity != null && mLastPausedActivity.app == app) {
mLastPausedActivity = null; mLastPausedActivity = null;
@@ -2740,7 +2742,8 @@ class ActivityStack extends Task {
} }
mStackSupervisor.removeHistoryRecords(app); mStackSupervisor.removeHistoryRecords(app);
return mRemoveHistoryRecordsForApp.process(app); final boolean hadVisibleActivities = mRemoveHistoryRecordsForApp.process(app);
return hadVisibleActivities || isPausingDied;
} }
boolean dump(FileDescriptor fd, PrintWriter pw, boolean dumpAll, boolean dumpClient, boolean dump(FileDescriptor fd, PrintWriter pw, boolean dumpAll, boolean dumpClient,

View File

@@ -225,5 +225,27 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
mockSession.finishMocking(); mockSession.finishMocking();
} }
@Test
public void testResumeNextActivityOnCrashedAppDied() {
mSupervisor.beginDeferResume();
final ActivityRecord homeActivity = new ActivityBuilder(mService)
.setTask(mRootWindowContainer.getDefaultTaskDisplayArea().getOrCreateRootHomeTask())
.build();
final ActivityRecord activity = new ActivityBuilder(mService).setCreateTask(true).build();
mSupervisor.endDeferResume();
// Assume the activity is finishing and hidden because it was crashed.
activity.finishing = true;
activity.mVisibleRequested = false;
activity.setVisible(false);
activity.getRootTask().mPausingActivity = activity;
homeActivity.setState(ActivityStack.ActivityState.PAUSED, "test");
// Even the visibility states are invisible, the next activity should be resumed because
// the crashed activity was pausing.
mService.mInternal.handleAppDied(activity.app, false /* restarting */,
null /* finishInstrumentationCallback */);
assertEquals(ActivityStack.ActivityState.RESUMED, homeActivity.getState());
}
} }