Merge changes from topic "bootstrap-service-virtualization-jar" into main

* changes:
  Track dependency between llpvm, remote attestation and dice flags
  Add a VirtualizationSystemService that runs inside system_server
diff --git a/apex/Android.bp b/apex/Android.bp
index 7c45cc5..7cc0414 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -32,7 +32,26 @@
     },
 }
 
-apex_defaults {
+soong_config_module_type {
+    name: "avf_flag_aware_apex_defaults",
+    module_type: "apex_defaults",
+    config_namespace: "ANDROID",
+    bool_variables: [
+        "release_avf_enable_device_assignment",
+        "release_avf_enable_llpvm_changes",
+        "release_avf_enable_remote_attestation",
+        "release_avf_enable_vendor_modules",
+    ],
+    properties: [
+        "androidManifest",
+        "arch",
+        "prebuilts",
+        "systemserverclasspath_fragments",
+        "vintf_fragments",
+    ],
+}
+
+avf_flag_aware_apex_defaults {
     name: "com.android.virt_common",
     // TODO(jiyong): make it updatable
     updatable: false,
@@ -65,22 +84,13 @@
         "libsso",
         "libutils",
     ],
-}
-
-soong_config_module_type {
-    name: "avf_flag_aware_apex_defaults",
-    module_type: "apex_defaults",
-    config_namespace: "ANDROID",
-    bool_variables: [
-        "release_avf_enable_device_assignment",
-        "release_avf_enable_remote_attestation",
-        "release_avf_enable_vendor_modules",
-    ],
-    properties: [
-        "arch",
-        "prebuilts",
-        "vintf_fragments",
-    ],
+    soong_config_variables: {
+        release_avf_enable_llpvm_changes: {
+            systemserverclasspath_fragments: [
+                "com.android.virt-systemserver-fragment",
+            ],
+        },
+    },
 }
 
 avf_flag_aware_apex_defaults {
@@ -143,6 +153,9 @@
                 },
             },
         },
+        release_avf_enable_llpvm_changes: {
+            androidManifest: "AndroidManifest.xml",
+        },
         release_avf_enable_vendor_modules: {
             prebuilts: [
                 "microdroid_gki-android14-6.1_initrd_debuggable",
@@ -322,3 +335,29 @@
         ],
     },
 }
+
+soong_config_module_type {
+    name: "avf_flag_aware_systemserverclasspath_fragment",
+    module_type: "systemserverclasspath_fragment",
+    config_namespace: "ANDROID",
+    bool_variables: [
+        "release_avf_enable_llpvm_changes",
+    ],
+    properties: [
+        "enabled",
+    ],
+}
+
+avf_flag_aware_systemserverclasspath_fragment {
+    name: "com.android.virt-systemserver-fragment",
+    contents: [
+        "service-virtualization",
+    ],
+    apex_available: ["com.android.virt"],
+    enabled: false,
+    soong_config_variables: {
+        release_avf_enable_llpvm_changes: {
+            enabled: true,
+        },
+    },
+}
diff --git a/apex/AndroidManifest.xml b/apex/AndroidManifest.xml
new file mode 100644
index 0000000..be52f42
--- /dev/null
+++ b/apex/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="com.android.virt">
+    <!-- APEX does not have classes.dex -->
+    <application android:hasCode="false">
+        <apex-system-service
+            android:name="com.android.system.virtualmachine.VirtualizationSystemService"
+        />
+    </application>
+</manifest>
diff --git a/apex/product_packages.mk b/apex/product_packages.mk
index 4c03836..a318817 100644
--- a/apex/product_packages.mk
+++ b/apex/product_packages.mk
@@ -44,3 +44,15 @@
     $(error RELEASE_AVF_ENABLE_VENDOR_MODULES must also be enabled)
   endif
 endif
+
+ifdef RELEASE_AVF_ENABLE_LLPVM_CHANGES
+  ifndef RELEASE_AVF_ENABLE_DICE_CHANGES
+    $(error RELEASE_AVF_ENABLE_DICE_CHANGES must also be enabled)
+  endif
+endif
+
+ifdef RELEASE_AVF_ENABLE_REMOTE_ATTESTATION
+  ifndef RELEASE_AVF_ENABLE_DICE_CHANGES
+    $(error RELEASE_AVF_ENABLE_DICE_CHANGES must also be enabled)
+  endif
+endif
diff --git a/javalib/service/Android.bp b/javalib/service/Android.bp
new file mode 100644
index 0000000..9c1fa01
--- /dev/null
+++ b/javalib/service/Android.bp
@@ -0,0 +1,30 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+java_library {
+    name: "service-virtualization",
+    srcs: [
+        "src/**/*.java",
+    ],
+    defaults: [
+        "framework-system-server-module-defaults",
+    ],
+    sdk_version: "system_server_current",
+    apex_available: ["com.android.virt"],
+    installable: true,
+}
diff --git a/javalib/service/src/com/android/system/virtualmachine/VirtualizationSystemService.java b/javalib/service/src/com/android/system/virtualmachine/VirtualizationSystemService.java
new file mode 100644
index 0000000..2905acd
--- /dev/null
+++ b/javalib/service/src/com/android/system/virtualmachine/VirtualizationSystemService.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.system.virtualmachine;
+
+import android.content.Context;
+import com.android.server.SystemService;
+
+/** TODO */
+public class VirtualizationSystemService extends SystemService {
+
+    public VirtualizationSystemService(Context context) {
+        super(context);
+    }
+
+    @Override
+    public void onStart() {}
+}