0
0
mirror of https://github.com/termux/termux-packages.git synced 2024-12-13 01:50:33 +00:00
termux-packages/packages/boinc/client-hostinfo_unix.cpp.patch

72 lines
2.3 KiB
Diff

--- a/client/hostinfo_unix.cpp
+++ b/client/hostinfo_unix.cpp
@@ -169,6 +169,16 @@
#include <OS.h>
#endif
+#ifdef __ANDROID__
+#include <sys/system_properties.h> // PROP_VALUE_MAX
+#endif
+
+#ifdef __TERMUX__
+#ifndef TERMUX_PKG_ANDROID_VERSION
+#define TERMUX_PKG_ANDROID_VERSION "7.0"
+#endif
+#endif
+
// Some OS define _SC_PAGE_SIZE instead of _SC_PAGESIZE
#if defined(_SC_PAGE_SIZE) && !defined(_SC_PAGESIZE)
#define _SC_PAGESIZE _SC_PAGE_SIZE
@@ -1505,7 +1515,12 @@
// return BOINC_SUCCESS if at least version could be found (extra_info may remain empty)
// return ERR_NOT_FOUND if ldd couldn't be opened or no version information was found
//
-#ifdef __GLIBC__
+#ifdef __ANDROID__
+int get_libc_version(string&, string&) {
+ // ldd should always not found on Android, less overhead
+ return ERR_NOT_FOUND;
+}
+#elif defined(__GLIBC__)
int get_libc_version(string& version, string&) {
version = string(gnu_get_libc_version());
return BOINC_SUCCESS;
@@ -1555,16 +1570,24 @@
#if HAVE_SYS_UTSNAME_H
struct utsname u;
uname(&u);
-#ifdef ANDROID
+#ifdef __ANDROID__
safe_strcpy(os_name, "Android");
-#else
+ // remove the need of query Android version through Java API
+ // which then process in client/gui_rpc_server_ops.cpp, handle_set_host_info()
+ char android_version[PROP_VALUE_MAX];
+ __system_property_get("ro.build.version.release", android_version);
+#ifdef __TERMUX__
+ if (strlen(android_version) == 0) { safe_strcpy(android_version, TERMUX_PKG_ANDROID_VERSION); }
+#endif
+ snprintf(os_version, sizeof(os_version), "%s (Android %s)", u.release, android_version);
+#elif defined(__EMX__) // OS2: version is in u.version
safe_strcpy(os_name, u.sysname);
-#endif //ANDROID
-#if defined(__EMX__) // OS2: version is in u.version
safe_strcpy(os_version, u.version);
#elif defined(__HAIKU__)
+ safe_strcpy(os_name, u.sysname);
snprintf(os_version, sizeof(os_version), "%s, %s", u.release, u.version);
#else
+ safe_strcpy(os_name, u.sysname);
safe_strcpy(os_version, u.release);
#endif
#ifdef _HPUX_SOURCE
@@ -1717,7 +1740,7 @@
return false;
}
} tty_patterns[] = {
-#if defined(LINUX_LIKE_SYSTEM) and !defined(ANDROID)
+#if defined(LINUX_LIKE_SYSTEM) and !defined(__ANDROID__)
{ "/dev", "tty",
{"ttyS", "ttyACM"},
},