Skip to content

Management Features

星冉 edited this page Jul 21, 2026 · 3 revisions

Management Features

中文 · ADB Connection Lifecycle

Management provides device-operation capabilities after ADB is established. It does not require a video Surface or the complete scrcpy session. Management availability does not prove remote-control availability; management failure should first be classified as transport, permission, command, parsing, or remote-capability failure.

Current sections

SessionManagementSection defines seven sections:

Section Capabilities Main boundary
DeviceInfo System, display, storage, memory, battery, CPU, and network snapshot Read-model aggregation; does not repair connections
Utility Fixed wireless port, screenshot, reboot/power, app activation, DPI/resolution, animation, sleep/wake Device-changing actions require confirmation and results
Files Browse, upload/download, copy, move, rename, delete, preview/edit Path quoting, permission, temporary local files, large-file lifetime
Apps List, icons, details, launch, install/uninstall, clear data, export APK Helper/cache use and dangerous-action confirmation
Process Dynamic process list, search, memory, and termination Dynamic snapshot, not static app-cache performance
PortForward Saved session rules and active ADB forwards Port conflicts, symmetric setup/removal, session ownership
Command One-shot commands, presets, history, and interactive terminal Ordinary command versus streaming shell and PTY lifetime

Connection ownership

  • Pages reuse or create an exact transport-identity connection through AdbConnectionManager.
  • One-shot work uses AdbConnection.executeShell() or AdbShellManager; continuous output uses streaming or PTY APIs rather than polling to imitate a terminal.
  • Leaving the page currently retains an ADB connection protected by the foreground service; it does not imply automatic disconnect. A product change must implement this explicitly at entry and exit.
  • scrcpy and management no longer switch based on a delayed-ACK product profile. One network connection assigns work between primary and streaming lanes.

Data and performance

  • Device information is a DeviceDashboardSnapshot aggregated from multiple commands; loading and error are part of the snapshot.
  • Entering management starts two independent warm-ups: the /sdcard file snapshot and the application-data pipeline. Opening Files or Apps reuses the ready snapshot instead of starting the first ADB request during composition.
  • The application pipeline publishes user apps first, then the complete inventory and APK sizes, then details and cached/helper presentations. One pipeline mutex serializes refreshes, per-package mutexes deduplicate detail loads, and a cache revision drives Compose projections without performing ADB IO while filtering.
  • File snapshots are cached per directory. Manual or section refresh bypasses the cache for only that section; refresh tokens are not shared across Files, Apps, Process, and PortForward.
  • App and file state is scoped to the selected session and released when the management screen is disposed; a cache key or completed background task must not leak across sessions or devices.
  • Dynamic process, storage, and network data uses an explicit refresh token or trigger and must not execute unbounded commands on Compose recomposition.
  • Lists are virtualized. Large results are parsed off the UI thread and committed as stable models.
  • File, app, and process parsers should be testable pure functions; pages coordinate state and actions.

Interactive terminal

  • The command page owns one reconnecting raw shell with keepalive, an unbounded de-duplicated history for the current management-screen lifetime, and explicit clear/close behavior. Up/down keys or controls navigate history.
  • The toolbar and physical keyboard can send Ctrl+C. Full-screen interactive programs such as vi, nano, less, screen, and tmux are blocked because the raw shell does not provide their required terminal model; non-interactive and streaming commands such as cat, grep, sed, and tail -f remain allowed.
  • ANSI control sequences are removed. Output uses a fixed dark terminal palette, semantic success/warning/error tones, token highlighting, and the final grep/rg pattern for match highlighting; these colors are presentation only and are not parsed as command state.

Safety and failure

  • Uninstall, clear data, process termination, file delete/overwrite, reboot, and power-off require an explicit target and confirmation.
  • Shell arguments, paths, and package names use the quoting required by their command; raw user values must not become executable structure.
  • Present the failure stage, exit or exception summary, and an actionable suggestion. Logs may contain redacted commands but not tokens, clipboard content, or private-file content.
  • Connection closure cancels terminals, file transfer, and background loads. Old tasks must not update a page after the selected device changes.

Regression anchors

  • SessionManagementAppSizeTest, SessionManagementFileTypeTest, SessionManagementFileCopyTest.
  • SessionManagementNetworkInfoTest, SessionManagementProcessSearchTest.
  • SessionManagementPortForwardSupportTest.
  • SessionManagementTerminalHighlightTest: semantic output, grep matches, unsupported interactive commands, and session-lifetime history.
  • Device coverage for permission refusal, command failure, mid-operation disconnect, large directories/app lists, cancelled dangerous actions, and Android/ROM command differences.

Clone this wiki locally