diff --git a/meow_ui_sys.c b/meow_ui_sys.c index b5fade9..3df3327 100644 --- a/meow_ui_sys.c +++ b/meow_ui_sys.c @@ -134,8 +134,23 @@ void meow_ui_sys_refresh(void) g_sys.batt = read_int("/sys/class/power_supply/battery/capacity"); if (g_sys.batt < 0 || g_sys.batt > 100) g_sys.batt = -1; char st[16]; - read_str("/sys/class/power_supply/battery/status", st, sizeof st); - g_sys.charging = (strstr(st, "Charg") || strstr(st, "Full")) ? 1 : 0; + /* 充电态权威源(真机实测 2026-09-01:battery/status 恒 Discharging 撒谎): + * 1) mp2731-charger/status(Charging/Full=充电中);2) 回退 fusb302-typec-source/online==1 + * (USB-C PD 插线);3) 再回退旧逻辑 battery/status==Charging || ac/online==1。 */ + read_str("/sys/class/power_supply/mp2731-charger/status", st, sizeof st); + if (st[0]) { + g_sys.charging = (strstr(st, "Charg") || strstr(st, "Full")) ? 1 : 0; + } else { + int onl = read_int("/sys/class/power_supply/fusb302-typec-source/online"); + if (onl >= 0) { + g_sys.charging = (onl == 1) ? 1 : 0; + } else { + read_str("/sys/class/power_supply/battery/status", st, sizeof st); + g_sys.charging = (strstr(st, "Charg") || strstr(st, "Full")) ? 1 : 0; + if (!g_sys.charging && read_int("/sys/class/power_supply/ac/online") == 1) + g_sys.charging = 1; + } + } char op[16]; read_str("/sys/class/net/wlan0/operstate", op, sizeof op); diff --git a/meow_ui_sys.h b/meow_ui_sys.h index 2a67ef9..d8c0866 100644 --- a/meow_ui_sys.h +++ b/meow_ui_sys.h @@ -7,7 +7,8 @@ * meow_ui_set_fullscreen() / meow_ui_statusbar_height()。 * * 数据源与 launcher 的 meow_sys 同源单点一致: - * - 电量 /sys/class/power_supply/battery/{capacity,status} + * - 电量 /sys/class/power_supply/battery/capacity(充电态权威源=mp2731-charger/status, + * 回退 fusb302-typec-source/online → battery/status|ac/online;battery/status 会撒谎) * - WiFi /sys/class/net/wlan0/operstate * - 蓝牙 实际 powered(hciconfig -a hci0 的 UP;spawn 贵 → 缓存 30s 刷一次) * - 音量 /usr/data/meow/settings.conf 的 audio.volume(launcher 同文件;