mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Display (Android): support detection in adb
This commit is contained in:
+1
-1
@@ -395,7 +395,7 @@ elseif(ANDROID)
|
||||
src/detection/cursor/cursor_nosupport.c
|
||||
src/detection/cpuusage/cpuusage_linux.c
|
||||
src/detection/disk/disk_linux.c
|
||||
src/detection/displayserver/displayserver_nosupport.c
|
||||
src/detection/displayserver/displayserver_android.c
|
||||
src/detection/font/font_nosupport.c
|
||||
src/detection/gpu/gpu_nosupport.c
|
||||
src/detection/host/host_android.c
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "displayserver.h"
|
||||
|
||||
#include "common/processing.h"
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
{
|
||||
ffStrbufInit(&ds->wmProcessName);
|
||||
ffStrbufInit(&ds->wmPrettyName);
|
||||
ffStrbufInit(&ds->wmProtocolName);
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInit(&ds->dePrettyName);
|
||||
ffStrbufInit(&ds->deVersion);
|
||||
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate();
|
||||
if (ffProcessAppendStdOut(&buf, (char* []) {
|
||||
"/system/bin/dumpsys",
|
||||
"display",
|
||||
NULL,
|
||||
}) != NULL || buf.length == 0)
|
||||
return; // Only works in `adb shell`, or when rooted
|
||||
|
||||
uint32_t index = 0;
|
||||
while ((index = ffStrbufNextIndexS(&buf, index, "DisplayDeviceInfo")) < buf.length)
|
||||
{
|
||||
index += strlen("DisplayDeviceInfo");
|
||||
uint32_t nextIndex = ffStrbufNextIndexC(&buf, index, '\n');
|
||||
buf.chars[nextIndex] = '\0';
|
||||
const char* info = buf.chars + index;
|
||||
|
||||
// {"Builtin display": uniqueId="local:4630947134992368259", 1440 x 3200, modeId 2, defaultModeId 1, supportedModes [{id=1, width=1440, height=3200, fps=60.000004, alternativeRefreshRates=[24.000002, 30.000002, 40.0, 120.00001, 120.00001, 120.00001, 120.00001, 120.00001]},
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateA(64);
|
||||
unsigned width = 0, height = 0, modeId = 0;
|
||||
double refreshRate = 0;
|
||||
// {"Builtin display": uniqueId="local:4630947134992368259", 1440 x 3200, modeId 2
|
||||
int res = sscanf(info, "{\"%63[^\"]\":%*s%u x %u, modeId%u", name.chars, &width, &height, &modeId);
|
||||
if (res >= 3)
|
||||
{
|
||||
if (res == 4)
|
||||
{
|
||||
++info; // skip first '{'
|
||||
while ((info = strchr(info, '{')))
|
||||
{
|
||||
++info;
|
||||
|
||||
unsigned id;
|
||||
double fps;
|
||||
// id=1, width=1440, height=3200, fps=60.000004,
|
||||
if (sscanf(info, "id=%u, %*s%*s fps=%lf", &id, &fps) >= 2)
|
||||
{
|
||||
if (id == modeId)
|
||||
{
|
||||
refreshRate = fps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufRecalculateLength(&name);
|
||||
ffdsAppendDisplay(ds,
|
||||
(uint32_t)width,
|
||||
(uint32_t)height,
|
||||
refreshRate,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
index = nextIndex + 1;
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
void ffPrintDisplay(FFDisplayOptions* options)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &instance.config.display.moduleArgs, "Display detection is not supported on Android");
|
||||
return;
|
||||
#endif
|
||||
|
||||
const FFDisplayServerResult* dsResult = ffConnectDisplayServer();
|
||||
|
||||
if(dsResult->displays.length == 0)
|
||||
|
||||
Reference in New Issue
Block a user