OSDN Git Service

ignore any exception in requestLocationUpdates
[android-x86/frameworks-base.git] / location / java / android / location / LocationManager.java
index 6d7a23d..b831e60 100644 (file)
@@ -81,6 +81,19 @@ public class LocationManager {
     public static final String GPS_PROVIDER = "gps";
 
     /**
+     * A special location provider for receiving locations without actually initiating
+     * a location fix. This provider can be used to passively receive location updates
+     * when other applications or services request them without actually requesting
+     * the locations yourself.  This provider will return locations generated by other
+     * providers.  You can query the {@link Location#getProvider()} method to determine
+     * the origin of the location update.
+     *
+     * Requires the permission android.permission.ACCESS_FINE_LOCATION, although if the GPS
+     * is not enabled this provider might only return coarse fixes.
+     */
+    public static final String PASSIVE_PROVIDER = "passive";
+
+    /**
      * Key used for the Bundle extra holding a boolean indicating whether
      * a proximity alert is entering (true) or exiting (false)..
      */
@@ -104,48 +117,6 @@ public class LocationManager {
      */
     public static final String KEY_LOCATION_CHANGED = "location";
 
-    public interface GeocodeProvider {
-        String getFromLocation(double latitude, double longitude, int maxResults,
-            GeocoderParams params, List<Address> addrs);
-
-        String getFromLocationName(String locationName,
-            double lowerLeftLatitude, double lowerLeftLongitude,
-            double upperRightLatitude, double upperRightLongitude, int maxResults,
-            GeocoderParams params, List<Address> addrs);
-    }
-
-    private static final class GeocodeProviderProxy extends IGeocodeProvider.Stub {
-        private GeocodeProvider mProvider;
-
-        GeocodeProviderProxy(GeocodeProvider provider) {
-            mProvider = provider;
-        }
-
-        /**
-         * This method is overridden to implement the
-         * {@link Geocoder#getFromLocation(double, double, int)} method.
-         * Classes implementing this method should not hold a reference to the params parameter.
-         */
-        public String getFromLocation(double latitude, double longitude, int maxResults,
-                GeocoderParams params, List<Address> addrs) {
-            return mProvider.getFromLocation(latitude, longitude, maxResults, params, addrs);
-        }
-
-        /**
-         * This method is overridden to implement the
-         * {@link Geocoder#getFromLocationName(String, int, double, double, double, double)} method.
-         * Classes implementing this method should not hold a reference to the params parameter.
-         */
-        public String getFromLocationName(String locationName,
-                double lowerLeftLatitude, double lowerLeftLongitude,
-                double upperRightLatitude, double upperRightLongitude, int maxResults,
-                GeocoderParams params, List<Address> addrs) {
-            return mProvider.getFromLocationName(locationName, lowerLeftLatitude,
-                    lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
-                    maxResults, params, addrs);
-        }
-    }
-
     // Map from LocationListeners to their associated ListenerTransport objects
     private HashMap<LocationListener,ListenerTransport> mListeners =
         new HashMap<LocationListener,ListenerTransport>();
@@ -346,7 +317,7 @@ public class LocationManager {
         List<String> providers = getProviders(enabledOnly);
         for (String providerName : providers) {
             LocationProvider provider = getProvider(providerName);
-            if (provider.meetsCriteria(criteria)) {
+            if (provider != null && provider.meetsCriteria(criteria)) {
                 if (goodProviders.isEmpty()) {
                     goodProviders = new ArrayList<String>();
                 }
@@ -739,7 +710,7 @@ public class LocationManager {
                 mListeners.put(listener, transport);
                 mService.requestLocationUpdates(provider, minTime, minDistance, transport);
             }
-        } catch (RemoteException ex) {
+        } catch (Exception ex) {
             Log.e(TAG, "requestLocationUpdates: DeadObjectException", ex);
         }
     }
@@ -1395,75 +1366,6 @@ public class LocationManager {
             return false;
         }
     }
-
-    /**
-     * Installs a location provider.
-     *
-     * @param name of the location provider
-     * @param provider Binder interface for the location provider
-     *
-     * @return true if the command succeeds.
-     *
-     * Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.
-     *
-     * {@hide}
-     */
-    public boolean installLocationProvider(String name, ILocationProvider provider) {
-        try {
-            mService.installLocationProvider(name, provider);
-            return true;
-        } catch (RemoteException e) {
-            Log.e(TAG, "RemoteException in installLocationProvider: ", e);
-            return false;
-        }
-    }
-
-    /**
-     * Installs a location provider.
-     *
-     * @param provider implementation of the location provider
-     *
-     * @return true if the command succeeds.
-     *
-     * Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.
-     */
-    public boolean installLocationProvider(LocationProviderImpl provider) {
-        return installLocationProvider(provider.getName(), provider.getInterface());
-    }
-
-    /**
-     * Installs a geocoder server.
-     *
-     * @param provider Binder interface for the geocoder provider
-     *
-     * @return true if the command succeeds.
-     *
-     * Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.
-     */
-    public boolean installGeocodeProvider(GeocodeProvider provider) {
-        try {
-            mService.installGeocodeProvider(new GeocodeProviderProxy(provider));
-            return true;
-        } catch (RemoteException e) {
-            Log.e(TAG, "RemoteException in setGeocodeProvider: ", e);
-            return false;
-        }
-    }
-
-    /**
-     * Used by location providers to report new locations.
-     *
-     * @param location new Location to report
-     *
-     * Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.
-     */
-    public void reportLocation(Location location) {
-        try {
-            mService.reportLocation(location);
-        } catch (RemoteException e) {
-            Log.e(TAG, "RemoteException in reportLocation: ", e);
-        }
-    }
     
     /**
      * Used by NetInitiatedActivity to report user response