Merge "Collect binder latency data even when device is charging / device state is unknown." into sc-dev
This commit is contained in:
@@ -220,7 +220,8 @@ public class BinderCallsStats implements BinderInternal.Observer {
|
|||||||
public CallSession callStarted(Binder binder, int code, int workSourceUid) {
|
public CallSession callStarted(Binder binder, int code, int workSourceUid) {
|
||||||
noteNativeThreadId();
|
noteNativeThreadId();
|
||||||
|
|
||||||
if (!canCollect()) {
|
// We always want to collect data for latency if it's enabled, regardless of device state.
|
||||||
|
if (!mCollectLatencyData && !canCollect()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +268,11 @@ public class BinderCallsStats implements BinderInternal.Observer {
|
|||||||
mLatencyObserver.callEnded(s);
|
mLatencyObserver.callEnded(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Latency collection has already been processed so check if the rest should be processed.
|
||||||
|
if (!canCollect()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UidEntry uidEntry = null;
|
UidEntry uidEntry = null;
|
||||||
final boolean recordCall;
|
final boolean recordCall;
|
||||||
if (s.recordedCall) {
|
if (s.recordedCall) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.internal.os;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
@@ -968,6 +969,22 @@ public class BinderCallsStatsTest {
|
|||||||
assertEquals(1, bcs.getLatencyObserver().getLatencyHistograms().size());
|
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
|
@Test
|
||||||
public void testLatencyCollectionEnabledByDefault() {
|
public void testLatencyCollectionEnabledByDefault() {
|
||||||
TestBinderCallsStats bcs = new TestBinderCallsStats();
|
TestBinderCallsStats bcs = new TestBinderCallsStats();
|
||||||
|
|||||||
Reference in New Issue
Block a user