Fix alarm not firing in memory-pressure situations
Bug: 25846551 The original form of the code that fires an alarm is: AlarmManager -> BroadcastReceiver -> Service. The new form of the code that fires an alarm is: AlarmManager -> Service. Evidence exists that the system lowmemorykiller may elect to kill the clock app after BroadcastReceiver.onReceive(...) completes but before Service.onStartCommand(...) begins. When this occurs, the results are disastrous as the clock fails to fire at the appropriate time. To remove this possibility, all alarm state changes are delivered to the Service. The methods that manipulate database state within BroadcastReceiver have been made public and static and are called directly from the Service to perform the same work as before. If the alarm state transition is to the FIRING state, the AlarmService also performs the work of posting the firing notification in the foreground. All of this occurs during the handling of a single Intent on the same thread within the service which should no longer provide lowmemorykiller with any opportunities to prevent the firing of an alarm by killing the clock app. Change-Id: I3629a5b725a758f680f41611939a5bbeec23238a
Loading