Move state check to audio handler thread.

This commit is contained in:
Alex Hart 2023-04-06 14:16:55 -03:00
parent 16f1fbf583
commit a141fdaf7d

View file

@ -337,10 +337,12 @@ class SignalBluetoothManager(
scoConnectionAttempts = 0
updateDevice()
}
} else if (state != State.UNINITIALIZED) {
} else {
handler.post {
val connectionState: Int = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_AUDIO_DISCONNECTED)
onAudioStateChanged(connectionState, isInitialStickyBroadcast)
if (state != State.UNINITIALIZED) {
val connectionState: Int = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_AUDIO_DISCONNECTED)
onAudioStateChanged(connectionState, isInitialStickyBroadcast)
}
}
}
} else if (intent.action == AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED) {