Skip to content

Commit 4880a73

Browse files
marconeAndroid (Google) Code Review
authored andcommitted
Merge "Fix startBluetoothSco race"
2 parents ddca470 + 671db6f commit 4880a73

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

media/java/android/media/AudioService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,11 +1347,10 @@ private void requestScoState(int state) {
13471347
// currently controlled by the same client process.
13481348
if ((AudioService.this.mMode == AudioSystem.MODE_NORMAL ||
13491349
mSetModeDeathHandlers.get(0).getPid() == mCreatorPid) &&
1350-
mBluetoothHeadsetDevice != null &&
13511350
(mScoAudioState == SCO_STATE_INACTIVE ||
13521351
mScoAudioState == SCO_STATE_DEACTIVATE_REQ)) {
13531352
if (mScoAudioState == SCO_STATE_INACTIVE) {
1354-
if (mBluetoothHeadset != null) {
1353+
if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {
13551354
if (mBluetoothHeadset.startScoUsingVirtualVoiceCall(
13561355
mBluetoothHeadsetDevice)) {
13571356
mScoAudioState = SCO_STATE_ACTIVE_INTERNAL;
@@ -1370,11 +1369,10 @@ private void requestScoState(int state) {
13701369
broadcastScoConnectionState(AudioManager.SCO_AUDIO_STATE_DISCONNECTED);
13711370
}
13721371
} else if (state == BluetoothHeadset.STATE_AUDIO_DISCONNECTED &&
1373-
mBluetoothHeadsetDevice != null &&
13741372
(mScoAudioState == SCO_STATE_ACTIVE_INTERNAL ||
13751373
mScoAudioState == SCO_STATE_ACTIVATE_REQ)) {
13761374
if (mScoAudioState == SCO_STATE_ACTIVE_INTERNAL) {
1377-
if (mBluetoothHeadset != null) {
1375+
if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {
13781376
if (!mBluetoothHeadset.stopScoUsingVirtualVoiceCall(
13791377
mBluetoothHeadsetDevice)) {
13801378
mScoAudioState = SCO_STATE_INACTIVE;

0 commit comments

Comments
 (0)