Setup NativeTestServer

this adds the classes dependent on the nativetestserverThis adds the classes dependent on the nativetestserver.

This setup depends on the cronet's platform implementation.
However, the tests jnilib is not prefixed and
because of that:
- We don't jarjar the base classes
- Don't jar the test classes
since the .so file needs the unjarjared versions.

Test: atest NetHttpTestServer
Bug: 267353182
Change-Id: Id5cfc8f842df4b13cef6f56dbaa6b9563c3989de
diff --git a/Cronet/tests/common/Android.bp b/Cronet/tests/common/Android.bp
index d56e47b..86fd807 100644
--- a/Cronet/tests/common/Android.bp
+++ b/Cronet/tests/common/Android.bp
@@ -35,7 +35,7 @@
         "CtsNetHttpTestsLib",
         "NetHttpTestsLibPreJarJar",
     ],
-    jarjar_rules: ":framework-tethering-jarjar-rules",
+    jarjar_rules: ":net-http-test-jarjar-rules",
     compile_multilib: "both", // Include both the 32 and 64 bit versions
     jni_libs: [
        "//external/cronet:cronet_aml_components_cronet_android_cronet_tests__testing"
diff --git a/Cronet/tests/mts/Android.bp b/Cronet/tests/mts/Android.bp
index e2cae41..2b5f578 100644
--- a/Cronet/tests/mts/Android.bp
+++ b/Cronet/tests/mts/Android.bp
@@ -17,12 +17,30 @@
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
+java_genrule {
+    name: "net-http-test-jarjar-rules",
+    tool_files: [
+        ":NetHttpTestsLibPreJarJar{.jar}",
+        "jarjar_excludes.txt",
+    ],
+    tools: [
+        "jarjar-rules-generator",
+    ],
+    out: ["net_http_test_jarjar_rules.txt"],
+    cmd: "$(location jarjar-rules-generator) " +
+        "$(location :NetHttpTestsLibPreJarJar{.jar}) " +
+        "--prefix android.net.http.internal " +
+        "--excludes $(location jarjar_excludes.txt) " +
+        "--output $(out)",
+}
+
 android_library {
     name: "NetHttpTestsLibPreJarJar",
     srcs: ["//external/cronet:cronet_aml_javatests_sources"],
-    sdk_version: "test_current",
+    sdk_version: "module_current",
     min_sdk_version: "30",
     static_libs: [
+        "//external/cronet:cronet_testserver_utils",
         "androidx.test.ext.junit",
         "androidx.test.rules",
         "junit",
@@ -41,7 +59,7 @@
         "mts-target-sdk-version-current",
      ],
      static_libs: ["NetHttpTestsLibPreJarJar"],
-     jarjar_rules: ":framework-tethering-jarjar-rules",
+     jarjar_rules: ":net-http-test-jarjar-rules",
      jni_libs: [
         "//external/cronet:cronet_aml_components_cronet_android_cronet_tests__testing"
      ],
diff --git a/Cronet/tests/mts/jarjar_excludes.txt b/Cronet/tests/mts/jarjar_excludes.txt
new file mode 100644
index 0000000..01f4d6a
--- /dev/null
+++ b/Cronet/tests/mts/jarjar_excludes.txt
@@ -0,0 +1,10 @@
+# It's prohibited to jarjar androidx packages
+androidx\..+
+# Do not jarjar the api classes
+android\.net\..+
+# cronet_tests.so is not jarjared and uses base classes. We can remove this when there's a
+# separate java base target to depend on.
+org\.chromium\.base\..+
+# Do not jarjar the tests and its utils as they also do JNI with cronet_tests.so
+org\.chromium\.net\..*Test.*(\$.+)?
+org\.chromium\.net\.NativeTestServer(\$.+)?
\ No newline at end of file