修复Android系统检测 (#313)

This commit is contained in:
Mikachu2333
2025-10-15 16:51:04 +08:00
committed by GitHub
parent 730d18a8a9
commit 6af3e51566

View File

@@ -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))