Connecting
The CLI reaches the app over USB, does its work and disconnects. There is nothing to open on the phone first: the app answers any computer while the phone is unlocked, and refuses while it is locked. The wire format is in Connection protocol.
A connection adds convenience, not trust. Every change is a signed bundle, checked exactly as an imported file is (Acceptance); the rest is read-only (status, the config, the waiting change, the event log).
Two transports
- adb. When the phone has USB debugging on (not armed, or a dev build, or an armed phone during a debugging window, below), the CLI wakes the app with a broadcast (
am broadcast -a dev.t342.quitlock.LISTEN) and connects to its socket throughadb forward. Only the adb shell user can send the broadcast (the receiver requiresandroid.permission.DUMP) or connect to the socket. The app listens for 30 seconds after the last connection ends. - The USB accessory (Android Open Accessory, Linux only). Used when adb cannot be: an armed phone keeps adb off. The CLI switches the phone into accessory mode, and Android hands the accessory to a screenless QuitLock activity. The first time, Android asks which app to open for the QuitLock CLI; choosing QuitLock and Always means it never asks again. Windows cannot do this switch while its own MTP driver holds the phone.
--transport auto (the default) uses adb when the phone has it on, otherwise the accessory, and never switches a phone that adb can already reach (so its file transfer mode stays as it is). --transport adb and --transport usb force one.
The CLI fails at once, with what to do, when it cannot connect: no phone, adb not authorised on the phone, adb offline, no USB permission on this computer, an armed phone with adb off and no accessory. It waits only for two things, a minute each, and says so: the phone to be unlocked, and Android’s accessory chooser.
The debugging window
An armed phone in a release build has adb off (invariant 13). For a computer that cannot use the accessory, the main screen has Allow USB debugging (5 min):
- The app runs the self-check, lifts the debugging restriction, turns adb on and starts a 5-minute timer. Installs from then on count as adb installs.
- While it is open, the app checks every second for what an adb shell could change against it: a proxy, an app installed over USB, a suspended app released, its own checks cancelled or restricted. On finding one it closes the window at once.
- It closes when the timer runs out, on Turn off (on the screen or in the notification), or on tampering. Closing turns adb off, puts the restriction back and runs the full self-check.
Opening and closing are both in the event log (debug_window_open, debug_window_close with the reason), so a partner can see how often it was used. If the app’s process dies with the window open, a one-off background job turns adb off when the limit passes, and the next start logs the window as closed.
Platform facts, item 16, lists what an adb shell can and cannot change.
What a connection exposes
Any computer the unlocked phone is plugged into can read the status, the config and the event log, and can send bundles, which the phone rejects unless they are signed by an enrolled key. Requiring the phone to be unlocked keeps a phone left on a desk from being read by whatever it is plugged into.
File fallback
Every CLI command that sends something accepts --to-file <path> (or --out), which writes the signed bundle instead of sending it. The user copies it to the phone over USB file transfer and taps Import bundle from file (the system file picker, so no storage permission). This works when neither transport works on the computer.