Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Previously with Android 4.1, doing something like:

adb shell input keyevent 82  
#(KEYCODE_MENU)

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

With 4.2, within 10s of boot, the lockscreen dims to black. Issuing the same ADB command no longer works and the screen remains blank.

If I manually press the menu key, this brings the screen back on, and I can then issue the keyevent to unlock the screen.

Any ideas how I can bring the display back up from ADB and unlock the screen from there?

Thanks

share|improve this question
    
There is a list of keyevents here and here, if anyone needs it for reference... –  Wilf Jan 9 at 23:44

2 Answers 2

If you are on 4.2.2, you might want to read e.g. ADB Whitelist As of the Android 4.2.2: 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". You can also find this in detail on this article on AndroidPolice:

The way it works is pretty simple - when you connect your PC to your Android device via USB, Android gets your PC's RSA key (an identifier token). In Android 4.2.2, when you have USB debugging enabled, this now causes a prompt to appear on connection, seen below.

Authorization Prompt
(image source: AndroidPolice)

Update from the comments below:

Additionally, as Shurane pointed out, behavior of adb keyevent seems to have changed with Android 4.2.2: while before adb keyevent 26 was a dedicated "screen-off", and adb shell input keyevent 82 a dedicated "screen-on" switch, now adb keyevent 26 is a toggle which turns the screen off (when it's on) and on (when it's off), as noted by Pepelac.

share|improve this answer
    
Even after adb whitelisting, sending a keyevent in 4.2.2 doesn't work the same way. –  Ehtesh Choudhury Apr 26 '13 at 20:21
    
Your comment suggests it works in a different way then. Do you mind to elaborate a little more? Might even be worth a separate answer. –  Izzy Apr 26 '13 at 20:25
    
Well, adb shell input keyevent 26 turns the screen off and adb shell input keyevent 82 turns the screen back on, right? But for 4.2.2, only keyevent 26 seems to work. keyevent 82 doesn't work for whatever reason. –  Ehtesh Choudhury Apr 26 '13 at 20:37
    
I see. Not having a 4.2+ device, I cannot check myself -- but maybe somebody else has some hints on that. –  Izzy Apr 26 '13 at 20:41
3  
@Shurane adb shell input keyevent 26 turns it off/on –  Pepelac May 6 '13 at 12:31

The trick is in 4.4.x and/or other systems you have to send an Enter after the command or else you have to wait x sec/min.

So do it like:

adb shell

@shell: input keyevent 26

@shell: 

@shell: exit

This will work in any case, I think.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.