From 4a602955d09c65fd0f8dece48c30e7c2551e9609 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 16 Oct 2018 10:59:55 +0900 Subject: [PATCH] android.test.{base|mock} are added as optional libraries. The two java shared libraries do not exist in the pre-P devices. Therefore, marking the dependencies to the libraries as optional so that an app is still installable to the old devices. This is safe because the classes in the java shared libs exist in other shared libraries (bootclasspath or android.test.runner). Bug: 113800422 Test: run aapt dump badging on the built GtsBackupHostTestCases uses-library tags for android.test.base|mock are with android:required=false, while the same tag for other libs are without the attribute. Change-Id: Ieb7c1429077aaf6899e214a217d9455d95dbfea6 --- core/android_manifest.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/android_manifest.mk b/core/android_manifest.mk index 8e8bfecef..8608ca1df 100644 --- a/core/android_manifest.mk +++ b/core/android_manifest.mk @@ -72,8 +72,15 @@ ifeq ($(LOCAL_PRIVATE_PLATFORM_APIS),true) my_manifest_fixer_flags += --uses-non-sdk-api endif $(fixed_android_manifest): PRIVATE_MANIFEST_FIXER_FLAGS := $(my_manifest_fixer_flags) +# These two libs are added as optional dependencies ( 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 $(fixed_android_manifest): $(MANIFEST_FIXER) $(fixed_android_manifest): $(main_android_manifest) + echo $(PRIVATE_OPTIONAL_SDK_LIB_NAMES) | tr ' ' '\n' > $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional @echo "Fix manifest: $@" $(MANIFEST_FIXER) \ --minSdkVersion $(PRIVATE_MIN_SDK_VERSION) \ @@ -81,5 +88,8 @@ $(fixed_android_manifest): $(main_android_manifest) --raise-min-sdk-version \ $(PRIVATE_MANIFEST_FIXER_FLAGS) \ $(if (PRIVATE_EXPORTED_SDK_LIBS_FILE),\ - $$(cat $(PRIVATE_EXPORTED_SDK_LIBS_FILE) | sort -u | sed -e 's/^/\ --uses-library\ /' | tr '\n' ' ')) \ + $$(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' ' ') \ + ) \ $< $@ + rm $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional