hold new permissions until targetSdkVersion update

This commit is contained in:
andrekir
2022-02-09 22:10:25 -03:00
parent d429a94e93
commit 64114ce341
3 changed files with 17 additions and 3 deletions

View File

@@ -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) {

View File

@@ -35,12 +35,13 @@ fun Context.getMissingPermissions(perms: List<String>) = perms.filter {
fun Context.getConnectPermissions(): List<String> {
val perms = mutableListOf<String>()
/* 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<String> {
val perms = mutableListOf<String>()
/* 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)
}