diff --git a/MobileGL/ConfigLoader.cpp b/MobileGL/ConfigLoader.cpp index 8848e8f8..3368c5aa 100644 --- a/MobileGL/ConfigLoader.cpp +++ b/MobileGL/ConfigLoader.cpp @@ -142,6 +142,28 @@ namespace MobileGL::MG_ConfigLoader { if (IsServerProcess()) return; ReadBackendFile(FilePathSetting("MOBILEGL_BACKEND_FILE", kDefaultBackendFile), out); ReadConfigFile(FilePathSetting("MOBILEGL_CONFIG_FILE", kDefaultConfigFile), out, log); +#if defined(__ANDROID__) + // An app that hosts the library (FCL) owns its process environment, so a developer + // has no way to set a MOBILEGL_* knob in it. `adb shell setprop debug.mobilegl.env + // "MOBILEGL_A=1;MOBILEGL_B=0"` does it, below the environment like the Linux config + // file (PROP_VALUE_MAX bounds it to a few keys). + char property[PROP_VALUE_MAX] = {}; + if (__system_property_get("debug.mobilegl.env", property) > 0) { + String all(property); + SizeT start = 0; + while (start < all.size()) { + SizeT end = all.find(';', start); + if (end == String::npos) end = all.size(); + const String item = all.substr(start, end - start); + const SizeT eq = item.find('='); + if (eq != String::npos && eq > 0) { + out.emplace(item.substr(0, eq), item.substr(eq + 1)); + if (log) MGLOG_I("Config: debug.mobilegl.env sets %s", item.c_str()); + } + start = end + 1; + } + } +#endif } } // namespace diff --git a/tools/device_bench/disagg/devstate.sh b/tools/device_bench/disagg/devstate.sh index 7e678048..103bb15b 100644 --- a/tools/device_bench/disagg/devstate.sh +++ b/tools/device_bench/disagg/devstate.sh @@ -17,5 +17,5 @@ anland=$(adb -s "$SER" shell pidof com.anland.consumer.mobilegl | tr -dc '0-9' | p=$(cat "$out/profile.txt") pn=$(echo "$p" | sed -n 's/.*profile=\([^ ]*\).*/\1/p'); pc=$(echo "$p" | sed -n 's/.*cpu=\([0-9]*\).*/\1/p'); pl=$(echo "$p" | sed -n 's/.*little=\([0-9]*\).*/\1/p'); pg=$(echo "$p" | sed -n 's/.*gpu=\([0-9]*\).*/\1/p') [ "$kind" = trace ] && { ver=-; swap=pbuffer; } -line="STATE profile=${pn:-unpinned}(${pc:+$((pc/1000))/$((pl/1000))/$((pg/1000000))MHz}) $(head -1 "$out/valid.txt") daemons=$daemons mc=$ver swap=${swap:-?} anland=$([ -n "$anland" ] && echo on || echo off)" +line="STATE profile=${pn:-unpinned}(${pc:+$((pc/1000))/$((pl/1000))/$((pg/1000000))MHz}) $(head -1 "$out/valid.txt") daemons=$daemons mc=$ver swap=${swap:-?} anland=$([ -n "$anland" ] && echo on || echo off) $(cat "$out/env.txt" 2>/dev/null)" echo "$line" > "$out/state.txt"; echo "$line"