Fix exception in AudioService when no BT Headset is connected.

If AudioManager.startBluetoothSco() is invoked with no Bluetooth Headset
connected, a NullPointerException will ensue.

Added check to make sure mBluetoothHeadsetDevice is set before accessing
it.

Bug: 17601845
Change-Id: Ia00bfffbea5484230b11a74787fe3309c18f824d
This commit is contained in:
Andre Eisenbach
2014-10-28 17:03:18 -07:00
parent f5c00c1c11
commit 570cc5302a

View File

@@ -2574,13 +2574,17 @@ public class AudioService extends IAudioService.Stub {
if (mScoAudioState == SCO_STATE_INACTIVE) {
mScoAudioMode = scoAudioMode;
if (scoAudioMode == SCO_MODE_UNDEFINED) {
mScoAudioMode = new Integer(Settings.Global.getInt(
mContentResolver,
"bluetooth_sco_channel_"+
mBluetoothHeadsetDevice.getAddress(),
SCO_MODE_VIRTUAL_CALL));
if (mScoAudioMode > SCO_MODE_MAX || mScoAudioMode < 0) {
mScoAudioMode = SCO_MODE_VIRTUAL_CALL;
if (mBluetoothHeadsetDevice != null) {
mScoAudioMode = new Integer(Settings.Global.getInt(
mContentResolver,
"bluetooth_sco_channel_"+
mBluetoothHeadsetDevice.getAddress(),
SCO_MODE_VIRTUAL_CALL));
if (mScoAudioMode > SCO_MODE_MAX || mScoAudioMode < 0) {
mScoAudioMode = SCO_MODE_VIRTUAL_CALL;
}
} else {
mScoAudioMode = SCO_MODE_RAW;
}
}
if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {