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

Commit 5e68ab19 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Resolve requested deferral policy based on caller.

Since there's going to be a very long-tail of broadcasts from the OS
sent to apps that we should mark as "defer until active", support the
ability to let a sender force a given policy, otherwise fall back to
reasonable defaults.

To mitigate risk of this CL landing, we're merging this as disabled,
and will enable in a future CL.

Also cleans up remaining internal usages of deprecated APIs.

Bug: 267646347
Test: treehugger
Change-Id: Ib024eabff2a0493507523336e3d0aac8adc325f7
parent f21ef1de
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2625,7 +2625,7 @@ public class DeviceIdleController extends SystemService

                final Bundle mostRecentDeliveryOptions = BroadcastOptions.makeBasic()
                        .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
                        .setDeferUntilActive(true)
                        .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                        .toBundle();

                mIdleIntent = new Intent(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
+1 −1
Original line number Diff line number Diff line
@@ -1948,7 +1948,7 @@ public class AlarmManagerService extends SystemService {
                            | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
            mTimeTickOptions = BroadcastOptions.makeBasic()
                    .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
                    .setDeferUntilActive(true)
                    .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                    .toBundle();
            mTimeTickTrigger = new IAlarmListener.Stub() {
                @Override
+3 −3
Original line number Diff line number Diff line
@@ -194,19 +194,19 @@ public final class BatteryService extends SystemService {

    private Bundle mBatteryChangedOptions = BroadcastOptions.makeBasic()
            .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
            .setDeferUntilActive(true)
            .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
            .toBundle();
    /** Used for both connected/disconnected, so match using key */
    private Bundle mPowerOptions = BroadcastOptions.makeBasic()
            .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
            .setDeliveryGroupMatchingKey("android", Intent.ACTION_POWER_CONNECTED)
            .setDeferUntilActive(true)
            .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
            .toBundle();
    /** Used for both low/okay, so match using key */
    private Bundle mBatteryOptions = BroadcastOptions.makeBasic()
            .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
            .setDeliveryGroupMatchingKey("android", Intent.ACTION_BATTERY_OKAY)
            .setDeferUntilActive(true)
            .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
            .toBundle();

    private MetricsLogger mMetricsLogger;
+1 −1
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ public final class DropBoxManagerService extends SystemService {
                    .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MERGED)
                    .setDeliveryGroupMatchingFilter(matchingFilter)
                    .setDeliveryGroupExtrasMerger(extrasMerger)
                    .setDeferUntilActive(true)
                    .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                    .toBundle();
        }

+0 −12
Original line number Diff line number Diff line
@@ -14507,18 +14507,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        // resultTo broadcasts are always infinitely deferrable.
        if ((resultTo != null) && !ordered && mEnableModernQueue) {
            if (brOptions == null) {
                brOptions = BroadcastOptions.makeBasic();
            }
            brOptions.setDeferUntilActive(true);
        }
        if (mEnableModernQueue && ordered && brOptions != null && brOptions.isDeferUntilActive()) {
            throw new IllegalArgumentException("Ordered broadcasts can't be deferred until active");
        }
        // Verify that protected broadcasts are only being sent by system code,
        // and that system code is only sending protected broadcasts.
        final boolean isProtectedBroadcast;
Loading