summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jakub Pawlowski <jpawlowski@google.com> 2016-11-22 12:44:22 -0800
committer Jakub Pawlowski <jpawlowski@google.com> 2016-11-22 13:38:15 -0800
commit76f517a173f79ad5789810188c4c36d3238b6f66 (patch)
tree2ae6c639b6050d57fcf7067449dbc4148ee48681
parent45c0c6939fb71a9f4bd7d9f0d5dcbe275e6db405 (diff)
Bluetooth: report proper advertiser status on error
When advertiser is not started because too many advertisers are registered, return proper error code. Bug: 30622771 Test: sl4a ConcurrentBleAdvertisingTest Change-Id: I57384ff30132e9a7ee17dcf191ff89baa7abf1ef
-rw-r--r--core/java/android/bluetooth/le/BluetoothLeAdvertiser.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
index 5d276623ce1c..94d03e533dff 100644
--- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -235,6 +235,7 @@ public final class BluetoothLeAdvertiser {
// >=0: registered and advertising started
private int mAdvertiserId;
private boolean mIsAdvertising = false;
+ private int registrationError = AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR;
public AdvertiseCallbackWrapper(AdvertiseCallback advertiseCallback,
AdvertiseData advertiseData, AdvertiseData scanResponse,
@@ -262,12 +263,11 @@ public final class BluetoothLeAdvertiser {
mLeAdvertisers.put(mAdvertiseCallback, this);
} else if (mAdvertiserId < 0) {
- // Registration timeout, reset mClientIf to -1 so no subsequent operations can
+ // Registration timeout, reset mClientIf to -2 so no subsequent operations can
// proceed.
- if (mAdvertiserId == 0) mAdvertiserId = -2;
+ if (mAdvertiserId == -1) mAdvertiserId = -2;
// Post internal error if registration failed.
- postStartFailure(mAdvertiseCallback,
- AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
+ postStartFailure(mAdvertiseCallback, registrationError);
} else {
// Unregister application if it's already registered but advertise failed.
try {
@@ -318,6 +318,8 @@ public final class BluetoothLeAdvertiser {
} catch (RemoteException e) {
Log.e(TAG, "failed to start advertising", e);
}
+ } else if (status == AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS) {
+ registrationError = status;
}
// Registration failed.
mAdvertiserId = -2;