Files
MeowOS e6f0b665e3 refactor(launcher): 拆分 meow_launcherd.c(9778行)→meow_launcherd/ 多文件(agent-149)
- 14 模块 .c + meow_launcher_internal.h(642): util/font_theme/fb_compositor/settings_page/power_menu/notif_center/app_launcher/main_menu/audio/backlight/net/keys/about/statusbar; meow_launcherd.c 已删
- 按行逐字搬移(0-diff), 118函数提升非static+47组extern(内部头), #if0退役区不编入(源码留.pre_split.bak)
- 关于本机小改: 作者 AskaEth/17 + info/item[13]防越界 + s_dd_modal 超高滚动(clamp/触摸滚动/音量键跟随/裁剪, 仅超高启用)
- build_launcher.sh 编译列表→模块; 文档/注释引用 meow_launcherd.c→模块/目录
- 编译0warning/-Wall -Wextra告警集与原文一致(77条无新增)/qemu-mipsel冒烟一致(--scan/--sysdump); launcher=c0799357(505KB; md5因多文件重编译与原文异,非回归依据)
- 备份 meow_launcherd.c.pre_split.bak/meow_launcherd.pre_split.bak; M2.69(0.7.64)已推卡并用户验证OK
2026-08-30 21:38:30 +08:00

103 lines
5.6 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* about.c — MeowOS launcher 拆分模块(LAUNCHER_SPLIT_PLAN 拆分)。*/
/* 本文件由拆分工具从 meow_launcherd.c 按职责搬移;逻辑与原文 0-diff(仅 static 可见性按跨模块需求调整)。*/
#include "meow_launcher_internal.h"
/* M2.5x 系统设置「关于本机」:复用 s_dd_modal(与「WiFi连接状态」弹窗同款)列只读设备信息,
* 点卡片外/返回即关。信息源:settings system.hostname / g_meowos_version(=/etc/meowos_version) /
* uname -r / /proc/cpuinfo / /proc/meminfo / df / wpa_cli status / hciconfig / fb 分辨率+状态栏高。
* 只展示安全信息(不含任何密钥/凭证);实时读,短超时不阻塞主循环;行数 ≤12 适配下拉视口。
* 说明:launcher/bootmenu/watchdog/meow_v 未单独暴露版本号,统一以 /etc/meowos_version 的
* MeowOS 版本表示(与固件打包同源);无独立固件版本文件。 */
void s_about_open(void)
{
/* M2.5x 关于本机:信息行上限 12→13(新增「作者」行后近乎占满;超出由 s_dd_modal 滚动展示)。 */
char info[13][96];
const char *item[13];
int n = 0;
char host[64];
char *o;
/* 设备名(settings system.hostname;缺省 meowos) */
if (meow_settings_get_str("system.hostname", host, sizeof host) != 0 || !host[0])
snprintf(host, sizeof host, "meowos");
snprintf(info[n++], sizeof info[0], "设备名: %s", host);
/* MeowOS / 固件版本(/etc/meowos_version;与固件打包同源) */
snprintf(info[n++], sizeof info[0], "MeowOS: v%s", g_meowos_version);
/* 作者(2026-08-30 用户要求:关于本机加作者一行) */
snprintf(info[n++], sizeof info[0], "作者: AskaEth / 17");
/* 内核版本 */
o = popen_read_tmo(400, "PATH=/bin:/sbin:/usr/bin:/usr/sbin uname -r 2>/dev/null");
if (o) { for (char *p = o; *p; p++) if (*p == '\n' || *p == '\r') { *p = 0; break; }
snprintf(info[n++], sizeof info[0], "内核: %s", o[0] ? o : "-"); free(o); }
else snprintf(info[n++], sizeof info[0], "内核: -");
/* CPU(/proc/cpuinfo:Processor/CPU model/Hardware/system type 任取首非空行) */
o = popen_read_tmo(500,
"PATH=/bin:/sbin:/usr/bin:/usr/sbin awk -F: '/(model name|cpu model|system type|machine|hardware)/{print $2; exit}' /proc/cpuinfo 2>/dev/null");
if (o) { char *q = o; for (char *p = o; *p; p++) if (*p == '\n' || *p == '\r') { *p = 0; break; }
while (*q == ' ' || *q == '\t') q++;
snprintf(info[n++], sizeof info[0], "CPU: %s", q[0] ? q : "-"); free(o); }
else snprintf(info[n++], sizeof info[0], "CPU: -");
/* 内存(/proc/meminfo MemTotal / MemAvailable,KB→MB) */
long mtot = 0, mavail = 0;
o = popen_read_tmo(500, "PATH=/bin:/sbin:/usr/bin:/usr/sbin awk '/^MemTotal:/{print $2}/^MemAvailable:/{print $2}' /proc/meminfo 2>/dev/null");
if (o) { if (sscanf(o, "%ld%ld", &mtot, &mavail) < 2) mavail = 0; free(o); }
if (mtot > 0) snprintf(info[n++], sizeof info[0], "内存: %ld/%ld MB", mavail / 1024, mtot / 1024);
else snprintf(info[n++], sizeof info[0], "内存: -");
/* 板载 /usr/data:df -k → 可用/总量(MB) */
long dfree = 0, dtot = 0;
o = popen_read_tmo(600, "PATH=/bin:/sbin:/usr/bin:/usr/sbin df -k /usr/data 2>/dev/null | awk 'NR==2{print $4, $2}'");
if (o) { if (sscanf(o, "%ld%ld", &dfree, &dtot) < 2) dtot = 0; free(o); }
if (dtot > 0) snprintf(info[n++], sizeof info[0], "板载: %ld/%ld MB", dfree / 1024, dtot / 1024);
else snprintf(info[n++], sizeof info[0], "板载: -");
/* TF 卡 /usr/data/mnt/sd_0:卡在(/proc/mounts 含该挂载点)则 df,否则「无卡」 */
if (card_present()) {
long sfree = 0, stot = 0;
o = popen_read_tmo(600, "PATH=/bin:/sbin:/usr/bin:/usr/sbin df -k /usr/data/mnt/sd_0 2>/dev/null | awk 'NR==2{print $4, $2}'");
if (o) { if (sscanf(o, "%ld%ld", &sfree, &stot) < 2) stot = 0; free(o); }
if (stot > 0) snprintf(info[n++], sizeof info[0], "TF卡: %ld/%ld MB", sfree / 1024, stot / 1024);
else snprintf(info[n++], sizeof info[0], "TF卡: -");
} else {
snprintf(info[n++], sizeof info[0], "TF卡: 无卡");
}
/* 当前屏幕分辨率 + 状态栏高 */
snprintf(info[n++], sizeof info[0], "屏幕: %dx%d 状态栏%dpx", fb_xres, fb_yres, (int)SB_BAR_H);
/* WiFi:连上则 SSID(decode)+ 本机IP + 本机MAC;未连接显示「未连接」 */
if (wlan_connected()) {
char ss[64]; net_wifi_ssid(ss, sizeof ss);
snprintf(info[n++], sizeof info[0], "WiFi: %s", ss[0] ? ss : "已连接");
o = popen_read_tmo(1200, "PATH=/bin:/sbin:/usr/bin:/usr/sbin wpa_cli -i wlan0 status 2>/dev/null");
char ip[32] = "", mac[24] = "";
if (o) {
char *p = o;
while (p && *p) {
char *e = strchr(p, '\n'); if (e) *e = 0;
if (!strncmp(p, "ip_address=", 11)) snprintf(ip, sizeof ip, "%s", p + 11);
else if (!strncmp(p, "address=", 8)) snprintf(mac, sizeof mac, "%s", p + 8);
p = e ? e + 1 : NULL;
}
free(o);
}
if (ip[0]) snprintf(info[n++], sizeof info[0], "本机IP: %s", ip);
if (mac[0]) snprintf(info[n++], sizeof info[0], "本机MAC: %s", mac);
} else {
snprintf(info[n++], sizeof info[0], "WiFi: 未连接");
}
/* 蓝牙:hci_powered 决定开/关 */
snprintf(info[n++], sizeof info[0], "蓝牙: %s", hci_powered() ? "开" : "关");
for (int i = 0; i < n && i < 13; i++) item[i] = info[i];
s_dd_modal("关于本机", item, n, -1); /* cur=-1:只读展示,无预勾选 */
}