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

Commit b8b57540 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 am: d7569a80

parents 3a97e72d d7569a80
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -19044,8 +19044,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) {