Doze mode causes alarms to look like they would sound in the next minute when on Battery optimized mode
This is a peculiar issue that is rooted in the Marshmallow’s doze mode and its interaction with sleep tracking. There are two modes of sleep tracking that we use:
- Battery optimized (uses sensor batching)
The modes are toggled in Settings > Sleep tracking > Battery optimized.
For sleep tracking, the device will either stay up all night (normal mode — drains more battery) or needs to be waken up in regular intervals to gather data from the sensor (sensor batching — drains a lot less battery).
The issue here is that doze mode prevents apps to schedule waking times more frequently than once every 15 minutes. The only exception is setAlarmClock method, which unfortunately is tied to UI elements such as the lockscreen.
We need to gather data every minute or so, so we are scheduling the phone to wake up every minute with the setAlarmClock method and take data from the accelerometer. This is unfortunately manifested to you as if the alarm would sound in the next minute. It won’t, you can rely on the alarm, but we cannot do much more with the battery optimized mode on Android 6.
If it annoys you too much, you can get back to the normal mode by turning Battery optimized off.
More info at: