diff options
-rw-r--r-- | api/current.xml | 11 | ||||
-rw-r--r-- | location/java/android/location/Geocoder.java | 21 | ||||
-rw-r--r-- | location/java/android/location/ILocationManager.aidl | 1 | ||||
-rw-r--r-- | services/java/com/android/server/LocationManagerService.java | 4 |
4 files changed, 36 insertions, 1 deletions
diff --git a/api/current.xml b/api/current.xml index 3e37035..923a7b6 100644 --- a/api/current.xml +++ b/api/current.xml @@ -82140,6 +82140,17 @@ <exception name="IOException" type="java.io.IOException"> </exception> </method> +<method name="isImplemented" + return="java.lang.Boolean" + abstract="false" + native="false" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> </class> <class name="GeocoderParams" extends="java.lang.Object" diff --git a/location/java/android/location/Geocoder.java b/location/java/android/location/Geocoder.java index c325b1b..546bb9d 100644 --- a/location/java/android/location/Geocoder.java +++ b/location/java/android/location/Geocoder.java @@ -40,7 +40,9 @@ import java.util.List; * * The Geocoder class requires a backend service that is not included in * the core android framework. The Geocoder query methods will return an - * empty list if there no backend service in the platform. + * empty list if there no backend service in the platform. Use the + * isImplemented() method to determine whether a Geocoder implementation + * exists. */ public final class Geocoder { private static final String TAG = "Geocoder"; @@ -49,6 +51,23 @@ public final class Geocoder { private ILocationManager mService; /** + * Returns true if the Geocoder methods getFromLocation and + * getFromLocationName are implemented. Lack of network + * connectivity may still cause these methods to return null or + * empty lists. + */ + public static Boolean isImplemented() { + IBinder b = ServiceManager.getService(Context.LOCATION_SERVICE); + ILocationManager lm = ILocationManager.Stub.asInterface(b); + try { + return lm.geocoderIsImplemented(); + } catch (RemoteException e) { + Log.e(TAG, "isImplemented: got RemoteException", e); + return false; + } + } + + /** * Constructs a Geocoder whose responses will be localized for the * given Locale. * diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl index a86f329..32d4b27 100644 --- a/location/java/android/location/ILocationManager.aidl +++ b/location/java/android/location/ILocationManager.aidl @@ -67,6 +67,7 @@ interface ILocationManager // it need not be shared with other providers. void reportLocation(in Location location, boolean passive); + boolean geocoderIsImplemented(); String getFromLocation(double latitude, double longitude, int maxResults, in GeocoderParams params, out List<Address> addrs); String getFromLocationName(String locationName, diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 74249f3..14d5995 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -1940,6 +1940,10 @@ public class LocationManagerService extends ILocationManager.Stub implements Run // Geocoder + public Boolean geocoderIsImplemented() { + return mGeocodeProvider != null; + } + public String getFromLocation(double latitude, double longitude, int maxResults, GeocoderParams params, List<Address> addrs) { if (mGeocodeProvider != null) { |