Use different versions for framework compatibility matrix
Keyed on MATRIX_LEVEL_OVERRIDE, FULL_TREBLE, SHIPPING_API_LEVEL,
and SDK_VERSION.
Bug: 62136051
Test: m system_compatibility_matrix.xml -j; \
grep -e"gatekeeper" -B1 $OUT/system/compatibility_matrix.xml; \
grep -e"oemlock" -B1 $OUT/system/compatibility_matrix.xml
bullhead: gatekeeper is optional, no oemlock (legacy.xml)
marlin without COMP_LEVEL_OVERRIDE: gatekeeper is not optional,
no oemlock (26.xml)
marlin with COMP_LEVEL_OVERRIDE: gatekeeper is not optional,
oemlock exists (current.xml)
new devices with COMP_LEVEL_OVERRIDE: same as above.
Change-Id: Icf7269df91950a8c3585a7e5f0022e6737954b77
diff --git a/core/config.mk b/core/config.mk
index 8cfda5f..62f1337 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -738,7 +738,38 @@
endif
FRAMEWORK_MANIFEST_FILE := system/libhidl/manifest.xml
-FRAMEWORK_COMPATIBILITY_MATRIX_FILE := hardware/interfaces/compatibility_matrix.xml
+
+# Compatibility matrix versioning:
+# MATRIX_LEVEL_OVERRIDE defined: MATRIX_LEVEL = MATRIX_LEVEL_OVERRIDE
+# MATRIX_LEVEL_OVERRIDE undefined:
+# FULL_TREBLE != true: MATRIX_LEVEL = legacy
+# FULL_TREBLE == true:
+# SHIPPING_API_LEVEL defined: MATRIX_LEVEL = SHIPPING_API_LEVEL
+# SHIPPING_API_LEVEL undefined: MATRIX_LEVEL = PLATFORM_SDK_VERSION
+# MATRIX_LEVEL == legacy => legacy.xml
+# MATRIX_LEVEL <= 26 => 26.xml
+# MATRIX_LEVEL == 27 => 27.xml # define when 27 releases
+# MATRIX_LEVEL == 28 => 28.xml # define when 28 releases
+# ...
+# otherwise => current.xml
+
+ifneq ($(PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE),)
+ PRODUCT_COMPATIBILITY_MATRIX_LEVEL := $(PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE)
+else ifneq ($(PRODUCT_FULL_TREBLE),true)
+ PRODUCT_COMPATIBILITY_MATRIX_LEVEL := legacy
+else ifneq ($(PRODUCT_SHIPPING_API_LEVEL),)
+ PRODUCT_COMPATIBILITY_MATRIX_LEVEL := $(PRODUCT_SHIPPING_API_LEVEL)
+else
+ PRODUCT_COMPATIBILITY_MATRIX_LEVEL := $(PLATFORM_SDK_VERSION)
+endif
+
+ifeq ($(strip $(PRODUCT_COMPATIBILITY_MATRIX_LEVEL)),legacy)
+ FRAMEWORK_COMPATIBILITY_MATRIX_FILE := hardware/interfaces/compatibility_matrix.legacy.xml
+else ifeq ($(call math_gt_or_eq,$(PRODUCT_COMPATIBILITY_MATRIX_LEVEL),27),)
+ FRAMEWORK_COMPATIBILITY_MATRIX_FILE := hardware/interfaces/compatibility_matrix.26.xml
+else
+ FRAMEWORK_COMPATIBILITY_MATRIX_FILE := hardware/interfaces/compatibility_matrix.current.xml
+endif
# ###############################################################
# Set up final options.