Friday, June 3, 2011

Finding your mother's mobile phone in a large field

So your friend, wife, etc. (or in my case mother) has lost her cell phone in about 1.5 hectares (~3.7 acres for you americans) of field and forrest.
You happen to be 100km away... what do you do?

The only way she's really going to find it before dark is to walk around and look for it... but it would be much easier to find in all that wild space if it was ringing.

This is exactly what happened to my mother.
I started dialling my phone and letting it ring while she went out to walk around... this got pretty tedious after the first little while.

So after all that dialling I noticed that the phone would ring for 59 seconds and then hang up (likely a feature of my carrier) and being the lazy and dumb programmer I am, I decided there must be a way to automate all that dialling.

A quick search with google and sure enough there was!

Lucky for me, I use an Android phone and I have the development tools on my computer. This allowed me to write a small script that simply dialled her over and over again every 70 seconds.

This is what I did:
- I use a Mac Pro (but this should work on linux with a bash shell as well, Windows users are on your own).
- You need the Android SDK installed.
- You need an android phone (I am using a Nexus S currently).

Here is the quick and dirty shell script I wrote to to the job:

#!/bin/bash
echo "Calling every 70 seconds..."
c=1
while [ 1 ]
do
adb -s 173166299F8500EC shell service call phone 2 s16 "13335554444"
sleep 70s;
echo "Calling again ($c) ..."
(( c++ ))
done

The -s ### is the identity of the phone, I have several devices connected to my computer and I needed to indicate which one I wanted to act upon.
The last number in quotes is the number to dial (redacted for security).
The 70s is 70 seconds of course.

This would dial the phone and wait 70 seconds (about 11 seconds longer than the phone would ring), then dial it again.

Warning: If you use this as a prank on someone, I'm not responsible for the hole in your shorts when your ass gets kicked; or if the phone company cuts you off after your buddy complains. Besides, think about it, they are going to know who is doing it to them when your number pops up on the screen.

Oh... and yes... she did find her phone in the end.