summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-08-18 00:30:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-08-18 00:30:13 +0000
commit4a5fd86da31b5f4f07262a01fc1f283fb04e154f (patch)
tree04e564b1f52ba6450500767befea8965d35c4aae /core/java
parentc6e9d293084602f3d2e2653df5431b9492074a4f (diff)
parentd56a8bec5c22cc91350940100849867a5d700eb5 (diff)
Merge "Bluetooth: Fix startAdvertisingSet error handling" into oc-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/bluetooth/le/BluetoothLeAdvertiser.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
index fb9b19f1fddc..44c2667f2d85 100644
--- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -415,7 +415,8 @@ public final class BluetoothLeAdvertiser {
gatt = mBluetoothManager.getBluetoothGatt();
} catch (RemoteException e) {
Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
- throw new IllegalStateException("Failed to get Bluetooth");
+ postStartSetFailure(handler, callback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
+ return;
}
IAdvertisingSetCallback wrapped = wrap(callback, handler);
@@ -429,7 +430,8 @@ public final class BluetoothLeAdvertiser {
periodicData, duration, maxExtendedAdvertisingEvents, wrapped);
} catch (RemoteException e) {
Log.e(TAG, "Failed to start advertising set - ", e);
- throw new IllegalStateException("Failed to start advertising set");
+ postStartSetFailure(handler, callback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
+ return;
}
}
@@ -647,6 +649,16 @@ public final class BluetoothLeAdvertiser {
};
}
+ private void postStartSetFailure(Handler handler, final AdvertisingSetCallback callback,
+ final int error) {
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onAdvertisingSetStarted(null, 0, error);
+ }
+ });
+ }
+
private void postStartFailure(final AdvertiseCallback callback, final int error) {
mHandler.post(new Runnable() {
@Override