Merge tag 'android-15.0.0_r32' of https://android.googlesource.com/platform/build into HEAD

Android 15.0.0 Release 32 (BP1A.250505.005)

Change-Id: I42a95ed20738acc34a36098b5429f4f8ebb11b5c
diff --git a/core/Makefile b/core/Makefile
index a7ab442..0c1deed 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -2257,9 +2257,11 @@
 $(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
 $(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
 $(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
-$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
-$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
-$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
+$(if $(filter true,$(AB_OTA_UPDATER)),,\
+    $(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
+    $(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
+    $(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
+)
 $(if $(or $(_size), $(_reserved), $(_headroom)),,
     $(hide) echo "$(1)_disable_sparse=true" >> $(2))
 $(call add-common-flags-to-image-props,$(1),$(2))
@@ -6150,6 +6152,9 @@
 ifeq ($(BUILDING_WITH_VSDK),true)
 	$(hide) echo "building_with_vsdk=true" >> $@
 endif
+ifneq ($(TARGET_OTA_ASSERT_DEVICE),)
+	$(hide) echo "ota_override_device=$(TARGET_OTA_ASSERT_DEVICE)" >> $@
+endif
 
 $(call declare-0p-target,$(INSTALLED_FASTBOOT_INFO_TARGET))
 
diff --git a/core/binary.mk b/core/binary.mk
index ea862be..9dbf1fd 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -44,6 +44,28 @@
 
 my_soong_problems :=
 
+# Automatically replace the old-style kernel header include with a dependency
+# on the generated_kernel_headers header library when building inline
+ifeq ($(INLINE_KERNEL_BUILDING),true)
+ifneq (,$(findstring $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include,$(LOCAL_C_INCLUDES)))
+  LOCAL_C_INCLUDES := $(patsubst $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include,,$(LOCAL_C_INCLUDES))
+  LOCAL_HEADER_LIBRARIES += generated_kernel_headers
+endif
+
+# Some qcom binaries use this weird -isystem include...
+ifneq (,$(findstring $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include,$(LOCAL_CFLAGS)))
+  LOCAL_CFLAGS := $(patsubst -isystem $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include,,$(LOCAL_CFLAGS))
+  LOCAL_HEADER_LIBRARIES += generated_kernel_headers
+endif
+
+# Remove KERNEL_OBJ/usr from any LOCAL_ADDITIONAL_DEPENDENCIES, we will
+# just include generated_kernel_headers which already has the proper
+# dependency
+ifneq (,$(findstring $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr,$(LOCAL_ADDITIONAL_DEPENDENCIES)))
+  LOCAL_ADDITIONAL_DEPENDENCIES := $(patsubst $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr,,$(LOCAL_ADDITIONAL_DEPENDENCIES))
+endif
+endif
+
 # The following LOCAL_ variables will be modified in this file.
 # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
 # we can't modify them in place.
diff --git a/core/config.mk b/core/config.mk
index d62b86d..5fb7f8c 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -458,6 +458,8 @@
 # See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
 FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(SCAN_EXCLUDE_DIRS) .repo .git)
 
+include vendor/omni/config/BoardConfigOmni.mk
+
 # The build system exposes several variables for where to find the kernel
 # headers:
 #   TARGET_DEVICE_KERNEL_HEADERS is automatically created for the current
@@ -864,6 +866,8 @@
 endif
 
 # The default key if not set as LOCAL_CERTIFICATE
+include $(TOPDIR)vendor/omni/build/core/certs.mk
+
 ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
   DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
 else
@@ -1319,6 +1323,9 @@
 SOONG_VARIABLES :=
 SOONG_EXTRA_VARIABLES :=
 
+# Rules for QCOM targets
+include vendor/omni/build/core/qcom_target.mk
+
 include $(BUILD_SYSTEM)/dumpvar.mk
 
 ifdef BOARD_VNDK_VERSION
diff --git a/core/definitions.mk b/core/definitions.mk
index adb35e0..16db4bf 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -3286,7 +3286,7 @@
 	$(hide) mkdir -p "$$(dir $$@)"
 	$(hide) rm -f "$$@"
 	$(hide) \
-	    if $(LLVM_READOBJ) -h "$$<" >/dev/null 2>&1; then \
+	    if $(LLVM_READOBJ) -h "$$<" 2>/dev/null | grep -q "^Format: elf"; then \
 	        $(call echo-error,$(2),$(3)); \
 	        $(call echo-error,$(2),found ELF file: $$<); \
 	        false; \
diff --git a/core/product.mk b/core/product.mk
index 1b336b0..ccac78b 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -603,9 +603,11 @@
 
 # Modified internally in the build system
 _readonly_late_variables += \
+  PRODUCT_CFI_INCLUDE_PATHS \
   PRODUCT_COPY_FILES \
   PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING \
   PRODUCT_DEX_PREOPT_BOOT_FLAGS \
+  PRODUCT_SOONG_NAMESPACES
 
 _readonly_early_variables := $(filter-out $(_readonly_late_variables),$(_product_var_list))
 
diff --git a/core/soong_extra_config.mk b/core/soong_extra_config.mk
index 2ff83a1..63abb0d 100644
--- a/core/soong_extra_config.mk
+++ b/core/soong_extra_config.mk
@@ -45,6 +45,10 @@
 $(call add_json_list, PRODUCT_PROPERTY_OVERRIDES,        $(call collapse-prop-pairs,PRODUCT_PROPERTY_OVERRIDES))
 $(call add_json_list, PRODUCT_DEFAULT_PROPERTY_OVERRIDES,        $(call collapse-prop-pairs,PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
 
+$(call add_json_list, OMNI_PRODUCT_PROPERTIES,      $(call collapse-prop-pairs,OMNI_PRODUCT_PROPERTIES))
+$(call add_json_list, PRODUCT_BUILD_PROP_OVERRIDES,      $(call collapse-prop-pairs,PRODUCT_BUILD_PROP_OVERRIDES))
+$(call add_json_list, ROM_BUILDTYPE,      $(call collapse-prop-pairs,ROM_BUILDTYPE))
+
 $(call add_json_str, BootloaderBoardName, $(TARGET_BOOTLOADER_BOARD_NAME))
 
 $(call add_json_bool, SdkBuild, $(filter sdk sdk_addon,$(MAKECMDGOALS)))
diff --git a/core/sysprop.mk b/core/sysprop.mk
index dcde71b..015b366 100644
--- a/core/sysprop.mk
+++ b/core/sysprop.mk
@@ -29,15 +29,17 @@
 # $(1): Partition name
 # $(2): Output file name
 define generate-common-build-props
+    bash -c '\
+    $(or $(PRODUCT_BUILD_PROP_OVERRIDES),:);\
     echo "####################################" >> $(2);\
     echo "# from generate-common-build-props" >> $(2);\
     echo "# These properties identify this partition image." >> $(2);\
     echo "####################################" >> $(2);\
     echo "ro.product.$(1).brand=$(PRODUCT_BRAND)" >> $(2);\
-    echo "ro.product.$(1).device=$(TARGET_DEVICE)" >> $(2);\
+    echo "ro.product.$(1).device=$${DeviceName:-$(TARGET_DEVICE)}" >> $(2);\
     echo "ro.product.$(1).manufacturer=$(PRODUCT_MANUFACTURER)" >> $(2);\
-    echo "ro.product.$(1).model=$(PRODUCT_MODEL)" >> $(2);\
-    echo "ro.product.$(1).name=$(TARGET_PRODUCT)" >> $(2);\
+    echo "ro.product.$(1).model=$${ProductModel:-$(PRODUCT_MODEL)}" >> $(2);\
+    echo "ro.product.$(1).name=$${DeviceProduct:-$(TARGET_PRODUCT)}" >> $(2);\
     if [ -n "$(strip $(PRODUCT_MODEL_FOR_ATTESTATION))" ]; then \
         echo "ro.product.model_for_attestation=$(PRODUCT_MODEL_FOR_ATTESTATION)" >> $(2);\
     fi; \
@@ -68,10 +70,7 @@
     )\
     echo "ro.$(1).build.date=`$(DATE_FROM_FILE)`" >> $(2);\
     echo "ro.$(1).build.date.utc=`$(DATE_FROM_FILE) +%s`" >> $(2);\
-    # Allow optional assignments for ARC forward-declarations (b/249168657)
-    # TODO: Remove any tag-related inconsistencies once the goals from
-    # go/arc-android-sigprop-changes have been achieved.
-    echo "ro.$(1).build.fingerprint?=$(BUILD_FINGERPRINT_FROM_FILE)" >> $(2);\
+    echo "ro.$(1).build.fingerprint?=$${BuildFingerprint:-$(BUILD_FINGERPRINT_FROM_FILE)}" >> $(2);\
     echo "ro.$(1).build.id?=$(BUILD_ID)" >> $(2);\
     echo "ro.$(1).build.tags?=$(BUILD_VERSION_TAGS)" >> $(2);\
     echo "ro.$(1).build.type=$(TARGET_BUILD_VARIANT)" >> $(2);\
@@ -80,6 +79,7 @@
     echo "ro.$(1).build.version.release_or_codename=$(PLATFORM_VERSION)" >> $(2);\
     echo "ro.$(1).build.version.sdk=$(PLATFORM_SDK_VERSION)" >> $(2);\
     echo "ro.$(1).build.version.sdk_minor=$(PLATFORM_SDK_MINOR_VERSION)" >> $(2);\
+    ';\
 
 endef
 
@@ -169,11 +169,15 @@
 # non-default dev keys (usually private keys from a vendor directory).
 # Both of these tags will be removed and replaced with "release-keys"
 # when the target-files is signed in a post-build step.
+ifneq ($(filter $(ROM_BUILDTYPE), WEEKLY GAPPS MICROG),)
+BUILD_KEYS := release-keys
+else
 ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/make/target/product/security/testkey)
 BUILD_KEYS := test-keys
 else
 BUILD_KEYS := dev-keys
 endif
+endif
 BUILD_VERSION_TAGS += $(BUILD_KEYS)
 BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
 
diff --git a/envsetup.sh b/envsetup.sh
index 554a220..0f5f6d0 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -53,8 +53,8 @@
 {
     local T=$(gettop)
     # Grep out the variable names from the script.
-    cached_vars=(`cat $T/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
-    cached_abs_vars=(`cat $T/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_abs_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
+    cached_vars=(`cat $T/build/envsetup.sh $T/vendor/omni/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
+    cached_abs_vars=(`cat $T/build/envsetup.sh $T/vendor/omni/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_abs_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
     # Call the build system to dump the "<val>=<value>" pairs as a shell script.
     build_dicts_script=`\builtin cd $T; build/soong/soong_ui.bash --dumpvars-mode \
                         --vars="${cached_vars[*]}" \
@@ -324,8 +324,6 @@
 {
     set_lunch_paths
     set_sequence_number
-
-    export ANDROID_BUILD_TOP=$(gettop)
 }
 
 function set_sequence_number()
@@ -512,10 +510,29 @@
     build_build_var_cache
     if [ $? -ne 0 ]
     then
-        if [[ "$product" =~ .*_(eng|user|userdebug) ]]
-        then
-            echo "Did you mean -${product/*_/}? (dash instead of underscore)"
-        fi
+        # if we can't find the product, try to grab it from our github
+        T=$(gettop)
+        pushd $T > /dev/null
+        vendor/omni/build/tools/roomservice.py $product
+        popd > /dev/null
+        check_product $product $release
+    else
+        T=$(gettop)
+        pushd $T > /dev/null
+        vendor/omni/build/tools/roomservice.py $product true
+        popd > /dev/null
+    fi
+    if [ $? -ne 0 ]
+    then
+        echo
+        echo "** Don't have a product spec for: '$product'"
+        echo "** Do you have the right repo manifest?"
+        product=
+    fi
+
+    if [ -z "$product" -o -z "$variant" ]
+    then
+        echo
         return 1
     fi
     export TARGET_PRODUCT=$(_get_build_var_cached TARGET_PRODUCT)
@@ -524,6 +541,13 @@
     # Note this is the string "release", not the value of the variable.
     export TARGET_BUILD_TYPE=release
 
+    local prebuilt_kernel=$(_get_build_var_cached TARGET_PREBUILT_KERNEL)
+    if [ -z "$prebuilt_kernel" ]; then
+        export INLINE_KERNEL_BUILDING=true
+    else
+        unset INLINE_KERNEL_BUILDING
+    fi
+
     [[ -n "${ANDROID_QUIET_BUILD:-}" ]] || echo
 
     set_stuff_for_environment
@@ -1175,4 +1199,6 @@
 source_vendorsetup
 addcompletions
 
+export ANDROID_BUILD_TOP=$(gettop)
 
+. $ANDROID_BUILD_TOP/vendor/omni/build/envsetup.sh
diff --git a/target/product/aosp_product.mk b/target/product/aosp_product.mk
index 3a5b622..8900479 100644
--- a/target/product/aosp_product.mk
+++ b/target/product/aosp_product.mk
@@ -32,10 +32,9 @@
     initial-package-stopped-states-aosp.xml \
     messaging \
     PhotoTable \
-    preinstalled-packages-platform-aosp-product.xml \
-    ThemePicker \
+    preinstalled-packages-platform-aosp-product.xml
 
 # Telephony:
 #   Provide a APN configuration to GSI product
-PRODUCT_COPY_FILES += \
+#PRODUCT_COPY_FILES += \
     device/sample/etc/apns-full-conf.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/apns-conf.xml
diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk
index 33891d7..0b6f981 100644
--- a/target/product/default_art_config.mk
+++ b/target/product/default_art_config.mk
@@ -219,5 +219,3 @@
     dalvik.vm.image-dex2oat-Xmx=64m \
     dalvik.vm.dex2oat-Xms=64m \
     dalvik.vm.dex2oat-Xmx=512m \
-
-PRODUCT_ENABLE_UFFD_GC := default
diff --git a/target/product/handheld_product.mk b/target/product/handheld_product.mk
index 8755ae6..cb58603 100644
--- a/target/product/handheld_product.mk
+++ b/target/product/handheld_product.mk
@@ -22,18 +22,21 @@
 
 # /product packages
 PRODUCT_PACKAGES += \
-    Browser2 \
-    Calendar \
     Camera2 \
     Contacts \
-    DeskClock \
-    Gallery2 \
     LatinIME \
-    Music \
     preinstalled-packages-platform-handheld-product.xml \
-    QuickSearchBox \
     SettingsIntelligence \
     frameworks-base-overlays
 
+ifneq ($(PRODUCT_EXCLUDE_EXTRA_PACKAGES),true)
+PRODUCT_PACKAGES += \
+    Browser2 \
+    Calendar \
+    DeskClock \
+    Gallery2 \
+    Music
+endif
+
 PRODUCT_PACKAGES_DEBUG += \
     frameworks-base-overlays-debug
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 464ad9b..4755aac 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -312,7 +312,7 @@
       base_fs_file = ConvertBlockMapToBaseFs(prop_dict["base_fs_file"])
       build_command.extend(["-d", base_fs_file])
     build_command.extend(["-L", prop_dict["mount_point"]])
-    if "extfs_inode_count" in prop_dict:
+    if "extfs_inode_count" in prop_dict and int(prop_dict["extfs_inode_count"]) >= 0:
       build_command.extend(["-i", prop_dict["extfs_inode_count"]])
     if "extfs_rsv_pct" in prop_dict:
       build_command.extend(["-M", prop_dict["extfs_rsv_pct"]])
@@ -606,19 +606,20 @@
           size = common.RoundUpTo4K(size)
         else:
           size = ((size + block_size - 1) // block_size) * block_size
-      extfs_inode_count = prop_dict["extfs_inode_count"]
-      inodes = int(fs_dict.get("Inode count", extfs_inode_count))
-      inodes -= int(fs_dict.get("Free inodes", "0"))
-      # add .2% margin or 1 inode, whichever is greater
-      spare_inodes = inodes * 2 // 1000
-      min_spare_inodes = 1
-      if spare_inodes < min_spare_inodes:
-        spare_inodes = min_spare_inodes
-      inodes += spare_inodes
-      prop_dict["extfs_inode_count"] = str(inodes)
+      if int(prop_dict["extfs_inode_count"]) >= 0:
+        extfs_inode_count = prop_dict["extfs_inode_count"]
+        inodes = int(fs_dict.get("Inode count", extfs_inode_count))
+        inodes -= int(fs_dict.get("Free inodes", "0"))
+        # add .2% margin or 1 inode, whichever is greater
+        spare_inodes = inodes * 2 // 1000
+        min_spare_inodes = 1
+        if spare_inodes < min_spare_inodes:
+          spare_inodes = min_spare_inodes
+        inodes += spare_inodes
+        prop_dict["extfs_inode_count"] = str(inodes)
+        logger.info(
+            "Allocating %d Inodes for %s.", inodes, out_file)
       prop_dict["partition_size"] = str(size)
-      logger.info(
-          "Allocating %d Inodes for %s.", inodes, out_file)
     elif fs_type.startswith("f2fs") and prop_dict.get("f2fs_compress") == "true":
       prop_dict["partition_size"] = str(size)
       prop_dict["image_size"] = str(size)
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index f04dfb7..c5c1269 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -445,7 +445,7 @@
           "system_other"] = self._partition_fingerprints["system"]
 
     # These two should be computed only after setting self._oem_props.
-    self._device = self.GetOemProperty("ro.product.device")
+    self._device = info_dict.get("ota_override_device", self.GetOemProperty("ro.product.device"))
     self._fingerprint = self.CalculateFingerprint()
     check_fingerprint(self._fingerprint)
 
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 033c02e..f8247ee 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -137,11 +137,13 @@
 
   def AssertDevice(self, device):
     """Assert that the device identifier is the given string."""
-    cmd = ('getprop("ro.product.device") == "%s" || '
-           'abort("E%d: This package is for \\"%s\\" devices; '
-           'this is a \\"" + getprop("ro.product.device") + "\\".");') % (
-               device, common.ErrorCode.DEVICE_MISMATCH, device)
-    self.script.append(cmd)
+    cmd = ('assert(' +
+           ' || \0'.join(['getprop("ro.product.device") == "%s" || getprop("ro.build.product") == "%s"'
+                         % (i, i) for i in device.split(",")]) +
+           ' || abort("E%d: This package is for device: %s; ' +
+           'this device is " + getprop("ro.product.device") + ".");' +
+           ');') % (common.ErrorCode.DEVICE_MISMATCH, device)
+    self.script.append(self.WordWrap(cmd))
 
   def AssertSomeBootloader(self, *bootloaders):
     """Asert that the bootloader version is one of *bootloaders."""