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

Commit 78ae8e04 authored by Bookatz's avatar Bookatz Committed by android-build-merger
Browse files

Merge "Batterystats BLE results counter takes in count" into oc-dev

am: 80fc1af1

Change-Id: I5b88079ab4bbefbc3e838e3ee8f90bfa961b0650
parents 1a3367a4 80fc1af1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ interface IBatteryStats {
    void noteBleScanStarted(in WorkSource ws);
    void noteBleScanStopped(in WorkSource ws);
    void noteResetBleScan();
    void noteBleScanResult(in WorkSource ws);
    void noteBleScanResults(in WorkSource ws, int numNewResults);

    HealthStatsParceler takeUidSnapshot(int uid);
    HealthStatsParceler[] takeUidSnapshots(in int[] uid);
+8 −4
Original line number Diff line number Diff line
@@ -935,6 +935,10 @@ public class BatteryStatsImpl extends BatteryStats {
            mCount.incrementAndGet();
        }

        void addAtomic(int delta) {
            mCount.addAndGet(delta);
        }

        /**
         * Clear state of this counter.
         */
@@ -4835,11 +4839,11 @@ public class BatteryStatsImpl extends BatteryStats {
        }
    }

    public void noteBluetoothScanResultFromSourceLocked(WorkSource ws) {
    public void noteBluetoothScanResultsFromSourceLocked(WorkSource ws, int numNewResults) {
        final int N = ws.size();
        for (int i = 0; i < N; i++) {
            int uid = mapUid(ws.get(i));
            getUidStatsLocked(uid).noteBluetoothScanResultLocked();
            getUidStatsLocked(uid).noteBluetoothScanResultsLocked(numNewResults);
        }
    }

@@ -6050,8 +6054,8 @@ public class BatteryStatsImpl extends BatteryStats {
            return mBluetoothScanResultCounter;
        }

        public void noteBluetoothScanResultLocked() {
            createBluetoothScanResultCounterLocked().stepAtomic();
        public void noteBluetoothScanResultsLocked(int numNewResults) {
            createBluetoothScanResultCounterLocked().addAtomic(numNewResults);
        }

        @Override
+4 −4
Original line number Diff line number Diff line
@@ -29,15 +29,15 @@ public class BatteryStatsNoteTest extends TestCase{
    private static final int UID = 10500;
    private static final WorkSource WS = new WorkSource(UID);

    /** Test that BatteryStatsImpl.Uid.noteBluetoothScanResultLocked. */
    /** Test that BatteryStatsImpl.Uid.noteBluetoothScanResultsLocked. */
    @SmallTest
    public void testNoteBluetoothScanResultLocked() throws Exception {
        MockBatteryStatsImpl bi = new MockBatteryStatsImpl(new MockClocks());
        bi.updateTimeBasesLocked(true, true, 0, 0);

        bi.noteBluetoothScanResultFromSourceLocked(WS);
        bi.noteBluetoothScanResultFromSourceLocked(WS);
        assertEquals(2,
        bi.noteBluetoothScanResultsFromSourceLocked(WS, 1);
        bi.noteBluetoothScanResultsFromSourceLocked(WS, 100);
        assertEquals(101,
                bi.getUidStats().get(UID).getBluetoothScanResultCounter()
                        .getCountLocked(STATS_SINCE_CHARGED));
    }
+2 −2
Original line number Diff line number Diff line
@@ -966,10 +966,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
    }

    @Override
    public void noteBleScanResult(WorkSource ws) {
    public void noteBleScanResults(WorkSource ws, int numNewResults) {
        enforceCallingPermission();
        synchronized (mStats) {
            mStats.noteBluetoothScanResultFromSourceLocked(ws);
            mStats.noteBluetoothScanResultsFromSourceLocked(ws, numNewResults);
        }
    }