Skill: fengyang0317/adb-controller (version 1.0.0)

--- name: adb-controller description: Control an Android device via ADB. Use when the user asks to control an Android device, tap, swipe, input text, or perform actions via adb. Automatically uses the adbServer configured in openclaw.json and takes screenshots. --- # ADB Controller This skill allows you to execute ADB (Android Debug Bridge) commands on a connected Android device and automatically retrieve a screenshot of the result. ## Configuration The user can configure the target ADB device/server in their `openclaw.json` (this is automatically read by the script): ```json { "skills": { "entries": { "adb-controller": { "adbServer": "192.168.1.100:5555" // or device serial } } } } ``` ## Usage To run an ADB command, execute the provided Python script: ```bash python3 ~/.openclaw/workspace/skills/adb-controller/scripts/run_adb.py shell input tap x y ``` You can pass any standard ADB arguments to the script. For example: - `python3 .../run_adb.py shell input text "hello"` - `python3 .../run_adb.py shell input keyevent 26` (Power button) - `python3 .../run_adb.py shell swipe 500 1000 500 500` ## Workflow (Mandatory) 1. Understand the user's intent and determine the correct ADB command. 2. Execute the user's requested action using the `run_adb.py` script via the `exec` tool. 3. The script will output the path to a newly captured screenshot. 4. **Send the Image:** You MUST use the `message` tool (with `action="send"` and `media="<path-to-screenshot>"`) to send the resulting screenshot to the user, allowing them to see the outcome of the action. Do not just output the file path.

path: scripts/run_adb.py
content: #!/usr/bin/env python3
import os
import sys
import subprocess
import time
from pathlib import Path

def main():
    args = sys.argv[1:]
    if not args:
        print("Usage: run_adb.py <adb command...>")
        sys.exit(1)
    
    # Read the ADB server address from the environment instead of parsing the JSON manually
    adb_server = os.environ.get('ADB_SERVER_ADDRESS')
    base_cmd = ["adb"]
    
    if adb_server:
        # If it looks like an IP address/port, attempt to connect first
        if ":" in adb_server:
            subprocess.run(["adb", "connect", adb_server], capture_output=True)
        base_cmd.extend(["-s", adb_server])
        
    cmd = base_cmd + args
    print(f"Running: {' '.join(cmd)}")
    
    try:
        result = subprocess.run(cmd, check=True, capture_output=True, text=True)
        print(result.stdout)
        if result.stderr:
            print(result.stderr, file=sys.stderr)
    except subprocess.CalledProcessError as e:
        print(f"ADB command failed with code {e.returncode}", file=sys.stderr)
        print(e.stderr, file=sys.stderr)
        
    # Take screenshot
    workspace = Path.home() / '.openclaw' / 'workspace'
    workspace.mkdir(parents=True, exist_ok=True)
    timestamp = int(time.time())
    screenshot_path = workspace / f"adb-screenshot-{timestamp}.png"
    
    screencap_cmd = base_cmd + ["exec-out", "screencap", "-p"]
    try:
        with open(screenshot_path, "wb") as f:
            subprocess.run(screencap_cmd, stdout=f, check=True)
        print(f"Screenshot saved to: {screenshot_path}")
    except Exception as e:
        print(f"Failed to take screenshot: {e}", file=sys.stderr)

if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)