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

Commit ed2671c6 authored by Louis Chang's avatar Louis Chang
Browse files

Remove unnecessary `removeFromApp` parameter

Always remove the activity from its process while calling
#destroyImmediately() and remove the unnecessary removeFromApp
parameter since the value is always true from all callers.

Bug: 161447610
Test: atest ActivityRecordTests
Change-Id: I5333ea7d3c07bddd29e1070ae373c0b24a281d9c
parent 113edff6
Loading
Loading
Loading
Loading
+15 −18
Original line number Diff line number Diff line
@@ -2786,8 +2786,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        makeFinishingLocked();

        final boolean activityRemoved = destroyImmediately(true /* removeFromApp */,
                "finish-imm:" + reason);
        final boolean activityRemoved = destroyImmediately("finish-imm:" + reason);

        // If the display does not have running activity, the configuration may need to be
        // updated for restoring original orientation of the display.
@@ -2835,7 +2834,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * @return {@code true} if activity was immediately removed from history, {@code false}
     * otherwise.
     */
    boolean destroyImmediately(boolean removeFromApp, String reason) {
    boolean destroyImmediately(String reason) {
        if (DEBUG_SWITCH || DEBUG_CLEANUP) {
            Slog.v(TAG_SWITCH, "Removing activity from " + reason + ": token=" + this
                    + ", app=" + (hasProcess() ? app.mName : "(null)"));
@@ -2857,7 +2856,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        cleanUp(false /* cleanServices */, false /* setState */);

        if (hasProcess()) {
            if (removeFromApp) {
            app.removeActivity(this, true /* keepAssociation */);
            if (!app.hasActivities()) {
                mAtmService.clearHeavyWeightProcessIfEquals(app);
@@ -2868,7 +2866,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        false /* activityChange */, true /* updateOomAdj */,
                        false /* addPendingTopUid */);
            }
            }

            boolean skipDestroy = false;

@@ -2934,7 +2931,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        + " pausing=" + stack.mPausingActivity
                        + " for reason " + reason);
            }
            return destroyImmediately(true /* removeFromApp */, reason);
            return destroyImmediately(reason);
        }
        return false;
    }
@@ -5122,7 +5119,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            if (DEBUG_STATES) Slog.v(TAG_STATES, "Stop failed; moving to STOPPED: " + this);
            setState(STOPPED, "stopIfPossible");
            if (deferRelaunchUntilPaused) {
                destroyImmediately(true /* removeFromApp */, "stop-except");
                destroyImmediately("stop-except");
            }
        }
    }
@@ -5163,7 +5160,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                clearOptionsLocked();
            } else {
                if (deferRelaunchUntilPaused) {
                    destroyImmediately(true /* removeFromApp */, "stop-config");
                    destroyImmediately("stop-config");
                    mRootWindowContainer.resumeFocusedStacksTopActivities();
                } else {
                    mRootWindowContainer.updatePreviousProcess(this);
@@ -7113,7 +7110,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            if (!attachedToProcess()) {
                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                        "Config is destroying non-running " + this);
                destroyImmediately(true /* removeFromApp */, "config");
                destroyImmediately("config");
            } else if (mState == PAUSING) {
                // A little annoying: we are waiting for this activity to finish pausing. Let's not
                // do anything now, but just flag that it needs to be restarted when done pausing.
+1 −3
Original line number Diff line number Diff line
@@ -41,10 +41,8 @@ import static android.content.pm.PackageManager.PERMISSION_DENIED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.PowerManager.PARTIAL_WAKE_LOCK;
import static android.os.Process.INVALID_UID;
import static android.os.Process.SYSTEM_UID;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.TYPE_VIRTUAL;

import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ALL;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CLEANUP;
@@ -1869,7 +1867,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        for (int i = 0; i < numFinishingActivities; i++) {
            final ActivityRecord r = finishingActivities.get(i);
            if (r.isInHistory()) {
                r.destroyImmediately(true /* removeFromApp */, "finish-" + reason);
                r.destroyImmediately("finish-" + reason);
            }
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -3379,7 +3379,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                if (r == null || !r.isDestroyable()) {
                    return false;
                }
                r.destroyImmediately(true /* removeFromApp */, "app-req");
                r.destroyImmediately("app-req");
                return r.isState(DESTROYING, DESTROYED);
            } finally {
                Binder.restoreCallingIdentity(origId);
+1 −1
Original line number Diff line number Diff line
@@ -2716,7 +2716,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                + " resumed=" + r.getStack().mResumedActivity + " pausing="
                + r.getStack().mPausingActivity + " for reason " + mDestroyAllActivitiesReason);

        r.destroyImmediately(true /* removeFromTask */, mDestroyAllActivitiesReason);
        r.destroyImmediately(mDestroyAllActivitiesReason);
    }

    // Tries to put all activity stacks to sleep. Returns true if all stacks were
+1 −1
Original line number Diff line number Diff line
@@ -941,7 +941,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
                final ActivityRecord r = candidates.remove(0);
                if (DEBUG_RELEASE) Slog.v(TAG_RELEASE, "Destroying " + r
                        + " in state " + r.getState() + " for reason " + reason);
                r.destroyImmediately(true /*removeFromApp*/, reason);
                r.destroyImmediately(reason);
                --maxRelease;
            } while (maxRelease > 0);
        }
Loading