1 /* 2 * Copyright (C) 2024 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 android.annotation.FlaggedApi; 20 import android.annotation.IntRange; 21 import android.annotation.NonNull; 22 import android.annotation.SystemApi; 23 import android.location.flags.Flags; 24 import android.os.Parcel; 25 import android.os.Parcelable; 26 27 import com.android.internal.util.Preconditions; 28 29 /** 30 * A class contains ionospheric correction. 31 * 32 * @hide 33 */ 34 @FlaggedApi(Flags.FLAG_GNSS_ASSISTANCE_INTERFACE) 35 @SystemApi 36 public final class IonosphericCorrection implements Parcelable { 37 38 /** Carrier frequency in Hz to differentiate signals from the same satellite. e.g. GPS L1/L5 */ 39 private final long mCarrierFrequencyHz; 40 41 /** Ionospheric correction. */ 42 @NonNull private final GnssCorrectionComponent mIonosphericCorrection; 43 44 /** 45 * Creates a new {@link IonosphericCorrection} instance. 46 * 47 * @param carrierFrequencyHz Carrier frequency in Hz to differentiate signals from the 48 * samesatellite. e.g. GPS L1/L5 49 * @param ionosphericCorrection Ionospheric correction. 50 */ IonosphericCorrection( @ntRangefrom = 0) long carrierFrequencyHz, @NonNull GnssCorrectionComponent ionosphericCorrection)51 public IonosphericCorrection( 52 @IntRange(from = 0) long carrierFrequencyHz, 53 @NonNull GnssCorrectionComponent ionosphericCorrection) { 54 Preconditions.checkArgument(carrierFrequencyHz > 0); 55 Preconditions.checkNotNull(ionosphericCorrection, "IonosphericCorrection cannot be null"); 56 mCarrierFrequencyHz = carrierFrequencyHz; 57 mIonosphericCorrection = ionosphericCorrection; 58 } 59 60 /** 61 * Returns the carrier frequency in Hz to differentiate signals from the same satellite. e.g. 62 * GPS L1/L5 63 */ 64 @IntRange(from = 0) getCarrierFrequencyHz()65 public long getCarrierFrequencyHz() { 66 return mCarrierFrequencyHz; 67 } 68 69 /** Returns the Ionospheric correction. */ 70 @NonNull getIonosphericCorrection()71 public GnssCorrectionComponent getIonosphericCorrection() { 72 return mIonosphericCorrection; 73 } 74 75 public static final @NonNull Creator<IonosphericCorrection> CREATOR = 76 new Creator<IonosphericCorrection>() { 77 @Override 78 @NonNull 79 public IonosphericCorrection createFromParcel(Parcel in) { 80 long carrierFrequencyHz = in.readLong(); 81 GnssCorrectionComponent ionosphericCorrection = 82 in.readTypedObject(GnssCorrectionComponent.CREATOR); 83 return new IonosphericCorrection(carrierFrequencyHz, ionosphericCorrection); 84 } 85 86 @Override 87 public IonosphericCorrection[] newArray(int size) { 88 return new IonosphericCorrection[size]; 89 } 90 }; 91 92 @Override describeContents()93 public int describeContents() { 94 return 0; 95 } 96 97 @Override writeToParcel(@onNull Parcel dest, int flags)98 public void writeToParcel(@NonNull Parcel dest, int flags) { 99 dest.writeLong(mCarrierFrequencyHz); 100 dest.writeTypedObject(mIonosphericCorrection, flags); 101 } 102 103 @Override 104 @NonNull toString()105 public String toString() { 106 StringBuilder builder = new StringBuilder("IonosphericCorrection["); 107 builder.append("carrierFrequencyHz = ").append(mCarrierFrequencyHz); 108 builder.append(", ionosphericCorrection = ").append(mIonosphericCorrection); 109 builder.append("]"); 110 return builder.toString(); 111 } 112 } 113