android-vdisplay
Skill638 starsChanged 3 months agoMITView on GitHub
Create an on-device virtual display ("second screen") on an Android phone running Minis via local wireless ADB, render it inside a floating Picture-in-Picture overlay window on the main screen, and let the agent launch apps, inspect the widget tree, take screenshots, and inject touch, swipe, text, and key events while allowing the human user to take over at any time (with automatic HTTP 423 mutual exclusion). Powered by scrcpy-server (trusted virtual display) + a companion overlay APK. Trigger this skill whenever the user mentions "second screen", "virtual display", "virtual screen", "PiP", "picture-in-picture", "floating window automation", "background app automation", "scrcpy virtual display", "operate an app without occupying the main screen", or wants the agent to control Android apps on the same phone with human takeover support.
In this repository56 other files it gives its agents.
- android-devSkill
- android-ui-automationSkill
- apple-remindersSkill
- appstoreprice-hubSkill
- asc-cliSkill
- bilibili-hubSkill
- Clash 控制器Skill
- cloudflare-dnsSkill
- codex-imageSkill
- codex-on-ishSkill
- contact-vcard-extractorSkill
- deepseek-usageSkill
- disk-scanSkill
- doubao-ttsSkill
- douyin-downloaderSkill
- evidence-chain-builderSkill
- exa-searchSkill
- free-ttsSkill
- fucai3d-latestSkill
- generative-ui-minisSkill
- github-sync-helperSkill
- health-sleep-analysisSkill
- health-training-checkinSkill
- hyperframes-cliSkill
- hyperframesSkill
- korea-stockSkill
- maimai-hubSkill
- memos-apiSkill
- nano-bananaSkill
- notion-hubSkill
- openstreetmap-markerSkill
- pdf-converterSkill
- production-agent-publicSkill
- qbt-hubSkill
- quark-hubSkill
- reverse-dcfSkill
- self-improving-agentSkill
- shortcuts-builderSkill
- shortcut-share-fileSkill
- spotify-hubSkill
- stock-fund-flowSkill
- stock-priceSkill
- tavily-searchSkill
- tg-hubSkill
- todoocardSkill
- twitter-downloaderSkill
- twitter-x-hubSkill
- us-stockSkill
- web-content-extractorSkill
- web-searchSkill
- weibo-hubSkill
- whenpeakSkill
- xianyu-hubSkill
- xiaohongshu-hubSkill
- youtube-downloaderSkill
- ytmusic-hubSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Every command outputs JSON or an explicit ERR: message and exits non-zero on failure.
- Very specific: line 34
Self-healing: If no frame is rendered within 3 seconds on first start, start.sh saves diagnostic logs and rebuilds once automatically …
- Very specific: line 61
When the user stationary long-presses the floating card for 1 second or taps the top-right Stop button, human takeover begins and all agent …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
android-vdisplay: On-Device Virtual Display + Floating PiP Overlay + Agent Control
On the same Android phone: scrcpy-server creates a trusted virtual display over local ADB (shell), apps run on that virtual display while rendered inside a floating Picture-in-Picture card on the main screen, the agent drives apps via scripts, and the human user can long-press the card to take over at any time.
Update First When Errors Occur
Whenever a script fails or behaves unexpectedly, update to the latest version first: reinstall the latest android-vdisplay skill package and run start.sh, which automatically checks and upgrades the on-device APK. Run sh scripts/agent.sh version to verify version parity. If it still fails after updating, follow the stage and hint fields in the JSON output.
Shortest Path (Follow Directly — Do Not Improvise)
SK=/var/minis/skills/android-vdisplay/scripts
sh $SK/start.sh # Auto-install -> pick free port -> start server/bridge/overlay -> wait for rendered frame
sh $SK/run-app.sh com.android.chrome # Launch app and verify it is in the foreground on the virtual display
sh $SK/agent.sh ui # Read widget tree first: 1 node per line with center c=(x,y) in 540-wide coord space
sh $SK/agent.sh ui find 7 # Match by text/desc/id; or run `ui-tap 7` to find and tap in one step
sh $SK/agent.sh tap 270 480 # Tap using c=(x,y) from `ui`; verify with `ui find` afterwards
sh $SK/agent.sh shot /tmp/s.jpg jpg 70 # Fall back to screenshots only when `ui` is empty/insufficient (games, WebView, Flutter, custom UI)
sh $SK/stop.sh # Stop and exit cleanlyEvery command outputs JSON or an explicit ERR: message and exits non-zero on failure. Follow the hint field in the JSON output directly instead of crafting raw adb commands by hand.
Prerequisites (One-Time)
Android 10+; Alpine requires adb curl python3 (apk add android-tools curl python3); adb devices must list the phone itself (via Wireless Debugging — see references/setup.md). When multiple devices are attached, set export SERIAL=<serial>; set export ADB_CONNECT=ip:port for automatic reconnection. Keep the phone screen unlocked and awake.
start.sh Status & Stages
- Success:
{"ok":true,"display":N,"port":P,"reused":false}.ok:truemeans the virtual display is created AND the decoder has rendered at least one frame (rendered>0), so it is ready for immediate interaction. - Reuse: If the virtual display for our
scidis already healthy (APK and server alive,ready:true, not closed, matching resolution),start.shreuses it immediately ("reused":true, ~1 s, without restarting anything). Force a fresh rebuild withstart.sh --freshorVDISPLAY_FRESH=1. Display IDs monotonically increase within a boot session — this is standard Android behavior, not a resource leak. - Self-healing: If no frame is rendered within 3 seconds on first start,
start.shsaves diagnostic logs and rebuilds once automatically ("healed":true). If it still fails, it exits withstage:"render". Diagnostic logs are saved under~/.android-vdisplay/logs/<timestamp>/(last 5 runs kept;stop.shalso saves logs) and reported insavedLogs. - Failure stages (
stage/hint/log):adb: Device disconnected or unauthorized (follow references/setup.md).server/bridge: Checklog; retrying once usually resolves transient races.display: Typically caused by a locked phone screen or bridge connection failure; unlock the phone and retry.frames: Overlay did not receive video packets; verify overlay permission and retry.render: Video packets arrived but the decoder rendered no frames (screenshots would be solid black); already retried once — inspectsavedLogs.
Core Operations (agent.sh)
| Command | Description |
status | ready:true = decoder has rendered a frame (rendered>0); frames is packet count only; also reports dropped, decodeErrors, port, humanActive, error |
shot [path] [png|jpg|webp] [q] | Capture screenshot (default width 540); jpg 70 is recommended for vision inspection to save latency and tokens |
ui [find TEXT] [clickable] [editable] [json] / ui-tap TEXT | Read virtual display widget tree (1 line per node with center point); ui-tap taps only when a single unique target matches |
tap x y / swipe x1 y1 x2 y2 [ms] | Coordinates in the same reference space as shot and ui (default width 540, proportional height) |
key <code> | 4=BACK, 3=HOME, 66=ENTER, 67=DEL |
text "content" | Injects ASCII character by character; non-ASCII (e.g. CJK) is pasted automatically via clipboard |
title "label" | Update the top-bar task pill on the floating window so the user sees what the agent is doing |
window x=.. y=.. w=<dp> / hide / show | Move/resize window; hide moves it off-screen while keeping the virtual display running and controllable |
version / resume | Check version parity; resume clears human takeover / stopped state |
run-app.sh <package>: Returns ok:true only after verifying the app is in the foreground on the virtual display; otherwise reports the exact reason (not installed vs. did not reach foreground).
Core Workflow & Rules
- Workflow:
start->run-app-> loop (uito locate target -> one action ->ui findto verify, orshotwhen needed) ->stop. - Widget Tree First (
ui): Always preferagent.sh uito inspect the virtual display's widget tree (0.12.0+, see references/accessibility.md); fall back toshotonly when nodes are empty or missing the target. Never runandroid-a11y-cli ui dump/findoruiautomator dumpfor the virtual display — both ignore--displayand always return main-screen nodes. Ifuireturns HTTP 503 (service disabled),agent.shautomatically heals it once; if it still fails, followhintor fall back toshotwithout looping. Inform the user before first use: to read the widget tree,start.shappends a read-only accessibility service (Minis Second Screen) via ADB without touching other services, andstop.shremoves it. - Human Takeover & HTTP 423:
- When the user stationary long-presses the floating card for 1 second or taps the top-right Stop button, human takeover begins and all agent control endpoints return HTTP 423 (
human has control/stopped by user). - Upon receiving 423, never retry in a loop. Pause immediately, inform the user in chat, and wait until the user taps "Hand back to AI" or asks you to continue. See references/takeover.md.
- When the user stationary long-presses the floating card for 1 second or taps the top-right Stop button, human takeover begins and all agent control endpoints return HTTP 423 (
- 10-Minute Idle Auto-Close: After 10 minutes with no agent requests (including
statuspolls) and no human touch on the floating window, the virtual display closes automatically (showing a countdown in the title bar during the last minute). Once closed,/statusis unreachable; runstart.shto start a new session. Customize the timeout viaIDLE_MIN=30 sh $SK/start.sh(IDLE_MIN=0disables auto-close). Always runstop.shproactively when finished. - Black Screen Triage: If screenshots are solid black (identical tiny JPEG byte size) or the floating card stays on "AI standby" with no video, take a main-screen screenshot to confirm, then run
stop.sh && start.shdirectly — do not retry screenshots in a loop. Since 0.11.0,start.shdetects and heals this automatically.
Progressive Disclosure References
- references/setup.md: Local Wireless Debugging pairing and connectivity guide
- references/takeover.md: Floating window gestures (long-press takeover, pinch zoom, edge docking) and HTTP 423 rules
- references/accessibility.md: Virtual display widget tree (
ui) design, silent activation, and auto-healing - references/agent-api.md: Built-in HTTP API (
127.0.0.1:28080) endpoints and response schema - references/architecture.md:
scrcpy-server+ TCP Bridge + APK cross-process architecture
Known Limitations
Verified on Google Pixel 4a (Android 13) and Pixel 6 (Android 17); virtual display widget tree via ui requires ADB WRITE_SECURE_SETTINGS (custom-drawn UI / games / Flutter require shot); unavailable while the phone is locked; video uses local loopback H.264; non-ASCII text injection overwrites the system clipboard.
Directory Layout
scripts/ (start, stop, run-app, agent, install, common, device-run), assets/ (skilled.apk, scrcpy-server.jar 5.0.1, skilled-shell.jar, VERSION), references/. Source repository: https://github.com/OpenMinis/scrcpy-skilled
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

