Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62172331 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Huizi Yang
Browse files

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
(cherry picked from commit 64e87514)
parent 76d35763
Loading
Loading
Loading
Loading
+28 −0
Original line number Original line Diff line number Diff line
@@ -1232,6 +1232,15 @@ public class GattService extends ProfileService {
        mScanManager.callbackDone(clientIf, status);
        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,
    void onBatchScanReports(int status, int scannerId, int reportType, int numRecords,
            byte[] recordData) throws RemoteException {
            byte[] recordData) throws RemoteException {
        if (DBG) {
        if (DBG) {
@@ -1244,6 +1253,18 @@ public class GattService extends ProfileService {
            // We only support single client for truncated mode.
            // We only support single client for truncated mode.
            ScannerMap.App app = mScannerMap.getById(scannerId);
            ScannerMap.App app = mScannerMap.getById(scannerId);
            if (app == null) return;
            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) {
            if (app.callback != null) {
                app.callback.onBatchScanResults(new ArrayList<ScanResult>(results));
                app.callback.onBatchScanResults(new ArrayList<ScanResult>(results));
            } else {
            } else {
@@ -1283,6 +1304,13 @@ public class GattService extends ProfileService {
            RemoteException {
            RemoteException {
        ScannerMap.App app = mScannerMap.getById(client.scannerId);
        ScannerMap.App app = mScannerMap.getById(client.scannerId);
        if (app == null) return;
        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()) {
        if (client.filters == null || client.filters.isEmpty()) {
            sendBatchScanResults(app, client, new ArrayList<ScanResult>(allResults));
            sendBatchScanResults(app, client, new ArrayList<ScanResult>(allResults));
            // TODO: Question to reviewer: Shouldn't there be a return here?
            // TODO: Question to reviewer: Shouldn't there be a return here?