Add PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES

It is a list of <module_name>:<manifest_name> pairs. When the module
name of an APK or an APEX matches with <module_name>, then its app
manifest name is overridden to <manifest_name>.

<module_name> and <manifest_name> can be patterns as in
com.android.%:com.mycompany.android.%.release

Test: m with PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES for
1) an APK in Android.mk
2) an APK in ANdroid.bp
3) an APEX
and check that manifest names are modified as specified

Change-Id: Ic09e059ea7b7ea99a50a1cf423a25aa587ef4466
This commit is contained in:
Jiyong Park 2019-01-05 12:57:54 +09:00
parent fe9f373e10
commit 185d41e84d
4 changed files with 32 additions and 0 deletions

View File

@ -87,6 +87,23 @@ else
LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d)))
endif
# If LOCAL_MODULE matches a rule in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES,
# override the manfest package name by the (first) rule matched
override_manifest_name := $(strip $(word 1,\
$(foreach rule,$(PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES),\
$(eval _pkg_name_pat := $(call word-colon,1,$(rule)))\
$(eval _manifest_name_pat := $(call word-colon,2,$(rule)))\
$(if $(filter $(_pkg_name_pat),$(LOCAL_MODULE)),\
$(patsubst $(_pkg_name_pat),$(_manifest_name_pat),$(LOCAL_MODULE))\
)\
)\
))
ifneq (,$(override_manifest_name))
# Note: this can override LOCAL_MANFEST_PACKAGE_NAME value set in Android.mk
LOCAL_MANIFEST_PACKAGE_NAME := $(override_manifest_name)
endif
include $(BUILD_SYSTEM)/force_aapt2.mk
# Process Support Library dependencies.

View File

@ -213,6 +213,7 @@ _product_var_list := \
PRODUCT_RETROFIT_DYNAMIC_PARTITIONS \
PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
PRODUCT_XOM_EXCLUDE_PATHS \
PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES \
define dump-product
$(info ==== $(1) ====)\

View File

@ -346,6 +346,11 @@ PRODUCT_SHIPPING_API_LEVEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SHI
# used for adding properties to default.prop
PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \
$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
$(foreach rule,$(PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES),\
$(if $(filter 2,$(words $(subst :,$(space),$(rule)))),,\
$(error Rule "$(rule)" in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDE is not <module_name>:<manifest_name>)))
.KATI_READONLY := PRODUCT_DEFAULT_PROPERTY_OVERRIDES
# A list of property assignments, like "key = value", with zero or more
@ -549,3 +554,10 @@ PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION := \
# set this variable to prevent OTA failures.
PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := \
$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS))
# List of <module_name>:<manifest_name> pairs to override the manifest package name
# of a module <module_name> to <manifest_name>. Patterns can be used as in
# com.android.%:com.acme.android.%.release
PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES := \
$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES))
.KATI_READONLY := PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES

View File

@ -144,6 +144,8 @@ $(call add_json_bool, FlattenApex, $(filter true,$(TARGET_
$(call add_json_str, DexpreoptGlobalConfig, $(DEX_PREOPT_CONFIG))
$(call add_json_list, ManifestPackageNameOverrides, $(PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES))
$(call add_json_map, VendorVars)
$(foreach namespace,$(SOONG_CONFIG_NAMESPACES),\
$(call add_json_map, $(namespace))\