Make our javalib more self-contained

Statically link HypervisorProperties, since it's inaccessible to app
code, with jarjar rules to rename it and remove the unneeded
sysprops. This allows clients that are compiled against our stubs to
run correctly.

These changes were originally included in
https://r.android.com/2192919, but they are useful now, before the API
is officially exposed, to allow for experimentation.

Bug: 242828259
Bug: 243512240
Test: Build test APK against stubs, atest MicrodroidHostTests
Change-Id: I6ec49d0a4c9a80100f184f23821b6e9d4ce265f9
diff --git a/javalib/Android.bp b/javalib/Android.bp
index 1df9b51..a6c3b80 100644
--- a/javalib/Android.bp
+++ b/javalib/Android.bp
@@ -2,20 +2,34 @@
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
+// Defines our permissions
+android_app {
+    name: "android.system.virtualmachine.res",
+    installable: true,
+    apex_available: ["com.android.virt"],
+    sdk_version: "current",
+}
+
 java_sdk_library {
     name: "android.system.virtualmachine",
     installable: true,
     compile_dex: true,
 
+    jarjar_rules: "jarjar-rules.txt",
+
     srcs: ["src/**/*.java"],
     static_libs: [
         "android.system.virtualizationservice-java",
+        // For android.sysprop.HypervisorProperties
+        "PlatformProperties",
     ],
 
     apex_available: ["com.android.virt"],
     permitted_packages: [
         "android.system.virtualmachine",
         "android.system.virtualizationservice",
+        // android.sysprop.*, renamed by jarjar
+        "com.android.system.virtualmachine.sysprop",
     ],
 }
 
@@ -23,10 +37,3 @@
     name: "android-virtualization-framework-sdk",
     api_dirs: ["32"],
 }
-
-android_app {
-    name: "android.system.virtualmachine.res",
-    installable: true,
-    apex_available: ["com.android.virt"],
-    sdk_version: "current",
-}
diff --git a/javalib/jarjar-rules.txt b/javalib/jarjar-rules.txt
new file mode 100644
index 0000000..dd8ad2d
--- /dev/null
+++ b/javalib/jarjar-rules.txt
@@ -0,0 +1,9 @@
+# Rules for the android.system.virtualmachine java_sdk_library.
+
+# This is the root of the API, everything we care about should be
+# reachable from here.
+# (This gets rid of all the android.sysprop classes we don't use.)
+keep android.system.virtualmachine.VirtualMachineManager
+
+# We statically link PlatformProperties, rename to avoid clashes.
+rule android.sysprop.** com.android.system.virtualmachine.sysprop.@1