maforn / TimedShutdownAndroid

An app for android that will automatically shutdown your phone after a timer without needing root access. This app uses the accessiblity permission to emulate the power off gestures.
GNU General Public License v3.0
35 stars 3 forks source link

Repeating schedule delay #23

Closed procionecastoro closed 1 month ago

procionecastoro commented 2 months ago

Hi, the app is great and extremely useful, the only ''bug'' that I have encountered is that when I select some or all days of the week to set a repeating schedule there's some delay, I'm not talking about the shutting in two seconds, there's up to 1 minute delay after the set time. This doesn't happen when there's no days selected so it's not repeating, in that case when the time comes it's instantly working. I was wondering is it common, should it be this way, or is this a problem with my phone maybe? I have a Motorola moto g54 5g on Android 14

maforn commented 2 months ago

Hello procionecastoro, the issue is both reasonable and strange at the same time: the code that takes care of the repeating scheduler and the normal scheduler is almost the same, the only difference is that one "alarm" is set up with alarmManager.setRepeating() while the other uses alarmManager.setAlarmClock() (you can check it in this file). At this point, I'd say that the problem is not in the code, nor in your phone but in the way that Android handles repeating alarms, probably they are not extremely precise to the second. I may be able to fix this by creating an alarm with setAlarmClock every time instead of just using setRepeating but it would complicate a bit the code and I am not sure it's worth the effort. Is the delay that much of a problem?

procionecastoro commented 2 months ago

Thanks for replying Maforn, as I've said the app is already great and I can still use the normal scheduler and turn it on everyday if I want it to be precise to the second, as long as the delay with the repeating scheduler stays around a minute it's not going to be much of a problem, so if I were you I'd consider to fix this only if you really want to make the app perfect. What led me to opening this issue is that nobody really said they had a delay with the repeating scheduler and I thought there was something wrong with my phone. Have you encountered this delay in the repeating scheduler when you tested it on your device too?

maforn commented 1 month ago

I've tested it and found a delay of about one minute. I still don't think that it's something that I should try to fix with a workaround, because I'm using the "correct" function that Android provides. Thank you for taking the time to raise this issue. Feel free to keep commenting if you disagree or if you have anything else to say.