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

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

Merge "Pass all scans to battery stats"

parents 142afcfb f565f454
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -164,15 +164,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);
    }
@@ -205,20 +203,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 recordScanSuspend(int scannerId) {
        LastScan scan = getScanFromScannerId(scannerId);