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

Commit 0e85b380 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Update delivery group policy for TIME_CHANGED and TIMEZONE_CHANGED.

Applying the DELIVERY_GROUP_POLICY_MOST_RECENT policy to TIME_CHANGED
and TIMEZONE_CHANGED broadcasts so that the older broadcasts can be
discarded when a new one comes in. Since they are already using
the FLAG_RECEIVER_REPLACE_PENDING, it should be safe to apply this
policy.

Bug: 311288757
Test: atest CtsAlarmManagerTestCases
Test: atest services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
Change-Id: Iada16830fa05d93e2a85c0a2d06ee31c0470cb4a
parent 546a73c3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2151,6 +2151,8 @@ public class AlarmManagerService extends SystemService {
                    mActivityManagerInternal.getBootTimeTempAllowListDuration(),
                    TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
                    PowerExemptionManager.REASON_TIMEZONE_CHANGED, "");
            mOptsTimeBroadcast.setDeliveryGroupPolicy(
                    BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT);
            getContext().sendBroadcastAsUser(intent, UserHandle.ALL,
                    null /* receiverPermission */, mOptsTimeBroadcast.toBundle());
        }
@@ -4596,6 +4598,8 @@ public class AlarmManagerService extends SystemService {
                                mActivityManagerInternal.getBootTimeTempAllowListDuration(),
                                TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
                                PowerExemptionManager.REASON_TIME_CHANGED, "");
                        mOptsTimeBroadcast.setDeliveryGroupPolicy(
                                BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT);
                        getContext().sendBroadcastAsUser(intent, UserHandle.ALL,
                                null /* receiverPermission */, mOptsTimeBroadcast.toBundle());
                        // The world has changed on us, so we need to re-evaluate alarms
+2 −0
Original line number Diff line number Diff line
@@ -3397,6 +3397,8 @@ public final class AlarmManagerServiceTest {
                bOptions.getTemporaryAppAllowlistType());
        assertEquals(PowerExemptionManager.REASON_TIMEZONE_CHANGED,
                bOptions.getTemporaryAppAllowlistReasonCode());
        assertEquals(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT,
                bOptions.getDeliveryGroupPolicy());
    }

    @Test