Xiaomi USB Debugging: Security Settings and Install via USB
Fix Xiaomi, Redmi and POCO ADB problems. Turn on USB debugging (Security settings) and Install via USB, and fix INSTALL_FAILED_USER_RESTRICTED and screen control errors.
Xiaomi, Redmi and POCO phones running MIUI or HyperOS add two extra switches on top of normal USB debugging. Without them, ADB connects but some things fail: apps refuse to install, or taps and typing sent from the computer do nothing. This guide shows where the switches are and what each error means.
Step 1: turn on Developer options
- Open Settings › About phone.
- Tap OS version (HyperOS) or MIUI version seven times, until you see "You are now a developer".
- Go to Settings › Additional settings › Developer options.
Step 2: the three switches
| Switch | What it allows | Needed for |
|---|---|---|
| USB debugging | Basic ADB: shell, logcat, file transfer | Everything |
| Install via USB | adb install and installing APKs from a computer | Installing apps |
| USB debugging (Security settings) | Sending taps, swipes and key presses, granting permissions | Screen control, automation, typing |
The last two ask you to sign in to a Mi account, and on many models a SIM card must be in the phone when you switch them on. That is Xiaomi's rule, not an ADB requirement. Once switched on, they usually stay on.
Error: INSTALL_FAILED_USER_RESTRICTED
adb: failed to install app.apk: Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]Two causes:
- Install via USB is off. Turn it on as above.
- You did not confirm on the phone. With Install via USB on, the phone shows an install dialog for each APK, with a countdown. Unlock the phone and tap Install before it times out.
Error: taps and typing do nothing
With only USB debugging on, the screen can be mirrored but input from the computer is rejected. Tools may show an error such as:
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permissionTurn on USB debugging (Security settings), then disconnect and reconnect. This affects scrcpy, ADBKit, Appium and anything else that sends input.
Error: the switch is greyed out or asks for a SIM
- Insert a SIM card, wait for signal, and try again.
- Sign in to a Mi account in Settings › Mi Account.
- Turn on mobile data or Wi-Fi so the account check can complete.
Error: the phone is not detected at all
That is not a Xiaomi setting. Check the cable, USB mode and drivers in adb devices shows no devices. On Windows, install Xiaomi's USB driver or the Google USB Driver.
Using a Xiaomi phone with ADBKit
- Turn on all three switches above.
- Open ADBKit in Chrome or Edge and connect by USB, or over Wi-Fi with the ADBKit agent.
- Unlock the phone and tap Allow on the "Allow USB debugging?" prompt.
ADBKit's connection help mentions USB debugging (Security settings) for Xiaomi phones, because without it the live screen shows but does not respond to clicks or typing. Installing an APK from ADBKit triggers the same on-phone confirmation as adb install, so keep the phone unlocked.
Turn it off when you are done
Security settings let a computer control your phone. When you finish testing, switch USB debugging (Security settings) and Install via USB off again, or turn Developer options off completely.
For other install errors see adb install errors explained. For the bootloader screen, see Xiaomi fastboot mode.