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

Commit 3137cfb8 authored by riddle_hsu's avatar riddle_hsu Committed by Steve Kondik
Browse files

[ActivityManager] Avoid keeping restarting home when only home activity exists.

Root Cause:
When there is only home activity existed,
updating home apk will call forceStopPackageLocked to finish the activity.
Then activity history becomes empty, then home will be launched,
but its package is still target to close that results a loop.

Solution:
If home activity has been force-stopped, do not stop the same home activity again.

Change-Id: Icff12028d407873c2e6f50a06bcad231b908ccbd
parent d7564a58
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -3401,6 +3401,7 @@ final class ActivityStack {
    boolean forceStopPackageLocked(String name, boolean doit, boolean evenPersistent, int userId) {
    boolean forceStopPackageLocked(String name, boolean doit, boolean evenPersistent, int userId) {
        boolean didSomething = false;
        boolean didSomething = false;
        TaskRecord lastTask = null;
        TaskRecord lastTask = null;
        ComponentName homeActivity = null;
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities;
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities;
            int numActivities = activities.size();
            int numActivities = activities.size();
@@ -3419,6 +3420,14 @@ final class ActivityStack {
                        }
                        }
                        return true;
                        return true;
                    }
                    }
                    if (r.isHomeActivity()) {
                        if (homeActivity != null && homeActivity.equals(r.realActivity)) {
                            Slog.i(TAG, "Skip force-stop again " + r);
                            continue;
                        } else {
                            homeActivity = r.realActivity;
                        }
                    }
                    didSomething = true;
                    didSomething = true;
                    Slog.i(TAG, "  Force finishing activity " + r);
                    Slog.i(TAG, "  Force finishing activity " + r);
                    if (samePackage) {
                    if (samePackage) {