Arya
Arya

Reputation: 8965

Unlock screen with command

There is no way to disable the lock screen on my phone, and the screen has to be unlocked in order for my adb/monkeyrunner interactions to work. There is no password or pattern security on the device, but I have to drag the lock and move it to the right and the screen unlocks.

How can I do this with adb/monkeyrunner?

Upvotes: 0

Views: 11336

Answers (1)

AADProgramming
AADProgramming

Reputation: 6345

Did you tried using below command:

adb shell input keyevent 82  
#(KEYCODE_MENU)

This command would unlock the screen at first boot and would then allow further commands to launch applications and have them displayed on the screen.

But As of the Android 4.2.2 update, when you connect your phone to a computer, you are presented with your computer's RSA key fingerprint to open the adb connection. You also have the ability to permanently trust the computer, so you don't have to repeat this step upon every re-connect.

Starting with this Android version, "remote devices" (i.e. those you run ADB commands from) must be authorized by the Android device (i.e. the one those commands are runnin on) -- so your Android device can tell "trusted callers" from "malicious attackers".

On these and later version use below command:

adb shell input keyevent 26

This locks the screen if the screen is unlocked. If the screen is already locked, it wakes up the device.

There is sample script in this link which uses monkeyrunner to lock/unlock device screen.

Upvotes: 1

Related Questions