From 3d0e3121d9bd16af6e7bff3214d80b7cf88f8865 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Fri, 21 Mar 2025 12:58:21 +0900 Subject: [PATCH] Only apply the early network agent creation on B ...and if the feature is not killed. For devices on V and below, this feature should be subject to a rollout. That rollout should be done in mainline beta if possible at all, meaning the flags can be defined later. If beta isn't possible after all, a legacy rollout can happen starting in M2025-06 too. Test: manual Change-Id: I941762bf759ce25b4bd1f908e971ceaf4f49f671 --- service/src/com/android/server/ConnectivityService.java | 8 ++++++-- .../java/com/android/server/ConnectivityServiceTest.java | 9 ++++++++- .../android/server/connectivityservice/base/CSTest.kt | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index b9b590b9a0..f58b317731 100644 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -1473,6 +1473,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { return SdkLevel.isAtLeastV(); } + public boolean isAtLeastB() { + return SdkLevel.isAtLeastB(); + } + /** * Get system properties to use in ConnectivityService. */ @@ -1933,8 +1937,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { mUseDeclaredMethodsForCallbacksEnabled = mDeps.isFeatureNotChickenedOut(context, ConnectivityFlags.USE_DECLARED_METHODS_FOR_CALLBACKS); - mQueueNetworkAgentEventsInSystemServer = - mDeps.isFeatureNotChickenedOut(context, + mQueueNetworkAgentEventsInSystemServer = mDeps.isAtLeastB() + && mDeps.isFeatureNotChickenedOut(context, ConnectivityFlags.QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER); // registerUidFrozenStateChangedCallback is only available on U+ mQueueCallbacksForFrozenApps = mDeps.isAtLeastU() diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java index 67cb1a4110..8c90e01086 100755 --- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java @@ -2241,7 +2241,8 @@ public class ConnectivityServiceTest { private static final int VERSION_T = 3; private static final int VERSION_U = 4; private static final int VERSION_V = 5; - private static final int VERSION_MAX = VERSION_V; + private static final int VERSION_B = 6; + private static final int VERSION_MAX = VERSION_B; private int mSdkLevel = VERSION_UNMOCKED; private void setBuildSdk(final int sdkLevel) { @@ -2270,6 +2271,12 @@ public class ConnectivityServiceTest { : mSdkLevel >= VERSION_U; } + @Override + public boolean isAtLeastB() { + return mSdkLevel == VERSION_UNMOCKED ? super.isAtLeastB() + : mSdkLevel >= VERSION_B; + } + @Override public BpfNetMaps getBpfNetMaps(Context context, INetd netd, InterfaceTracker interfaceTracker) { diff --git a/tests/unit/java/com/android/server/connectivityservice/base/CSTest.kt b/tests/unit/java/com/android/server/connectivityservice/base/CSTest.kt index 48333c59cf..0fe61eca44 100644 --- a/tests/unit/java/com/android/server/connectivityservice/base/CSTest.kt +++ b/tests/unit/java/com/android/server/connectivityservice/base/CSTest.kt @@ -112,7 +112,8 @@ internal const val VERSION_S = 2 internal const val VERSION_T = 3 internal const val VERSION_U = 4 internal const val VERSION_V = 5 -internal const val VERSION_MAX = VERSION_V +internal const val VERSION_B = 6 +internal const val VERSION_MAX = VERSION_B internal const val CALLING_UID_UNMOCKED = Process.INVALID_UID @@ -388,6 +389,7 @@ open class CSTest { override fun isAtLeastT() = if (isSdkUnmocked) super.isAtLeastT() else sdkLevel >= VERSION_T override fun isAtLeastU() = if (isSdkUnmocked) super.isAtLeastU() else sdkLevel >= VERSION_U override fun isAtLeastV() = if (isSdkUnmocked) super.isAtLeastV() else sdkLevel >= VERSION_V + override fun isAtLeastB() = if (isSdkUnmocked) super.isAtLeastB() else sdkLevel >= VERSION_B private var callingUid = CALLING_UID_UNMOCKED