FileDocCategorySizeDatePackage
LocationProviderImpl.javaAPI DocAndroid 1.5 API9220Wed May 06 22:42:00 BST 2009android.location

LocationProviderImpl

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. {@hide}

Fields Summary
private static final String
TAG
private static ArrayList
sProviders
private static HashMap
sProvidersByName
private boolean
mLocationTracking
private long
mMinTime
Constructors Summary
protected LocationProviderImpl(String name)


       
        super(name);
    
Methods Summary
public static voidaddProvider(android.location.LocationProviderImpl provider)

        sProviders.add(provider);
        sProvidersByName.put(provider.getName(), provider);
    
public abstract voiddisable()
Disables this provider. When disabled, calls to {@link #getStatus()} and {@link #getLocation} need not be handled. Hardware may be shut down while the provider is disabled.

public abstract voidenable()
Enables this provider. When enabled, calls to {@link #getStatus()} and {@link #getLocation} must be handled. Hardware may be started up when the provider is enabled.

public voidenableLocationTracking(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.

param
enable true if location tracking should be enabled.

        mLocationTracking = enable;
    
public abstract booleangetLocation(Location l)
Sets a Location object with the information gathered during the most recent fix.

param
l location object to set
return
true if a location fix is available

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

return
the smallest minTime value over all listeners for this provider

        return mMinTime;
    
public static android.location.LocationProviderImplgetProvider(java.lang.String name)

        return sProvidersByName.get(name);
    
public static java.util.ListgetProviders()

        return new ArrayList<LocationProviderImpl>(sProviders);
    
public intgetStatus()
Returns a information on the status of this provider. {@link #OUT_OF_SERVICE} is returned if the provider is out of service, and this is not expected to change in the near future; {@link #TEMPORARILY_UNAVAILABLE} is returned if the provider is temporarily unavailable but is expected to be available shortly; and {@link #AVAILABLE} is returned if the provider is currently available.

        return getStatus(null);
    
public abstract intgetStatus(android.os.Bundle extras)
Returns a information on the status of this provider. {@link #OUT_OF_SERVICE} is returned if the provider is out of service, and this is not expected to change in the near future; {@link #TEMPORARILY_UNAVAILABLE} is returned if the provider is temporarily unavailable but is expected to be available shortly; and {@link #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 longgetStatusUpdateTime()
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()} 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.

return
time of last status update in millis since last reboot

        return 0;
    
public abstract booleanisEnabled()
Returns true if this provider is enabled, false otherwise;

public booleanisLocationTracking()
Returns true if the provider has any listeners

return
true if provider is being tracked

        return mLocationTracking;
    
public static android.location.LocationProviderImplloadFromClass(java.io.File classFile)

        if (!classFile.exists()) {
            return null;
        }
        if (Config.LOGD) {
            Log.d(TAG, "Loading class specifier file " + classFile.getPath());
        }
        String className = null;
        try {
            BufferedReader br =
                new BufferedReader(new FileReader(classFile), 8192);
            className = br.readLine();
            br.close();
            Class providerClass = Class.forName(className);
            if (Config.LOGD) {
                Log.d(TAG, "Loading provider class " + providerClass.getName());
            }
            LocationProviderImpl provider =
                (LocationProviderImpl) providerClass.newInstance();
            if (Config.LOGD) {
                Log.d(TAG, "Got provider instance " + provider);
            }

            return provider;
        } catch (IOException ioe) {
            Log.e(TAG, "IOException loading config file " +
                  classFile.getPath(), ioe);
        } catch (IllegalAccessException iae) {
            Log.e(TAG, "IllegalAccessException loading class " +
                  className, iae);
        } catch (InstantiationException ie) {
            Log.e(TAG, "InstantiationException loading class " +
                  className, ie);
        } catch (ClassNotFoundException cnfe) {
            Log.e(TAG, "ClassNotFoundException loading class " +
                  className, cnfe);
        } catch (ClassCastException cce) {
            Log.e(TAG, "ClassCastException loading class " +
                  className, cce);
        }
        return null;
    
public static voidremoveProvider(android.location.LocationProviderImpl provider)

        sProviders.remove(provider);
        sProvidersByName.remove(provider.getName());
    
public booleansendExtraCommand(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.

        return false;
    
public voidsetMinTime(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.

param
minTime the smallest minTime value over all listeners for this provider.

        mMinTime = minTime;
    
public voidupdateCellState(com.android.internal.location.CellState state)
Updates the cell state for the given provider. This function must be overwritten if {@link #requiresCell} returns true.

param
state cell state

    
public voidupdateNetworkState(int state)
Updates the network state for the given provider. This function must be overwritten if {@link #requiresNetwork} returns true. The state is {@link #TEMPORARILY_UNAVAILABLE} (disconnected), OR {@link #AVAILABLE} (connected or connecting).

param
state data state