Manage onfound/lost resources (1/2)
Provide error callback to app if advertisement tracking resources
can't be reserved
Change-Id: Ie66b2ec7a64b24bbdf3bb22003a4a7eb46623792
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 875aef6..3efbc2d 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -1305,9 +1305,12 @@
public boolean isHardwareTrackingFiltersAvailable() {
if (getState() != STATE_ON) return false;
try {
- synchronized(mManagerCallback) {
- if(mService != null) return (mService.numOfHwTrackFiltersAvailable() != 0);
+ IBluetoothGatt iGatt = mManagerService.getBluetoothGatt();
+ if (iGatt == null) {
+ // BLE is not supported
+ return false;
}
+ return (iGatt.numHwTrackFiltersAvailable() != 0);
} catch (RemoteException e) {
Log.e(TAG, "", e);
}
diff --git a/core/java/android/bluetooth/BluetoothGattCallbackWrapper.java b/core/java/android/bluetooth/BluetoothGattCallbackWrapper.java
index cdb24f4..01778b3 100644
--- a/core/java/android/bluetooth/BluetoothGattCallbackWrapper.java
+++ b/core/java/android/bluetooth/BluetoothGattCallbackWrapper.java
@@ -123,4 +123,7 @@
public void onFoundOrLost(boolean onFound, ScanResult scanResult) throws RemoteException {
}
+ @Override
+ public void onScanManagerErrorCallback(int errorCode) throws RemoteException {
+ }
}
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index f6001bf..a3eceb5 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -100,7 +100,6 @@
boolean isActivityAndEnergyReportingSupported();
void getActivityEnergyInfoFromController();
BluetoothActivityEnergyInfo reportActivityInfo();
- int numOfHwTrackFiltersAvailable();
// for dumpsys support
String dump();
diff --git a/core/java/android/bluetooth/IBluetoothGatt.aidl b/core/java/android/bluetooth/IBluetoothGatt.aidl
index 4ca57f8..72abeaf 100644
--- a/core/java/android/bluetooth/IBluetoothGatt.aidl
+++ b/core/java/android/bluetooth/IBluetoothGatt.aidl
@@ -103,4 +103,5 @@
in boolean confirm, in byte[] value);
void disconnectAll();
void unregAll();
+ int numHwTrackFiltersAvailable();
}
diff --git a/core/java/android/bluetooth/IBluetoothGattCallback.aidl b/core/java/android/bluetooth/IBluetoothGattCallback.aidl
index 91e62ea..cbba9f0 100644
--- a/core/java/android/bluetooth/IBluetoothGattCallback.aidl
+++ b/core/java/android/bluetooth/IBluetoothGattCallback.aidl
@@ -67,6 +67,7 @@
void onReadRemoteRssi(in String address, in int rssi, in int status);
void onMultiAdvertiseCallback(in int status, boolean isStart,
in AdvertiseSettings advertiseSettings);
+ void onScanManagerErrorCallback(in int errorCode);
void onConfigureMTU(in String address, in int mtu, in int status);
void onFoundOrLost(in boolean onFound, in ScanResult scanResult);
}
diff --git a/core/java/android/bluetooth/le/BluetoothLeScanner.java b/core/java/android/bluetooth/le/BluetoothLeScanner.java
index e184d1e2..9c3f3f1 100644
--- a/core/java/android/bluetooth/le/BluetoothLeScanner.java
+++ b/core/java/android/bluetooth/le/BluetoothLeScanner.java
@@ -381,6 +381,18 @@
}
});
}
+
+ @Override
+ public void onScanManagerErrorCallback(final int errorCode) {
+ if (VDBG) {
+ Log.d(TAG, "onScanManagerErrorCallback() - errorCode = " + errorCode);
+ }
+ synchronized (this) {
+ if (mClientIf <= 0)
+ return;
+ }
+ postCallbackError(mScanCallback, errorCode);
+ }
}
private void postCallbackError(final ScanCallback callback, final int errorCode) {