Remove Profile Auto connection specific logic

Remove  profile auto connection specific logic as it is not implemented in
Bluetooth app
Disconnect PBAP server connection  when user initiates device level disconnection

Change-Id: I381ed96f6b57f414bbaccd694f55d2b992e330a4
This commit is contained in:
Ganesh Ganapathi Batta
2012-07-31 16:12:46 -07:00
committed by Matthew Xie
parent 9effd14611
commit 0654b71534
10 changed files with 165 additions and 262 deletions

View File

@@ -119,30 +119,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
Log.d(TAG, "onProfileStateChanged: profile " + profile +
" newProfileState " + newProfileState);
}
if (profile instanceof HeadsetProfile) {
if (newProfileState == BluetoothProfile.STATE_CONNECTED) {
if (BluetoothProfile.PRIORITY_AUTO_CONNECT != profile.getPreferred(mDevice))
mProfileManager.enableAutoConnectForHf(mDevice, true);
} else if (newProfileState == BluetoothProfile.STATE_DISCONNECTED) {
// dont reset auto connect priority when bluetooth turned off
if ((BluetoothAdapter.STATE_ON == mLocalAdapter.getBluetoothState())
|| (BluetoothAdapter.STATE_TURNING_ON == mLocalAdapter.getBluetoothState())) {
mProfileManager.enableAutoConnectForHf(mDevice, false);
}
}
} else if (profile instanceof A2dpProfile ) {
if (newProfileState == BluetoothProfile.STATE_CONNECTED) {
if (BluetoothProfile.PRIORITY_AUTO_CONNECT != profile.getPreferred(mDevice))
mProfileManager.enableAutoConnectForA2dp(mDevice,true);
} else if (newProfileState == BluetoothProfile.STATE_DISCONNECTED) {
// dont reset auto connect priority when bluetooth turned off
if ((BluetoothAdapter.STATE_ON == mLocalAdapter.getBluetoothState())
|| (BluetoothAdapter.STATE_TURNING_ON == mLocalAdapter.getBluetoothState())) {
mProfileManager.enableAutoConnectForA2dp(mDevice, false);
}
}
}
mProfileConnectionState.put(profile, newProfileState);
if (newProfileState == BluetoothProfile.STATE_CONNECTED) {
if (!mProfiles.contains(profile)) {
@@ -180,6 +156,14 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
for (LocalBluetoothProfile profile : mProfiles) {
disconnect(profile);
}
// Disconnect PBAP server in case its connected
// This is to ensure all the profiles are disconnected as some CK/Hs do not
// disconnect PBAP connection when HF connection is brought down
PbapServerProfile PbapProfile = mProfileManager.getPbapProfile();
if (PbapProfile.getConnectionStatus(mDevice) == BluetoothProfile.STATE_CONNECTED)
{
PbapProfile.disconnect(mDevice);
}
}
void disconnect(LocalBluetoothProfile profile) {
@@ -507,23 +491,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
.elapsedRealtime()) {
connectWithoutResettingTimer(false);
}
// On an incoming pairing, set all the available profiles as preferred.
for (LocalBluetoothProfile profile : mProfiles) {
profile.setPreferred(mDevice, true);
}
dispatchAttributesChanged();
}
// Clear service priority of Hid, A2DP and Headset profiles on unbond
private void clearProfilePriorities() {
for (LocalBluetoothProfile profile : mProfiles) {
profile.setUnbonded(mDevice);
}
}
void onBondingStateChanged(int bondState) {
if (bondState == BluetoothDevice.BOND_NONE) {
clearProfilePriorities();
mProfiles.clear();
mConnectAfterPairing = false; // cancel auto-connect
setPhonebookPermissionChoice(PHONEBOOK_ACCESS_UNKNOWN);