From 951e4bd8f653a9be2d96c3258201b708ddef8476 Mon Sep 17 00:00:00 2001 From: Suprabh Shukla <suprabh@google.com> Date: Thu, 15 Feb 2024 22:30:33 +0000 Subject: [PATCH] Temporarily turn background network restrictions off Adding a constant field to turn off the feature at compile time. After verification of local builds and tests, when the feature is ready for staging, the boolean can be flipped to true or removed. Test: atest CtsHostsideNetworkTests Test: atest resolv_integration_test Test: atest FrameworksServicesTests:NetworkPolicyManagerServiceTest Bug: 304347838 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:21eb0750809b80b154aad628ed6d349ce3f38cbb) Merged-In: I42c375e8a948f95e79f898cb09bb5c1b859ae113 Change-Id: I42c375e8a948f95e79f898cb09bb5c1b859ae113 --- .../com/android/server/net/NetworkPolicyManagerService.java | 5 ++++- .../android/server/net/NetworkPolicyManagerServiceTest.java | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java index 898b19969d9c..c11356b7308e 100644 --- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java @@ -339,6 +339,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { static final String TAG = NetworkPolicyLogger.TAG; private static final boolean LOGD = NetworkPolicyLogger.LOGD; 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. @@ -1060,7 +1062,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } // The flag is boot-stable. - mBackgroundNetworkRestricted = Flags.networkBlockedForTopSleepingAndAbove(); + mBackgroundNetworkRestricted = ALWAYS_RESTRICT_BACKGROUND_NETWORK + && Flags.networkBlockedForTopSleepingAndAbove(); if (mBackgroundNetworkRestricted) { // Firewall rules and UidBlockedState will get updated in // updateRulesForGlobalChangeAL below. diff --git a/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java index 5f2abc3285c9..34929356fe8c 100644 --- a/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java @@ -205,6 +205,7 @@ import libcore.io.Streams; import org.junit.After; import org.junit.Assume; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.MethodRule; @@ -2217,6 +2218,7 @@ public class NetworkPolicyManagerServiceTest { assertFalse(mService.isUidNetworkingBlocked(UID_B, false)); } + @Ignore("Temporarily disabled until the feature is enabled") @Test @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE) public void testBackgroundChainOnTempAllowlistChange() throws Exception { @@ -2246,6 +2248,7 @@ public class NetworkPolicyManagerServiceTest { assertTrue(mService.isUidNetworkingBlocked(UID_A, false)); } + @Ignore("Temporarily disabled until the feature is enabled") @Test @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE) public void testUidObserverFiltersProcStateChanges() throws Exception { @@ -2308,6 +2311,7 @@ public class NetworkPolicyManagerServiceTest { waitForUidEventHandlerIdle(); } + @Ignore("Temporarily disabled until the feature is enabled") @Test @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE) public void testUidObserverFiltersStaleChanges() throws Exception { @@ -2328,6 +2332,7 @@ public class NetworkPolicyManagerServiceTest { waitForUidEventHandlerIdle(); } + @Ignore("Temporarily disabled until the feature is enabled") @Test @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE) public void testUidObserverFiltersCapabilityChanges() throws Exception { -- GitLab