As everybody knows, Android is maintaining two cache files with location information. One is cache.wifi (a wifi router database with MAC and GPS of the router) the other is cache.cell (a database with mobile communication cells and their GPS). Due to the fact, that these files are in binary format the following Python code-snippet should help to encode the actual data:
cacheFile = open("cache.wifi", 'rb') version, entries = struct.unpack('>hh', cacheFile.read(4)) i = 0 while i < entries: key = cacheFile.read(struct.unpack('>h', cacheFile.read(2))[0]) (accuracy, confidence, latitude, longitude, readtime) = struct.unpack('>iiddQ', cacheFile.read(32)) outputFile.write('%25s %7d %5d %10f %10f %s \n' % (key,accuracy,confidence,latitude,longitude,time.strftime("%x %X %z", time.localtime(readtime/1000)))) i=i+1 cacheFile.close()
The cache files are located at:
/data/data/com.google.android.location/files/
This snippet works for both cache files, just change the filename 🙂