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

Commit 766e7d73 authored by Jing Ji's avatar Jing Ji
Browse files

Do not kill process bound with WAIVE_PRIORITY / ALLOW_OOM_MANAGEMENT

...when it's cached & idle and in forced-app-standby mode, if the client
app is not cached.

Bug: 189598723
Test: atest FrameworksServicesTests:ActivityManagerTest
Test: atest FrameworksMockingServicesTests:AppStateTrackerTest
Test: Manual - make such bindings from non-cached app and verify it
Change-Id: I96e4160711cf3d29cb3fc810df505ca4dd6f8e89
parent df773665
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1573,6 +1573,7 @@ public class OomAdjuster {
        state.setAdjTarget(null);
        state.setEmpty(false);
        state.setCached(false);
        state.setNoKillOnForcedAppStandbyAndIdle(false);
        state.resetAllowStartFgsState();
        app.mOptRecord.setShouldNotFreeze(false);

@@ -2061,6 +2062,9 @@ public class OomAdjuster {
                            // Similar to BIND_WAIVE_PRIORITY, keep it unfrozen.
                            if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
                                app.mOptRecord.setShouldNotFreeze(true);
                                // Similarly, we shouldn't kill it when it's in forced-app-standby
                                // mode and cached & idle state.
                                app.mState.setNoKillOnForcedAppStandbyAndIdle(true);
                            }
                            // Not doing bind OOM management, so treat
                            // this guy more like a started service.
@@ -2265,6 +2269,9 @@ public class OomAdjuster {
                        // unfrozen.
                        if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
                            app.mOptRecord.setShouldNotFreeze(true);
                            // Similarly, we shouldn't kill it when it's in forced-app-standby
                            // mode and cached & idle state.
                            app.mState.setNoKillOnForcedAppStandbyAndIdle(true);
                        }
                    }
                    if ((cr.flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
+1 −0
Original line number Diff line number Diff line
@@ -5043,6 +5043,7 @@ public final class ProcessList {
        final UidRecord uidRec = app.getUidRecord();
        if (mService.mConstants.mKillForceAppStandByAndCachedIdle
                && uidRec != null && uidRec.isIdle()
                && !app.mState.shouldNotKillOnForcedAppStandbyAndIdle()
                && app.isCached() && app.mState.isForcedAppStandby()) {
            app.killLocked("cached idle & forced-app-standby",
                    ApplicationExitInfo.REASON_OTHER,
+17 −0
Original line number Diff line number Diff line
@@ -363,6 +363,13 @@ final class ProcessStateRecord {
    @ElapsedRealtimeLong
    private long mLastInvisibleTime;

    /**
     * Whether or not this process could be killed when it's in forced-app-standby mode
     * and cached &amp; idle state.
     */
    @GuardedBy("mService")
    private boolean mNoKillOnForcedAppStandbyAndIdle;

    // Below are the cached task info for OomAdjuster only
    private static final int VALUE_INVALID = -1;
    private static final int VALUE_FALSE = 0;
@@ -1143,6 +1150,16 @@ final class ProcessStateRecord {
        return mLastInvisibleTime;
    }

    @GuardedBy("mService")
    void setNoKillOnForcedAppStandbyAndIdle(boolean shouldNotKill) {
        mNoKillOnForcedAppStandbyAndIdle = shouldNotKill;
    }

    @GuardedBy("mService")
    boolean shouldNotKillOnForcedAppStandbyAndIdle() {
        return mNoKillOnForcedAppStandbyAndIdle;
    }

    @GuardedBy({"mService", "mProcLock"})
    void dump(PrintWriter pw, String prefix, long nowUptime) {
        if (mReportedInteraction || mFgInteractionTime != 0) {