-
Notifications
You must be signed in to change notification settings - Fork 8
Events Monitoring and Shell Integration
The project has two event models with different purposes. SessionEvent is the formal runtime input for an active remote session. ScrcpyEventBus provides application-level cross-component notification, statistics, and compatibility projections. The latter must not replace the session state machine.
Events that change ADB, server, socket, decoder, cleanup, or reconnect facts enter the current Session.handleEvent(). One Channel serially reduces them into SessionState and the component snapshot. New main-path code must not update only the global bus while leaving session state unchanged.
ScrcpyEventBus is appropriate for:
- Cross-module notifications such as USB detach and connection lost.
- Shell, forward, and file-push observation statistics.
- Sampled telemetry such as media frames and socket bytes.
- Native status/error callbacks and main-thread dispatch.
It must not persist user configuration, own connection resources, decide reconnect budget, or become the UI's only truth.
ScrcpyEventLoop serially consumes an unbounded Channel, asks ScrcpyEventLogger to log, then calls the handler registered for the event class. ScrcpyEventMonitor projects Shell, forward, files, ADB verification, server logs, sockets, media, device screen, connections, and exceptions into device monitor state.
- High-frequency events whose
needsSampling()is true log every 100th item while total statistics continue accumulating. - Lifecycle, failure, user action, and resource-boundary events are not sampled because their order matters.
- Because the Channel is unbounded, producers still aggregate high-frequency data at the source; they must not publish every byte or pointer sample without limit.
- Handler registration currently retains one function per event class. Confirm that a new consumer will not overwrite an existing handler.
- Monitor state is a diagnostic projection cleared by device id on disconnect; it does not drive the session backward.
AdbShellManager.execute(connection, command, retryOnFailure, reportToEventBus) runs on the IO dispatcher and publishes ShellCommandExecuted or ShellCommandFailed. Internal probes such as property reads and heartbeat may disable bus reporting to avoid noise.
Choose an entry point:
- One-shot command:
AdbConnection.executeShell(); useAdbShellManager.execute()when unified statistics are required. - Continuous output:
openStreamingShellStream()on the delayed-ACK streaming lane. - Interactive terminal:
openPtyShellStream(); the implementation may fall back to a raw stream on failure. - scrcpy-specific server and forward orchestration remains in
ConnectionLifecycle, not the generic Shell manager.
- Is this a session fact, cross-module notification, telemetry, or just a function result?
- Does it carry device/session correlation without treating an mDNS resolved endpoint as transport identity?
- Are command arguments quoted safely, and can output contain sensitive or unbounded content?
- Are failure, cancellation, and stream close reported once while preserving cancellation semantics?
- Is high-frequency data aggregated at the source with explicit sampling?
- Is a projection being misused as resource owner or reconnect trigger?
- Overview / 总览
- Quick Start / 快速开始
- Connection & Pairing / 连接设备与配对
- Session Management / 会话管理
- Remote Control / 远程控制
- Settings / 设置
- Management Features / 管理功能
- FAQ / 常见问题
- Overview / 总览
- Technical Index / 技术文档索引
- Audit Checklist / 初始化与更新清单
- Conventions / 文档维护约定
- Architecture / 架构
- Module Map / 模块地图与边界
- Runtime Path / 运行时主链路
- Session State / 会话状态与事件
- Session Lifecycle / 会话配置与连接生命周期
- ADB, USB & Wireless / ADB、USB 与无线
- ADB Lifecycle / ADB 连接生命周期
- Pairing / 设备配对与无线调试
- Codecs / 编码与解码
- Remote Interaction / 远程交互性能与悬浮菜单
- Clipboard / 剪贴板同步
- Management / 管理功能
- Events & Shell / 事件、监控与 Shell
- Logging / 日志系统与维护
- Troubleshooting / 分层排障方法
- UI Design / UI 设计系统
- Bilingual Copy / 双语与文案
- Remote UI Analysis / 远程 UI 布局分析
- Engineering Rules / 工程与验证规则
- External Research / 外部研究与取舍
Technical topics appear here only after their page-level audit is complete. / 技术主题仅在完成逐页审核后加入侧边栏。