Merge "BT: Don't switch devices when one of the connected BT headsets disconnects"
This commit is contained in:
@@ -3097,7 +3097,22 @@ public class AudioService extends IAudioService.Stub {
|
|||||||
boolean success =
|
boolean success =
|
||||||
handleDeviceConnection(connected, outDevice, address, btDeviceName) &&
|
handleDeviceConnection(connected, outDevice, address, btDeviceName) &&
|
||||||
handleDeviceConnection(connected, inDevice, address, btDeviceName);
|
handleDeviceConnection(connected, inDevice, address, btDeviceName);
|
||||||
if (success) {
|
|
||||||
|
if (!success) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When one BT headset is disconnected while another BT headset
|
||||||
|
* is connected, don't mess with the headset device.
|
||||||
|
*/
|
||||||
|
if ((state == BluetoothProfile.STATE_DISCONNECTED ||
|
||||||
|
state == BluetoothProfile.STATE_DISCONNECTING) &&
|
||||||
|
mBluetoothHeadset != null &&
|
||||||
|
mBluetoothHeadset.getAudioState(btDevice) == BluetoothHeadset.STATE_AUDIO_CONNECTED) {
|
||||||
|
Log.w(TAG, "SCO connected through another device, returning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (mScoClients) {
|
synchronized (mScoClients) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
mBluetoothHeadsetDevice = btDevice;
|
mBluetoothHeadsetDevice = btDevice;
|
||||||
@@ -3107,7 +3122,6 @@ public class AudioService extends IAudioService.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener =
|
private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener =
|
||||||
new BluetoothProfile.ServiceListener() {
|
new BluetoothProfile.ServiceListener() {
|
||||||
@@ -5250,7 +5264,6 @@ public class AudioService extends IAudioService.Stub {
|
|||||||
state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
|
state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
|
||||||
BluetoothProfile.STATE_DISCONNECTED);
|
BluetoothProfile.STATE_DISCONNECTED);
|
||||||
BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||||
|
|
||||||
setBtScoDeviceConnectionState(btDevice, state);
|
setBtScoDeviceConnectionState(btDevice, state);
|
||||||
} else if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) {
|
} else if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) {
|
||||||
boolean broadcast = false;
|
boolean broadcast = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user