Add TetheringCoverageTests

Bug: 148636687
Test: atest TetheringCoverageTests
      atest TetheringTests
      atest TetheringIntegrationTests
      atest NetworkStackTests
      atest CtsTetheringTest
Change-Id: I1f2a50f16894b05e988476520ba25baba0b60d88
diff --git a/Tethering/tests/unit/Android.bp b/Tethering/tests/unit/Android.bp
index 59681e9..4849fd5 100644
--- a/Tethering/tests/unit/Android.bp
+++ b/Tethering/tests/unit/Android.bp
@@ -14,39 +14,33 @@
 // limitations under the License.
 //
 
-android_test {
-    name: "TetheringTests",
-    certificate: "platform",
+java_defaults {
+    name: "TetheringTestsDefaults",
     srcs: [
         "src/**/*.java",
         "src/**/*.kt",
     ],
-    test_suites: [
-        "device-tests",
-        "mts",
-    ],
-    compile_multilib: "both",
     static_libs: [
+        "TetheringApiCurrentLib",
         "androidx.test.rules",
         "frameworks-base-testutils",
-        "net-tests-utils",
         "mockito-target-extended-minus-junit4",
-        "TetheringApiCurrentLib",
+        "net-tests-utils",
         "testables",
     ],
     // TODO(b/147200698) change sdk_version to module-current and
     // remove framework-minus-apex, ext, and framework-res
     sdk_version: "core_platform",
     libs: [
-        "framework-minus-apex",
-        "ext",
-        "framework-res",
-        "framework-wifi-stubs-module_libs_api",
-        "framework-telephony-stubs",
         "android.test.runner",
         "android.test.base",
         "android.test.mock",
+        "ext",
+        "framework-minus-apex",
+        "framework-res",
+        "framework-telephony-stubs",
         "framework-tethering",
+        "framework-wifi-stubs-module_libs_api",
     ],
     jni_libs: [
         // For mockito extended
@@ -55,3 +49,25 @@
     ],
     jarjar_rules: "jarjar-rules.txt",
 }
+
+// Library containing the unit tests. This is used by the coverage test target to pull in the
+// unit test code. It is not currently used by the tests themselves because all the build
+// configuration needed by the tests is in the TetheringTestsDefaults rule.
+android_library {
+    name: "TetheringTestsLib",
+    defaults: ["TetheringTestsDefaults"],
+    visibility: [
+        "//frameworks/base/packages/Tethering/tests/integration",
+    ]
+}
+
+android_test {
+    name: "TetheringTests",
+    certificate: "platform",
+    test_suites: [
+        "device-tests",
+        "mts",
+    ],
+    defaults: ["TetheringTestsDefaults"],
+    compile_multilib: "both",
+}