summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Pawlowski <jpawlowski@google.com>2020-11-16 15:54:00 +0100
committerJakub Pawlowski <jpawlowski@google.com>2020-12-05 18:28:54 +0000
commitfe5f16ffa41c9bf99a94893dfa121de9f017c9b6 (patch)
tree40503cf75bd78b4c830bd6820b3dd7564e3764d1
parent0da6fbbaff48abd1342e2495b5bb8b769b02d12c (diff)
downloadBluetooth-fe5f16ffa41c9bf99a94893dfa121de9f017c9b6.tar.gz
Check permission before sending batch scan result
Use same checks as for regular scan results Bug: 172670415 Test: compilation Merged-In: I4274026943ce64a51a30c3fbf6cc85eec853ad4f Change-Id: I4274026943ce64a51a30c3fbf6cc85eec853ad4f
-rw-r--r--src/com/android/bluetooth/gatt/GattService.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java
index fd8551a3c..0c9135b2a 100644
--- a/src/com/android/bluetooth/gatt/GattService.java
+++ b/src/com/android/bluetooth/gatt/GattService.java
@@ -1531,6 +1531,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) {
@@ -1545,6 +1554,18 @@ public class GattService extends ProfileService {
if (app == null) {
return;
}
+
+ ScanClient client = findBatchScanClientById(scannerId);
+ if (client == null) {
+ return;
+ }
+
+ // Do no report if location mode is OFF or the client has no location permission
+ // PEERS_MAC_ADDRESS permission holders always get results
+ if (!hasScanResultPermission(client)) {
+ return;
+ }
+
if (app.callback != null) {
app.callback.onBatchScanResults(new ArrayList<ScanResult>(results));
} else {
@@ -1586,6 +1607,13 @@ public class GattService extends ProfileService {
if (app == null) {
return;
}
+
+ // Do no report if location mode is OFF or the client has no location permission
+ // PEERS_MAC_ADDRESS permission holders always get results
+ 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?