Merge "Donot bind to GATT service when BLE is not supported" into jb-mr2-dev

This commit is contained in:
Matthew Xie
2013-05-09 21:14:47 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 5 deletions

View File

@ -1472,9 +1472,13 @@ public final class BluetoothAdapter {
try {
IBluetoothGatt iGatt = mManagerService.getBluetoothGatt();
if (iGatt == null) {
// BLE is not supported
return false;
}
UUID uuid = UUID.randomUUID();
GattCallbackWrapper wrapper = new GattCallbackWrapper(this, callback, serviceUuids);
iGatt.registerClient(new ParcelUuid(uuid), wrapper);
if (wrapper.scanStarted()) {
mLeScanClients.put(callback, wrapper);

View File

@ -1187,6 +1187,10 @@ public final class BluetoothDevice implements Parcelable {
IBluetoothManager managerService = adapter.getBluetoothManager();
try {
IBluetoothGatt iGatt = managerService.getBluetoothGatt();
if (iGatt == null) {
// BLE is not supported
return null;
}
BluetoothGatt gatt = new BluetoothGatt(context, iGatt, this);
gatt.connect(autoConnect, callback);
return gatt;