diff options
| author | Mike Lockwood <> | 2009-04-03 08:24:47 -0700 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-03 08:24:47 -0700 |
| commit | f6f9792d44ae9242981dab5ecc1ebf40190aada6 (patch) | |
| tree | 4bf5e9432997d6dd2ea6d9b431963f2233b4d827 /location/java/android | |
| parent | 8fd3a039f8e8cfd9d2d46a3853901e30b19c30c0 (diff) | |
| download | frameworks_base-f6f9792d44ae9242981dab5ecc1ebf40190aada6.zip frameworks_base-f6f9792d44ae9242981dab5ecc1ebf40190aada6.tar.gz frameworks_base-f6f9792d44ae9242981dab5ecc1ebf40190aada6.tar.bz2 | |
AI 144453: am: CL 144452 More Location Manager cleanup:
Remove 1 Hz "heartbeat" polling of location providers from LocationManagerService.
Now location providers report their location to LocationManagerService via
LocationManager.setLocation() rather than waiting to be polled.
This reduces GPS fix latency by up to one second.
Remove LocationProvderImpl.getLocation().
Since we are no longer polling, this method is no longer necessary.
BUG=1729031
Original author: lockwood
Automated import of CL 144453
Diffstat (limited to 'location/java/android')
| -rw-r--r-- | location/java/android/location/ILocationManager.aidl | 3 | ||||
| -rw-r--r-- | location/java/android/location/LocationProviderImpl.java | 26 |
2 files changed, 17 insertions, 12 deletions
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl index d0f9877..a7fb04d 100644 --- a/location/java/android/location/ILocationManager.aidl +++ b/location/java/android/location/ILocationManager.aidl @@ -53,6 +53,9 @@ interface ILocationManager boolean isProviderEnabled(String provider); Location getLastKnownLocation(String provider); + + /* used by location providers to tell the location manager when it has a new location */ + void setLocation(in Location location); String getFromLocation(double latitude, double longitude, int maxResults, String language, String country, String variant, String appName, out List<Address> addrs); diff --git a/location/java/android/location/LocationProviderImpl.java b/location/java/android/location/LocationProviderImpl.java index 0962992..bb225e2 100644 --- a/location/java/android/location/LocationProviderImpl.java +++ b/location/java/android/location/LocationProviderImpl.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.List; import android.os.Bundle; +import android.os.RemoteException; import android.util.Config; import android.util.Log; @@ -46,11 +47,13 @@ public abstract class LocationProviderImpl extends LocationProvider { private static HashMap<String, LocationProviderImpl> sProvidersByName = new HashMap<String, LocationProviderImpl>(); + private final ILocationManager mLocationManager; private boolean mLocationTracking = false; private long mMinTime = 0; - protected LocationProviderImpl(String name) { + protected LocationProviderImpl(String name, ILocationManager locationManager) { super(name); + mLocationManager = locationManager; } public static void addProvider(LocationProviderImpl provider) { @@ -114,16 +117,24 @@ public abstract class LocationProviderImpl extends LocationProvider { return null; } + public void reportLocationChanged(Location location) { + try { + mLocationManager.setLocation(location); + } catch (RemoteException e) { + Log.e(TAG, "RemoteException calling ILocationManager.onLocationChanged"); + } + } + /** * Enables this provider. When enabled, calls to {@link #getStatus()} - * and {@link #getLocation} must be handled. Hardware may be started up + * must be handled. Hardware may be started up * when the provider is enabled. */ public abstract void enable(); /** * Disables this provider. When disabled, calls to {@link #getStatus()} - * and {@link #getLocation} need not be handled. Hardware may be shut + * need not be handled. Hardware may be shut * down while the provider is disabled. */ public abstract void disable(); @@ -175,15 +186,6 @@ public abstract class LocationProviderImpl extends LocationProvider { } /** - * Sets a Location object with the information gathered - * during the most recent fix. - * - * @param l location object to set - * @return true if a location fix is available - */ - public abstract boolean getLocation(Location l); - - /** * Notifies the location provider that clients are listening for locations. * Called with enable set to true when the first client is added and * called with enable set to false when the last client is removed. |
