From 64114ce34183e3dca47a597887ea61055e7abe7c Mon Sep 17 00:00:00 2001 From: andrekir Date: Wed, 9 Feb 2022 22:10:25 -0300 Subject: [PATCH] hold new permissions until targetSdkVersion update --- app/src/main/AndroidManifest.xml | 8 ++++++-- app/src/main/java/com/geeksville/mesh/MainActivity.kt | 3 +++ .../java/com/geeksville/mesh/android/ContextServices.kt | 9 ++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c33d0876..723da633 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,16 +12,20 @@ android:name="android.hardware.location.gps" android:required="false" /> - + + <!– API 31+ Bluetooth permissions –> +--> + + diff --git a/app/src/main/java/com/geeksville/mesh/MainActivity.kt b/app/src/main/java/com/geeksville/mesh/MainActivity.kt index e62d809e..4fcf73e2 100644 --- a/app/src/main/java/com/geeksville/mesh/MainActivity.kt +++ b/app/src/main/java/com/geeksville/mesh/MainActivity.kt @@ -268,11 +268,14 @@ class MainActivity : AppCompatActivity(), Logging, // Manifest.permission.WRITE_EXTERNAL_STORAGE ) +/* TODO - wait for targetSdkVersion 31 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { perms.add(Manifest.permission.BLUETOOTH_CONNECT) } else { perms.add(Manifest.permission.BLUETOOTH) } +*/ + perms.add(Manifest.permission.BLUETOOTH) // Some old phones complain about requesting perms they don't understand if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { diff --git a/app/src/main/java/com/geeksville/mesh/android/ContextServices.kt b/app/src/main/java/com/geeksville/mesh/android/ContextServices.kt index c3926e77..6f2312bf 100644 --- a/app/src/main/java/com/geeksville/mesh/android/ContextServices.kt +++ b/app/src/main/java/com/geeksville/mesh/android/ContextServices.kt @@ -35,12 +35,13 @@ fun Context.getMissingPermissions(perms: List) = perms.filter { fun Context.getConnectPermissions(): List { val perms = mutableListOf() +/* TODO - wait for targetSdkVersion 31 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { perms.add(Manifest.permission.BLUETOOTH_CONNECT) } else { perms.add(Manifest.permission.BLUETOOTH) } - +*/ return getMissingPermissions(perms) } @@ -53,12 +54,18 @@ fun Context.hasConnectPermission() = getConnectPermissions().isEmpty() fun Context.getScanPermissions(): List { val perms = mutableListOf() +/* TODO - wait for targetSdkVersion 31 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { perms.add(Manifest.permission.BLUETOOTH_SCAN) } else if (!BluetoothInterface.hasCompanionDeviceApi(this)) { perms.add(Manifest.permission.ACCESS_FINE_LOCATION) perms.add(Manifest.permission.BLUETOOTH_ADMIN) } +*/ + if (!BluetoothInterface.hasCompanionDeviceApi(this)) { + perms.add(Manifest.permission.ACCESS_FINE_LOCATION) + perms.add(Manifest.permission.BLUETOOTH_ADMIN) + } return getMissingPermissions(perms) }