2

Using the adb shell I can input text on the phone. But that does not work, if the phone's display is off. I have to press the home button first and unlock the screen for this to work. How can I automate this with the adb shell without adding additional code on the device?

adb shell input keyevent KEYCODE_HOME

Unfortunately, that does not work at all.

Mahoni
  • 7,088
  • 17
  • 58
  • 115
  • http://forum.xda-developers.com/showthread.php?t=865876 Looks like it may work, have not tried it yet. – brett Jan 30 '13 at 21:54
  • @brett Thanks brett, it would be nice if this can be done without additional code (edited my question). But I am afraid this is not possible. – Mahoni Jan 30 '13 at 21:55
  • You could always reboot the phone , would do the trick but you'd have to wait.... – brett Jan 30 '13 at 22:00

2 Answers2

1

You could check the display power state with dumpsys power and then if needed emulate the power key press to wake it up.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
1

Use adb shell input keyevent 26 to wake up the device. (Source) Now do the text input or whatsoever you want to do. And, unlocking can also be done using input command but different locks requires different technique, so you'll have to Google a bit, or provide the info here so that I/others can answer it.

The same command can put the device to sleep as well.

Community
  • 1
  • 1
user47
  • 1,080
  • 11
  • 28