DEV Community

Cover image for I Vibe‑Coded My Way Into a Broken Android with ChatGPT & Python
hiruthicSha
hiruthicSha

Posted on • Originally published at ai.plainenglish.io

I Vibe‑Coded My Way Into a Broken Android with ChatGPT & Python

It started with a crack, literally…

My friend dropped her phone on asphalt, and after six long years of brutal survival, the screen finally decided it had had enough.

We're talking six years of tech abuse. No screen protector, no hard case, multiple drops on every imaginable surface. We used to joke that this phone was the true successor to the legendary Nokia brick. This device had more scars than the guy fighting the final boss.

But this time it was different, guess it's just Wrong asphalt, wrong time.

The display still lit up, but the touchscreen? Possessed. Ghost taps everywhere, especially on the bottom edge, where it developed a deep obsession with hammering the Android "Back" button, like it was desperately trying to erase its own existence.

To make matters worse, she lives life on maximum risk mode, no cloud backup, no SD card, no local copy. Just raw, unprotected digital chaos.

Replacing the screen? Not happening. The model was so old, it should've come with museum tags.

That's when the idea struck: What if we never touch the screen again?

Armed with ChatGPT, Python, ADB, and a whole lot of vibe coding, I hacked together a way to remotely control the phone using ADB. I ended up writing a tool that let me tap, swipe, and type on the phone, all by clicking on screenshots. And it actually worked.

The Problem

We figured this was finally the moment to retire the old warrior and get a new phone, repairing it would've been expensive, given its age, and even then, it was living on borrowed time which makes the use even more risky.

We had one mission: get the data out.

But that was easier said than done. Every time we tried to open an app or navigate the UI, the ghost taps would kick in, slamming the back button, opening random apps, or just spamming nonsense. It was like trying to defuse a bomb while someone kept pressing "Cancel".

Since a screen replacement which was our easy way out, wasn't an option, we thought about buying a USB-C to USB-A (female) adapter to plug in a mouse and control the phone that way. But that meant waiting for the adapter. Since I had an idea in mind, I challenged myself: "Let me try fixing this before you finish that venti iced coffee."

Idea

I've seen people doing things with ADB to control things like tapping the screen and opening apps or installing. Since I still had the android development setup in my laptop, I quickly found the platform-tools location in my android SDK directory and tried connecting the device.

Thankfully, the phone already had Developer Options and USB debugging enabled, from back when I used it to test a few apps. And since it was running an older version of Android, the Developer Options hadn't hidden themselves again, like newer versions love to do.

That meant ADB was almost ready to roll, the only hurdle left was tapping "Allow" on the "Trust this computer?" prompt that appears the first time you connect ADB from a new machine. After the painful yet fun 5 minutes of a pleasant Tuesday evening, we were able to click the allow button before the ghost tapping started!

Attempt #1: Screenshots, Coordinates, and Pain

With USB debugging enabled, I knew I could control the phone using ADB, this means I could simulate taps and swipes without physically touching the screen.

I started by blindly guessing the coordinates, because hey, what could go wrong? Turns out: everything.

I ran commands like:

adb shell input tap 500 1000
Enter fullscreen mode Exit fullscreen mode

…and hoped it landed on the right button.

Sometimes I'd get lucky and open the correct app. Most of the time, though, I was just poking empty pixels.

So I leveled up, just a little.

I began taking screenshots with ADB:

adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
Enter fullscreen mode Exit fullscreen mode

Then I'd open the image in MS Paint, hover over the UI element I wanted to tap, grab the x and y coordinates, and fire off an ADB tap with surgical precision.

It was progress… but every single tap felt like a full-blown side quest: screenshot, open Paint, find coordinates, run command, observe results, repeat.

The whole process felt like trying to control a wild animal using chopsticks.

There had to be a better way. I decided it was time to automate the chaos. And me being me, if something has more than zero steps, I'm automating it. You'd know that if you've been following along and reading these stories:

Meme generated with imgflip.com

Attempt #2: Vibe coding a tool

The goal is to be able to click on the phone screen from my machine using ADB. So, my requirements are:

  1. Render the phone screen on my machine by taking a screenshot.
  2. Get the coordinates when I click on the screen and generate an ADB command, and send it.
  3. Need a way to type, for input fields like phone numbers or login forms.
  4. Need a way to swipe to unlock by pattern.

So I spent maybe like 5 mins creating the prompt for my requirements and asked ChatGPT. After reviewing the code, and asking it to cover a few cases and few adjustments later, I had a tool that could mirror my phone. Now, after finding the sweet spot between the code crashing and having a steady stream of screen updates, I had around 20–25 FPS.

And that's it. From there, I shared my script with her, gave her instructions on how to use it, and in under 30 minutes, the WhatsApp backup was under control, and other backups were also started.

Lessons Learned at a Coffee Time

In the end, we didn't need a new screen, a USB adapter, or even a working touchscreen.

All we needed was a bit of Python, some OpenCV magic, and a spark of vibe coding spirit.

With a little help from ChatGPT, I turned a random idea into a working tool that saved data from a decade-old phone powered purely by commitment and sheer f***ing will.

And yes, for the record, I did finish before she finished her coffee.

Never thought I'd say this, but coding does make life a little better.
That is… as long as you use it wisely, and actually understand what your LLM is spitting out.

So, always enable USB debugging.

That's a joke, please don't. Backup regularly and keep your data safe.
Here is the script: http://gist.github.com/hiruthicShaSS/e2ce710032199729b16160eb040e5c8d


Stay Curious. Adios 👋
Cover image generated with ChatGPT.

Top comments (2)

Collapse
 
samaldis_18 profile image
Sam Aldis

Hey I love the concept but just wandered why scrcpy wasn't an option?

Collapse
 
dotallio profile image
Dotallio

Love the coffee-powered hacking energy here. Any plans to make the tool even more user friendly or use it for other vibe-coding rescues?