Auto connect hf/a2dp

Change-Id: I4cb260a1f794c2e094a0b19bdc1df919c4287232
This commit is contained in:
Swaminatha Balaji
2012-04-27 09:18:38 -07:00
committed by Matthew Xie
parent 83b0d575dd
commit 2ac143fff7
4 changed files with 109 additions and 3 deletions

16
src/com/android/settings/bluetooth/HeadsetProfile.java Normal file → Executable file
View File

@@ -63,6 +63,7 @@ final class HeadsetProfile implements LocalBluetoothProfile {
// headset device.
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
if (deviceList.isEmpty()) {
mProfileManager.setHfServiceUp(true);
return;
}
BluetoothDevice firstDevice = deviceList.get(0);
@@ -76,12 +77,14 @@ final class HeadsetProfile implements LocalBluetoothProfile {
BluetoothProfile.STATE_CONNECTED);
mProfileManager.callServiceConnectedListeners();
mProfileManager.setHfServiceUp(true);
}
public void onServiceDisconnected(int profile) {
mProfileReady = false;
mService = null;
mProfileManager.callServiceDisconnectedListeners();
mProfileManager.setHfServiceUp(false);
}
}
@@ -158,6 +161,19 @@ final class HeadsetProfile implements LocalBluetoothProfile {
}
}
// This function is added as the AUTO CONNECT priority could not be set by using setPreferred(),
// as setPreferred() takes only boolean input but getPreferred() supports interger output.
// Also this need not implemented by all profiles so this has been added here.
public void enableAutoConnect(BluetoothDevice device, boolean enable) {
if (enable) {
mService.setPriority(device, BluetoothProfile.PRIORITY_AUTO_CONNECT);
} else {
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
}
}
}
public synchronized boolean isProfileReady() {
return mProfileReady;
}