summaryrefslogtreecommitdiffstats
path: root/core/java/android/server
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2010-09-13 14:57:59 -0700
committerJaikumar Ganesh <jaikumar@google.com>2010-09-13 14:57:59 -0700
commit20c8f47330e7d4f5f191264f0d7ca67f6532adc2 (patch)
tree9e822ed87448a58738f1144c8b6627b3257e6d96 /core/java/android/server
parentb6b81f5f39f5ff5b8530717b4c015ef31d43e5d4 (diff)
parent0522f5e9b7dac0dc0229c9ddb07e7e5482846b1a (diff)
downloadframeworks_base-20c8f47330e7d4f5f191264f0d7ca67f6532adc2.zip
frameworks_base-20c8f47330e7d4f5f191264f0d7ca67f6532adc2.tar.gz
frameworks_base-20c8f47330e7d4f5f191264f0d7ca67f6532adc2.tar.bz2
resolved conflicts for merge of 0522f5e9 to master
Change-Id: Ie0a7ece33dced1042948087053e49665f6235fc2
Diffstat (limited to 'core/java/android/server')
-rw-r--r--core/java/android/server/BluetoothEventLoop.java23
-rw-r--r--core/java/android/server/BluetoothService.java89
2 files changed, 110 insertions, 2 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index fde3769..c066862 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -614,6 +614,17 @@ class BluetoothEventLoop {
mWakeLock.release();
}
+ private void onRequestOobData(String objectPath , int nativeData) {
+ String address = checkPairingRequestAndGetAddress(objectPath, nativeData);
+ if (address == null) return;
+
+ Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
+ intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
+ intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
+ BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT);
+ mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
+ }
+
private boolean onAgentAuthorize(String objectPath, String deviceUuid) {
if (!mBluetoothService.isEnabled()) return false;
@@ -672,6 +683,18 @@ class BluetoothEventLoop {
return false;
}
+ private boolean onAgentOutOfBandDataAvailable(String objectPath) {
+ if (!mBluetoothService.isEnabled()) return false;
+
+ String address = mBluetoothService.getAddressFromObjectPath(objectPath);
+ if (address == null) return false;
+
+ if (mBluetoothService.getDeviceOutOfBandData(
+ mAdapter.getRemoteDevice(address)) != null) {
+ return true;
+ }
+ }
+
private boolean isOtherSinkInNonDisconnectingState(String address) {
BluetoothA2dp a2dp = new BluetoothA2dp(mContext);
Set<BluetoothDevice> devices = a2dp.getNonDisconnectedSinks();
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 7252736..71f2477 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -55,6 +55,7 @@ import android.os.ServiceManager;
import android.os.SystemService;
import android.provider.Settings;
import android.util.Log;
+import android.util.Pair;
import com.android.internal.app.IBatteryStats;
@@ -144,6 +145,7 @@ public class BluetoothService extends IBluetooth.Stub {
private BluetoothA2dpService mA2dpService;
private final HashMap<BluetoothDevice, Integer> mInputDevices;
private final HashMap<BluetoothDevice, Integer> mPanDevices;
+ private final HashMap<String, Pair<byte[], byte[]>> mDeviceOobData;
private static String mDockAddress;
private String mDockPin;
@@ -200,6 +202,7 @@ public class BluetoothService extends IBluetooth.Stub {
mDeviceProperties = new HashMap<String, Map<String,String>>();
mDeviceServiceChannelCache = new HashMap<String, Map<ParcelUuid, Integer>>();
+ mDeviceOobData = new HashMap<String, Pair<byte[], byte[]>>();
mUuidIntentTracker = new ArrayList<String>();
mUuidCallbackTracker = new HashMap<RemoteService, IBluetoothCallback>();
mServiceRecordToPid = new HashMap<Integer, Integer>();
@@ -1155,7 +1158,7 @@ public class BluetoothService extends IBluetooth.Stub {
mIsDiscovering = isDiscovering;
}
- public synchronized boolean createBond(String address) {
+ private boolean isBondingFeasible(String address) {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
if (!isEnabledInternal()) return false;
@@ -1185,17 +1188,67 @@ public class BluetoothService extends IBluetooth.Stub {
return false;
}
}
+ return true;
+ }
+
+ public synchronized boolean createBond(String address) {
+ if (!isBondingFeasible(address)) return false;
+
+ if (!createPairedDeviceNative(address, 60000 /*1 minute*/ )) {
+ return false;
+ }
+
+ mBondState.setPendingOutgoingBonding(address);
+ mBondState.setBondState(address, BluetoothDevice.BOND_BONDING);
+
+ return true;
+ }
+
+ public synchronized boolean createBondOutOfBand(String address, byte[] hash,
+ byte[] randomizer) {
+ if (!isBondingFeasible(address)) return false;
- if (!createPairedDeviceNative(address, 60000 /* 1 minute */)) {
+ if (!createPairedDeviceOutOfBandNative(address, 60000 /* 1 minute */)) {
return false;
}
+ setDeviceOutOfBandData(address, hash, randomizer);
mBondState.setPendingOutgoingBonding(address);
mBondState.setBondState(address, BluetoothDevice.BOND_BONDING);
return true;
}
+ public synchronized boolean setDeviceOutOfBandData(String address, byte[] hash,
+ byte[] randomizer) {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
+ "Need BLUETOOTH_ADMIN permission");
+ if (!isEnabledInternal()) return false;
+
+ Pair <byte[], byte[]> value = new Pair<byte[], byte[]>(hash, randomizer);
+
+ if (DBG) {
+ log("Setting out of band data for:" + address + ":" +
+ Arrays.toString(hash) + ":" + Arrays.toString(randomizer));
+ }
+
+ mDeviceOobData.put(address, value);
+ return true;
+ }
+
+ Pair<byte[], byte[]> getDeviceOutOfBandData(BluetoothDevice device) {
+ return mDeviceOobData.get(device.getAddress());
+ }
+
+
+ public synchronized byte[] readOutOfBandData() {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM,
+ "Need BLUETOOTH permission");
+ if (!isEnabledInternal()) return null;
+
+ return readAdapterOutOfBandDataNative();
+ }
+
public synchronized boolean cancelBondProcess(String address) {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
@@ -1954,6 +2007,32 @@ public class BluetoothService extends IBluetooth.Stub {
return setPairingConfirmationNative(address, confirm, data.intValue());
}
+ public synchronized boolean setRemoteOutOfBandData(String address) {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
+ "Need BLUETOOTH_ADMIN permission");
+ if (!isEnabledInternal()) return false;
+ address = address.toUpperCase();
+ Integer data = mEventLoop.getPasskeyAgentRequestData().remove(address);
+ if (data == null) {
+ Log.w(TAG, "setRemoteOobData(" + address + ") called but no native data available, " +
+ "ignoring. Maybe the PasskeyAgent Request was cancelled by the remote device" +
+ " or by bluez.\n");
+ return false;
+ }
+
+ Pair<byte[], byte[]> val = mDeviceOobData.get(address);
+ byte[] hash, randomizer;
+ if (val == null) {
+ // TODO: check what should be passed in this case.
+ hash = new byte[16];
+ randomizer = new byte[16];
+ } else {
+ hash = val.first;
+ randomizer = val.second;
+ }
+ return setRemoteOutOfBandDataNative(address, hash, randomizer, data.intValue());
+ }
+
public synchronized boolean cancelPairingUserInput(String address) {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
@@ -2487,6 +2566,9 @@ public class BluetoothService extends IBluetooth.Stub {
private native boolean stopDiscoveryNative();
private native boolean createPairedDeviceNative(String address, int timeout_ms);
+ private native boolean createPairedDeviceOutOfBandNative(String address, int timeout_ms);
+ private native byte[] readAdapterOutOfBandDataNative();
+
private native boolean cancelDeviceCreationNative(String address);
private native boolean removeDeviceNative(String objectPath);
private native int getDeviceServiceChannelNative(String objectPath, String uuid,
@@ -2497,6 +2579,9 @@ public class BluetoothService extends IBluetooth.Stub {
private native boolean setPasskeyNative(String address, int passkey, int nativeData);
private native boolean setPairingConfirmationNative(String address, boolean confirm,
int nativeData);
+ private native boolean setRemoteOutOfBandDataNative(String address, byte[] hash,
+ byte[] randomizer, int nativeData);
+
private native boolean setDevicePropertyBooleanNative(String objectPath, String key,
int value);
private native boolean createDeviceNative(String address);