summaryrefslogtreecommitdiff
path: root/core/java/android/app/AlarmManager.java
Commit message (Collapse)AuthorAgeFilesLines
* Move AlarmManager to apexSuprabh Shukla2020-05-191-1158/+0
| | | | | | | | | | | | | | | Mechanical refactoring to move all except native code to the apex directory. Accesses across the jar boundary will be cleaned up in follow-ups. Also, moved alarm manager code into its own package for better organization. Test: Buids, boots. Existing tests: atest FrameworksMockingServicesTests:AlarmManagerServiceTest atest CtsAlarmManagerTestCases Bug: 151976605 Change-Id: Ida46491c1f1dff02dce4c50d3fafd4efbf977766
* Don't remove OnAlarmListener mappings in the clientSuprabh Shukla2020-04-281-22/+20
| | | | | | | | | | | | | Removing the mapping is prone to races in keeping the state consistent with the server. An inconsistent state can lead to multiple alarms on the server for the same listener. Test: atest CtsJobSchedulerTestCases doesn't fill the alarm queue with more than one alarm. atest CtsAlarmManagerTestCases Bug: 154444435 Change-Id: Iaf11d5decb17fbf2366b49d9865231bf65dbdc41
* Merge "Rename ZoneInfoDB -> ZoneInfoDb" am: 402674f2a0 am: c3e31d6ac5 am: ↵Automerger Merge Worker2020-01-291-2/+2
|\ | | | | | | | | | | f8a4287915 Change-Id: I72978765010e3da52bcdf00299f7ba999bc9201b
| * Rename ZoneInfoDB -> ZoneInfoDbNeil Fuller2020-01-281-2/+2
| | | | | | | | | | | | | | | | Rename ZoneInfoDB -> ZoneInfoDb to conform with coding standards. Bug: 148086409 Test: treehugger Change-Id: I2a5eca6bd013d3ca2ba93aabf36745f8873fc6fb
| * Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-091-1/+1
| | | | | | | | | | | | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I8789f8499d4dca08580672e9e45ed9a7026dd686 Merged-In: I8789f8499d4dca08580672e9e45ed9a7026dd686
* | Use new UnsupportedAppUsage annotation.Artur Satayev2019-12-181-1/+1
| | | | | | | | | | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I8789f8499d4dca08580672e9e45ed9a7026dd686
* | Rename writeToProto to be dumpDebugJeffrey Huang2019-12-051-2/+2
|/ | | | | | | | | We want to eventually migrate some of these APIs to be @SystemApi for mainline modules. The #dumpDebug name is more appropriate than #writeToProto. Bug: 142279786 Test: Manual Change-Id: I60793e91cedf6b720d4ecef6a8484f4fed4ff30f
* All Parcelable CREATOR fields are @NonNull.Jeff Sharkey2019-02-281-1/+1
| | | | | | | | | If they were null, then the Parcelable would fail to work. Bug: 126726802 Test: manual Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014 Exempt-From-Owner-Approval: Trivial API annotations
* Merge "Track move of timezone classes to libcore.timezone" am: d48dbc9a34 ↵Neil Fuller2018-11-281-1/+1
|\ | | | | | | | | | | | | | | am: f79ecf7c82 am: 402dc485d0 Change-Id: If9c8cfdce9bd0b3bcd460216edca369fd75abdde
| * Track move of timezone classes to libcore.timezoneNeil Fuller2018-11-271-1/+1
| | | | | | | | | | | | | | | | | | Some time zone related libcore classes are moving from libcore.util to libcore.timezone. Bug: 119026403 Test: build only Change-Id: Ic807977a85276b888362295d1d305effe33076fc
| * Avoiding potential NPE when dumping to proto.Kweku Adams2018-09-111-2/+3
| | | | | | | | | | | | | | | | Inspired by aosp/736453. Cherry-picked from ag/4934453 Bug: 113087610 Test: Android builds Change-Id: I9f0dae9cd5a839947c7ed150980eb30b928beef7
| * Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For packages: android.app.usage android.app.trust android.app.timezonedetector android.app.timezone android.app.timedetector android.app.job android.app.backup android.app.assist android.app.admin android.app This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I5d15d50344d7178617418846917f693cfabf006b Merged-In: I618c5dc4462ae990d9df45c3e9ed3f092cc5138c
* | Avoiding potential NPE when dumping to proto.Kweku Adams2018-09-041-1/+3
| | | | | | | | | | | | | | | | Inspired by http://aosp/736453. Bug: 113087610 Test: Android builds Change-Id: I9f0dae9cd5a839947c7ed150980eb30b928beef7
* | Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For packages: android.app.usage android.app.trust android.app.timezonedetector android.app.timezone android.app.timedetector android.app.job android.app.backup android.app.assist android.app.admin android.app This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I618c5dc4462ae990d9df45c3e9ed3f092cc5138c
* | Annotate methods with SET_TIME and SET_TIME_ZONE.Jeff Sharkey2018-06-111-1/+2
|/ | | | | | Bug: 79583362 Test: manual Change-Id: Ic38cf49e9428917b7879d486f4a919970a2259cd
* Pass in the user defined by Context.Jeff Sharkey2018-02-031-1/+3
| | | | | | | | | | | | | | | The majority of Manager-style classes already use Context.getUserId() when making calls into the OS, so clean up the remaining callers to unify behind this strategy. This gives @SystemApi developers a nice clean interface to interact across user boundaries, instead of manually adding "AsUser" or "ForUser" method variants, which would quickly become unsustainable. Test: builds, boots Bug: 72863821 Exempt-From-Owner-Approval: trivial changes Change-Id: Ib772ec4438e57a2ad4950821b9432f9842998451
* Fix issue #23820845: Update AlarmManager.setAlarmClock() documentation...Dianne Hackborn2017-12-051-5/+17
| | | | | | | | ...to note interactions with idle mode / doze Test: made docs Bug: 23820845 Change-Id: I2d17fd53bc662e0fc4c597b64bf38f155d197bee
* incidentd: Adding proto dump for AlarmManager.Kweku Adams2017-10-231-7/+16
| | | | | | Test: flash device and check incident.proto output. Bug: 65750801 Change-Id: If1e42c70908a0b11358cf48766c028e37c0329ae
* Fix #62350081 - annotate permission requirementsChristopher Tate2017-06-051-0/+3
| | | | | | | | | The Alarm Manager APIs that allow callers to ascribe wakelock time to other apps are gated on the UPDATE_DEVICE_STATS permission. Document this with the appropriate annotation. Test: N/A Change-Id: Idf5548089fb7d2235139ae8ba7bf58e7f455eb33
* Annotate @SystemApi with required permissions.Jeff Sharkey2017-06-051-5/+2
| | | | | | | | | | | | | | | | | Most @SystemApi methods should be protected with system (or higher) permissions, so annotate common methods with @RequiresPermission to make automatic verification easier. Verification is really only relevant when calling into system services (where permissions checking can happen on the other side of a Binder call), so annotate managers with the new @SystemService annotation, which is now automatically documented. This is purely a docs change; no logic changes are being made. Test: make -j32 update-api && make -j32 offline-sdk-docs Bug: 62263906 Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
* Fix frozen alarm issueMakoto Onuki2017-05-041-4/+5
| | | | | | | Bug 34724174 Test: Manual test with "dumpsys alarm" + putting device into doze Change-Id: I1d9ec3ac1e78ea263b2598a8c7ab4157ec40c535
* Even more auto-doc work.Jeff Sharkey2017-04-241-38/+48
| | | | | | | | | | Update docs based on what new lint detector found. Add new @IntDef to parameters or methods returning constants or flags, and add @RequiresPermission to methods mentioning permissions. Test: make -j32 offline-sdk-docs Bug: 37526420 Change-Id: I7f640f7883fcb66b911a52ae93b83f77306571ec
* Merge "Work on issue #28942589: Tune job scheduler" into nyc-devDianne Hackborn2016-06-011-0/+16
|\
| * Work on issue #28942589: Tune job schedulerDianne Hackborn2016-05-311-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now have a new settings key that provides all of the existing tuning parameters, plus some newly redone ones for dealing with different memory levels. Changed the minimum batching for overall jobs from 2 to 1, so we will never get in the way of immediately scheduling jobs when the developer asks for this. We should now be able to rely on the doze modes to do better batching of jobs for us when it is really important. Also work on issue #28981330: Excessive JobScheduler wakeup alarms. Use a work source with scheduled alarms to blame them on the app whose job they are being scheduled for, and add a check for whether a job's timing constraint has been satisfied before considering it a possible candidate for the next alarm. (If it is satisified, the time is in the past, so we should not schedule an alarm for it.) Finally clean up a bunch of the dumpsys output to make it easier to understand. Change-Id: I06cf2c1310448f47cf386f393e9b267335fabaeb
* | Don't bother with WeakHashMap for direct alarm bookkeepingChristopher Tate2016-05-311-3/+3
|/ | | | | | | | | Call cancel() explicitly before dropping local references to your callback objects; they won't just quietly go away. Bug 28987260 Change-Id: Id9da66ed86a46b4fb38127e2ddd7a7d84fd2313a
* Don't worry about an extra weak indirection with callback alarmsChristopher Tate2016-04-211-19/+7
| | | | | | Bug 27995384 Change-Id: Ie9cf3e05dca4af7085b479fb65d4cf45ee0239ba
* Fix NPE in AlarmManager.cancel(...)Joe LaPenna2016-04-011-4/+6
| | | | | | | | | | | | If AlarmManager.cancel is called before any component has had a chance to register an alarm, sWrappers will not have been set, as it is only initialized in setImpl. When cancelling an alarm and sWrappers does not exist, log a warning and return early. BUG: 27972657 Change-Id: Ied10719ba1d154f97eecfc32f429fd9ce39bf747
* Fix issue #27653326: Sync doesn't work in doze maintenanceDianne Hackborn2016-03-181-3/+4
| | | | | | | | | | | | | Add a (configurable) delay between when we start a maintenance window until the minimum time we will end it. Also switch to using the alarm manager callback API. (Yay!) Also fix a little printing problem in the alarm manager dump so we put the package name and not some class hash in the summary string of an alarm entry. Change-Id: I4281e5c80bc8b26ebc1fb6f603ec33ec0e379daa
* Improve AlarmManager docsChristopher Tate2016-03-091-5/+15
| | | | | | | | | In particular, add some missing information about what getNextAlarmClock() returns. Bug 27562400 Change-Id: I8c76b0c4208082d4da8ea490518e023584da6440
* When system server goes down, crash apps more.Jeff Sharkey2016-03-011-2/+7
| | | | | | | | | | | | | Apps making calls into the system server may end up persisting internal state or making security decisions based on the perceived success or failure of a call, or the default values returned. The reality is that if the system process just died, init will be along shortly to kill all running apps, so we should have no problem rethrowing the RemoteException as a RuntimeException. Bug: 27364859 Change-Id: Ife0bcb079636c88d54c44d17eb580409fd79028b
* Relax null parameter enforcement for legacy appsChristopher Tate2015-12-021-4/+9
| | | | | | | | | No longer throws when calling cancel() with a null PendingIntent if the app targets SDK < NYC. Bug 25798631 Change-Id: Ic91f42808811645b01802abcc785f4218aac0e8b
* Make WorkSource version of alarm listener API @SystemApiChristopher Tate2015-11-041-1/+1
| | | | | | | WorkSource is not public API but this should be available to system support modules. Change-Id: I7283ab8aa5c5e298959d21a5c8fe55ed119bc6a3
* Introduce direct listener API for alarm deliveryChristopher Tate2015-10-301-17/+242
| | | | | | | | | | | | | | | | | | | | | | | | | | | The Alarm Manager now supports a set() variant that takes a listener callback to invoke at alarm trigger time rather than a PendingIntent. This is much lower overhead and has guaranteed low delivery latency from the trigger time. The tradeoff is that the app must be running *continuously* from the time the alarm is set to the time it is delivered. If the app exits for any reason before the alarm fires, the listener becomes invalid and the alarm will be dropped. This is more or less equivalent to setting an alarm with a broadcast PendingIntent that matches only a runtime-registered receiver. The app's alarm listener can be any object that implements the new AlarmManager.OnAlarmListener interface and implements its onAlarm() method. There is no data delivered at alarm trigger time: whatever state needs to be associated with the specific alarm instance should simply be packaged inside the OnAlarmListener instance. An alarm using OnAlarmListener can request that the onAlarm() method be called on an arbitrary handler. If the program passes 'null' for this parameter when setting the alarm, the callback occurs on the application's main Looper thread. Bug 20157436 Change-Id: I2eb030a24efdd466a2eee1666c5231201b43684b
* am bc2a8843: am b97c5ddd: am 9b36f526: am c1836bb0: Merge "Change MNC ↵Dianne Hackborn2015-08-011-1/+1
|\ | | | | | | | | | | | | codename to just M." into mnc-dev * commit 'bc2a88431e3dc51e2245cc28e327f11d0c78bd56': Change MNC codename to just M.
| * Change MNC codename to just M.Dianne Hackborn2015-07-291-1/+1
| | | | | | | | Change-Id: I4281d200ff6560791c47cf9073ceea1cb509361e
* | am 04efda69: am 6b335380: am 47306086: am a681d7d9: Merge "Improve alarm ↵Dianne Hackborn2015-07-101-10/+16
|\| | | | | | | | | | | | | manager docs." into mnc-dev * commit '04efda693713243a47afb193ae389d5d36ff5dfa': Improve alarm manager docs.
| * Improve alarm manager docs.Dianne Hackborn2015-07-091-10/+16
| | | | | | | | Change-Id: I7547b48327a709783d908509efc7afd1a3f1a06a
* | am 6e2fb78f: am e554cc96: Merge "Implement some control over ↵Dianne Hackborn2015-06-121-1/+22
|\| | | | | | | | | | | | | ALLOW_WHILE_IDLE alarms." into mnc-dev * commit '6e2fb78fbe3ce50182f0ad928748aeada57a44cf': Implement some control over ALLOW_WHILE_IDLE alarms.
| * Implement some control over ALLOW_WHILE_IDLE alarms.Dianne Hackborn2015-06-121-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since these alarms allow you to bypass the idle restrictions, we don't want them to be so open-ended like other alarms. This implements a policy where the alarm manager will only deliver these types of alarms every X minutes to each application. For this initial implementation, X is 1 minute under normal operation and 15 minutes when in idle mode. To do this, I needed to introduce a new internal allow-while-idle flag for system alarms, which applications can't get, and doesn't have these new restrictions. Also tweaked how the alarm manager handles the alarm window, so it doesn't change if the alarm gets rescheduld; the window is now always what as computed based on the time when the alarm was first given to it. Finally, fix TimeUtils to be able to correctly print times that are > 999 days. Change-Id: Ibad8c6a7c14b0624b54e82267be23224b4c31e84
* | am 7b566da5: Merge "AlarmClockInfo: fix redundant word in doc comment"Chris Tate2015-05-141-1/+1
|\ \ | |/ |/| | | | | * commit '7b566da55afad480622c328d658f0e654019688d': AlarmClockInfo: fix redundant word in doc comment
| * AlarmClockInfo: fix redundant word in doc commentShuhrat Dehkanov2015-05-141-1/+1
| | | | | | | | | | | | | | Removed one of unintentional double "intent"s. Change-Id: I0ce4224964afae0587ce55b6b4775370eff89d26 Signed-off-by: Shuhrat Dehkanov <k@efir.uz>
* | Implement device idle in power manager.Dianne Hackborn2015-05-111-5/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When in device idle mode, we now prevent most apps from being able to hold partial wake locks. The device idle controller now pushes its white list of app uids into the power manager, so it can apply this policy correctly to only apps that are not whitelisted. The implementation adds a new "disabled" flag to a wake lock which is set when we want to apply this policy. When set, we ensure that we tell battery stats that the wake lock is not being held and ignore that wake lock when computing the power state summary. Also add new SDK APIs to schedule alarms that are allowed to execute while in idle mode. Finally add new dumpsys commands to the device idle controller to completely disable and re-enable its operation, to use for testing. Change-Id: I1f16672c6ac06d03bb538f9854d5843db9aa6f27
* | AlarmManager: Reject non-olson timezones for targetSdk >= MNarayan Kamath2015-05-011-6/+37
| | | | | | | | | | | | | | | | | | | | | | This has caused a lot of grief, confusion and outright broken behaviour due to the fact that the Posix spec and the Java spec define conflicting interpretations of "custom" timezones like GMT+5:30 (eastern hemisphere for java, western for posix). bug: 19987403 bug: 19106773 Change-Id: Ia9b007067bb175b0805d4262f17390a0bd98d927
* | Work on issue #20401752: device idle and alarms.Dianne Hackborn2015-04-211-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Main change is to fix problems in the alarm manager where it was not doing a good job at scheduling the device idle wakeup before an alarm. To fix this, we now keep explicit track of the next "wake from idle" alarm so we can consistently use that to adjust the time of the device idle alarm if needed. Also a bunch of debugging stuff to help further diagnose this problem: - Alarm summary now includes the last time the alarm went off. - Improved dumpsys output of alarms. - New event log tags for changes related to idle state. Change-Id: Idd2c8d24ae23379f7c75815ddbc6835c2a04656c
* | More work on device idle mode and other power stuff.Dianne Hackborn2015-04-091-9/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add idle mode support to the alarm manager. Introduce a new concept of flags associated with alarms to tell the alarm manager how to treat the alarm -- they allow everything from the alarm that will bring us out of idle mode, to alarms that are allowed when idle or should also bring us out of idle. The standalone boolean is now also a flag. (Note there is currently no protection from user space setting the flags however it wants; I will be working on that in a follow-up change.) When in idle mode, the alarm manager pushes all alarms that shouldn't execute during that time over to a separate list that is not executed until out of idle. To help with this, I reworked a bit how Alarm objects are managed, so that when rebatching or moving between lists we don't have to allocated new objects but can just use the same existing instance. Also tweaked the sync manager to deal with idle mode, which currently just means doing the same thing as when low on storage -- turning off sync. Add new ACTION_CHARGING and ACTION_DISCHARGING broadcasts that apps can listen for to know when the device is actively charging and discharging. These are better than the old POWER_CONNECTED and POWER_DISCONNECTED ones because we only report charging when we actually see that there is enough power being provided to charge the battery (and will report discharging if there is not enough power). The job controller uses these new actions for scheduling jobs that want to run while plugged in. Removed the "stable charging" stuff while doing so, since the new charging state serves as an even better signal for that. Introduced two new process states: FOREGROUND_SERVICE and TOP_SLEEPING. This will allow us to treat foreground services specially (such as still allowing network access to them for background music playback) while not mixing them together with whatever happens to be the top activity while the device is asleep. Also some other small cleanup here and there. Change-Id: I7a9808b578bad6f50deb8e1baf919298512a0d3a
* | Remove unused imports in frameworks/base.John Spurlock2015-02-281-1/+0
|/ | | | Change-Id: I031443de83f93eb57a98863001826671b18f3b17
* Add @SystemApi annotations to methods used by GmsCore.David Christie2014-09-041-0/+2
| | | | | | -Currently these methods are called using reflection for location. Bug: 17371392 Change-Id: I6546f5b485415beff69164ba0d526757ee831f69
* Made AlarmClockInfo a nested class in AlarmManagerJose Lima2014-08-141-0/+84
| | | | | Bug: 16959028 Change-Id: I150eaaff765d1e214c3621c1bf50162ec0dac8ec
* Add AlarmClock API to AlarmManagerAdrian Roos2014-07-101-8/+81
| | | | | | | | | Adds a new kind of alarm that represents an alarm clock and a way to query the next scheduled alarm clock. Deprecates Settings.System.NEXT_ALARM_FORMATTED. Bug: 14589952 Change-Id: I297eeeff36d07adcda010afac183d0f5ee37dc99
* Un-deprecate setInexactRepeating() and tweak docsChristopher Tate2013-10-251-33/+52
| | | | | | Bug 10461371 Change-Id: Ic62a0e94c83c0c7b50e21a7bee19c3d92255d231