FileDocCategorySizeDatePackage
GpsStatus.javaAPI DocAndroid 1.5 API6402Wed May 06 22:42:00 BST 2009android.location

GpsStatus

public final class GpsStatus extends Object
This class represents the current state of the GPS engine. This class is used in conjunction with the {@link Listener} interface.

Fields Summary
private static final int
NUM_SATELLITES
private int
mTimeToFirstFix
private GpsSatellite[]
mSatellites
private Iterable
mSatelliteList
public static final int
GPS_EVENT_STARTED
Event sent when the GPS system has started.
public static final int
GPS_EVENT_STOPPED
Event sent when the GPS system has stopped.
public static final int
GPS_EVENT_FIRST_FIX
Event sent when the GPS system has received its first fix since starting. Call {@link #getTimeToFirstFix()} to find the time from start to first fix.
public static final int
GPS_EVENT_SATELLITE_STATUS
Event sent periodically to report GPS satellite status. Call {@link #getSatellites()} to retrieve the status for each satellite.
Constructors Summary
GpsStatus()


                  
       
                                                                     
          
    

     
        for (int i = 0; i < mSatellites.length; i++) {
            mSatellites[i] = new GpsSatellite(i + 1);
        }
    
Methods Summary
public intgetMaxSatellites()
Returns the maximum number of satellites that can be in the satellite list that can be returned by {@link #getSatellites()}.

return
the maximum number of satellites

        return NUM_SATELLITES;
    
public java.lang.IterablegetSatellites()
Returns an array of {@link GpsSatellite} objects, which represent the current state of the GPS engine.

return
the list of satellites

        return mSatelliteList;
    
public intgetTimeToFirstFix()
Returns the time required to receive the first fix since the most recent restart of the GPS engine.

return
time to first fix in milliseconds

        return mTimeToFirstFix;
    
synchronized voidsetStatus(int svCount, int[] prns, float[] snrs, float[] elevations, float[] azimuths, int ephemerisMask, int almanacMask, int usedInFixMask)
Used internally within {@link LocationManager} to copy GPS status data from the Location Manager Service to its cached GpsStatus instance. Is synchronized to ensure that GPS status updates are atomic.

        int i;

        for (i = 0; i < mSatellites.length; i++) {
            mSatellites[i].mValid = false;
        }
        
        for (i = 0; i < svCount; i++) {
            int prn = prns[i] - 1;
            int prnShift = (1 << prn);
            GpsSatellite satellite = mSatellites[prn];

            satellite.mValid = true;
            satellite.mSnr = snrs[i];
            satellite.mElevation = elevations[i];
            satellite.mAzimuth = azimuths[i];
            satellite.mHasEphemeris = ((ephemerisMask & prnShift) != 0);
            satellite.mHasAlmanac = ((almanacMask & prnShift) != 0);
            satellite.mUsedInFix = ((usedInFixMask & prnShift) != 0);
        }
    
voidsetStatus(android.location.GpsStatus status)
Used by {@link LocationManager#getGpsStatus} to copy LocationManager's cached GpsStatus instance to the client's copy. Since this method is only used within {@link LocationManager#getGpsStatus}, it does not need to be synchronized.

        mTimeToFirstFix = status.getTimeToFirstFix();

        for (int i = 0; i < mSatellites.length; i++) {
            mSatellites[i].setStatus(status.mSatellites[i]);
        } 
    
voidsetTimeToFirstFix(int ttff)

        mTimeToFirstFix = ttff;