diff options
11 files changed, 98 insertions, 82 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java index 96aee512c090..a2bd210b67a6 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java @@ -155,8 +155,8 @@ public class A2dpProfile implements LocalBluetoothProfile { public boolean disconnect(BluetoothDevice device) { if (mService == null) return false; // Downgrade priority as user is disconnecting the headset. - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON){ - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -179,23 +179,29 @@ public class A2dpProfile implements LocalBluetoothProfile { } public boolean isPreferred(BluetoothDevice device) { - if (mService == null) return false; - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + if (mService == null) { + return false; + } + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { - if (mService == null) return BluetoothProfile.PRIORITY_OFF; - return mService.getPriority(device); + if (mService == null) { + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; + } + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { - if (mService == null) return; + if (mService == null) { + return; + } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } boolean isA2dpPlaying() { diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java index 55765dd40d36..9c896c80b409 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java @@ -124,8 +124,8 @@ final class A2dpSinkProfile implements LocalBluetoothProfile { return false; } // Downgrade priority as user is disconnecting the headset. - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -141,14 +141,14 @@ final class A2dpSinkProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { if (mService == null) { - return BluetoothProfile.PRIORITY_OFF; + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } - return mService.getPriority(device); + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { @@ -156,11 +156,11 @@ final class A2dpSinkProfile implements LocalBluetoothProfile { return; } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java index 9f7b7181b19f..560cb3b9b5b4 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java @@ -120,8 +120,8 @@ public class HeadsetProfile implements LocalBluetoothProfile { return false; } // Downgrade priority as user is disconnecting the headset. - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -165,14 +165,14 @@ public class HeadsetProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { if (mService == null) { - return BluetoothProfile.PRIORITY_OFF; + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } - return mService.getPriority(device); + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { @@ -180,11 +180,11 @@ public class HeadsetProfile implements LocalBluetoothProfile { return; } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java index ebaeb742b198..58655a2b930a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java @@ -153,8 +153,8 @@ public class HearingAidProfile implements LocalBluetoothProfile { public boolean disconnect(BluetoothDevice device) { if (mService == null) return false; // Downgrade priority as user is disconnecting the hearing aid. - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON){ - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -177,23 +177,29 @@ public class HearingAidProfile implements LocalBluetoothProfile { } public boolean isPreferred(BluetoothDevice device) { - if (mService == null) return false; - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + if (mService == null) { + return false; + } + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { - if (mService == null) return BluetoothProfile.PRIORITY_OFF; - return mService.getPriority(device); + if (mService == null) { + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; + } + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { - if (mService == null) return; + if (mService == null) { + return; + } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java index 860b77d1ebcd..a372e23654e0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java @@ -135,8 +135,8 @@ final class HfpClientProfile implements LocalBluetoothProfile { return false; } // Downgrade priority as user is disconnecting the headset. - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON){ - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -154,15 +154,15 @@ final class HfpClientProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } @Override public int getPreferred(BluetoothDevice device) { if (mService == null) { - return BluetoothProfile.PRIORITY_OFF; + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } - return mService.getPriority(device); + return mService.getConnectionPolicy(device); } @Override @@ -171,11 +171,11 @@ final class HfpClientProfile implements LocalBluetoothProfile { return; } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java index 6d874ab2be9b..975a1e67af5b 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java @@ -116,23 +116,27 @@ public class HidProfile implements LocalBluetoothProfile { } public boolean isPreferred(BluetoothDevice device) { - if (mService == null) return false; - return mService.getPriority(device) != BluetoothProfile.PRIORITY_OFF; + if (mService == null) { + return false; + } + return mService.getConnectionPolicy(device) != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { - if (mService == null) return BluetoothProfile.PRIORITY_OFF; - return mService.getPriority(device); + if (mService == null) { + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; + } + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { if (mService == null) return; if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java index d4dda329fa63..95139a1bfab9 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java @@ -123,8 +123,8 @@ public final class MapClientProfile implements LocalBluetoothProfile { return false; } // Downgrade priority as user is disconnecting. - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -140,14 +140,14 @@ public final class MapClientProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { if (mService == null) { - return BluetoothProfile.PRIORITY_OFF; + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } - return mService.getPriority(device); + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { @@ -155,11 +155,11 @@ public final class MapClientProfile implements LocalBluetoothProfile { return; } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java index b2a9a6a28231..31a0eea56b42 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java @@ -119,8 +119,8 @@ public class MapProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -136,14 +136,14 @@ public class MapProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { if (mService == null) { - return BluetoothProfile.PRIORITY_OFF; + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } - return mService.getPriority(device); + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { @@ -151,11 +151,11 @@ public class MapProfile implements LocalBluetoothProfile { return; } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java index e1e5dbe29a1a..8e3f3edcef10 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OppProfile.java @@ -57,7 +57,7 @@ final class OppProfile implements LocalBluetoothProfile { } public int getPreferred(BluetoothDevice device) { - return BluetoothProfile.PRIORITY_OFF; // Settings app doesn't handle OPP + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; // Settings app doesn't handle OPP } public void setPreferred(BluetoothDevice device, boolean preferred) { diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java index a2da4fb30e39..4ea0df621bea 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java @@ -151,14 +151,14 @@ public final class PbapClientProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { if (mService == null) { - return BluetoothProfile.PRIORITY_OFF; + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } - return mService.getPriority(device); + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { @@ -166,11 +166,11 @@ public final class PbapClientProfile implements LocalBluetoothProfile { return; } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java index 9b733f2e0e50..0ca4d6195a32 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java @@ -119,8 +119,8 @@ final class SapProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } return mService.disconnect(device); } @@ -136,14 +136,14 @@ final class SapProfile implements LocalBluetoothProfile { if (mService == null) { return false; } - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; + return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } public int getPreferred(BluetoothDevice device) { if (mService == null) { - return BluetoothProfile.PRIORITY_OFF; + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } - return mService.getPriority(device); + return mService.getConnectionPolicy(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { @@ -151,11 +151,11 @@ final class SapProfile implements LocalBluetoothProfile { return; } if (preferred) { - if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED); } } else { - mService.setPriority(device, BluetoothProfile.PRIORITY_OFF); + mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); } } |