Build 1.0_r1(from source)

android.location
Class LocationProviderImpl

java.lang.Object
  extended by android.location.LocationProvider
      extended by android.location.LocationProviderImpl
Direct Known Subclasses:
TestLocationProvider

public abstract class LocationProviderImpl
extends LocationProvider

An abstract superclass for location provider implementations. Location provider implementations are typically instantiated by the location manager service in the system process, and location information is made available to implementations via the manager.


Field Summary
 
Fields inherited from class android.location.LocationProvider
AVAILABLE, BAD_CHARS_REGEX, OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE
 
Constructor Summary
protected LocationProviderImpl(String name)
           
 
Method Summary
static void addProvider(LocationProviderImpl provider)
           
abstract  void disable()
          Disables this provider.
abstract  void enable()
          Enables this provider.
 void enableLocationTracking(boolean enable)
          Notifies the location provider that clients are listening for locations.
abstract  boolean getLocation(Location l)
          Sets a Location object with the information gathered during the most recent fix.
 long getMinTime()
          Gets the smallest minimum time between updates amongst all the clients listening for locations.
static LocationProviderImpl getProvider(String name)
           
static List<LocationProviderImpl> getProviders()
           
 int getStatus()
          Returns a information on the status of this provider.
abstract  int getStatus(Bundle extras)
          Returns a information on the status of this provider.
 long getStatusUpdateTime()
          Returns the time at which the status was last updated.
abstract  boolean isEnabled()
          Returns true if this provider is enabled, false otherwise;
 boolean isLocationTracking()
          Returns true if the provider has any listeners
static LocationProviderImpl loadFromClass(File classFile)
           
static void removeProvider(LocationProviderImpl provider)
           
 boolean sendExtraCommand(String command, Bundle extras)
          Implements addditional location provider specific additional commands.
 void setMinTime(long minTime)
          Notifies the location provider of the smallest minimum time between updates amongst all clients that are listening for locations.
 void updateCellState(com.android.internal.location.CellState state)
          Updates the cell state for the given provider.
 void updateNetworkState(int state)
          Updates the network state for the given provider.
 
Methods inherited from class android.location.LocationProvider
getAccuracy, getName, getPowerRequirement, hasMonetaryCost, meetsCriteria, requiresCell, requiresNetwork, requiresSatellite, supportsAltitude, supportsBearing, supportsSpeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocationProviderImpl

protected LocationProviderImpl(String name)
Method Detail

addProvider

public static void addProvider(LocationProviderImpl provider)

removeProvider

public static void removeProvider(LocationProviderImpl provider)

getProviders

public static List<LocationProviderImpl> getProviders()

getProvider

public static LocationProviderImpl getProvider(String name)

loadFromClass

public static LocationProviderImpl loadFromClass(File classFile)

enable

public abstract void enable()
Enables this provider. When enabled, calls to getStatus() and getLocation(android.location.Location) must be handled. Hardware may be started up when the provider is enabled.


disable

public abstract void disable()
Disables this provider. When disabled, calls to getStatus() and getLocation(android.location.Location) need not be handled. Hardware may be shut down while the provider is disabled.


isEnabled

public abstract boolean isEnabled()
Returns true if this provider is enabled, false otherwise;


getStatus

public int getStatus()
Returns a information on the status of this provider. 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.


getStatus

public abstract int getStatus(Bundle extras)
Returns a information on the status of this provider. 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.


getStatusUpdateTime

public long getStatusUpdateTime()
Returns the time at which the status was last updated. It is the responsibility of the provider to appropriately set this value using android.os.SystemClock.elapsedRealtime() each time 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.

Returns:
time of last status update in millis since last reboot

getLocation

public abstract boolean getLocation(Location l)
Sets a Location object with the information gathered during the most recent fix.

Parameters:
l - location object to set
Returns:
true if a location fix is available

enableLocationTracking

public void enableLocationTracking(boolean enable)
Notifies the location provider that clients are listening for locations. Called with enable set to true when the first client is added and called with enable set to false when the last client is removed. This allows the provider to prepare for receiving locations, and to shut down when no clients are remaining.

Parameters:
enable - true if location tracking should be enabled.

isLocationTracking

public boolean isLocationTracking()
Returns true if the provider has any listeners

Returns:
true if provider is being tracked

setMinTime

public void setMinTime(long minTime)
Notifies the location provider of the smallest minimum time between updates amongst all clients that are listening for locations. This allows the provider to reduce the frequency of updates to match the requested frequency.

Parameters:
minTime - the smallest minTime value over all listeners for this provider.

getMinTime

public long getMinTime()
Gets the smallest minimum time between updates amongst all the clients listening for locations. By default this value is 0 (as frqeuently as possible)

Returns:
the smallest minTime value over all listeners for this provider

updateNetworkState

public void updateNetworkState(int state)
Updates the network state for the given provider. This function must be overwritten if LocationProvider.requiresNetwork() returns true. The state is LocationProvider.TEMPORARILY_UNAVAILABLE (disconnected), OR LocationProvider.AVAILABLE (connected or connecting).

Parameters:
state - data state

updateCellState

public void updateCellState(com.android.internal.location.CellState state)
Updates the cell state for the given provider. This function must be overwritten if LocationProvider.requiresCell() returns true.

Parameters:
state - cell state

sendExtraCommand

public boolean sendExtraCommand(String command,
                                Bundle extras)
Implements addditional location provider specific additional commands.

Parameters:
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.
Returns:
true if the command succeeds.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature