From 7f74d534f39c4d1e1db8604faa117dcf127cc8b9 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Tue, 14 Jul 2009 12:21:26 -0700 Subject: Reconnect to A2DP device only if it supports that profile, fix HF AG UUID. --- core/java/android/bluetooth/BluetoothUuid.java | 2 +- core/java/android/server/BluetoothA2dpService.java | 15 ++++++++++++++- core/java/android/server/BluetoothEventLoop.java | 4 +--- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/java/android/bluetooth/BluetoothUuid.java b/core/java/android/bluetooth/BluetoothUuid.java index 96b93f9..f8316a5 100644 --- a/core/java/android/bluetooth/BluetoothUuid.java +++ b/core/java/android/bluetooth/BluetoothUuid.java @@ -52,7 +52,7 @@ public final class BluetoothUuid { } public static boolean isHandsfree(UUID uuid) { - return uuid.equals(Handsfree) || uuid.equals(HandsfreeAudioGateway); + return uuid.equals(Handsfree); } public static boolean isHeadset(UUID uuid) { diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index 1cf7be9..722a7cc 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -104,7 +104,8 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { break; } } else if (action.equals(BluetoothIntent.REMOTE_DEVICE_CONNECTED_ACTION)) { - if (getSinkPriority(address) > BluetoothA2dp.PRIORITY_OFF) { + if (getSinkPriority(address) > BluetoothA2dp.PRIORITY_OFF && + isSinkDevice(address)) { // This device is a preferred sink. Make an A2DP connection // after a delay. We delay to avoid connection collisions, // and to give other profiles such as HFP a chance to @@ -185,6 +186,18 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { return -1; } + private boolean isSinkDevice(String address) { + String uuids[] = mBluetoothService.getRemoteUuids(address); + UUID uuid; + for (String deviceUuid: uuids) { + uuid = UUID.fromString(deviceUuid); + if (BluetoothUuid.isAudioSink(uuid)) { + return true; + } + } + return false; + } + private synchronized boolean addAudioSink (String address) { String path = mBluetoothService.getObjectPathFromAddress(address); String propValues[] = (String []) getSinkPropertiesNative(path); diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 38eb4d7..76906b6 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -371,9 +371,7 @@ class BluetoothEventLoop { boolean authorized = false; UUID uuid = UUID.fromString(deviceUuid); - if (mBluetoothService.isEnabled() && (BluetoothUuid.isAudioSink(uuid) || - BluetoothUuid.isAudioSource(uuid) || - BluetoothUuid.isAdvAudioDist(uuid))) { + if (mBluetoothService.isEnabled() && BluetoothUuid.isAudioSink(uuid)) { BluetoothA2dp a2dp = new BluetoothA2dp(mContext); authorized = a2dp.getSinkPriority(address) > BluetoothA2dp.PRIORITY_OFF; if (authorized) { -- cgit v1.1