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

Commit 682f1a9f authored by Jing Ji's avatar Jing Ji Committed by Automerger Merge Worker
Browse files

Merge "Do not kill process bound with WAIVE_PRIORITY / ALLOW_OOM_MANAGEMENT"...

Merge "Do not kill process bound with WAIVE_PRIORITY / ALLOW_OOM_MANAGEMENT" into sc-dev am: 35b2d00e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14766840

Change-Id: I82068dc0ec0b8c48cf00eab78cd27d2f5444d0b3
parents 8aac75a7 35b2d00e
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -1573,6 +1573,7 @@ public class OomAdjuster {
        state.setAdjTarget(null);
        state.setAdjTarget(null);
        state.setEmpty(false);
        state.setEmpty(false);
        state.setCached(false);
        state.setCached(false);
        state.setNoKillOnForcedAppStandbyAndIdle(false);
        state.resetAllowStartFgsState();
        state.resetAllowStartFgsState();
        app.mOptRecord.setShouldNotFreeze(false);
        app.mOptRecord.setShouldNotFreeze(false);


@@ -2061,6 +2062,9 @@ public class OomAdjuster {
                            // Similar to BIND_WAIVE_PRIORITY, keep it unfrozen.
                            // Similar to BIND_WAIVE_PRIORITY, keep it unfrozen.
                            if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
                            if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
                                app.mOptRecord.setShouldNotFreeze(true);
                                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
                            // Not doing bind OOM management, so treat
                            // this guy more like a started service.
                            // this guy more like a started service.
@@ -2265,6 +2269,9 @@ public class OomAdjuster {
                        // unfrozen.
                        // unfrozen.
                        if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
                        if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
                            app.mOptRecord.setShouldNotFreeze(true);
                            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) {
                    if ((cr.flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
+1 −0
Original line number Original line Diff line number Diff line
@@ -5043,6 +5043,7 @@ public final class ProcessList {
        final UidRecord uidRec = app.getUidRecord();
        final UidRecord uidRec = app.getUidRecord();
        if (mService.mConstants.mKillForceAppStandByAndCachedIdle
        if (mService.mConstants.mKillForceAppStandByAndCachedIdle
                && uidRec != null && uidRec.isIdle()
                && uidRec != null && uidRec.isIdle()
                && !app.mState.shouldNotKillOnForcedAppStandbyAndIdle()
                && app.isCached() && app.mState.isForcedAppStandby()) {
                && app.isCached() && app.mState.isForcedAppStandby()) {
            app.killLocked("cached idle & forced-app-standby",
            app.killLocked("cached idle & forced-app-standby",
                    ApplicationExitInfo.REASON_OTHER,
                    ApplicationExitInfo.REASON_OTHER,
+17 −0
Original line number Original line Diff line number Diff line
@@ -363,6 +363,13 @@ final class ProcessStateRecord {
    @ElapsedRealtimeLong
    @ElapsedRealtimeLong
    private long mLastInvisibleTime;
    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
    // Below are the cached task info for OomAdjuster only
    private static final int VALUE_INVALID = -1;
    private static final int VALUE_INVALID = -1;
    private static final int VALUE_FALSE = 0;
    private static final int VALUE_FALSE = 0;
@@ -1143,6 +1150,16 @@ final class ProcessStateRecord {
        return mLastInvisibleTime;
        return mLastInvisibleTime;
    }
    }


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

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

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