1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-08 19:27:04 +01:00

Fix crash when nearby devices (BLUETOOTH_SCAN) permission is missing

This commit is contained in:
pacjo 2024-08-25 20:08:09 +02:00 committed by José Rebelo
parent 6bfd3dcd06
commit cae6f5d73e

View File

@ -1214,7 +1214,11 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
private void startForeground() {
GB.createNotificationChannels(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_DENIED)
return;
startForeground(GB.NOTIFICATION_ID, GB.createNotification(getString(R.string.gadgetbridge_running), this), ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE);
} else {
startForeground(GB.NOTIFICATION_ID, GB.createNotification(getString(R.string.gadgetbridge_running), this));