summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-01-15 19:18:53 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-01-15 19:18:53 +0000
commit424a7c27a26fd16512a8bc330b4b033ff5a13f52 (patch)
tree690d25f6030c8bee185ebe7d4f6097925afa507c
parente1806f9a0a9bf6c6baccf938cc11339f2c6fc65d (diff)
parentaeeb3ecc30902e0540dc7feb7c80dcd752ce1e1d (diff)
downloadBluetooth-424a7c27a26fd16512a8bc330b4b033ff5a13f52.tar.gz
Snap for 7084909 from aeeb3ecc30902e0540dc7feb7c80dcd752ce1e1d to qt-aml-tzdata-releaseandroid-mainline-10.0.0_r12
Change-Id: I86cadef846d9a04d0c70ad4ec3a06894d7fead52
-rw-r--r--src/com/android/bluetooth/gatt/AdvertiseManager.java42
-rw-r--r--src/com/android/bluetooth/gatt/GattService.java26
2 files changed, 67 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/gatt/AdvertiseManager.java b/src/com/android/bluetooth/gatt/AdvertiseManager.java
index 85917a471..b76d8619d 100644
--- a/src/com/android/bluetooth/gatt/AdvertiseManager.java
+++ b/src/com/android/bluetooth/gatt/AdvertiseManager.java
@@ -217,7 +217,7 @@ class AdvertiseManager {
Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
if (entry == null) {
- Log.i(TAG, "onOwnAddressRead() - bad advertiserId " + advertiserId);
+ Log.w(TAG, "onOwnAddressRead() - bad advertiserId " + advertiserId);
return;
}
@@ -226,6 +226,11 @@ class AdvertiseManager {
}
void getOwnAddress(int advertiserId) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "getOwnAddress() - bad advertiserId " + advertiserId);
+ return;
+ }
getOwnAddressNative(advertiserId);
}
@@ -260,37 +265,72 @@ class AdvertiseManager {
}
void enableAdvertisingSet(int advertiserId, boolean enable, int duration, int maxExtAdvEvents) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "enableAdvertisingSet() - bad advertiserId " + advertiserId);
+ return;
+ }
enableAdvertisingSetNative(advertiserId, enable, duration, maxExtAdvEvents);
}
void setAdvertisingData(int advertiserId, AdvertiseData data) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "setAdvertisingData() - bad advertiserId " + advertiserId);
+ return;
+ }
String deviceName = AdapterService.getAdapterService().getName();
setAdvertisingDataNative(advertiserId,
AdvertiseHelper.advertiseDataToBytes(data, deviceName));
}
void setScanResponseData(int advertiserId, AdvertiseData data) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "setScanResponseData() - bad advertiserId " + advertiserId);
+ return;
+ }
String deviceName = AdapterService.getAdapterService().getName();
setScanResponseDataNative(advertiserId,
AdvertiseHelper.advertiseDataToBytes(data, deviceName));
}
void setAdvertisingParameters(int advertiserId, AdvertisingSetParameters parameters) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "setAdvertisingParameters() - bad advertiserId " + advertiserId);
+ return;
+ }
setAdvertisingParametersNative(advertiserId, parameters);
}
void setPeriodicAdvertisingParameters(int advertiserId,
PeriodicAdvertisingParameters parameters) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "setPeriodicAdvertisingParameters() - bad advertiserId " + advertiserId);
+ return;
+ }
setPeriodicAdvertisingParametersNative(advertiserId, parameters);
}
void setPeriodicAdvertisingData(int advertiserId, AdvertiseData data) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "setPeriodicAdvertisingData() - bad advertiserId " + advertiserId);
+ return;
+ }
String deviceName = AdapterService.getAdapterService().getName();
setPeriodicAdvertisingDataNative(advertiserId,
AdvertiseHelper.advertiseDataToBytes(data, deviceName));
}
void setPeriodicAdvertisingEnable(int advertiserId, boolean enable) {
+ Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiserId);
+ if (entry == null) {
+ Log.w(TAG, "setPeriodicAdvertisingEnable() - bad advertiserId " + advertiserId);
+ return;
+ }
setPeriodicAdvertisingEnableNative(advertiserId, enable);
}
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java
index 5f2b42e7a..032780da1 100644
--- a/src/com/android/bluetooth/gatt/GattService.java
+++ b/src/com/android/bluetooth/gatt/GattService.java
@@ -1551,6 +1551,15 @@ public class GattService extends ProfileService {
mScanManager.callbackDone(clientIf, status);
}
+ ScanClient findBatchScanClientById(int scannerId) {
+ for (ScanClient client : mScanManager.getBatchScanQueue()) {
+ if (client.scannerId == scannerId) {
+ return client;
+ }
+ }
+ return null;
+ }
+
void onBatchScanReports(int status, int scannerId, int reportType, int numRecords,
byte[] recordData) throws RemoteException {
if (DBG) {
@@ -1565,6 +1574,17 @@ public class GattService extends ProfileService {
if (app == null) {
return;
}
+
+ ScanClient client = findBatchScanClientById(scannerId);
+ if (client == null) {
+ return;
+ }
+
+ // Do not report if location mode is OFF or the client has no location permission
+ if (!hasScanResultPermission(client)) {
+ return;
+ }
+
if (app.callback != null) {
app.callback.onBatchScanResults(new ArrayList<ScanResult>(results));
} else {
@@ -1606,6 +1626,12 @@ public class GattService extends ProfileService {
if (app == null) {
return;
}
+
+ // Do not report if location mode is OFF or the client has no location permission
+ if (!hasScanResultPermission(client)) {
+ return;
+ }
+
if (client.filters == null || client.filters.isEmpty()) {
sendBatchScanResults(app, client, new ArrayList<ScanResult>(allResults));
// TODO: Question to reviewer: Shouldn't there be a return here?