Reset the priority on unbond
Change-Id: I67b68bd70b947177218e0b908b79ebb9de9f45a8
This commit is contained in:
committed by
Matthew Xie
parent
b45e3c8fe9
commit
c70f548355
@@ -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() {
|
boolean isA2dpPlaying() {
|
||||||
if (mService == null) return false;
|
if (mService == null) return false;
|
||||||
List<BluetoothDevice> sinks = mService.getConnectedDevices();
|
List<BluetoothDevice> sinks = mService.getConnectedDevices();
|
||||||
|
@@ -514,8 +514,16 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
dispatchAttributesChanged();
|
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) {
|
void onBondingStateChanged(int bondState) {
|
||||||
if (bondState == BluetoothDevice.BOND_NONE) {
|
if (bondState == BluetoothDevice.BOND_NONE) {
|
||||||
|
clearProfilePriorities();
|
||||||
mProfiles.clear();
|
mProfiles.clear();
|
||||||
mConnectAfterPairing = false; // cancel auto-connect
|
mConnectAfterPairing = false; // cancel auto-connect
|
||||||
setPhonebookPermissionChoice(PHONEBOOK_ACCESS_UNKNOWN);
|
setPhonebookPermissionChoice(PHONEBOOK_ACCESS_UNKNOWN);
|
||||||
|
@@ -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() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
if (mService == null) return new ArrayList<BluetoothDevice>(0);
|
if (mService == null) return new ArrayList<BluetoothDevice>(0);
|
||||||
return mService.getDevicesMatchingConnectionStates(
|
return mService.getDevicesMatchingConnectionStates(
|
||||||
|
@@ -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() {
|
public String toString() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,8 @@ interface LocalBluetoothProfile {
|
|||||||
|
|
||||||
void setPreferred(BluetoothDevice device, boolean preferred);
|
void setPreferred(BluetoothDevice device, boolean preferred);
|
||||||
|
|
||||||
|
void setUnbonded(BluetoothDevice device);
|
||||||
|
|
||||||
boolean isProfileReady();
|
boolean isProfileReady();
|
||||||
|
|
||||||
/** Display order for device profile settings. */
|
/** Display order for device profile settings. */
|
||||||
|
@@ -63,6 +63,10 @@ final class OppProfile implements LocalBluetoothProfile {
|
|||||||
public void setPreferred(BluetoothDevice device, boolean preferred) {
|
public void setPreferred(BluetoothDevice device, boolean preferred) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUnbonded(BluetoothDevice device) {
|
||||||
|
// Settings app doesn't handle OPP
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isProfileReady() {
|
public boolean isProfileReady() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -117,6 +117,11 @@ final class PanProfile implements LocalBluetoothProfile {
|
|||||||
// ignore: isPreferred is always true for PAN
|
// ignore: isPreferred is always true for PAN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUnbonded(BluetoothDevice device)
|
||||||
|
{
|
||||||
|
// ignore: PAN profile cannot be disabled
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user