summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2012-07-11 10:26:13 -0700
committerNick Pelly <npelly@google.com>2012-07-16 12:18:52 -0700
commite0fd693c6098f59004f9e96ad75c058e26c337b0 (patch)
treed015b05584ab8cb4feab93fe8bdbedcbad7502fa /location
parent357d9cb861e05c514acba8cc0a8fc5ef70e4a356 (diff)
downloadframeworks_base-e0fd693c6098f59004f9e96ad75c058e26c337b0.zip
frameworks_base-e0fd693c6098f59004f9e96ad75c058e26c337b0.tar.gz
frameworks_base-e0fd693c6098f59004f9e96ad75c058e26c337b0.tar.bz2
Improve geofencing: throttle location updates with distance to fence.
Previously any geofence (proximity alert) would turn the GPS on at full rate. Now, we modify the GPS interval with the distance to the nearest geofence. A speed of 100m/s is assumed to calculate the next GPS update. Also o Major refactor of geofencing code, to make it easier to continue to improve. o Discard proximity alerts when an app is removed. o Misc cleanup of nearby code. There are other upcoming changes that make this a good time for some house-keeping. TODO: The new geofencing heuristics are much better than before, but still relatively naive. The next steps could be: - Improve boundary detection - Improve update thottling for large geofences - Consider velocity when throttling Change-Id: Ie6e23d2cb2b931eba5d2a2fc759543bb96e2f7d0
Diffstat (limited to 'location')
-rw-r--r--location/java/android/location/ILocationManager.aidl2
-rw-r--r--location/java/android/location/LocationManager.java21
-rw-r--r--location/java/com/android/internal/location/DummyLocationProvider.java11
3 files changed, 28 insertions, 6 deletions
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index 2255bf2..47b7adf 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -54,7 +54,7 @@ interface ILocationManager
boolean sendExtraCommand(String provider, String command, inout Bundle extras);
void addProximityAlert(double latitude, double longitude, float distance,
- long expiration, in PendingIntent intent);
+ long expiration, in PendingIntent intent, in String packageName);
void removeProximityAlert(in PendingIntent intent);
Bundle getProviderInfo(String provider);
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 1299574..ff74f41 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -17,6 +17,7 @@
package android.location;
import android.app.PendingIntent;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
@@ -52,7 +53,9 @@ import java.util.List;
*/
public class LocationManager {
private static final String TAG = "LocationManager";
- private ILocationManager mService;
+
+ private final Context mContext;
+ private final ILocationManager mService;
private final HashMap<GpsStatus.Listener, GpsStatusListenerTransport> mGpsStatusListeners =
new HashMap<GpsStatus.Listener, GpsStatusListenerTransport>();
private final HashMap<GpsStatus.NmeaListener, GpsStatusListenerTransport> mNmeaListeners =
@@ -193,6 +196,7 @@ public class LocationManager {
}
}
+ @Override
public void onLocationChanged(Location location) {
Message msg = Message.obtain();
msg.what = TYPE_LOCATION_CHANGED;
@@ -200,6 +204,7 @@ public class LocationManager {
mListenerHandler.sendMessage(msg);
}
+ @Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Message msg = Message.obtain();
msg.what = TYPE_STATUS_CHANGED;
@@ -213,6 +218,7 @@ public class LocationManager {
mListenerHandler.sendMessage(msg);
}
+ @Override
public void onProviderEnabled(String provider) {
Message msg = Message.obtain();
msg.what = TYPE_PROVIDER_ENABLED;
@@ -220,6 +226,7 @@ public class LocationManager {
mListenerHandler.sendMessage(msg);
}
+ @Override
public void onProviderDisabled(String provider) {
Message msg = Message.obtain();
msg.what = TYPE_PROVIDER_DISABLED;
@@ -260,8 +267,9 @@ public class LocationManager {
* right way to create an instance of this class is using the
* factory Context.getSystemService.
*/
- public LocationManager(ILocationManager service) {
+ public LocationManager(Context context, ILocationManager service) {
mService = service;
+ mContext = context;
}
private LocationProvider createProvider(String name, Bundle info) {
@@ -1086,8 +1094,8 @@ public class LocationManager {
", intent = " + intent);
}
try {
- mService.addProximityAlert(latitude, longitude, radius,
- expiration, intent);
+ mService.addProximityAlert(latitude, longitude, radius, expiration, intent,
+ mContext.getPackageName());
} catch (RemoteException ex) {
Log.e(TAG, "addProximityAlert: RemoteException", ex);
}
@@ -1361,6 +1369,7 @@ public class LocationManager {
mNmeaBuffer = new ArrayList<Nmea>();
}
+ @Override
public void onGpsStarted() {
if (mListener != null) {
Message msg = Message.obtain();
@@ -1369,6 +1378,7 @@ public class LocationManager {
}
}
+ @Override
public void onGpsStopped() {
if (mListener != null) {
Message msg = Message.obtain();
@@ -1377,6 +1387,7 @@ public class LocationManager {
}
}
+ @Override
public void onFirstFix(int ttff) {
if (mListener != null) {
mGpsStatus.setTimeToFirstFix(ttff);
@@ -1386,6 +1397,7 @@ public class LocationManager {
}
}
+ @Override
public void onSvStatusChanged(int svCount, int[] prns, float[] snrs,
float[] elevations, float[] azimuths, int ephemerisMask,
int almanacMask, int usedInFixMask) {
@@ -1401,6 +1413,7 @@ public class LocationManager {
}
}
+ @Override
public void onNmeaReceived(long timestamp, String nmea) {
if (mNmeaListener != null) {
synchronized (mNmeaBuffer) {
diff --git a/location/java/com/android/internal/location/DummyLocationProvider.java b/location/java/com/android/internal/location/DummyLocationProvider.java
index e7b5143..3122960 100644
--- a/location/java/com/android/internal/location/DummyLocationProvider.java
+++ b/location/java/com/android/internal/location/DummyLocationProvider.java
@@ -24,7 +24,7 @@ import android.location.LocationProvider;
* A DummyLocationProvider may be queried to determine the properties
* of the provider whcih it shadows, but does not actually provide location
* data.
- *
+ *
* {@hide}
*/
public class DummyLocationProvider extends LocationProvider {
@@ -86,6 +86,7 @@ public class DummyLocationProvider extends LocationProvider {
* Returns true if the provider requires access to a
* data network (e.g., the Internet), false otherwise.
*/
+ @Override
public boolean requiresNetwork() {
return mRequiresNetwork;
}
@@ -95,6 +96,7 @@ public class DummyLocationProvider extends LocationProvider {
* satellite-based positioning system (e.g., GPS), false
* otherwise.
*/
+ @Override
public boolean requiresSatellite() {
return mRequiresSatellite;
}
@@ -104,6 +106,7 @@ public class DummyLocationProvider extends LocationProvider {
* cellular network (e.g., to make use of cell tower IDs), false
* otherwise.
*/
+ @Override
public boolean requiresCell() {
return mRequiresCell;
}
@@ -113,6 +116,7 @@ public class DummyLocationProvider extends LocationProvider {
* monetary charge to the user, false if use is free. It is up to
* each provider to give accurate information.
*/
+ @Override
public boolean hasMonetaryCost() {
return mHasMonetaryCost;
}
@@ -123,6 +127,7 @@ public class DummyLocationProvider extends LocationProvider {
* under most circumstances but may occassionally not report it
* should return true.
*/
+ @Override
public boolean supportsAltitude() {
return mSupportsAltitude;
}
@@ -133,6 +138,7 @@ public class DummyLocationProvider extends LocationProvider {
* under most circumstances but may occassionally not report it
* should return true.
*/
+ @Override
public boolean supportsSpeed() {
return mSupportsSpeed;
}
@@ -143,6 +149,7 @@ public class DummyLocationProvider extends LocationProvider {
* under most circumstances but may occassionally not report it
* should return true.
*/
+ @Override
public boolean supportsBearing() {
return mSupportsBearing;
}
@@ -153,6 +160,7 @@ public class DummyLocationProvider extends LocationProvider {
* @return the power requirement for this provider, as one of the
* constants Criteria.POWER_REQUIREMENT_*.
*/
+ @Override
public int getPowerRequirement() {
return mPowerRequirement;
}
@@ -164,6 +172,7 @@ public class DummyLocationProvider extends LocationProvider {
* @return the horizontal accuracy for this provider, as one of the
* constants Criteria.ACCURACY_*.
*/
+ @Override
public int getAccuracy() {
return mAccuracy;
}