Skip to content

DeviceStateTracker: Use exact alarms for the time schedule#97

Open
chenxiaolong wants to merge 1 commit intomasterfrom
exact-alarm
Open

DeviceStateTracker: Use exact alarms for the time schedule#97
chenxiaolong wants to merge 1 commit intomasterfrom
exact-alarm

Conversation

@chenxiaolong
Copy link
Copy Markdown
Owner

Inexact alarms would be preferable, but there is no way to set the maximum deviance from the desired time. For the default 1h cycle + 5m sync interval, AOSP will add a 3m45s delay to the 5m portion, but a 41m15s delay to the 55m portion. The latter is so wildly different from what the user configured that the number has no meaning anymore.

Instead, we'll just use exact alarms. The ability to do this is automatically granted when the user disables battery optimizations, but this commit also adds the SCHEDULE_EXACT_ALARM permission for users who don't do that. They will need to manually grant the permission from Android's settings because disabling battery optimizations is the (strongly) recommended setup. If exact alarms are not allowed, then inexact alarms will be used as a fallback.

The user will now be responsible for choosing values that are sane and don't wake up the device too often because these alarms will interrupt doze mode.

Fixes: #83

Inexact alarms would be preferable, but there is no way to set the
maximum deviance from the desired time. For the default 1h cycle + 5m
sync interval, AOSP will add a 3m45s delay to the 5m portion, but a
41m15s delay to the 55m portion. The latter is so wildly different from
what the user configured that the number has no meaning anymore.

Instead, we'll just use exact alarms. The ability to do this is
automatically granted when the user disables battery optimizations, but
this commit also adds the SCHEDULE_EXACT_ALARM permission for users who
don't do that. They will need to manually grant the permission from
Android's settings because disabling battery optimizations is the
(strongly) recommended setup. If exact alarms are not allowed, then
inexact alarms will be used as a fallback.

The user will now be responsible for choosing values that are sane and
don't wake up the device too often because these alarms will interrupt
doze mode.

Fixes: #83

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Time schedule syncs don't work when device idle

1 participant