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

Commit 9eb76924 authored by Suprabh Shukla's avatar Suprabh Shukla Committed by Automerger Merge Worker
Browse files

Merge "Revert^3 "Enable default background network restrictions"" into main...

Merge "Revert^3 "Enable default background network restrictions"" into main am: 2381575a am: 06494c5c

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2989199



Change-Id: Ic9308e3c98c02bead6f1377b1297ef2dbe866104
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 54aec1b9 06494c5c
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -340,6 +340,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
    static final String TAG = NetworkPolicyLogger.TAG;
    static final String TAG = NetworkPolicyLogger.TAG;
    private static final boolean LOGD = NetworkPolicyLogger.LOGD;
    private static final boolean LOGD = NetworkPolicyLogger.LOGD;
    private static final boolean LOGV = NetworkPolicyLogger.LOGV;
    private static final boolean LOGV = NetworkPolicyLogger.LOGV;
    // TODO: b/304347838 - Remove once the feature is in staging.
    private static final boolean ALWAYS_RESTRICT_BACKGROUND_NETWORK = false;


    /**
    /**
     * No opportunistic quota could be calculated from user data plan or data settings.
     * No opportunistic quota could be calculated from user data plan or data settings.
@@ -1068,7 +1070,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                    }
                    }


                    // The flag is boot-stable.
                    // The flag is boot-stable.
                    mBackgroundNetworkRestricted = Flags.networkBlockedForTopSleepingAndAbove();
                    mBackgroundNetworkRestricted = ALWAYS_RESTRICT_BACKGROUND_NETWORK
                            && Flags.networkBlockedForTopSleepingAndAbove();
                    if (mBackgroundNetworkRestricted) {
                    if (mBackgroundNetworkRestricted) {
                        // Firewall rules and UidBlockedState will get updated in
                        // Firewall rules and UidBlockedState will get updated in
                        // updateRulesForGlobalChangeAL below.
                        // updateRulesForGlobalChangeAL below.
+9 −0
Original line number Original line Diff line number Diff line
@@ -206,6 +206,7 @@ import libcore.io.Streams;
import org.junit.After;
import org.junit.After;
import org.junit.Assume;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.Test;
import org.junit.rules.MethodRule;
import org.junit.rules.MethodRule;
@@ -2150,12 +2151,14 @@ public class NetworkPolicyManagerServiceTest {
        assertFalse(mService.isUidNetworkingBlocked(UID_E, false));
        assertFalse(mService.isUidNetworkingBlocked(UID_E, false));
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testBackgroundChainEnabled() throws Exception {
    public void testBackgroundChainEnabled() throws Exception {
        verify(mNetworkManager).setFirewallChainEnabled(FIREWALL_CHAIN_BACKGROUND, true);
        verify(mNetworkManager).setFirewallChainEnabled(FIREWALL_CHAIN_BACKGROUND, true);
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testBackgroundChainOnProcStateChange() throws Exception {
    public void testBackgroundChainOnProcStateChange() throws Exception {
@@ -2185,6 +2188,7 @@ public class NetworkPolicyManagerServiceTest {
        assertTrue(mService.isUidNetworkingBlocked(UID_A, false));
        assertTrue(mService.isUidNetworkingBlocked(UID_A, false));
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testBackgroundChainOnAllowlistChange() throws Exception {
    public void testBackgroundChainOnAllowlistChange() throws Exception {
@@ -2223,6 +2227,7 @@ public class NetworkPolicyManagerServiceTest {
        assertFalse(mService.isUidNetworkingBlocked(UID_B, false));
        assertFalse(mService.isUidNetworkingBlocked(UID_B, false));
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testBackgroundChainOnTempAllowlistChange() throws Exception {
    public void testBackgroundChainOnTempAllowlistChange() throws Exception {
@@ -2261,6 +2266,7 @@ public class NetworkPolicyManagerServiceTest {
                && uidState.procState == procState && uidState.capability == capability;
                && uidState.procState == procState && uidState.capability == capability;
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testUidObserverFiltersProcStateChanges() throws Exception {
    public void testUidObserverFiltersProcStateChanges() throws Exception {
@@ -2323,6 +2329,7 @@ public class NetworkPolicyManagerServiceTest {
        waitForUidEventHandlerIdle();
        waitForUidEventHandlerIdle();
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testUidObserverFiltersStaleChanges() throws Exception {
    public void testUidObserverFiltersStaleChanges() throws Exception {
@@ -2343,6 +2350,7 @@ public class NetworkPolicyManagerServiceTest {
        waitForUidEventHandlerIdle();
        waitForUidEventHandlerIdle();
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testUidObserverFiltersCapabilityChanges() throws Exception {
    public void testUidObserverFiltersCapabilityChanges() throws Exception {
@@ -2422,6 +2430,7 @@ public class NetworkPolicyManagerServiceTest {
        assertFalse(mService.isUidNetworkingBlocked(UID_A, false));
        assertFalse(mService.isUidNetworkingBlocked(UID_A, false));
    }
    }


    @Ignore("Temporarily disabled until the feature is enabled")
    @Test
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)
    public void testObsoleteHandleUidChanged() throws Exception {
    public void testObsoleteHandleUidChanged() throws Exception {