From 7ab7f538924371a9dd4be7a27a6ae3b4c04b301c Mon Sep 17 00:00:00 2001 From: Laurent Tu Date: Tue, 30 Oct 2012 14:54:02 -0700 Subject: Hide new location APIs and undeprecate old ones Hide all new location APIs related to LocationRequest/Geofence and undeprecate all deprecated APIs consequently to the LocationRequest and Geofence introduction. Also introduce LocationRequestUnbundled for LocationProviders to use. Change-Id: I5b116c7d342041f45b341c88a4b6813571118018 --- api/17.txt | 109 +++++--------- api/current.txt | 109 +++++--------- location/java/android/location/Criteria.java | 4 - location/java/android/location/Geofence.java | 2 + location/java/android/location/Location.java | 9 -- .../java/android/location/LocationManager.java | 156 +++------------------ .../java/android/location/LocationProvider.java | 4 - .../java/android/location/LocationRequest.java | 2 + .../provider/LocationRequestUnbundled.java | 128 +++++++++++++++++ .../provider/ProviderRequestUnbundled.java | 10 +- .../com/android/location/fused/FusionEngine.java | 14 +- 11 files changed, 241 insertions(+), 306 deletions(-) create mode 100644 location/lib/java/com/android/location/provider/LocationRequestUnbundled.java diff --git a/api/17.txt b/api/17.txt index fde6302..58f485f 100644 --- a/api/17.txt +++ b/api/17.txt @@ -10586,7 +10586,7 @@ package android.location { field public static final android.os.Parcelable.Creator CREATOR; } - public deprecated class Criteria implements android.os.Parcelable { + public class Criteria implements android.os.Parcelable { ctor public Criteria(); ctor public Criteria(android.location.Criteria); method public int describeContents(); @@ -10632,13 +10632,6 @@ package android.location { method public static boolean isPresent(); } - public final class Geofence implements android.os.Parcelable { - method public static android.location.Geofence createCircle(double, double, float); - method public int describeContents(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator CREATOR; - } - public final class GpsSatellite { method public float getAzimuth(); method public float getElevation(); @@ -10684,7 +10677,7 @@ package android.location { method public android.os.Bundle getExtras(); method public double getLatitude(); method public double getLongitude(); - method public deprecated java.lang.String getProvider(); + method public java.lang.String getProvider(); method public float getSpeed(); method public long getTime(); method public boolean hasAccuracy(); @@ -10722,57 +10715,51 @@ package android.location { } public class LocationManager { - method public void addGeofence(android.location.LocationRequest, android.location.Geofence, android.app.PendingIntent); method public boolean addGpsStatusListener(android.location.GpsStatus.Listener); method public boolean addNmeaListener(android.location.GpsStatus.NmeaListener); - method public deprecated void addProximityAlert(double, double, float, long, android.app.PendingIntent); - method public deprecated void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int); - method public deprecated void clearTestProviderEnabled(java.lang.String); - method public deprecated void clearTestProviderLocation(java.lang.String); - method public deprecated void clearTestProviderStatus(java.lang.String); - method public deprecated java.util.List getAllProviders(); - method public deprecated java.lang.String getBestProvider(android.location.Criteria, boolean); + method public void addProximityAlert(double, double, float, long, android.app.PendingIntent); + method public void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int); + method public void clearTestProviderEnabled(java.lang.String); + method public void clearTestProviderLocation(java.lang.String); + method public void clearTestProviderStatus(java.lang.String); + method public java.util.List getAllProviders(); + method public java.lang.String getBestProvider(android.location.Criteria, boolean); method public android.location.GpsStatus getGpsStatus(android.location.GpsStatus); - method public deprecated android.location.Location getLastKnownLocation(java.lang.String); - method public android.location.Location getLastLocation(); - method public deprecated android.location.LocationProvider getProvider(java.lang.String); - method public deprecated java.util.List getProviders(boolean); - method public deprecated java.util.List getProviders(android.location.Criteria, boolean); - method public deprecated boolean isProviderEnabled(java.lang.String); - method public void removeAllGeofences(android.app.PendingIntent); - method public void removeGeofence(android.location.Geofence, android.app.PendingIntent); + method public android.location.Location getLastKnownLocation(java.lang.String); + method public android.location.LocationProvider getProvider(java.lang.String); + method public java.util.List getProviders(boolean); + method public java.util.List getProviders(android.location.Criteria, boolean); + method public boolean isProviderEnabled(java.lang.String); method public void removeGpsStatusListener(android.location.GpsStatus.Listener); method public void removeNmeaListener(android.location.GpsStatus.NmeaListener); - method public deprecated void removeProximityAlert(android.app.PendingIntent); - method public deprecated void removeTestProvider(java.lang.String); + method public void removeProximityAlert(android.app.PendingIntent); + method public void removeTestProvider(java.lang.String); method public void removeUpdates(android.location.LocationListener); method public void removeUpdates(android.app.PendingIntent); - method public deprecated void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener); - method public deprecated void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener, android.os.Looper); - method public deprecated void requestLocationUpdates(long, float, android.location.Criteria, android.location.LocationListener, android.os.Looper); - method public deprecated void requestLocationUpdates(java.lang.String, long, float, android.app.PendingIntent); - method public deprecated void requestLocationUpdates(long, float, android.location.Criteria, android.app.PendingIntent); - method public void requestLocationUpdates(android.location.LocationRequest, android.location.LocationListener, android.os.Looper); - method public void requestLocationUpdates(android.location.LocationRequest, android.app.PendingIntent); - method public deprecated void requestSingleUpdate(java.lang.String, android.location.LocationListener, android.os.Looper); - method public deprecated void requestSingleUpdate(android.location.Criteria, android.location.LocationListener, android.os.Looper); - method public deprecated void requestSingleUpdate(java.lang.String, android.app.PendingIntent); - method public deprecated void requestSingleUpdate(android.location.Criteria, android.app.PendingIntent); - method public deprecated boolean sendExtraCommand(java.lang.String, java.lang.String, android.os.Bundle); - method public deprecated void setTestProviderEnabled(java.lang.String, boolean); - method public deprecated void setTestProviderLocation(java.lang.String, android.location.Location); - method public deprecated void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long); - field public static final deprecated java.lang.String GPS_PROVIDER = "gps"; + method public void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener); + method public void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener, android.os.Looper); + method public void requestLocationUpdates(long, float, android.location.Criteria, android.location.LocationListener, android.os.Looper); + method public void requestLocationUpdates(java.lang.String, long, float, android.app.PendingIntent); + method public void requestLocationUpdates(long, float, android.location.Criteria, android.app.PendingIntent); + method public void requestSingleUpdate(java.lang.String, android.location.LocationListener, android.os.Looper); + method public void requestSingleUpdate(android.location.Criteria, android.location.LocationListener, android.os.Looper); + method public void requestSingleUpdate(java.lang.String, android.app.PendingIntent); + method public void requestSingleUpdate(android.location.Criteria, android.app.PendingIntent); + method public boolean sendExtraCommand(java.lang.String, java.lang.String, android.os.Bundle); + method public void setTestProviderEnabled(java.lang.String, boolean); + method public void setTestProviderLocation(java.lang.String, android.location.Location); + method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long); + field public static final java.lang.String GPS_PROVIDER = "gps"; field public static final java.lang.String KEY_LOCATION_CHANGED = "location"; - field public static final deprecated java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; + field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; field public static final java.lang.String KEY_PROXIMITY_ENTERING = "entering"; - field public static final deprecated java.lang.String KEY_STATUS_CHANGED = "status"; - field public static final deprecated java.lang.String NETWORK_PROVIDER = "network"; - field public static final deprecated java.lang.String PASSIVE_PROVIDER = "passive"; - field public static final deprecated java.lang.String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED"; + field public static final java.lang.String KEY_STATUS_CHANGED = "status"; + field public static final java.lang.String NETWORK_PROVIDER = "network"; + field public static final java.lang.String PASSIVE_PROVIDER = "passive"; + field public static final java.lang.String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED"; } - public deprecated class LocationProvider { + public class LocationProvider { method public int getAccuracy(); method public java.lang.String getName(); method public int getPowerRequirement(); @@ -10789,30 +10776,6 @@ package android.location { field public static final int TEMPORARILY_UNAVAILABLE = 1; // 0x1 } - public final class LocationRequest implements android.os.Parcelable { - method public static android.location.LocationRequest create(); - method public int describeContents(); - method public long getExpireAt(); - method public long getFastestInterval(); - method public long getInterval(); - method public int getNumUpdates(); - method public int getQuality(); - method public android.location.LocationRequest setExpireAt(long); - method public android.location.LocationRequest setExpireIn(long); - method public android.location.LocationRequest setFastestInterval(long); - method public android.location.LocationRequest setInterval(long); - method public android.location.LocationRequest setNumUpdates(int); - method public android.location.LocationRequest setQuality(int); - method public void writeToParcel(android.os.Parcel, int); - field public static final int ACCURACY_BLOCK = 102; // 0x66 - field public static final int ACCURACY_CITY = 104; // 0x68 - field public static final int ACCURACY_FINE = 100; // 0x64 - field public static final android.os.Parcelable.Creator CREATOR; - field public static final int POWER_HIGH = 203; // 0xcb - field public static final int POWER_LOW = 201; // 0xc9 - field public static final int POWER_NONE = 200; // 0xc8 - } - } package android.media { diff --git a/api/current.txt b/api/current.txt index fde6302..58f485f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -10586,7 +10586,7 @@ package android.location { field public static final android.os.Parcelable.Creator CREATOR; } - public deprecated class Criteria implements android.os.Parcelable { + public class Criteria implements android.os.Parcelable { ctor public Criteria(); ctor public Criteria(android.location.Criteria); method public int describeContents(); @@ -10632,13 +10632,6 @@ package android.location { method public static boolean isPresent(); } - public final class Geofence implements android.os.Parcelable { - method public static android.location.Geofence createCircle(double, double, float); - method public int describeContents(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator CREATOR; - } - public final class GpsSatellite { method public float getAzimuth(); method public float getElevation(); @@ -10684,7 +10677,7 @@ package android.location { method public android.os.Bundle getExtras(); method public double getLatitude(); method public double getLongitude(); - method public deprecated java.lang.String getProvider(); + method public java.lang.String getProvider(); method public float getSpeed(); method public long getTime(); method public boolean hasAccuracy(); @@ -10722,57 +10715,51 @@ package android.location { } public class LocationManager { - method public void addGeofence(android.location.LocationRequest, android.location.Geofence, android.app.PendingIntent); method public boolean addGpsStatusListener(android.location.GpsStatus.Listener); method public boolean addNmeaListener(android.location.GpsStatus.NmeaListener); - method public deprecated void addProximityAlert(double, double, float, long, android.app.PendingIntent); - method public deprecated void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int); - method public deprecated void clearTestProviderEnabled(java.lang.String); - method public deprecated void clearTestProviderLocation(java.lang.String); - method public deprecated void clearTestProviderStatus(java.lang.String); - method public deprecated java.util.List getAllProviders(); - method public deprecated java.lang.String getBestProvider(android.location.Criteria, boolean); + method public void addProximityAlert(double, double, float, long, android.app.PendingIntent); + method public void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int); + method public void clearTestProviderEnabled(java.lang.String); + method public void clearTestProviderLocation(java.lang.String); + method public void clearTestProviderStatus(java.lang.String); + method public java.util.List getAllProviders(); + method public java.lang.String getBestProvider(android.location.Criteria, boolean); method public android.location.GpsStatus getGpsStatus(android.location.GpsStatus); - method public deprecated android.location.Location getLastKnownLocation(java.lang.String); - method public android.location.Location getLastLocation(); - method public deprecated android.location.LocationProvider getProvider(java.lang.String); - method public deprecated java.util.List getProviders(boolean); - method public deprecated java.util.List getProviders(android.location.Criteria, boolean); - method public deprecated boolean isProviderEnabled(java.lang.String); - method public void removeAllGeofences(android.app.PendingIntent); - method public void removeGeofence(android.location.Geofence, android.app.PendingIntent); + method public android.location.Location getLastKnownLocation(java.lang.String); + method public android.location.LocationProvider getProvider(java.lang.String); + method public java.util.List getProviders(boolean); + method public java.util.List getProviders(android.location.Criteria, boolean); + method public boolean isProviderEnabled(java.lang.String); method public void removeGpsStatusListener(android.location.GpsStatus.Listener); method public void removeNmeaListener(android.location.GpsStatus.NmeaListener); - method public deprecated void removeProximityAlert(android.app.PendingIntent); - method public deprecated void removeTestProvider(java.lang.String); + method public void removeProximityAlert(android.app.PendingIntent); + method public void removeTestProvider(java.lang.String); method public void removeUpdates(android.location.LocationListener); method public void removeUpdates(android.app.PendingIntent); - method public deprecated void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener); - method public deprecated void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener, android.os.Looper); - method public deprecated void requestLocationUpdates(long, float, android.location.Criteria, android.location.LocationListener, android.os.Looper); - method public deprecated void requestLocationUpdates(java.lang.String, long, float, android.app.PendingIntent); - method public deprecated void requestLocationUpdates(long, float, android.location.Criteria, android.app.PendingIntent); - method public void requestLocationUpdates(android.location.LocationRequest, android.location.LocationListener, android.os.Looper); - method public void requestLocationUpdates(android.location.LocationRequest, android.app.PendingIntent); - method public deprecated void requestSingleUpdate(java.lang.String, android.location.LocationListener, android.os.Looper); - method public deprecated void requestSingleUpdate(android.location.Criteria, android.location.LocationListener, android.os.Looper); - method public deprecated void requestSingleUpdate(java.lang.String, android.app.PendingIntent); - method public deprecated void requestSingleUpdate(android.location.Criteria, android.app.PendingIntent); - method public deprecated boolean sendExtraCommand(java.lang.String, java.lang.String, android.os.Bundle); - method public deprecated void setTestProviderEnabled(java.lang.String, boolean); - method public deprecated void setTestProviderLocation(java.lang.String, android.location.Location); - method public deprecated void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long); - field public static final deprecated java.lang.String GPS_PROVIDER = "gps"; + method public void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener); + method public void requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener, android.os.Looper); + method public void requestLocationUpdates(long, float, android.location.Criteria, android.location.LocationListener, android.os.Looper); + method public void requestLocationUpdates(java.lang.String, long, float, android.app.PendingIntent); + method public void requestLocationUpdates(long, float, android.location.Criteria, android.app.PendingIntent); + method public void requestSingleUpdate(java.lang.String, android.location.LocationListener, android.os.Looper); + method public void requestSingleUpdate(android.location.Criteria, android.location.LocationListener, android.os.Looper); + method public void requestSingleUpdate(java.lang.String, android.app.PendingIntent); + method public void requestSingleUpdate(android.location.Criteria, android.app.PendingIntent); + method public boolean sendExtraCommand(java.lang.String, java.lang.String, android.os.Bundle); + method public void setTestProviderEnabled(java.lang.String, boolean); + method public void setTestProviderLocation(java.lang.String, android.location.Location); + method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long); + field public static final java.lang.String GPS_PROVIDER = "gps"; field public static final java.lang.String KEY_LOCATION_CHANGED = "location"; - field public static final deprecated java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; + field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; field public static final java.lang.String KEY_PROXIMITY_ENTERING = "entering"; - field public static final deprecated java.lang.String KEY_STATUS_CHANGED = "status"; - field public static final deprecated java.lang.String NETWORK_PROVIDER = "network"; - field public static final deprecated java.lang.String PASSIVE_PROVIDER = "passive"; - field public static final deprecated java.lang.String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED"; + field public static final java.lang.String KEY_STATUS_CHANGED = "status"; + field public static final java.lang.String NETWORK_PROVIDER = "network"; + field public static final java.lang.String PASSIVE_PROVIDER = "passive"; + field public static final java.lang.String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED"; } - public deprecated class LocationProvider { + public class LocationProvider { method public int getAccuracy(); method public java.lang.String getName(); method public int getPowerRequirement(); @@ -10789,30 +10776,6 @@ package android.location { field public static final int TEMPORARILY_UNAVAILABLE = 1; // 0x1 } - public final class LocationRequest implements android.os.Parcelable { - method public static android.location.LocationRequest create(); - method public int describeContents(); - method public long getExpireAt(); - method public long getFastestInterval(); - method public long getInterval(); - method public int getNumUpdates(); - method public int getQuality(); - method public android.location.LocationRequest setExpireAt(long); - method public android.location.LocationRequest setExpireIn(long); - method public android.location.LocationRequest setFastestInterval(long); - method public android.location.LocationRequest setInterval(long); - method public android.location.LocationRequest setNumUpdates(int); - method public android.location.LocationRequest setQuality(int); - method public void writeToParcel(android.os.Parcel, int); - field public static final int ACCURACY_BLOCK = 102; // 0x66 - field public static final int ACCURACY_CITY = 104; // 0x68 - field public static final int ACCURACY_FINE = 100; // 0x64 - field public static final android.os.Parcelable.Creator CREATOR; - field public static final int POWER_HIGH = 203; // 0xcb - field public static final int POWER_LOW = 201; // 0xc9 - field public static final int POWER_NONE = 200; // 0xc8 - } - } package android.media { diff --git a/location/java/android/location/Criteria.java b/location/java/android/location/Criteria.java index 68fb4a0..a6099be 100644 --- a/location/java/android/location/Criteria.java +++ b/location/java/android/location/Criteria.java @@ -24,11 +24,7 @@ import android.os.Parcelable; * location provider. Providers maybe ordered according to accuracy, * power usage, ability to report altitude, speed, * and bearing, and monetary cost. - * - * @deprecated use {@link LocationRequest} instead, and also see notes - * at {@link LocationManager} */ -@Deprecated public class Criteria implements Parcelable { /** * A constant indicating that the application does not choose to diff --git a/location/java/android/location/Geofence.java b/location/java/android/location/Geofence.java index 791d3d0..5fef626 100644 --- a/location/java/android/location/Geofence.java +++ b/location/java/android/location/Geofence.java @@ -23,6 +23,8 @@ import android.os.Parcelable; * Represents a geographical boundary, also known as a geofence. * *

Currently only circular geofences are supported and they do not support altitude changes. + * + * @hide */ public final class Geofence implements Parcelable { /** @hide */ diff --git a/location/java/android/location/Location.java b/location/java/android/location/Location.java index 4025a7b..9b32667 100644 --- a/location/java/android/location/Location.java +++ b/location/java/android/location/Location.java @@ -466,17 +466,8 @@ public class Location implements Parcelable { /** * Returns the name of the provider that generated this fix. * - *

At API version 17 we deprecated {@link LocationProvider} - * and all API methods that request a provider by name. The new API methods - * will produce locations that could come from different sources, and even - * locations that are fused from several sources. So you should generally - * not care what provider is associated with a location object. - * * @return the provider, or null if it has not been set - * - * @deprecated locations can now be sourced from many providers, or even fused */ - @Deprecated public String getProvider() { return mProvider; } diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 653e8d1..5a2f71b 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -46,29 +46,6 @@ import com.android.internal.location.ProviderProperties; * {@link android.content.Context#getSystemService * Context.getSystemService(Context.LOCATION_SERVICE)}. * - *

At API version 17 the Location API's were simplified. - * Previously applications would need to explicitly enumerate, select, and - * track Location Providers (such as GPS or Network). - * This has been replaced by the concept of - * Fused Location. Now applications just specify the quality of service - * required for location updates (using the new {@link LocationRequest} class), - * and the system will fuse results from individual location providers - * as necessary before returning the result to the application. - * - *

As a result of this change, the {@link LocationProvider} and - * {@link Criteria} classes have been deprecated, in favor of - * {@link LocationRequest}. Furthermore, all Location Manager - * methods involving Criteria or explicitly named Providers have - * been deprecated, in favor of new variants that use - * {@link LocationRequest}. - * - *

A single {@link LocationRequest} object can trigger the use - * of all providers (including GPS, Network, and the passive) provider - * as necessary. This should result in a lot less work for your application. You - * no longer need to track the status and availability of each - * location provider. Just set the quality of locations required - * in {@link LocationRequest}, and let the system manage the rest. - * *

Unless noted, all Location API methods require * the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} or * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permissions. @@ -93,10 +70,7 @@ public class LocationManager { *

This provider determines location based on * availability of cell tower and WiFi access points. Results are retrieved * by means of a network lookup. - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public static final String NETWORK_PROVIDER = "network"; /** @@ -112,10 +86,7 @@ public class LocationManager { *

    *
  • satellites - the number of satellites used to derive the fix *
- * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public static final String GPS_PROVIDER = "gps"; /** @@ -129,10 +100,7 @@ public class LocationManager { * the origin of the location update. Requires the permission * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}, although if the GPS is * not enabled this provider might only return coarse fixes. - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public static final String PASSIVE_PROVIDER = "passive"; /** @@ -156,19 +124,13 @@ public class LocationManager { /** * Key used for a Bundle extra holding an Integer status value * when a status change is broadcast using a PendingIntent. - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public static final String KEY_STATUS_CHANGED = "status"; /** * Key used for a Bundle extra holding an Boolean status value * when a provider enabled/disabled event is broadcast using a PendingIntent. - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public static final String KEY_PROVIDER_ENABLED = "providerEnabled"; /** @@ -191,10 +153,7 @@ public class LocationManager { /** * Broadcast intent action when the configured location providers * change. - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public static final String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED"; @@ -338,10 +297,7 @@ public class LocationManager { * be accessed by the calling activity or are currently disabled. * * @return list of Strings containing names of the provider - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public List getAllProviders() { try { return mService.getAllProviders(); @@ -357,10 +313,7 @@ public class LocationManager { * @param enabledOnly if true then only the providers which are currently * enabled are returned. * @return list of Strings containing names of the providers - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public List getProviders(boolean enabledOnly) { try { return mService.getProviders(null, enabledOnly); @@ -380,10 +333,7 @@ public class LocationManager { * @throws IllegalArgumentException if name is null or does not exist * @throws SecurityException if the caller is not permitted to access the * given provider. - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public LocationProvider getProvider(String name) { checkProvider(name); try { @@ -407,10 +357,7 @@ public class LocationManager { * @param enabledOnly if true then only the providers which are currently * enabled are returned. * @return list of Strings containing names of the providers - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public List getProviders(Criteria criteria, boolean enabledOnly) { checkCriteria(criteria); try { @@ -442,10 +389,7 @@ public class LocationManager { * @param criteria the criteria that need to be matched * @param enabledOnly if true then only a provider that is currently enabled is returned * @return name of the provider that best matches the requirements - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public String getBestProvider(Criteria criteria, boolean enabledOnly) { checkCriteria(criteria); try { @@ -461,7 +405,7 @@ public class LocationManager { * pending intent. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param provider the name of the provider with which to register * @param minTime minimum time interval between location updates, in milliseconds @@ -475,9 +419,7 @@ public class LocationManager { * @throws IllegalArgumentException if listener is null * @throws RuntimeException if the calling thread has no Looper * @throws SecurityException if no suitable permission is present - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public void requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener) { checkProvider(provider); @@ -493,7 +435,7 @@ public class LocationManager { * the specified looper thread. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param provider the name of the provider with which to register * @param minTime minimum time interval between location updates, in milliseconds @@ -508,10 +450,7 @@ public class LocationManager { * @throws IllegalArgumentException if provider is null or doesn't exist * @throws IllegalArgumentException if listener is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public void requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener, Looper looper) { checkProvider(provider); @@ -527,7 +466,7 @@ public class LocationManager { * on the specified looper thread. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param minTime minimum time interval between location updates, in milliseconds * @param minDistance minimum distance between location updates, in meters @@ -543,10 +482,7 @@ public class LocationManager { * @throws IllegalArgumentException if criteria is null * @throws IllegalArgumentException if listener is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public void requestLocationUpdates(long minTime, float minDistance, Criteria criteria, LocationListener listener, Looper looper) { checkCriteria(criteria); @@ -562,7 +498,7 @@ public class LocationManager { * pending intent. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param provider the name of the provider with which to register * @param minTime minimum time interval between location updates, in milliseconds @@ -573,10 +509,7 @@ public class LocationManager { * on this device * @throws IllegalArgumentException if intent is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public void requestLocationUpdates(String provider, long minTime, float minDistance, PendingIntent intent) { checkProvider(provider); @@ -591,11 +524,8 @@ public class LocationManager { * Register for location updates using a Criteria and pending intent. * *

The requestLocationUpdates() and - * requestSingleUpdate() methods involving - * an explicit String provider or {@link Criteria} are deprecated. - * - *

They register the current activity to be updated - * periodically by the named provider, or by the provider matching + * requestSingleUpdate() register the current activity to be + * updated periodically by the named provider, or by the provider matching * the specified {@link Criteria}, with location and status updates. * *

It may take a while to receive the first location update. If @@ -680,10 +610,7 @@ public class LocationManager { * @throws IllegalArgumentException if criteria is null * @throws IllegalArgumentException if intent is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public void requestLocationUpdates(long minTime, float minDistance, Criteria criteria, PendingIntent intent) { checkCriteria(criteria); @@ -699,7 +626,7 @@ public class LocationManager { * a callback. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param provider the name of the provider with which to register * @param listener a {@link LocationListener} whose @@ -712,10 +639,7 @@ public class LocationManager { * @throws IllegalArgumentException if provider is null or doesn't exist * @throws IllegalArgumentException if listener is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest#setNumUpdates} instead */ - @Deprecated public void requestSingleUpdate(String provider, LocationListener listener, Looper looper) { checkProvider(provider); checkListener(listener); @@ -730,7 +654,7 @@ public class LocationManager { * a callback. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param criteria contains parameters for the location manager to choose the * appropriate provider and parameters to compute the location @@ -744,10 +668,7 @@ public class LocationManager { * @throws IllegalArgumentException if criteria is null * @throws IllegalArgumentException if listener is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest#setNumUpdates} instead */ - @Deprecated public void requestSingleUpdate(Criteria criteria, LocationListener listener, Looper looper) { checkCriteria(criteria); checkListener(listener); @@ -761,7 +682,7 @@ public class LocationManager { * Register for a single location update using a named provider and pending intent. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param provider the name of the provider with which to register * @param intent a {@link PendingIntent} to be sent for the location update @@ -769,10 +690,7 @@ public class LocationManager { * @throws IllegalArgumentException if provider is null or doesn't exist * @throws IllegalArgumentException if intent is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest#setNumUpdates} instead */ - @Deprecated public void requestSingleUpdate(String provider, PendingIntent intent) { checkProvider(provider); checkPendingIntent(intent); @@ -786,7 +704,7 @@ public class LocationManager { * Register for a single location update using a Criteria and pending intent. * *

See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} - * for more detail on how to use this (deprecated) method. + * for more detail on how to use this method. * * @param criteria contains parameters for the location manager to choose the * appropriate provider and parameters to compute the location @@ -795,10 +713,7 @@ public class LocationManager { * @throws IllegalArgumentException if provider is null or doesn't exist * @throws IllegalArgumentException if intent is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest#setNumUpdates} instead */ - @Deprecated public void requestSingleUpdate(Criteria criteria, PendingIntent intent) { checkCriteria(criteria); checkPendingIntent(intent); @@ -862,6 +777,8 @@ public class LocationManager { * * @throws IllegalArgumentException if listener is null * @throws SecurityException if no suitable permission is present + * + * @hide */ public void requestLocationUpdates(LocationRequest request, LocationListener listener, Looper looper) { @@ -887,6 +804,8 @@ public class LocationManager { * * @throws IllegalArgumentException if intent is null * @throws SecurityException if no suitable permission is present + * + * @hide */ public void requestLocationUpdates(LocationRequest request, PendingIntent intent) { checkPendingIntent(intent); @@ -1011,10 +930,7 @@ public class LocationManager { * * @throws SecurityException if {@link android.Manifest.permission#ACCESS_FINE_LOCATION} * permission is not present - * - * @deprecated Use {@link LocationRequest} and {@link Geofence} instead */ - @Deprecated public void addProximityAlert(double latitude, double longitude, float radius, long expiration, PendingIntent intent) { checkPendingIntent(intent); @@ -1062,6 +978,8 @@ public class LocationManager { * @throws IllegalArgumentException if intent is null * @throws SecurityException if {@link android.Manifest.permission#ACCESS_FINE_LOCATION} * permission is not present + * + * @hide */ public void addGeofence(LocationRequest request, Geofence fence, PendingIntent intent) { checkPendingIntent(intent); @@ -1089,10 +1007,7 @@ public class LocationManager { * @throws IllegalArgumentException if intent is null * @throws SecurityException if {@link android.Manifest.permission#ACCESS_FINE_LOCATION} * permission is not present - * - * @deprecated Use {@link LocationRequest} and {@link Geofence} instead */ - @Deprecated public void removeProximityAlert(PendingIntent intent) { checkPendingIntent(intent); String packageName = mContext.getPackageName(); @@ -1117,6 +1032,8 @@ public class LocationManager { * @throws IllegalArgumentException if intent is null * @throws SecurityException if {@link android.Manifest.permission#ACCESS_FINE_LOCATION} * permission is not present + * + * @hide */ public void removeGeofence(Geofence fence, PendingIntent intent) { checkPendingIntent(intent); @@ -1138,6 +1055,8 @@ public class LocationManager { * @throws IllegalArgumentException if intent is null * @throws SecurityException if {@link android.Manifest.permission#ACCESS_FINE_LOCATION} * permission is not present + * + * @hide */ public void removeAllGeofences(PendingIntent intent) { checkPendingIntent(intent); @@ -1161,10 +1080,7 @@ public class LocationManager { * * @throws IllegalArgumentException if provider is null * @throws SecurityException if no suitable permission is present - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public boolean isProviderEnabled(String provider) { checkProvider(provider); @@ -1187,6 +1103,8 @@ public class LocationManager { * * @return The last known location, or null if not available * @throws SecurityException if no suitable permission is present + * + * @hide */ public Location getLastLocation() { String packageName = mContext.getPackageName(); @@ -1215,10 +1133,7 @@ public class LocationManager { * * @throws SecurityException if no suitable permission is present * @throws IllegalArgumentException if provider is null or doesn't exist - * - * @deprecated Use {@link #getLastLocation} instead */ - @Deprecated public Location getLastKnownLocation(String provider) { checkProvider(provider); String packageName = mContext.getPackageName(); @@ -1246,10 +1161,7 @@ public class LocationManager { * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION * Settings.Secure.ALLOW_MOCK_LOCATION} system setting is not enabled * @throws IllegalArgumentException if a provider with the given name already exists - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void addTestProvider(String name, boolean requiresNetwork, boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, int powerRequirement, int accuracy) { @@ -1276,10 +1188,7 @@ public class LocationManager { * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled * @throws IllegalArgumentException if no provider with the given name exists - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void removeTestProvider(String provider) { try { mService.removeTestProvider(provider); @@ -1303,10 +1212,7 @@ public class LocationManager { * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled * @throws IllegalArgumentException if no provider with the given name exists * @throws IllegalArgumentException if the location is incomplete - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void setTestProviderLocation(String provider, Location loc) { if (!loc.isComplete()) { IllegalArgumentException e = new IllegalArgumentException( @@ -1337,10 +1243,7 @@ public class LocationManager { * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled * @throws IllegalArgumentException if no provider with the given name exists - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void clearTestProviderLocation(String provider) { try { mService.clearTestProviderLocation(provider); @@ -1360,10 +1263,7 @@ public class LocationManager { * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled * @throws IllegalArgumentException if no provider with the given name exists - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void setTestProviderEnabled(String provider, boolean enabled) { try { mService.setTestProviderEnabled(provider, enabled); @@ -1381,10 +1281,7 @@ public class LocationManager { * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled * @throws IllegalArgumentException if no provider with the given name exists - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void clearTestProviderEnabled(String provider) { try { mService.clearTestProviderEnabled(provider); @@ -1406,10 +1303,7 @@ public class LocationManager { * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled * @throws IllegalArgumentException if no provider with the given name exists - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void setTestProviderStatus(String provider, int status, Bundle extras, long updateTime) { try { mService.setTestProviderStatus(provider, status, extras, updateTime); @@ -1427,10 +1321,7 @@ public class LocationManager { * or the {@link android.provider.Settings.Secure#ALLOW_MOCK_LOCATION * Settings.Secure.ALLOW_MOCK_LOCATION}} system setting is not enabled * @throws IllegalArgumentException if no provider with the given name exists - * - * @deprecated requesting location providers by name is deprecated */ - @Deprecated public void clearTestProviderStatus(String provider) { try { mService.clearTestProviderStatus(provider); @@ -1673,10 +1564,7 @@ public class LocationManager { * The provider may optionally fill the extras Bundle with results from the command. * * @return true if the command succeeds. - * - * @deprecated Use {@link LocationRequest} instead, see notes on {@link LocationManager} */ - @Deprecated public boolean sendExtraCommand(String provider, String command, Bundle extras) { try { return mService.sendExtraCommand(provider, command, extras); diff --git a/location/java/android/location/LocationProvider.java b/location/java/android/location/LocationProvider.java index 737e17f..c4fd097 100644 --- a/location/java/android/location/LocationProvider.java +++ b/location/java/android/location/LocationProvider.java @@ -32,11 +32,7 @@ import com.android.internal.location.ProviderProperties; * characteristics or monetary costs to the user. The {@link * Criteria} class allows providers to be selected based on * user-specified criteria. - * - * @deprecated Use the {@link Criteria} class to request location instead of - * enumerating providers. */ -@Deprecated public class LocationProvider { public static final int OUT_OF_SERVICE = 0; public static final int TEMPORARILY_UNAVAILABLE = 1; diff --git a/location/java/android/location/LocationRequest.java b/location/java/android/location/LocationRequest.java index 6871ee2..68f540b 100644 --- a/location/java/android/location/LocationRequest.java +++ b/location/java/android/location/LocationRequest.java @@ -80,6 +80,8 @@ import android.util.TimeUtils; *

All location requests are considered hints, and you may receive * locations that are more accurate, less accurate, and slower * than requested. + * + * @hide */ public final class LocationRequest implements Parcelable { /** diff --git a/location/lib/java/com/android/location/provider/LocationRequestUnbundled.java b/location/lib/java/com/android/location/provider/LocationRequestUnbundled.java new file mode 100644 index 0000000..41fd769 --- /dev/null +++ b/location/lib/java/com/android/location/provider/LocationRequestUnbundled.java @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.location.provider; + +import android.location.LocationRequest; + +/** + * This class is an interface to LocationRequests for unbundled applications. + * + *

IMPORTANT: This class is effectively a public API for unbundled + * applications, and must remain API stable. See README.txt in the root + * of this package for more information. + */ +public final class LocationRequestUnbundled { + /** + * Returned by {@link #getQuality} when requesting the most accurate locations available. + * + *

This may be up to 1 meter accuracy, although this is implementation dependent. + */ + public static final int ACCURACY_FINE = LocationRequest.ACCURACY_FINE; + + /** + * Returned by {@link #getQuality} when requesting "block" level accuracy. + * + *

Block level accuracy is considered to be about 100 meter accuracy, + * although this is implementation dependent. Using a coarse accuracy + * such as this often consumes less power. + */ + public static final int ACCURACY_BLOCK = LocationRequest.ACCURACY_BLOCK; + + /** + * Returned by {@link #getQuality} when requesting "city" level accuracy. + * + *

City level accuracy is considered to be about 10km accuracy, + * although this is implementation dependent. Using a coarse accuracy + * such as this often consumes less power. + */ + public static final int ACCURACY_CITY = LocationRequest.ACCURACY_CITY; + + /** + * Returned by {@link #getQuality} when requiring no direct power impact (passive locations). + * + *

This location request will not trigger any active location requests, + * but will receive locations triggered by other applications. Your application + * will not receive any direct power blame for location work. + */ + public static final int POWER_NONE = LocationRequest.POWER_NONE; + + /** + * Returned by {@link #getQuality} when requesting low power impact. + * + *

This location request will avoid high power location work where + * possible. + */ + public static final int POWER_LOW = LocationRequest.POWER_LOW; + + /** + * Returned by {@link #getQuality} when allowing high power consumption for location. + * + *

This location request will allow high power location work. + */ + public static final int POWER_HIGH = LocationRequest.POWER_HIGH; + + private final LocationRequest delegate; + + LocationRequestUnbundled(LocationRequest delegate) { + this.delegate = delegate; + } + + /** + * Get the desired interval of this request, in milliseconds. + * + * @return desired interval in milliseconds, inexact + */ + public long getInterval() { + return delegate.getInterval(); + } + + /** + * Get the fastest interval of this request, in milliseconds. + * + *

The system will never provide location updates faster + * than the minimum of {@link #getFastestInterval} and + * {@link #getInterval}. + * + * @return fastest interval in milliseconds, exact + */ + public long getFastestInterval() { + return delegate.getFastestInterval(); + } + + /** + * Get the quality of the request. + * + * @return an accuracy or power constant + */ + public int getQuality() { + return delegate.getQuality(); + } + + /** + * Get the minimum distance between location updates, in meters. + * + * @return minimum distance between location updates in meters + */ + public float getSmallestDisplacement() { + return delegate.getSmallestDisplacement(); + } + + @Override + public String toString() { + return delegate.toString(); + } +} diff --git a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java index 3605381..ad3d1df 100644 --- a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java +++ b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java @@ -16,6 +16,7 @@ package com.android.location.provider; +import java.util.ArrayList; import java.util.List; import android.location.LocationRequest; @@ -47,8 +48,13 @@ public final class ProviderRequestUnbundled { /** * Never null. */ - public List getLocationRequests() { - return mRequest.locationRequests; + public List getLocationRequests() { + List result = new ArrayList( + mRequest.locationRequests.size()); + for (LocationRequest r : mRequest.locationRequests) { + result.add(new LocationRequestUnbundled(r)); + } + return result; } @Override diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java index 60de79c..f137373 100644 --- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java +++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java @@ -21,13 +21,13 @@ import java.io.PrintWriter; import java.util.HashMap; import com.android.location.provider.LocationProviderBase; +import com.android.location.provider.LocationRequestUnbundled; import com.android.location.provider.ProviderRequestUnbundled; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; -import android.location.LocationRequest; import android.os.Bundle; import android.os.Looper; import android.os.Parcelable; @@ -161,10 +161,10 @@ public class FusionEngine implements LocationListener { long networkInterval = Long.MAX_VALUE; long gpsInterval = Long.MAX_VALUE; - for (LocationRequest request : mRequest.getLocationRequests()) { + for (LocationRequestUnbundled request : mRequest.getLocationRequests()) { switch (request.getQuality()) { - case LocationRequest.ACCURACY_FINE: - case LocationRequest.POWER_HIGH: + case LocationRequestUnbundled.ACCURACY_FINE: + case LocationRequestUnbundled.POWER_HIGH: if (request.getInterval() < gpsInterval) { gpsInterval = request.getInterval(); } @@ -172,9 +172,9 @@ public class FusionEngine implements LocationListener { networkInterval = request.getInterval(); } break; - case LocationRequest.ACCURACY_BLOCK: - case LocationRequest.ACCURACY_CITY: - case LocationRequest.POWER_LOW: + case LocationRequestUnbundled.ACCURACY_BLOCK: + case LocationRequestUnbundled.ACCURACY_CITY: + case LocationRequestUnbundled.POWER_LOW: if (request.getInterval() < networkInterval) { networkInterval = request.getInterval(); } -- cgit v1.1