diff options
| author | Matthew Xie <mattx@google.com> | 2013-05-08 19:26:57 -0700 |
|---|---|---|
| committer | The Android Automerger <android-build@android.com> | 2013-05-09 16:13:39 -0700 |
| commit | e1c0cbcd55ffffac4b5be78d8ed8d25315353af1 (patch) | |
| tree | 002654b2ddd4f90e90d194bfae33c2e9d25389af /core/java | |
| parent | b5a75b20aa276932dc2cb5131e7d7720e1e41822 (diff) | |
Donot bind to GATT service when BLE is not supported
bug 8664724
Change-Id: I9b9222cd5877babcded73798a5d1ff13fd10e791
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 6 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothDevice.java | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index cfbfb48d4a1f..7ec73ef74135 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -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); diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index 3c1ec90f19c3..79a5ffea46ab 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -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; |
