diff --git a/lib/xy.h b/lib/xy.h index 08dda24..a1991cf 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -1290,18 +1290,21 @@ xy_detect_os () char buf[256] = {0}; fread (buf, 1, sizeof(buf) - 1, fp); fclose (fp); - if (strstr (buf, "Android")) - { - xy.on_android = true; - return; - } - else if (strstr (buf, "Linux")) + if (strstr (buf, "Linux")) { xy.on_linux = true; return; } } + // @consult https://android.googlesource.com/platform/system/core/+/refs/heads/main/rootdir/init.environ.rc.in + char *android_env = getenv ("ANDROID_ROOT"); + if (xy_str_find (android_env, "/system").found) + { + xy.on_android = true; + return; + } + /* 判断 macOS */ DIR *d = opendir ("/System/Applications"); if (d) @@ -1312,6 +1315,7 @@ xy_detect_os () { xy.on_macos = true; closedir (d); + return; } } @@ -1333,6 +1337,7 @@ xy_detect_os () pclose (fp); if (strstr (buf, "BSD") != NULL) xy.on_bsd = true; + return; } if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd))