summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/BluetoothEventLoop.java
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2009-12-17 14:59:10 -0800
committerJaikumar Ganesh <jaikumar@google.com>2009-12-17 15:08:48 -0800
commit577dd1f3e274b84876471c22efac578db94811fc (patch)
tree87cb5b6717655df9554c6f35ffb86712e0f08a18 /core/java/android/server/BluetoothEventLoop.java
parent24780ea60fab2c7fb399c88cd51151eccbbf383f (diff)
downloadframeworks_base-577dd1f3e274b84876471c22efac578db94811fc.zip
frameworks_base-577dd1f3e274b84876471c22efac578db94811fc.tar.gz
frameworks_base-577dd1f3e274b84876471c22efac578db94811fc.tar.bz2
Accept incoming connections if no other sink is in NonDisconnecting state.
Bluez sends SINK_STATE_CHANGE before onAgentAuthorize, so we may be already in CONNECTING state. This will happen with some A2DP kits which don't like us connecting and thus we will never be able to connect to them. Bug:2335345 Dr No: Hiroshi
Diffstat (limited to 'core/java/android/server/BluetoothEventLoop.java')
-rw-r--r--core/java/android/server/BluetoothEventLoop.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index 0d0d245..b28cf43 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -21,14 +21,15 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothUuid;
-import android.os.ParcelUuid;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
+import android.os.ParcelUuid;
import android.util.Log;
import java.util.HashMap;
+import java.util.Set;
/**
* TODO: Move this to
@@ -553,7 +554,7 @@ class BluetoothEventLoop {
if (mBluetoothService.isEnabled() &&
(BluetoothUuid.isAudioSource(uuid) || BluetoothUuid.isAvrcpTarget(uuid)
|| BluetoothUuid.isAdvAudioDist(uuid)) &&
- (a2dp.getNonDisconnectedSinks().size() == 0)) {
+ !isOtherSinkInNonDisconnectingState(address)) {
BluetoothDevice device = mAdapter.getRemoteDevice(address);
authorized = a2dp.getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF;
if (authorized) {
@@ -568,6 +569,16 @@ class BluetoothEventLoop {
return authorized;
}
+ boolean isOtherSinkInNonDisconnectingState(String address) {
+ BluetoothA2dp a2dp = new BluetoothA2dp(mContext);
+ Set<BluetoothDevice> devices = a2dp.getNonDisconnectedSinks();
+ if (devices.size() == 0) return false;
+ for(BluetoothDevice dev: devices) {
+ if (!dev.getAddress().equals(address)) return true;
+ }
+ return false;
+ }
+
private void onAgentCancel() {
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);