From 2fe88000cf5e4d7d2d498f1029ed69bd1066a3a1 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 17 Nov 2022 09:06:33 +0700 Subject: [PATCH] Adjust Bluetooth permission handling for Android SDK >= 31 --- platform/android/AndroidManifest.xml.in | 10 ++++-- .../src/ch/opengis/qfield/QFieldActivity.java | 32 +++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/platform/android/AndroidManifest.xml.in b/platform/android/AndroidManifest.xml.in index 1030d9c986..437e2ee1a9 100644 --- a/platform/android/AndroidManifest.xml.in +++ b/platform/android/AndroidManifest.xml.in @@ -11,8 +11,14 @@ - - + + + + = Build.VERSION_CODES.S) { + if (ContextCompat.checkSelfPermission( + QFieldActivity.this, Manifest.permission.BLUETOOTH_SCAN) == + PackageManager.PERMISSION_DENIED) { + permissionsList.add(Manifest.permission.BLUETOOTH_SCAN); + } + if (ContextCompat.checkSelfPermission( + QFieldActivity.this, + Manifest.permission.BLUETOOTH_CONNECT) == + PackageManager.PERMISSION_DENIED) { + permissionsList.add(Manifest.permission.BLUETOOTH_CONNECT); + } + } else { + if (ContextCompat.checkSelfPermission( + QFieldActivity.this, Manifest.permission.BLUETOOTH) == + PackageManager.PERMISSION_DENIED) { + permissionsList.add(Manifest.permission.BLUETOOTH); + } + if (ContextCompat.checkSelfPermission( + QFieldActivity.this, Manifest.permission.BLUETOOTH_ADMIN) == + PackageManager.PERMISSION_DENIED) { + permissionsList.add(Manifest.permission.BLUETOOTH_ADMIN); + } } if (permissionsList.size() > 0) { String[] permissions = new String[permissionsList.size()];