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

Commit ce9f94d9 authored by Patrick Rohr's avatar Patrick Rohr
Browse files

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
parent 8b6082b5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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.
+9 −0
Original line number Diff line number Diff line
@@ -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: ");