BlackyHawky / Clock

Privacy-conscious open-source clock, based on AOSP Clock
Apache License 2.0
178 stars 11 forks source link

Shake to snooze: alarm animation display keeps running, neither sound nor vibration after snoozing #38

Closed mcg-android closed 4 months ago

mcg-android commented 4 months ago

I recently started using com.best.deskclock 2.1, installed from F-Droid on a smartphone running GrapheneOS 2024050700.

The main feature I was looking for is "shake to snooze". I've set "Device shake action" to "Snooze" and "Snooze length" to "6 minutes".

After the installation, the app asked me to grant a few permissions. Additionally, I granted permission "Sensors"; the operating system had notified me that com.best.deskclock wanted to access sensors after an alarm had fired.

Describe the bug

When an alarm fires and I shake the phone, the alarm sound and vibration stop immediately (as expected) and a notification says the alarm is snoozed (until current time + 6 minutes, expected), but the display unexpectedly keeps showing the fullscreen alarm animation.

If I then swipe left to snooze, everything works as expected. If I don't do anything further, the display keeps showing the alarm animation. After six minutes, the notification text changes to += 6 minutes without another shake or swipe, and neither sound nor vibration start again. In effect, I'll get up late and the battery is down. ;-)

qw123wh commented 4 months ago

@mcg-android Did this problem also happen to you in the old version 1.2?

Do you have the same problem in the grapheneos native clock app?

BlackyHawky commented 4 months ago

... but the display unexpectedly keeps showing the fullscreen alarm animation.

The main problem here is that the animation that appears when the alarm is triggered does not disappear when the device is shaken.

Perhaps this problem is due to Android 14, as it appears on my tablet, which is also equipped with Android 14 but not on my phone equipped with Android 12.

Edit: when the Device flip action setting is set there's also the same problem.

Just to be sure: your version of GrapheneOS is actually a version of Android 14?

After six minutes, the notification text changes to += 6 minutes without another shake or swipe, and neither sound nor vibration start again.

For this point, I'm not sure it's a bug; in fact, if you don't take any action when the alarm is triggered, the application considers that the alarm is missed after the time indicated in the Silence after setting.

BlackyHawky commented 4 months ago

In my case, this doesn't happen with version 1.2. It's going to be quite a challenge to find the cause after all these changes... 😭

BlackyHawky commented 4 months ago

After some research, I'm (almost sure) that the problem comes from targetSdk 34 in the gradle file.

To achieve this result, I tested the application with the old commit 6b0fa7da just before my first modifications and the bug doesn't appear. After updating the gradle file with targetSdk 34 and adding some Context.RECEIVER_NOT_EXPORTED to make the alarm work (and only making this modification) the bug appears again.

In conclusion, I don't know what to do 😅


Edit: I compiled the crDroid version and there are no bugs either. The main difference between the 2 versions is targetSdk, which is 33 for the crDroid version.

qw123wh commented 4 months ago

two changes I found are these, but I don't know if they can solve the error

https://github.com/LineageOS/android_packages_apps_DeskClock/commit/95071858b980c137472f169cb793e8357a769e96

https://github.com/LineageOS/android_packages_apps_DeskClock/commit/0137eb8cc24a42166f47984ec9f7e375e827b63a

BlackyHawky commented 4 months ago

two changes I found are these, but I don't know if they can solve the error

Thank you so much for looking too.

Unfortunately, this has no effect. The only way I've found is to downgrade to targetSdk 33 and that's the only thing there is to modify in the gradle file. Until I know where it came from, I'll apply this fix.

Edit: @qw123wh Do you have a way to test the LineageOS version? I'd have to compile it, but I need time...

BlackyHawky commented 4 months ago

@mcg-android can you test the apk attached please? Clock_2.2-debug.zip

mcg-android commented 4 months ago

You guys are too fast... For the sake of completeness, answers to open questions:

Did this problem also happen to you in the old version 1.2?

I had not used com.best.deskclock in version 1.2. I did consider downgrading for testing, but now I'll first try going forward. :-)

Do you have the same problem in the grapheneos native clock app?

The native clock app (com.android.deskclock) does not support shake (nor flip) actions. In a short test, I found no way to "semi-snooze" an alarm shown by that native clock app: sound, vibration, and fullscreen animation always stopped together.

mcg-android commented 4 months ago

Just to be sure: your version of GrapheneOS is actually a version of Android 14?

"About phone" "Device details" "Android version" does say "14".

After six minutes, the notification text changes to += 6 minutes without another shake or swipe, and neither sound nor vibration start again.

For this point, I'm not sure it's a bug; in fact, if you don't take any action when the alarm is triggered, the application considers that the alarm is missed after the time indicated in the Silence after setting.

I guess it could be seen either way: I did take some action, the shaking turned off sound and vibration (and the notification says "snoozing"), but the animation is still running, so is the alarm still firing or not...? Anyway, it's clear that the situation was not supposed to happen in the first place – so somehow forcing a restart of sound and vibration in case it looks like a "semi-snooze" would probably just be a safety-net (if it's possible at all), I guess.

mcg-android commented 4 months ago

can you test the apk attached please? Clock_2.2-debug.zip

Installed com.best.deskclock.debug from ebb8195334ebc270d4beef0185284f31 Clock_2.2-debug.apk and played around: no issues encountered. In particular, shaking not only stops sound and vibration but also the fullscreen animation, as expected (with "Device shake action" set to "Snooze" and permission granted to access sensors). Sound, vibration, and the fullscreen animation start again after the snooze time; worked fine multiple times in a row.

Excellent, thanks! Let's see if I'll get out of bed on time tomorrow. :-)

qw123wh commented 4 months ago

@BlackyHawky wait, before downgrading the sdk, let's do some more tests. I'll try to load the lineage clock here with SDK 34, and we'll test it on A14 devices.

qw123wh commented 4 months ago

apk-archive.zip

Test this version of Lineage clock

qw123wh commented 4 months ago

apk-archive.zip

Test this version of Lineage clock

I tested this version on a Samsung phone A14, it works correctly for what we are interested in (only with the screen turned on). So it can be solved with SDK 34.

BlackyHawky commented 4 months ago

Test this version of Lineage clock

I can't test your version because of the package name. However, I took the time to make my own version and indeed, everything works correctly.

it can be solved with SDK 34

Yes, but I'm not sure I can find it quickly...

BlackyHawky commented 4 months ago

In the end, I found out how to solve the problem easily and it was quite logical. 😉

mcg-android commented 4 months ago

I've set "Device shake action" to "Snooze" [...] ... When an alarm fires and I shake the phone, [...] the display unexpectedly keeps showing the fullscreen alarm animation.

This unexpected behaviour no longer appears with version 2.3 (installed from F-Droid). Noticed no newly introduced unexpected behaviour.

Thank you!