1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.location;
18
19/**
20 * This class represents the current state of a GPS satellite.
21 * This class is used in conjunction with the {@link GpsStatus} class.
22 */
23public final class GpsSatellite {
24    /* These package private values are modified by the GpsStatus class */
25    boolean mValid;
26    boolean mHasEphemeris;
27    boolean mHasAlmanac;
28    boolean mUsedInFix;
29    int mPrn;
30    float mSnr;
31    float mElevation;
32    float mAzimuth;
33
34    GpsSatellite(int prn) {
35        mPrn = prn;
36    }
37
38    /**
39     * Used by {@link LocationManager#getGpsStatus} to copy LocationManager's
40     * cached GpsStatus instance to the client's copy.
41     */
42    void setStatus(GpsSatellite satellite) {
43        if (satellite == null) {
44            mValid = false;
45        } else {
46            mValid = satellite.mValid;
47            mHasEphemeris = satellite.mHasEphemeris;
48            mHasAlmanac = satellite.mHasAlmanac;
49            mUsedInFix = satellite.mUsedInFix;
50            mSnr = satellite.mSnr;
51            mElevation = satellite.mElevation;
52            mAzimuth = satellite.mAzimuth;
53        }
54    }
55
56    /**
57     * Returns the PRN (pseudo-random number) for the satellite.
58     *
59     * @return PRN number
60     */
61    public int getPrn() {
62        return mPrn;
63    }
64
65    /**
66     * Returns the signal to noise ratio for the satellite.
67     *
68     * @return the signal to noise ratio
69     */
70    public float getSnr() {
71        return mSnr;
72    }
73
74    /**
75     * Returns the elevation of the satellite in degrees.
76     * The elevation can vary between 0 and 90.
77     *
78     * @return the elevation in degrees
79     */
80    public float getElevation() {
81        return mElevation;
82    }
83
84    /**
85     * Returns the azimuth of the satellite in degrees.
86     * The azimuth can vary between 0 and 360.
87     *
88     * @return the azimuth in degrees
89     */
90    public float getAzimuth() {
91        return mAzimuth;
92    }
93
94    /**
95     * Returns true if the GPS engine has ephemeris data for the satellite.
96     *
97     * @return true if the satellite has ephemeris data
98     */
99    public boolean hasEphemeris() {
100        return mHasEphemeris;
101    }
102
103    /**
104     * Returns true if the GPS engine has almanac data for the satellite.
105     *
106     * @return true if the satellite has almanac data
107     */
108    public boolean hasAlmanac() {
109        return mHasAlmanac;
110    }
111
112    /**
113     * Returns true if the satellite was used by the GPS engine when
114     * calculating the most recent GPS fix.
115     *
116     * @return true if the satellite was used to compute the most recent fix.
117     */
118    public boolean usedInFix() {
119        return mUsedInFix;
120    }
121}
122