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

Commit d849d9d3 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Automerger Merge Worker
Browse files

Merge "Prioritize broadcasts to persistent processes." into udc-dev am: e546f6af

parents 96d4aed8 e546f6af
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -18901,12 +18901,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public void waitForBroadcastIdle() {
        waitForBroadcastIdle(LOG_WRITER_INFO);
        waitForBroadcastIdle(LOG_WRITER_INFO, false);
    }
    public void waitForBroadcastIdle(@NonNull PrintWriter pw) {
    void waitForBroadcastIdle(@NonNull PrintWriter pw, boolean flushBroadcastLoopers) {
        enforceCallingPermission(permission.DUMP, "waitForBroadcastIdle()");
        if (flushBroadcastLoopers) {
            BroadcastLoopers.waitForIdle(pw);
        }
        for (BroadcastQueue queue : mBroadcastQueues) {
            queue.waitForIdle(pw);
        }
@@ -18919,7 +18921,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        waitForBroadcastBarrier(LOG_WRITER_INFO, false, false);
    }
    public void waitForBroadcastBarrier(@NonNull PrintWriter pw,
    void waitForBroadcastBarrier(@NonNull PrintWriter pw,
            boolean flushBroadcastLoopers, boolean flushApplicationThreads) {
        enforceCallingPermission(permission.DUMP, "waitForBroadcastBarrier()");
        if (flushBroadcastLoopers) {
@@ -18937,7 +18939,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     * Wait for all pending {@link IApplicationThread} events to be processed in
     * all currently running apps.
     */
    public void waitForApplicationBarrier(@NonNull PrintWriter pw) {
    void waitForApplicationBarrier(@NonNull PrintWriter pw) {
        final CountDownLatch finishedLatch = new CountDownLatch(1);
        final AtomicInteger pingCount = new AtomicInteger(0);
        final AtomicInteger pongCount = new AtomicInteger(0);
+11 −1
Original line number Diff line number Diff line
@@ -3447,7 +3447,17 @@ final class ActivityManagerShellCommand extends ShellCommand {

    int runWaitForBroadcastIdle(PrintWriter pw) throws RemoteException {
        pw = new PrintWriter(new TeeWriter(LOG_WRITER_INFO, pw));
        mInternal.waitForBroadcastIdle(pw);
        boolean flushBroadcastLoopers = false;
        String opt;
        while ((opt = getNextOption()) != null) {
            if (opt.equals("--flush-broadcast-loopers")) {
                flushBroadcastLoopers = true;
            } else {
                getErrPrintWriter().println("Error: Unknown option: " + opt);
                return -1;
            }
        }
        mInternal.waitForBroadcastIdle(pw, flushBroadcastLoopers);
        return 0;
    }

+28 −0
Original line number Diff line number Diff line
@@ -246,6 +246,26 @@ public class BroadcastConstants {
    private static final String KEY_DELAY_URGENT_MILLIS = "bcast_delay_urgent_millis";
    private static final long DEFAULT_DELAY_URGENT_MILLIS = -120_000;

    /**
     * For {@link BroadcastQueueModernImpl}: Delay to apply to broadcasts to
     * foreground processes, typically a negative value to indicate they should be
     * executed before most other pending broadcasts.
     */
    public long DELAY_FOREGROUND_PROC_MILLIS = DEFAULT_DELAY_FOREGROUND_PROC_MILLIS;
    private static final String KEY_DELAY_FOREGROUND_PROC_MILLIS =
            "bcast_delay_foreground_proc_millis";
    private static final long DEFAULT_DELAY_FOREGROUND_PROC_MILLIS = -120_000;

    /**
     * For {@link BroadcastQueueModernImpl}: Delay to apply to broadcasts to
     * persistent processes, typically a negative value to indicate they should be
     * executed before most other pending broadcasts.
     */
    public long DELAY_PERSISTENT_PROC_MILLIS = DEFAULT_DELAY_FOREGROUND_PROC_MILLIS;
    private static final String KEY_DELAY_PERSISTENT_PROC_MILLIS =
            "bcast_delay_persistent_proc_millis";
    private static final long DEFAULT_DELAY_PERSISTENT_PROC_MILLIS = -120_000;

    /**
     * For {@link BroadcastQueueModernImpl}: Maximum number of complete
     * historical broadcasts to retain for debugging purposes.
@@ -411,6 +431,10 @@ public class BroadcastConstants {
                    DEFAULT_DELAY_CACHED_MILLIS);
            DELAY_URGENT_MILLIS = getDeviceConfigLong(KEY_DELAY_URGENT_MILLIS,
                    DEFAULT_DELAY_URGENT_MILLIS);
            DELAY_FOREGROUND_PROC_MILLIS = getDeviceConfigLong(KEY_DELAY_FOREGROUND_PROC_MILLIS,
                    DEFAULT_DELAY_FOREGROUND_PROC_MILLIS);
            DELAY_PERSISTENT_PROC_MILLIS = getDeviceConfigLong(KEY_DELAY_PERSISTENT_PROC_MILLIS,
                    DEFAULT_DELAY_PERSISTENT_PROC_MILLIS);
            MAX_HISTORY_COMPLETE_SIZE = getDeviceConfigInt(KEY_MAX_HISTORY_COMPLETE_SIZE,
                    DEFAULT_MAX_HISTORY_COMPLETE_SIZE);
            MAX_HISTORY_SUMMARY_SIZE = getDeviceConfigInt(KEY_MAX_HISTORY_SUMMARY_SIZE,
@@ -463,6 +487,10 @@ public class BroadcastConstants {
                    TimeUtils.formatDuration(DELAY_CACHED_MILLIS)).println();
            pw.print(KEY_DELAY_URGENT_MILLIS,
                    TimeUtils.formatDuration(DELAY_URGENT_MILLIS)).println();
            pw.print(KEY_DELAY_FOREGROUND_PROC_MILLIS,
                    TimeUtils.formatDuration(DELAY_FOREGROUND_PROC_MILLIS)).println();
            pw.print(KEY_DELAY_PERSISTENT_PROC_MILLIS,
                    TimeUtils.formatDuration(DELAY_PERSISTENT_PROC_MILLIS)).println();
            pw.print(KEY_MAX_HISTORY_COMPLETE_SIZE, MAX_HISTORY_COMPLETE_SIZE).println();
            pw.print(KEY_MAX_HISTORY_SUMMARY_SIZE, MAX_HISTORY_SUMMARY_SIZE).println();
            pw.print(KEY_MAX_CONSECUTIVE_URGENT_DISPATCHES,
+4 −4
Original line number Diff line number Diff line
@@ -1098,8 +1098,11 @@ class BroadcastProcessQueue {
                mRunnableAt = runnableAt + constants.DELAY_URGENT_MILLIS;
                mRunnableAtReason = REASON_INSTRUMENTED;
            } else if (mUidForeground) {
                mRunnableAt = runnableAt + constants.DELAY_URGENT_MILLIS;
                mRunnableAt = runnableAt + constants.DELAY_FOREGROUND_PROC_MILLIS;
                mRunnableAtReason = REASON_FOREGROUND;
            } else if (mProcessPersistent) {
                mRunnableAt = runnableAt + constants.DELAY_PERSISTENT_PROC_MILLIS;
                mRunnableAtReason = REASON_PERSISTENT;
            } else if (mCountOrdered > 0) {
                mRunnableAt = runnableAt;
                mRunnableAtReason = REASON_CONTAINS_ORDERED;
@@ -1112,9 +1115,6 @@ class BroadcastProcessQueue {
            } else if (mCountManifest > 0) {
                mRunnableAt = runnableAt;
                mRunnableAtReason = REASON_CONTAINS_MANIFEST;
            } else if (mProcessPersistent) {
                mRunnableAt = runnableAt;
                mRunnableAtReason = REASON_PERSISTENT;
            } else if (mUidCached) {
                if (r.deferUntilActive) {
                    // All enqueued broadcasts are deferrable, defer
+5 −0
Original line number Diff line number Diff line
@@ -11053,6 +11053,11 @@ public class AudioService extends IAudioService.Stub
        dumpAccessibilityServiceUids(pw);
        dumpAssistantServicesUids(pw);
        pw.print("  supportsBluetoothVariableLatency=");
        pw.println(AudioSystem.supportsBluetoothVariableLatency());
        pw.print("  isBluetoothVariableLatencyEnabled=");
        pw.println(AudioSystem.isBluetoothVariableLatencyEnabled());
        dumpAudioPolicies(pw);
        mDynPolicyLogger.dump(pw);
        mPlaybackMonitor.dump(pw);
Loading