|
WiFiGPS Location Service
|
| Introduction |
WiFiGPSLocation is an Android service to simplify duty-cycling of the GPS receiver when a user is not mobile. The WiFiGPSLocation application runs as an Android Service on the phone. It defines a simple interface using the Android Interface Definition Language (AIDL). All other applications get the last location of the user through this interface from WiFiGPSLocation. Unlike the default Android location API, the location API provided by WiFiGPSLocation is synchronous (i.e., a call to getLocation() is guaranteed to return immediately with the last location of the user.)
The WiFiGPSLocation constantly queries the GPS receiver to track the
location of the user. Upon a getLocation() request, it returns the
latest known location of the user. However, it tries to duty-cycle the
GPS receiver's time when it detects the user is not mobile. WiFiGPSLocation
uses the WiFi RF fingerprint to detect when a user is not moving to
turn off GPS, and when the user starts moving to turn it back on. This
document outlines the design and implementation of WiFiGPSLocation,
and provides instructions on how to use it in other applications.
Forward your questions and comments to Hossein Falaki
| Design |
WiFiGPSLocation continuously scans for visible WiFi access points (APs). The result of each WiFi scan is stored in an in-memory cache along with the corresponding GPS location. If a specific set of WiFi access points has been seen for significant number of times, it is marked as a "significant entry." Next time this same WiFi signature is seen, the service concludes that the user is not moving, and therefore turns off GPS. GPS is turned back on as soon as the set of visible WiFi APs changes (to a non-significant signature).
Every DEFAULT_WIFI_SCANNING_INTERVAL (currently set to two minutes) a WiFi scan is performed. At the same time every DEFAULT_GPS_SCANNING_INTERVAL (currently set to one minutes, but can be dynamically changed by clients through the AIDL interface) a GPS location sample is recorded. The set of visible WiFi APs are filtered based on the signal strength. Only APs with signal stronger than SIGNAL_THRESHOLD (currently set to -80 dBm) are used. This filtering eliminates transient WiFi access points and makes the WiFi signature more stable. Corresponding to each WiFi signature a cache entry is created that keeps track of the number of times this signature has been seen, the time when the entry has been created, and the corresponding GPS location object (if it exists). To save memory the cache is indexed by the MD5 hash of the string representation of set of WiFi APs (and the original set of WiFi APs is discarded).
Every time a WiFi scan completes, the cache is checked and if the same signature exists with count exceeding SIGNIFICANCE_THRESHOLD (currently set to 3), the corresponding GPS location is set as the last seen location, and GPS is turned off. If no record is found in the cache or the corresponding record is not "significant" GPS scanning is resumed.
Every CLEANUP_INTERVAL (currently set to one hour), the cache is inspected to clean stale and transient entries. Transient entries are those with count less than SIGNIFICANCE_THRESHOLD and older than one hour. Stale entries are those which were added more than CACHE_TIMEOUT (currently set to three hours) ago, considering that every revisit of that entry extends its life time for EXTENTION_TIME (currently set to 10 minutes).
| Download |
The source code is available on GitHub. Please visit here.