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

Commit fed92f8c authored by Ajay Panicker's avatar Ajay Panicker Committed by Android (Google) Code Review
Browse files

Merge "Pass all scans to battery stats" into oc-dr1-dev

parents 2887c337 824d8f2f
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -157,15 +157,13 @@ import com.android.bluetooth.btservice.BluetoothProto;
        scanEvent.setInitiator(truncateAppName(appName));
        gattService.addScanEvent(scanEvent);

        if (!isScanning()) {
        if (!isScanning()) mScanStartTime = startTime;
        try {
            boolean isUnoptimized = !(scan.filtered || scan.background || scan.opportunistic);
                mScanStartTime = startTime;
            batteryStats.noteBleScanStarted(workSource, isUnoptimized);
        } catch (RemoteException e) {
            /* ignore */
        }
        }

        ongoingScans.put(scannerId, scan);
    }
@@ -193,20 +191,22 @@ import com.android.bluetooth.btservice.BluetoothProto;
        gattService.addScanEvent(scanEvent);

        if (!isScanning()) {
            try {
            long totalDuration = stopTime - mScanStartTime;
            mTotalScanTime += totalDuration;
            minScanTime = Math.min(totalDuration, minScanTime);
            maxScanTime = Math.max(totalDuration, maxScanTime);
        }

        try {
            // Inform battery stats of any results it might be missing on
            // scan stop
            boolean isUnoptimized = !(scan.filtered || scan.background || scan.opportunistic);
            batteryStats.noteBleScanResults(workSource, scan.results % 100);
                batteryStats.noteBleScanStopped(workSource);
            batteryStats.noteBleScanStopped(workSource, isUnoptimized);
        } catch (RemoteException e) {
            /* ignore */
        }
    }
    }

    synchronized void setScanTimeout(int scannerId) {
        if (!isScanning()) return;