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

Commit 640eeeaf authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add the Filter statistic to scan statistics"

parents 94c53341 bd11ad34
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -44,14 +44,16 @@ import com.android.bluetooth.btservice.BluetoothProto;
        boolean opportunistic;
        boolean opportunistic;
        boolean timeout;
        boolean timeout;
        boolean background;
        boolean background;
        boolean filtered;
        int results;
        int results;


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


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


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


        LastScan scan = new LastScan(startTime, 0, false, false);
        LastScan scan = new LastScan(startTime, 0, false, false, filtered);
        if (settings != null) {
        if (settings != null) {
          scan.opportunistic = settings.getScanMode() == ScanSettings.SCAN_MODE_OPPORTUNISTIC;
          scan.opportunistic = settings.getScanMode() == ScanSettings.SCAN_MODE_OPPORTUNISTIC;
          scan.background = (settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_FIRST_MATCH) != 0;
          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.opportunistic) sb.append(" (Opportunistic)");
            if (lastScan.background) sb.append(" (Background)");
            if (lastScan.background) sb.append(" (Background)");
            if (lastScan.timeout) sb.append(" (Forced-Opportunistic)");
            if (lastScan.timeout) sb.append(" (Forced-Opportunistic)");
            if (lastScan.filtered) sb.append(" (Filtered)");
        }
        }
        sb.append("\n");
        sb.append("\n");


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

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


        mScanManager.startScan(scanClient);
        mScanManager.startScan(scanClient);