Emulating Broken Touch Screen with Adb

How to fix Broken Touch Screen Android

It’s already almost 10 years since the first Android phone was released. Since then, amount of buttons on a phone was pretty minimal, touch screens have seized the phone world.

Since my first Android phone, I was not the one changing phones every year, so many of them ended up requiring to be replaced rather than just be upgraded to a new cool phone.

What is interesting, that the most common issue was the mentioned above touch screen. It happened, that some parts of the screen were not accessible as they used to be. Unfortunately, not all applications allow us to change the orientation of the screen.

This short note is just a reminder for myself if in the 2-3 year I find myself again with a half-functioning touch screen.

Let’s emulate the touch screen

If one can not use some parts of the screen, there must be some way to hack it or emulate these touches or inputs. Fortunately for me, there was a way and this way is using Android Debug Bridge (adb)

As the name stands, the tool is used for debugging some of the activities on your connected phone. For my problem, I just wanted to use it as an input emulation.

Initial setup for Mac OS

Since I use Mac OS as my main operating system. These instruction are for Mac OS, but one can also find similar manual for Linux or Windows.

  1. Install adb, if you do not have Android Studio or Android SDK
    StackOverFlow Instruction: How to install adb on Mac OS

  2. Add platform-tools to your path

    echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
    echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
  3. Refresh your bash profile (or restart your terminal app)

    source ~/.bash_profile

Emulation

Once everything is configured, now we can actially start emulating required actions

First, let’s list all devices:

adb devices

You should see something like this:

List of devices attached
AA42L1A12345	device

If you have multiple connected devices you would need to specify a name of device with adb -s device-code your-command option like. You need to allow USB debugging in order to be able to execute commands on your phone. if you see unauthorized - try to disconnect USB and re-enable debug.

Now we can input text:

adb shell input text "something-amazing-you-can-not-type-anymore"

We can even also emulate every keycode separately:

adb shell input keyevent KEYCODE

For the list of key codes look at another topic at StackOverflow