public abstract class LocationProviderBase extends Object
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 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 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.
Modifier and Type | Field and Description |
---|---|
static String |
EXTRA_NO_GPS_LOCATION
Bundle key for a version of the location containing no GPS data.
|
static String |
FUSED_PROVIDER
Name of the Fused location provider.
|
protected ILocationManager |
mLocationManager |
Constructor and Description |
---|
LocationProviderBase(String tag,
ProviderPropertiesUnbundled properties) |
Modifier and Type | Method and Description |
---|---|
IBinder |
getBinder() |
abstract void |
onDisable()
Disable the location provider.
|
void |
onDump(FileDescriptor fd,
PrintWriter pw,
String[] args)
Dump debug information.
|
abstract void |
onEnable()
Enable the location provider.
|
abstract int |
onGetStatus(Bundle extras)
Returns a information on the status of this provider.
|
abstract long |
onGetStatusUpdateTime()
Returns the time at which the status was last updated.
|
boolean |
onSendExtraCommand(String command,
Bundle extras)
Implements addditional location provider specific additional commands.
|
abstract void |
onSetRequest(ProviderRequestUnbundled request,
WorkSource source)
Set the
ProviderRequest requirements for this provider. |
void |
reportLocation(Location location)
Used by the location provider to report new locations.
|
protected final ILocationManager mLocationManager
public static final String EXTRA_NO_GPS_LOCATION
public static final String FUSED_PROVIDER
This provider combines inputs for all possible location sources to provide the best possible Location fix.
public LocationProviderBase(String tag, ProviderPropertiesUnbundled properties)
public IBinder getBinder()
public final void reportLocation(Location location)
location
- new Location to report
Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.public abstract void onEnable()
The provider may initialize resources, but does not yet need to report locations.
public abstract void onDisable()
The provider must release resources, and stop performing work. It may no longer report locations.
public abstract void onSetRequest(ProviderRequestUnbundled request, WorkSource source)
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 void onDump(FileDescriptor fd, PrintWriter pw, String[] args)
public abstract int onGetStatus(Bundle extras)
LocationProvider.OUT_OF_SERVICE
is returned if the provider is
out of service, and this is not expected to change in the near
future; LocationProvider.TEMPORARILY_UNAVAILABLE
is returned if
the provider is temporarily unavailable but is expected to be
available shortly; and 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 long onGetStatusUpdateTime()
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.public boolean onSendExtraCommand(String command, Bundle extras)
command
- name of the command to send to the provider.extras
- optional arguments for the command (or null).
The provider may optionally fill the extras Bundle with results from the command.