From 34acf485fd700cab8440ab73e1d354044589e04a Mon Sep 17 00:00:00 2001 From: Jing Ji Date: Mon, 7 Mar 2022 00:35:15 -0800 Subject: [PATCH] Add am command to list sysconfig to the bg restriction exemptions Bug: 222414556 Test: am list-bg-exemptions-config Change-Id: I170c312ec74b7ff2bba705c607048af96f18f34a --- .../server/am/ActivityManagerShellCommand.java | 15 +++++++++++++++ .../server/am/AppRestrictionController.java | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java index 28b807c5d30bb..2b61e7fd27522 100644 --- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java +++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java @@ -343,6 +343,8 @@ final class ActivityManagerShellCommand extends ShellCommand { return runSetStopUserOnSwitch(pw); case "set-bg-abusive-uids": return runSetBgAbusiveUids(pw); + case "list-bg-exemptions-config": + return runListBgExemptionsConfig(pw); default: return handleDefaultCommands(cmd); } @@ -3292,6 +3294,19 @@ final class ActivityManagerShellCommand extends ShellCommand { return 0; } + private int runListBgExemptionsConfig(PrintWriter pw) throws RemoteException { + final ArraySet sysConfigs = mInternal.mAppRestrictionController + .mBgRestrictionExemptioFromSysConfig; + if (sysConfigs != null) { + for (int i = 0, size = sysConfigs.size(); i < size; i++) { + pw.print(sysConfigs.valueAt(i)); + pw.print(' '); + } + pw.println(); + } + return 0; + } + private Resources getResources(PrintWriter pw) throws RemoteException { // system resources does not contain all the device configuration, construct it manually. Configuration config = mInterface.getConfiguration(); diff --git a/services/core/java/com/android/server/am/AppRestrictionController.java b/services/core/java/com/android/server/am/AppRestrictionController.java index 6e6cb879ae4f4..3577032fb76c1 100644 --- a/services/core/java/com/android/server/am/AppRestrictionController.java +++ b/services/core/java/com/android/server/am/AppRestrictionController.java @@ -241,7 +241,7 @@ public final class AppRestrictionController { /** * The pre-config packages that are exempted from the background restrictions. */ - private ArraySet mBgRestrictionExemptioFromSysConfig; + ArraySet mBgRestrictionExemptioFromSysConfig; /** * Lock specifically for bookkeeping around the carrier-privileged app set.