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

Commit 759bccde authored by Chirayu Desai's avatar Chirayu Desai Committed by Michael Bestas
Browse files

restricted-networking: Add a marker policy for network-isolation migration

* We remove the pre-12 POLICY_REJECT_ALL (network-isolation) since it's
  been replaced with restricted-networking-mode.
* However, if the migration fails, there's no way of knowing, since
  restricted-networking-mode is an allowlist
* Add a new marker policy that is not used anywhere, just so that we
  can debug migration problems easily with
  `adb shell dumpsys netpolicy`
* Can be easily removed later once we know for sure this works well (12L perhaps)

Change-Id: I349eb146d4af935c8ce2d2329ab353d042a319f0
parent 9d57437a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -103,6 +103,10 @@ public class NetworkPolicyManager {
     * @hide
     */
    public static final int POLICY_REJECT_ALL = 0x40000;
    /** Reject network usage on all networks, migration helper
     * @hide
     */
    public static final int POLICY_REJECT_ALL_MIGRATED = 0x80000;

    /*
     * Rules defining whether an uid has access to a network given its type (metered / non-metered).
+2 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import static android.net.NetworkPolicyManager.MASK_RESTRICTED_MODE_NETWORKS;
import static android.net.NetworkPolicyManager.POLICY_ALLOW_METERED_BACKGROUND;
import static android.net.NetworkPolicyManager.POLICY_NONE;
import static android.net.NetworkPolicyManager.POLICY_REJECT_ALL;
import static android.net.NetworkPolicyManager.POLICY_REJECT_ALL_MIGRATED;
import static android.net.NetworkPolicyManager.POLICY_REJECT_CELLULAR;
import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
import static android.net.NetworkPolicyManager.POLICY_REJECT_VPN;
@@ -2477,6 +2478,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {

        // Clear policy to avoid future conflicts
        for (int uid : uidsToDeny) {
            addUidPolicy(uid, POLICY_REJECT_ALL_MIGRATED);
            removeUidPolicy(uid, POLICY_REJECT_ALL);
        }
    }