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

Commit 628fd6d9 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Network Location unbundling:



The network location and geocode provider services are now started on demand
and their interfaces are now retrieved via bindService().

Remove obsolete LocationManager installLocationProvider() and installGeocodeProvider() methods.

Add abstract class android.location.provider.GeocodeProvider to provide a public wrapper to
the IGeocodeProvider Binder interface. Replaces the LocationManager.GeocodeProvider interface.

Rename LocationProviderImpl to android.location.provider.LocationProvider.

Move LocationManager.reportLocation() to android.location.provider.LocationProvider,
so all methods related to external location providers are now all in one class.

Avoid calling from the Location Manager Service into providers that are disabled so we
do not start the network location service unnecessarily.

Change-Id: If3ed2d5d62b83ba508006711d575cad09f4a0007
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 53bd2522
Loading
Loading
Loading
Loading
+0 −255
Original line number Diff line number Diff line
@@ -77614,32 +77614,6 @@
<parameter name="enabledOnly" type="boolean">
</parameter>
</method>
<method name="installGeocodeProvider"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="provider" type="android.location.LocationManager.GeocodeProvider">
</parameter>
</method>
<method name="installLocationProvider"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="provider" type="android.location.LocationProviderImpl">
</parameter>
</method>
<method name="isProviderEnabled"
 return="boolean"
 abstract="false"
@@ -77731,19 +77705,6 @@
<parameter name="intent" type="android.app.PendingIntent">
</parameter>
</method>
<method name="reportLocation"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="location" type="android.location.Location">
</parameter>
</method>
<method name="requestLocationUpdates"
 return="void"
 abstract="false"
@@ -77936,62 +77897,6 @@
>
</field>
</class>
<interface name="LocationManager.GeocodeProvider"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="getFromLocation"
 return="java.lang.String"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="latitude" type="double">
</parameter>
<parameter name="longitude" type="double">
</parameter>
<parameter name="maxResults" type="int">
</parameter>
<parameter name="params" type="android.location.GeocoderParams">
</parameter>
<parameter name="addrs" type="java.util.List&lt;android.location.Address&gt;">
</parameter>
</method>
<method name="getFromLocationName"
 return="java.lang.String"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="locationName" type="java.lang.String">
</parameter>
<parameter name="lowerLeftLatitude" type="double">
</parameter>
<parameter name="lowerLeftLongitude" type="double">
</parameter>
<parameter name="upperRightLatitude" type="double">
</parameter>
<parameter name="upperRightLongitude" type="double">
</parameter>
<parameter name="maxResults" type="int">
</parameter>
<parameter name="params" type="android.location.GeocoderParams">
</parameter>
<parameter name="addrs" type="java.util.List&lt;android.location.Address&gt;">
</parameter>
</method>
</interface>
<class name="LocationProvider"
 extends="java.lang.Object"
 abstract="true"
@@ -78157,166 +78062,6 @@
>
</field>
</class>
<class name="LocationProviderImpl"
 extends="android.location.LocationProvider"
 abstract="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="LocationProviderImpl"
 type="android.location.LocationProviderImpl"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</constructor>
<method name="addListener"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uid" type="int">
</parameter>
</method>
<method name="disable"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="enable"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="enableLocationTracking"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="enable" type="boolean">
</parameter>
</method>
<method name="getStatus"
 return="int"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="extras" type="android.os.Bundle">
</parameter>
</method>
<method name="getStatusUpdateTime"
 return="long"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="removeListener"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uid" type="int">
</parameter>
</method>
<method name="sendExtraCommand"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="command" type="java.lang.String">
</parameter>
<parameter name="extras" type="android.os.Bundle">
</parameter>
</method>
<method name="setMinTime"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="minTime" type="long">
</parameter>
</method>
<method name="updateLocation"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="location" type="android.location.Location">
</parameter>
</method>
<method name="updateNetworkState"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="state" type="int">
</parameter>
<parameter name="info" type="android.net.NetworkInfo">
</parameter>
</method>
</class>
</package>
<package name="android.media"
>
+0 −4
Original line number Diff line number Diff line
@@ -81,10 +81,6 @@ interface ILocationManager
    void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime);
    void clearTestProviderStatus(String provider);

    /* for installing external Location Providers */
    void installLocationProvider(String name, ILocationProvider provider);
    void installGeocodeProvider(IGeocodeProvider provider);

    // for NI support
    boolean sendNiResponse(int notifId, int userResponse);
}
+0 −111
Original line number Diff line number Diff line
@@ -104,48 +104,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>();
@@ -1396,75 +1354,6 @@ public class LocationManager {
        }
    }
    
    /**
     * 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
     * for network initiated GPS fix requests.
+83 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 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 android.location.provider;

import android.os.IBinder;

import android.location.Address;
import android.location.GeocoderParams;
import android.location.IGeocodeProvider;

import java.util.List;

/**
 * An abstract superclass for geocode providers that are implemented
 * outside of the core android platform.
 * Geocode providers can be implemented as services and return the result of
 * {@link GeocodeProvider#getBinder()} in its getBinder() method.
 *
 * @hide
 */
public abstract class GeocodeProvider {

    private IGeocodeProvider.Stub mProvider = new IGeocodeProvider.Stub() {
        public String getFromLocation(double latitude, double longitude, int maxResults,
                GeocoderParams params, List<Address> addrs) {
            return GeocodeProvider.this.onGetFromLocation(latitude, longitude, maxResults,
                    params, addrs);
        }

        public String getFromLocationName(String locationName,
                double lowerLeftLatitude, double lowerLeftLongitude,
                double upperRightLatitude, double upperRightLongitude, int maxResults,
                GeocoderParams params, List<Address> addrs) {
            return GeocodeProvider.this.onGetFromLocationName(locationName, lowerLeftLatitude,
                    lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
                    maxResults, params, addrs);
        }
    };

    /**
     * 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 abstract String onGetFromLocation(double latitude, double longitude, int maxResults,
            GeocoderParams params, List<Address> 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 abstract String onGetFromLocationName(String locationName,
            double lowerLeftLatitude, double lowerLeftLongitude,
            double upperRightLatitude, double upperRightLongitude, int maxResults,
            GeocoderParams params, List<Address> addrs);

    /**
     * Returns the Binder interface for the geocode provider.
     * This is intended to be used for the onBind() method of
     * a service that implements a geocoder service.
     *
     * @return the IBinder instance for the provider
     */
    public IBinder getBinder() {
        return mProvider;
    }
}
Loading