diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2009-07-16 18:26:28 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-07-17 17:52:26 -0700 |
commit | b0eca41de0bb6747d8648b134912782e45e4cbef (patch) | |
tree | 6986cf82444e5a5c28b0da75932e83c76f35667f /core/java/android/server/BluetoothEventLoop.java | |
parent | fd7628aa84584e78cbe78e0c4fb4386312a98e05 (diff) | |
download | frameworks_base-b0eca41de0bb6747d8648b134912782e45e4cbef.zip frameworks_base-b0eca41de0bb6747d8648b134912782e45e4cbef.tar.gz frameworks_base-b0eca41de0bb6747d8648b134912782e45e4cbef.tar.bz2 |
Initial support of 2.1 pairing.
Note: Some cases have not been tested yet, as we would need to
get proper UI support.
Diffstat (limited to 'core/java/android/server/BluetoothEventLoop.java')
-rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 76906b6..dc84d1f 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -317,23 +317,53 @@ class BluetoothEventLoop { } mBluetoothService.setRemoteDeviceProperty(address, name, uuid); } - } - private void onRequestPinCode(String objectPath, int nativeData) { + private String checkPairingRequestAndGetAddress(String objectPath, int nativeData) { String address = mBluetoothService.getAddressFromObjectPath(objectPath); if (address == null) { - Log.e(TAG, "Unable to get device address in onRequestPinCode, returning null"); - return; + Log.e(TAG, "Unable to get device address in checkPairingRequestAndGetAddress, " + + "returning null"); + return null; } address = address.toUpperCase(); mPasskeyAgentRequestData.put(address, new Integer(nativeData)); if (mBluetoothService.getBluetoothState() == BluetoothDevice.BLUETOOTH_STATE_TURNING_OFF) { // shutdown path - mBluetoothService.cancelPin(address); - return; + mBluetoothService.cancelPairingUserInput(address); + return null; } + return address; + } + + private void onRequestConfirmation(String objectPath, int passkey, int nativeData) { + String address = checkPairingRequestAndGetAddress(objectPath, nativeData); + if (address == null) return; + + Intent intent = new Intent(BluetoothIntent.PAIRING_REQUEST_ACTION); + intent.putExtra(BluetoothIntent.ADDRESS, address); + intent.putExtra(BluetoothIntent.PASSKEY, passkey); + intent.putExtra(BluetoothIntent.PAIRING_VARIANT, + BluetoothDevice.PAIRING_VARIANT_CONFIRMATION); + mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); + return; + } + + private void onRequestPasskey(String objectPath, int nativeData) { + String address = checkPairingRequestAndGetAddress(objectPath, nativeData); + if (address == null) return; + + Intent intent = new Intent(BluetoothIntent.PAIRING_REQUEST_ACTION); + intent.putExtra(BluetoothIntent.ADDRESS, address); + intent.putExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PASSKEY); + mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); + return; + } + + private void onRequestPinCode(String objectPath, int nativeData) { + String address = checkPairingRequestAndGetAddress(objectPath, nativeData); + if (address == null) return; if (mBluetoothService.getBondState().getBondState(address) == BluetoothDevice.BOND_BONDING) { @@ -358,6 +388,7 @@ class BluetoothEventLoop { } Intent intent = new Intent(BluetoothIntent.PAIRING_REQUEST_ACTION); intent.putExtra(BluetoothIntent.ADDRESS, address); + intent.putExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); return; } @@ -386,9 +417,9 @@ class BluetoothEventLoop { } private void onAgentCancel() { - // We immediately response to DBUS Authorize() so this should not - // usually happen - log("onAgentCancel"); + Intent intent = new Intent(BluetoothIntent.PAIRING_CANCEL_ACTION); + mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); + return; } private void onRestartRequired() { |