在最近几天互联网对 iPhone 有缓存 这一针对定位服务的披露的愤怒/过度反应之后, 我决定看看我的 Android 设备 为相同功能缓存了什么。
这是一个我临时拼凑的快速导出工具, 用于解析来自 Android 定位提供程序的这些文件。
这些文件名为 cache.cell 和 cache.wifi,位于
Android 设备上的 /data/data/com.google.android.location/files 中。
你需要设备的 root 权限才能读取该目录。
如何禁用:
找到 Settings -> Location & Security -> Use wireless networks 并取消勾选。
在 2.3 设备上这会删除这些文件;我的 2.2 设备会保留这些文件,但停止更新它们。 目前其他版本的情况未知。
用法:
$ parse.py <cache file>
你也可以传入 --gpx 选项以获得 GPX 格式
的输出,然后使用 gpsbabel 或类似工具将数据转换为你
想要的格式:
$ parse.py --gpx cache.wifi > wifi.gpx
重要说明:查看旧的 Android 源代码(这些代码似乎已不再由 Google 开放)后发现,其受到很大限制。
然而,数据只有在添加新信息时才会被清理。没有时间 基础的清理,除非有新的数据添加到缓存中。这 可能导致旧数据在设备移动有限时仍被 保留。
// Maximum time (in millis) that a record is valid for, before it needs
// to be refreshed from the server.
private static final long MAX_CELL_REFRESH_RECORD_AGE = 12 * 60 * 60 * 1000; // 12 hours
private static final long MAX_WIFI_REFRESH_RECORD_AGE = 48 * 60 * 60 * 1000; // 48 hours
// Cache sizes
private static final int MAX_CELL_RECORDS = 50;
private static final int MAX_WIFI_RECORDS = 200;
示例输出:
$ ./parse.py cache.wifi
db version: 1
total: 47
key accuracy conf. latitude longitude time
50:63:13:57:42:7e 80 92 57.689354 11.994763 04/11/11 10:03:51 +0200
e0:cb:4e:7e:cc:53 75 92 57.689340 11.994495 04/11/11 10:03:51 +0200
4c:54:99:14:47:68 57 92 57.708979 11.916581 04/11/11 01:14:53 +0200
00:26:18:0a:ad:cb 60 92 57.709699 11.917637 04/13/11 08:40:36 +0200
00:22:15:28:3f:7a 60 92 57.699467 11.979340 04/13/11 11:52:16 +0200
00:22:3f:a7:d9:fd 65 92 57.699442 11.979343 04/13/11 11:52:16 +0200
$ ./parse.py cache.cell
db version: 1
total: 41
key accuracy conf. latitude longitude time
240:5:15:983885 1186 75 57.704031 11.910801 04/11/11 20:03:14 +0200
240:5:15:983882 883 75 57.706322 11.911692 04/13/11 01:41:29 +0200
240:5:75:4915956 678 75 57.700175 11.976824 04/13/11 11:52:16 +0200
240:5:75:4915953 678 75 57.700064 11.976629 04/13/11 11:53:09 +0200
240:7:61954:58929 1406 75 57.710205 11.921849 04/15/11 19:46:31 +0200
240:7:15:58929 -1 0 0.000000 0.000000 04/15/11 19:46:32 +0200
240:5:75:4915832 831 75 57.690024 11.998419 04/15/11 16:13:53 +0200
如果你有任何问题/信息想要分享,我可以 通过 [email protected] 联系到。