Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.1 kB · 30 lines
Kotlin
at mistress
12345678910111213141516171819202122232425262728293031package com.rtnbleserver
import android.Manifestimport android.content.Contextimport android.content.pm.PackageManagerimport android.os.Build
internal object BluetoothPermissions { /** Permissions needed to advertise a GATT server. */ fun serverGranted(context: Context): Boolean { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { return true } return granted(context, Manifest.permission.BLUETOOTH_CONNECT) && granted(context, Manifest.permission.BLUETOOTH_ADVERTISE) }
/** Permissions needed to scan for and connect to a GATT server. */ fun clientGranted(context: Context): Boolean { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { return granted(context, Manifest.permission.BLUETOOTH_SCAN) && granted(context, Manifest.permission.BLUETOOTH_CONNECT) } return granted(context, Manifest.permission.ACCESS_FINE_LOCATION) }
private fun granted(context: Context, permission: String): Boolean { return context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED }}