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

Commit 1f3889a4 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix force-stop may restart stopped process

Assume the stopping package has 2 activities on top, when removing
the top one, if the next activity is not finishing, it will be
considered as visible and got started again. So before the removal,
all activities should be set as finishing.

Bug: 163048635
Test: ActivityManagerTest#testForceStopPackageWontRestartProcess
Change-Id: If84aa83607d33e3d18ed71713e85ff1de3ac7ab9
parent 19d897f3
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -1177,12 +1177,19 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
    boolean handleAppDied() {
        mAtm.mStackSupervisor.removeHistoryRecords(this);

        final boolean isRemoved = isRemoved();
        boolean hasVisibleActivities = false;
        if (mInactiveActivities != null && !mInactiveActivities.isEmpty()) {
            // Make sure that all activities in this process are handled.
            mActivities.addAll(mInactiveActivities);
        }
        if (isRemoved()) {
            // The package of the died process should be force-stopped, so make its activities as
            // finishing to prevent the process from being started again if the next top (or being
            // visible) activity also resides in the same process. This must be done before removal.
            for (int i = mActivities.size() - 1; i >= 0; i--) {
                mActivities.get(i).makeFinishingLocked();
            }
        }
        for (int i = mActivities.size() - 1; i >= 0; i--) {
            final ActivityRecord r = mActivities.get(i);
            if (r.mVisibleRequested || r.isVisible()) {
@@ -1191,12 +1198,6 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
                // is not yet committed, so isVisible()=true.
                hasVisibleActivities = true;
            }
            if (isRemoved) {
                // The package of the died process should be force-stopped, so make its activities
                // as finishing to prevent the process from being started again if the next top (or
                // being visible) activity also resides in the same process.
                r.makeFinishingLocked();
            }

            final Task rootTask = r.getRootTask();
            if (rootTask != null) {