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

Commit 9f8f4db9 authored by Olivier Gaillard's avatar Olivier Gaillard Committed by Android (Google) Code Review
Browse files

Merge "Log the number of ANRs skipped"

parents ac5a42d6 e55067de
Loading
Loading
Loading
Loading
+26 −19
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.util.SparseBooleanArray;
import com.android.internal.annotations.CompositeRWLock;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.expresslog.Counter;
import com.android.internal.os.ProcessCpuTracker;
import com.android.internal.os.TimeoutRecord;
import com.android.internal.os.anr.AnrLatencyTracker;
@@ -260,6 +261,28 @@ class ProcessErrorStateRecord {
        mDialogController = new ErrorDialogController(app);
    }

    @GuardedBy("mService")
    boolean skipAnrLocked(String annotation) {
        // PowerManager.reboot() can block for a long time, so ignore ANRs while shutting down.
        if (mService.mAtmInternal.isShuttingDown()) {
            Slog.i(TAG, "During shutdown skipping ANR: " + this + " " + annotation);
            return true;
        } else if (isNotResponding()) {
            Slog.i(TAG, "Skipping duplicate ANR: " + this + " " + annotation);
            return true;
        } else if (isCrashing()) {
            Slog.i(TAG, "Crashing app skipping ANR: " + this + " " + annotation);
            return true;
        } else if (mApp.isKilledByAm()) {
            Slog.i(TAG, "App already killed by AM skipping ANR: " + this + " " + annotation);
            return true;
        } else if (mApp.isKilled()) {
            Slog.i(TAG, "Skipping died app ANR: " + this + " " + annotation);
            return true;
        }
        return false;
    }

    void appNotResponding(String activityShortComponentName, ApplicationInfo aInfo,
            String parentShortComponentName, WindowProcessController parentProcess,
            boolean aboveSystem, TimeoutRecord timeoutRecord,
@@ -303,26 +326,10 @@ class ProcessErrorStateRecord {
            // Store annotation here as instance above will not be hit on all paths.
            setAnrAnnotation(annotation);

            // PowerManager.reboot() can block for a long time, so ignore ANRs while shutting down.
            if (mService.mAtmInternal.isShuttingDown()) {
                Slog.i(TAG, "During shutdown skipping ANR: " + this + " " + annotation);
                latencyTracker.anrSkippedProcessErrorStateRecordAppNotResponding();
                return;
            } else if (isNotResponding()) {
                Slog.i(TAG, "Skipping duplicate ANR: " + this + " " + annotation);
                latencyTracker.anrSkippedProcessErrorStateRecordAppNotResponding();
                return;
            } else if (isCrashing()) {
                Slog.i(TAG, "Crashing app skipping ANR: " + this + " " + annotation);
                latencyTracker.anrSkippedProcessErrorStateRecordAppNotResponding();
                return;
            } else if (mApp.isKilledByAm()) {
                Slog.i(TAG, "App already killed by AM skipping ANR: " + this + " " + annotation);
                latencyTracker.anrSkippedProcessErrorStateRecordAppNotResponding();
                return;
            } else if (mApp.isKilled()) {
                Slog.i(TAG, "Skipping died app ANR: " + this + " " + annotation);
            Counter.logIncrement("stability_anr.value_total_anrs");
            if (skipAnrLocked(annotation)) {
                latencyTracker.anrSkippedProcessErrorStateRecordAppNotResponding();
                Counter.logIncrement("stability_anr.value_skipped_anrs");
                return;
            }