Merge "Snap for 9550355 from ca3b60361256cc97d839b2e235f78cc2f45d52d8 to sdk-release" into sdk-release
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..d84260b
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,29 @@
+//
+// Copyright (C) 2021 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: ["device_generic_common_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+    name: "device_generic_common_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+    ],
+    // large-scale-change unable to identify any license_text files
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fcb14e6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,53 @@
+# GSI
+
+This document introduces special GSI settings for facilitating xTS-on-GSI with
+a single image.
+
+### Support system_dlkm partition
+
+```
+[BoardConfigGsiCommon.mk]
+
+BOARD_USES_SYSTEM_DLKMIMAGE := true
+BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE := ext4
+TARGET_COPY_OUT_SYSTEM_DLKM := system_dlkm
+
+[gsi_release.mk]
+
+PRODUCT_BUILD_SYSTEM_DLKM_IMAGE := false
+```
+
+Starting from Android 13, all devices must include a [system_dlkm partition].
+GSI enables system_dlkm to support the devices with system_dlkm partition,
+and be compatible with old devices without a system_dlkm partition.
+
+With these configurations, `/system/system_dlkm` would not be created.
+Instead, a `/system/lib/modules` -> `/system_dlkm/lib/modules` symlink is
+created.
+
+For device without system_dlkm partition, the symlink would be dangling.
+The dangling symlink shouldn't be followed anyway because the device doesn't
+use system_dlkm.
+
+For device with system_dlkm, they can load modules via that path normally like
+when they are using their original system image.
+
+[system_dlkm partition]: https://source.android.com/docs/core/architecture/bootloader/partitions/gki-partitions
+
+### SystemUI overlays
+
+Some devices access the private android framework resource by `@*android:`
+while overlaying their SystemUI setting `status_bar_header_height_keyguard`.
+However, referencing private framework resource IDs from RRO packages in the
+vendor partition crashes on these devices when GSI is used. This is because
+private framework resource don't have a stable ID, and these vendor RRO
+packages would be referencing to dangling resource references after GSI is
+used (b/245806899).
+
+In order to prevent SystemUI crash, GSI adds a runtime resource overlay in
+the system_ext partition, which have higher overlay precedence than RROs on
+vendor partition, so the problematic vendor RROs would be overridden.
+
+Lifetime of this package:
+* Starts at: Android 14.
+* Deprecation plan: TBD, depends on b/254581880.
diff --git a/gsi_arm64.mk b/gsi_arm64.mk
index d792cd9..81b0a3e 100644
--- a/gsi_arm64.mk
+++ b/gsi_arm64.mk
@@ -35,6 +35,9 @@
 #
 $(call inherit-product, device/generic/common/gsi_system_ext.mk)
 
+# pKVM
+$(call inherit-product, packages/modules/Virtualization/apex/product_packages.mk)
+
 #
 # All components inherited here go to product image
 #
diff --git a/gsi_system_ext.mk b/gsi_system_ext.mk
index ff487e2..8fcb3d9 100644
--- a/gsi_system_ext.mk
+++ b/gsi_system_ext.mk
@@ -22,6 +22,7 @@
 PRODUCT_PACKAGES += \
     Launcher3QuickStep \
     Provision \
+    RemoteProvisioner \
     Settings \
     StorageManager \
     SystemUI
diff --git a/gsi_x86_64.mk b/gsi_x86_64.mk
index eb5bd97..b45184c 100644
--- a/gsi_x86_64.mk
+++ b/gsi_x86_64.mk
@@ -28,6 +28,9 @@
 #
 $(call inherit-product, device/generic/common/gsi_system_ext.mk)
 
+# pKVM
+$(call inherit-product, packages/modules/Virtualization/apex/product_packages.mk)
+
 #
 # All components below go to product image
 #
diff --git a/overlays/SystemUI/Android.bp b/overlays/SystemUI/Android.bp
new file mode 100644
index 0000000..361729a
--- /dev/null
+++ b/overlays/SystemUI/Android.bp
@@ -0,0 +1,29 @@
+//
+// Copyright 2022 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 {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "device_generic_common_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["device_generic_common_license"],
+}
+
+runtime_resource_overlay {
+    name: "gsi_overlay_systemui",
+    system_ext_specific: true,
+}
diff --git a/overlays/SystemUI/AndroidManifest.xml b/overlays/SystemUI/AndroidManifest.xml
new file mode 100644
index 0000000..d76b302
--- /dev/null
+++ b/overlays/SystemUI/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2022 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.systemui.gsi.overlay">
+
+    <application android:hasCode="false" />
+
+    <overlay
+      android:targetPackage="com.android.systemui"
+      />
+</manifest>
diff --git a/overlays/SystemUI/res/values/config.xml b/overlays/SystemUI/res/values/config.xml
new file mode 100644
index 0000000..87bf621
--- /dev/null
+++ b/overlays/SystemUI/res/values/config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2022 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.
+-->
+
+<resources>
+    <dimen name="status_bar_header_height_keyguard">@*android:dimen/status_bar_height</dimen>
+</resources>
diff --git a/overlays/overlay-config.xml b/overlays/overlay-config.xml
new file mode 100644
index 0000000..8ef8a81
--- /dev/null
+++ b/overlays/overlay-config.xml
@@ -0,0 +1,22 @@
+<!--
+ * Copyright (C) 2022 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.
+ -->
+
+<config>
+    <!-- Immutable overlays must precede mutable ones -->
+    <overlay package="com.android.systemui.gsi.overlay" mutable="false" enabled="true" />
+
+    <!-- Mutable overlays -->
+</config>