am dd2bf1d5: am c70f5483: Reset the priority on unbond

* commit 'dd2bf1d583bf186075b807152b98e3d30179cb2a':
  Reset the priority on unbond
This commit is contained in:
Ravi Nagarajan
2012-08-01 00:46:42 -07:00
committed by Android Git Automerger
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;
}