FileDocCategorySizeDatePackage
LocationProviderBase.javaAPI DocAndroid 5.1 API7752Thu Mar 12 22:22:30 GMT 2015com.android.location.provider

LocationProviderBase

public abstract class LocationProviderBase extends Object
Base class for location providers implemented as unbundled services.

The network location provider must export a service with action "com.android.location.service.v2.NetworkLocationProvider" and a valid minor version in a meta-data field on the service, and then return the result of {@link #getBinder()} on service binding.

The fused location provider must export a service with action "com.android.location.service.FusedLocationProvider" and a valid minor version in a meta-data field on the service, and then return the result of {@link #getBinder()} on service binding.

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.

Fields Summary
private final String
TAG
protected final android.location.ILocationManager
mLocationManager
private final com.android.internal.location.ProviderProperties
mProperties
private final android.os.IBinder
mBinder
public static final String
EXTRA_NO_GPS_LOCATION
Bundle key for a version of the location containing no GPS data. Allows location providers to flag locations as being safe to feed to LocationFudger.
public static final String
FUSED_PROVIDER
Name of the Fused location provider.

This provider combines inputs for all possible location sources to provide the best possible Location fix.

Constructors Summary
public LocationProviderBase(String tag, ProviderPropertiesUnbundled properties)

        TAG = tag;
        IBinder b = ServiceManager.getService(Context.LOCATION_SERVICE);
        mLocationManager = ILocationManager.Stub.asInterface(b);
        mProperties = properties.getProviderProperties();
        mBinder = new Service();
    
Methods Summary
public android.os.IBindergetBinder()

        return mBinder;
    
public abstract voidonDisable()
Disable the location provider.

The provider must release resources, and stop performing work. It may no longer report locations.

public voidonDump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
Dump debug information.

    
public abstract voidonEnable()
Enable the location provider.

The provider may initialize resources, but does not yet need to report locations.

public abstract intonGetStatus(android.os.Bundle extras)
Returns a information on the status of this provider.

{@link android.location.LocationProvider#OUT_OF_SERVICE} is returned if the provider is out of service, and this is not expected to change in the near future; {@link android.location.LocationProvider#TEMPORARILY_UNAVAILABLE} is returned if the provider is temporarily unavailable but is expected to be available shortly; and {@link android.location.LocationProvider#AVAILABLE} is returned if the provider is currently available.

If extras is non-null, additional status information may be added to it in the form of provider-specific key/value pairs.

public abstract longonGetStatusUpdateTime()
Returns the time at which the status was last updated. It is the responsibility of the provider to appropriately set this value using {@link android.os.SystemClock#elapsedRealtime SystemClock.elapsedRealtime()}. there is a status update that it wishes to broadcast to all its listeners. The provider should be careful not to broadcast the same status again.

return
time of last status update in millis since last reboot

public booleanonSendExtraCommand(java.lang.String command, android.os.Bundle extras)
Implements addditional location provider specific additional commands.

param
command name of the command to send to the provider.
param
extras optional arguments for the command (or null). The provider may optionally fill the extras Bundle with results from the command.
return
true if the command succeeds.

        // default implementation
        return false;
    
public abstract voidonSetRequest(ProviderRequestUnbundled request, android.os.WorkSource source)
Set the {@link ProviderRequest} requirements for this provider.

Each call to this method overrides all previous requests.

This method might trigger the provider to start returning locations, or to stop returning locations, depending on the parameters in the request.

public final voidreportLocation(android.location.Location location)
Used by the location provider to report new locations.

param
location new Location to report Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.

        try {
            mLocationManager.reportLocation(location, false);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException", e);
        } catch (Exception e) {
            // never crash provider, might be running in a system process
            Log.e(TAG, "Exception", e);
        }