Skip to main content

app_lock

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read whether the screen is locked, or lock and unlock it. A state rather than a power-button press: power is a toggle, so asking for it twice leaves the device where it started and you cannot tell which way it went. Both directions are confirmed by reading the device back. A device with a PIN, pattern or password cannot be unlocked from outside and says so rather than reporting success. Locking discards the refs from the last app_map.

Changes the device, the app or the session: readOnlyHint is false.

Arguments​

NameTypeRequiredWhat it is
devicestringDevice serial to target, e.g. "emulator-5554". Omit when only one device is running.
driverstring: uiautomator2, uiautomator, wdaDriver to use: "uiautomator2" (default for Android; fast, installs a server APK on first use), "uiautomator" (Android, installs nothing, slower, cannot type), or "wda" (WebDriverAgent: iOS simulators and iPhones).
statestring: lock, unlock"lock" or "unlock". Omit to read.

Examples​

Each is the arguments of a tools/call request; the first is shown whole.

Lock the screen​

{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "app_lock",
"arguments": {
"state": "lock"
}
}
}

Unlock it​

{
"state": "unlock"
}