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

Commit 85ca9dfd authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "freezer: don't freeze WPRI-bound apps" into rvc-dev am: 945984e2 am:...

Merge "freezer: don't freeze WPRI-bound apps" into rvc-dev am: 945984e2 am: 9263643d am: db70d311

Change-Id: I5819fd81c4ad4d9525a8eb5538c49825984ae5d2
parents 1a8541bc db70d311
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -911,10 +911,12 @@ public final class CachedAppOptimizer {
                pid = proc.pid;
                pid = proc.pid;
                name = proc.processName;
                name = proc.processName;


                if (proc.curAdj <= ProcessList.CACHED_APP_MIN_ADJ) {
                if (proc.curAdj < ProcessList.CACHED_APP_MIN_ADJ
                        || proc.shouldNotFreeze) {
                    if (DEBUG_FREEZER) {
                    if (DEBUG_FREEZER) {
                        Slog.d(TAG_AM, "Skipping freeze for process " + pid
                        Slog.d(TAG_AM, "Skipping freeze for process " + pid
                                + " " + name + " (not cached)");
                                + " " + name + " curAdj = " + proc.curAdj
                                + ", shouldNotFreeze = " + proc.shouldNotFreeze);
                    }
                    }
                    return;
                    return;
                }
                }
+27 −12
Original line number Original line Diff line number Diff line
@@ -1109,6 +1109,7 @@ public final class OomAdjuster {
        app.adjTarget = null;
        app.adjTarget = null;
        app.empty = false;
        app.empty = false;
        app.setCached(false);
        app.setCached(false);
        app.shouldNotFreeze = false;


        final int appUid = app.info.uid;
        final int appUid = app.info.uid;
        final int logUid = mService.mCurOomAdjUid;
        final int logUid = mService.mCurOomAdjUid;
@@ -1542,7 +1543,7 @@ public final class OomAdjuster {
                    }
                    }


                    boolean trackedProcState = false;
                    boolean trackedProcState = false;
                    if ((cr.flags& Context.BIND_WAIVE_PRIORITY) == 0) {

                    ProcessRecord client = cr.binding.client;
                    ProcessRecord client = cr.binding.client;
                    if (computeClients) {
                    if (computeClients) {
                        computeOomAdjLocked(client, cachedAdj, topApp, doingAll, now,
                        computeOomAdjLocked(client, cachedAdj, topApp, doingAll, now,
@@ -1552,13 +1553,14 @@ public final class OomAdjuster {
                        client.setCurRawProcState(client.setProcState);
                        client.setCurRawProcState(client.setProcState);
                    }
                    }


                    int clientAdj = client.getCurRawAdj();
                    int clientProcState = client.getCurRawProcState();

                    if ((cr.flags & Context.BIND_WAIVE_PRIORITY) == 0) {
                        if (shouldSkipDueToCycle(app, client, procState, adj, cycleReEval)) {
                        if (shouldSkipDueToCycle(app, client, procState, adj, cycleReEval)) {
                            continue;
                            continue;
                        }
                        }


                        int clientAdj = client.getCurRawAdj();
                        int clientProcState = client.getCurRawProcState();

                        if (clientProcState == PROCESS_STATE_FOREGROUND_SERVICE) {
                        if (clientProcState == PROCESS_STATE_FOREGROUND_SERVICE) {
                            procStateFromFGSClient = true;
                            procStateFromFGSClient = true;
                        }
                        }
@@ -1762,6 +1764,19 @@ public final class OomAdjuster {
                                        + ProcessList.makeProcStateString(procState));
                                        + ProcessList.makeProcStateString(procState));
                            }
                            }
                        }
                        }
                    } else { // BIND_WAIVE_PRIORITY == true
                        // BIND_WAIVE_PRIORITY bindings are special when it comes to the
                        // freezer. Processes bound via WPRI are expected to be running,
                        // but they are not promoted in the LRU list to keep them out of
                        // cached. As a result, they can freeze based on oom_adj alone.
                        // Normally, bindToDeath would fire when a cached app would die
                        // in the background, but nothing will fire when a running process
                        // pings a frozen process. Accordingly, any cached app that is
                        // bound by an unfrozen app via a WPRI binding has to remain
                        // unfrozen.
                        if (clientAdj < ProcessList.CACHED_APP_MIN_ADJ) {
                            app.shouldNotFreeze = true;
                        }
                    }
                    }
                    if ((cr.flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
                    if ((cr.flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
                        app.treatLikeActivity = true;
                        app.treatLikeActivity = true;
+1 −0
Original line number Original line Diff line number Diff line
@@ -167,6 +167,7 @@ class ProcessRecord implements WindowProcessListener {
    int lastCompactAction;      // The most recent compaction action performed for this app.
    int lastCompactAction;      // The most recent compaction action performed for this app.
    boolean frozen;             // True when the process is frozen.
    boolean frozen;             // True when the process is frozen.
    long freezeUnfreezeTime;    // Last time the app was (un)frozen, 0 for never
    long freezeUnfreezeTime;    // Last time the app was (un)frozen, 0 for never
    boolean shouldNotFreeze;    // True if a process has a WPRI binding from an unfrozen process
    private int mCurSchedGroup; // Currently desired scheduling class
    private int mCurSchedGroup; // Currently desired scheduling class
    int setSchedGroup;          // Last set to background scheduling class
    int setSchedGroup;          // Last set to background scheduling class
    int trimMemoryLevel;        // Last selected memory trimming level
    int trimMemoryLevel;        // Last selected memory trimming level