Thursday, April 11, 2019

No touching! making calls and SMS with your touch-broken Android phone

the cute Android; trapped behind a broken screen

Crack!

Recently my G9 4G faced an unfortunate (and unspeakable-of) accident; the screen was shattered, and worse, it was rendering upside down (more precisely, vertically mirrored). But even worse, the touch was working upright (upside up)!

To give you an idea of the situation, when I swipe down, the menu unrolls upwards from the bottom of the screen. Then, when I tap the top right icon on the menu, what gets tapped is the icon that appears (upside down, of course) on the bottom right of the screen.

Not a very usable - not to mention user friendly - configuration ;)

Typing without a screen?

As if that wasn't enough, the top two-thirds of the display was completely blacked out - meaning that I could not read anything from the lower two-thirds of the screen; which, incidentally, happens to be where all the keyboard and dialer stuff is.

No way to make a call or type an SMS - "smart" phone, eh?

I didn't have a spare phone or modem/router at hand, so I was literally grounded - muzzled and cut off from the rest of the world.

USB debugging - to the rescue!

Luckily, I had USB debugging enabled; like I always do, as soon as I get hold of a new device.

Frankly, I strongly recommend all of you to have USB debugging enabled on your Androids - authorized for your personal computers. It can save you immense trouble at hard times.

am and service: beauties in the adb shell castle

Once you are in, via an adb shell, you have access to a rich array of Android operational-level commands - most of which work without root access.

am is one of them, which can launch an Android activity (such as the dialer) with desired parameters (yeah, you guessed it; the phone number).

service is another, which allows you to directly invoke methods defined in different Android services, via the command line.

Naturally, my first reflex was to google for "android send SMS via ADB"; which was actually what led me to am and service, and to the actual userland commands.

Sending an SMS with service call: no touching!

Taknok had written an awesome Stack Overflow answer, so I had to look no further.

I did have to dig down the Android 7.0 ISms.aidl source code - because the G9 runs stock 7.0 - in order to decide the actual parameters that I need to pass in. (It was too late when I spotted Taknok's already-written comment on 7.0.)

adb shell service call isms 7 i32 2 s16 "com.android.mms.service" \
    s16 "0911911911" s16 "null" \
    s16 'Yo, ma 4n display z bust. Call ya l8r on a pay 4n! tc' \
    s16 "null" s16 "null"

Here I use i32 2 to send the SMS via my secondary SIM card (G9 is dual-SIM).

Making a call with am: just one touch... or no touching, if you insist!

Again, Stack Overflow helped:

adb shell am start -a android.intent.action.CALL -d tel:"0911911911"

Here there's a bit of a setback, because Android pops up a SIM selection dialog before the call; since my touch was still working fine, I managed to tap the correct SIM card entry with some guesswork. (I couldn't find a way to pass the SIM number to the CALL action, and I suspect it might not be even possible.)

If your touch is totally dead, you could still use adb shell input tap {x} {y} to tap the correct entry - with some trial-and-error.

So there!

You never know when you're gonna lose the display or touch on your Android. Trust me, you never know.

And when it happens, you better be ready.

Bookmark (or earmark, whatever) this post; or the StackOverflow links, if you would rather; enable USB debugging; and wait till the time comes ;)

No comments: