Allow preinstalled apps to use the AVF APIs

Guarded by a build-time flag.

Bug: 278765584
Test: Builds, with and without the flag enabled
Test: With flag enabled, preinstalled app gets permission
Change-Id: I9dc43d88060744b1d9d50fd8ff6b12c156bfcbf3
diff --git a/javalib/Android.bp b/javalib/Android.bp
index a124af7..cbc2a17 100644
--- a/javalib/Android.bp
+++ b/javalib/Android.bp
@@ -2,12 +2,25 @@
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
+soong_config_module_type {
+    name: "avf_flag_aware_android_app",
+    module_type: "android_app",
+    config_namespace: "ANDROID",
+    bool_variables: ["release_avf_allow_preinstalled_apps"],
+    properties: ["manifest"],
+}
+
 // Defines our permissions
-android_app {
+avf_flag_aware_android_app {
     name: "android.system.virtualmachine.res",
     installable: true,
     apex_available: ["com.android.virt"],
     platform_apis: true,
+    soong_config_variables: {
+        release_avf_allow_preinstalled_apps: {
+            manifest: "AndroidManifestNext.xml",
+        },
+    },
 }
 
 java_sdk_library {