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

Commit bd11ad34 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Add the Filter statistic to scan statistics

Test: sl4a FilterTest
Change-Id: Ic16e523524022803107b5e0653a35e3f2cbc5186
parent 94c53341
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -44,14 +44,16 @@ import com.android.bluetooth.btservice.BluetoothProto;
        boolean opportunistic;
        boolean timeout;
        boolean background;
        boolean filtered;
        int results;

        public LastScan(long timestamp, long duration,
                        boolean opportunistic, boolean background) {
        public LastScan(long timestamp, long duration, boolean opportunistic, boolean background,
                boolean filtered) {
            this.duration = duration;
            this.timestamp = timestamp;
            this.opportunistic = opportunistic;
            this.background = background;
            this.filtered = filtered;
            this.results = 0;
        }
    }
@@ -90,7 +92,7 @@ import com.android.bluetooth.btservice.BluetoothProto;
        results++;
    }

    synchronized void recordScanStart(ScanSettings settings) {
    synchronized void recordScanStart(ScanSettings settings, boolean filtered) {
        if (isScanning)
            return;

@@ -98,7 +100,7 @@ import com.android.bluetooth.btservice.BluetoothProto;
        isScanning = true;
        startTime = System.currentTimeMillis();

        LastScan scan = new LastScan(startTime, 0, false, false);
        LastScan scan = new LastScan(startTime, 0, false, false, filtered);
        if (settings != null) {
          scan.opportunistic = settings.getScanMode() == ScanSettings.SCAN_MODE_OPPORTUNISTIC;
          scan.background = (settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_FIRST_MATCH) != 0;
@@ -209,6 +211,7 @@ import com.android.bluetooth.btservice.BluetoothProto;
            if (lastScan.opportunistic) sb.append(" (Opportunistic)");
            if (lastScan.background) sb.append(" (Background)");
            if (lastScan.timeout) sb.append(" (Forced-Opportunistic)");
            if (lastScan.filtered) sb.append(" (Filtered)");
        }
        sb.append("\n");

@@ -237,6 +240,7 @@ import com.android.bluetooth.btservice.BluetoothProto;
                if (scan.opportunistic) sb.append("Opp ");
                if (scan.background) sb.append("Back ");
                if (scan.timeout) sb.append("Forced ");
                if (scan.filtered) sb.append("Filter ");
                sb.append(scan.results + " results");
                sb.append("\n");
            }
+3 −1
Original line number Diff line number Diff line
@@ -1350,7 +1350,9 @@ public class GattService extends ProfileService {
                return;
            }
            scanClient.stats = app;
            app.recordScanStart(settings);

            boolean isFilteredScan = (filters != null) && !filters.isEmpty();
            app.recordScanStart(settings, isFilteredScan);
        }

        mScanManager.startScan(scanClient);