From bbeb1efe6de97b2901f1302585ed565eec1a2fda Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Mon, 13 Oct 2025 12:50:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(lib):=20=E4=BC=98=E5=8C=96=20Android=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xy.h | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/xy.h b/lib/xy.h index 08dda249..6d642fc7 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -1284,23 +1284,13 @@ xy_detect_os () } } - FILE *fp = fopen ("/proc/version", "r"); - if (fp) - { - 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")) - { - xy.on_linux = true; - return; - } - } + char *android_env = getenv ("ANDROID_ROOT"); + if (android_env == "/system") + { + xy.on_linux = true; + xy.on_android = true; + return; + } /* 判断 macOS */ DIR *d = opendir ("/System/Applications"); From b5cf57bfb5424501de0f0bc9b6bf7e5082b94d2e Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Mon, 13 Oct 2025 13:08:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(lib):=20=E4=BF=AE=E5=A4=8D=20Android=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xy.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/xy.h b/lib/xy.h index 6d642fc7..54e82f97 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -1284,13 +1284,14 @@ xy_detect_os () } } - char *android_env = getenv ("ANDROID_ROOT"); - if (android_env == "/system") - { - xy.on_linux = true; - xy.on_android = true; - return; - } + // REF: 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_linux = true; + xy.on_android = true; + return; + } /* 判断 macOS */ DIR *d = opendir ("/System/Applications"); From c0a9b626fd2b461f95114745a17638f818996b9e Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Wed, 15 Oct 2025 15:04:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(lib):=20=E4=BF=AE=E5=A4=8D=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E7=B3=BB=E7=BB=9F=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91?= =?UTF-8?q?=201.=20=E5=9B=9E=E9=80=80linux=E6=A3=80=E6=B5=8B=202.=20?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=BC=BA=E5=B0=91=E7=9A=84return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xy.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/xy.h b/lib/xy.h index 54e82f97..a1991cff 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -1284,11 +1284,23 @@ xy_detect_os () } } - // REF: https://android.googlesource.com/platform/system/core/+/refs/heads/main/rootdir/init.environ.rc.in + FILE *fp = fopen ("/proc/version", "r"); + if (fp) + { + char buf[256] = {0}; + fread (buf, 1, sizeof(buf) - 1, fp); + fclose (fp); + 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_linux = true; xy.on_android = true; return; } @@ -1303,6 +1315,7 @@ xy_detect_os () { xy.on_macos = true; closedir (d); + return; } } @@ -1324,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))