How I killed my Android phone and brought it back to life using ADB

Yesterday, I rebooted my rooted Android phone, the Lonovo P770, and I could not get the keyboard to work because the Language & Input settings kept crashing. I tried to do a factory reset but forgot that I uninstalled some of the Lenovo's stock apps including the stock launcher and keyboard. So, after the reset finished, the phone was useless because I could not open any apps.

Basically, I couldn't do anything with my phone except for the settings app. But as a Linux user (proudly face :D) I wondered there is any way to install and configure my phone from a computer. And here it is:

The Android's ADB

ADB allows me to do a lot of things with my Android phone from a computer including install apps (apk packages) and apply some settings (for example: change keyboard, set language...). Here are the steps:

1. Install adb utilities in Ubuntu 14.10 (or 14.04)

$ sudo apt-get install android-tools-adb android-tools-fastboot

2. Setup driver for my phone (Lenovo P770)

a. Check my phone vendor id and device id:

$ lsusb
...
Bus 002 Device 005: ID 17ef:7435 Lenovo A789 (Mass Storage mode, with debug)
...

b. Create the driver:

$ sudo nano /etc/udev/rules.d/51-android.rules

#Lenovo
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", ATTR{idProduct}=="7435", MODE="0666", GROUP="dangtrinhnt"

c. Restart udev:

$ sudo service udev restart

3. Connect my phone to the computer via USB, open the terminal and check if adb recognizes my phone

$ adb devices
List of devices attached 
0123456789ABCDEF        device

4. Download and install the launcher (solo launcher) apk

$ adb install solo.apk

Notes: I had to restart the bootloader to make the launcher working:

$ adb reboot-bootloader

5. Download and install the Hacker's Keyboard apk

$ adb install hacker.apk

6. Use Hacker's Keyboard as the phone's input method

a. List the phone's input method:

$ adb shell ime list

org.pocketworkstation.pckeyboard/.LatinIME:
  mId=org.pocketworkstation.pckeyboard/.LatinIME mSettingsActivityName=org.pocketworkstation.pckeyboard.LatinIMESettings
  mIsDefaultResId=0x7f090005
  Service:
    priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
    ServiceInfo:
      name=org.pocketworkstation.pckeyboard.LatinIME
      packageName=org.pocketworkstation.pckeyboard
      labelRes=0x7f0800c0 nonLocalizedLabel=null icon=0x0
      enabled=true exported=true processName=org.pocketworkstation.pckeyboard
      permission=android.permission.BIND_INPUT_METHOD
      flags=0x0


b. Set the input method:

$ adb shell ime set org.pocketworkstation.pckeyboard/.LatinIME

7. Change the language to English (because it's Vietnamese by default)

$ adb shell "su -c 'setprop persist.sys.language en; setprop persist.sys.country GB; stop; sleep 5; start'"


After all of the above I can add my Google account and install apps from Google Play Store and bring my phone back to life!!!

Woohuuu!!! \m/\m/\m/


References:

http://www.droidviews.com/setup-adb-usb-drivers-ubuntu-easily/
http://bernaerts.dyndns.org/linux/74-ubuntu/328-ubuntu-trusty-android-adb-fastboot-qtadb
http://bernaerts.dyndns.org/linux/74-ubuntu/245-ubuntu-precise-android-adb-fastboot-qtadb
http://stackoverflow.com/questions/8495487/switch-language-programmatically-on-an-android-device
http://android.stackexchange.com/questions/47948/how-to-change-input-method-with-ime-command
http://www.jimmycollins.org/blog/?p=529
http://stackoverflow.com/questions/8495487/switch-language-programmatically-on-an-android-device


Comments