diff options
| author | 2018-08-06 17:45:38 +0200 | |
|---|---|---|
| committer | 2018-08-08 12:14:17 +0000 | |
| commit | 1f014f40103afa455dcc93a6de98127e0a8abb4b (patch) | |
| tree | 7525991ce28cd5e7c35bc0f10787d95cb363d10a | |
| parent | c874462c2de6e67fbb077f2ec0817a4a1af1c303 (diff) | |
Fix NPE when starting advertising with null GATT
Bug: 112164168
Change-Id: I82be0e06e990cc116d3ab48de80b5bb170d69892
| -rw-r--r-- | core/java/android/bluetooth/le/BluetoothLeAdvertiser.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java index 0fb4ba1a8765..13c5ff690973 100644 --- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java +++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java @@ -411,7 +411,14 @@ public final class BluetoothLeAdvertiser { try { gatt = mBluetoothManager.getBluetoothGatt(); } catch (RemoteException e) { - Log.e(TAG, "Failed to get Bluetooth gatt - ", e); + Log.e(TAG, "Failed to get Bluetooth GATT - ", e); + postStartSetFailure(handler, callback, + AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); + return; + } + + if (gatt == null) { + Log.e(TAG, "Bluetooth GATT is null"); postStartSetFailure(handler, callback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); return; |