Add shell command to query Restricted Mode state
This will be used in the CTS test to query the state of the Restricted Mode. Test: adb shell cmd netpolicy get restricted-mode Bug: 170323671 Bug: 175281879 Change-Id: Ic25b5835d48a4b54eb9f2b4817244651ea09bd60
This commit is contained in:
@@ -3864,6 +3864,13 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isRestrictedModeEnabled() {
|
||||
synchronized (mUidRulesFirstLock) {
|
||||
return mRestrictedNetworkingMode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updates restricted mode state / access for all apps
|
||||
* Called on initialization and when restricted mode is enabled / disabled.
|
||||
|
||||
@@ -119,6 +119,8 @@ class NetworkPolicyManagerShellCommand extends ShellCommand {
|
||||
switch(type) {
|
||||
case "restrict-background":
|
||||
return getRestrictBackground();
|
||||
case "restricted-mode":
|
||||
return getRestrictedModeState();
|
||||
}
|
||||
pw.println("Error: unknown get type '" + type + "'");
|
||||
return -1;
|
||||
@@ -255,6 +257,13 @@ class NetworkPolicyManagerShellCommand extends ShellCommand {
|
||||
return listUidList("App Idle whitelisted UIDs", uids);
|
||||
}
|
||||
|
||||
private int getRestrictedModeState() {
|
||||
final PrintWriter pw = getOutPrintWriter();
|
||||
pw.print("Restricted mode status: ");
|
||||
pw.println(mInterface.isRestrictedModeEnabled() ? "enabled" : "disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getRestrictBackground() throws RemoteException {
|
||||
final PrintWriter pw = getOutPrintWriter();
|
||||
pw.print("Restrict background status: ");
|
||||
|
||||
Reference in New Issue
Block a user