Merge "Bluetooth: Multi HF support" into lmp-dev
This commit is contained in:
@@ -115,7 +115,7 @@ final class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
List<BluetoothDevice> sinks = mService.getConnectedDevices();
|
List<BluetoothDevice> sinks = mService.getConnectedDevices();
|
||||||
if (sinks != null) {
|
if (sinks != null) {
|
||||||
for (BluetoothDevice sink : sinks) {
|
for (BluetoothDevice sink : sinks) {
|
||||||
mService.disconnect(sink);
|
Log.d(TAG,"Not disconnecting device = " + sink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mService.connect(device);
|
return mService.connect(device);
|
||||||
@@ -124,24 +124,33 @@ final class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) return false;
|
||||||
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
|
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
|
||||||
if (!deviceList.isEmpty() && deviceList.get(0).equals(device)) {
|
if (!deviceList.isEmpty()) {
|
||||||
|
for (BluetoothDevice dev : deviceList) {
|
||||||
|
if (dev.equals(device)) {
|
||||||
|
if (V) Log.d(TAG,"Downgrade priority as user" +
|
||||||
|
"is disconnecting the headset");
|
||||||
// Downgrade priority as user is disconnecting the headset.
|
// Downgrade priority as user is disconnecting the headset.
|
||||||
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
|
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
|
||||||
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
|
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
|
||||||
}
|
}
|
||||||
return mService.disconnect(device);
|
return mService.disconnect(device);
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
if (mService == null) return BluetoothProfile.STATE_DISCONNECTED;
|
if (mService == null) return BluetoothProfile.STATE_DISCONNECTED;
|
||||||
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
|
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
|
||||||
|
if (!deviceList.isEmpty()){
|
||||||
return !deviceList.isEmpty() && deviceList.get(0).equals(device)
|
for (BluetoothDevice dev : deviceList) {
|
||||||
? mService.getConnectionState(device)
|
if (dev.equals(device)) {
|
||||||
: BluetoothProfile.STATE_DISCONNECTED;
|
return mService.getConnectionState(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BluetoothProfile.STATE_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPreferred(BluetoothDevice device) {
|
public boolean isPreferred(BluetoothDevice device) {
|
||||||
|
Reference in New Issue
Block a user