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

Commit 26e17305 authored by Siim Sammul's avatar Siim Sammul Committed by Automerger Merge Worker
Browse files

Merge "Collect binder latency data even when device is charging / device state...

Merge "Collect binder latency data even when device is charging / device state is unknown." into sc-dev am: 764da8b1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15080830

Change-Id: I32ba75f264624570c4eff5b74db72e11a6f71fbf
parents 2b660bdd 764da8b1
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -220,7 +220,8 @@ public class BinderCallsStats implements BinderInternal.Observer {
    public CallSession callStarted(Binder binder, int code, int workSourceUid) {
        noteNativeThreadId();

        if (!canCollect()) {
        // We always want to collect data for latency if it's enabled, regardless of device state.
        if (!mCollectLatencyData && !canCollect()) {
            return null;
        }

@@ -267,6 +268,11 @@ public class BinderCallsStats implements BinderInternal.Observer {
            mLatencyObserver.callEnded(s);
        }

        // Latency collection has already been processed so check if the rest should be processed.
        if (!canCollect()) {
            return;
        }

        UidEntry uidEntry = null;
        final boolean recordCall;
        if (s.recordedCall) {
+17 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.os;
import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

@@ -968,6 +969,22 @@ public class BinderCallsStatsTest {
        assertEquals(1, bcs.getLatencyObserver().getLatencyHistograms().size());
    }

    @Test
    public void testLatencyCollectionActiveEvenWithoutDeviceState() {
        TestBinderCallsStats bcs = new TestBinderCallsStats(null);
        bcs.setCollectLatencyData(true);

        Binder binder = new Binder();
        CallSession callSession = bcs.callStarted(binder, 1, WORKSOURCE_UID);
        assertNotEquals(null, callSession);

        bcs.time += 10;
        bcs.elapsedTime += 20;
        bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE, WORKSOURCE_UID);

        assertEquals(1, bcs.getLatencyObserver().getLatencyHistograms().size());
    }

    @Test
    public void testLatencyCollectionEnabledByDefault() {
        TestBinderCallsStats bcs = new TestBinderCallsStats();