1 /* 2 * Copyright (C) 2014 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 17 package android.location; 18 19 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_AUTOMATIC_GAIN_CONTROL; 20 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_CARRIER_CYCLES; 21 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_CARRIER_FREQUENCY; 22 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_CARRIER_PHASE; 23 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_CARRIER_PHASE_UNCERTAINTY; 24 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_FULL_ISB; 25 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_FULL_ISB_UNCERTAINTY; 26 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_SATELLITE_ISB; 27 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_SATELLITE_ISB_UNCERTAINTY; 28 import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasurementFlags.HAS_SNR; 29 30 import android.annotation.FloatRange; 31 import android.annotation.IntDef; 32 import android.annotation.NonNull; 33 import android.annotation.TestApi; 34 import android.os.Parcel; 35 import android.os.Parcelable; 36 37 import java.lang.annotation.Retention; 38 import java.lang.annotation.RetentionPolicy; 39 40 /** 41 * A class representing a GNSS satellite measurement, containing raw and computed information. 42 */ 43 public final class GnssMeasurement implements Parcelable { 44 private int mFlags; 45 private int mSvid; 46 private int mConstellationType; 47 private double mTimeOffsetNanos; 48 private int mState; 49 private long mReceivedSvTimeNanos; 50 private long mReceivedSvTimeUncertaintyNanos; 51 private double mCn0DbHz; 52 private double mBasebandCn0DbHz; 53 private double mPseudorangeRateMetersPerSecond; 54 private double mPseudorangeRateUncertaintyMetersPerSecond; 55 private int mAccumulatedDeltaRangeState; 56 private double mAccumulatedDeltaRangeMeters; 57 private double mAccumulatedDeltaRangeUncertaintyMeters; 58 private float mCarrierFrequencyHz; 59 private long mCarrierCycles; 60 private double mCarrierPhase; 61 private double mCarrierPhaseUncertainty; 62 private int mMultipathIndicator; 63 private double mSnrInDb; 64 private double mAutomaticGainControlLevelInDb; 65 @NonNull private String mCodeType; 66 private double mFullInterSignalBiasNanos; 67 private double mFullInterSignalBiasUncertaintyNanos; 68 private double mSatelliteInterSignalBiasNanos; 69 private double mSatelliteInterSignalBiasUncertaintyNanos; 70 71 // The following enumerations must be in sync with the values declared in GNSS HAL. 72 73 private static final int HAS_NO_FLAGS = 0; 74 private static final int HAS_CODE_TYPE = (1 << 14); 75 private static final int HAS_BASEBAND_CN0 = (1 << 15); 76 77 /** 78 * The status of the multipath indicator. 79 * @hide 80 */ 81 @Retention(RetentionPolicy.SOURCE) 82 @IntDef({MULTIPATH_INDICATOR_UNKNOWN, MULTIPATH_INDICATOR_DETECTED, 83 MULTIPATH_INDICATOR_NOT_DETECTED}) 84 public @interface MultipathIndicator {} 85 86 /** 87 * The indicator is not available or the presence or absence of multipath is unknown. 88 */ 89 public static final int MULTIPATH_INDICATOR_UNKNOWN = 0; 90 91 /** 92 * The measurement shows signs of multi-path. 93 */ 94 public static final int MULTIPATH_INDICATOR_DETECTED = 1; 95 96 /** 97 * The measurement shows no signs of multi-path. 98 */ 99 public static final int MULTIPATH_INDICATOR_NOT_DETECTED = 2; 100 101 /** 102 * GNSS measurement tracking loop state 103 * @hide 104 */ 105 @IntDef(flag = true, prefix = { "STATE_" }, value = { 106 STATE_CODE_LOCK, STATE_BIT_SYNC, STATE_SUBFRAME_SYNC, 107 STATE_TOW_DECODED, STATE_MSEC_AMBIGUOUS, STATE_SYMBOL_SYNC, STATE_GLO_STRING_SYNC, 108 STATE_GLO_TOD_DECODED, STATE_BDS_D2_BIT_SYNC, STATE_BDS_D2_SUBFRAME_SYNC, 109 STATE_GAL_E1BC_CODE_LOCK, STATE_GAL_E1C_2ND_CODE_LOCK, STATE_GAL_E1B_PAGE_SYNC, 110 STATE_SBAS_SYNC, STATE_TOW_KNOWN, STATE_GLO_TOD_KNOWN, STATE_2ND_CODE_LOCK 111 }) 112 @Retention(RetentionPolicy.SOURCE) 113 public @interface State {} 114 115 /** This GNSS measurement's tracking state is invalid or unknown. */ 116 public static final int STATE_UNKNOWN = 0; 117 /** This GNSS measurement's tracking state has code lock. */ 118 public static final int STATE_CODE_LOCK = (1<<0); 119 /** This GNSS measurement's tracking state has bit sync. */ 120 public static final int STATE_BIT_SYNC = (1<<1); 121 /** This GNSS measurement's tracking state has sub-frame sync. */ 122 public static final int STATE_SUBFRAME_SYNC = (1<<2); 123 /** This GNSS measurement's tracking state has time-of-week decoded. */ 124 public static final int STATE_TOW_DECODED = (1<<3); 125 /** This GNSS measurement's tracking state contains millisecond ambiguity. */ 126 public static final int STATE_MSEC_AMBIGUOUS = (1<<4); 127 /** This GNSS measurement's tracking state has symbol sync. */ 128 public static final int STATE_SYMBOL_SYNC = (1<<5); 129 /** This Glonass measurement's tracking state has string sync. */ 130 public static final int STATE_GLO_STRING_SYNC = (1<<6); 131 /** This Glonass measurement's tracking state has time-of-day decoded. */ 132 public static final int STATE_GLO_TOD_DECODED = (1<<7); 133 /** This Beidou measurement's tracking state has D2 bit sync. */ 134 public static final int STATE_BDS_D2_BIT_SYNC = (1<<8); 135 /** This Beidou measurement's tracking state has D2 sub-frame sync. */ 136 public static final int STATE_BDS_D2_SUBFRAME_SYNC = (1<<9); 137 /** This Galileo measurement's tracking state has E1B/C code lock. */ 138 public static final int STATE_GAL_E1BC_CODE_LOCK = (1<<10); 139 /** This Galileo measurement's tracking state has E1C secondary code lock. */ 140 public static final int STATE_GAL_E1C_2ND_CODE_LOCK = (1<<11); 141 /** This Galileo measurement's tracking state has E1B page sync. */ 142 public static final int STATE_GAL_E1B_PAGE_SYNC = (1<<12); 143 /** This SBAS measurement's tracking state has whole second level sync. */ 144 public static final int STATE_SBAS_SYNC = (1<<13); 145 /** 146 * This GNSS measurement's tracking state has time-of-week known, possibly not decoded 147 * over the air but has been determined from other sources. If TOW decoded is set then TOW Known 148 * will also be set. 149 */ 150 public static final int STATE_TOW_KNOWN = (1<<14); 151 /** 152 * This Glonass measurement's tracking state has time-of-day known, possibly not decoded 153 * over the air but has been determined from other sources. If TOD decoded is set then TOD Known 154 * will also be set. 155 */ 156 public static final int STATE_GLO_TOD_KNOWN = (1<<15); 157 158 /** This GNSS measurement's tracking state has secondary code lock. */ 159 public static final int STATE_2ND_CODE_LOCK = (1 << 16); 160 161 /** 162 * All the GNSS receiver state flags, for bit masking purposes (not a sensible state for any 163 * individual measurement.) 164 */ 165 private static final int STATE_ALL = 0x3fff; // 2 bits + 4 bits + 4 bits + 4 bits = 14 bits 166 167 /** 168 * GNSS measurement accumulated delta range state 169 * @hide 170 */ 171 @IntDef(flag = true, prefix = { "ADR_STATE_" }, value = { 172 ADR_STATE_VALID, ADR_STATE_RESET, ADR_STATE_CYCLE_SLIP, ADR_STATE_HALF_CYCLE_RESOLVED, 173 ADR_STATE_HALF_CYCLE_REPORTED 174 }) 175 @Retention(RetentionPolicy.SOURCE) 176 public @interface AdrState {} 177 178 /** 179 * The state of the value {@link #getAccumulatedDeltaRangeMeters()} is invalid or unknown. 180 */ 181 public static final int ADR_STATE_UNKNOWN = 0; 182 183 /** 184 * The state of the {@link #getAccumulatedDeltaRangeMeters()} is valid. 185 */ 186 public static final int ADR_STATE_VALID = (1<<0); 187 188 /** 189 * The state of the {@link #getAccumulatedDeltaRangeMeters()} has detected a reset. 190 */ 191 public static final int ADR_STATE_RESET = (1<<1); 192 193 /** 194 * The state of the {@link #getAccumulatedDeltaRangeMeters()} has a cycle slip detected. 195 */ 196 public static final int ADR_STATE_CYCLE_SLIP = (1<<2); 197 198 /** 199 * Reports whether the value {@link #getAccumulatedDeltaRangeMeters()} has resolved the half 200 * cycle ambiguity. 201 * 202 * <p> When this bit is set, the {@link #getAccumulatedDeltaRangeMeters()} corresponds to the 203 * carrier phase measurement plus an accumulated integer number of carrier full cycles. 204 * 205 * <p> When this bit is unset, the {@link #getAccumulatedDeltaRangeMeters()} corresponds to the 206 * carrier phase measurement plus an accumulated integer number of carrier half cycles. 207 */ 208 public static final int ADR_STATE_HALF_CYCLE_RESOLVED = (1<<3); 209 210 /** 211 * Reports whether the flag {@link #ADR_STATE_HALF_CYCLE_RESOLVED} has been reported by the 212 * GNSS hardware. 213 * 214 * <p> When this bit is set, the value of {@link #getAccumulatedDeltaRangeUncertaintyMeters()} 215 * can be low (centimeter level) whether or not the half cycle ambiguity is resolved. 216 * 217 * <p> When this bit is unset, the value of {@link #getAccumulatedDeltaRangeUncertaintyMeters()} 218 * is larger, to cover the potential error due to half cycle ambiguity being unresolved. 219 */ 220 public static final int ADR_STATE_HALF_CYCLE_REPORTED = (1<<4); 221 222 /** 223 * All the 'Accumulated Delta Range' flags. 224 * @hide 225 */ 226 @TestApi 227 public static final int ADR_STATE_ALL = 228 ADR_STATE_VALID | ADR_STATE_RESET | ADR_STATE_CYCLE_SLIP | 229 ADR_STATE_HALF_CYCLE_RESOLVED | ADR_STATE_HALF_CYCLE_REPORTED; 230 231 // End enumerations in sync with gps.h 232 233 /** 234 * @hide 235 */ 236 @TestApi GnssMeasurement()237 public GnssMeasurement() { 238 initialize(); 239 } 240 241 /** 242 * Sets all contents to the values stored in the provided object. 243 * @hide 244 */ 245 @TestApi set(GnssMeasurement measurement)246 public void set(GnssMeasurement measurement) { 247 mFlags = measurement.mFlags; 248 mSvid = measurement.mSvid; 249 mConstellationType = measurement.mConstellationType; 250 mTimeOffsetNanos = measurement.mTimeOffsetNanos; 251 mState = measurement.mState; 252 mReceivedSvTimeNanos = measurement.mReceivedSvTimeNanos; 253 mReceivedSvTimeUncertaintyNanos = measurement.mReceivedSvTimeUncertaintyNanos; 254 mCn0DbHz = measurement.mCn0DbHz; 255 mBasebandCn0DbHz = measurement.mBasebandCn0DbHz; 256 mPseudorangeRateMetersPerSecond = measurement.mPseudorangeRateMetersPerSecond; 257 mPseudorangeRateUncertaintyMetersPerSecond = 258 measurement.mPseudorangeRateUncertaintyMetersPerSecond; 259 mAccumulatedDeltaRangeState = measurement.mAccumulatedDeltaRangeState; 260 mAccumulatedDeltaRangeMeters = measurement.mAccumulatedDeltaRangeMeters; 261 mAccumulatedDeltaRangeUncertaintyMeters = 262 measurement.mAccumulatedDeltaRangeUncertaintyMeters; 263 mCarrierFrequencyHz = measurement.mCarrierFrequencyHz; 264 mCarrierCycles = measurement.mCarrierCycles; 265 mCarrierPhase = measurement.mCarrierPhase; 266 mCarrierPhaseUncertainty = measurement.mCarrierPhaseUncertainty; 267 mMultipathIndicator = measurement.mMultipathIndicator; 268 mSnrInDb = measurement.mSnrInDb; 269 mAutomaticGainControlLevelInDb = measurement.mAutomaticGainControlLevelInDb; 270 mCodeType = measurement.mCodeType; 271 mFullInterSignalBiasNanos = measurement.mFullInterSignalBiasNanos; 272 mFullInterSignalBiasUncertaintyNanos = 273 measurement.mFullInterSignalBiasUncertaintyNanos; 274 mSatelliteInterSignalBiasNanos = measurement.mSatelliteInterSignalBiasNanos; 275 mSatelliteInterSignalBiasUncertaintyNanos = 276 measurement.mSatelliteInterSignalBiasUncertaintyNanos; 277 } 278 279 /** 280 * Resets all the contents to its original state. 281 * @hide 282 */ 283 @TestApi reset()284 public void reset() { 285 initialize(); 286 } 287 288 /** 289 * Gets the satellite ID. 290 * 291 * <p>Interpretation depends on {@link #getConstellationType()}. 292 * See {@link GnssStatus#getSvid(int)}. 293 */ getSvid()294 public int getSvid() { 295 return mSvid; 296 } 297 298 /** 299 * Sets the Satellite ID. 300 * @hide 301 */ 302 @TestApi setSvid(int value)303 public void setSvid(int value) { 304 mSvid = value; 305 } 306 307 /** 308 * Gets the constellation type. 309 * 310 * <p>The return value is one of those constants with {@code CONSTELLATION_} prefix in 311 * {@link GnssStatus}. 312 */ 313 @GnssStatus.ConstellationType getConstellationType()314 public int getConstellationType() { 315 return mConstellationType; 316 } 317 318 /** 319 * Sets the constellation type. 320 * @hide 321 */ 322 @TestApi setConstellationType(@nssStatus.ConstellationType int value)323 public void setConstellationType(@GnssStatus.ConstellationType int value) { 324 mConstellationType = value; 325 } 326 327 /** 328 * Gets the time offset at which the measurement was taken in nanoseconds. 329 * 330 * <p>The reference receiver's time from which this is offset is specified by 331 * {@link GnssClock#getTimeNanos()}. 332 * 333 * <p>The sign of this value is given by the following equation: 334 * <pre> 335 * measurement time = TimeNanos + TimeOffsetNanos</pre> 336 * 337 * <p>The value provides an individual time-stamp for the measurement, and allows sub-nanosecond 338 * accuracy. 339 */ getTimeOffsetNanos()340 public double getTimeOffsetNanos() { 341 return mTimeOffsetNanos; 342 } 343 344 /** 345 * Sets the time offset at which the measurement was taken in nanoseconds. 346 * @hide 347 */ 348 @TestApi setTimeOffsetNanos(double value)349 public void setTimeOffsetNanos(double value) { 350 mTimeOffsetNanos = value; 351 } 352 353 /** 354 * Gets per-satellite sync state. 355 * 356 * <p>It represents the current sync state for the associated satellite. 357 * 358 * <p>This value helps interpret {@link #getReceivedSvTimeNanos()}. 359 */ 360 @State getState()361 public int getState() { 362 return mState; 363 } 364 365 /** 366 * Sets the sync state. 367 * @hide 368 */ 369 @TestApi setState(@tate int value)370 public void setState(@State int value) { 371 mState = value; 372 } 373 374 /** 375 * Gets a string representation of the 'sync state'. 376 * 377 * <p>For internal and logging use only. 378 */ getStateString()379 private String getStateString() { 380 if (mState == STATE_UNKNOWN) { 381 return "Unknown"; 382 } 383 384 StringBuilder builder = new StringBuilder(); 385 if ((mState & STATE_CODE_LOCK) != 0) { 386 builder.append("CodeLock|"); 387 } 388 if ((mState & STATE_BIT_SYNC) != 0) { 389 builder.append("BitSync|"); 390 } 391 if ((mState & STATE_SUBFRAME_SYNC) != 0) { 392 builder.append("SubframeSync|"); 393 } 394 if ((mState & STATE_TOW_DECODED) != 0) { 395 builder.append("TowDecoded|"); 396 } 397 if ((mState & STATE_TOW_KNOWN) != 0) { 398 builder.append("TowKnown|"); 399 } 400 if ((mState & STATE_MSEC_AMBIGUOUS) != 0) { 401 builder.append("MsecAmbiguous|"); 402 } 403 if ((mState & STATE_SYMBOL_SYNC) != 0) { 404 builder.append("SymbolSync|"); 405 } 406 if ((mState & STATE_GLO_STRING_SYNC) != 0) { 407 builder.append("GloStringSync|"); 408 } 409 if ((mState & STATE_GLO_TOD_DECODED) != 0) { 410 builder.append("GloTodDecoded|"); 411 } 412 if ((mState & STATE_GLO_TOD_KNOWN) != 0) { 413 builder.append("GloTodKnown|"); 414 } 415 if ((mState & STATE_BDS_D2_BIT_SYNC) != 0) { 416 builder.append("BdsD2BitSync|"); 417 } 418 if ((mState & STATE_BDS_D2_SUBFRAME_SYNC) != 0) { 419 builder.append("BdsD2SubframeSync|"); 420 } 421 if ((mState & STATE_GAL_E1BC_CODE_LOCK) != 0) { 422 builder.append("GalE1bcCodeLock|"); 423 } 424 if ((mState & STATE_GAL_E1C_2ND_CODE_LOCK) != 0) { 425 builder.append("E1c2ndCodeLock|"); 426 } 427 if ((mState & STATE_GAL_E1B_PAGE_SYNC) != 0) { 428 builder.append("GalE1bPageSync|"); 429 } 430 if ((mState & STATE_SBAS_SYNC) != 0) { 431 builder.append("SbasSync|"); 432 } 433 if ((mState & STATE_2ND_CODE_LOCK) != 0) { 434 builder.append("2ndCodeLock|"); 435 } 436 437 int remainingStates = mState & ~STATE_ALL; 438 if (remainingStates > 0) { 439 builder.append("Other("); 440 builder.append(Integer.toBinaryString(remainingStates)); 441 builder.append(")|"); 442 } 443 builder.setLength(builder.length() - 1); 444 return builder.toString(); 445 } 446 447 /** 448 * Gets the received GNSS satellite time, at the measurement time, in nanoseconds. 449 * 450 * <p>The received satellite time is relative to the beginning of the system week for all 451 * constellations except for Glonass where it is relative to the beginning of the Glonass 452 * system day. 453 * 454 * <p>The table below indicates the valid range of the received GNSS satellite time. These 455 * ranges depend on the constellation and code being tracked and the state of the tracking 456 * algorithms given by the {@link #getState} method. The minimum value of this field is zero. 457 * The maximum value of this field is determined by looking across all of the state flags 458 * that are set, for the given constellation and code type, and finding the the maximum value 459 * in this table. 460 * 461 * <p>For example, for GPS L1 C/A, if STATE_TOW_KNOWN is set, this field can be any value from 0 462 * to 1 week (in nanoseconds), and for GAL E1B code, if only STATE_GAL_E1BC_CODE_LOCK is set, 463 * then this field can be any value from 0 to 4 milliseconds (in nanoseconds.) 464 * 465 * <table border="1"> 466 * <thead> 467 * <tr> 468 * <td /> 469 * <td colspan="3"><strong>GPS/QZSS</strong></td> 470 * <td><strong>GLNS</strong></td> 471 * <td colspan="2"><strong>BDS</strong></td> 472 * <td colspan="3"><strong>GAL</strong></td> 473 * <td><strong>SBAS</strong></td> 474 * </tr> 475 * <tr> 476 * <td><strong>State Flag</strong></td> 477 * <td><strong>L1 C/A</strong></td> 478 * <td><strong>L5I</strong></td> 479 * <td><strong>L5Q</strong></td> 480 * <td><strong>L1OF</strong></td> 481 * <td><strong>B1I (D1)</strong></td> 482 * <td><strong>B1I (D2)</strong></td> 483 * <td><strong>E1B</strong></td> 484 * <td><strong>E1C</strong></td> 485 * <td><strong>E5AQ</strong></td> 486 * <td><strong>L1 C/A</strong></td> 487 * </tr> 488 * </thead> 489 * <tbody> 490 * <tr> 491 * <td> 492 * <strong>STATE_UNKNOWN</strong> 493 * </td> 494 * <td>0</td> 495 * <td>0</td> 496 * <td>0</td> 497 * <td>0</td> 498 * <td>0</td> 499 * <td>0</td> 500 * <td>0</td> 501 * <td>0</td> 502 * <td>0</td> 503 * <td>0</td> 504 * </tr> 505 * <tr> 506 * <td> 507 * <strong>STATE_CODE_LOCK</strong> 508 * </td> 509 * <td>1 ms</td> 510 * <td>1 ms</td> 511 * <td>1 ms</td> 512 * <td>1 ms</td> 513 * <td>1 ms</td> 514 * <td>1 ms</td> 515 * <td>-</td> 516 * <td>-</td> 517 * <td>1 ms</td> 518 * <td>1 ms</td> 519 * </tr> 520 * <tr> 521 * <td> 522 * <strong>STATE_SYMBOL_SYNC</strong> 523 * </td> 524 * <td>20 ms (optional)</td> 525 * <td>10 ms</td> 526 * <td>1 ms (optional)</td> 527 * <td>10 ms</td> 528 * <td>20 ms (optional)</td> 529 * <td>2 ms</td> 530 * <td>4 ms (optional)</td> 531 * <td>4 ms (optional)</td> 532 * <td>1 ms (optional)</td> 533 * <td>2 ms</td> 534 * </tr> 535 * <tr> 536 * <td> 537 * <strong>STATE_BIT_SYNC</strong> 538 * </td> 539 * <td>20 ms</td> 540 * <td>20 ms</td> 541 * <td>1 ms (optional)</td> 542 * <td>20 ms</td> 543 * <td>20 ms</td> 544 * <td>-</td> 545 * <td>8 ms</td> 546 * <td>-</td> 547 * <td>1 ms (optional)</td> 548 * <td>4 ms</td> 549 * </tr> 550 * <tr> 551 * <td> 552 * <strong>STATE_SUBFRAME_SYNC</strong> 553 * </td> 554 * <td>6s</td> 555 * <td>6s</td> 556 * <td>-</td> 557 * <td>2 s</td> 558 * <td>6 s</td> 559 * <td>-</td> 560 * <td>-</td> 561 * <td>-</td> 562 * <td>100 ms</td> 563 * <td>-</td> 564 * </tr> 565 * <tr> 566 * <td> 567 * <strong>STATE_TOW_DECODED</strong> 568 * </td> 569 * <td colspan="2">1 week</td> 570 * <td>-</td> 571 * <td>1 day</td> 572 * <td colspan="2">1 week</td> 573 * <td colspan="2">1 week</td> 574 * <td>-</td> 575 * <td>1 week</td> 576 * </tr> 577 * <tr> 578 * <td> 579 * <strong>STATE_TOW_KNOWN</strong> 580 * </td> 581 * <td colspan="3">1 week</td> 582 * <td>1 day</td> 583 * <td colspan="2">1 week</td> 584 * <td colspan="3">1 week</td> 585 * <td>1 week</td> 586 * </tr> 587 * <tr> 588 * <td> 589 * <strong>STATE_GLO_STRING_SYNC</strong> 590 * </td> 591 * <td>-</td> 592 * <td>-</td> 593 * <td>-</td> 594 * <td>2 s</td> 595 * <td>-</td> 596 * <td>-</td> 597 * <td>-</td> 598 * <td>-</td> 599 * <td>-</td> 600 * <td>-</td> 601 * </tr> 602 * <tr> 603 * <td> 604 * <strong>STATE_GLO_TOD_DECODED</strong> 605 * </td> 606 * <td>-</td> 607 * <td>-</td> 608 * <td>-</td> 609 * <td>1 day</td> 610 * <td>-</td> 611 * <td>-</td> 612 * <td>-</td> 613 * <td>-</td> 614 * <td>-</td> 615 * <td>-</td> 616 * </tr> 617 * <tr> 618 * <td> 619 * <strong>STATE_GLO_TOD_KNOWN</strong> 620 * </td> 621 * <td>-</td> 622 * <td>-</td> 623 * <td>-</td> 624 * <td>1 day</td> 625 * <td>-</td> 626 * <td>-</td> 627 * <td>-</td> 628 * <td>-</td> 629 * <td>-</td> 630 * <td>-</td> 631 * </tr> 632 * <tr> 633 * <td> 634 * <strong>STATE_BDS_D2_BIT_SYNC</strong> 635 * </td> 636 * <td>-</td> 637 * <td>-</td> 638 * <td>-</td> 639 * <td>-</td> 640 * <td>-</td> 641 * <td>2 ms</td> 642 * <td>-</td> 643 * <td>-</td> 644 * <td>-</td> 645 * <td>-</td> 646 * </tr> 647 * <tr> 648 * <td> 649 * <strong>STATE_BDS_D2_SUBFRAME_SYNC</strong> 650 * </td> 651 * <td>-</td> 652 * <td>-</td> 653 * <td>-</td> 654 * <td>-</td> 655 * <td>-</td> 656 * <td>600 ms</td> 657 * <td>-</td> 658 * <td>-</td> 659 * <td>-</td> 660 * <td>-</td> 661 * </tr> 662 * <tr> 663 * <td> 664 * <strong>STATE_GAL_E1BC_CODE_LOCK</strong> 665 * </td> 666 * <td>-</td> 667 * <td>-</td> 668 * <td>-</td> 669 * <td>-</td> 670 * <td>-</td> 671 * <td>-</td> 672 * <td>4 ms</td> 673 * <td>4 ms</td> 674 * <td>-</td> 675 * <td>-</td> 676 * </tr> 677 * <tr> 678 * <td> 679 * <strong>STATE_GAL_E1C_2ND_CODE_LOCK</strong> 680 * </td> 681 * <td>-</td> 682 * <td>-</td> 683 * <td>-</td> 684 * <td>-</td> 685 * <td>-</td> 686 * <td>-</td> 687 * <td>-</td> 688 * <td>100 ms</td> 689 * <td>-</td> 690 * <td>-</td> 691 * </tr> 692 * <tr> 693 * <td> 694 * <strong>STATE_2ND_CODE_LOCK</strong> 695 * </td> 696 * <td>-</td> 697 * <td>10 ms (optional)</td> 698 * <td>20 ms</td> 699 * <td>-</td> 700 * <td>-</td> 701 * <td>-</td> 702 * <td>-</td> 703 * <td>100 ms (optional)</td> 704 * <td>100 ms</td> 705 * <td>-</td> 706 * </tr> 707 * <tr> 708 * <td> 709 * <strong>STATE_GAL_E1B_PAGE_SYNC</strong> 710 * </td> 711 * <td>-</td> 712 * <td>-</td> 713 * <td>-</td> 714 * <td>-</td> 715 * <td>-</td> 716 * <td>-</td> 717 * <td>2 s</td> 718 * <td>-</td> 719 * <td>-</td> 720 * <td>-</td> 721 * </tr> 722 * <tr> 723 * <td> 724 * <strong>STATE_SBAS_SYNC</strong> 725 * </td> 726 * <td>-</td> 727 * <td>-</td> 728 * <td>-</td> 729 * <td>-</td> 730 * <td>-</td> 731 * <td>-</td> 732 * <td>-</td> 733 * <td>-</td> 734 * <td>-</td> 735 * <td>1 s</td> 736 * </tr> 737 * </tbody> 738 * </table> 739 * 740 * <p>Note: TOW Known refers to the case where TOW is possibly not decoded over the air but has 741 * been determined from other sources. If TOW decoded is set then TOW Known must also be set. 742 * 743 * <p>Note well: if there is any ambiguity in integer millisecond, STATE_MSEC_AMBIGUOUS must be 744 * set accordingly, in the 'state' field. This value must be populated, unless the 'state' == 745 * STATE_UNKNOWN. 746 * 747 * <p>Note on optional flags: 748 * <ul> 749 * <li> For L1 C/A and B1I, STATE_SYMBOL_SYNC is optional since the symbol length is the 750 * same as the bit length. 751 * <li> For L5Q and E5aQ, STATE_BIT_SYNC and STATE_SYMBOL_SYNC are optional since they are 752 * implied by STATE_CODE_LOCK. 753 * <li> STATE_2ND_CODE_LOCK for L5I is optional since it is implied by STATE_SYMBOL_SYNC. 754 * <li> STATE_2ND_CODE_LOCK for E1C is optional since it is implied by 755 * STATE_GAL_E1C_2ND_CODE_LOCK. 756 * <li> For E1B and E1C, STATE_SYMBOL_SYNC is optional, because it is implied by 757 * STATE_GAL_E1BC_CODE_LOCK. 758 * </ul> 759 */ getReceivedSvTimeNanos()760 public long getReceivedSvTimeNanos() { 761 return mReceivedSvTimeNanos; 762 } 763 764 /** 765 * Sets the received GNSS time in nanoseconds. 766 * @hide 767 */ 768 @TestApi setReceivedSvTimeNanos(long value)769 public void setReceivedSvTimeNanos(long value) { 770 mReceivedSvTimeNanos = value; 771 } 772 773 /** 774 * Gets the error estimate (1-sigma) for the received GNSS time, in nanoseconds. 775 */ getReceivedSvTimeUncertaintyNanos()776 public long getReceivedSvTimeUncertaintyNanos() { 777 return mReceivedSvTimeUncertaintyNanos; 778 } 779 780 /** 781 * Sets the received GNSS time uncertainty (1-Sigma) in nanoseconds. 782 * @hide 783 */ 784 @TestApi setReceivedSvTimeUncertaintyNanos(long value)785 public void setReceivedSvTimeUncertaintyNanos(long value) { 786 mReceivedSvTimeUncertaintyNanos = value; 787 } 788 789 /** 790 * Gets the Carrier-to-noise density in dB-Hz. 791 * 792 * <p>Typical range: 10-50 dB-Hz. The range of possible C/N0 values is 0-63 dB-Hz to handle 793 * some edge cases. 794 * 795 * <p>The value contains the measured C/N0 for the signal at the antenna input. 796 */ 797 @FloatRange(from = 0, to = 63) getCn0DbHz()798 public double getCn0DbHz() { 799 return mCn0DbHz; 800 } 801 802 /** 803 * Sets the carrier-to-noise density in dB-Hz. 804 * @hide 805 */ 806 @TestApi setCn0DbHz(double value)807 public void setCn0DbHz(double value) { 808 mCn0DbHz = value; 809 } 810 811 /** 812 * Returns {@code true} if {@link #getBasebandCn0DbHz()} is available, {@code false} otherwise. 813 */ hasBasebandCn0DbHz()814 public boolean hasBasebandCn0DbHz() { 815 return isFlagSet(HAS_BASEBAND_CN0); 816 } 817 818 /** 819 * Gets the baseband carrier-to-noise density in dB-Hz. 820 * 821 * <p>Typical range: 10-50 dB-Hz. The range of possible baseband C/N0 values is 0-63 dB-Hz to 822 * handle some edge cases. 823 * 824 * <p>The value contains the measured C/N0 for the signal at the baseband. This is typically 825 * a few dB weaker than the value estimated for C/N0 at the antenna port, which is reported 826 * in {@link #getCn0DbHz()}. 827 */ 828 @FloatRange(from = 0, to = 63) getBasebandCn0DbHz()829 public double getBasebandCn0DbHz() { 830 return mBasebandCn0DbHz; 831 } 832 833 /** 834 * Sets the baseband carrier-to-noise density in dB-Hz. 835 * 836 * @hide 837 */ 838 @TestApi setBasebandCn0DbHz(double value)839 public void setBasebandCn0DbHz(double value) { 840 setFlag(HAS_BASEBAND_CN0); 841 mBasebandCn0DbHz = value; 842 } 843 844 /** 845 * Resets the baseband carrier-to-noise density in dB-Hz. 846 * 847 * @hide 848 */ 849 @TestApi resetBasebandCn0DbHz()850 public void resetBasebandCn0DbHz() { 851 resetFlag(HAS_BASEBAND_CN0); 852 } 853 854 /** 855 * Gets the Pseudorange rate at the timestamp in m/s. 856 * 857 * <p>The error estimate for this value is 858 * {@link #getPseudorangeRateUncertaintyMetersPerSecond()}. 859 * 860 * <p>The value is uncorrected, i.e. corrections for receiver and satellite clock frequency 861 * errors are not included. 862 * 863 * <p>A positive 'uncorrected' value indicates that the SV is moving away from the receiver. The 864 * sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler shift' 865 * is given by the equation: 866 * 867 * <pre> 868 * pseudorange rate = -k * doppler shift (where k is a constant)</pre> 869 */ getPseudorangeRateMetersPerSecond()870 public double getPseudorangeRateMetersPerSecond() { 871 return mPseudorangeRateMetersPerSecond; 872 } 873 874 /** 875 * Sets the pseudorange rate at the timestamp in m/s. 876 * @hide 877 */ 878 @TestApi setPseudorangeRateMetersPerSecond(double value)879 public void setPseudorangeRateMetersPerSecond(double value) { 880 mPseudorangeRateMetersPerSecond = value; 881 } 882 883 /** 884 * Gets the pseudorange's rate uncertainty (1-Sigma) in m/s. 885 * 886 * <p>The uncertainty is represented as an absolute (single sided) value. 887 */ getPseudorangeRateUncertaintyMetersPerSecond()888 public double getPseudorangeRateUncertaintyMetersPerSecond() { 889 return mPseudorangeRateUncertaintyMetersPerSecond; 890 } 891 892 /** 893 * Sets the pseudorange's rate uncertainty (1-Sigma) in m/s. 894 * @hide 895 */ 896 @TestApi setPseudorangeRateUncertaintyMetersPerSecond(double value)897 public void setPseudorangeRateUncertaintyMetersPerSecond(double value) { 898 mPseudorangeRateUncertaintyMetersPerSecond = value; 899 } 900 901 /** 902 * Gets 'Accumulated Delta Range' state. 903 * 904 * <p>It indicates whether {@link #getAccumulatedDeltaRangeMeters()} is reset or there is a 905 * cycle slip (indicating 'loss of lock'). 906 */ 907 @AdrState getAccumulatedDeltaRangeState()908 public int getAccumulatedDeltaRangeState() { 909 return mAccumulatedDeltaRangeState; 910 } 911 912 /** 913 * Sets the 'Accumulated Delta Range' state. 914 * @hide 915 */ 916 @TestApi setAccumulatedDeltaRangeState(@drState int value)917 public void setAccumulatedDeltaRangeState(@AdrState int value) { 918 mAccumulatedDeltaRangeState = value; 919 } 920 921 /** 922 * Gets a string representation of the 'Accumulated Delta Range state'. 923 * 924 * <p>For internal and logging use only. 925 */ getAccumulatedDeltaRangeStateString()926 private String getAccumulatedDeltaRangeStateString() { 927 if (mAccumulatedDeltaRangeState == ADR_STATE_UNKNOWN) { 928 return "Unknown"; 929 } 930 StringBuilder builder = new StringBuilder(); 931 if ((mAccumulatedDeltaRangeState & ADR_STATE_VALID) == ADR_STATE_VALID) { 932 builder.append("Valid|"); 933 } 934 if ((mAccumulatedDeltaRangeState & ADR_STATE_RESET) == ADR_STATE_RESET) { 935 builder.append("Reset|"); 936 } 937 if ((mAccumulatedDeltaRangeState & ADR_STATE_CYCLE_SLIP) == ADR_STATE_CYCLE_SLIP) { 938 builder.append("CycleSlip|"); 939 } 940 if ((mAccumulatedDeltaRangeState & ADR_STATE_HALF_CYCLE_RESOLVED) == 941 ADR_STATE_HALF_CYCLE_RESOLVED) { 942 builder.append("HalfCycleResolved|"); 943 } 944 if ((mAccumulatedDeltaRangeState & ADR_STATE_HALF_CYCLE_REPORTED) 945 == ADR_STATE_HALF_CYCLE_REPORTED) { 946 builder.append("HalfCycleReported|"); 947 } 948 int remainingStates = mAccumulatedDeltaRangeState & ~ADR_STATE_ALL; 949 if (remainingStates > 0) { 950 builder.append("Other("); 951 builder.append(Integer.toBinaryString(remainingStates)); 952 builder.append(")|"); 953 } 954 builder.deleteCharAt(builder.length() - 1); 955 return builder.toString(); 956 } 957 958 /** 959 * Gets the accumulated delta range since the last channel reset, in meters. 960 * 961 * <p>The error estimate for this value is {@link #getAccumulatedDeltaRangeUncertaintyMeters()}. 962 * 963 * <p>The availability of the value is represented by {@link #getAccumulatedDeltaRangeState()}. 964 * 965 * <p>A positive value indicates that the SV is moving away from the receiver. 966 * The sign of {@link #getAccumulatedDeltaRangeMeters()} and its relation to the sign of 967 * {@link #getCarrierPhase()} is given by the equation: 968 * 969 * <pre> 970 * accumulated delta range = -k * carrier phase (where k is a constant)</pre> 971 * 972 * <p>Similar to the concept of an RTCM "Phaserange", when the accumulated delta range is 973 * initially chosen, and whenever it is reset, it will retain the integer nature 974 * of the relative carrier phase offset between satellites observed by this receiver, such that 975 * the double difference of this value between receivers and satellites may be used, together 976 * with integer ambiguity resolution, to determine highly precise relative location between 977 * receivers. 978 * 979 * <p>This includes ensuring that all half-cycle ambiguities are resolved before this value is 980 * reported as {@link #ADR_STATE_VALID}. 981 * 982 * <p>The alignment of the phase measurement will not be adjusted by the receiver so the 983 * in-phase and quadrature phase components will have a quarter cycle offset as they do when 984 * transmitted from the satellites. If the measurement is from a combination of the in-phase 985 * and quadrature phase components, then the alignment of the phase measurement will be aligned 986 * to the in-phase component. 987 */ getAccumulatedDeltaRangeMeters()988 public double getAccumulatedDeltaRangeMeters() { 989 return mAccumulatedDeltaRangeMeters; 990 } 991 992 /** 993 * Sets the accumulated delta range in meters. 994 * @hide 995 */ 996 @TestApi setAccumulatedDeltaRangeMeters(double value)997 public void setAccumulatedDeltaRangeMeters(double value) { 998 mAccumulatedDeltaRangeMeters = value; 999 } 1000 1001 /** 1002 * Gets the accumulated delta range's uncertainty (1-Sigma) in meters. 1003 * 1004 * <p>The uncertainty is represented as an absolute (single sided) value. 1005 * 1006 * <p>The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}. 1007 */ getAccumulatedDeltaRangeUncertaintyMeters()1008 public double getAccumulatedDeltaRangeUncertaintyMeters() { 1009 return mAccumulatedDeltaRangeUncertaintyMeters; 1010 } 1011 1012 /** 1013 * Sets the accumulated delta range's uncertainty (1-sigma) in meters. 1014 * 1015 * <p>The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}. 1016 * 1017 * @hide 1018 */ 1019 @TestApi setAccumulatedDeltaRangeUncertaintyMeters(double value)1020 public void setAccumulatedDeltaRangeUncertaintyMeters(double value) { 1021 mAccumulatedDeltaRangeUncertaintyMeters = value; 1022 } 1023 1024 /** 1025 * Returns {@code true} if {@link #getCarrierFrequencyHz()} is available, {@code false} 1026 * otherwise. 1027 */ hasCarrierFrequencyHz()1028 public boolean hasCarrierFrequencyHz() { 1029 return isFlagSet(HAS_CARRIER_FREQUENCY); 1030 } 1031 1032 /** 1033 * Gets the carrier frequency of the tracked signal. 1034 * 1035 * <p>For example it can be the GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, 1036 * L5 = 1176.45 MHz, varying GLO channels, etc. If the field is not set, it is the primary 1037 * common use central frequency, e.g. L1 = 1575.45 MHz for GPS. 1038 * 1039 * <p> For an L1, L5 receiver tracking a satellite on L1 and L5 at the same time, two raw 1040 * measurement objects will be reported for this same satellite, in one of the measurement 1041 * objects, all the values related to L1 will be filled, and in the other all of the values 1042 * related to L5 will be filled. 1043 * 1044 * <p>The value is only available if {@link #hasCarrierFrequencyHz()} is {@code true}. 1045 * 1046 * @return the carrier frequency of the signal tracked in Hz. 1047 */ getCarrierFrequencyHz()1048 public float getCarrierFrequencyHz() { 1049 return mCarrierFrequencyHz; 1050 } 1051 1052 /** 1053 * Sets the Carrier frequency in Hz. 1054 * @hide 1055 */ 1056 @TestApi setCarrierFrequencyHz(float carrierFrequencyHz)1057 public void setCarrierFrequencyHz(float carrierFrequencyHz) { 1058 setFlag(HAS_CARRIER_FREQUENCY); 1059 mCarrierFrequencyHz = carrierFrequencyHz; 1060 } 1061 1062 /** 1063 * Resets the Carrier frequency in Hz. 1064 * @hide 1065 */ 1066 @TestApi resetCarrierFrequencyHz()1067 public void resetCarrierFrequencyHz() { 1068 resetFlag(HAS_CARRIER_FREQUENCY); 1069 mCarrierFrequencyHz = Float.NaN; 1070 } 1071 1072 /** 1073 * Returns {@code true} if {@link #getCarrierCycles()} is available, {@code false} otherwise. 1074 * 1075 * @deprecated use {@link #getAccumulatedDeltaRangeState()} instead. 1076 */ 1077 @Deprecated hasCarrierCycles()1078 public boolean hasCarrierCycles() { 1079 return isFlagSet(HAS_CARRIER_CYCLES); 1080 } 1081 1082 /** 1083 * The number of full carrier cycles between the satellite and the receiver. 1084 * 1085 * <p>The reference frequency is given by the value of {@link #getCarrierFrequencyHz()}. 1086 * 1087 * <p>The value is only available if {@link #hasCarrierCycles()} is {@code true}. 1088 * 1089 * @deprecated use {@link #getAccumulatedDeltaRangeMeters()} instead. 1090 */ 1091 @Deprecated getCarrierCycles()1092 public long getCarrierCycles() { 1093 return mCarrierCycles; 1094 } 1095 1096 /** 1097 * Sets the number of full carrier cycles between the satellite and the receiver. 1098 * 1099 * @deprecated use {@link #setAccumulatedDeltaRangeMeters(double)} 1100 * and {@link #setAccumulatedDeltaRangeState(int)} instead. 1101 * 1102 * @hide 1103 */ 1104 @TestApi 1105 @Deprecated setCarrierCycles(long value)1106 public void setCarrierCycles(long value) { 1107 setFlag(HAS_CARRIER_CYCLES); 1108 mCarrierCycles = value; 1109 } 1110 1111 /** 1112 * Resets the number of full carrier cycles between the satellite and the receiver. 1113 * 1114 * @deprecated use {@link #setAccumulatedDeltaRangeMeters(double)} 1115 * and {@link #setAccumulatedDeltaRangeState(int)} instead. 1116 * @hide 1117 */ 1118 @TestApi 1119 @Deprecated resetCarrierCycles()1120 public void resetCarrierCycles() { 1121 resetFlag(HAS_CARRIER_CYCLES); 1122 mCarrierCycles = Long.MIN_VALUE; 1123 } 1124 1125 /** 1126 * Returns {@code true} if {@link #getCarrierPhase()} is available, {@code false} otherwise. 1127 * 1128 * @deprecated use {@link #getAccumulatedDeltaRangeState()} instead. 1129 */ 1130 @Deprecated hasCarrierPhase()1131 public boolean hasCarrierPhase() { 1132 return isFlagSet(HAS_CARRIER_PHASE); 1133 } 1134 1135 /** 1136 * Gets the RF phase detected by the receiver. 1137 * 1138 * <p>Range: [0.0, 1.0]. 1139 * 1140 * <p>This is the fractional part of the complete carrier phase measurement. 1141 * 1142 * <p>The reference frequency is given by the value of {@link #getCarrierFrequencyHz()}. 1143 * 1144 * <p>The error estimate for this value is {@link #getCarrierPhaseUncertainty()}. 1145 * 1146 * <p>The value is only available if {@link #hasCarrierPhase()} is {@code true}. 1147 * 1148 * @deprecated use {@link #getAccumulatedDeltaRangeMeters()} instead. 1149 */ 1150 @Deprecated getCarrierPhase()1151 public double getCarrierPhase() { 1152 return mCarrierPhase; 1153 } 1154 1155 /** 1156 * Sets the RF phase detected by the receiver. 1157 * 1158 * @deprecated use {@link #setAccumulatedDeltaRangeMeters(double)} 1159 * and {@link #setAccumulatedDeltaRangeState(int)} instead. 1160 * 1161 * @hide 1162 */ 1163 @TestApi 1164 @Deprecated setCarrierPhase(double value)1165 public void setCarrierPhase(double value) { 1166 setFlag(HAS_CARRIER_PHASE); 1167 mCarrierPhase = value; 1168 } 1169 1170 /** 1171 * Resets the RF phase detected by the receiver. 1172 * 1173 * @deprecated use {@link #setAccumulatedDeltaRangeMeters(double)} 1174 * and {@link #setAccumulatedDeltaRangeState(int)} instead. 1175 * 1176 * @hide 1177 */ 1178 @TestApi 1179 @Deprecated resetCarrierPhase()1180 public void resetCarrierPhase() { 1181 resetFlag(HAS_CARRIER_PHASE); 1182 } 1183 1184 /** 1185 * Returns {@code true} if {@link #getCarrierPhaseUncertainty()} is available, {@code false} 1186 * otherwise. 1187 * 1188 * @deprecated use {@link #getAccumulatedDeltaRangeState()} instead. 1189 */ 1190 @Deprecated hasCarrierPhaseUncertainty()1191 public boolean hasCarrierPhaseUncertainty() { 1192 return isFlagSet(HAS_CARRIER_PHASE_UNCERTAINTY); 1193 } 1194 1195 /** 1196 * Gets the carrier-phase's uncertainty (1-Sigma). 1197 * 1198 * <p>The uncertainty is represented as an absolute (single sided) value. 1199 * 1200 * <p>The value is only available if {@link #hasCarrierPhaseUncertainty()} is {@code true}. 1201 * 1202 * @deprecated use {@link #getAccumulatedDeltaRangeUncertaintyMeters()} instead. 1203 */ 1204 @Deprecated getCarrierPhaseUncertainty()1205 public double getCarrierPhaseUncertainty() { 1206 return mCarrierPhaseUncertainty; 1207 } 1208 1209 /** 1210 * Sets the Carrier-phase's uncertainty (1-Sigma) in cycles. 1211 * 1212 * @deprecated use {@link #setAccumulatedDeltaRangeUncertaintyMeters(double)} 1213 * and {@link #setAccumulatedDeltaRangeState(int)} instead. 1214 * 1215 * @hide 1216 */ 1217 @TestApi 1218 @Deprecated setCarrierPhaseUncertainty(double value)1219 public void setCarrierPhaseUncertainty(double value) { 1220 setFlag(HAS_CARRIER_PHASE_UNCERTAINTY); 1221 mCarrierPhaseUncertainty = value; 1222 } 1223 1224 /** 1225 * Resets the Carrier-phase's uncertainty (1-Sigma) in cycles. 1226 * 1227 * @deprecated use {@link #setAccumulatedDeltaRangeUncertaintyMeters(double)} 1228 * and {@link #setAccumulatedDeltaRangeState(int)} instead. 1229 * 1230 * @hide 1231 */ 1232 @TestApi 1233 @Deprecated resetCarrierPhaseUncertainty()1234 public void resetCarrierPhaseUncertainty() { 1235 resetFlag(HAS_CARRIER_PHASE_UNCERTAINTY); 1236 } 1237 1238 /** 1239 * Gets a value indicating the 'multipath' state of the event. 1240 */ 1241 @MultipathIndicator getMultipathIndicator()1242 public int getMultipathIndicator() { 1243 return mMultipathIndicator; 1244 } 1245 1246 /** 1247 * Sets the 'multi-path' indicator. 1248 * @hide 1249 */ 1250 @TestApi setMultipathIndicator(@ultipathIndicator int value)1251 public void setMultipathIndicator(@MultipathIndicator int value) { 1252 mMultipathIndicator = value; 1253 } 1254 1255 /** 1256 * Gets a string representation of the 'multi-path indicator'. 1257 * 1258 * <p>For internal and logging use only. 1259 */ getMultipathIndicatorString()1260 private String getMultipathIndicatorString() { 1261 switch (mMultipathIndicator) { 1262 case MULTIPATH_INDICATOR_UNKNOWN: 1263 return "Unknown"; 1264 case MULTIPATH_INDICATOR_DETECTED: 1265 return "Detected"; 1266 case MULTIPATH_INDICATOR_NOT_DETECTED: 1267 return "NotDetected"; 1268 default: 1269 return "<Invalid: " + mMultipathIndicator + ">"; 1270 } 1271 } 1272 1273 /** 1274 * Returns {@code true} if {@link #getSnrInDb()} is available, {@code false} otherwise. 1275 */ hasSnrInDb()1276 public boolean hasSnrInDb() { 1277 return isFlagSet(HAS_SNR); 1278 } 1279 1280 /** 1281 * Gets the (post-correlation & integration) Signal-to-Noise ratio (SNR) in dB. 1282 * 1283 * <p>The value is only available if {@link #hasSnrInDb()} is {@code true}. 1284 */ getSnrInDb()1285 public double getSnrInDb() { 1286 return mSnrInDb; 1287 } 1288 1289 /** 1290 * Sets the Signal-to-noise ratio (SNR) in dB. 1291 * @hide 1292 */ 1293 @TestApi setSnrInDb(double snrInDb)1294 public void setSnrInDb(double snrInDb) { 1295 setFlag(HAS_SNR); 1296 mSnrInDb = snrInDb; 1297 } 1298 1299 /** 1300 * Resets the Signal-to-noise ratio (SNR) in dB. 1301 * @hide 1302 */ 1303 @TestApi resetSnrInDb()1304 public void resetSnrInDb() { 1305 resetFlag(HAS_SNR); 1306 } 1307 1308 /** 1309 * Returns {@code true} if {@link #getAutomaticGainControlLevelDb()} is available, 1310 * {@code false} otherwise. 1311 */ hasAutomaticGainControlLevelDb()1312 public boolean hasAutomaticGainControlLevelDb() { 1313 return isFlagSet(HAS_AUTOMATIC_GAIN_CONTROL); 1314 } 1315 1316 /** 1317 * Gets the Automatic Gain Control level in dB. 1318 * 1319 * <p> AGC acts as a variable gain amplifier adjusting the power of the incoming signal. The AGC 1320 * level may be used to indicate potential interference. When AGC is at a nominal level, this 1321 * value must be set as 0. Higher gain (and/or lower input power) shall be output as a positive 1322 * number. Hence in cases of strong jamming, in the band of this signal, this value will go more 1323 * negative. 1324 * 1325 * <p> Note: Different hardware designs (e.g. antenna, pre-amplification, or other RF HW 1326 * components) may also affect the typical output of of this value on any given hardware design 1327 * in an open sky test - the important aspect of this output is that changes in this value are 1328 * indicative of changes on input signal power in the frequency band for this measurement. 1329 * 1330 * <p> The value is only available if {@link #hasAutomaticGainControlLevelDb()} is {@code true} 1331 */ getAutomaticGainControlLevelDb()1332 public double getAutomaticGainControlLevelDb() { 1333 return mAutomaticGainControlLevelInDb; 1334 } 1335 1336 /** 1337 * Sets the Automatic Gain Control level in dB. 1338 * @hide 1339 */ 1340 @TestApi setAutomaticGainControlLevelInDb(double agcLevelDb)1341 public void setAutomaticGainControlLevelInDb(double agcLevelDb) { 1342 setFlag(HAS_AUTOMATIC_GAIN_CONTROL); 1343 mAutomaticGainControlLevelInDb = agcLevelDb; 1344 } 1345 1346 /** 1347 * Resets the Automatic Gain Control level. 1348 * @hide 1349 */ 1350 @TestApi resetAutomaticGainControlLevel()1351 public void resetAutomaticGainControlLevel() { 1352 resetFlag(HAS_AUTOMATIC_GAIN_CONTROL); 1353 } 1354 1355 /** 1356 * Returns {@code true} if {@link #getCodeType()} is available, 1357 * {@code false} otherwise. 1358 */ hasCodeType()1359 public boolean hasCodeType() { 1360 return isFlagSet(HAS_CODE_TYPE); 1361 } 1362 1363 /** 1364 * Gets the GNSS measurement's code type. 1365 * 1366 * <p>Similar to the Attribute field described in RINEX 3.03, e.g., in Tables 4-10, and Table 1367 * A2 at the RINEX 3.03 Update 1 Document. 1368 * 1369 * <p>Returns "A" for GALILEO E1A, GALILEO E6A, IRNSS L5A, IRNSS SA. 1370 * 1371 * <p>Returns "B" for GALILEO E1B, GALILEO E6B, IRNSS L5B, IRNSS SB. 1372 * 1373 * <p>Returns "C" for GPS L1 C/A, GPS L2 C/A, GLONASS G1 C/A, GLONASS G2 C/A, GALILEO E1C, 1374 * GALILEO E6C, SBAS L1 C/A, QZSS L1 C/A, IRNSS L5C. 1375 * 1376 * <p>Returns "D" for BDS B1C D. 1377 * 1378 * <p>Returns "I" for GPS L5 I, GLONASS G3 I, GALILEO E5a I, GALILEO E5b I, GALILEO E5a+b I, 1379 * SBAS L5 I, QZSS L5 I, BDS B1 I, BDS B2 I, BDS B3 I. 1380 * 1381 * <p>Returns "L" for GPS L1C (P), GPS L2C (L), QZSS L1C (P), QZSS L2C (L), LEX(6) L. 1382 * 1383 * <p>Returns "M" for GPS L1M, GPS L2M. 1384 * 1385 * <p>Returns "N" for GPS L1 codeless, GPS L2 codeless. 1386 * 1387 * <p>Returns "P" for GPS L1P, GPS L2P, GLONASS G1P, GLONASS G2P, BDS B1C P. 1388 * 1389 * <p>Returns "Q" for GPS L5 Q, GLONASS G3 Q, GALILEO E5a Q, GALILEO E5b Q, GALILEO E5a+b Q, 1390 * SBAS L5 Q, QZSS L5 Q, BDS B1 Q, BDS B2 Q, BDS B3 Q. 1391 * 1392 * <p>Returns "S" for GPS L1C (D), GPS L2C (M), QZSS L1C (D), QZSS L2C (M), LEX(6) S. 1393 * 1394 * <p>Returns "W" for GPS L1 Z-tracking, GPS L2 Z-tracking. 1395 * 1396 * <p>Returns "X" for GPS L1C (D+P), GPS L2C (M+L), GPS L5 (I+Q), GLONASS G3 (I+Q), GALILEO 1397 * E1 (B+C), GALILEO E5a (I+Q), GALILEO E5b (I+Q), GALILEO E5a+b(I+Q), GALILEO E6 (B+C), SBAS 1398 * L5 (I+Q), QZSS L1C (D+P), QZSS L2C (M+L), QZSS L5 (I+Q), LEX(6) (S+L), BDS B1 (I+Q), BDS 1399 * B1C (D+P), BDS B2 (I+Q), BDS B3 (I+Q), IRNSS L5 (B+C). 1400 * 1401 * <p>Returns "Y" for GPS L1Y, GPS L2Y. 1402 * 1403 * <p>Returns "Z" for GALILEO E1 (A+B+C), GALILEO E6 (A+B+C), QZSS L1-SAIF. 1404 * 1405 * <p>Returns "UNKNOWN" if the GNSS Measurement's code type is unknown. 1406 * 1407 * <p>This is used to specify the observation descriptor defined in GNSS Observation Data File 1408 * Header Section Description in the RINEX standard (Version 3.XX), in cases where the code type 1409 * does not align with the above listed values. For example, if a code type "G" is added, this 1410 * string shall be set to "G". 1411 */ 1412 @NonNull getCodeType()1413 public String getCodeType() { 1414 return mCodeType; 1415 } 1416 1417 /** 1418 * Sets the GNSS measurement's code type. 1419 * 1420 * @hide 1421 */ 1422 @TestApi setCodeType(@onNull String codeType)1423 public void setCodeType(@NonNull String codeType) { 1424 setFlag(HAS_CODE_TYPE); 1425 mCodeType = codeType; 1426 } 1427 1428 /** 1429 * Resets the GNSS measurement's code type. 1430 * 1431 * @hide 1432 */ 1433 @TestApi resetCodeType()1434 public void resetCodeType() { 1435 resetFlag(HAS_CODE_TYPE); 1436 mCodeType = "UNKNOWN"; 1437 } 1438 1439 /** 1440 * Returns {@code true} if {@link #getFullInterSignalBiasNanos()} is available, 1441 * {@code false} otherwise. 1442 */ hasFullInterSignalBiasNanos()1443 public boolean hasFullInterSignalBiasNanos() { 1444 return isFlagSet(HAS_FULL_ISB); 1445 } 1446 1447 /** 1448 * Gets the GNSS measurement's inter-signal bias in nanoseconds with sub-nanosecond accuracy. 1449 * 1450 * <p>This value is the sum of the estimated receiver-side and the space-segment-side 1451 * inter-system bias, inter-frequency bias and inter-code bias, including: 1452 * 1453 * <ul> 1454 * <li>Receiver inter-constellation bias (with respect to the constellation in 1455 * {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1456 * <li>Receiver inter-frequency bias (with respect to the carrier frequency in 1457 * {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1458 * <li>Receiver inter-code bias (with respect to the code type in 1459 * {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1460 * <li>Master clock bias (e.g., GPS-GAL Time Offset (GGTO), GPS-UTC Time Offset (TauGps), 1461 * BDS-GLO Time Offset (BGTO))(with respect to the constellation in 1462 * {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1463 * <li>Group delay (e.g., Total Group Delay (TGD))</li> 1464 * <li>Satellite inter-frequency bias (GLO only) (with respect to the carrier frequency in 1465 * {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1466 * <li>Satellite inter-code bias (e.g., Differential Code Bias (DCB)) (with respect to the code 1467 * type in {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1468 * </ul> 1469 * 1470 * <p>If a component of the above is already compensated in the provided 1471 * {@link GnssMeasurement#getReceivedSvTimeNanos()}, then it must not be included in the 1472 * reported full ISB. 1473 * 1474 * <p>The value does not include the inter-frequency Ionospheric bias. 1475 * 1476 * <p>The value is only available if {@link #hasFullInterSignalBiasNanos()} is {@code true}. 1477 */ getFullInterSignalBiasNanos()1478 public double getFullInterSignalBiasNanos() { 1479 return mFullInterSignalBiasNanos; 1480 } 1481 1482 /** 1483 * Sets the GNSS measurement's inter-signal bias in nanoseconds. 1484 * 1485 * @hide 1486 */ 1487 @TestApi setFullInterSignalBiasNanos(double fullInterSignalBiasNanos)1488 public void setFullInterSignalBiasNanos(double fullInterSignalBiasNanos) { 1489 setFlag(HAS_FULL_ISB); 1490 mFullInterSignalBiasNanos = fullInterSignalBiasNanos; 1491 } 1492 1493 /** 1494 * Resets the GNSS measurement's inter-signal bias in nanoseconds. 1495 * 1496 * @hide 1497 */ 1498 @TestApi resetFullInterSignalBiasNanos()1499 public void resetFullInterSignalBiasNanos() { 1500 resetFlag(HAS_FULL_ISB); 1501 } 1502 1503 /** 1504 * Returns {@code true} if {@link #getFullInterSignalBiasUncertaintyNanos()} is available, 1505 * {@code false} otherwise. 1506 */ hasFullInterSignalBiasUncertaintyNanos()1507 public boolean hasFullInterSignalBiasUncertaintyNanos() { 1508 return isFlagSet(HAS_FULL_ISB_UNCERTAINTY); 1509 } 1510 1511 /** 1512 * Gets the GNSS measurement's inter-signal bias uncertainty (1 sigma) in 1513 * nanoseconds with sub-nanosecond accuracy. 1514 * 1515 * <p>The value is only available if {@link #hasFullInterSignalBiasUncertaintyNanos()} is 1516 * {@code true}. 1517 */ 1518 @FloatRange(from = 0.0) getFullInterSignalBiasUncertaintyNanos()1519 public double getFullInterSignalBiasUncertaintyNanos() { 1520 return mFullInterSignalBiasUncertaintyNanos; 1521 } 1522 1523 /** 1524 * Sets the GNSS measurement's inter-signal bias uncertainty (1 sigma) in nanoseconds. 1525 * 1526 * @hide 1527 */ 1528 @TestApi setFullInterSignalBiasUncertaintyNanos(@loatRangefrom = 0.0) double fullInterSignalBiasUncertaintyNanos)1529 public void setFullInterSignalBiasUncertaintyNanos(@FloatRange(from = 0.0) 1530 double fullInterSignalBiasUncertaintyNanos) { 1531 setFlag(HAS_FULL_ISB_UNCERTAINTY); 1532 mFullInterSignalBiasUncertaintyNanos = fullInterSignalBiasUncertaintyNanos; 1533 } 1534 1535 /** 1536 * Resets the GNSS measurement's inter-signal bias uncertainty (1 sigma) in 1537 * nanoseconds. 1538 * 1539 * @hide 1540 */ 1541 @TestApi resetFullInterSignalBiasUncertaintyNanos()1542 public void resetFullInterSignalBiasUncertaintyNanos() { 1543 resetFlag(HAS_FULL_ISB_UNCERTAINTY); 1544 } 1545 1546 /** 1547 * Returns {@code true} if {@link #getSatelliteInterSignalBiasNanos()} is available, 1548 * {@code false} otherwise. 1549 */ hasSatelliteInterSignalBiasNanos()1550 public boolean hasSatelliteInterSignalBiasNanos() { 1551 return isFlagSet(HAS_SATELLITE_ISB); 1552 } 1553 1554 /** 1555 * Gets the GNSS measurement's satellite inter-signal bias in nanoseconds with sub-nanosecond 1556 * accuracy. 1557 * 1558 * <p>This value is the space-segment-side inter-system bias, inter-frequency bias and 1559 * inter-code bias, including: 1560 * 1561 * <ul> 1562 * <li>Master clock bias (e.g., GPS-GAL Time Offset (GGTO), GPS-UTC Time Offset (TauGps), 1563 * BDS-GLO Time Offset (BGTO))(with respect to the constellation in 1564 * {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1565 * <li>Group delay (e.g., Total Group Delay (TGD))</li> 1566 * <li>Satellite inter-frequency bias (GLO only) (with respect to the carrier frequency in 1567 * {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1568 * <li>Satellite inter-code bias (e.g., Differential Code Bias (DCB)) (with respect to the code 1569 * type in {@link GnssClock#getReferenceConstellationTypeForIsb())</li> 1570 * </ul> 1571 * 1572 * <p>The value is only available if {@link #hasSatelliteInterSignalBiasNanos()} is {@code 1573 * true}. 1574 */ getSatelliteInterSignalBiasNanos()1575 public double getSatelliteInterSignalBiasNanos() { 1576 return mSatelliteInterSignalBiasNanos; 1577 } 1578 1579 /** 1580 * Sets the GNSS measurement's satellite inter-signal bias in nanoseconds. 1581 * 1582 * @hide 1583 */ 1584 @TestApi setSatelliteInterSignalBiasNanos(double satelliteInterSignalBiasNanos)1585 public void setSatelliteInterSignalBiasNanos(double satelliteInterSignalBiasNanos) { 1586 setFlag(HAS_SATELLITE_ISB); 1587 mSatelliteInterSignalBiasNanos = satelliteInterSignalBiasNanos; 1588 } 1589 1590 /** 1591 * Resets the GNSS measurement's satellite inter-signal bias in nanoseconds. 1592 * 1593 * @hide 1594 */ 1595 @TestApi resetSatelliteInterSignalBiasNanos()1596 public void resetSatelliteInterSignalBiasNanos() { 1597 resetFlag(HAS_SATELLITE_ISB); 1598 } 1599 1600 /** 1601 * Returns {@code true} if {@link #getSatelliteInterSignalBiasUncertaintyNanos()} is available, 1602 * {@code false} otherwise. 1603 */ hasSatelliteInterSignalBiasUncertaintyNanos()1604 public boolean hasSatelliteInterSignalBiasUncertaintyNanos() { 1605 return isFlagSet(HAS_SATELLITE_ISB_UNCERTAINTY); 1606 } 1607 1608 /** 1609 * Gets the GNSS measurement's satellite inter-signal bias uncertainty (1 sigma) in 1610 * nanoseconds with sub-nanosecond accuracy. 1611 * 1612 * <p>The value is only available if {@link #hasSatelliteInterSignalBiasUncertaintyNanos()} is 1613 * {@code true}. 1614 */ 1615 @FloatRange(from = 0.0) getSatelliteInterSignalBiasUncertaintyNanos()1616 public double getSatelliteInterSignalBiasUncertaintyNanos() { 1617 return mSatelliteInterSignalBiasUncertaintyNanos; 1618 } 1619 1620 /** 1621 * Sets the GNSS measurement's satellite inter-signal bias uncertainty (1 sigma) in nanoseconds. 1622 * 1623 * @hide 1624 */ 1625 @TestApi setSatelliteInterSignalBiasUncertaintyNanos(@loatRangefrom = 0.0) double satelliteInterSignalBiasUncertaintyNanos)1626 public void setSatelliteInterSignalBiasUncertaintyNanos(@FloatRange(from = 0.0) 1627 double satelliteInterSignalBiasUncertaintyNanos) { 1628 setFlag(HAS_SATELLITE_ISB_UNCERTAINTY); 1629 mSatelliteInterSignalBiasUncertaintyNanos = satelliteInterSignalBiasUncertaintyNanos; 1630 } 1631 1632 /** 1633 * Resets the GNSS measurement's satellite inter-signal bias uncertainty (1 sigma) in 1634 * nanoseconds. 1635 * 1636 * @hide 1637 */ 1638 @TestApi resetSatelliteInterSignalBiasUncertaintyNanos()1639 public void resetSatelliteInterSignalBiasUncertaintyNanos() { 1640 resetFlag(HAS_SATELLITE_ISB_UNCERTAINTY); 1641 } 1642 1643 1644 public static final @NonNull Creator<GnssMeasurement> CREATOR = new Creator<GnssMeasurement>() { 1645 @Override 1646 public GnssMeasurement createFromParcel(Parcel parcel) { 1647 GnssMeasurement gnssMeasurement = new GnssMeasurement(); 1648 1649 gnssMeasurement.mFlags = parcel.readInt(); 1650 gnssMeasurement.mSvid = parcel.readInt(); 1651 gnssMeasurement.mConstellationType = parcel.readInt(); 1652 gnssMeasurement.mTimeOffsetNanos = parcel.readDouble(); 1653 gnssMeasurement.mState = parcel.readInt(); 1654 gnssMeasurement.mReceivedSvTimeNanos = parcel.readLong(); 1655 gnssMeasurement.mReceivedSvTimeUncertaintyNanos = parcel.readLong(); 1656 gnssMeasurement.mCn0DbHz = parcel.readDouble(); 1657 gnssMeasurement.mPseudorangeRateMetersPerSecond = parcel.readDouble(); 1658 gnssMeasurement.mPseudorangeRateUncertaintyMetersPerSecond = parcel.readDouble(); 1659 gnssMeasurement.mAccumulatedDeltaRangeState = parcel.readInt(); 1660 gnssMeasurement.mAccumulatedDeltaRangeMeters = parcel.readDouble(); 1661 gnssMeasurement.mAccumulatedDeltaRangeUncertaintyMeters = parcel.readDouble(); 1662 gnssMeasurement.mCarrierFrequencyHz = parcel.readFloat(); 1663 gnssMeasurement.mCarrierCycles = parcel.readLong(); 1664 gnssMeasurement.mCarrierPhase = parcel.readDouble(); 1665 gnssMeasurement.mCarrierPhaseUncertainty = parcel.readDouble(); 1666 gnssMeasurement.mMultipathIndicator = parcel.readInt(); 1667 gnssMeasurement.mSnrInDb = parcel.readDouble(); 1668 gnssMeasurement.mAutomaticGainControlLevelInDb = parcel.readDouble(); 1669 gnssMeasurement.mCodeType = parcel.readString(); 1670 gnssMeasurement.mBasebandCn0DbHz = parcel.readDouble(); 1671 gnssMeasurement.mFullInterSignalBiasNanos = parcel.readDouble(); 1672 gnssMeasurement.mFullInterSignalBiasUncertaintyNanos = parcel.readDouble(); 1673 gnssMeasurement.mSatelliteInterSignalBiasNanos = parcel.readDouble(); 1674 gnssMeasurement.mSatelliteInterSignalBiasUncertaintyNanos = parcel.readDouble(); 1675 1676 return gnssMeasurement; 1677 } 1678 1679 @Override 1680 public GnssMeasurement[] newArray(int i) { 1681 return new GnssMeasurement[i]; 1682 } 1683 }; 1684 1685 @Override writeToParcel(Parcel parcel, int flags)1686 public void writeToParcel(Parcel parcel, int flags) { 1687 parcel.writeInt(mFlags); 1688 parcel.writeInt(mSvid); 1689 parcel.writeInt(mConstellationType); 1690 parcel.writeDouble(mTimeOffsetNanos); 1691 parcel.writeInt(mState); 1692 parcel.writeLong(mReceivedSvTimeNanos); 1693 parcel.writeLong(mReceivedSvTimeUncertaintyNanos); 1694 parcel.writeDouble(mCn0DbHz); 1695 parcel.writeDouble(mPseudorangeRateMetersPerSecond); 1696 parcel.writeDouble(mPseudorangeRateUncertaintyMetersPerSecond); 1697 parcel.writeInt(mAccumulatedDeltaRangeState); 1698 parcel.writeDouble(mAccumulatedDeltaRangeMeters); 1699 parcel.writeDouble(mAccumulatedDeltaRangeUncertaintyMeters); 1700 parcel.writeFloat(mCarrierFrequencyHz); 1701 parcel.writeLong(mCarrierCycles); 1702 parcel.writeDouble(mCarrierPhase); 1703 parcel.writeDouble(mCarrierPhaseUncertainty); 1704 parcel.writeInt(mMultipathIndicator); 1705 parcel.writeDouble(mSnrInDb); 1706 parcel.writeDouble(mAutomaticGainControlLevelInDb); 1707 parcel.writeString(mCodeType); 1708 parcel.writeDouble(mBasebandCn0DbHz); 1709 parcel.writeDouble(mFullInterSignalBiasNanos); 1710 parcel.writeDouble(mFullInterSignalBiasUncertaintyNanos); 1711 parcel.writeDouble(mSatelliteInterSignalBiasNanos); 1712 parcel.writeDouble(mSatelliteInterSignalBiasUncertaintyNanos); 1713 } 1714 1715 @Override describeContents()1716 public int describeContents() { 1717 return 0; 1718 } 1719 1720 @Override toString()1721 public String toString() { 1722 final String format = " %-29s = %s\n"; 1723 final String formatWithUncertainty = " %-29s = %-25s %-40s = %s\n"; 1724 StringBuilder builder = new StringBuilder("GnssMeasurement:\n"); 1725 1726 builder.append(String.format(format, "Svid", mSvid)); 1727 builder.append(String.format(format, "ConstellationType", mConstellationType)); 1728 builder.append(String.format(format, "TimeOffsetNanos", mTimeOffsetNanos)); 1729 1730 builder.append(String.format(format, "State", getStateString())); 1731 1732 builder.append(String.format( 1733 formatWithUncertainty, 1734 "ReceivedSvTimeNanos", 1735 mReceivedSvTimeNanos, 1736 "ReceivedSvTimeUncertaintyNanos", 1737 mReceivedSvTimeUncertaintyNanos)); 1738 1739 builder.append(String.format(format, "Cn0DbHz", mCn0DbHz)); 1740 1741 if (hasBasebandCn0DbHz()) { 1742 builder.append(String.format(format, "BasebandCn0DbHz", mBasebandCn0DbHz)); 1743 } 1744 1745 builder.append(String.format( 1746 formatWithUncertainty, 1747 "PseudorangeRateMetersPerSecond", 1748 mPseudorangeRateMetersPerSecond, 1749 "PseudorangeRateUncertaintyMetersPerSecond", 1750 mPseudorangeRateUncertaintyMetersPerSecond)); 1751 1752 builder.append(String.format( 1753 format, 1754 "AccumulatedDeltaRangeState", 1755 getAccumulatedDeltaRangeStateString())); 1756 1757 builder.append(String.format( 1758 formatWithUncertainty, 1759 "AccumulatedDeltaRangeMeters", 1760 mAccumulatedDeltaRangeMeters, 1761 "AccumulatedDeltaRangeUncertaintyMeters", 1762 mAccumulatedDeltaRangeUncertaintyMeters)); 1763 1764 if (hasCarrierFrequencyHz()) { 1765 builder.append(String.format(format, "CarrierFrequencyHz", mCarrierFrequencyHz)); 1766 } 1767 1768 if (hasCarrierCycles()) { 1769 builder.append(String.format(format, "CarrierCycles", mCarrierCycles)); 1770 } 1771 1772 if (hasCarrierPhase() || hasCarrierPhaseUncertainty()) { 1773 builder.append(String.format( 1774 formatWithUncertainty, 1775 "CarrierPhase", 1776 hasCarrierPhase() ? mCarrierPhase : null, 1777 "CarrierPhaseUncertainty", 1778 hasCarrierPhaseUncertainty() ? mCarrierPhaseUncertainty : null)); 1779 } 1780 1781 builder.append(String.format(format, "MultipathIndicator", getMultipathIndicatorString())); 1782 1783 if (hasSnrInDb()) { 1784 builder.append(String.format(format, "SnrInDb", mSnrInDb)); 1785 } 1786 1787 if (hasAutomaticGainControlLevelDb()) { 1788 builder.append(String.format(format, "AgcLevelDb", mAutomaticGainControlLevelInDb)); 1789 } 1790 1791 if (hasCodeType()) { 1792 builder.append(String.format(format, "CodeType", mCodeType)); 1793 } 1794 1795 if (hasFullInterSignalBiasNanos() || hasFullInterSignalBiasUncertaintyNanos()) { 1796 builder.append(String.format( 1797 formatWithUncertainty, 1798 "InterSignalBiasNs", 1799 hasFullInterSignalBiasNanos() ? mFullInterSignalBiasNanos : null, 1800 "InterSignalBiasUncertaintyNs", 1801 hasFullInterSignalBiasUncertaintyNanos() 1802 ? mFullInterSignalBiasUncertaintyNanos : null)); 1803 } 1804 1805 if (hasSatelliteInterSignalBiasNanos() || hasSatelliteInterSignalBiasUncertaintyNanos()) { 1806 builder.append(String.format( 1807 formatWithUncertainty, 1808 "SatelliteInterSignalBiasNs", 1809 hasSatelliteInterSignalBiasNanos() ? mSatelliteInterSignalBiasNanos : null, 1810 "SatelliteInterSignalBiasUncertaintyNs", 1811 hasSatelliteInterSignalBiasUncertaintyNanos() 1812 ? mSatelliteInterSignalBiasUncertaintyNanos 1813 : null)); 1814 } 1815 1816 return builder.toString(); 1817 } 1818 initialize()1819 private void initialize() { 1820 mFlags = HAS_NO_FLAGS; 1821 setSvid(0); 1822 setTimeOffsetNanos(Long.MIN_VALUE); 1823 setState(STATE_UNKNOWN); 1824 setReceivedSvTimeNanos(Long.MIN_VALUE); 1825 setReceivedSvTimeUncertaintyNanos(Long.MAX_VALUE); 1826 setCn0DbHz(Double.MIN_VALUE); 1827 setPseudorangeRateMetersPerSecond(Double.MIN_VALUE); 1828 setPseudorangeRateUncertaintyMetersPerSecond(Double.MIN_VALUE); 1829 setAccumulatedDeltaRangeState(ADR_STATE_UNKNOWN); 1830 setAccumulatedDeltaRangeMeters(Double.MIN_VALUE); 1831 setAccumulatedDeltaRangeUncertaintyMeters(Double.MIN_VALUE); 1832 resetCarrierFrequencyHz(); 1833 resetCarrierCycles(); 1834 resetCarrierPhase(); 1835 resetCarrierPhaseUncertainty(); 1836 setMultipathIndicator(MULTIPATH_INDICATOR_UNKNOWN); 1837 resetSnrInDb(); 1838 resetAutomaticGainControlLevel(); 1839 resetCodeType(); 1840 resetBasebandCn0DbHz(); 1841 resetFullInterSignalBiasNanos(); 1842 resetFullInterSignalBiasUncertaintyNanos(); 1843 resetSatelliteInterSignalBiasNanos(); 1844 resetSatelliteInterSignalBiasUncertaintyNanos(); 1845 } 1846 setFlag(int flag)1847 private void setFlag(int flag) { 1848 mFlags |= flag; 1849 } 1850 resetFlag(int flag)1851 private void resetFlag(int flag) { 1852 mFlags &= ~flag; 1853 } 1854 isFlagSet(int flag)1855 private boolean isFlagSet(int flag) { 1856 return (mFlags & flag) == flag; 1857 } 1858 } 1859