Fix usage of annotations in TetheringLib

Annotations such as @SystemApi cannot be jarjared to a different
package, as the members would not match the system API declarations.

Instead, only build against the annotations from
framework-annotations-lib, but do not include them as classes in the
output jar; annotations are not required to be available to the
classloader at runtime.

Test: builds, boots, tethering working
Bug: 147812912
Fixes: 148609988
Change-Id: I1fae97a1c1e0ba07fa3e2d64cde7650cd26d0acd
diff --git a/Tethering/Android.bp b/Tethering/Android.bp
index cf2b1f0..1083adb 100644
--- a/Tethering/Android.bp
+++ b/Tethering/Android.bp
@@ -16,7 +16,8 @@
 
 java_defaults {
     name: "TetheringAndroidLibraryDefaults",
-    sdk_version: "system_current",
+    // TODO (b/146757305): change to module API once available
+    sdk_version: "core_platform",
     srcs: [
         "src/**/*.java",
         ":framework-tethering-shared-srcs",
@@ -34,6 +35,8 @@
     libs: [
         "framework-tethering",
         "unsupportedappusage",
+        "android_system_stubs_current",
+        "framework-res",
     ],
     plugins: ["java_api_finder"],
     manifest: "AndroidManifestBase.xml",
@@ -81,7 +84,8 @@
 // Common defaults for compiling the actual APK.
 java_defaults {
     name: "TetheringAppDefaults",
-    sdk_version: "system_current",
+    // TODO (b/146757305): change to module API once available
+    sdk_version: "core_platform",
     privileged: true,
     // Build system doesn't track transitive dependeicies for jni_libs, list all the dependencies
     // explicitly.
@@ -96,6 +100,8 @@
     ],
     libs: [
         "framework-tethering",
+        "android_system_stubs_current",
+        "framework-res",
     ],
     jarjar_rules: "jarjar-rules.txt",
     optimize: {
diff --git a/Tethering/common/TetheringLib/Android.bp b/Tethering/common/TetheringLib/Android.bp
index e0adb34..24762ff 100644
--- a/Tethering/common/TetheringLib/Android.bp
+++ b/Tethering/common/TetheringLib/Android.bp
@@ -41,12 +41,12 @@
 
 java_library {
     name: "framework-tethering",
-    sdk_version: "system_current",
+    // TODO (b/146757305): change to module_app_current once available
+    sdk_version: "core_platform",
     srcs: [
         "src/android/net/TetheredClient.java",
         "src/android/net/TetheringManager.java",
         "src/android/net/TetheringConstants.java",
-        ":framework-tethering-annotations",
     ],
     static_libs: [
         "tethering-aidl-interfaces-java",
@@ -55,6 +55,7 @@
     installable: true,
 
     libs: [
+        "framework-annotations-lib",
         "android_system_stubs_current",
     ],
 
diff --git a/Tethering/common/TetheringLib/jarjar-rules.txt b/Tethering/common/TetheringLib/jarjar-rules.txt
index 1403bba..e459fad 100644
--- a/Tethering/common/TetheringLib/jarjar-rules.txt
+++ b/Tethering/common/TetheringLib/jarjar-rules.txt
@@ -1,2 +1 @@
-rule android.annotation.** com.android.networkstack.tethering.annotation.@1
-rule com.android.internal.annotations.** com.android.networkstack.tethering.annotation.@1
\ No newline at end of file
+# jarjar rules for the bootclasspath tethering framework library here
\ No newline at end of file