From 8f31e9d663f1f9909682fbc531c68df9fcbe376a Mon Sep 17 00:00:00 2001 From: Siim Sammul Date: Wed, 21 Jul 2021 19:13:24 +0100 Subject: [PATCH] Do not make a getThreadTimeMicro() call when it is not needed. This was accidentally changed with https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15080830 Bug: 193543224 Test: N/A no functionality change, just avoiding a method call Change-Id: If4579e96cd5aab41a46f60b5133938e81d608cff --- core/java/com/android/internal/os/BinderCallsStats.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/os/BinderCallsStats.java b/core/java/com/android/internal/os/BinderCallsStats.java index 6ce7cea12dfa3..be91aaca5d393 100644 --- a/core/java/com/android/internal/os/BinderCallsStats.java +++ b/core/java/com/android/internal/os/BinderCallsStats.java @@ -220,8 +220,9 @@ public class BinderCallsStats implements BinderInternal.Observer { public CallSession callStarted(Binder binder, int code, int workSourceUid) { noteNativeThreadId(); + boolean collectCpu = canCollect(); // We always want to collect data for latency if it's enabled, regardless of device state. - if (!mCollectLatencyData && !canCollect()) { + if (!mCollectLatencyData && !collectCpu) { return null; } @@ -233,7 +234,7 @@ public class BinderCallsStats implements BinderInternal.Observer { s.timeStarted = -1; s.recordedCall = shouldRecordDetailedData(); - if (mRecordingAllTransactionsForUid || s.recordedCall) { + if (collectCpu && (mRecordingAllTransactionsForUid || s.recordedCall)) { s.cpuTimeStarted = getThreadTimeMicro(); s.timeStarted = getElapsedRealtimeMicro(); } else if (mCollectLatencyData) {