diff options
3 files changed, 22 insertions, 53 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index b3fe8f6d47eb..fe91b6c52331 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -3465,7 +3465,8 @@ public final class ActivityManagerService extends ActivityManagerNative clearProfilerLocked(); } - mStackSupervisor.handleAppDiedLocked(app, restarting); + // Remove this application's activities from active lists. + boolean hasVisibleActivities = mStackSupervisor.handleAppDiedLocked(app, restarting); app.activities.clear(); @@ -3476,6 +3477,19 @@ public final class ActivityManagerService extends ActivityManagerNative info.putString("shortMsg", "Process crashed."); finishInstrumentationLocked(app, Activity.RESULT_CANCELED, info); } + + if (!restarting) { + if (!mStackSupervisor.resumeTopActivitiesLocked()) { + // If there was nothing to resume, and we are not already + // restarting this process, but there is a visible activity that + // is hosted by the process... then make sure all visible + // activities are running, taking care of restarting this + // process. + if (hasVisibleActivities) { + mStackSupervisor.ensureActivitiesVisibleLocked(null, 0); + } + } + } } private final int getLRURecordIndexForAppLocked(IApplicationThread thread) { diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index 422e2b180a06..e77de84139e3 100644 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -3431,13 +3431,9 @@ final class ActivityStack { /** * Reset local parameters because an app's activity died. * @param app The app of the activity that died. - * @return true if home should be launched next. + * @return result from removeHistoryRecordsForAppLocked. */ boolean handleAppDiedLocked(ProcessRecord app) { - if (!containsApp(app)) { - return false; - } - if (mPausingActivity != null && mPausingActivity.app == app) { if (DEBUG_PAUSE || DEBUG_CLEANUP) Slog.v(TAG, "App died while pausing: " + mPausingActivity); @@ -3448,30 +3444,7 @@ final class ActivityStack { mLastNoHistoryActivity = null; } - // Determine if the top task is exiting and should return to home. Do this before it gets - // removed in removeHistoryRecordsForAppsLocked. - boolean launchHomeNext = false; - TaskRecord topTask = mTaskHistory.get(mTaskHistory.size() - 1); - ArrayList<ActivityRecord> activities = topTask.mActivities; - int activityNdx; - for (activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { - ActivityRecord r = activities.get(activityNdx); - if (r.finishing) { - continue; - } - if (r.app != app) { - // This is the dying activity. - break; - } - } - if (activityNdx < 0) { - // All activities in task belong to app. Set launchHomeNext to task's value. - launchHomeNext = topTask.mOnTopOfHome; - } - - removeHistoryRecordsForAppLocked(app); - - return launchHomeNext; + return removeHistoryRecordsForAppLocked(app); } void handleAppCrashLocked(ProcessRecord app) { diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java index dc9036f16745..b4de258a8051 100644 --- a/services/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/java/com/android/server/am/ActivityStackSupervisor.java @@ -1906,30 +1906,12 @@ public final class ActivityStackSupervisor { return r; } - void handleAppDiedLocked(ProcessRecord app, boolean restarting) { - boolean launchHomeTaskNext = false; - final ActivityStack focusedStack = getFocusedStack(); - final int numStacks = mStacks.size(); - for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) { - final ActivityStack stack = mStacks.get(stackNdx); - // Only update launchHomeTaskNext for the focused stack. - launchHomeTaskNext |= (stack.handleAppDiedLocked(app) && stack == focusedStack); - } - - if (!restarting) { - if (launchHomeTaskNext) { - resumeHomeActivity(null); - } else { - if (!resumeTopActivitiesLocked(focusedStack, null, null)) { - // If there was nothing to resume, and we are not already - // restarting this process, but there is a visible activity that - // is hosted by the process... then make sure all visible - // activities are running, taking care of restarting this - // process. - ensureActivitiesVisibleLocked(null, 0); - } - } + boolean handleAppDiedLocked(ProcessRecord app, boolean restarting) { + boolean hasVisibleActivities = false; + for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { + hasVisibleActivities |= mStacks.get(stackNdx).handleAppDiedLocked(app); } + return hasVisibleActivities; } void closeSystemDialogsLocked() { |