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

Commit 16bae885 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Allow tests to query processes frozen state.

Bug: 265999823
Test: atest tests/app/BroadcastsTest/src/android/app/cts/broadcasts/BroadcastDeferralTest.java
Change-Id: I7809d7dedd1a763e5dea12ec3e0f1750e92e3039
parent dc0f1da4
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -5345,6 +5345,20 @@ public class ActivityManager {
        }
    }

    /**
     * Checks if the process represented by the given {@code pid} is frozen.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.DUMP)
    public boolean isProcessFrozen(int pid) {
        try {
            return getService().isProcessFrozen(pid);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @return The reason code of whether or not the given UID should be exempted from background
     * restrictions here.
+4 −0
Original line number Diff line number Diff line
@@ -779,6 +779,10 @@ interface IActivityManager {
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
    boolean isModernBroadcastQueueEnabled();

    /** Checks if the process represented by the given pid is frozen. */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
    boolean isProcessFrozen(int pid);

    /**
     * @return The reason code of whether or not the given UID should be exempted from background
     * restrictions here.
+6 −0
Original line number Diff line number Diff line
@@ -18538,6 +18538,12 @@ public class ActivityManagerService extends IActivityManager.Stub
        return mEnableModernQueue;
    }
    @Override
    public boolean isProcessFrozen(int pid) {
        enforceCallingPermission(permission.DUMP, "isProcessFrozen()");
        return mOomAdjuster.mCachedAppOptimizer.isProcessFrozen(pid);
    }
    @Override
    @ReasonCode
    public int getBackgroundRestrictionExemptionReason(int uid) {
+1 −0
Original line number Diff line number Diff line
@@ -1113,6 +1113,7 @@ class BroadcastProcessQueue {
        pw.print(" because ");
        pw.print(reasonToString(mRunnableAtReason));
        pw.println();
        pw.print("mProcessCached="); pw.println(mProcessCached);
        pw.increaseIndent();
        if (mActive != null) {
            dumpRecord("ACTIVE", now, pw, mActive, mActiveIndex);
+6 −0
Original line number Diff line number Diff line
@@ -1509,6 +1509,12 @@ public final class CachedAppOptimizer {
        return profile;
    }

    boolean isProcessFrozen(int pid) {
        synchronized (mProcLock) {
            return mFrozenProcesses.contains(pid);
        }
    }

    @VisibleForTesting
    static final class SingleCompactionStats {
        private static final float STATSD_SAMPLE_RATE = 0.1f;