0
0
mirror of https://github.com/markusfisch/BinaryEye.git synced 2024-09-19 19:42:18 +02:00

Only check BLUETOOTH_CONNECT on Android S+

This symbol doesn't exist before Android S.
This commit is contained in:
Markus Fisch 2023-03-15 20:31:01 +01:00
parent 021d775835
commit 142df25d7e

View File

@ -3,6 +3,7 @@ package de.markusfisch.android.binaryeye.app
import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager
import android.os.Build
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
@ -33,11 +34,15 @@ fun Activity.hasLocationPermission(callback: () -> Any): Boolean {
}
const val PERMISSION_BLUETOOTH = 4
fun Activity.hasBluetoothPermission(): Boolean {
return hasPermission(
fun Activity.hasBluetoothPermission() = if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
) {
hasPermission(
Manifest.permission.BLUETOOTH_CONNECT,
PERMISSION_BLUETOOTH
)
} else {
false
}
private fun Activity.hasPermission(