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

Commit 104ad79d authored by Amith Yamasani's avatar Amith Yamasani Committed by Automerger Merge Worker
Browse files

Merge "Implement freezer delay broadcast option in legacy queue" into udc-dev...

Merge "Implement freezer delay broadcast option in legacy queue" into udc-dev am: d7569a80 am: a42e0e3f

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



Change-Id: I7ff500f58d13b6258d86894c133aac78ee8cbb88
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 719c2712 a42e0e3f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -19046,8 +19046,11 @@ public class ActivityManagerService extends IActivityManager.Stub
            long delayedDurationMs) {
        Objects.requireNonNull(targetPackage);
        Preconditions.checkArgumentNonnegative(delayedDurationMs);
        Preconditions.checkState(mEnableModernQueue, "Not valid in legacy queue");
        enforceCallingPermission(permission.DUMP, "forceDelayBroadcastDelivery()");
        // Ignore request if modern queue is not enabled
        if (!mEnableModernQueue) {
            return;
        }
        for (BroadcastQueue queue : mBroadcastQueues) {
            queue.forceDelayBroadcastDelivery(targetPackage, delayedDurationMs);
+18 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.am;

import static android.app.ActivityManager.RESTRICTION_LEVEL_RESTRICTED_BUCKET;
import static android.app.ActivityManagerInternal.OOM_ADJ_REASON_START_RECEIVER;
import static android.os.PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_APP_FREEZING_DELAYED;
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;
@@ -384,6 +385,16 @@ public class BroadcastQueueImpl extends BroadcastQueue {
        maybeReportBroadcastDispatchedEventLocked(r, r.curReceiver.applicationInfo.uid);
        r.intent.setComponent(r.curComponent);

        // See if we need to delay the freezer based on BroadcastOptions
        if (r.options != null
                && r.options.getTemporaryAppAllowlistDuration() > 0
                && r.options.getTemporaryAppAllowlistType()
                    == TEMPORARY_ALLOW_LIST_TYPE_APP_FREEZING_DELAYED) {
            mService.mOomAdjuster.mCachedAppOptimizer.unfreezeTemporarily(app,
                    CachedAppOptimizer.UNFREEZE_REASON_START_RECEIVER,
                    r.options.getTemporaryAppAllowlistDuration());
        }

        boolean started = false;
        try {
            if (DEBUG_BROADCAST_LIGHT) Slog.v(TAG_BROADCAST,
@@ -930,9 +941,14 @@ public class BroadcastQueueImpl extends BroadcastQueue {
            Slog.v(TAG, "Broadcast temp allowlist uid=" + uid + " duration=" + duration
                    + " type=" + type + " : " + b.toString());
        }

        // Only add to temp allowlist if it's not the APP_FREEZING_DELAYED type. That will be
        // handled when the broadcast is actually being scheduled on the app thread.
        if (type != TEMPORARY_ALLOW_LIST_TYPE_APP_FREEZING_DELAYED) {
            mService.tempAllowlistUidLocked(uid, duration, reasonCode, b.toString(), type,
                    r.callingUid);
        }
    }

    private void processNextBroadcast(boolean fromMsg) {
        synchronized (mService) {