diff options
| author | Jaikumar Ganesh <jaikumar@google.com> | 2009-08-03 17:17:37 -0700 |
|---|---|---|
| committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-08-04 10:06:35 -0700 |
| commit | 9488cbd0b9ce0a9b49647910e76c6fa910f948ea (patch) | |
| tree | 0756301813c07fa7a75836804ba095a9ef1440ab /core/java/android/server/BluetoothEventLoop.java | |
| parent | afcc40ac718e85ffdcadc1b9f8ff1bcc82822f02 (diff) | |
Add incoming connections to the cache and change authorization check.
a) Add incoming connections to cache.
b) Some devices like DS970 sends Adv Audio as the UUID for incoming connection.
Diffstat (limited to 'core/java/android/server/BluetoothEventLoop.java')
| -rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index d98277703d0e..1704733c3e47 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -122,33 +122,41 @@ class BluetoothEventLoop { return isEventLoopRunningNative(); } - private void onDeviceFound(String address, String[] properties) { - if (properties == null) { - Log.e(TAG, "ERROR: Remote device properties are null"); - return; - } + private void addDevice(String address, String[] properties) { mBluetoothService.addRemoteDeviceProperties(address, properties); String rssi = mBluetoothService.getRemoteDeviceProperty(address, "RSSI"); String classValue = mBluetoothService.getRemoteDeviceProperty(address, "Class"); String name = mBluetoothService.getRemoteDeviceProperty(address, "Name"); - - if (rssi != null && classValue != null) { + short rssiValue; + // For incoming connections, we don't get the RSSI value. Use a default of MIN_VALUE. + // If we accept the pairing, we will automatically show it at the top of the list. + if (rssi != null) { + rssiValue = (short)Integer.valueOf(rssi).intValue(); + } else { + rssiValue = Short.MIN_VALUE; + } + if (classValue != null) { Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION); intent.putExtra(BluetoothIntent.ADDRESS, address); intent.putExtra(BluetoothIntent.CLASS, Integer.valueOf(classValue)); - intent.putExtra(BluetoothIntent.RSSI, (short)Integer.valueOf(rssi).intValue()); + intent.putExtra(BluetoothIntent.RSSI, rssiValue); intent.putExtra(BluetoothIntent.NAME, name); mContext.sendBroadcast(intent, BLUETOOTH_PERM); } else { - log ("RSSI: " + rssi + " or ClassValue: " + classValue + - " for remote device: " + address + " is null"); + log ("ClassValue: " + classValue + " for remote device: " + address + " is null"); } } - private void onDeviceDisappeared(String address) { - mBluetoothService.removeRemoteDeviceProperties(address); + private void onDeviceFound(String address, String[] properties) { + if (properties == null) { + Log.e(TAG, "ERROR: Remote device properties are null"); + return; + } + addDevice(address, properties); + } + private void onDeviceDisappeared(String address) { Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION); intent.putExtra(BluetoothIntent.ADDRESS, address); mContext.sendBroadcast(intent, BLUETOOTH_PERM); @@ -208,7 +216,14 @@ class BluetoothEventLoop { } private void onDeviceCreated(String deviceObjectPath) { - // do nothing. + String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath); + if (!mBluetoothService.isRemoteDeviceInCache(address)) { + // Incoming connection, we haven't seen this device, add to cache. + String[] properties = mBluetoothService.getRemoteDeviceProperties(address); + if (properties != null) { + addDevice(address, properties); + } + } return; } @@ -316,6 +331,13 @@ class BluetoothEventLoop { } } mBluetoothService.setRemoteDeviceProperty(address, name, uuid); + } else if (name.equals("Paired")) { + if (propValues[1].equals("true")) { + mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED); + } else { + mBluetoothService.getBondState().setBondState(address, + BluetoothDevice.BOND_NOT_BONDED); + } } } @@ -403,7 +425,8 @@ class BluetoothEventLoop { boolean authorized = false; UUID uuid = UUID.fromString(deviceUuid); if (mBluetoothService.isEnabled() && - (BluetoothUuid.isAudioSink(uuid) || BluetoothUuid.isAvrcpController(uuid))) { + (BluetoothUuid.isAudioSink(uuid) || BluetoothUuid.isAvrcpController(uuid) + || BluetoothUuid.isAdvAudioDist(uuid))) { BluetoothA2dp a2dp = new BluetoothA2dp(mContext); authorized = a2dp.getSinkPriority(address) > BluetoothA2dp.PRIORITY_OFF; if (authorized) { |
