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

Commit 8b4a771b authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Log a bit to differentiate PendingIntent and callback alarms

Before this change, only PendingIntent alarms were tracked for scheduling.
Add a boolean is_listener field in the atom so we can know if an alarm
scheduled is with PendingIntent or an IAlarmListener.

Test: atest FrameworksMockingServicesTests:AlarmManagerServiceTest
Test: atest CtsStatsdAtomHostTestCases:AlarmStatsTest


Flag: EXEMPT metrics only change

Bug: 274001514
Change-Id: Ied8beacff47c5b3efaa6285a0c2f119fe167c166
parent c6c40848
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ class MetricsHelper {
                a.repeatInterval != 0,
                reasonToStatsReason(a.exactAllowReason),
                AlarmManagerService.isRtc(a.type),
                ActivityManager.processStateAmToProto(callerProcState));
                ActivityManager.processStateAmToProto(callerProcState),
                a.listener != null);
    }

    static void pushAlarmBatchDelivered(
+13 −4
Original line number Diff line number Diff line
@@ -3482,11 +3482,20 @@ public final class AlarmManagerServiceTest {

    @Test
    public void alarmScheduledAtomPushed() {
        for (int i = 0; i < 10; i++) {
            final PendingIntent pi = getNewMockPendingIntent();
        for (int i = 0; i < 20; i++) {
            final PendingIntent pi;
            final IAlarmListener listener;
            if (i % 2 == 0) {
                pi = null;
                listener = getNewListener(() -> {});
                setTestAlarmWithListener(ELAPSED_REALTIME, mNowElapsedTest + i, listener);
            } else {
                pi = getNewMockPendingIntent();
                listener = null;
                setTestAlarm(ELAPSED_REALTIME, mNowElapsedTest + i, pi);
            }

            verify(() -> MetricsHelper.pushAlarmScheduled(argThat(a -> a.matches(pi, null)),
            verify(() -> MetricsHelper.pushAlarmScheduled(argThat(a -> a.matches(pi, listener)),
                    anyInt()));
        }
    }