Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4903f25 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Add passive location provider.



The passive location provider allows receiving location updates without
actually triggering them.  This allows an application to receive location
updates that are being generated due to other clients of the location manager.

Change-Id: Ibf7a96b089c56875d4f62d3210252ae8d9f32768
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent c6a0a9cb
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -78725,6 +78725,17 @@
 visibility="public"
>
</field>
<field name="PASSIVE_PROVIDER"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;passive&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="LocationProvider"
 extends="java.lang.Object"
+4 −2
Original line number Diff line number Diff line
@@ -59,8 +59,10 @@ interface ILocationManager

    Location getLastKnownLocation(String provider);

    /* used by location providers to tell the location manager when it has a new location */
    void reportLocation(in Location location);
    // Used by location providers to tell the location manager when it has a new location.
    // Passive is true if the location is coming from the passive provider, in which case
    // it need not be shared with other providers.
    void reportLocation(in Location location, boolean passive);

    String getFromLocation(double latitude, double longitude, int maxResults,
        in GeocoderParams params, out List<Address> addrs);
+13 −0
Original line number Diff line number Diff line
@@ -80,6 +80,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)..
+4 −0
Original line number Diff line number Diff line
@@ -71,6 +71,10 @@ public abstract class LocationProvider {
     * false otherwise.
     */
    public boolean meetsCriteria(Criteria criteria) {
        // We do not want to match the special passive provider based on criteria.
        if (LocationManager.PASSIVE_PROVIDER.equals(mName)) {
            return false;
        }
        if ((criteria.getAccuracy() != Criteria.NO_REQUIREMENT) && 
            (criteria.getAccuracy() < getAccuracy())) {
            return false;
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ public abstract class LocationProvider {
     */
    public void reportLocation(Location location) {
        try {
            mLocationManager.reportLocation(location);
            mLocationManager.reportLocation(location, false);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException in reportLocation: ", e);
        }
Loading