feat(launcher): 通知查询/清除 IPC + App崩溃直报crash (agent-199) — MSG_NOTIFY_QUERY(0x25)/QUERY_RESULT(0x27)/DISMISS_ALL(0x26,保留媒体/进度/常驻红线), DISMISS(0x22)复用既有; 序列化在主循环单写者做; launch_app waitpid 回收处 notify_app_crash(信号杀/非0退出上报 /tmp/meow_crash.sock best-effort, 干净exit不报)
launcher 61f6b0db→3c7c2ec7; qemu IPC 往返+宿主存储单测+mock crash socket 全过; 顺带清理既有告警(util.c/app_launcher.c/meow_ipc.c)
This commit is contained in:
1 parent
29e1b35da8
commit
2d93298f8a
7 files changed
+272
-8
No files matched your search
@@ -158,7 +158,6 @@ static int cmd_declare(const char *app_id, int nent, char **ents)
|
||||
strncpy(d.app_id, app_id, MEOW_APP_ID_MAX - 1);
|
||||
int n = 0;
|
||||
char *p = d.entries;
|
||||
int cap = (int)sizeof(d.entries);
|
||||
for (int i = 0; i < nent && n < 8; i++) {
|
||||
size_t l = strlen(ents[i]);
|
||||
if (l + 1 > (size_t)(d.entries + sizeof d.entries - p)) break;
|
||||
@@ -272,6 +271,47 @@ static int cmd_dismiss(uint32_t id)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 查询当前内存活跃通知集 → MSG_NOTIFY_QUERY,期望 MSG_NOTIFY_QUERY_RESULT(打印 JSON 文本)。
|
||||
* 可选 <app_id> 过滤(缺省=全部)。 */
|
||||
static int cmd_querynotif(const char *app_id)
|
||||
{
|
||||
int fd = connect_path(g_sock);
|
||||
if (fd < 0) return 1;
|
||||
uint8_t rbuf[MEOW_IPC_MAX];
|
||||
int rt = xchg(fd, MSG_NOTIFY_QUERY, 8, app_id, app_id ? (uint32_t)strlen(app_id) : 0,
|
||||
rbuf, sizeof rbuf);
|
||||
close(fd);
|
||||
if (rt == MSG_NOTIFY_QUERY_RESULT) {
|
||||
m_notify_query_result_t r;
|
||||
memcpy(&r, rbuf, sizeof r);
|
||||
uint32_t tl = r.text_len < sizeof r.text ? r.text_len : sizeof r.text - 1;
|
||||
printf("QUERY ok: code=%d len=%u\n%s\n", r.code, (unsigned)tl, r.text);
|
||||
return r.code == MEOW_OK ? 0 : 1;
|
||||
}
|
||||
if (rt == MSG_ERR) { print_err((const m_err_t *)rbuf); return 1; }
|
||||
fprintf(stderr, "QUERY: unexpected resp type 0x%04x\n", rt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 一键清除(保留 ongoing/media/progress)→ MSG_NOTIFY_DISMISS_ALL,期望 MSG_ACK(status=清除数)。 */
|
||||
static int cmd_dismissall(void)
|
||||
{
|
||||
int fd = connect_path(g_sock);
|
||||
if (fd < 0) return 1;
|
||||
uint8_t rbuf[256];
|
||||
int rt = xchg(fd, MSG_NOTIFY_DISMISS_ALL, 9, NULL, 0, rbuf, sizeof rbuf);
|
||||
close(fd);
|
||||
if (rt == MSG_ACK) {
|
||||
m_ack_t a;
|
||||
memcpy(&a, rbuf, sizeof a);
|
||||
printf("DISMISS_ALL ok: code=%d cleared=%u\n", a.code, a.status);
|
||||
return a.code == MEOW_OK ? 0 : 1;
|
||||
}
|
||||
if (rt == MSG_ERR) { print_err((const m_err_t *)rbuf); return 1; }
|
||||
fprintf(stderr, "DISMISS_ALL: unexpected resp type 0x%04x\n", rt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *env = getenv("MEOW_IPC_SOCK");
|
||||
@@ -329,6 +369,13 @@ int main(int argc, char **argv)
|
||||
if (i + 1 >= argc) { fprintf(stderr, "dismiss needs <id>\n"); return 1; }
|
||||
return cmd_dismiss((uint32_t)strtoul(argv[i + 1], NULL, 0));
|
||||
}
|
||||
if (!strcmp(cmd, "querynotif")) {
|
||||
const char *app = (i + 1 < argc) ? argv[i + 1] : NULL;
|
||||
return cmd_querynotif(app);
|
||||
}
|
||||
if (!strcmp(cmd, "dismissall")) {
|
||||
return cmd_dismissall();
|
||||
}
|
||||
fprintf(stderr, "unknown cmd %s; try --help\n", cmd);
|
||||
return 1;
|
||||
}
|
||||
Reference in new issue
Block a user