• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.telephony.satellite.wrapper;
18 
19 import android.annotation.FlaggedApi;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import androidx.annotation.NonNull;
24 
25 import com.android.internal.telephony.flags.Flags;
26 
27 import java.util.Objects;
28 
29 /**
30  * The position of a satellite in Earth orbit.
31  *
32  * Longitude is the angular distance, measured in degrees, east or west of the prime longitude line
33  * ranging from -180 to 180 degrees
34  * Altitude is the distance from the center of the Earth to the satellite, measured in kilometers
35  *
36  * @hide
37  */
38 public class SatellitePositionWrapper implements Parcelable {
39 
40     /**
41      * The longitude of the satellite in degrees, ranging from -180 to 180 degrees
42      */
43     private double mLongitudeDegree;
44 
45     /**
46      * The distance from the center of the earth to the satellite, measured in kilometers
47      */
48     private double mAltitudeKm;
49 
50     /**
51      * Constructor for {@link SatellitePositionWrapper} used to create an instance from a
52      * {@link Parcel}.
53      *
54      * @param in The {@link Parcel} to read the satellite position data from.
55      */
SatellitePositionWrapper(Parcel in)56     public SatellitePositionWrapper(Parcel in) {
57         mLongitudeDegree = in.readDouble();
58         mAltitudeKm = in.readDouble();
59     }
60 
61     /**
62      * Constructor for {@link SatellitePositionWrapper}.
63      *
64      * @param longitudeDegree The longitude of the satellite in degrees.
65      * @param altitudeKm      The altitude of the satellite in kilometers.
66      */
SatellitePositionWrapper(double longitudeDegree, double altitudeKm)67     public SatellitePositionWrapper(double longitudeDegree, double altitudeKm) {
68         mLongitudeDegree = longitudeDegree;
69         mAltitudeKm = altitudeKm;
70     }
71 
72     public static final Creator<SatellitePositionWrapper> CREATOR =
73             new Creator<SatellitePositionWrapper>() {
74                 @Override
75                 public SatellitePositionWrapper createFromParcel(Parcel in) {
76                     return new SatellitePositionWrapper(in);
77                 }
78 
79                 @Override
80                 public SatellitePositionWrapper[] newArray(int size) {
81                     return new SatellitePositionWrapper[size];
82                 }
83             };
84 
85     @Override
describeContents()86     public int describeContents() {
87         return 0;
88     }
89 
90     /**
91      * @param dest  The Parcel in which the object should be written.
92      * @param flags Additional flags about how the object should be written.
93      *              May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
94      */
95     @Override
writeToParcel(@onNull Parcel dest, int flags)96     public void writeToParcel(@NonNull Parcel dest, int flags) {
97         dest.writeDouble(mLongitudeDegree);
98         dest.writeDouble(mAltitudeKm);
99     }
100 
101     /**
102      * Returns the longitude of the satellite in degrees, ranging from -180 to 180 degrees.
103      *
104      * @return The longitude of the satellite.
105      */
getLongitudeDegrees()106     public double getLongitudeDegrees() {
107         return mLongitudeDegree;
108     }
109 
110     /**
111      * Returns the altitude of the satellite in kilometers
112      *
113      * @return The altitude of the satellite.
114      */
getAltitudeKm()115     public double getAltitudeKm() {
116         return mAltitudeKm;
117     }
118 
119     @Override
equals(Object o)120     public boolean equals(Object o) {
121         if (this == o) return true;
122         if (!(o instanceof SatellitePositionWrapper that)) return false;
123 
124         return Double.compare(that.mLongitudeDegree, mLongitudeDegree) == 0
125                 && Double.compare(that.mAltitudeKm, mAltitudeKm) == 0;
126     }
127 
128     @Override
hashCode()129     public int hashCode() {
130         return Objects.hash(mLongitudeDegree, mAltitudeKm);
131     }
132 
133     @Override
134     @NonNull
toString()135     public String toString() {
136         return "mLongitudeDegree: " + mLongitudeDegree + ", " + "mAltitudeKm: " + mAltitudeKm;
137     }
138 }
139