diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2010-12-10 17:51:52 -0800 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2010-12-10 17:51:52 -0800 |
commit | 498d12bac0df509a4f74a4df8a8c69ec22583a1a (patch) | |
tree | d6f26409f37c298faa7587fd6b5f1aa02257e087 | |
parent | 7553ebea45f7e5dba91224b2749be304a2a27d8f (diff) | |
download | packages_apps_Settings-498d12bac0df509a4f74a4df8a8c69ec22583a1a.tar.gz packages_apps_Settings-498d12bac0df509a4f74a4df8a8c69ec22583a1a.tar.bz2 packages_apps_Settings-498d12bac0df509a4f74a4df8a8c69ec22583a1a.zip |
Add ability to connect to only headset profile.
Fix some SDP records issues.
Change-Id: I42816527b1ae0749b4b59b7947f1acb9d2e6f001
3 files changed, 30 insertions, 16 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index f89cc89c6..aae13115a 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -353,7 +353,7 @@ public class BluetoothSettings extends SettingsPreferenceFragment case BluetoothDevicePicker.FILTER_TYPE_AUDIO: if (uuids != null) { if (BluetoothUuid.containsAnyUuid(uuids, - LocalBluetoothProfileManager.A2DP_PROFILE_UUIDS)) return true; + LocalBluetoothProfileManager.A2DP_SINK_PROFILE_UUIDS)) return true; if (BluetoothUuid.containsAnyUuid(uuids, LocalBluetoothProfileManager.HEADSET_PROFILE_UUIDS)) return true; diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 76a5b9928..df455b376 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -589,7 +589,11 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> ParcelUuid[] uuids = mDevice.getUuids(); if (uuids == null) return false; - LocalBluetoothProfileManager.updateProfiles(uuids, mProfiles); + BluetoothAdapter adapter = mLocalManager.getBluetoothAdapter(); + ParcelUuid[] localUuids = adapter.getUuids(); + if (localUuids == null) return false; + + LocalBluetoothProfileManager.updateProfiles(uuids, localUuids, mProfiles); if (DEBUG) { Log.e(TAG, "updating profiles for " + mDevice.getName()); diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java index 885706f39..f177ed073 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java @@ -48,11 +48,15 @@ public abstract class LocalBluetoothProfileManager { BluetoothUuid.Handsfree, }; - /* package */ static final ParcelUuid[] A2DP_PROFILE_UUIDS = new ParcelUuid[] { + /* package */ static final ParcelUuid[] A2DP_SINK_PROFILE_UUIDS = new ParcelUuid[] { BluetoothUuid.AudioSink, BluetoothUuid.AdvAudioDist, }; + /* package */ static final ParcelUuid[] A2DP_SRC_PROFILE_UUIDS = new ParcelUuid[] { + BluetoothUuid.AudioSource + }; + /* package */ static final ParcelUuid[] OPP_PROFILE_UUIDS = new ParcelUuid[] { BluetoothUuid.ObexObjectPush }; @@ -124,25 +128,24 @@ public abstract class LocalBluetoothProfileManager { // TODO(): Combine the init and updateLocalProfiles codes. // init can get called from various paths, it makes no sense to add and then delete. public static void updateLocalProfiles(LocalBluetoothManager localManager, ParcelUuid[] uuids) { - if (!BluetoothUuid.containsAnyUuid(uuids, HEADSET_PROFILE_UUIDS)) { + if (!BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree_AG) && + !BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HSP_AG)) { sProfileMap.remove(Profile.HEADSET); } - if (BluetoothUuid.containsAnyUuid(uuids, A2DP_PROFILE_UUIDS)) { + if (!BluetoothUuid.containsAnyUuid(uuids, A2DP_SRC_PROFILE_UUIDS)) { sProfileMap.remove(Profile.A2DP); } - if (BluetoothUuid.containsAnyUuid(uuids, OPP_PROFILE_UUIDS)) { + if (!BluetoothUuid.containsAnyUuid(uuids, OPP_PROFILE_UUIDS)) { sProfileMap.remove(Profile.OPP); } - if (BluetoothUuid.containsAnyUuid(uuids, HID_PROFILE_UUIDS)) { - sProfileMap.remove(Profile.HID); - } - - if (BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS)) { + if (!BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS)) { sProfileMap.remove(Profile.PAN); } + + // There is no local SDP record for HID and Settings app doesn't control PBAP } private static LinkedList<ServiceListener> mServiceListeners = @@ -186,21 +189,28 @@ public abstract class LocalBluetoothProfileManager { * NOTE: This list happens to define the connection order. We should put this logic in a more * well known place when this method is no longer temporary. * @param uuids of the remote device + * @param localUuids UUIDs of the local device * @param profiles The list of profiles to fill */ - public static void updateProfiles(ParcelUuid[] uuids, List<Profile> profiles) { + public static void updateProfiles(ParcelUuid[] uuids, ParcelUuid[] localUuids, + List<Profile> profiles) { profiles.clear(); if (uuids == null) { return; } - if (BluetoothUuid.containsAnyUuid(uuids, HEADSET_PROFILE_UUIDS) && - sProfileMap.containsKey(Profile.HEADSET)) { - profiles.add(Profile.HEADSET); + if (sProfileMap.containsKey(Profile.HEADSET)) { + if ((BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.HSP_AG) && + BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HSP)) || + (BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.Handsfree_AG) && + BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree))) { + profiles.add(Profile.HEADSET); + } } - if (BluetoothUuid.containsAnyUuid(uuids, A2DP_PROFILE_UUIDS) && + + if (BluetoothUuid.containsAnyUuid(uuids, A2DP_SINK_PROFILE_UUIDS) && sProfileMap.containsKey(Profile.A2DP)) { profiles.add(Profile.A2DP); } |