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

Commit d7569a80 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

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

parents 39d50e4d f6f23bff
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -19037,8 +19037,11 @@ public class ActivityManagerService extends IActivityManager.Stub
            long delayedDurationMs) {
            long delayedDurationMs) {
        Objects.requireNonNull(targetPackage);
        Objects.requireNonNull(targetPackage);
        Preconditions.checkArgumentNonnegative(delayedDurationMs);
        Preconditions.checkArgumentNonnegative(delayedDurationMs);
        Preconditions.checkState(mEnableModernQueue, "Not valid in legacy queue");
        enforceCallingPermission(permission.DUMP, "forceDelayBroadcastDelivery()");
        enforceCallingPermission(permission.DUMP, "forceDelayBroadcastDelivery()");
        // Ignore request if modern queue is not enabled
        if (!mEnableModernQueue) {
            return;
        }
        for (BroadcastQueue queue : mBroadcastQueues) {
        for (BroadcastQueue queue : mBroadcastQueues) {
            queue.forceDelayBroadcastDelivery(targetPackage, delayedDurationMs);
            queue.forceDelayBroadcastDelivery(targetPackage, delayedDurationMs);
+18 −2
Original line number Original line 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.ActivityManager.RESTRICTION_LEVEL_RESTRICTED_BUCKET;
import static android.app.ActivityManagerInternal.OOM_ADJ_REASON_START_RECEIVER;
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_EMPTY;
import static android.os.Process.ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE;
import static android.os.Process.ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE;
import static android.text.TextUtils.formatSimple;
import static android.text.TextUtils.formatSimple;
@@ -384,6 +385,16 @@ public class BroadcastQueueImpl extends BroadcastQueue {
        maybeReportBroadcastDispatchedEventLocked(r, r.curReceiver.applicationInfo.uid);
        maybeReportBroadcastDispatchedEventLocked(r, r.curReceiver.applicationInfo.uid);
        r.intent.setComponent(r.curComponent);
        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;
        boolean started = false;
        try {
        try {
            if (DEBUG_BROADCAST_LIGHT) Slog.v(TAG_BROADCAST,
            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
            Slog.v(TAG, "Broadcast temp allowlist uid=" + uid + " duration=" + duration
                    + " type=" + type + " : " + b.toString());
                    + " 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,
            mService.tempAllowlistUidLocked(uid, duration, reasonCode, b.toString(), type,
                    r.callingUid);
                    r.callingUid);
        }
        }
    }


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