summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/BluetoothEventLoop.java
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2009-07-16 18:26:28 -0700
committerJaikumar Ganesh <jaikumar@google.com>2009-07-17 14:00:32 -0700
commit228b2f3a813e93413a0f9e2f29dfbfc54590a356 (patch)
tree9912bf96f82aef0fba304b25e3a25ec85cd324e1 /core/java/android/server/BluetoothEventLoop.java
parent0fde7de9d660e4acdb8404f954f75d8c331b5d45 (diff)
downloadframeworks_base-228b2f3a813e93413a0f9e2f29dfbfc54590a356.zip
frameworks_base-228b2f3a813e93413a0f9e2f29dfbfc54590a356.tar.gz
frameworks_base-228b2f3a813e93413a0f9e2f29dfbfc54590a356.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.java49
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() {