Snap for 8564071 from afff79c8641d51e53e49f564ce79993b474b6c8c to mainline-cellbroadcast-release

Change-Id: Id48cbf1055bd5f3bcdee205915578f41c3c3dd68
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
new file mode 100644
index 0000000..32ac42d
--- /dev/null
+++ b/AndroidProducts.mk
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+PRODUCT_MAKEFILES := \
+    $(LOCAL_DIR)/gki_arm64.mk \
+    $(LOCAL_DIR)/gki_x86_64.mk \
+    $(LOCAL_DIR)/gsi_arm.mk \
+    $(LOCAL_DIR)/gsi_arm64.mk \
+    $(LOCAL_DIR)/gsi_x86.mk \
+    $(LOCAL_DIR)/gsi_x86_64.mk \
+    $(LOCAL_DIR)/mgsi/csi_arm.mk \
+    $(LOCAL_DIR)/mgsi/csi_arm64.mk \
+    $(LOCAL_DIR)/mgsi/csi_x86.mk \
+    $(LOCAL_DIR)/mgsi/csi_x86_64.mk \
+    $(LOCAL_DIR)/mgsi/mgsi_arm.mk \
+    $(LOCAL_DIR)/mgsi/mgsi_arm64.mk \
+    $(LOCAL_DIR)/mgsi/mgsi_x86.mk \
+    $(LOCAL_DIR)/mgsi/mgsi_x86_64.mk
diff --git a/BoardConfigGkiCommon.mk b/BoardConfigGkiCommon.mk
new file mode 100644
index 0000000..c7970d7
--- /dev/null
+++ b/BoardConfigGkiCommon.mk
@@ -0,0 +1,52 @@
+# 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.
+#
+
+# Enable GKI 2.0 certification
+BOARD_GKI_SIGNING_KEY_PATH := build/make/target/product/gsi/testkey_rsa2048.pem
+BOARD_GKI_SIGNING_ALGORITHM := SHA256_RSA2048
+
+# Enable chained vbmeta for boot and init_boot images
+BOARD_AVB_ENABLE := true
+BOARD_AVB_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
+
+BOARD_AVB_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
+BOARD_AVB_BOOT_ALGORITHM := SHA256_RSA4096
+BOARD_AVB_BOOT_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
+BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION := 2
+
+BOARD_AVB_INIT_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
+BOARD_AVB_INIT_BOOT_ALGORITHM := SHA256_RSA4096
+BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
+BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION := 3
+
+# Sets boot SPL.
+BOOT_SECURITY_PATCH = $(PLATFORM_SECURITY_PATCH)
+
+# Boot image with kernel only (no ramdisk)
+BOARD_BOOT_HEADER_VERSION := 4
+BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION)
+BOARD_USES_RECOVERY_AS_BOOT :=
+TARGET_NO_KERNEL := false
+BOARD_USES_GENERIC_KERNEL_IMAGE := true
+BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK ?= true
+
+# No system image
+BOARD_SYSTEMIMAGE_PARTITION_SIZE :=
+
+# No vendor_boot
+BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT :=
+
+# No recovery
+BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE :=
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..d97975c
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+  license_type: NOTICE
+}
diff --git a/gki_arm64.mk b/gki_arm64.mk
new file mode 100644
index 0000000..3ff21cd
--- /dev/null
+++ b/gki_arm64.mk
@@ -0,0 +1,65 @@
+#
+# 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.
+#
+
+#
+# TODO (b/212486689): The minimum system stuff for build pass.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
+
+#
+# Build GKI boot images
+#
+include device/generic/common/gki_common.mk
+
+PRODUCT_COPY_FILES += \
+    kernel/prebuilts/4.19/arm64/kernel-4.19:kernel-4.19 \
+    kernel/prebuilts/4.19/arm64/kernel-4.19-gz:kernel-4.19-gz \
+    kernel/prebuilts/4.19/arm64/kernel-4.19-lz4:kernel-4.19-lz4 \
+    kernel/prebuilts/5.10/arm64/kernel-5.10:kernel-5.10 \
+    kernel/prebuilts/5.10/arm64/kernel-5.10-gz:kernel-5.10-gz \
+    kernel/prebuilts/5.10/arm64/kernel-5.10-lz4:kernel-5.10-lz4 \
+    kernel/prebuilts/5.15/arm64/kernel-5.15:kernel-5.15 \
+    kernel/prebuilts/5.15/arm64/kernel-5.15-gz:kernel-5.15-gz \
+    kernel/prebuilts/5.15/arm64/kernel-5.15-lz4:kernel-5.15-lz4 \
+
+$(call dist-for-goals,dist_files,kernel/prebuilts/4.19/arm64/prebuilt-info.txt:kernel/4.19/prebuilt-info.txt)
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.10/arm64/prebuilt-info.txt:kernel/5.10/prebuilt-info.txt)
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.15/arm64/prebuilt-info.txt:kernel/5.15/prebuilt-info.txt)
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+PRODUCT_COPY_FILES += \
+    kernel/prebuilts/4.19/arm64/kernel-4.19-allsyms:kernel-4.19-allsyms \
+    kernel/prebuilts/4.19/arm64/kernel-4.19-gz-allsyms:kernel-4.19-gz-allsyms \
+    kernel/prebuilts/4.19/arm64/kernel-4.19-lz4-allsyms:kernel-4.19-lz4-allsyms \
+    kernel/prebuilts/5.10/arm64/kernel-5.10-allsyms:kernel-5.10-allsyms \
+    kernel/prebuilts/5.10/arm64/kernel-5.10-gz-allsyms:kernel-5.10-gz-allsyms \
+    kernel/prebuilts/5.10/arm64/kernel-5.10-lz4-allsyms:kernel-5.10-lz4-allsyms \
+    kernel/prebuilts/5.15/arm64/kernel-5.15-allsyms:kernel-5.15-allsyms \
+    kernel/prebuilts/5.15/arm64/kernel-5.15-gz-allsyms:kernel-5.15-gz-allsyms \
+    kernel/prebuilts/5.15/arm64/kernel-5.15-lz4-allsyms:kernel-5.15-lz4-allsyms \
+
+$(call dist-for-goals,dist_files,kernel/prebuilts/4.19/arm64/prebuilt-info.txt:kernel/4.19-debug/prebuilt-info.txt)
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.10/arm64/prebuilt-info.txt:kernel/5.10-debug/prebuilt-info.txt)
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.15/arm64/prebuilt-info.txt:kernel/5.15-debug/prebuilt-info.txt)
+
+endif
+
+
+PRODUCT_NAME := gki_arm64
+PRODUCT_DEVICE := gki_arm64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GKI on ARM64
diff --git a/gki_arm64/BoardConfig.mk b/gki_arm64/BoardConfig.mk
new file mode 100644
index 0000000..0263549
--- /dev/null
+++ b/gki_arm64/BoardConfig.mk
@@ -0,0 +1,56 @@
+# 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.
+#
+
+TARGET_ARCH := arm64
+TARGET_ARCH_VARIANT := armv8-a
+TARGET_CPU_ABI := arm64-v8a
+TARGET_CPU_ABI2 :=
+TARGET_CPU_VARIANT := generic
+
+TARGET_2ND_ARCH := arm
+TARGET_2ND_ARCH_VARIANT := armv8-a
+TARGET_2ND_CPU_ABI := armeabi-v7a
+TARGET_2ND_CPU_ABI2 := armeabi
+TARGET_2ND_CPU_VARIANT := generic
+
+include device/generic/common/BoardConfigGkiCommon.mk
+
+BOARD_KERNEL-4.19-GZ_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-4.19-GZ-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.10_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10-GZ_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.10-GZ-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.10-LZ4_BOOTIMAGE_PARTITION_SIZE := 53477376
+BOARD_KERNEL-5.10-LZ4-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 53477376
+BOARD_KERNEL-5.15_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.15-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.15-GZ_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.15-GZ-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.15-LZ4_BOOTIMAGE_PARTITION_SIZE := 53477376
+BOARD_KERNEL-5.15-LZ4-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 53477376
+
+BOARD_KERNEL_BINARIES := \
+    kernel-4.19-gz \
+    kernel-5.10 kernel-5.10-gz kernel-5.10-lz4 \
+    kernel-5.15 kernel-5.15-gz kernel-5.15-lz4 \
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+BOARD_KERNEL_BINARIES += \
+    kernel-4.19-gz-allsyms \
+    kernel-5.10-allsyms kernel-5.10-gz-allsyms kernel-5.10-lz4-allsyms \
+    kernel-5.15-allsyms kernel-5.15-gz-allsyms kernel-5.15-lz4-allsyms \
+
+endif
diff --git a/gki_common.mk b/gki_common.mk
new file mode 100644
index 0000000..42b9a6c
--- /dev/null
+++ b/gki_common.mk
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+
+#
+# Output boot.img
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_ramdisk.mk)
+PRODUCT_BUILD_BOOT_IMAGE := true
+
+PRODUCT_BUILD_INIT_BOOT_IMAGE := false
+PRODUCT_BUILD_CACHE_IMAGE := false
+PRODUCT_BUILD_ODM_IMAGE := false
+PRODUCT_BUILD_VENDOR_DLKM_IMAGE := false
+PRODUCT_BUILD_ODM_DLKM_IMAGE := false
+PRODUCT_BUILD_PRODUCT_IMAGE  := false
+PRODUCT_BUILD_RAMDISK_IMAGE := true
+PRODUCT_BUILD_SYSTEM_IMAGE := false
+PRODUCT_BUILD_SYSTEM_EXT_IMAGE := false
+PRODUCT_BUILD_SYSTEM_OTHER_IMAGE := false
+PRODUCT_BUILD_USERDATA_IMAGE := false
+PRODUCT_BUILD_VENDOR_IMAGE := false
+PRODUCT_BUILD_VENDOR_BOOT_IMAGE := false
+PRODUCT_BUILD_RECOVERY_IMAGE := false
+PRODUCT_BUILD_VBMETA_IMAGE := false
+PRODUCT_BUILD_DEBUG_BOOT_IMAGE := false
+PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE := false
+
+MODULE_BUILD_FROM_SOURCE := true
+PRODUCT_EXPORT_BOOT_IMAGE_TO_DIST := true
diff --git a/gki_x86_64.mk b/gki_x86_64.mk
new file mode 100644
index 0000000..2dc7919
--- /dev/null
+++ b/gki_x86_64.mk
@@ -0,0 +1,50 @@
+#
+# 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.
+#
+
+#
+# TODO (b/212486689): The minimum system stuff for build pass.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
+
+#
+# Build GKI boot images
+#
+include device/generic/common/gki_common.mk
+
+PRODUCT_COPY_FILES += \
+    kernel/prebuilts/5.10/x86_64/kernel-5.10:kernel-5.10 \
+    kernel/prebuilts/5.15/x86_64/kernel-5.15:kernel-5.15 \
+
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.10/x86_64/prebuilt-info.txt:kernel/5.10/prebuilt-info.txt)
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.15/x86_64/prebuilt-info.txt:kernel/5.15/prebuilt-info.txt)
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+
+PRODUCT_COPY_FILES += \
+    kernel/prebuilts/5.10/x86_64/kernel-5.10-allsyms:kernel-5.10-allsyms \
+    kernel/prebuilts/5.15/x86_64/kernel-5.15-allsyms:kernel-5.15-allsyms \
+
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.10/x86_64/prebuilt-info.txt:kernel/5.10-debug/prebuilt-info.txt)
+$(call dist-for-goals,dist_files,kernel/prebuilts/5.15/x86_64/prebuilt-info.txt:kernel/5.15-debug/prebuilt-info.txt)
+
+endif
+
+
+PRODUCT_NAME := gki_x86_64
+PRODUCT_DEVICE := gki_x86_64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GKI on x86_64
diff --git a/gki_x86_64/BoardConfig.mk b/gki_x86_64/BoardConfig.mk
new file mode 100755
index 0000000..6321edc
--- /dev/null
+++ b/gki_x86_64/BoardConfig.mk
@@ -0,0 +1,42 @@
+# 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.
+#
+
+TARGET_CPU_ABI := x86_64
+TARGET_ARCH := x86_64
+TARGET_ARCH_VARIANT := x86_64
+
+TARGET_2ND_CPU_ABI := x86
+TARGET_2ND_ARCH := x86
+TARGET_2ND_ARCH_VARIANT := x86_64
+
+include device/generic/common/BoardConfigGkiCommon.mk
+
+BOARD_KERNEL-5.4_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.15_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.15-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 67108864
+
+# Boot images
+BOARD_KERNEL_BINARIES := \
+    kernel-5.10 \
+    kernel-5.15 \
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+BOARD_KERNEL_BINARIES += \
+    kernel-5.10-allsyms \
+    kernel-5.15-allsyms \
+
+endif
diff --git a/gsi_arm.mk b/gsi_arm.mk
new file mode 100644
index 0000000..1a28cc8
--- /dev/null
+++ b/gsi_arm.mk
@@ -0,0 +1,51 @@
+#
+# 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.
+#
+
+# The system image of gsi_arm-userdebug is the GSI for devices with:
+# - ARM 32-bit userspace
+# - 64-bit binder interface
+# - system-as-root
+# - VNDK enforcement
+# - compatible property override enabled
+
+#
+# All components inherited here go to system image
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
+
+# Enable mainline checking
+PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := true
+
+#
+# All components inherited here go to system_ext image
+#
+$(call inherit-product, device/generic/common/gsi_system_ext.mk)
+
+#
+# All components inherited here go to product image
+#
+$(call inherit-product, device/generic/common/gsi_product.mk)
+
+#
+# Special settings for GSI releasing
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_release.mk)
+
+
+PRODUCT_NAME := gsi_arm
+PRODUCT_DEVICE := generic
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GSI on ARM
diff --git a/gsi_arm64.mk b/gsi_arm64.mk
new file mode 100644
index 0000000..d792cd9
--- /dev/null
+++ b/gsi_arm64.mk
@@ -0,0 +1,52 @@
+#
+# 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.
+#
+
+# The system image of gsi_arm64-userdebug is the GSI for devices with:
+# - ARM 64-bit userspace
+# - 64-bit binder interface
+# - system-as-root
+# - VNDK enforcement
+# - compatible property override enabled
+
+#
+# All components inherited here go to system image
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
+
+# Enable mainline checking
+PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := true
+
+#
+# All components inherited here go to system_ext image
+#
+$(call inherit-product, device/generic/common/gsi_system_ext.mk)
+
+#
+# All components inherited here go to product image
+#
+$(call inherit-product, device/generic/common/gsi_product.mk)
+
+#
+# Special settings for GSI releasing
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_release.mk)
+
+
+PRODUCT_NAME := gsi_arm64
+PRODUCT_DEVICE := generic_arm64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GSI on ARM64
diff --git a/gsi_product.mk b/gsi_product.mk
new file mode 100644
index 0000000..aad06d2
--- /dev/null
+++ b/gsi_product.mk
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+
+# This makefile contains the product partition contents for CTS on
+# GSI compliance testing. Only add something here for this purpose.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_product.mk)
+
+PRODUCT_PACKAGES += \
+    Browser2 \
+    Camera2 \
+    Dialer \
+    LatinIME \
+    messaging \
+
+# Default AOSP sounds
+$(call inherit-product-if-exists, frameworks/base/data/sounds/AllAudio.mk)
+
+# Additional settings used in all AOSP builds
+PRODUCT_PRODUCT_PROPERTIES += \
+    ro.config.ringtone?=Ring_Synth_04.ogg \
+    ro.config.notification_sound?=pixiedust.ogg \
+    ro.com.android.dataroaming?=true \
+
+PRODUCT_COPY_FILES += \
+    device/sample/etc/apns-full-conf.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/apns-conf.xml
diff --git a/gsi_system_ext.mk b/gsi_system_ext.mk
new file mode 100644
index 0000000..ff487e2
--- /dev/null
+++ b/gsi_system_ext.mk
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+
+# This makefile contains the system_ext partition contents for CTS on
+# GSI compliance testing. Only add something here for this purpose.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_system_ext.mk)
+
+#  handheld packages
+PRODUCT_PACKAGES += \
+    Launcher3QuickStep \
+    Provision \
+    Settings \
+    StorageManager \
+    SystemUI
+
+#  telephony packages
+PRODUCT_PACKAGES += \
+    CarrierConfig
+
+# Install a copy of the debug policy to the system_ext partition, and allow
+# init-second-stage to load debug policy from system_ext.
+# This option is only meant to be set by compliance GSI targets.
+PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT := true
+PRODUCT_PACKAGES += system_ext_userdebug_plat_sepolicy.cil
diff --git a/gsi_x86.mk b/gsi_x86.mk
new file mode 100644
index 0000000..0dfde63
--- /dev/null
+++ b/gsi_x86.mk
@@ -0,0 +1,47 @@
+#
+# 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.
+#
+
+#
+# All components inherited here go to system image
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
+
+# Enable mainline checking
+PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := true
+
+#
+# All components inherited here go to system_ext image
+#
+$(call inherit-product, device/generic/common/gsi_system_ext.mk)
+
+#
+# All components below go to product image
+#
+$(call inherit-product, device/generic/common/gsi_product.mk)
+
+#
+# Special settings to skip mount product and system_ext on the device,
+# so this product can be tested isolated from those partitions.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_release.mk)
+
+# Needed to build mk_combined_img used for creating mixed GSI/emu image
+PRODUCT_SOONG_NAMESPACES += device/generic/goldfish
+
+PRODUCT_NAME := gsi_x86
+PRODUCT_DEVICE := generic_x86
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GSI on x86
diff --git a/gsi_x86_64.mk b/gsi_x86_64.mk
new file mode 100644
index 0000000..eb5bd97
--- /dev/null
+++ b/gsi_x86_64.mk
@@ -0,0 +1,48 @@
+#
+# 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.
+#
+
+#
+# All components inherited here go to system image
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
+
+# Enable mainline checking
+PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := true
+
+#
+# All components inherited here go to system_ext image
+#
+$(call inherit-product, device/generic/common/gsi_system_ext.mk)
+
+#
+# All components below go to product image
+#
+$(call inherit-product, device/generic/common/gsi_product.mk)
+
+#
+# Special settings to skip mount product and system_ext on the device,
+# so this product can be tested isolated from those partitions.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_release.mk)
+
+# Needed to build mk_combined_img used for creating mixed GSI/emu image
+PRODUCT_SOONG_NAMESPACES += device/generic/goldfish
+
+PRODUCT_NAME := gsi_x86_64
+PRODUCT_DEVICE := generic_x86_64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GSI on x86_64
diff --git a/mgsi/AndroidProducts.mk b/mgsi/AndroidProducts.mk
deleted file mode 100644
index f6b0bfc..0000000
--- a/mgsi/AndroidProducts.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Copyright 2019 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.
-#
-
-PRODUCT_MAKEFILES := \
-	device/generic/common/mgsi/csi_arm64.mk \
-	device/generic/common/mgsi/csi_x86.mk \
-	device/generic/common/mgsi/mgsi_arm.mk \
-	device/generic/common/mgsi/mgsi_arm64.mk \
-	device/generic/common/mgsi/mgsi_x86.mk \
-	device/generic/common/mgsi/mgsi_x86_64.mk \
diff --git a/mgsi/BoardConfigMgsiCommon.mk b/mgsi/BoardConfigMgsiCommon.mk
index a6b1f4f..82efc09 100644
--- a/mgsi/BoardConfigMgsiCommon.mk
+++ b/mgsi/BoardConfigMgsiCommon.mk
@@ -55,7 +55,3 @@
 
 # Disable 64 bit mediadrmserver
 TARGET_ENABLE_MEDIADRM_64 :=
-
-# Ordinary (non-flattened) APEX may require kernel changes. For maximum compatibility,
-# use flattened APEX for MGSI
-TARGET_FLATTEN_APEX := true
diff --git a/mgsi/csi_arm.mk b/mgsi/csi_arm.mk
new file mode 100644
index 0000000..2739ec1
--- /dev/null
+++ b/mgsi/csi_arm.mk
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+
+#
+# All components inherited here go to system image
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
+
+# Enable mainline checking
+PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
+
+#
+# All components inherited here go to system_ext image
+#
+# VNDK snapshot is needed to support older vendor images
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_system_ext.mk)
+
+#
+# All components below go to product image
+#
+
+#
+# Special settings to skip mount product and system_ext on the device,
+# so this product can be tested isolated from those partitions.
+#
+$(call inherit-product, device/generic/common/mgsi/mgsi_release.mk)
+
+# Don't build super.img.
+PRODUCT_BUILD_SUPER_PARTITION := false
+
+# Instruct AM to enable framework's fallback home activity
+PRODUCT_SYSTEM_EXT_PROPERTIES += ro.system_user_home_needed=true
+# Add RRO needed by CSI
+PRODUCT_PACKAGE_OVERLAYS := device/generic/common/mgsi/overlay
+
+PRODUCT_SOONG_NAMESPACES += device/generic/goldfish
+
+PRODUCT_NAME := csi_arm
+PRODUCT_DEVICE := dummy_arm
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := arm CSI
diff --git a/mgsi/csi_arm64.mk b/mgsi/csi_arm64.mk
index cbe69f6..401ae8f 100644
--- a/mgsi/csi_arm64.mk
+++ b/mgsi/csi_arm64.mk
@@ -18,7 +18,7 @@
 # All components inherited here go to system image
 #
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking
 PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
@@ -32,8 +32,6 @@
 #
 # All components below go to product image
 #
-# NFC: Provide a libnfc-nci.conf to CSI (to avoid nfc related exceptions)
-PRODUCT_COPY_FILES += device/generic/common/nfc/libnfc-nci.conf:$(TARGET_COPY_OUT_PRODUCT)/etc/libnfc-nci.conf
 
 #
 # Special settings to skip mount product and system_ext on the device,
diff --git a/mgsi/csi_x86.mk b/mgsi/csi_x86.mk
index a041f14..46ab8cd 100644
--- a/mgsi/csi_x86.mk
+++ b/mgsi/csi_x86.mk
@@ -17,7 +17,7 @@
 #
 # All components inherited here go to system image
 #
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking
 PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
@@ -31,8 +31,6 @@
 #
 # All components below go to product image
 #
-# NFC: Provide a libnfc-nci.conf to CSI (to avoid nfc related exceptions)
-PRODUCT_COPY_FILES += device/generic/common/nfc/libnfc-nci.conf:$(TARGET_COPY_OUT_PRODUCT)/etc/libnfc-nci.conf
 
 #
 # Special settings to skip mount product and system_ext on the device,
diff --git a/mgsi/csi_x86_64.mk b/mgsi/csi_x86_64.mk
new file mode 100644
index 0000000..cceed35
--- /dev/null
+++ b/mgsi/csi_x86_64.mk
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+
+#
+# All components inherited here go to system image
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
+
+# Enable mainline checking
+PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
+
+#
+# All components inherited here go to system_ext image
+#
+# VNDK snapshot is needed to support older vendor images
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_system_ext.mk)
+
+#
+# All components below go to product image
+#
+
+#
+# Special settings to skip mount product and system_ext on the device,
+# so this product can be tested isolated from those partitions.
+#
+$(call inherit-product, device/generic/common/mgsi/mgsi_release.mk)
+
+# Don't build super.img.
+PRODUCT_BUILD_SUPER_PARTITION := false
+
+# Instruct AM to enable framework's fallback home activity
+PRODUCT_SYSTEM_EXT_PROPERTIES += ro.system_user_home_needed=true
+# Add RRO needed by CSI
+PRODUCT_PACKAGE_OVERLAYS := device/generic/common/mgsi/overlay
+
+PRODUCT_SOONG_NAMESPACES += device/generic/goldfish
+
+PRODUCT_NAME := csi_x86_64
+PRODUCT_DEVICE := dummy_x86_64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := x86_64 CSI
diff --git a/mgsi/mgsi_arm.mk b/mgsi/mgsi_arm.mk
index 5068311..c1011c4 100644
--- a/mgsi/mgsi_arm.mk
+++ b/mgsi/mgsi_arm.mk
@@ -17,7 +17,7 @@
 #
 # All components inherited here go to system image
 #
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking
 PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
diff --git a/mgsi/mgsi_arm64.mk b/mgsi/mgsi_arm64.mk
index 89753f3..1c1a4ee 100644
--- a/mgsi/mgsi_arm64.mk
+++ b/mgsi/mgsi_arm64.mk
@@ -18,7 +18,7 @@
 # All components inherited here go to system image
 #
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking
 PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
diff --git a/mgsi/mgsi_product.mk b/mgsi/mgsi_product.mk
index 2bc04b9..fd92388 100644
--- a/mgsi/mgsi_product.mk
+++ b/mgsi/mgsi_product.mk
@@ -36,8 +36,3 @@
 #   Provide a APN configuration to GSI product
 PRODUCT_COPY_FILES += \
     device/sample/etc/apns-full-conf.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/apns-conf.xml
-
-# NFC:
-#   Provide a libnfc-nci.conf to GSI product
-PRODUCT_COPY_FILES += \
-    device/generic/common/nfc/libnfc-nci.conf:$(TARGET_COPY_OUT_PRODUCT)/etc/libnfc-nci.conf
diff --git a/mgsi/mgsi_release.mk b/mgsi/mgsi_release.mk
index f697b8a..d93bdec 100644
--- a/mgsi/mgsi_release.mk
+++ b/mgsi/mgsi_release.mk
@@ -29,11 +29,6 @@
     system/product/% \
     system/system_ext/%
 
-# apex is not available before Q
-# Properties set in system (here) take precedence over those in vendor.
-PRODUCT_PRODUCT_PROPERTIES += \
-    ro.apex.updatable=false
-
 # Split selinux policy
 PRODUCT_FULL_TREBLE_OVERRIDE := true
 
@@ -49,4 +44,4 @@
     init.gsi.rc \
 
 # Support additional P and Q VNDK packages
-PRODUCT_EXTRA_VNDK_VERSIONS := 28 29
+PRODUCT_EXTRA_VNDK_VERSIONS := 30
diff --git a/mgsi/mgsi_x86.mk b/mgsi/mgsi_x86.mk
index 3a10aa5..bd73319 100644
--- a/mgsi/mgsi_x86.mk
+++ b/mgsi/mgsi_x86.mk
@@ -17,7 +17,7 @@
 #
 # All components inherited here go to system image
 #
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking for excat this product name
 PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
diff --git a/mgsi/mgsi_x86_64.mk b/mgsi/mgsi_x86_64.mk
index 9a409ee..e16deaf 100644
--- a/mgsi/mgsi_x86_64.mk
+++ b/mgsi/mgsi_x86_64.mk
@@ -18,7 +18,7 @@
 # All components inherited here go to system image
 #
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk)
 
 # Enable mainline checking
 PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed
diff --git a/nfc/libnfc-nci.conf b/nfc/libnfc-nci.conf
deleted file mode 100644
index 7c686fb..0000000
--- a/nfc/libnfc-nci.conf
+++ /dev/null
@@ -1,82 +0,0 @@
-###############################################################################
-# Debug options
-NFC_DEBUG_ENABLED=0
-
-###############################################################################
-# File used for NFA storage
-NFA_STORAGE="/data/nfc"
-PRESERVE_STORAGE=0x01
-
-###############################################################################
-# When screen is turned off, specify the desired power state of the controller.
-# 0: power-off-sleep state; DEFAULT
-# 1: full-power state
-# 2: screen-off card-emulation (CE4/CE3/CE1 modes are used)
-SCREEN_OFF_POWER_STATE=1
-
-###############################################################################
-# Default poll duration (in ms)
-#  The defualt is 500ms if not set (see nfc_target.h)
-#NFA_DM_DISC_DURATION_POLL=333
-
-###############################################################################
-# Force tag polling for the following technology(s).
-# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
-# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B |
-#            NFA_TECHNOLOGY_MASK_F | NFA_TECHNOLOGY_MASK_ISO15693 |
-#            NFA_TECHNOLOGY_MASK_B_PRIME | NFA_TECHNOLOGY_MASK_KOVIO |
-#            NFA_TECHNOLOGY_MASK_A_ACTIVE | NFA_TECHNOLOGY_MASK_F_ACTIVE.
-#
-# Notable bits:
-# NFA_TECHNOLOGY_MASK_A             0x01    /* NFC Technology A             */
-# NFA_TECHNOLOGY_MASK_B             0x02    /* NFC Technology B             */
-# NFA_TECHNOLOGY_MASK_F             0x04    /* NFC Technology F             */
-# NFA_TECHNOLOGY_MASK_ISO15693      0x08    /* Proprietary Technology       */
-# NFA_TECHNOLOGY_MASK_KOVIO         0x20    /* Proprietary Technology       */
-# NFA_TECHNOLOGY_MASK_A_ACTIVE      0x40    /* NFC Technology A active mode */
-# NFA_TECHNOLOGY_MASK_F_ACTIVE      0x80    /* NFC Technology F active mode */
-POLLING_TECH_MASK=0x2F
-
-###############################################################################
-# Force P2P to only listen for the following technology(s).
-# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
-# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_F |
-#            NFA_TECHNOLOGY_MASK_A_ACTIVE | NFA_TECHNOLOGY_MASK_F_ACTIVE
-#
-# Notable bits:
-# NFA_TECHNOLOGY_MASK_A             0x01    /* NFC Technology A             */
-# NFA_TECHNOLOGY_MASK_F             0x04    /* NFC Technology F             */
-# NFA_TECHNOLOGY_MASK_A_ACTIVE      0x40    /* NFC Technology A active mode */
-# NFA_TECHNOLOGY_MASK_F_ACTIVE      0x80    /* NFC Technology F active mode */
-P2P_LISTEN_TECH_MASK=0x00
-
-###############################################################################
-# Force UICC to only listen to the following technology(s).
-# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
-# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B | NFA_TECHNOLOGY_MASK_F
-UICC_LISTEN_TECH_MASK=0x07
-
-###############################################################################
-# Override the stack default for NFA_EE_MAX_EE_SUPPORTED set in nfc_target.h.
-# The value is set to 3 by default as it assumes we will discover 0xF2,
-# 0xF3, and 0xF4. If a platform will exclude and SE, this value can be reduced
-# so that the stack will not wait any longer than necessary.
-# Maximum EE supported number
-# NXP PN547C2 0x02
-# NXP PN65T 0x03
-# NXP PN548C2 0x02
-# NXP PN66T 0x03
-NFA_MAX_EE_SUPPORTED=0x02
-
-###############################################################################
-# AID for Empty Select command
-# If specified, this AID will be substituted when an Empty SELECT command is
-# detected.  The first byte is the length of the AID.  Maximum length is 16.
-AID_FOR_EMPTY_SELECT={08:A0:00:00:01:51:00:00:00}
-
-###############################################################################
-# AID_MATCHING constants
-# AID_MATCHING_EXACT_ONLY 0x00
-# AID_MATCHING_EXACT_OR_PREFIX 0x01
-# AID_MATCHING_PREFIX_ONLY 0x02
-AID_MATCHING_MODE=0x01