Split vendor's system prop overrides into vendor partition
If ENABLE_TREBLE and early mount of vendor partition are enabled,
overrides in PRODUCT_DEFAULT_PROPERTY_OVERRIDES will be stored in
vendor/default.prop.
If ENABLE_TREBLE and vendor partition are enabled, overrides in
PRODUCT_PROPERTY_OVERRIDES will be stored in vendor/build.prop.
default.prop of recovery image will include all the contents of
vendor/default.prop and vendor/build.prop additionally.
ENABLE_EARLY_MOUNT is added to specify whether early mount is enabled
or not, but it should be removed later when early mount becomes
default for all ENABLE_TREBLE products.
Test: building succeeded, and verified on bullhead.
Bug: 34116668
Change-Id: Ic2eb8882ae71921a76c02b3d62d3289c45949295
diff --git a/core/Makefile b/core/Makefile
index 1cbb6bc..741fe77 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -71,13 +71,33 @@
endif
# -----------------------------------------------------------------
+# vendor_default_property_overrides_split_enabled and
+# vendor_build_property_overrides_split_enabled
+vendor_default_property_overrides_split_enabled :=
+vendor_build_property_overrides_split_enabled :=
+ifeq ($(ENABLE_TREBLE), true)
+ ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+ vendor_build_property_overrides_split_enabled := true
+
+ # Checks whether early mount for vendor partition is enabled or not.
+ # TODO(jaekyun): Early mount will be mandatory for ENABLE_TREBLE=true. After
+ # that is done, this condition check should be removed.
+ ifeq ($(ENABLE_EARLY_MOUNT), true)
+ vendor_default_property_overrides_split_enabled := true
+ endif
+ endif
+endif
+
+# -----------------------------------------------------------------
# default.prop
INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
FINAL_DEFAULT_PROPERTIES := \
$(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
-FINAL_DEFAULT_PROPERTIES += \
- $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+ifndef vendor_default_property_overrides_split_enabled
+ FINAL_DEFAULT_PROPERTIES += \
+ $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+endif
FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
$(FINAL_DEFAULT_PROPERTIES),=)
@@ -100,6 +120,30 @@
$(hide) build/tools/post_process_props.py $@
# -----------------------------------------------------------------
+# vendor default.prop
+INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
+ifdef vendor_default_property_overrides_split_enabled
+INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
+ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
+
+FINAL_VENDOR_DEFAULT_PROPERTIES += \
+ $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
+
+$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
+ @echo Target buildinfo: $@
+ @mkdir -p $(dir $@)
+ $(hide) echo "#" > $@; \
+ echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
+ echo "#" >> $@;
+ $(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
+ echo "$(line)" >> $@;)
+ $(hide) build/tools/post_process_props.py $@
+
+endif # vendor_default_property_overrides_split_enabled
+
+# -----------------------------------------------------------------
# build.prop
INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
@@ -288,14 +332,30 @@
ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
-$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
+
+ifdef vendor_build_property_overrides_split_enabled
+FINAL_VENDOR_BUILD_PROPERTIES += \
+ $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
+FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(FINAL_VENDOR_BUILD_PROPERTIES),=)
+endif # vendor_build_property_overrides_split_enabled
+
+$(INSTALLED_VENDOR_BUILD_PROP_TARGET):
@echo Target vendor buildinfo: $@
@mkdir -p $(dir $@)
$(hide) echo > $@
$(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@
$(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
$(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
-endif
+ifdef vendor_build_property_overrides_split_enabled
+ $(hide) echo "#" >> $@; \
+ echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
+ echo "#" >> $@;
+ $(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
+ echo "$(line)" >> $@;)
+ $(hide) build/tools/post_process_props.py $@
+endif # vendor_build_property_overrides_split_enabled
+endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
# ----------------------------------------------------------------
@@ -905,7 +965,10 @@
recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery
recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
-recovery_build_prop := $(intermediate_system_build_prop)
+recovery_build_props := $(intermediate_system_build_prop)
+ifdef vendor_build_property_overrides_split_enabled
+recovery_build_props += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
+endif
recovery_resources_common := $(call include-path-for, recovery)/res
# Set recovery_density to the density bucket of the device.
@@ -1037,8 +1100,13 @@
$(if $(strip $(recovery_wipe)), \
$(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe)
$(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
- $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
+ $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) \
> $(TARGET_RECOVERY_ROOT_OUT)/default.prop
+ $(if $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET), \
+ $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
+ >> $(TARGET_RECOVERY_ROOT_OUT)/default.prop)
+ $(hide) cat $(recovery_build_props) \
+ >> $(TARGET_RECOVERY_ROOT_OUT)/default.prop
$(BOARD_RECOVERY_IMAGE_PREPARE)
$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \
$(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \
@@ -1080,9 +1148,10 @@
$(INTERNAL_RECOVERYIMAGE_FILES) \
$(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
$(INSTALLED_2NDBOOTLOADER_TARGET) \
- $(recovery_build_prop) $(recovery_resource_deps) \
+ $(recovery_build_props) $(recovery_resource_deps) \
$(recovery_fstab) \
- $(RECOVERY_INSTALL_OTA_KEYS)
+ $(RECOVERY_INSTALL_OTA_KEYS) \
+ $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
$(call pretty,"Target boot image from recovery: $@")
$(call build-recoveryimage-target, $@)
endif
@@ -1093,9 +1162,10 @@
$(INTERNAL_RECOVERYIMAGE_FILES) \
$(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
$(INSTALLED_2NDBOOTLOADER_TARGET) \
- $(recovery_build_prop) $(recovery_resource_deps) \
+ $(recovery_build_props) $(recovery_resource_deps) \
$(recovery_fstab) \
- $(RECOVERY_INSTALL_OTA_KEYS)
+ $(RECOVERY_INSTALL_OTA_KEYS) \
+ $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
$(call build-recoveryimage-target, $@)
ifdef RECOVERY_RESOURCE_ZIP
diff --git a/core/main.mk b/core/main.mk
index 017b818..459e5e7 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -251,9 +251,15 @@
ADDITIONAL_BUILD_PROPERTIES += \
ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
endif
-ADDITIONAL_BUILD_PROPERTIES := \
- $(ADDITIONAL_BUILD_PROPERTIES) \
- $(PRODUCT_PROPERTY_OVERRIDES)
+
+ifneq ($(ENABLE_TREBLE), true)
+ ADDITIONAL_BUILD_PROPERTIES += $(PRODUCT_PROPERTY_OVERRIDES)
+else
+ ifndef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+ ADDITIONAL_BUILD_PROPERTIES += $(PRODUCT_PROPERTY_OVERRIDES)
+ endif
+endif
+
# Bring in standard build system definitions.
include $(BUILD_SYSTEM)/definitions.mk
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index 9dcaadf..80fb85d 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -30,6 +30,12 @@
def mangle_build_prop(prop):
pass
+# Put the modifications that you need to make into /vendor/default.prop and
+# /odm/default.prop into this function. The prop object has get(name) and
+# put(name,value) methods.
+def mangle_default_prop_override(prop):
+ pass
+
# Put the modifications that you need to make into the /default.prop into this
# function. The prop object has get(name) and put(name,value) methods.
def mangle_default_prop(prop):
@@ -119,6 +125,9 @@
if filename.endswith("/build.prop"):
mangle_build_prop(properties)
+ elif (filename.endswith("/vendor/default.prop") or
+ filename.endswith("/odm/default.prop")):
+ mangle_default_prop_override(properties)
elif filename.endswith("/default.prop"):
mangle_default_prop(properties)
else: