1

I have the following problem: Somehow, this evening the touchscreen of my Sony Xperia Z broke. I have two thin cracks in the display and everything on the right side of the crack does not react. I have backup phones but I wanted to get back at least my photos. My device is encrypted with a passphrase, but I cannot type. My idea was, to unlock it from adb, so I can backup my data. I run SlimKat (SlimRom) with TeamWin Recovery.

When I enter recovery mode, I can see my phone:

$ adb devices
List of devices attached 
CB5A1PN2WU  recovery

But no commands work:

$ adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -

How can I get my data? Can I remotely control my keyboard? Sadly, everything is saved on the internal flash memory.

  • Welcome to the site, strix. Variations of this question have been asked before, you might try a search on "unlock with adb", although I didn't see an obvious solution for you. This post also has a detailed answer that may be useful to you. – TomG Sep 5 '14 at 0:40
  • I have read this before. The problem is: for all these solutions I need a working touch screen or a running phone. My phone is encrypted and turned off. I don't have either touch nor adb shell working... – strix Sep 5 '14 at 6:32
2

The Xperia Z supports USB-on-the-go, so with a USB-OTG adaptor and a USB keyboard you should be able to enter the encryption passphrase to boot the device.

  • Thanks, this is great! Worked like a charm, and getting all my data for 6$ was more than worth it! – strix Sep 6 '14 at 7:10
1

Although buying an OTG cable should work fine, there is in fact a way to unlock your device through ADB alone. Found this out the hard way when I included a character in my password that was not typable on the virtual keyboard and an OTG cable did not work for reasons I won't get into.

There are two ADB commands with which you can trigger keyboard events. I have tested these and they both work on the disk decryption key input screen. These commands are:

  • adb shell input text 'mytext' emulates typing mytext onto the keyboard. Note that it does not accept arbitrary text: you can mostly use this to send ASCII vowels, consonants and digits to the keyboard in this way. Special characters (e.g. ', #, ;) including the space bar using this command either require special syntax or are not accepted.
  • adb shell inputevent <event_number> emulates the event of a specific key press. This can be used to type certain special characters. The full list of key events can be seen in the Android developer documentation. Although the key events supported differ per Android version, all key events you would use for typing in a password have been supported since Android 3.0 (API level 11).

See this Stack Overflow answer for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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