sweakpl / qralarm-android

QRAlarm is an Android alarm clock application that lets the user turn off alarms by scanning the QR Code.
GNU General Public License v3.0
112 stars 10 forks source link

Crash when playing the system default alarm tone #1

Closed BloodRaven0 closed 2 years ago

BloodRaven0 commented 2 years ago

I'm on android 10 and attempting to play the system default alarm tone crashes the app immediately. Also if it's set to the default tone, the alarm doesn't ring when it should (probably due to crashing again). Switching to one of the 3 included alarms (gentle guitar or one of the other two), everything seems to work just fine.

My phone is poco x3 nfc, unlocked and rooted, with Resurrection Remix custom Rom installed.

I tested it on my girlfriend's phone (unrooted huawei p30 lite) and it seems to work fine.

Sorry for not providing a crash log but I don't really know how, since when I press "copy crash log url" after the app crashes, it says "Error uploading the log to dogbin" and nothing gets copied to clipboard. I'd be happy to provide a log if you guide me as to how to get one. EDIT: I don't know if this is useful, but I downloaded an app called MatCat and recorded 2 crashes with it in debug mode, here's the pastebin entry: https://pastebin.com/4hfKzHxr

sweakpl commented 2 years ago

Hey, thanks for feedback!

The logs You've sent were very helpful, thank You for the effort! :D

It seems, like the app needs an additional permission to read priviledged phone state as the line in the crash log says:

java.lang.SecurityException: getDefaultOutgoingPhoneAccount: Neither user 10348
    nor current process has android.permission.READ_PRIVILEGED_PHONE_STATE.

So the app is somehow trying to get the access to the telecom service of the phone, which I would have never thought would be happening with QRAlarm...

Either way, when it comes to that READ_PRIVILEGED_PHONE_STATE permission, it was introduced in Android 10 and the description of it says:

Android 10 changes the permissions for device identifiers so that all device identifiers are now protected by the
READ_PRIVILEGED_PHONE_STATE permission. The READ_PRIVILEGED_PHONE_STATE permission is only granted
to apps signed with the platform key and privileged system apps.

That means that this permission is only available for the system applications which really complicates the situation since I just can not get this permission...

I have a wild guess about why that is happening, but I am not 100% certain. This might be caused by the fact that the default system alarm ringtone was changed to a sound that resides in user's storage to which my app has limited access - it can not read it. And all of that might be leading to the app trying to access the telecom service and in turn causing the crash...

BloodRaven0 commented 2 years ago

Yeah I thought a similar thing, but sadly my ROM has no "built in" alarm sounds I could try, only "pixel sounds" that I think still count as user-defined. I tried selecting "none" as my alarm tone, but QRalarm still crashed when trying to play it lol.

Edit: I just checked my girlfriend's phone, and it is on EMUI 10 / android 10 as well, but her OS has no way to change the default alarm tone, it's set to a certain melody and can only be changed on a per-alarm basis. I'd guess it's working because it's built-in?

Anyway, I think a selection of a custom alarm would be a better solution, even though it would require access to local files. This would fix the crashes and allow users of EMUI and other restrictive OS's that don't allow the changing of the default ringtone, to use a custom ringtone.

Also I think it would be better to have "Gentle guitar" set as the default for now, so people don't get crashing alarms out of the box 😅