Self-healing mechanism for Android TV applications against OEM `force-stop` actions, specifically using SyncAdapter.
Raw Developer Origin & Technical Request
GitHub Issue
Nov 9, 2026
承接 #48 的定位结论。#48 已把死循环讲透:`killAllThirdApp` 强停 → 包置 `stopped=true` → 无障碍串里本应用的段被系统清掉 → 开机不 bind → `proc=0`,只能靠外部 adb 补回。建议 6 里提到的 SyncAdapter 方向,我在同款场景下找到了一套**实测可用的开源实现**可以借鉴——Aerial 桌面(app.orchard.tv,MIT 协议)。同一次 `killAllThirdApp` 里 Aerial 也被强停,但它每次都能在 30–60 秒内自己回来,靠的就是 SyncAdapter。本文给出适合 StudyOnTV 的移植写法,全部组件 API 21 起可用。
## 一、为什么 SyncAdapter 能穿过 force-stop
force-stop 掐断 BOOT_COMPLETED 广播、AlarmManager、JobScheduler、START_STICKY 重启,但**掐不断系统同步框架**:同步调度由 system_server 里的 SyncManager 持有,sync adapter 的注册信息在系统侧缓存,对 stopped 包依然有效——调度到达时系统会显式 bind,进程随之启动。
## 二、关键技巧:挂在 "settings" authority 上,事件驱动,无需定时器
Aerial 的做法不是定时轮询,而是把 sync adapter 的 `contentAuthority` 指到系统的 **`settings`**:
- SettingsProvider 对每次系统设置写入都带 `syncToNetwork` 标记,SyncManager 随后约 30 秒内调度一次本地同步;
- 而固件强停应用时"把这一段从 `enabled_accessibility_services` 里裁掉"**本身就是一次 settings 写入**——等于系统杀应用的时候,顺手触发了应用的复活。杀得越准,来得越快。
不需要网络,不需要轮询,也不会被"系统周期性改写白名单"(#48 里 `rt_pkg_white_list` 失效的原因)影响。
## 三、适配 StudyOnTV 的完整参考实现
### 1. AndroidManifest.xml
```xml
Developer Debate & Comments
Adjacent Repository Pain Points
Other highly discussed features and pain points extracted from chadyi/StudyOnTV.
检测更新失败
Frequently Asked Questions
Market intelligence mapped to Self-healing mechanism for Android TV applications against OEM `force-stop` actions, specifically using SyncAdapter..
What problem does Self-healing mechanism for Android TV applications against OEM `force-stop` actions, specifically using SyncAdapter. solve?
How is the developer community reacting to Self-healing mechanism for Android TV applications against OEM `force-stop` actions, specifically using SyncAdapter.?
What architecture is tied to Self-healing mechanism for Android TV applications against OEM `force-stop` actions, specifically using SyncAdapter.?
Engagement Signals
Cross-Market Term Frequency
Counts stored text matches for foundational terms like settings and Android 14 in analysed public discussions. These counts do not measure adoption.
Stored text matches, not adoption or market-share measurements.
- settings: 33 records
- Android 14: 4 records
- 小米电视: 3 records
- system_server: 3 records
- SyncAdapter 自愈机制: 1 records
- 冷启动必挂: 1 records
- 死循环: 1 records
- killAllThirdApp: 1 records
- stopped=true: 1 records
- 无障碍串: 1 records
- 开机不 bind: 1 records
- proc=0: 1 records
- 外部 adb 补回: 1 records
- SyncManager: 1 records
- sync adapter: 1 records
- BOOT_COMPLETED 广播: 1 records
- AlarmManager: 1 records
- JobScheduler: 1 records
- START_STICKY: 1 records
- 系统同步框架: 1 records
- 显式 bind: 1 records
- contentAuthority: 1 records
- SettingsProvider: 1 records
- syncToNetwork: 1 records
- LOCAL 同步: 1 records
- enabled_accessibility_services: 1 records
- rt_pkg_white_list: 1 records
- API 21: 1 records
- MiTV-MFFU0: 1 records
- GuardSync.kt: 1 records
- GuardSyncService: 1 records
- GuardAccountService: 1 records
- GuardListener.kt: 1 records
- RevivalSync.kt: 1 records
- GuardSetup.kt: 1 records
- MIT 许可: 1 records
- accountType=com.studyontv.tv: 1 records
- authority=settings: 1 records
- supportsUploading=true: 1 records
- AndroidManifest.xml: 1 records
- WRITE_SECURE_SETTINGS: 1 records
- READ_SYNC_SETTINGS: 1 records
- WRITE_SYNC_SETTINGS: 1 records
- FOREGROUND_SERVICE_SPECIAL_USE: 1 records
- dumpsys activity broadcasts: 1 records
- stopped 标记: 1 records
- 通知监听通道: 1 records
- enabled_notification_listeners: 1 records
- NMS: 1 records
- cmd notification allow_listener: 1 records
- 三层拉起: 1 records
- 外部 ADB 看门狗: 1 records
- am start: 1 records
SaaS Metrics