Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 846a482a authored by Craig Mautner's avatar Craig Mautner Committed by Android Git Automerger
Browse files

am ade5f387: Merge "Revert to jb-mr2 handling of app died." into klp-dev

* commit 'ade5f387':
  Revert to jb-mr2 handling of app died.
parents a5c43674 ade5f387
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -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) {
+2 −29
Original line number Diff line number Diff line
@@ -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) {
+5 −23
Original line number Diff line number Diff line
@@ -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() {