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

Commit 834b56e8 authored by Jing Ji's avatar Jing Ji
Browse files

Cap the LRU position of broadcast receivers in bg restricted apps

Previously receiving a broadcast will bump the receiver's position
in the LRU list; now for apps in restricted bucket or background
restricted level, receiving a broadcast won't bump its LRU position.

Bug: 200326767
Test: atest CtsAppTestCases:ActivityManagerTest
Change-Id: I45ed2fed0a807a48e0096997d0e34f4867f1a6a7
parent 627bbedd
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.am;

import static android.app.ActivityManager.RESTRICTION_LEVEL_RESTRICTED_BUCKET;
import static android.os.Process.ZYGOTE_POLICY_FLAG_EMPTY;
import static android.os.Process.ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE;
import static android.text.TextUtils.formatSimple;
@@ -316,7 +317,11 @@ public final class BroadcastQueue {
        final ProcessReceiverRecord prr = app.mReceivers;
        prr.addCurReceiver(r);
        app.mState.forceProcessStateUpTo(ActivityManager.PROCESS_STATE_RECEIVER);
        // Don't bump its LRU position if it's in the background restricted.
        if (mService.mInternal.getRestrictionLevel(app.info.packageName, app.userId)
                < RESTRICTION_LEVEL_RESTRICTED_BUCKET) {
            mService.updateLruProcessLocked(app, false, null);
        }
        // Make sure the oom adj score is updated before delivering the broadcast.
        // Force an update, even if there are other pending requests, overall it still saves time,
        // because time(updateOomAdj(N apps)) <= N * time(updateOomAdj(1 app)).