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

Commit 2b2e73d1 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

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

parents 5b718616 9caf734d
Loading
Loading
Loading
Loading
+23 −1
Original line number Original line Diff line number Diff line
@@ -120,8 +120,13 @@ public class BinderCallsStats implements BinderInternal.Observer {
                    UidEntry uidEntry = mUidEntries.get(mSendUidsToObserver.valueAt(i));
                    UidEntry uidEntry = mUidEntries.get(mSendUidsToObserver.valueAt(i));
                    if (uidEntry != null) {
                    if (uidEntry != null) {
                        ArrayMap<CallStatKey, CallStat> callStats = uidEntry.mCallStats;
                        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,
                        mCallStatsObserver.noteCallStats(uidEntry.workSourceUid,
                                uidEntry.incrementalCallCount, callStats.values()
                                uidEntry.incrementalCallCount, tmpCallStats
                        );
                        );
                        uidEntry.incrementalCallCount = 0;
                        uidEntry.incrementalCallCount = 0;
                        for (int j = callStats.size() - 1; j >= 0; j--) {
                        for (int j = callStats.size() - 1; j >= 0; j--) {
@@ -829,6 +834,23 @@ public class BinderCallsStats implements BinderInternal.Observer {
            this.screenInteractive = screenInteractive;
            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
        @Override
        public String toString() {
        public String toString() {
            // This is expensive, but CallStat.toString() is only used for debugging.
            // This is expensive, but CallStat.toString() is only used for debugging.