Revert "Immediately create networks unless chickened out"

Revert submission 3548747

Reason for revert: Droidmonitor created revert due to b/404956859. Will be verified through ABTD for standard investigation.

Reverted changes: /q/submissionid:3548747

Change-Id: Ic4226f2f1a20965f80b554967568a4450e460da2
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index e27b72d..48a825a 100644
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -113,7 +113,6 @@
 import static android.net.NetworkCapabilities.RES_ID_UNSET;
 import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
 import static android.net.NetworkCapabilities.TRANSPORT_TEST;
-import static android.net.NetworkCapabilities.TRANSPORT_THREAD;
 import static android.net.NetworkCapabilities.TRANSPORT_VPN;
 import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
 import static android.net.NetworkRequest.Type.LISTEN_FOR_BEST;
@@ -5449,18 +5448,15 @@
     }
 
     @VisibleForTesting
-    protected boolean shouldCreateNetworksImmediately(@NonNull NetworkCapabilities caps) {
+    protected static boolean shouldCreateNetworksImmediately(@NonNull NetworkCapabilities caps) {
         // The feature of creating the networks immediately was slated for U, but race conditions
         // detected late required this was flagged off.
-        // TODO : remove when it's determined that the code is stable
-        return mQueueNetworkAgentEventsInSystemServer
-                // Local network agents for Thread used to not create networks immediately,
-                // but other local agents (tethering, P2P) require this to function.
-                || (caps.hasCapability(NET_CAPABILITY_LOCAL_NETWORK)
-                && !caps.hasTransport(TRANSPORT_THREAD));
+        // TODO : enable this in a Mainline update or in V, and re-enable the test for this
+        // in NetworkAgentTest.
+        return caps.hasCapability(NET_CAPABILITY_LOCAL_NETWORK);
     }
 
-    private boolean shouldCreateNativeNetwork(@NonNull NetworkAgentInfo nai,
+    private static boolean shouldCreateNativeNetwork(@NonNull NetworkAgentInfo nai,
             @NonNull NetworkInfo.State state) {
         if (nai.isCreated()) return false;
         if (state == NetworkInfo.State.CONNECTED) return true;
diff --git a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
index 4c3bce0..92155c3 100644
--- a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
+++ b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
@@ -179,10 +179,6 @@
 // without affecting the run time of successful runs. Thus, set a very high timeout.
 private const val DEFAULT_TIMEOUT_MS = 5000L
 
-private const val QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER =
-    "queue_network_agent_events_in_system_server"
-
-
 // When waiting for a NetworkCallback to determine there was no timeout, waiting is the
 // only possible thing (the relevant handler is the one in the real ConnectivityService,
 // and then there is the Binder call), so have a short timeout for this as it will be
@@ -207,6 +203,12 @@
 private val PREFIX = IpPrefix("2001:db8::/64")
 private val NEXTHOP = InetAddresses.parseNumericAddress("fe80::abcd")
 
+// On T and below, the native network is only created when the agent connects.
+// Starting in U, the native network was to be created as soon as the agent is registered,
+// but this has been flagged off for now pending resolution of race conditions.
+// TODO : enable this in a Mainline update or in V.
+private const val SHOULD_CREATE_NETWORKS_IMMEDIATELY = false
+
 @AppModeFull(reason = "Instant apps can't use NetworkAgent because it needs NETWORK_FACTORY'.")
 // NetworkAgent is updated as part of the connectivity module, and running NetworkAgent tests in MTS
 // for modules other than Connectivity does not provide much value. Only run them in connectivity
@@ -232,18 +234,6 @@
     private var qosTestSocket: Closeable? = null // either Socket or DatagramSocket
     private val ifacesToCleanUp = mutableListOf<TestNetworkInterface>()
 
-    // Unless the queuing in system server feature is chickened out, native networks are created
-    // immediately. Historically they would only created as they'd connect, which would force
-    // the code to apply link properties multiple times and suffer errors early on. Creating
-    // them early required that ordering between the client and the system server is guaranteed
-    // (at least to some extent), which has been done by moving the event queue from the client
-    // to the system server. When that feature is not chickened out, create networks immediately.
-    private val SHOULD_CREATE_NETWORKS_IMMEDIATELY
-        get() = mCM.isConnectivityServiceFeatureEnabledForTesting(
-            QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER
-        )
-
-
     @Before
     fun setUp() {
         instrumentation.getUiAutomation().adoptShellPermissionIdentity()