mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
add bluetooth_connect permission checks
This commit is contained in:
parent
a2f5d74bfc
commit
dc852b97ba
3 changed files with 44 additions and 28 deletions
|
|
@ -29,6 +29,24 @@ fun Context.getMissingPermissions(perms: List<String>) = perms.filter {
|
|||
) != PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
/**
|
||||
* Bluetooth connect permissions (or empty if we already have what we need)
|
||||
*/
|
||||
fun Context.getConnectPermissions(): List<String> {
|
||||
val perms = mutableListOf<String>()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
perms.add(Manifest.permission.BLUETOOTH_CONNECT)
|
||||
} else {
|
||||
perms.add(Manifest.permission.BLUETOOTH)
|
||||
}
|
||||
|
||||
return getMissingPermissions(perms)
|
||||
}
|
||||
|
||||
/** @return true if the user already has Bluetooth connect permission */
|
||||
fun Context.hasConnectPermission() = getConnectPermissions().isEmpty()
|
||||
|
||||
/**
|
||||
* Bluetooth scan/discovery permissions (or empty if we already have what we need)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue