View Single Post
Posts: 27 | Thanked: 73 times | Joined on Nov 2009 @ The Netherlands
#1
Alright, i think i speak for a lot of us that losing our phones would be disastrous. Either because you lose it, or it was stolen. Nobody wants to go through that.

I've made some strides in making sure that you can get it back.
It's important to note that aside from the first step, the rest can be done REMOTE. So if you really have lost your phone you can do all of the steps while it's still lost but responding.

This guide will also help if you've allready lost it but can still log in.

Required:
*a modicum of unix/linux knowledge, you'll need to know how to use SSH and edit files from the commandline
*ssh installed on the phone
*a remote server, ssh/ftp etc.

DISCLAIMER: Using the below could end in tears/flames/the end of the world! Also my code will most likely be ugly/tear inducing/vommitable so use at your own risk


The most important step is making sure you know what your phone's public IP is. Most mobile providers will randomize your IP on each connection but that's what this whole thing is about. If you know this, and you can still login, you have a shot at recovery.

To be able to find it, you could install a dynamic DNS client, or you can do the following:
Locate the /etc/network/if-up.d/00_disable_icmp_echo_reply and add the following in between the bottom echo and exit lines:

Code:
ifconfig gprs0|awk '/inet addr/ { print $2 }'|awk -F: '{ print $2 }' > /tmp/n900ip
The line below that you add a way to make sure the file is stored on the remote server. You can do this with SCP for example:

Code:
scp /tmp/n900ip [user]@[remote computer]:/[remote location]
Or use any other way to make sure this file is stored somewhere other than the phone, and accessible to you since it contains the public IP of your phone.
Adding these lines to this script will make sure it's activated every time your phone makes a gprs/3g connection, storing the ip offsite every time.

Check to make sure this works by disconnecting and reconnecting your connection on the phone and checking the file it uploaded to your server. After you do this try logging in to your phone with this IP using SSH. Did all that work? Great, rest easy for now.



IT'S GONE! I CAN'T FIND IT!


Alright, if everything went as planned you'll have your public ip. Try the SSH connection you tested and login.


IT WORKED! Now what?

First things first. If your phone is moving, it very probably isn't in your posession anymore.
Check the accelerometers to see if this is the case with:

Code:
watch cat /sys/class/i2c-adapter/i2c-3/3-001d/coord
If you see those numbers (x,y,z) vary, then skip straight to the GPS step.


Ok so it's not moving, it could be you just left it in a pocket or somewhere close.
Let's make it make a noise. If you have mplayer you could do a:

Code:
mplayer /home/user/MyDocs/[location with an MP3]
Or make it vibrate with:

Code:
dbus-send --print-reply --system --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_activate string:PatternIncomingCall
and use:

Code:
dbus-send --print-reply --system --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_deactivate string:PatternIncomingCall
to stop vibrating.


THIS IS STUPID, YOU'RE STUPID! I DON'T HEAR IT?


Well, here is where things get a bit more complicated. It could be that you left it at work, or maybe it's not actually in your possesion anymore...

Let's see what were up against.

Make a picture with the front cam:

Code:
gst-launch v4l2src device=/dev/video1 num-buffers=1 ! ffmpegcolorspace ! jpegenc ! filesink location=frontcam.jpg
and get the picture to your server (scp [user]@[n900 public ip]:/home/user/MyDocs/frontcam.png .). You can even start a simple webserver from the commandline with:

Code:
python -m SimpleHTTPServer 80
and go to http://[public ip] to get the frontcam.jpg or any other files from the location where you started the above.


You can also make it call you and listen in on what is going on the neigbourhood of your phone:

Code:
dbus-send --system --dest=com.nokia.csd.Call --type=method_call --print-reply /com/nokia/csd/call com.nokia.csd.Call.CreateWith string:"[YOUR PHONE NUMBER GOES HERE]" uint32:0

I DON'T HEAR OR SEE A THING!


Here's where we're going to try and read the gps.

First, install python-location (apt-get install python-location) on your phone and make a new file called gps.py and fill it with this (thanks to happy_n900_user!):

Code:
 import location
import gobject

def on_error(control, error, data):
    print "location error: %d... quitting" % error
    data.quit()

def on_changed(device, data):
    if not device:
        return
    if device.fix:
        if (device.fix[1] & location.GPS_DEVICE_LATLONG_SET) and (device.fix[1] & location.GPS_DEVICE_TIME_SET) and not (device.status & location.GPS_DEVICE_STATUS_NO_FIX):
            print "lat = %f, long = %f" % device.fix[4:6]
            data.stop()

def on_stop(control, data):
    print "quitting"
    data.quit()

def start_location(data):
    data.start()
    return False

loop = gobject.MainLoop()
control = location.GPSDControl.get_default()
device = location.GPSDevice()
control.set_properties(preferred_method=location.METHOD_USER_SELECTED,
                       preferred_interval=location.INTERVAL_DEFAULT)

control.connect("error-verbose", on_error, loop)
device.connect("changed", on_changed, control)
control.connect("gpsd-stopped", on_stop, loop)

gobject.idle_add(start_location, control)

loop.run()
Now save and run it with

Code:
python2.5 gps.py
If everything goes well you'll get a LAT LONG you can plug into google maps.
If it's out of GPS range, you'll have to kill it with CTRL+C.

Once you have that, GO GET YOUR PHONE BACK (but please be smart about it! )

All of this is not meant to be some all inclusive guide, it's meant to give you a shot if you ever do lose your phone.

I'll try and keep this post updated with new methods

Big thanks go to:
-Jebba for his great list of dbus commands
-happy_n900_user for getting the python script to actually spit out a GPS location
-everyone involved in making this phone as great as it is!

Last edited by synthaxx; 03-13-2010 at 07:43 PM.
 

The Following 53 Users Say Thank You to synthaxx For This Useful Post: