Merge "Clone the CallStat objects/lists before dispatching it to the listener" into sc-dev

This commit is contained in:
Jing Ji
2021-03-10 02:16:46 +00:00
committed by Android (Google) Code Review

View File

@@ -120,8 +120,13 @@ public class BinderCallsStats implements BinderInternal.Observer {
UidEntry uidEntry = mUidEntries.get(mSendUidsToObserver.valueAt(i));
if (uidEntry != null) {
ArrayMap<CallStatKey, CallStat> callStats = uidEntry.mCallStats;
final int csize = callStats.size();
final ArrayList<CallStat> tmpCallStats = new ArrayList<>(csize);
for (int j = 0; j < csize; j++) {
tmpCallStats.add(callStats.valueAt(j).clone());
}
mCallStatsObserver.noteCallStats(uidEntry.workSourceUid,
uidEntry.incrementalCallCount, callStats.values()
uidEntry.incrementalCallCount, tmpCallStats
);
uidEntry.incrementalCallCount = 0;
for (int j = callStats.size() - 1; j >= 0; j--) {
@@ -829,6 +834,23 @@ public class BinderCallsStats implements BinderInternal.Observer {
this.screenInteractive = screenInteractive;
}
@Override
public CallStat clone() {
CallStat clone = new CallStat(callingUid, binderClass, transactionCode,
screenInteractive);
clone.recordedCallCount = recordedCallCount;
clone.callCount = callCount;
clone.cpuTimeMicros = cpuTimeMicros;
clone.maxCpuTimeMicros = maxCpuTimeMicros;
clone.latencyMicros = latencyMicros;
clone.maxLatencyMicros = maxLatencyMicros;
clone.maxRequestSizeBytes = maxRequestSizeBytes;
clone.maxReplySizeBytes = maxReplySizeBytes;
clone.exceptionCount = exceptionCount;
clone.incrementalCallCount = incrementalCallCount;
return clone;
}
@Override
public String toString() {
// This is expensive, but CallStat.toString() is only used for debugging.