ympavlov / minidoro

Android app for Pomodoro Technique users
MIT License
30 stars 3 forks source link

Minidoro crashes when overriding silent mode #5

Open philkoch opened 2 years ago

philkoch commented 2 years ago

I'm using Minidoro on a Fairphone 3 with LineageOS 17 (Android 10 based with micro-G) and when the phone is in silent mode the app crashes silently when the timer runs out. I have the Override Silent Mode option turned on. It works fine when the Option is turned off.

MartinX3 commented 2 years ago

Same with LineageOS 18.1 (Android 11)

  1. it crashes if the screen is disabled
  2. It crashes if I minimize the app and look at the home screen (Switched to homescreen 6 seconds before alarm)
  3. It crashes if I left the app open
01-08 11:37:51.890  7079  7079 D AndroidRuntime: Shutting down VM
--------- beginning of crash
01-08 11:37:51.891  7079  7079 E AndroidRuntime: FATAL EXCEPTION: main
01-08 11:37:51.891  7079  7079 E AndroidRuntime: Process: com.github.ympavlov.minidoro, PID: 7079
01-08 11:37:51.891  7079  7079 E AndroidRuntime: java.lang.SecurityException: Not allowed to change Do Not Disturb state
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Parcel.createException(Parcel.java:2357)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:2340)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:2282)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.media.IAudioService$Stub$Proxy.setRingerModeExternal(IAudioService.java:2998)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.media.AudioManager.setRingerMode(AudioManager.java:1150)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.github.ympavlov.minidoro.dnd.e.a(Unknown Source:13)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.github.ympavlov.minidoro.dnd.e.a(Unknown Source:18)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.github.ympavlov.minidoro.b.update(Unknown Source:56)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at java.util.Observable.notifyObservers(Observable.java:163)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at java.util.Observable.notifyObservers(Observable.java:115)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.github.ympavlov.minidoro.d.n(Unknown Source:38)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.github.ympavlov.minidoro.d.a(Unknown Source:14)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.github.ympavlov.minidoro.CountDownView.update(Unknown Source:8)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at java.util.Observable.notifyObservers(Observable.java:163)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.github.ympavlov.minidoro.g$1.run(Unknown Source:23)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:938)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:223)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7664)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
01-08 11:37:51.891  7079  7079 E AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at com.android.server.audio.AudioService.setRingerModeExternal(AudioService.java:3485)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.media.IAudioService$Stub.onTransact(IAudioService.java:1322)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Binder.execTransactInternal(Binder.java:1154)
01-08 11:37:51.891  7079  7079 E AndroidRuntime:    at android.os.Binder.execTransact(Binder.java:1123)
01-08 11:37:51.891  7079  7079 E AndroidRuntime: 
01-08 11:37:51.931  7079  7079 I Process : Sending signal. PID: 7079 SIG: 9

The solution is to add the android.permission.ACCESS_NOTIFICATION_POLICY permission in the manifest and to ask and check the permissions at runtime. https://developer.android.com/training/permissions/requesting

And please start using android jetpack and kotlin instead of java.

ivanruvalcaba commented 9 months ago

Any news on the release of the version that fixes this problem?