Skip to content

Migrate sleep timer from AlarmManager to a more reliable in-app implementation

Nicolas Pomepuy requested to merge Aza/vlc-android:sleep_timer into master

Fixes #2360 (closed) As AlarmManager is not reliable on all API versions/OEM implementations we want to get rid of it for the sleep timer management and instead use a custom implementation based on coroutine job.

Difference with previous implementation:

  • We do not use any AlarmManager but instead tie the sleep timer value / checking to the PlaybackService
  • In term of UX, the sleep timer is now removed if the PlaybackService is stopped. It means that any "stop" event will delete the current sleep timer for future playback even if it's not consumed. I chose to do it that way, but the current implementation allows to restore the sleep timer if we want. [TO BE DISCUSSED]
  • the new implementation should not have any performance impact as it only consists of a loop running in background
  • I left a lot of logs in the first commit for debug purposes. We should get rid of it before merging

Merge request reports