隐屏(HideScreen) 是一个基于 Xposed / LSPosed 的轻量级 Android 模块。
它在截图、录屏及屏幕投射过程中,使作用域内的应用界面从最终画面中消失,而应用本身在设备上的显示和交互完全不受影响。
模块的实现完全依赖 Android 原生安全机制 —— 通过设置 SurfaceControl.setSkipScreenshot(true),让系统合成画面时自动跳过指定窗口。模块本身不修改应用内容、不注入视图、不持续运行,仅在窗口创建时一次性标记,性能极佳,耗电可忽略不计。
WindowManager 添加的窗口(包括输入法、对话框、Toast 等)本模块的设计哲学为:只做一件事,做到极致。
核心机制
在 ViewRootImpl 窗口生命周期的关键节点,通过反射调用系统隐藏 API SurfaceControl.Transaction.setSkipScreenshot(true),将防截屏标志写入 SurfaceFlinger。系统截图与录屏服务会自动遵守该标志,无需额外拦截或修改系统行为。
关键优化
SurfaceControl 的字段并记住,后续窗口直接命中,彻底消除无效的反射遍历。setSkipScreenshot 及 setSecure 方法,确保从 Android 6.0 到最新版本的广泛兼容性。close() 方法,及时释放底层 Binder 引用,避免任何潜在的系统资源堆积。性能与功耗
模块只在窗口创建、旋转或重建时进行极短的事务提交,其余时间完全静默。在日常使用中,其对 CPU 和电池的影响微乎其微,完全可以忽略不计。即便在低端设备上,也不会产生任何可感知的卡顿或发热。
启用后,被选中的应用在进行系统截图、录屏或屏幕投射时,其界面将不出现在结果中。
切勿将本模块作用于以下目标:
若错误地将模块应用于系统组件,可能导致:
本模块仅设计用于第三方普通应用,请务必在 LSPosed 作用域中仔细甄别。
setSkipScreenshot 的支持程度不同,模块在某些深度定制的系统上可能效果受限(已知问题极少)。本模块的核心思路受 Transparent Screenshot 启发,在此向原作者的开源精神表示感谢。
当前版本已在性能、兼容性、资源管理等方面进行了彻底重构,具体差异详见技术原理与优化章节。
本项目基于 MIT License 发布。
###概述
HideScreen is a lightweight Xposed / LSPosed module for Android.
It hides the target application’s UI from screenshots, screen recordings, and screen casting results, while the app remains fully visible and interactive on the physical device.
The module leverages Android’s native secure surface flag — SurfaceControl.setSkipScreenshot(true) — to instruct SurfaceFlinger to exclude specific windows from the final composed output. No content modification, view injection, or background service is involved. Performance is excellent, and power consumption is negligible.
WindowManager (including IME, dialogs, toasts)The module follows a single‑responsibility principle: do one thing exceptionally well.
Core Approach
Hooks into ViewRootImpl lifecycle methods (setView, relayoutWindow, performTraversals) and applies the screenshot‑skip flag via reflective calls to SurfaceControl.Transaction. The system screenshot / screen recording pipeline respects this flag automatically.
Key Optimizations
SurfaceControl field used by the device is detected and memorized, avoiding unnecessary reflection traversal.setSkipScreenshot and setSecure in optimal order, ensuring broad compatibility from Android 6.0 to the latest versions.close() on the transaction object to release underlying Binder references promptly.Performance & Power
The module performs a brief transaction only when a window is created, rotated, or rebuilt. The rest of the time it stays completely idle. Its impact on CPU and battery is so minimal that it is entirely unnoticeable in daily use, even on low‑end devices.
Once enabled, selected apps will no longer appear in system screenshots, screen recordings, or casting outputs.
Do NOT apply this module to the following:
android) or system_serverApplying the module to system components may cause:
This module is strictly designed for ordinary third‑party applications. Choose scopes carefully within LSPosed.
setSkipScreenshot.The core idea of this module was inspired by Transparent Screenshot. We appreciate the original author’s open-source spirit.
The current version has been completely refactored in terms of performance, compatibility, and resource management. See Technical Highlights for detailed differences.
This project is licensed under the MIT License.
ac.no.screenshot