From 15a1b15591fbc7aade1003da6c96b0b27a4c327b Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Wed, 24 Nov 2021 09:27:30 +0100 Subject: [PATCH] Really fix nearby permission check in settings view --- .../nearby/core/ui/ExposureNotificationsPreferencesFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsPreferencesFragment.kt b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsPreferencesFragment.kt index 5003182d..537d46b0 100644 --- a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsPreferencesFragment.kt +++ b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsPreferencesFragment.kt @@ -131,7 +131,8 @@ class ExposureNotificationsPreferencesFragment : PreferenceFragmentCompat() { val advertisingSupported = if (bluetoothSupported == true) AdvertiserService.isSupported(appContext) else bluetoothSupported val nearbyPermissions = arrayOf("android.permission.BLUETOOTH_ADVERTISE", "android.permission.BLUETOOTH_SCAN") - val nearbyPermissionsGranted = Build.VERSION.SDK_INT >= 31 || nearbyPermissions.all { + // Expresses implication (API 31+ → all new permissions granted) ≡ (¬API 31+ | all new permissions granted) + val nearbyPermissionsGranted = Build.VERSION.SDK_INT < 31 || nearbyPermissions.all { ContextCompat.checkSelfPermission(appContext, it) == PackageManager.PERMISSION_GRANTED } exposureNearbyNotGranted.isVisible = enabled && !nearbyPermissionsGranted