sforkowany z mirror/meshtastic-android
hold new permissions until targetSdkVersion update
rodzic
d429a94e93
commit
64114ce341
|
@ -12,16 +12,20 @@
|
|||
android:name="android.hardware.location.gps"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Request legacy Bluetooth permissions on older devices -->
|
||||
<!-- TODO - wait for targetSdkVersion 31
|
||||
<!– Request legacy Bluetooth permissions on older devices –>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH"
|
||||
android:maxSdkVersion="30" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
|
||||
android:maxSdkVersion="30" />
|
||||
|
||||
<!-- API 31+ Bluetooth permissions -->
|
||||
<!– API 31+ Bluetooth permissions –>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
|
||||
android:usesPermissionFlags="neverForLocation" />
|
||||
-->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
|
||||
<!-- Permissions required for providing location (from phone GPS) to mesh -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue