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

Commit 68402941 authored by Lee Shombert's avatar Lee Shombert Committed by Android (Google) Code Review
Browse files

Merge "Small modifications to AnrTimer" into main

parents 24a8b075 40d3f397
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -193,6 +193,10 @@ public class AnrTimer<V> implements AutoCloseable {
    @GuardedBy("mLock")
    private int mTotalStarted = 0;

    /** The total number of timers that were restarted without an explicit cancel. */
    @GuardedBy("mLock")
    private int mTotalRestarted = 0;

    /** The total number of errors detected. */
    @GuardedBy("mLock")
    private int mTotalErrors = 0;
@@ -434,10 +438,10 @@ public class AnrTimer<V> implements AutoCloseable {
        @Override
        void start(@NonNull V arg, int pid, int uid, long timeoutMs) {
            synchronized (mLock) {
                if (mTimerIdMap.containsKey(arg)) {
                    // There is an existing timer.  Cancel it.
                    cancel(arg);
                }
                // If there is an existing timer, cancel it.  This is a nop if the timer does not
                // exist.
                if (cancel(arg)) mTotalRestarted++;

                int timerId = nativeAnrTimerStart(mNative, pid, uid, timeoutMs, mExtend);
                if (timerId > 0) {
                    mTimerIdMap.put(arg, timerId);
@@ -546,10 +550,8 @@ public class AnrTimer<V> implements AutoCloseable {
        private Integer removeLocked(V arg) {
            Integer r = mTimerIdMap.remove(arg);
            if (r != null) {
                synchronized (mTimerArgMap) {
                mTimerArgMap.remove(r);
            }
            }
            return r;
        }
    }
@@ -672,8 +674,8 @@ public class AnrTimer<V> implements AutoCloseable {
        synchronized (mLock) {
            pw.format("timer: %s\n", mLabel);
            pw.increaseIndent();
            pw.format("started=%d maxStarted=%d running=%d expired=%d errors=%d\n",
                    mTotalStarted, mMaxStarted, mTimerIdMap.size(),
            pw.format("started=%d maxStarted=%d  restarted=%d running=%d expired=%d errors=%d\n",
                    mTotalStarted, mMaxStarted, mTotalRestarted, mTimerIdMap.size(),
                    mTotalExpired, mTotalErrors);
            pw.decreaseIndent();
            mFeature.dump(pw, false);
+0 −2
Original line number Diff line number Diff line
@@ -487,7 +487,6 @@ class AnrTimerService::Ticker {
        timer_id_t front = headTimerId();
        auto found = running_.find(key);
        if (found != running_.end()) running_.erase(found);
        if (front != headTimerId()) restartLocked();
    }

    // Remove every timer associated with the service.
@@ -501,7 +500,6 @@ class AnrTimerService::Ticker {
                i++;
            }
        }
        if (front != headTimerId()) restartLocked();
    }

    // Return the number of timers still running.