mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Add Android basic support
This commit is contained in:
@@ -391,3 +391,11 @@ uint32_t ffSettingsGetSQLiteColumnCount(FFinstance* instance, const char* fileNa
|
||||
return 0;
|
||||
}
|
||||
#endif //FF_HAVE_SQLITE3
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <sys/system_properties.h>
|
||||
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
|
||||
ffStrbufEnsureCapacity(result, PROP_VALUE_MAX);
|
||||
result->length = __system_property_get(propName, result->chars);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -340,6 +340,10 @@ FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, con
|
||||
|
||||
uint32_t ffSettingsGetSQLiteColumnCount(FFinstance* instance, const char* fileName, const char* tableName);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
|
||||
#endif
|
||||
|
||||
//common/detectPlasma.c
|
||||
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance);
|
||||
|
||||
|
||||
+9
-6
@@ -63,14 +63,17 @@ void ffPrintCPU(FFinstance* instance)
|
||||
|
||||
while(getline(&line, &len, cpuinfo) != -1)
|
||||
{
|
||||
ffGetPropValue(line, "model name :", &name);
|
||||
ffGetPropValue(line, "vendor_id :", &vendor);
|
||||
ffGetPropValue(line, "cpu cores :", &physicalCoresString);
|
||||
ffGetPropValue(line, "cpu MHz :", &procGhzString);
|
||||
|
||||
//Stop after the first CPU
|
||||
if(strstr(line, "flags") != NULL)
|
||||
if(name.length > 0 && (*line == '\0' || *line == '\n'))
|
||||
break;
|
||||
|
||||
(void)(
|
||||
ffGetPropValue(line, "model name :", &name) ||
|
||||
ffGetPropValue(line, "vendor_id :", &vendor) ||
|
||||
ffGetPropValue(line, "cpu cores :", &physicalCoresString) ||
|
||||
ffGetPropValue(line, "cpu MHz :", &procGhzString) ||
|
||||
(name.length == 0 && ffGetPropValue(line, "Hardware :", &name)) //For Android devices
|
||||
);
|
||||
}
|
||||
|
||||
if(line != NULL)
|
||||
|
||||
+21
-12
@@ -18,18 +18,6 @@ const FFOSResult* ffDetectOS(FFinstance* instance)
|
||||
}
|
||||
init = true;
|
||||
|
||||
FILE* osRelease = fopen("/etc/os-release", "r");
|
||||
|
||||
if(osRelease == NULL)
|
||||
osRelease = fopen("/usr/lib/os-release", "r");
|
||||
|
||||
ffStrbufInitA(&result.error, 64);
|
||||
if(osRelease == NULL)
|
||||
{
|
||||
ffStrbufAppendS(&result.error, "couldn't read /etc/os-release nor /usr/lib/os-release");
|
||||
return &result;
|
||||
}
|
||||
|
||||
ffStrbufInit(&result.systemName);
|
||||
ffStrbufInit(&result.name);
|
||||
ffStrbufInit(&result.prettyName);
|
||||
@@ -47,6 +35,19 @@ const FFOSResult* ffDetectOS(FFinstance* instance)
|
||||
ffStrbufSetS(&result.systemName, instance->state.utsname.sysname);
|
||||
ffStrbufSetS(&result.architecture, instance->state.utsname.machine);
|
||||
|
||||
#if !__ANDROID__
|
||||
FILE* osRelease = fopen("/etc/os-release", "r");
|
||||
|
||||
if(osRelease == NULL)
|
||||
osRelease = fopen("/usr/lib/os-release", "r");
|
||||
|
||||
ffStrbufInitA(&result.error, 64);
|
||||
if(osRelease == NULL)
|
||||
{
|
||||
ffStrbufAppendS(&result.error, "couldn't read /etc/os-release nor /usr/lib/os-release");
|
||||
return &result;
|
||||
}
|
||||
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
@@ -70,6 +71,14 @@ const FFOSResult* ffDetectOS(FFinstance* instance)
|
||||
free(line);
|
||||
|
||||
fclose(osRelease);
|
||||
#else
|
||||
ffStrbufSetS(&result.name, "Android");
|
||||
ffStrbufSetS(&result.id, "android");
|
||||
ffSettingsGetAndroidProperty("ro.build.version.release", &result.versionID);
|
||||
ffSettingsGetAndroidProperty("ro.build.version.sdk", &result.version);
|
||||
ffSettingsGetAndroidProperty("ro.build.version.codename", &result.codename);
|
||||
ffSettingsGetAndroidProperty("ro.build.display.id", &result.buildID);
|
||||
#endif
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ void ffPrintPackages(FFinstance* instance)
|
||||
{
|
||||
uint32_t pacman = getNumElements("/var/lib/pacman/local", DT_DIR);
|
||||
uint32_t dpkg = getNumStrings("/var/lib/dpkg/status", "Status: ");
|
||||
|
||||
#if __ANDROID__
|
||||
dpkg += getNumStrings("/data/data/com.termux/files/usr/var/lib/dpkg/status", "Status: ");
|
||||
#endif
|
||||
|
||||
uint32_t rpm = ffSettingsGetSQLiteColumnCount(instance, "/var/lib/rpm/rpmdb.sqlite", "Packages");
|
||||
uint32_t xbps = getNumElements("/var/db/xbps", DT_REG);
|
||||
uint32_t flatpak = getNumElements("/var/lib/flatpak/app", DT_DIR);
|
||||
|
||||
Reference in New Issue
Block a user