@@ -436,8 +436,13 @@ && connectBluetoothScoAudioHelper(mBluetoothHeadset,
436
436
if (mBluetoothHeadset == null || mBluetoothHeadsetDevice == null ) {
437
437
return false ;
438
438
}
439
- return mBluetoothHeadset .getAudioState (mBluetoothHeadsetDevice )
440
- == BluetoothHeadset .STATE_AUDIO_CONNECTED ;
439
+ try {
440
+ return mBluetoothHeadset .getAudioState (mBluetoothHeadsetDevice )
441
+ == BluetoothHeadset .STATE_AUDIO_CONNECTED ;
442
+ } catch (Exception e ) {
443
+ Log .e (TAG , "Exception while getting audio state of " + mBluetoothHeadsetDevice , e );
444
+ }
445
+ return false ;
441
446
}
442
447
443
448
// @GuardedBy("mDeviceBroker.mSetModeLock")
@@ -1051,12 +1056,16 @@ private static boolean connectBluetoothScoAudioHelper(BluetoothHeadset bluetooth
1051
1056
}
1052
1057
1053
1058
private void checkScoAudioState () {
1054
- if (mBluetoothHeadset != null
1055
- && mBluetoothHeadsetDevice != null
1056
- && mScoAudioState == SCO_STATE_INACTIVE
1057
- && mBluetoothHeadset .getAudioState (mBluetoothHeadsetDevice )
1058
- != BluetoothHeadset .STATE_AUDIO_DISCONNECTED ) {
1059
- mScoAudioState = SCO_STATE_ACTIVE_EXTERNAL ;
1059
+ try {
1060
+ if (mBluetoothHeadset != null
1061
+ && mBluetoothHeadsetDevice != null
1062
+ && mScoAudioState == SCO_STATE_INACTIVE
1063
+ && mBluetoothHeadset .getAudioState (mBluetoothHeadsetDevice )
1064
+ != BluetoothHeadset .STATE_AUDIO_DISCONNECTED ) {
1065
+ mScoAudioState = SCO_STATE_ACTIVE_EXTERNAL ;
1066
+ }
1067
+ } catch (Exception e ) {
1068
+ Log .e (TAG , "Exception while getting audio state of " + mBluetoothHeadsetDevice , e );
1060
1069
}
1061
1070
}
1062
1071
0 commit comments