Support both R and S+ in NetworkFactory

NetworkFactory needs to be backwards compatible as
it is statically linked by the Wifi module, which
needs to run on both R and S.

To achieve this, maintain 2 separate implementations
called NetworkFactoryImpl (S+) and
NetworkFactoryLegacyImpl (R). NetworkFactory itself
becomes a shim that delegates to one of these
implementations depending on the device's SDK version.

CP of ag/14265947

Ignore-AOSP-First: Merge in internal first to fix
                   S-on-R test breakages.
Bug: 183902758
Test: ClientModeImplTest
      OemWifiNetworkFactoryTest
      TelephonyNetworkFactoryTest
      UntrustedWifiNetworkFactoryTest
      WifiNetworkFactoryTest
Change-Id: I6a08f39ad1633dd7c1582c362c97821e24ce6683
Merged-In: I6a08f39ad1633dd7c1582c362c97821e24ce6683
diff --git a/staticlibs/Android.bp b/staticlibs/Android.bp
index f3b2faa..1371c8c 100644
--- a/staticlibs/Android.bp
+++ b/staticlibs/Android.bp
@@ -34,9 +34,9 @@
 java_library {
   name: "net-utils-device-common",
   srcs: [
-      "device/**/*.java",
+      "device/com/android/net/module/util/**/*.java",
       // This library is used by system modules, for which the system health impact of Kotlin
-      // has not yet been evaluated.
+      // has not yet been evaluated. Annotations may need jarjar'ing.
       // "src_devicecommon/**/*.kt",
       ":framework-annotations",
   ],
@@ -117,13 +117,15 @@
         "//frameworks/libs/net/common/tests:__subpackages__",
         "//frameworks/libs/net/common/device",
         "//packages/modules/Wifi/framework/tests:__subpackages__",
-    ]
+    ],
 }
-
 filegroup {
     name: "net-utils-services-common-srcs",
     srcs: [
         "device/android/net/NetworkFactory.java",
+        "device/android/net/NetworkFactoryImpl.java",
+        "device/android/net/NetworkFactoryLegacyImpl.java",
+        "device/android/net/NetworkFactoryShim.java",
     ],
     visibility: [
         "//frameworks/base/services/net",
@@ -138,6 +140,9 @@
     ],
     sdk_version: "system_current",
     min_sdk_version: "30",
+    static_libs: [
+        "modules-utils-build_system",
+    ],
     visibility: [
         "//frameworks/base/services/net",
     ],
@@ -150,6 +155,9 @@
     srcs: [
         // Any class here *must* have a corresponding jarjar rule in the telephony build rules.
         "device/android/net/NetworkFactory.java",
+        "device/android/net/NetworkFactoryImpl.java",
+        "device/android/net/NetworkFactoryLegacyImpl.java",
+        "device/android/net/NetworkFactoryShim.java",
     ],
     path: "device",
     visibility: [
@@ -178,6 +186,9 @@
     name: "net-utils-wifi-service-common-srcs",
     srcs: [
        "device/android/net/NetworkFactory.java",
+       "device/android/net/NetworkFactoryImpl.java",
+       "device/android/net/NetworkFactoryLegacyImpl.java",
+       "device/android/net/NetworkFactoryShim.java",
        "framework/com/android/net/module/util/NetUtils.java",
     ],
     visibility: [