From 6af3e51566b9997559f67f5f594f0a4903162dc5 Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Wed, 15 Oct 2025 16:51:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAndroid=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=20(#313)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xy.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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))