真机 meow_ui_time_ms() 返回「低 32=秒×1000、高 32 随机」的根因不是 SDK 写法,
而是 zig 0.17 自带 musl 在 mipsel 上的 time64 ABI 自相矛盾:
- zig 头(mips-linux-musl/bits/alltypes.h)无条件 64 位 time_t、struct timespec 16 字节;
- zig 的 clang 给 32 位 mips 预定义 __ILP32__,musl 的 time64 回退分支
`#if defined(SYS_x_time64) && !defined(__ILP32__)`(本意只排除 x32)被编译掉;
- 于是 libc 的 __clock_gettime64 实为 o32 time32 实现(SYS_clock_gettime 4263),
只写 8 字节 {int32 sec; int32 nsec},与头的 16 字节布局错配。
修复(patch_v2/sdk/meow_ui_time.c):
- meow_ui_time_ms() 直接按内核 o32 ABI 取 8 字节 time32,再升 64 位毫秒;
- 同 TU 强定义 __clock_gettime/__clock_gettime64(归档先于 -lc,链接期接管,
time()/gettimeofday()/pthread 定时等待的内部取时随之修正);
- 同源缺陷一并修:__nanosleep_time64/__clock_nanosleep(_time64) 转换 time32 后重发
(修复前 usleep(16000) 等亚秒睡眠立即返回、变忙等空转);
- gfx/sys/input/cachegov 四处重复 now_ms 收敛到 meow_ui_time_ms;
- build_sdk.sh OBJS 增加 meow_ui_time;新增 test_meow_time 宿主单测、
tools/clock_abi_probe.c 探针、CLOCK_ABI.md 根因/验证/影响面文档;
- 26 个宿主测试的编译注释补 meow_ui_time.c(cachegov 测试补时钟源)。
验证:宿主单测 PASS;anim(32)/view_event 宿主用例全过;build_sdk_host.sh --verify
76 成员全 MIPS32r2、0 warning;探针链接后无 libc cgt_init/__vdsosym,
__time64/__timedwait_cp 的取时指向本 TU,睡眠走 4166/4265 且用本地 8 字节结构。
125 lines
5.6 KiB
C
125 lines
5.6 KiB
C
/* test_sb_collapse.c — 宿主验证「全屏状态栏收合」纯逻辑(agent-146,不依赖 /dev/fb0/字库):
|
||
* 1. 顶条模式上报:App 进程(system_mode=0)set_collapsed/set_fullscreen → 写 /tmp/meowapp_sbar
|
||
* ('0'展开/'1'收合/'2'隐藏),供 launcher 感知 App 运行时全屏/收合态。
|
||
* 2. 热区保留判定:状态栏激活(含收合)时 meow_ui_statusbar_hotzone()==MUI_SBAR_H(28)(收合≠禁热区,
|
||
* 渲染与热区事件分离);仅全屏隐藏(inset0)时缩到 MEOW_SBAR_HOTZONE_FS(4)。
|
||
* 3. 收合状态机:system_mode=1 + animate(200) + set_collapsed(1) → animating()==1,
|
||
* collapse_offset() 随时间推进 → 28(收合出屏);set_collapsed(0) → offset 回 0(恢复)。
|
||
* 4. 收合 inset:collapsed → meow_ui_statusbar_height()==MUI_SBAR_COLLAPSE_H(4)。
|
||
*
|
||
* 编译(宿主 gcc,链真实 gfx/sys/theme/vol/log + 打桩 font/global + meow_notify_ipc):
|
||
* gcc -o test_sb_collapse test_sb_collapse.c test_host_stub.c \
|
||
* meow_ui_gfx.c meow_ui_time.c meow_ui_sys.c meow_ui_theme.c meow_ui_vol.c meow_ui_log.c meow_notify_ipc.c \
|
||
* -I. -I../meow_launcherd -DMEOW_UI_HOST_TEST -pthread
|
||
*/
|
||
#include "meow_ui.h"
|
||
#include "meow_ui_internal.h"
|
||
#include "meow_ui_sys.h"
|
||
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <unistd.h>
|
||
#include <fcntl.h>
|
||
#include <assert.h>
|
||
|
||
#define SBAR_MODE_FILE "/tmp/meowapp_sbar"
|
||
|
||
static int read_mode(void)
|
||
{
|
||
int fd = open(SBAR_MODE_FILE, O_RDONLY);
|
||
if (fd < 0) return -1;
|
||
char ch[8]; int n = read(fd, ch, sizeof ch - 1);
|
||
close(fd);
|
||
if (n <= 0) return -1;
|
||
return ch[0] == '1' ? 1 : (ch[0] == '2' ? 2 : 0);
|
||
}
|
||
|
||
int main(void)
|
||
{
|
||
meow_ui_opts o = { 480, 720 };
|
||
assert(meow_ui_init(&o) == 0);
|
||
/* 初始 App 模式(system_mode 默认 0) */
|
||
assert(meow_ui_sys_render_enabled() == 0);
|
||
|
||
/* ---- 1) 顶条模式上报 ---- */
|
||
meow_ui_set_fullscreen(0); meow_ui_statusbar_set_collapsed(0);
|
||
assert(read_mode() == 0); /* 展开 */
|
||
meow_ui_statusbar_set_collapsed(1);
|
||
assert(read_mode() == 1); /* 收合 */
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
meow_ui_set_fullscreen(1);
|
||
assert(read_mode() == 2); /* 隐藏 */
|
||
meow_ui_set_fullscreen(0);
|
||
printf("PASS mode-file: app writes /tmp/meowapp_sbar (0=expanded 1=collapsed 2=hidden)\n");
|
||
|
||
/* ---- 2a) 激活(含收合)时热区保留 28 ---- */
|
||
meow_ui_statusbar_set_collapsed(1);
|
||
assert(meow_ui_statusbar_collapsed() == 1);
|
||
assert(meow_ui_statusbar_hotzone() == MUI_SBAR_H); /* 收合仍监听顶部 28px(渲染与热区分离) */
|
||
assert(meow_ui_statusbar_height() == MUI_SBAR_COLLAPSE_H); /* 收合 inset=4(提示线) */
|
||
assert(meow_ui_sys_statusbar_active() == 1); /* 收合仍视为状态栏激活 */
|
||
printf("PASS hotzone-retain: collapsed -> hotzone=%d(28) inset=%d(4) active\n",
|
||
meow_ui_statusbar_hotzone(), meow_ui_statusbar_height());
|
||
|
||
/* ---- 2b) 全屏隐藏(immersive)时热区缩小 ---- */
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
meow_ui_set_fullscreen(1);
|
||
int fs_hot = meow_ui_statusbar_hotzone();
|
||
assert(fs_hot == MEOW_SBAR_HOTZONE_FS); /* inset0 → 4 */
|
||
printf("PASS hotzone-shrink: fullscreen-hidden -> hotzone=%d(fs=4)\n", fs_hot);
|
||
meow_ui_set_fullscreen(0);
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
|
||
/* ---- 3) 收合状态机(launcher / system_mode=1)---- */
|
||
meow_ui_sys_set_system_mode(1);
|
||
assert(meow_ui_sys_render_enabled() == 1);
|
||
meow_ui_set_refresh_always_max(1); /* 宿主:绕过帧率门控,逐次 flush 可推进 */
|
||
|
||
meow_ui_statusbar_set_collapsed(0); /* 复位 */
|
||
meow_ui_set_fullscreen(0);
|
||
meow_ui_statusbar_animate(200); /* 上移过渡 200ms */
|
||
assert(meow_ui_statusbar_animating() == 0);
|
||
meow_ui_statusbar_set_collapsed(1); /* 目标收合 */
|
||
assert(meow_ui_statusbar_animating() == 1); /* 未到位 → 过渡中 */
|
||
assert(meow_ui_statusbar_collapse_offset() == 0);
|
||
|
||
/* 驱动 present(标顶条左上 1px 唤醒 + 上屏)并让时间流逝,验证 offset 推进 */
|
||
int off_prev = 0, progressed = 0;
|
||
for (int i = 0; i < 60; i++) {
|
||
meow_ui_flush_region(0, 0, 1, 1);
|
||
usleep(15000); /* ~15ms/帧,模拟过渡期高频刷 */
|
||
int off = meow_ui_statusbar_collapse_offset();
|
||
if (off > off_prev) progressed = 1;
|
||
off_prev = off;
|
||
if (!meow_ui_statusbar_animating()) break; /* 到 28 稳定 */
|
||
}
|
||
assert(progressed == 1);
|
||
assert(meow_ui_statusbar_collapse_offset() >= MUI_SBAR_H);
|
||
assert(meow_ui_statusbar_animating() == 0);
|
||
assert(meow_ui_statusbar_height() == MUI_SBAR_COLLAPSE_H); /* 收合稳定:inset=4 */
|
||
printf("PASS collapse-enter: offset 0->%d (animating 1->0)\n",
|
||
meow_ui_statusbar_collapse_offset());
|
||
|
||
/* 退出全屏(恢复):offset 回 0 */
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
assert(meow_ui_statusbar_animating() == 1);
|
||
int back = 0;
|
||
for (int i = 0; i < 60; i++) {
|
||
meow_ui_flush_region(0, 0, 1, 1);
|
||
usleep(15000);
|
||
back = meow_ui_statusbar_collapse_offset();
|
||
if (!meow_ui_statusbar_animating()) break;
|
||
}
|
||
assert(back == 0 && meow_ui_statusbar_animating() == 0);
|
||
assert(meow_ui_statusbar_height() == MUI_SBAR_H); /* 恢复:inset=28 */
|
||
printf("PASS collapse-exit: offset ->0 (inset back to 28)\n");
|
||
|
||
/* 清理:宿主测试产物 */
|
||
unlink(SBAR_MODE_FILE);
|
||
|
||
printf("ALL PASS\n");
|
||
meow_ui_shutdown();
|
||
return 0;
|
||
}
|