充电态权威源 mp2731-charger/status(修 battery/status 撒谎恒 Discharging)
真机实测:设备充电中但 battery/status 恒 Discharging;权威源为 mp2731-charger/status(Charging/Full),回退链 fusb302-typec-source/online==1 → 旧逻辑 battery/status==Charging || ac/online==1。电量仍读 battery/capacity。 - meow_svc_power: battery/status 命令充电判定走权威链(MEOW_PS_DIR 可重定向供宿主自测); svc_power_authtest 补 6 用例(mp2731 Charging/Full/Discharging + 两级回退)全 PASS - SDK meow_ui_sys: 状态栏充电态同权威链 - launcher util.c: 抽 batt_is_charging() 公共判定;meow_sys_light 1s 轻刷补充电态(插拔实时) - bootmenu 无充电判定(仅读 capacity)/MeowPanel 透传 power 服务:均无需改 - 真机验证(充电窗口):新二进制 battery=88%(Charging),对照固件内旧版 88%(Discharging) - hello/files/ncm 随 meow_ui.a(af6703f2) 重链已热更到卡(.new+mv,md5 对核一致) md5: meow_svc_power 39ae3aa2 / meow_launcherd 2aa61780 / hello 2444c151 / files 691db88b / ncm 89da63ed(仅重链,源码未动)
This commit is contained in:
1 parent
793a807ce3
commit
f149e24f28
13 files changed
+114
-12
No files matched your search
@@ -9,12 +9,15 @@
|
||||
* cc -Wall -Wextra -I../meow_launcherd svc_power_authtest.c -o svc_power_authtest && ./svc_power_authtest
|
||||
*/
|
||||
#define main meow_svc_power_prod_main_unused
|
||||
#define MEOW_PS_DIR "/tmp/meow_ps_authtest" /* 充电态判定宿主自测:重定向 sysfs 根 */
|
||||
#include "meow_svc_power.c"
|
||||
#undef main
|
||||
#undef MEOW_PS_DIR
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static int g_fail = 0;
|
||||
#define CHECK(cond) do { if (!(cond)) { printf(" FAIL: %s (line %d)\n", #cond, __LINE__); g_fail++; } \
|
||||
@@ -126,6 +129,49 @@ int main(void)
|
||||
a.cmd = POWER_SET_DEFAULT_MEOW; CHECK(is_read_level(&a) == 0);
|
||||
a.cmd = POWER_SET_DEFAULT_HIBY; CHECK(is_read_level(&a) == 0);
|
||||
|
||||
/* == 充电态权威源(真机实测 2026-09-01:battery/status 恒 Discharging 撒谎)==
|
||||
* 在 /tmp 造 power_supply 假节点(MEOW_PS_DIR 已重定向),覆盖判定优先级:
|
||||
* mp2731-charger/status(权威)→ fusb302-typec-source/online → battery/status|ac/online。 */
|
||||
printf("== charging_status_str (authoritative mp2731) ==\n");
|
||||
mkdir("/tmp/meow_ps_authtest", 0755);
|
||||
mkdir("/tmp/meow_ps_authtest/battery", 0755);
|
||||
mkdir("/tmp/meow_ps_authtest/mp2731-charger", 0755);
|
||||
mkdir("/tmp/meow_ps_authtest/fusb302-typec-source", 0755);
|
||||
mkdir("/tmp/meow_ps_authtest/ac", 0755);
|
||||
write_file_str("/tmp/meow_ps_authtest/battery/capacity", "72", 0644);
|
||||
write_file_str("/tmp/meow_ps_authtest/battery/voltage_now", "4150000", 0644);
|
||||
write_file_str("/tmp/meow_ps_authtest/battery/status", "Discharging", 0644); /* 撒谎节点 */
|
||||
write_file_str("/tmp/meow_ps_authtest/ac/online", "0", 0644);
|
||||
|
||||
char out[64];
|
||||
/* T1: mp2731=Charging(battery 撒谎 Discharging)→ 充电中 */
|
||||
write_file_str("/tmp/meow_ps_authtest/mp2731-charger/status", "Charging", 0644);
|
||||
battery_fill(out, sizeof out);
|
||||
CHECK(strstr(out, "(Charging)") != NULL);
|
||||
/* T2: mp2731=Full → 满电 */
|
||||
write_file_str("/tmp/meow_ps_authtest/mp2731-charger/status", "Full", 0644);
|
||||
battery_fill(out, sizeof out);
|
||||
CHECK(strstr(out, "(Full)") != NULL);
|
||||
/* T3: mp2731=Discharging 且拔线 → 非充电(权威源的放电可信) */
|
||||
write_file_str("/tmp/meow_ps_authtest/mp2731-charger/status", "Discharging", 0644);
|
||||
write_file_str("/tmp/meow_ps_authtest/fusb302-typec-source/online", "0", 0644);
|
||||
battery_fill(out, sizeof out);
|
||||
CHECK(strstr(out, "(Discharging)") != NULL);
|
||||
/* T4: mp2731 节点不可读 → 回退 fusb302 online==1 → 充电 */
|
||||
unlink("/tmp/meow_ps_authtest/mp2731-charger/status");
|
||||
write_file_str("/tmp/meow_ps_authtest/fusb302-typec-source/online", "1", 0644);
|
||||
battery_fill(out, sizeof out);
|
||||
CHECK(strstr(out, "(Charging)") != NULL);
|
||||
/* T5: 全不可读 → 回退旧逻辑 ac/online==1 → Charging */
|
||||
unlink("/tmp/meow_ps_authtest/fusb302-typec-source/online");
|
||||
write_file_str("/tmp/meow_ps_authtest/ac/online", "1", 0644);
|
||||
battery_fill(out, sizeof out);
|
||||
CHECK(strstr(out, "(Charging)") != NULL);
|
||||
/* T6: 全不可读且 ac/online=0、battery=Discharging → Discharging */
|
||||
write_file_str("/tmp/meow_ps_authtest/ac/online", "0", 0644);
|
||||
battery_fill(out, sizeof out);
|
||||
CHECK(strstr(out, "(Discharging)") != NULL);
|
||||
|
||||
if (g_fail) { printf("\nAUTH TEST: %d FAIL\n", g_fail); return 1; }
|
||||
printf("\nAUTH TEST: ALL PASS\n");
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user