这个 Magisk 模块用于切换 Android 的 USB 调试常驻通知和 USB 充电/连接通知。
默认行为:隐藏“已连接到 USB 调试”通知和“正在通过 USB 为此设备充电”通知。
ADB 调试通知由 AOSP UsbDeviceManager.updateAdbNotification() 读取 persist.adb.notify 控制:
persist.adb.notify=0:不显示 USB 调试通知。persist.adb.notify=1:恢复 Android 默认显示行为。
USB 充电/连接通知没有对应的 persist.adb.notify 属性开关,模块通过 cmd notification snooze 隐藏当前 Android 系统 USB 通知。
模块在开机早期通过 post-fs-data.sh 写入 ADB 属性,在 late start 阶段通过 service.sh 补做当前通知隐藏。当前处理的通知 key:
- USB 调试通知:
-1|android|26|null|1000 - USB 充电/连接通知:
-1|android|32|null|1000
下载 release 中的 usb_adb_notify_toggle-v1.0.2.zip,在 Magisk 中安装,然后重启。
也可以本地构建:
./scripts/build.sh构建产物会生成在 dist/。
可以在 Magisk 模块列表里点击本模块的 Action 按钮切换,也可以执行:
su -c usb-adb-notify status
su -c usb-adb-notify off
su -c usb-adb-notify on
su -c usb-adb-notify toggleoff 会设置 persist.adb.notify=0,并隐藏 USB 调试通知与 USB 充电/连接通知。
on 会设置 persist.adb.notify=1,并恢复系统默认显示行为。
- 本模块只处理 USB 调试通知和 USB 充电/连接通知,不处理 FIClash、VPN、投屏、文件传输工具等第三方前台服务通知。
post-fs-data.sh会在开机早期写入属性,service.sh会在晚启动阶段补做当前通知隐藏。- 从隐藏切回显示时,通知不一定立刻重新出现;通常需要重插 USB、切换 USB 调试或重启后触发系统重新发通知。
- 卸载模块时会恢复
persist.adb.notify=1,并 unsnooze 当前模块处理的系统通知,避免把设备长期留在隐藏状态。
module/
META-INF/com/google/android/
action.sh
common.sh
customize.sh
module.prop
post-fs-data.sh
service.sh
system/bin/usb-adb-notify
uninstall.sh
scripts/
build.sh
本仓库纳入 darren_space 后按轻量 tooling repo 管理:
- 工作区标准入口:
../harness/docs/workspace/standards/README.md - 终端脚本输出标准:
../harness/docs/workspace/standards/tooling/terminal_output_golden_path.md - Magisk 模块标准:
../harness/docs/workspace/standards/magisk_module/magisk_module_golden_path.md
- AOSP
UsbDeviceManager:https://android.googlesource.com/platform/frameworks/base/+/5ac72a2/services/java/com/android/server/usb/UsbDeviceManager.java - Magisk Developer Guides:https://magisk.readthedocs.io/en/latest/developers/guides.html
GPL-3.0。模块安装器脚本来自 Magisk 官方模块 installer 机制,按 GPL 授权发布更稳妥。