Skip to content

Commit

Permalink
added more permissions for android 12
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Leighton committed Aug 23, 2022
1 parent 59e2b18 commit 4c49376
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,12 @@ public Boolean checkPermission() {
);

if (currentVer >= 31 && hasPermission) {
hasPermission = (hasPermission && ContextCompat.checkSelfPermission(context, "android.permission.BLUETOOTH_CONNECT") == PackageManager.PERMISSION_GRANTED);
hasPermission = (hasPermission &&
ContextCompat.checkSelfPermission(context, "android.permission.BLUETOOTH") == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(context, "android.permission.BLUETOOTH_ADMIN") == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(context, "android.permission.BLUETOOTH_CONNECT") == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(context, "android.permission.BLUETOOTH_SCAN") == PackageManager.PERMISSION_GRANTED
);
}

return hasPermission;
Expand All @@ -385,7 +390,10 @@ public void requestPermission() {
if (currentVer >= 31) {
// there doesn't seem to be a constant for this (i.e. Manifest.permission.BLUETOOTH_CONNECT) -- kept getting compiler errors
// but using the permission string directly seems to work
permissions.add("android.permission.BLUETOOTH");
permissions.add("android.permission.BLUETOOTH_ADMIN");
permissions.add("android.permission.BLUETOOTH_CONNECT");
permissions.add("android.permission.BLUETOOTH_SCAN");
}

String[] array = permissions.toArray(new String[permissions.size()]);
Expand Down

0 comments on commit 4c49376

Please sign in to comment.