From 2d61e47f88f303c67c30307ed20dfb7d16174e08 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 18 Jun 2018 20:18:37 +0000 Subject: [PATCH] Revert "Revert "Inject minSdkVersion from the build system"" This reverts commit 4cd1a75d171392bf942ad82533df65b9b1485025. PackageParser no longer treats minSdkVersion=Q as targetSdkVersion=Q when targetSdkVersion is set to a number. Bug: 110167203 Bug: 110353795 Change-Id: Ib44743e4c49e59cd29a57af1bf885090e380b1b6 --- core/android_manifest.mk | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/core/android_manifest.mk b/core/android_manifest.mk index 08f3f383a..e52bb2c54 100644 --- a/core/android_manifest.mk +++ b/core/android_manifest.mk @@ -6,9 +6,9 @@ ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) LOCAL_MANIFEST_FILE := AndroidManifest.xml endif ifdef LOCAL_FULL_MANIFEST_FILE - full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE) + main_android_manifest := $(LOCAL_FULL_MANIFEST_FILE) else - full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) + main_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) endif LOCAL_STATIC_JAVA_AAR_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)) @@ -32,18 +32,35 @@ ifdef LOCAL_STATIC_JAVA_AAR_LIBRARIES endif endif +full_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml + +ifdef LOCAL_MIN_SDK_VERSION + $(full_android_manifest): PRIVATE_MIN_SDK_VERSION := $(LOCAL_MIN_SDK_VERSION) +else ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION))) + $(full_android_manifest): PRIVATE_MIN_SDK_VERSION := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) +else + $(full_android_manifest): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK) +endif + # Set up rules to merge library manifest files ifneq (,$(strip $(my_full_libs_manifest_files))) -main_android_manifest := $(full_android_manifest) -full_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml $(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(my_full_libs_manifest_files) $(full_android_manifest): $(ANDROID_MANIFEST_MERGER_CLASSPATH) +$(full_android_manifest): $(MANIFEST_FIXER) $(full_android_manifest) : $(main_android_manifest) $(my_full_libs_manifest_files) @echo "Merge android manifest files: $@ <-- $< $(PRIVATE_LIBS_MANIFESTS)" @mkdir -p $(dir $@) - $(hide) $(ANDROID_MANIFEST_MERGER) --main $< \ + $(MANIFEST_FIXER) $< $@.tmp --minSdkVersion $(PRIVATE_MIN_SDK_VERSION) + $(hide) $(ANDROID_MANIFEST_MERGER) --main $@.tmp \ --libs $(call normalize-path-list,$(PRIVATE_LIBS_MANIFESTS)) \ --out $@ + rm $@.tmp + +else +$(full_android_manifest): $(MANIFEST_FIXER) +$(full_android_manifest): $(main_android_manifest) + @echo "Fix manifest: $@" + $(MANIFEST_FIXER) $< $@ --minSdkVersion $(PRIVATE_MIN_SDK_VERSION) endif