Loading apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -2895,7 +2895,11 @@ public class AlarmManagerService extends SystemService { } else { } else { needsPermission = false; needsPermission = false; lowerQuota = allowWhileIdle; lowerQuota = allowWhileIdle; idleOptions = allowWhileIdle ? mOptsWithFgs.toBundle() : null; idleOptions = (allowWhileIdle || (alarmClock != null)) // This avoids exceptions on existing alarms when the app upgrades to // target S. Note that FGS from pre-S apps isn't restricted anyway. ? mOptsWithFgs.toBundle() : null; if (exact) { if (exact) { exactAllowReason = EXACT_ALLOW_REASON_COMPAT; exactAllowReason = EXACT_ALLOW_REASON_COMPAT; } } Loading services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -2357,10 +2357,15 @@ public class AlarmManagerServiceTest { mBinder.set(TEST_CALLING_PACKAGE, RTC_WAKEUP, 1234, WINDOW_EXACT, 0, 0, mBinder.set(TEST_CALLING_PACKAGE, RTC_WAKEUP, 1234, WINDOW_EXACT, 0, 0, alarmPi, null, null, null, alarmClock); alarmPi, null, null, null, alarmClock); final ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class); verify(mService).setImpl(eq(RTC_WAKEUP), eq(1234L), eq(WINDOW_EXACT), eq(0L), verify(mService).setImpl(eq(RTC_WAKEUP), eq(1234L), eq(WINDOW_EXACT), eq(0L), eq(alarmPi), isNull(), isNull(), eq(FLAG_STANDALONE | FLAG_WAKE_FROM_IDLE), eq(alarmPi), isNull(), isNull(), eq(FLAG_STANDALONE | FLAG_WAKE_FROM_IDLE), isNull(), eq(alarmClock), eq(TEST_CALLING_UID), eq(TEST_CALLING_PACKAGE), isNull(), isNull(), eq(alarmClock), eq(TEST_CALLING_UID), eq(TEST_CALLING_PACKAGE), eq(EXACT_ALLOW_REASON_COMPAT)); bundleCaptor.capture(), eq(EXACT_ALLOW_REASON_COMPAT)); final BroadcastOptions idleOptions = new BroadcastOptions(bundleCaptor.getValue()); final int type = idleOptions.getTemporaryAppAllowlistType(); assertEquals(TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, type); } } @Test @Test Loading Loading
apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -2895,7 +2895,11 @@ public class AlarmManagerService extends SystemService { } else { } else { needsPermission = false; needsPermission = false; lowerQuota = allowWhileIdle; lowerQuota = allowWhileIdle; idleOptions = allowWhileIdle ? mOptsWithFgs.toBundle() : null; idleOptions = (allowWhileIdle || (alarmClock != null)) // This avoids exceptions on existing alarms when the app upgrades to // target S. Note that FGS from pre-S apps isn't restricted anyway. ? mOptsWithFgs.toBundle() : null; if (exact) { if (exact) { exactAllowReason = EXACT_ALLOW_REASON_COMPAT; exactAllowReason = EXACT_ALLOW_REASON_COMPAT; } } Loading
services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -2357,10 +2357,15 @@ public class AlarmManagerServiceTest { mBinder.set(TEST_CALLING_PACKAGE, RTC_WAKEUP, 1234, WINDOW_EXACT, 0, 0, mBinder.set(TEST_CALLING_PACKAGE, RTC_WAKEUP, 1234, WINDOW_EXACT, 0, 0, alarmPi, null, null, null, alarmClock); alarmPi, null, null, null, alarmClock); final ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class); verify(mService).setImpl(eq(RTC_WAKEUP), eq(1234L), eq(WINDOW_EXACT), eq(0L), verify(mService).setImpl(eq(RTC_WAKEUP), eq(1234L), eq(WINDOW_EXACT), eq(0L), eq(alarmPi), isNull(), isNull(), eq(FLAG_STANDALONE | FLAG_WAKE_FROM_IDLE), eq(alarmPi), isNull(), isNull(), eq(FLAG_STANDALONE | FLAG_WAKE_FROM_IDLE), isNull(), eq(alarmClock), eq(TEST_CALLING_UID), eq(TEST_CALLING_PACKAGE), isNull(), isNull(), eq(alarmClock), eq(TEST_CALLING_UID), eq(TEST_CALLING_PACKAGE), eq(EXACT_ALLOW_REASON_COMPAT)); bundleCaptor.capture(), eq(EXACT_ALLOW_REASON_COMPAT)); final BroadcastOptions idleOptions = new BroadcastOptions(bundleCaptor.getValue()); final int type = idleOptions.getTemporaryAppAllowlistType(); assertEquals(TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, type); } } @Test @Test Loading