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

Commit 824d8f2f authored by Ajay Panicker's avatar Ajay Panicker Committed by Andre Eisenbach
Browse files

Pass all scans to battery stats

Also let battery stats know if the scan that was just stopped
was optimized or not.

Bug: 63456783
Test: runtest -x frameworks/base/core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Change-Id: Ic8308cdfe8654a7628fd6181dde9898483f528aa
parent 03b09b3a
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;