d4rken-org / capod

A companion app for AirPods on Android.
https://play.google.com/store/apps/details?id=eu.darken.capod
GNU General Public License v3.0
537 stars 48 forks source link

Fix app crash on launch if permission are not granted #217

Closed d4rken closed 4 months ago

d4rken commented 4 months ago

Fixes this on app launch:


12:49:29.433 AndroidRuntime                       E  FATAL EXCEPTION: main
                                                     Process: eu.darken.capod, PID: 15164
                                                     java.lang.SecurityException: Starting FGS with type connectedDevice callerApp=ProcessRecord{cb03698 15164:eu.darken.capod/u0a352} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE] any of the permissions allOf=false [android.permission.BLUETOOTH_ADVERTISE, android.permission.BLUETOOTH_CONNECT, android.permission.BLUETOOTH_SCAN, android.permission.CHANGE_NETWORK_STATE, android.permission.CHANGE_WIFI_STATE, android.permission.CHANGE_WIFI_MULTICAST_STATE, android.permission.NFC, android.permission.TRANSMIT_IR, android.permission.UWB_RANGING, USB Device, USB Accessory]
                                                        at android.os.Parcel.createExceptionOrNull(Parcel.java:3242)
                                                        at android.os.Parcel.createException(Parcel.java:3226)
                                                        at android.os.Parcel.readException(Parcel.java:3209)
                                                        at android.os.Parcel.readException(Parcel.java:3151)
                                                        at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7167)
                                                        at android.app.Service.startForeground(Service.java:863)
                                                        at androidx.work.impl.foreground.SystemForegroundService$Api31Impl.startForeground(SystemForegroundService.java:194)
                                                        at androidx.work.impl.foreground.SystemForegroundService$1.run(SystemForegroundService.java:130)
                                                        at android.os.Handler.handleCallback(Handler.java:959)
                                                        at android.os.Handler.dispatchMessage(Handler.java:100)
                                                        at android.os.Looper.loopOnce(Looper.java:232)
                                                        at android.os.Looper.loop(Looper.java:317)
                                                        at android.app.ActivityThread.main(ActivityThread.java:8699)
                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)