diff --git a/CLAUDE.md b/CLAUDE.md index 8a0448d..bc69e87 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -71,7 +71,7 @@ NotifyListenerService (系统通知入口) |---|---| | `A2iApp.kt` | `Application` 单例;持有全局 `appScope`(`SupervisorJob+Dispatchers.Default`)与全局组件:三个 Store(`settings`/`appRules`/`logStore`)+ 监听类(`phoneCallMonitor`/`connectivityMonitor`/`carrierBalanceQuery`/`smsForwarder`/`updateChecker`)。全部经 `A2iApp.instance.xxx` 访问,`onCreate` 构造并 `start()`。UI 通过 `collectAsState()` 订阅 Store 的 `StateFlow`。 | | `service/NotifyListenerService.kt` | `NotificationListenerService` 实现;每条通知调 `processor.process()`,过滤后推送。 | -| `core/NotificationProcessor.kt` | **核心决策点**。包含 LRU 去重缓存(5s)、脱敏检测(`*****` → 回退到 `tickerText`)、系统状态消息过滤、广告过滤、验证码提取、特殊 App 解析。返回 `Decision(message?, reason, appLabel, code)`。 | +| `core/NotificationProcessor.kt` | **核心决策点**。包含 LRU 去重缓存(5s)、脱敏检测(`*****` → 回退到 `tickerText`)、持续性通知 + VPN/代理客户端常驻通知(`silentPackages`)静默过滤、系统状态消息过滤、广告过滤、验证码提取、特殊 App 解析。返回 `Decision(message?, reason, appLabel, code, silent)`。 | | `core/CodeExtractor.kt` | 三段正则:关键词+数字、数字+关键词、纯数字 4-8 位。检测到全 `*****` 时直接返回 null。 | | `core/AdFilter.kt` | 内置营销关键词 + 用户自定义关键词(`settings.adKeywords`)。 | | `core/AppParsers.kt` | 微信/QQ/Telegram 的 `clickUrl` 映射 + 重要消息关键词(@我、验证码、通话等)。 | @@ -97,7 +97,7 @@ NotifyListenerService (系统通知入口) - **Store 全局单例**:所有 Store 通过 `A2iApp.instance.xxx` 访问。**不要**在 Compose 中创建新的 Store 实例。 - **协程作用域**:跨屏调用用 `app.appScope.launch { ... }`(Application 级别的 `SupervisorJob + Dispatchers.Default`)。 - **过滤流水线**(顺序很重要,在 `NotificationProcessor.process` 中): - 1. 全局开关 → 2. ongoing 过滤(静默)→ 3. App 黑/白名单 → 4. 空内容/脱敏 → 5. 噪音包名 → 6. 系统状态消息 → 7. 近空内容 → 8. 广告过滤 → 9. 已发短信(仅收不发)→ 10. 运营商余额回执拦截 → **11. 去重检查(5s 窗口)** → 12. 验证码提取 → 13. 特殊 App 解析 → 14. 构造 BarkMessage + 1. 全局开关 → 2. ongoing 过滤(静默)→ 2b. VPN/代理常驻通知静默过滤(silentPackages)→ 3. App 黑/白名单 → 4. 空内容/脱敏 → 5. 噪音包名 → 6. 系统状态消息 → 7. 近空内容 → 8. 广告过滤 → 9. 已发短信(仅收不发)→ 10. 运营商余额回执拦截 → **11. 去重检查(5s 窗口)** → 12. 验证码提取 → 13. 特殊 App 解析 → 14. 构造 BarkMessage - **Bark API** 字段映射在 `BarkMessage.kt`(`@SerialName`):`device_key`/`autoCopy`/`isArchive` 用下划线/驼峰别名,其他用蛇形。 - **版本号**:`app/build.gradle.kts` 的 `versionCode`/`versionName`,运行时通过 `appVersionName(context)` 读取,首页底部居中显示 `v{version}`。**改完代码同步递增 versionCode/versionName,并更新本文档「版本与发布」一节的当前版本。** diff --git a/app/src/main/java/com/a2i/forwarder/core/NotificationProcessor.kt b/app/src/main/java/com/a2i/forwarder/core/NotificationProcessor.kt index c497c24..64225e3 100644 --- a/app/src/main/java/com/a2i/forwarder/core/NotificationProcessor.kt +++ b/app/src/main/java/com/a2i/forwarder/core/NotificationProcessor.kt @@ -49,6 +49,14 @@ class NotificationProcessor(private val context: Context) { "com.google.android.gms", ) + // 静默过滤的包名:代理/VPN 客户端的常驻流量通知,高频且无意义,过滤不写日志 + private val silentPackages = setOf( + "com.getsurfboard", // Surfboard + "com.github.metacubex.clash.meta", // Clash Meta for Android + "com.github.kr328.clash", // Clash for Android + "com.v2ray.ang", // v2rayNG + ) + fun process(sbn: StatusBarNotification): Decision { val pkg = sbn.packageName val n = sbn.notification ?: return Decision(null, "无通知", pkg, null) @@ -94,6 +102,10 @@ class NotificationProcessor(private val context: Context) { if (settings.skipOngoing.value && isOngoing) return Decision(null, "持续性通知", appLabel, null, silent = true) + // ---- 静默包名过滤(VPN/代理客户端的常驻流量通知,高频无意义,不写日志)---- + if (pkg in silentPackages) + return Decision(null, "常驻通知静默", appLabel, null, silent = true) + // ---- App 黑白名单 ---- if (!rules.isForwardingOn(pkg)) return Decision(null, "此 App 已关", appLabel, null)