Merge "Allow tests to query processes frozen state."

This commit is contained in:
Sudheer Shanka
2023-01-25 06:02:14 +00:00
committed by Android (Google) Code Review
5 changed files with 31 additions and 0 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -18497,6 +18497,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) {

View File

@@ -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);

View File

@@ -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;