hello f45ba051→c06b3b4f; mipsel -Wall -Wextra 0 warning; 宿主 P1c/P2/P3+widgets 全 PASS 出入(诚实): view on_draw/on_event 路径暂未启用(注册表直绘已覆盖, on_draw 双画风险), 留批③实测; home/full 仍手绘未迁注册表
57 lines
2.7 KiB
C
57 lines
2.7 KiB
C
/* logic/notify.c — 通知业务(notif_send/notif_cancel)。
|
||
*
|
||
* 纯业务:只依赖 SDK 通知数据类型/API(meow_notify_*)+ meow_log,不碰任何 UI 控件/view。
|
||
* UI 只经 notif_send()/notif_cancel() 调用(契约 ①);本层不回调 UI,最近一条 id 由本层持有。
|
||
* 注:boundary 折中——通知是 SDK 服务(§9.1),故本文件 include meow_ui.h 仅用其通知类型/函数。
|
||
*/
|
||
#include "logic.h"
|
||
#include "meow_ui.h"
|
||
#include <string.h>
|
||
#include <stdint.h>
|
||
|
||
static uint32_t g_last_notif = 0; /* 最近一次 send 返回的 id,供 cancel */
|
||
|
||
void notif_send(int which)
|
||
{
|
||
meow_notify n;
|
||
memset(&n, 0, sizeof n);
|
||
n.progress = -1;
|
||
n.timeout_ms = MEOW_NOTIFY_TIMEOUT_NEVER;
|
||
n.urgency = MEOW_NOTIFY_URG_NORMAL;
|
||
const char *label = "?";
|
||
|
||
switch (which) {
|
||
case 0: label = "INFO"; n.cat = MEOW_NOTIFY_CAT_GENERAL;
|
||
n.title = "测试-普通通知"; n.body = "普通 INFO 通知,timeout=5000ms"; n.timeout_ms = 5000; break;
|
||
case 1: label = "MEDIA"; n.cat = MEOW_NOTIFY_CAT_MEDIA; n.urgency = MEOW_NOTIFY_URG_LOW;
|
||
n.title = "测试-媒体通知"; n.body = "媒体单例,正在播放,timeout=-1 常驻";
|
||
n.timeout_ms = MEOW_NOTIFY_TIMEOUT_ONGOING; break;
|
||
case 2: label = "HIGH"; n.cat = MEOW_NOTIFY_CAT_GENERAL; n.urgency = MEOW_NOTIFY_URG_HIGH;
|
||
n.title = "测试-紧急度HIGH"; n.body = "高紧急度:顶部横幅+提示音"; n.timeout_ms = 3000; break;
|
||
case 3: label = "PROG"; n.cat = MEOW_NOTIFY_CAT_PROGRESS;
|
||
n.title = "测试-进度通知"; n.body = "下载进度 40%"; n.timeout_ms = 8000; n.progress = 40; break;
|
||
case 4: label = "ONGO"; n.cat = MEOW_NOTIFY_CAT_GENERAL;
|
||
n.title = "测试-常驻通知"; n.body = "常驻不自动过期(timeout=-1),需手动取消";
|
||
n.timeout_ms = MEOW_NOTIFY_TIMEOUT_ONGOING; break;
|
||
case 5: label = "TGT"; n.cat = MEOW_NOTIFY_CAT_MESSAGE;
|
||
n.title = "测试-跳转Activity"; n.body = "点击跳转 target_activity=main";
|
||
n.timeout_ms = 6000; n.target_activity = "main"; n.icon = NULL; break;
|
||
default: return;
|
||
}
|
||
|
||
uint32_t id = meow_notify_send(&n);
|
||
g_last_notif = id;
|
||
meow_log(MEOW_LOG_INFO,
|
||
"notify btn=%s id=%u cat=%s urg=%s tmo=%d prog=%d target=%s title=%s",
|
||
label, (unsigned)id, meow_notify_category_str(n.cat),
|
||
meow_notify_urgency_str(n.urgency), n.timeout_ms, n.progress,
|
||
n.target_activity ? n.target_activity : "-", n.title ? n.title : "-");
|
||
}
|
||
|
||
void notif_cancel(void)
|
||
{
|
||
int r = meow_notify_cancel(g_last_notif);
|
||
meow_log(MEOW_LOG_INFO, "notify cancel id=%u result=%d", (unsigned)g_last_notif, r);
|
||
g_last_notif = 0;
|
||
}
|