From 0c9ee0f2b998f3fea3e4d7ef54a5e2ce5cf38002 Mon Sep 17 00:00:00 2001 From: Juston Li Date: Tue, 8 Oct 2024 16:35:12 -0700 Subject: [PATCH] android: look for debug/vendor prefixed options Properties from the vendor partition must use a "vendor." prefix from Android T+. Meanwhile the "debug." prefix can be used for local overrides. The order of precedence thus becomes: 1. getenv 2. debug.mesa.* 3. vendor.mesa.* 4. mesa.* (as a fallback for older versions) Signed-off-by: Juston Li Part-of: --- src/util/os_misc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/util/os_misc.c b/src/util/os_misc.c index f5293183c85..4b7916634b3 100644 --- a/src/util/os_misc.c +++ b/src/util/os_misc.c @@ -150,7 +150,10 @@ os_log_message(const char *message) * * 1) convert to lowercase * 2) replace '_' with '.' - * 3) if necessary, prepend "mesa." + * 3) replace "MESA_" or prepend with "mesa." + * 4) look for "debug.mesa." prefix + * 5) look for "vendor.mesa." prefix + * 6) look for "mesa." prefix * * For example: * - MESA_EXTENSION_OVERRIDE -> mesa.extension.override @@ -175,9 +178,16 @@ os_get_android_option(const char *name) } } - int len = property_get(key, os_android_option_value, NULL); - if (len > 1) { - return os_android_option_value; + /* prefixes to search sorted by preference */ + const char *prefices[] = { "debug.", "vendor.", "" }; + char full_key[PROPERTY_KEY_MAX]; + int len = 0; + for (int i = 0; i < ARRAY_SIZE(prefices); i++) { + strlcpy(full_key, prefices[i], PROPERTY_KEY_MAX); + strlcat(full_key, key, PROPERTY_KEY_MAX); + len = property_get(full_key, os_android_option_value, NULL); + if (len > 0) + return os_android_option_value; } return NULL; }