From 10455df7e2147561f69dcdcb585efecc3a3d7cfe Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Thu, 25 Nov 2021 15:34:19 +0100 Subject: [PATCH] also catch potential stopAdvertising exceptions --- .../gms/nearby/exposurenotification/AdvertiserService.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt index 03612f2a..6b894642 100644 --- a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt +++ b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt @@ -218,7 +218,11 @@ class AdvertiserService : LifecycleService() { Log.i(TAG, "Tried calling stopAdvertisingSet without android.permission.BLUETOOTH_ADVERTISE permission.", ) } } else { - advertiser?.stopAdvertising(callback) + try { + advertiser?.stopAdvertising(callback) + } catch (e: SecurityException) { + Log.i(TAG, "stopAdvertising() failed with a SecurityException. Maybe some permissions are missing?", ) + } } handler.postDelayed(startLaterRunnable, 1000) }