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

Commit b9510e7f authored by Mohamad Mahmoud's avatar Mohamad Mahmoud Committed by Automerger Merge Worker
Browse files

Merge "Add VolatileDropboxEntryStates for timely header state collection" into...

Merge "Add VolatileDropboxEntryStates for timely header state collection" into udc-qpr-dev am: 57b114f8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24511975



Change-Id: I375d20feb2d26f6315b893bec1466ae1df513e75
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4a7ff115 57b114f8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -935,7 +935,7 @@ public class Watchdog implements Dumpable {
                        mActivity.addErrorToDropBox(
                                dropboxTag, null, "system_server", null, null, null,
                                null, report.toString(), stack, null, null, null,
                                errorId);
                                errorId, null);
                    }
                }
            };
+41 −8
Original line number Diff line number Diff line
@@ -2112,6 +2112,34 @@ public class ActivityManagerService extends IActivityManager.Stub
        mVoiceInteractionManagerProvider = provider;
    }
    /**
     * Represents volatile states associated with a Dropbox entry.
     * <p>
     * These states, such as the process frozen state, can change quickly over time and thus
     * should be captured as soon as possible to ensure accurate state. If a state is undefined,
     * it means that the state was not read early and a fallback value can be used.
     * </p>
     */
    static class VolatileDropboxEntryStates {
        private final Boolean mIsProcessFrozen;
        private VolatileDropboxEntryStates(Boolean frozenState) {
            this.mIsProcessFrozen = frozenState;
        }
        public static VolatileDropboxEntryStates withProcessFrozenState(boolean frozenState) {
            return new VolatileDropboxEntryStates(frozenState);
        }
        public static VolatileDropboxEntryStates emptyVolatileDropboxEnytyStates() {
            return new VolatileDropboxEntryStates(null);
        }
        public Boolean isProcessFrozen() {
            return mIsProcessFrozen;
        }
    }
    static class MemBinder extends Binder {
        ActivityManagerService mActivityManagerService;
        private final PriorityDump.PriorityDumper mPriorityDumper =
@@ -8892,7 +8920,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        addErrorToDropBox(
                eventType, r, processName, null, null, null, null, null, null, crashInfo,
                new Float(loadingProgress), incrementalMetrics, null);
                new Float(loadingProgress), incrementalMetrics, null, null);
        // For GWP-ASan recoverable crashes, don't make the app crash (the whole point of
        // 'recoverable' is that the app doesn't crash). Normally, for nonrecoreable native crashes,
@@ -9001,7 +9029,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        final StringBuilder sb = new StringBuilder(1024);
        synchronized (sb) {
            appendDropBoxProcessHeaders(process, processName, sb);
            appendDropBoxProcessHeaders(process, processName, null, sb);
            sb.append("Build: ").append(Build.FINGERPRINT).append("\n");
            sb.append("System-App: ").append(isSystemApp).append("\n");
            sb.append("Uptime-Millis: ").append(info.violationUptimeMillis).append("\n");
@@ -9104,7 +9132,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                callingPid, (r != null) ? r.getProcessClassEnum() : 0);
        addErrorToDropBox("wtf", r, processName, null, null, null, tag, null, null, crashInfo,
                null, null, null);
                null, null, null, null);
        return r;
    }
@@ -9129,7 +9157,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        for (Pair<String, ApplicationErrorReport.CrashInfo> p = list.poll();
                p != null; p = list.poll()) {
            addErrorToDropBox("wtf", proc, "system_server", null, null, null, p.first, null, null,
                    p.second, null, null, null);
                    p.second, null, null, null, null);
        }
    }
@@ -9152,7 +9180,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     * to append various headers to the dropbox log text.
     */
    void appendDropBoxProcessHeaders(ProcessRecord process, String processName,
            final StringBuilder sb) {
            final VolatileDropboxEntryStates volatileStates, final StringBuilder sb) {
        // Watchdog thread ends up invoking this function (with
        // a null ProcessRecord) to add the stack file to dropbox.
        // Do not acquire a lock on this (am) in such cases, as it
@@ -9171,7 +9199,12 @@ public class ActivityManagerService extends IActivityManager.Stub
            sb.append("PID: ").append(process.getPid()).append("\n");
            sb.append("UID: ").append(process.uid).append("\n");
            if (process.mOptRecord != null) {
                sb.append("Frozen: ").append(process.mOptRecord.isFrozen()).append("\n");
                // Use 'isProcessFrozen' from 'volatileStates' if it'snon-null (present),
                // otherwise use 'isFrozen' from 'mOptRecord'.
                sb.append("Frozen: ").append(
                    (volatileStates != null && volatileStates.isProcessFrozen() != null)
                    ? volatileStates.isProcessFrozen() : process.mOptRecord.isFrozen()
                ).append("\n");
            }
            int flags = process.info.flags;
            final IPackageManager pm = AppGlobals.getPackageManager();
@@ -9279,7 +9312,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            String subject, final String report, final File dataFile,
            final ApplicationErrorReport.CrashInfo crashInfo,
            @Nullable Float loadingProgress, @Nullable IncrementalMetrics incrementalMetrics,
            @Nullable UUID errorId) {
            @Nullable UUID errorId, @Nullable VolatileDropboxEntryStates volatileStates) {
        // NOTE -- this must never acquire the ActivityManagerService lock,
        // otherwise the watchdog may be prevented from resetting the system.
@@ -9301,7 +9334,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (rateLimitResult.shouldRateLimit()) return;
        final StringBuilder sb = new StringBuilder(1024);
        appendDropBoxProcessHeaders(process, processName, sb);
        appendDropBoxProcessHeaders(process, processName, volatileStates, sb);
        if (process != null) {
            sb.append("Foreground: ")
                    .append(process.isInterestingToUserLocked() ? "Yes" : "No")
+2 −1
Original line number Diff line number Diff line
@@ -1838,7 +1838,8 @@ public class AppProfiler {
        dropBuilder.append(catSw.toString());
        FrameworkStatsLog.write(FrameworkStatsLog.LOW_MEM_REPORTED);
        mService.addErrorToDropBox("lowmem", null, "system_server", null,
                null, null, tag.toString(), dropBuilder.toString(), null, null, null, null, null);
                null, null, tag.toString(), dropBuilder.toString(), null, null, null, null, null,
                null);
        synchronized (mService) {
            long now = SystemClock.uptimeMillis();
            if (mLastMemUsageReportTime < now) {
+6 −1
Original line number Diff line number Diff line
@@ -297,6 +297,7 @@ class ProcessErrorStateRecord {

        ArrayList<Integer> firstPids = new ArrayList<>(5);
        SparseBooleanArray lastPids = new SparseBooleanArray(20);
        ActivityManagerService.VolatileDropboxEntryStates volatileDropboxEntriyStates = null;

        mApp.getWindowProcessController().appEarlyNotResponding(annotation, () -> {
            latencyTracker.waitingOnAMSLockStarted();
@@ -341,6 +342,9 @@ class ProcessErrorStateRecord {
            synchronized (mProcLock) {
                latencyTracker.waitingOnProcLockEnded();
                setNotResponding(true);
                volatileDropboxEntriyStates =
                        ActivityManagerService.VolatileDropboxEntryStates
                                .withProcessFrozenState(mApp.mOptRecord.isFrozen());
            }

            // Log the ANR to the event log.
@@ -618,7 +622,8 @@ class ProcessErrorStateRecord {
                ? (ProcessRecord) parentProcess.mOwner : null;
        mService.addErrorToDropBox("anr", mApp, mApp.processName, activityShortComponentName,
                parentShortComponentName, parentPr, null, report.toString(), tracesFile,
                null, new Float(loadingProgress), incrementalMetrics, errorId);
                null, new Float(loadingProgress), incrementalMetrics, errorId,
                volatileDropboxEntriyStates);

        if (mApp.getWindowProcessController().appNotResponding(info.toString(),
                () -> {
+1 −1
Original line number Diff line number Diff line
@@ -5632,7 +5632,7 @@ public final class ProcessList {
            if (logToDropbox) {
                final long now = SystemClock.elapsedRealtime();
                final StringBuilder sb = new StringBuilder();
                mService.appendDropBoxProcessHeaders(app, app.processName, sb);
                mService.appendDropBoxProcessHeaders(app, app.processName, null, sb);
                sb.append("Reason: " + reason).append("\n");
                sb.append("Requester UID: " + requester).append("\n");
                dbox.addText(DROPBOX_TAG_IMPERCEPTIBLE_KILL, sb.toString());