Boot your encrypted Android without keyboard

Boot your encrypted Android without keyboard

Last week i bought a Xiaomi MiPad 2 (it's a great tablet for 200€ !), it came without official keyboard so i've installed the google keyboard from the playstore

When i've installed Meraki System Manager i was forced to encrypt my data partition but after a reboot a pin for unencryption was prompted but without a keyboard !
Indeed, the google keyboard is installed but in the encrypted partition .... (/data/app) so after some search i found a solution but **YOU NEED ADB ACTIVE** on your tablet !

In the first time you need to boot your phone/tablet.

Connect your phone/tablet to your computer, and check if it recognized by adb

$ adb devices
List of devices  xxxxxxxxxxxxxx

If your phone/tablet is recognized your good !

So now you need to enter your pin through adb with 'input keyevent'

$ adb shell input keyevent 7  
$ adb shell input keyevent 8  
$ adb shell input keyevent 9  
$ adb shell input keyevent 10

in this exemple i write 0123 on the pin screen

here's the list of the keyevents for numbers

0 => 7
1 => 8  
2 => 9
3 => 10  
4 => 11  
5 => 12  
6 => 13  
7 => 14
8 => 15  
9 => 16

And finally press enter !

$ adb shell input keyevent 66

Congrats, android boot !

Okay our android has booted but now we need to fix the keyboard !

The solution is to move the keyboard from **/data** to **/system**.

Go to the adb shell

$ adb shell  
# Grant the su shell with superuser
> su
> mount -o remount,rw /system #remount the /system with read/write permissions
> cd /data/app  
> ls
# You should see the folder of the google keyboard, com.google.android.inputmethod.latin-1
# Create the folder structure with the existent structure from the /data/app folder
> mkdir /system/app/com.google.android.inputmethod.latin-1
> mkdir /system/app/com.google.android.inputmethod.latin-1/lib  
> mkdir /system/app/com.google.android.inputmethod.latin-1/lib/x86_64  
> cd /data/app/com.google.android.inputmethod.latin-1  
> cp base.apk /system/app/com.google.android.inputmethod.latin-1/  
> cd lib/x86_64  
> cp *.so /system/app/com.google.android.inputmethod.latin-1/lib/x86_64  
> chmod 755 /system/app/com.google.android.inputmethod.latin-1  
> chmod 755 /system/app/com.google.android.inputmethod.latin-1/lib  
> chmod 755 /system/app/com.google.android.inputmethod.latin-1/lib/x86_64  
> chmod 644 /system/app/com.google.android.inputmethod.latin-1/base.apk  
> chmod 644 /system/app/com.google.android.inputmethod.latin-1/lib/x86_64/*.so  
> reboot


_I've manually recreated all the folders and copy file per file because a simple mv/cp won't work (i don't know why and i didn't had the time to find why)_
After the reboot you should be able to enter your pin with the google keyboard :)