From 27f601f5d96bb6b94233169ae8a29ea4290e6904 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Thu, 23 May 2024 00:00:08 +0000 Subject: [PATCH] Consider non-shipping lunch targets to be future. Many places in the codebase have checks like this: if shipping level > X: do cool thing Y This is great because it reduces the cost to upgrade and test old Android devices or refactor their code. However, many targets, such as the NDK, the SDK, mainline modules, and so on do not set a shipping level, so they don't get to do the cool thing Y. In order to resolve this, we could modify every check to check the default case. However, this is an invasive change, and it is not maintainable. Instead, consider non-shipping products to always be in the future. In general, Android features are required to be backwards compatible, so this should always work for things like mainline. Also note, this means when someone adds a new feature Y like this, they'll clearly see the impact of it being added everywhere, rather than on such a small selection of newly shipping devices. This avoids a risk where a change needs to be run on mainline modules (or other targets) but is not tested in this configuration from the start. Future work: many `ifndef` checks can be cleaned up after this, or if this approach makes sense, they can be cleaned up in this CL. Bug: 339026799 Bug: 279808973 Bug: 333908433 Test: builds of: - errorprone-trunk_staging - mainline_modules_sdks-trunk_staging-userdebug - mainline_modules_x86_64-trunk_staging-userdebug - ndk - sdk-trunk_staging-userdebug Test: too large number gives: build/make/core/product_config.mk:598: error: integer greater than 10001 is not supported!. Change-Id: I17c34267f774ea8b9265e1d798a67af7838715c5 --- common/math.mk | 5 +++-- core/product_config.mk | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/common/math.mk b/common/math.mk index ecee474d14..829ceb5e6f 100644 --- a/common/math.mk +++ b/common/math.mk @@ -315,8 +315,9 @@ $(call math-expect,(call numbers_greater_or_equal_to,1,0 2 1 3),2 1 3) $(call math-expect,(call numbers_greater_or_equal_to,0,0 2 1 3),0 2 1 3) $(call math-expect,(call numbers_greater_or_equal_to,1,0 2 1 3 2),2 1 3 2) -_INT_LIMIT_WORDS := $(foreach a,x x,$(foreach b,x x x x x x x x x x x x x x x x,\ - $(foreach c,x x x x x x x x x x x x x x x x,x x x x x x x x x x x x x x x x))) +# 10,001 = 10 ** 4 + 1, contains 10,001 x's, so 1 more than 10,000 (future) API level +_INT_LIMIT_WORDS := x $(foreach a,0 1 2 3 4 5 6 7 8 9,$(foreach b,0 1 2 3 4 5 6 7 8 9,\ + $(foreach c,0 1 2 3 4 5 6 7 8 9,x x x x x x x x x x))) define _int_encode $(if $(filter $(words x $(_INT_LIMIT_WORDS)),$(words $(wordlist 1,$(1),x $(_INT_LIMIT_WORDS)))),\ diff --git a/core/product_config.mk b/core/product_config.mk index f21c1c4188..c73a56e42e 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -426,6 +426,10 @@ else TARGET_AAPT_CHARACTERISTICS := $(PRODUCT_CHARACTERISTICS) endif +ifndef PRODUCT_SHIPPING_API_LEVEL + PRODUCT_SHIPPING_API_LEVEL := 10000 +endif + ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE ifneq (1,$(words $(PRODUCT_DEFAULT_DEV_CERTIFICATE))) $(error PRODUCT_DEFAULT_DEV_CERTIFICATE='$(PRODUCT_DEFAULT_DEV_CERTIFICATE)', \