kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
hold new permissions until targetSdkVersion update
rodzic
d429a94e93
commit
64114ce341
|
@ -12,16 +12,20 @@
|
||||||
android:name="android.hardware.location.gps"
|
android:name="android.hardware.location.gps"
|
||||||
android:required="false" />
|
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"
|
<uses-permission android:name="android.permission.BLUETOOTH"
|
||||||
android:maxSdkVersion="30" />
|
android:maxSdkVersion="30" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
|
||||||
android:maxSdkVersion="30" />
|
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_CONNECT" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
|
||||||
android:usesPermissionFlags="neverForLocation" />
|
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 -->
|
<!-- Permissions required for providing location (from phone GPS) to mesh -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
|
|
@ -268,11 +268,14 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||||
// Manifest.permission.WRITE_EXTERNAL_STORAGE
|
// Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* TODO - wait for targetSdkVersion 31
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
perms.add(Manifest.permission.BLUETOOTH_CONNECT)
|
perms.add(Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
} else {
|
} else {
|
||||||
perms.add(Manifest.permission.BLUETOOTH)
|
perms.add(Manifest.permission.BLUETOOTH)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
perms.add(Manifest.permission.BLUETOOTH)
|
||||||
|
|
||||||
// Some old phones complain about requesting perms they don't understand
|
// Some old phones complain about requesting perms they don't understand
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
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> {
|
fun Context.getConnectPermissions(): List<String> {
|
||||||
val perms = mutableListOf<String>()
|
val perms = mutableListOf<String>()
|
||||||
|
|
||||||
|
/* TODO - wait for targetSdkVersion 31
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
perms.add(Manifest.permission.BLUETOOTH_CONNECT)
|
perms.add(Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
} else {
|
} else {
|
||||||
perms.add(Manifest.permission.BLUETOOTH)
|
perms.add(Manifest.permission.BLUETOOTH)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return getMissingPermissions(perms)
|
return getMissingPermissions(perms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,12 +54,18 @@ fun Context.hasConnectPermission() = getConnectPermissions().isEmpty()
|
||||||
fun Context.getScanPermissions(): List<String> {
|
fun Context.getScanPermissions(): List<String> {
|
||||||
val perms = mutableListOf<String>()
|
val perms = mutableListOf<String>()
|
||||||
|
|
||||||
|
/* TODO - wait for targetSdkVersion 31
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
perms.add(Manifest.permission.BLUETOOTH_SCAN)
|
perms.add(Manifest.permission.BLUETOOTH_SCAN)
|
||||||
} else if (!BluetoothInterface.hasCompanionDeviceApi(this)) {
|
} else if (!BluetoothInterface.hasCompanionDeviceApi(this)) {
|
||||||
perms.add(Manifest.permission.ACCESS_FINE_LOCATION)
|
perms.add(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||||
perms.add(Manifest.permission.BLUETOOTH_ADMIN)
|
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)
|
return getMissingPermissions(perms)
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue