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

Commit 304ddcbb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix a bug that cause binder calls to be underreported."

parents fd1672a5 1c56b4d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ public class BinderCallsStats implements BinderInternal.Observer {
                // It helps to keep the memory usage down when sampling is enabled.
                final CallStat callStat = uidEntry.get(
                        callingUid, s.binderClass, s.transactionCode,
                        mDeviceState.isScreenInteractive());
                        screenInteractive);
                if (callStat != null) {
                    callStat.callCount++;
                }
+30 −0
Original line number Diff line number Diff line
@@ -718,6 +718,36 @@ public class BinderCallsStatsTest {
        assertEquals(2, callStats.recordedCallCount);
    }

    @Test
    public void testTrackScreenInteractiveDisabled_sampling() {
        TestBinderCallsStats bcs = new TestBinderCallsStats();
        bcs.setSamplingInterval(2);
        bcs.setTrackScreenInteractive(false);
        Binder binder = new Binder();

        mDeviceState.setScreenInteractive(false);
        CallSession callSession = bcs.callStarted(binder, 1, WORKSOURCE_UID);
        bcs.time += 10;
        bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE, WORKSOURCE_UID);

        mDeviceState.setScreenInteractive(true);
        callSession = bcs.callStarted(binder, 1, WORKSOURCE_UID);
        bcs.time += 1000;  // shoud be ignored.
        bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE, WORKSOURCE_UID);

        SparseArray<BinderCallsStats.UidEntry> uidEntries = bcs.getUidEntries();
        assertEquals(1, uidEntries.size());
        BinderCallsStats.UidEntry uidEntry = uidEntries.get(WORKSOURCE_UID);
        Assert.assertNotNull(uidEntry);
        assertEquals(2, uidEntry.callCount);

        List<BinderCallsStats.CallStat> callStatsList = new ArrayList(uidEntry.getCallStatsList());
        assertEquals(1, callStatsList.size());
        BinderCallsStats.CallStat callStats = callStatsList.get(0);
        assertEquals(false, callStats.screenInteractive);
        assertEquals(2, callStats.callCount);
        assertEquals(1, callStats.recordedCallCount);
    }

    class TestBinderCallsStats extends BinderCallsStats {
        public int callingUid = CALLING_UID;