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

Commit 6aa10314 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Check permission before sending batch scan result" into qt-dev am: 88611d69

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/13063899

Change-Id: I423eb469df2a4c402c951ca88ff6e332cdfebb73
parents d7f482dc 88611d69
Loading
Loading
Loading
Loading
+26 −0
Original line number Original line Diff line number Diff line
@@ -1551,6 +1551,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) {
@@ -1565,6 +1574,17 @@ public class GattService extends ProfileService {
            if (app == null) {
            if (app == null) {
                return;
                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) {
            if (app.callback != null) {
                app.callback.onBatchScanResults(new ArrayList<ScanResult>(results));
                app.callback.onBatchScanResults(new ArrayList<ScanResult>(results));
            } else {
            } else {
@@ -1606,6 +1626,12 @@ public class GattService extends ProfileService {
        if (app == null) {
        if (app == null) {
            return;
            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()) {
        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?