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

Commit 9ff3c6b6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add ANR annotation to AppExitInfo reason" into tm-dev

parents 32cc80fe 3103fbdd
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -125,6 +125,12 @@ class ProcessErrorStateRecord {
    @CompositeRWLock({"mService", "mProcLock"})
    @CompositeRWLock({"mService", "mProcLock"})
    private AppNotRespondingDialog.Data mAnrData;
    private AppNotRespondingDialog.Data mAnrData;


    /**
     * Annotation from process killed due to an ANR.
     */
    @GuardedBy("mService")
    private String mAnrAnnotation;

    /**
    /**
     * Optional local handler to be invoked in the process crash.
     * Optional local handler to be invoked in the process crash.
     */
     */
@@ -193,6 +199,16 @@ class ProcessErrorStateRecord {
        mCrashingReport = crashingReport;
        mCrashingReport = crashingReport;
    }
    }


    @GuardedBy("mService")
    String getAnrAnnotation() {
        return mAnrAnnotation;
    }

    @GuardedBy("mService")
    void setAnrAnnotation(String anrAnnotation) {
        mAnrAnnotation = anrAnnotation;
    }

    @GuardedBy(anyOf = {"mService", "mProcLock"})
    @GuardedBy(anyOf = {"mService", "mProcLock"})
    ActivityManager.ProcessErrorStateInfo getNotRespondingReport() {
    ActivityManager.ProcessErrorStateInfo getNotRespondingReport() {
        return mNotRespondingReport;
        return mNotRespondingReport;
@@ -243,6 +259,8 @@ class ProcessErrorStateRecord {


        mApp.getWindowProcessController().appEarlyNotResponding(annotation, () -> {
        mApp.getWindowProcessController().appEarlyNotResponding(annotation, () -> {
            synchronized (mService) {
            synchronized (mService) {
                // Store annotation here as instance below races with this killLocked.
                setAnrAnnotation(annotation);
                mApp.killLocked("anr", ApplicationExitInfo.REASON_ANR, true);
                mApp.killLocked("anr", ApplicationExitInfo.REASON_ANR, true);
            }
            }
        });
        });
@@ -256,6 +274,9 @@ class ProcessErrorStateRecord {
        final int pid = mApp.getPid();
        final int pid = mApp.getPid();
        final UUID errorId;
        final UUID errorId;
        synchronized (mService) {
        synchronized (mService) {
            // 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.
            // PowerManager.reboot() can block for a long time, so ignore ANRs while shutting down.
            if (mService.mAtmInternal.isShuttingDown()) {
            if (mService.mAtmInternal.isShuttingDown()) {
                Slog.i(TAG, "During shutdown skipping ANR: " + this + " " + annotation);
                Slog.i(TAG, "During shutdown skipping ANR: " + this + " " + annotation);
+4 −0
Original line number Original line Diff line number Diff line
@@ -1071,6 +1071,10 @@ class ProcessRecord implements WindowProcessListener {
            @SubReason int subReason, boolean noisy) {
            @SubReason int subReason, boolean noisy) {
        if (!mKilledByAm) {
        if (!mKilledByAm) {
            Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "kill");
            Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "kill");
            if (reasonCode == ApplicationExitInfo.REASON_ANR
                    && mErrorState.getAnrAnnotation() != null) {
                description = description + ": " + mErrorState.getAnrAnnotation();
            }
            if (mService != null && (noisy || info.uid == mService.mCurOomAdjUid)) {
            if (mService != null && (noisy || info.uid == mService.mCurOomAdjUid)) {
                mService.reportUidInfoMessageLocked(TAG,
                mService.reportUidInfoMessageLocked(TAG,
                        "Killing " + toShortString() + " (adj " + mState.getSetAdj()
                        "Killing " + toShortString() + " (adj " + mState.getSetAdj()