2014-02-06 10:24:45 +08:00
|
|
|
# Handle AndroidManifest.xmls
|
2019-02-07 08:36:32 +08:00
|
|
|
# Input: LOCAL_MANIFEST_FILE, LOCAL_FULL_MANIFEST_FILE, LOCAL_FULL_LIBS_MANIFEST_FILES,
|
|
|
|
# LOCAL_USE_EMBEDDED_NATIVE_LIBS
|
2014-02-06 10:24:45 +08:00
|
|
|
# Output: full_android_manifest
|
|
|
|
|
|
|
|
ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
|
|
|
|
LOCAL_MANIFEST_FILE := AndroidManifest.xml
|
|
|
|
endif
|
|
|
|
ifdef LOCAL_FULL_MANIFEST_FILE
|
2018-06-19 04:18:37 +08:00
|
|
|
main_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
|
2014-02-06 10:24:45 +08:00
|
|
|
else
|
2018-06-19 04:18:37 +08:00
|
|
|
main_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
|
2014-02-06 10:24:45 +08:00
|
|
|
endif
|
|
|
|
|
2015-05-28 06:14:28 +08:00
|
|
|
LOCAL_STATIC_JAVA_AAR_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_AAR_LIBRARIES))
|
2018-06-13 04:43:10 +08:00
|
|
|
|
|
|
|
my_full_libs_manifest_files :=
|
|
|
|
|
|
|
|
ifndef LOCAL_DONT_MERGE_MANIFESTS
|
|
|
|
my_full_libs_manifest_files += $(LOCAL_FULL_LIBS_MANIFEST_FILES)
|
|
|
|
|
2018-06-08 07:44:07 +08:00
|
|
|
my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES) $(LOCAL_STATIC_ANDROID_LIBRARIES),\
|
|
|
|
$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/manifest/AndroidManifest.xml)
|
2018-06-13 04:43:10 +08:00
|
|
|
endif
|
|
|
|
|
2018-06-19 04:18:37 +08:00
|
|
|
full_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
|
|
|
|
|
2018-06-14 03:34:51 +08:00
|
|
|
ifneq (,$(strip $(my_full_libs_manifest_files)))
|
2018-07-26 01:12:48 +08:00
|
|
|
# Set up rules to merge library manifest files
|
|
|
|
fixed_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml.fixed
|
2018-06-14 03:34:51 +08:00
|
|
|
|
2018-07-26 01:12:48 +08:00
|
|
|
$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(my_full_libs_manifest_files)
|
2019-02-27 14:12:30 +08:00
|
|
|
$(full_android_manifest): $(ANDROID_MANIFEST_MERGER)
|
2018-07-26 01:12:48 +08:00
|
|
|
$(full_android_manifest) : $(fixed_android_manifest) $(my_full_libs_manifest_files)
|
2014-10-30 06:48:32 +08:00
|
|
|
@echo "Merge android manifest files: $@ <-- $< $(PRIVATE_LIBS_MANIFESTS)"
|
2014-02-06 10:24:45 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2018-07-26 01:12:48 +08:00
|
|
|
$(hide) $(ANDROID_MANIFEST_MERGER) --main $< \
|
2017-09-09 04:29:54 +08:00
|
|
|
--libs $(call normalize-path-list,$(PRIVATE_LIBS_MANIFESTS)) \
|
2014-02-06 10:24:45 +08:00
|
|
|
--out $@
|
2018-06-19 04:18:37 +08:00
|
|
|
else
|
2018-07-26 01:12:48 +08:00
|
|
|
fixed_android_manifest := $(full_android_manifest)
|
2014-02-06 10:24:45 +08:00
|
|
|
endif
|
2018-07-26 01:12:48 +08:00
|
|
|
|
2019-04-19 05:46:48 +08:00
|
|
|
my_target_sdk_version := $(call module-target-sdk-version)
|
|
|
|
|
|
|
|
ifdef TARGET_BUILD_APPS
|
|
|
|
ifndef TARGET_BUILD_APPS_USE_PREBUILT_SDK
|
|
|
|
ifeq ($(my_target_sdk_version),$(PLATFORM_VERSION_CODENAME))
|
|
|
|
ifdef UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT
|
|
|
|
my_target_sdk_version := $(my_target_sdk_version).$$(cat $(API_FINGERPRINT))
|
|
|
|
$(fixed_android_manifest): $(API_FINGERPRINT)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2019-02-07 07:40:03 +08:00
|
|
|
$(fixed_android_manifest): PRIVATE_MIN_SDK_VERSION := $(call module-min-sdk-version)
|
2019-04-19 05:46:48 +08:00
|
|
|
$(fixed_android_manifest): PRIVATE_TARGET_SDK_VERSION := $(my_target_sdk_version)
|
2018-09-11 04:37:10 +08:00
|
|
|
|
2018-07-26 01:12:48 +08:00
|
|
|
my_exported_sdk_libs_file := $(call local-intermediates-dir,COMMON)/exported-sdk-libs
|
|
|
|
$(fixed_android_manifest): PRIVATE_EXPORTED_SDK_LIBS_FILE := $(my_exported_sdk_libs_file)
|
|
|
|
$(fixed_android_manifest): $(my_exported_sdk_libs_file)
|
|
|
|
|
2018-08-28 19:28:38 +08:00
|
|
|
my_manifest_fixer_flags :=
|
2018-07-26 07:11:31 +08:00
|
|
|
ifneq ($(LOCAL_MODULE_CLASS),APPS)
|
2018-08-28 19:28:38 +08:00
|
|
|
my_manifest_fixer_flags += --library
|
2018-07-26 07:11:31 +08:00
|
|
|
endif
|
2018-08-28 19:28:38 +08:00
|
|
|
ifeq ($(LOCAL_PRIVATE_PLATFORM_APIS),true)
|
|
|
|
my_manifest_fixer_flags += --uses-non-sdk-api
|
|
|
|
endif
|
2018-10-23 02:25:05 +08:00
|
|
|
|
2019-01-30 05:03:22 +08:00
|
|
|
ifeq (true,$(LOCAL_USE_EMBEDDED_DEX))
|
|
|
|
my_manifest_fixer_flags += --use-embedded-dex
|
2018-10-23 02:25:05 +08:00
|
|
|
endif
|
|
|
|
|
2019-02-07 08:36:32 +08:00
|
|
|
ifeq ($(LOCAL_MODULE_CLASS),APPS)
|
|
|
|
ifeq (true,$(call math_gt_or_eq,$(patsubst $(PLATFORM_VERSION_CODENAME),100,$(call module-min-sdk-version)),23))
|
|
|
|
ifeq (true,$(LOCAL_USE_EMBEDDED_NATIVE_LIBS))
|
|
|
|
my_manifest_fixer_flags += --extract-native-libs=false
|
|
|
|
else
|
|
|
|
my_manifest_fixer_flags += --extract-native-libs=true
|
|
|
|
endif
|
|
|
|
else ifeq (true,$(LOCAL_USE_EMBEDDED_NATIVE_LIBS))
|
|
|
|
$(call pretty-error,LOCAL_USE_EMBEDDED_NATIVE_LIBS is set but minSdkVersion $(call module-min-sdk-version) does not support it)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-08-28 19:28:38 +08:00
|
|
|
$(fixed_android_manifest): PRIVATE_MANIFEST_FIXER_FLAGS := $(my_manifest_fixer_flags)
|
2018-10-16 09:59:55 +08:00
|
|
|
# These two libs are added as optional dependencies (<uses-library> with
|
|
|
|
# android:required set to false). This is because they haven't existed in pre-P
|
|
|
|
# devices, but classes in them were in bootclasspath jars, etc. So making them
|
|
|
|
# hard dependencies (andriod:required=true) would prevent apps from being
|
|
|
|
# installed to such legacy devices.
|
|
|
|
$(fixed_android_manifest): PRIVATE_OPTIONAL_SDK_LIB_NAMES := android.test.base android.test.mock
|
2018-07-26 01:12:48 +08:00
|
|
|
$(fixed_android_manifest): $(MANIFEST_FIXER)
|
|
|
|
$(fixed_android_manifest): $(main_android_manifest)
|
2018-10-16 09:59:55 +08:00
|
|
|
echo $(PRIVATE_OPTIONAL_SDK_LIB_NAMES) | tr ' ' '\n' > $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional
|
2018-07-26 01:12:48 +08:00
|
|
|
@echo "Fix manifest: $@"
|
|
|
|
$(MANIFEST_FIXER) \
|
|
|
|
--minSdkVersion $(PRIVATE_MIN_SDK_VERSION) \
|
2018-09-11 04:37:10 +08:00
|
|
|
--targetSdkVersion $(PRIVATE_TARGET_SDK_VERSION) \
|
|
|
|
--raise-min-sdk-version \
|
2018-07-26 07:11:31 +08:00
|
|
|
$(PRIVATE_MANIFEST_FIXER_FLAGS) \
|
2018-07-26 01:12:48 +08:00
|
|
|
$(if (PRIVATE_EXPORTED_SDK_LIBS_FILE),\
|
2018-10-16 09:59:55 +08:00
|
|
|
$$(cat $(PRIVATE_EXPORTED_SDK_LIBS_FILE) | grep -v -f $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional | sort -u | sed -e 's/^/\ --uses-library\ /' | tr '\n' ' ') \
|
|
|
|
$$(cat $(PRIVATE_EXPORTED_SDK_LIBS_FILE) | grep -f $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional | sort -u | sed -e 's/^/\ --optional-uses-library\ /' | tr '\n' ' ') \
|
|
|
|
) \
|
2018-07-26 01:12:48 +08:00
|
|
|
$< $@
|
2018-10-16 09:59:55 +08:00
|
|
|
rm $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional
|