Use AlarmManager to manage the ending of timers #236
No reviewers
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: brandon.presley/Massive#236
Loading…
Reference in New Issue
No description provided.
Delete Branch "joseph/Massive:use_alarm_manager"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the discussion in #235, I have implemented AlarmManager to schedule the expiry of the timers.
This follows how the android clock deals with timers 1 2.
Unfortunately the docs on
AlarmManager
andsetExactAndAllowWhileIdle
isn't very clear and is quite misleading.This gives the impression that it counts alarms being dispatched as any alarm you set, however having a look at the source code it seems like as long as you cancel the previous alarm or the previous alarm has executed before dispatching a new one, your quota won't be effected.
I'll link the android tests for AlarmManager here,
testSimpleQuotaDeferral
shows how inorder to use up your quota you have to start at least more that one alarm simultaneously. As well as some other related files 1 2 3I also tested adding multiple new sets on the emulator (various android releases) and two phones by spamming the button about 100 times as fast as I could. Suffice to say I didn't seem to hit any quota limit even when I sent off 100 new sets in under 15 seconds.
1000 - millisElapsed % 1000
is replaced withtimer.getRemainingMillis() % 1000
inpostDelayed
. This has no behavioral change as the result of both statements is the same.This fixes all the issues I've been having with timers.
Incredible stuff my brother! Love your work
Hey boss I was trying to copy your work into Flexify https://github.com/brandonp2412/Flexify/blob/main/android/app/src/main/kotlin/com/presley/flexify/TimerService.kt but I'm getting
Unresolved reference: FOREGROUND_SERVICE_TYPE_SPECIAL_USE
do I need to change that projects android target version or install something?I was getting that too when I tried copying it into Flexify - it still complains however it builds just fine for me now.
I have submitted an mr on Flexify with the changes from this mr + some fixes for bugs I encountered when trying to run in debug mode.
Use AlarmManager to manage the ending of timersto WIP: Use AlarmManager to manage the ending of timersMarking this WIP as I would like to take some of the changes I made in the Flexify mr over here.
41b9232a1b
to58b8488a27
WIP: Use AlarmManager to manage the ending of timersto Use AlarmManager to manage the ending of timersBrought over applicable changes from here.
This mr and Flexify one should be ready now.
Pull request closed