Allow direct-callback alarms for non-wakeup alarms
Turns out there are known use cases for it, in particular to avoid
interfering with doze/idle type optimizations. In addition, it is
not reliably possible to aim for a specific *wall-clock* trigger time
when posting work to a Handler, since the time base used there is
uptime rather than elapsed.
Bug 26114467
Change-Id: I7cede733fc7e09704b63dfe3e98b00365bbdff35
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index 960fb4b..5f57a76 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -1233,14 +1233,6 @@
}
}
- // direct-callback alarms must be wakeup alarms (otherwise they should just be
- // posting work to a Handler)
- if (directReceiver != null) {
- if (type != RTC_WAKEUP && type != ELAPSED_REALTIME_WAKEUP) {
- throw new IllegalArgumentException("Only wakeup alarms can use AlarmReceivers");
- }
- }
-
if (workSource != null) {
getContext().enforcePermission(
android.Manifest.permission.UPDATE_DEVICE_STATS,