Improved Bluetooth headset connected test
This commit is contained in:
@@ -1549,14 +1549,13 @@ class BaresipService: Service() {
|
|||||||
return audioFocusRequest == null
|
return audioFocusRequest == null
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
|
||||||
private fun isBluetoothHeadsetConnected(ctx: Context): Boolean {
|
private fun isBluetoothHeadsetConnected(ctx: Context): Boolean {
|
||||||
return if (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.BLUETOOTH_CONNECT) ==
|
if (VERSION.SDK_INT >= 31 &&
|
||||||
PackageManager.PERMISSION_GRANTED)
|
ActivityCompat.checkSelfPermission(ctx, Manifest.permission.BLUETOOTH_CONNECT) ==
|
||||||
btAdapter != null && btAdapter!!.isEnabled &&
|
PackageManager.PERMISSION_DENIED)
|
||||||
|
return false
|
||||||
|
return btAdapter != null && btAdapter!!.isEnabled &&
|
||||||
btAdapter!!.getProfileConnectionState(BluetoothHeadset.HEADSET) == BluetoothAdapter.STATE_CONNECTED
|
btAdapter!!.getProfileConnectionState(BluetoothHeadset.HEADSET) == BluetoothAdapter.STATE_CONNECTED
|
||||||
else
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isBluetoothScoOn(am: AudioManager): Boolean {
|
private fun isBluetoothScoOn(am: AudioManager): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user