Reset the priority on unbond

Change-Id: I67b68bd70b947177218e0b908b79ebb9de9f45a8
This commit is contained in:
Ravi Nagarajan
2012-06-29 19:24:16 +05:30
committed by Matthew Xie
parent b45e3c8fe9
commit c70f548355
7 changed files with 37 additions and 0 deletions

View File

@@ -151,6 +151,12 @@ final class A2dpProfile implements LocalBluetoothProfile {
}
}
public void setUnbonded(BluetoothDevice device)
{
if (mService == null) return;
mService.setPriority(device, BluetoothProfile.PRIORITY_UNDEFINED);
}
boolean isA2dpPlaying() {
if (mService == null) return false;
List<BluetoothDevice> sinks = mService.getConnectedDevices();

View File

@@ -514,8 +514,16 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
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);

View File

@@ -167,6 +167,12 @@ final class HeadsetProfile implements LocalBluetoothProfile {
}
}
public void setUnbonded(BluetoothDevice device)
{
if (mService == null) return;
mService.setPriority(device, BluetoothProfile.PRIORITY_UNDEFINED);
}
public List<BluetoothDevice> getConnectedDevices() {
if (mService == null) return new ArrayList<BluetoothDevice>(0);
return mService.getDevicesMatchingConnectionStates(

View File

@@ -118,6 +118,12 @@ final class HidProfile implements LocalBluetoothProfile {
}
}
public void setUnbonded(BluetoothDevice device)
{
if (mService == null) return;
mService.setPriority(device, BluetoothProfile.PRIORITY_UNDEFINED);
}
public String toString() {
return NAME;
}

View File

@@ -47,6 +47,8 @@ interface LocalBluetoothProfile {
void setPreferred(BluetoothDevice device, boolean preferred);
void setUnbonded(BluetoothDevice device);
boolean isProfileReady();
/** Display order for device profile settings. */

View File

@@ -63,6 +63,10 @@ final class OppProfile implements LocalBluetoothProfile {
public void setPreferred(BluetoothDevice device, boolean preferred) {
}
public void setUnbonded(BluetoothDevice device) {
// Settings app doesn't handle OPP
}
public boolean isProfileReady() {
return true;
}

View File

@@ -117,6 +117,11 @@ final class PanProfile implements LocalBluetoothProfile {
// ignore: isPreferred is always true for PAN
}
public void setUnbonded(BluetoothDevice device)
{
// ignore: PAN profile cannot be disabled
}
public String toString() {
return NAME;
}