1 /*
2 * Copyright (C) 2019 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 #include <Constants.h>
18 #include <MockLocation.h>
19 #include <Utils.h>
20 #include <aidl/android/hardware/gnss/BnGnss.h>
21 #include <utils/SystemClock.h>
22
23 namespace android {
24 namespace hardware {
25 namespace gnss {
26 namespace common {
27
28 using aidl::android::hardware::gnss::ElapsedRealtime;
29 using aidl::android::hardware::gnss::GnssClock;
30 using aidl::android::hardware::gnss::GnssConstellationType;
31 using aidl::android::hardware::gnss::GnssData;
32 using aidl::android::hardware::gnss::GnssLocation;
33 using aidl::android::hardware::gnss::GnssMeasurement;
34 using aidl::android::hardware::gnss::IGnss;
35 using aidl::android::hardware::gnss::IGnssDebug;
36 using aidl::android::hardware::gnss::IGnssMeasurementCallback;
37 using aidl::android::hardware::gnss::SatellitePvt;
38 using GnssSvInfo = aidl::android::hardware::gnss::IGnssCallback::GnssSvInfo;
39 using GnssSvFlags = aidl::android::hardware::gnss::IGnssCallback::GnssSvFlags;
40
41 using GnssSvFlagsV1_0 = V1_0::IGnssCallback::GnssSvFlags;
42 using GnssAgc = aidl::android::hardware::gnss::GnssData::GnssAgc;
43 using GnssMeasurementFlagsV1_0 = V1_0::IGnssMeasurementCallback::GnssMeasurementFlags;
44 using GnssMeasurementFlagsV2_1 = V2_1::IGnssMeasurementCallback::GnssMeasurementFlags;
45 using GnssMeasurementStateV2_0 = V2_0::IGnssMeasurementCallback::GnssMeasurementState;
46 using ElapsedRealtimeFlags = V2_0::ElapsedRealtimeFlags;
47 using GnssConstellationTypeV2_0 = V2_0::GnssConstellationType;
48 using IGnssMeasurementCallbackV2_0 = V2_0::IGnssMeasurementCallback;
49 using GnssSignalType = V2_1::GnssSignalType;
50
51 using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
52 using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
53 using GnssSvInfoV1_0 = V1_0::IGnssCallback::GnssSvInfo;
54 using GnssSvInfoV2_0 = V2_0::IGnssCallback::GnssSvInfo;
55 using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
56 using GnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo;
57 using Row = V2_1::IGnssAntennaInfoCallback::Row;
58 using Coord = V2_1::IGnssAntennaInfoCallback::Coord;
59
getMockMeasurementV2_1()60 GnssDataV2_1 Utils::getMockMeasurementV2_1() {
61 GnssDataV2_0 gnssDataV2_0 = Utils::getMockMeasurementV2_0();
62 V2_1::IGnssMeasurementCallback::GnssMeasurement gnssMeasurementV2_1 = {
63 .v2_0 = gnssDataV2_0.measurements[0],
64 .flags = (uint32_t)(GnssMeasurementFlagsV2_1::HAS_CARRIER_FREQUENCY |
65 GnssMeasurementFlagsV2_1::HAS_CARRIER_PHASE |
66 GnssMeasurementFlagsV2_1::HAS_FULL_ISB |
67 GnssMeasurementFlagsV2_1::HAS_FULL_ISB_UNCERTAINTY |
68 GnssMeasurementFlagsV2_1::HAS_SATELLITE_ISB |
69 GnssMeasurementFlagsV2_1::HAS_SATELLITE_ISB_UNCERTAINTY),
70 .fullInterSignalBiasNs = 30.0,
71 .fullInterSignalBiasUncertaintyNs = 250.0,
72 .satelliteInterSignalBiasNs = 20.0,
73 .satelliteInterSignalBiasUncertaintyNs = 150.0,
74 .basebandCN0DbHz = 25.0,
75 };
76 GnssSignalType referenceSignalTypeForIsb = {
77 .constellation = GnssConstellationTypeV2_0::GPS,
78 .carrierFrequencyHz = 1.59975e+09,
79 .codeType = "C",
80 };
81 V2_1::IGnssMeasurementCallback::GnssClock gnssClockV2_1 = {
82 .v1_0 = gnssDataV2_0.clock,
83 .referenceSignalTypeForIsb = referenceSignalTypeForIsb,
84 };
85 hidl_vec<V2_1::IGnssMeasurementCallback::GnssMeasurement> measurements(1);
86 measurements[0] = gnssMeasurementV2_1;
87 GnssDataV2_1 gnssDataV2_1 = {
88 .measurements = measurements,
89 .clock = gnssClockV2_1,
90 .elapsedRealtime = gnssDataV2_0.elapsedRealtime,
91 };
92 return gnssDataV2_1;
93 }
94
getMockMeasurementV2_0()95 GnssDataV2_0 Utils::getMockMeasurementV2_0() {
96 V1_0::IGnssMeasurementCallback::GnssMeasurement measurement_1_0 = {
97 .flags = (uint32_t)GnssMeasurementFlagsV1_0::HAS_CARRIER_FREQUENCY,
98 .svid = (int16_t)6,
99 .constellation = V1_0::GnssConstellationType::UNKNOWN,
100 .timeOffsetNs = 0.0,
101 .receivedSvTimeInNs = 8195997131077,
102 .receivedSvTimeUncertaintyInNs = 15,
103 .cN0DbHz = 30.0,
104 .pseudorangeRateMps = -484.13739013671875,
105 .pseudorangeRateUncertaintyMps = 0.1037999987602233,
106 .accumulatedDeltaRangeState = (uint32_t)V1_0::IGnssMeasurementCallback::
107 GnssAccumulatedDeltaRangeState::ADR_STATE_UNKNOWN,
108 .accumulatedDeltaRangeM = 0.0,
109 .accumulatedDeltaRangeUncertaintyM = 0.0,
110 .carrierFrequencyHz = 1.59975e+09,
111 .multipathIndicator =
112 V1_0::IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_UNKNOWN};
113 V1_1::IGnssMeasurementCallback::GnssMeasurement measurement_1_1 = {.v1_0 = measurement_1_0};
114 V2_0::IGnssMeasurementCallback::GnssMeasurement measurement_2_0 = {
115 .v1_1 = measurement_1_1,
116 .codeType = "C",
117 .state = GnssMeasurementStateV2_0::STATE_CODE_LOCK |
118 GnssMeasurementStateV2_0::STATE_BIT_SYNC |
119 GnssMeasurementStateV2_0::STATE_SUBFRAME_SYNC |
120 GnssMeasurementStateV2_0::STATE_TOW_DECODED |
121 GnssMeasurementStateV2_0::STATE_GLO_STRING_SYNC |
122 GnssMeasurementStateV2_0::STATE_GLO_TOD_DECODED,
123 .constellation = GnssConstellationTypeV2_0::GLONASS,
124 };
125
126 hidl_vec<IGnssMeasurementCallbackV2_0::GnssMeasurement> measurements(1);
127 measurements[0] = measurement_2_0;
128 V1_0::IGnssMeasurementCallback::GnssClock clock = {.timeNs = 2713545000000,
129 .fullBiasNs = -1226701900521857520,
130 .biasNs = 0.59689998626708984,
131 .biasUncertaintyNs = 47514.989972114563,
132 .driftNsps = -51.757811607455452,
133 .driftUncertaintyNsps = 310.64968328491528,
134 .hwClockDiscontinuityCount = 1};
135
136 V2_0::ElapsedRealtime timestamp = {
137 .flags = ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |
138 ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS,
139 .timestampNs = static_cast<uint64_t>(::android::elapsedRealtimeNano()),
140 // This is an hardcoded value indicating a 1ms of uncertainty between the two clocks.
141 // In an actual implementation provide an estimate of the synchronization uncertainty
142 // or don't set the field.
143 .timeUncertaintyNs = 1000000};
144
145 GnssDataV2_0 gnssData = {
146 .measurements = measurements, .clock = clock, .elapsedRealtime = timestamp};
147 return gnssData;
148 }
149
getMockMeasurement(const bool enableCorrVecOutputs,const bool enableFullTracking)150 GnssData Utils::getMockMeasurement(const bool enableCorrVecOutputs, const bool enableFullTracking) {
151 aidl::android::hardware::gnss::GnssSignalType signalType = {
152 .constellation = GnssConstellationType::GLONASS,
153 .carrierFrequencyHz = 1.59975e+09,
154 .codeType = aidl::android::hardware::gnss::GnssSignalType::CODE_TYPE_C,
155 };
156 GnssMeasurement measurement = {
157 .flags = GnssMeasurement::HAS_AUTOMATIC_GAIN_CONTROL |
158 GnssMeasurement::HAS_CARRIER_FREQUENCY | GnssMeasurement::HAS_CARRIER_PHASE |
159 GnssMeasurement::HAS_CARRIER_PHASE_UNCERTAINTY |
160 GnssMeasurement::HAS_FULL_ISB | GnssMeasurement::HAS_FULL_ISB_UNCERTAINTY |
161 GnssMeasurement::HAS_SATELLITE_ISB |
162 GnssMeasurement::HAS_SATELLITE_ISB_UNCERTAINTY |
163 GnssMeasurement::HAS_SATELLITE_PVT,
164 .svid = 13,
165 .signalType = signalType,
166 .receivedSvTimeInNs = 8195997131077,
167 .receivedSvTimeUncertaintyInNs = 15,
168 .antennaCN0DbHz = 30.0,
169 .basebandCN0DbHz = 26.5,
170 .agcLevelDb = 2.3,
171 .pseudorangeRateMps = -484.13739013671875,
172 .pseudorangeRateUncertaintyMps = 0.1037999987602233,
173 .accumulatedDeltaRangeState = GnssMeasurement::ADR_STATE_VALID,
174 .accumulatedDeltaRangeM = 1.52,
175 .accumulatedDeltaRangeUncertaintyM = 2.43,
176 .multipathIndicator = aidl::android::hardware::gnss::GnssMultipathIndicator::UNKNOWN,
177 .state = GnssMeasurement::STATE_CODE_LOCK | GnssMeasurement::STATE_BIT_SYNC |
178 GnssMeasurement::STATE_SUBFRAME_SYNC | GnssMeasurement::STATE_TOW_DECODED |
179 GnssMeasurement::STATE_GLO_STRING_SYNC |
180 GnssMeasurement::STATE_GLO_TOD_DECODED,
181 .fullInterSignalBiasNs = 21.5,
182 .fullInterSignalBiasUncertaintyNs = 792.0,
183 .satelliteInterSignalBiasNs = 233.9,
184 .satelliteInterSignalBiasUncertaintyNs = 921.2,
185 .satellitePvt =
186 {
187 .flags = SatellitePvt::HAS_POSITION_VELOCITY_CLOCK_INFO |
188 SatellitePvt::HAS_IONO | SatellitePvt::HAS_TROPO,
189 .satPosEcef = {.posXMeters = 10442993.1153328,
190 .posYMeters = -19926932.8051666,
191 .posZMeters = -12034295.0216203,
192 .ureMeters = 1000.2345678},
193 .satVelEcef = {.velXMps = -478.667183715732,
194 .velYMps = 1580.68371984114,
195 .velZMps = -3030.52994449997,
196 .ureRateMps = 10.2345678},
197 .satClockInfo = {.satHardwareCodeBiasMeters = 1.396983861923e-09,
198 .satTimeCorrectionMeters = -7113.08964331,
199 .satClkDriftMps = 0},
200 .ionoDelayMeters = 3.069949602639317e-08,
201 .tropoDelayMeters = 3.882265204404031,
202 .ephemerisSource =
203 SatellitePvt::SatelliteEphemerisSource::SERVER_LONG_TERM,
204 .timeOfClockSeconds = 12345,
205 .issueOfDataClock = 143,
206 .timeOfEphemerisSeconds = 9876,
207 .issueOfDataEphemeris = 48,
208 },
209 .correlationVectors = {}};
210
211 GnssClock clock = {.gnssClockFlags = GnssClock::HAS_FULL_BIAS | GnssClock::HAS_BIAS |
212 GnssClock::HAS_BIAS_UNCERTAINTY | GnssClock::HAS_DRIFT |
213 GnssClock::HAS_DRIFT_UNCERTAINTY,
214 .timeNs = 2713545000000,
215 .fullBiasNs = -1226701900521857520,
216 .biasNs = 0.59689998626708984,
217 .biasUncertaintyNs = 47514.989972114563,
218 .driftNsps = -51.757811607455452,
219 .driftUncertaintyNsps = 310.64968328491528,
220 .hwClockDiscontinuityCount = 1,
221 .referenceSignalTypeForIsb = signalType};
222
223 ElapsedRealtime timestamp = {
224 .flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
225 .timestampNs = ::android::elapsedRealtimeNano(),
226 // This is an hardcoded value indicating a 1ms of uncertainty between the two clocks.
227 // In an actual implementation provide an estimate of the synchronization uncertainty
228 // or don't set the field.
229 .timeUncertaintyNs = 1020400};
230
231 if (enableCorrVecOutputs) {
232 aidl::android::hardware::gnss::CorrelationVector correlationVector1 = {
233 .frequencyOffsetMps = 10,
234 .samplingWidthM = 30,
235 .samplingStartM = 0,
236 .magnitude = {0, 5000, 10000, 5000, 0, 0, 3000, 0}};
237 aidl::android::hardware::gnss::CorrelationVector correlationVector2 = {
238 .frequencyOffsetMps = 20,
239 .samplingWidthM = 30,
240 .samplingStartM = -10,
241 .magnitude = {0, 3000, 5000, 3000, 0, 0, 1000, 0}};
242 measurement.correlationVectors = {correlationVector1, correlationVector2};
243 measurement.flags |= GnssMeasurement::HAS_CORRELATION_VECTOR;
244 }
245
246 GnssAgc gnssAgc1 = {
247 .agcLevelDb = 3.5,
248 .constellation = GnssConstellationType::GLONASS,
249 .carrierFrequencyHz = (int64_t)kGloG1FreqHz,
250 };
251
252 GnssAgc gnssAgc2 = {
253 .agcLevelDb = -5.1,
254 .constellation = GnssConstellationType::GPS,
255 .carrierFrequencyHz = (int64_t)kGpsL1FreqHz,
256 };
257
258 GnssData gnssData = {.measurements = {measurement},
259 .clock = clock,
260 .elapsedRealtime = timestamp,
261 .gnssAgcs = std::vector({gnssAgc1, gnssAgc2}),
262 .isFullTracking = enableFullTracking};
263 return gnssData;
264 }
265
getMockLocation()266 GnssLocation Utils::getMockLocation() {
267 ElapsedRealtime elapsedRealtime = {
268 .flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
269 .timestampNs = ::android::elapsedRealtimeNano(),
270 // This is an hardcoded value indicating a 1ms of uncertainty between the two clocks.
271 // In an actual implementation provide an estimate of the synchronization uncertainty
272 // or don't set the field.
273 .timeUncertaintyNs = 1020400};
274 GnssLocation location = {.gnssLocationFlags = 0xFF,
275 .latitudeDegrees = gMockLatitudeDegrees,
276 .longitudeDegrees = gMockLongitudeDegrees,
277 .altitudeMeters = gMockAltitudeMeters,
278 .speedMetersPerSec = gMockSpeedMetersPerSec,
279 .bearingDegrees = gMockBearingDegrees,
280 .horizontalAccuracyMeters = kMockHorizontalAccuracyMeters,
281 .verticalAccuracyMeters = kMockVerticalAccuracyMeters,
282 .speedAccuracyMetersPerSecond = kMockSpeedAccuracyMetersPerSecond,
283 .bearingAccuracyDegrees = kMockBearingAccuracyDegrees,
284 .timestampMillis = static_cast<int64_t>(
285 kMockTimestamp + ::android::elapsedRealtimeNano() / 1e6),
286 .elapsedRealtime = elapsedRealtime};
287 return location;
288 }
289
getMockLocationV2_0()290 V2_0::GnssLocation Utils::getMockLocationV2_0() {
291 const V2_0::ElapsedRealtime timestamp = {
292 .flags = V2_0::ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |
293 V2_0::ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS,
294 .timestampNs = static_cast<uint64_t>(::android::elapsedRealtimeNano()),
295 // This is an hardcoded value indicating a 1ms of uncertainty between the two clocks.
296 // In an actual implementation provide an estimate of the synchronization uncertainty
297 // or don't set the field.
298 .timeUncertaintyNs = 1000000};
299
300 V2_0::GnssLocation location = {.v1_0 = Utils::getMockLocationV1_0(),
301 .elapsedRealtime = timestamp};
302 return location;
303 }
304
getMockLocationV1_0()305 V1_0::GnssLocation Utils::getMockLocationV1_0() {
306 V1_0::GnssLocation location = {
307 .gnssLocationFlags = 0xFF,
308 .latitudeDegrees = gMockLatitudeDegrees,
309 .longitudeDegrees = gMockLongitudeDegrees,
310 .altitudeMeters = gMockAltitudeMeters,
311 .speedMetersPerSec = gMockSpeedMetersPerSec,
312 .bearingDegrees = gMockBearingDegrees,
313 .horizontalAccuracyMeters = kMockHorizontalAccuracyMeters,
314 .verticalAccuracyMeters = kMockVerticalAccuracyMeters,
315 .speedAccuracyMetersPerSecond = kMockSpeedAccuracyMetersPerSecond,
316 .bearingAccuracyDegrees = kMockBearingAccuracyDegrees,
317 .timestamp =
318 static_cast<int64_t>(kMockTimestamp + ::android::elapsedRealtimeNano() / 1e6)};
319 return location;
320 }
321
322 namespace {
getMockSvInfo(int svid,GnssConstellationType type,float cN0DbHz,float basebandCN0DbHz,float elevationDegrees,float azimuthDegrees,long carrierFrequencyHz)323 GnssSvInfo getMockSvInfo(int svid, GnssConstellationType type, float cN0DbHz, float basebandCN0DbHz,
324 float elevationDegrees, float azimuthDegrees, long carrierFrequencyHz) {
325 GnssSvInfo svInfo = {
326 .svid = svid,
327 .constellation = type,
328 .cN0Dbhz = cN0DbHz,
329 .basebandCN0DbHz = basebandCN0DbHz,
330 .elevationDegrees = elevationDegrees,
331 .azimuthDegrees = azimuthDegrees,
332 .carrierFrequencyHz = carrierFrequencyHz,
333 .svFlag = (int)GnssSvFlags::USED_IN_FIX | (int)GnssSvFlags::HAS_EPHEMERIS_DATA |
334 (int)GnssSvFlags::HAS_ALMANAC_DATA | (int)GnssSvFlags::HAS_CARRIER_FREQUENCY};
335 return svInfo;
336 }
337 } // anonymous namespace
338
getMockSvInfoList()339 std::vector<GnssSvInfo> Utils::getMockSvInfoList() {
340 std::vector<GnssSvInfo> gnssSvInfoList = {
341 getMockSvInfo(3, GnssConstellationType::GPS, 32.5, 27.5, 59.1, 166.5, kGpsL1FreqHz),
342 getMockSvInfo(5, GnssConstellationType::GPS, 27.0, 22.0, 29.0, 56.5, kGpsL1FreqHz),
343 getMockSvInfo(17, GnssConstellationType::GPS, 30.5, 25.5, 71.0, 77.0, kGpsL5FreqHz),
344 getMockSvInfo(26, GnssConstellationType::GPS, 24.1, 19.1, 28.0, 253.0, kGpsL5FreqHz),
345 getMockSvInfo(5, GnssConstellationType::GLONASS, 20.5, 15.5, 11.5, 116.0, kGloG1FreqHz),
346 getMockSvInfo(17, GnssConstellationType::GLONASS, 21.5, 16.5, 28.5, 186.0,
347 kGloG1FreqHz),
348 getMockSvInfo(18, GnssConstellationType::GLONASS, 28.3, 25.3, 38.8, 69.0, kGloG1FreqHz),
349 getMockSvInfo(10, GnssConstellationType::GLONASS, 25.0, 20.0, 66.0, 247.0,
350 kGloG1FreqHz),
351 getMockSvInfo(3, GnssConstellationType::IRNSS, 22.0, 19.7, 35.0, 112.0, kIrnssL5FreqHz),
352 };
353 return gnssSvInfoList;
354 }
355
getMockSvInfoListV2_1()356 hidl_vec<GnssSvInfoV2_1> Utils::getMockSvInfoListV2_1() {
357 GnssSvInfoV1_0 gnssSvInfoV1_0 = Utils::getMockSvInfoV1_0(3, V1_0::GnssConstellationType::GPS,
358 32.5, 59.1, 166.5, kGpsL1FreqHz);
359 GnssSvInfoV2_0 gnssSvInfoV2_0 =
360 Utils::getMockSvInfoV2_0(gnssSvInfoV1_0, V2_0::GnssConstellationType::GPS);
361 hidl_vec<GnssSvInfoV2_1> gnssSvInfoList = {
362 Utils::getMockSvInfoV2_1(gnssSvInfoV2_0, 27.5),
363 getMockSvInfoV2_1(
364 getMockSvInfoV2_0(getMockSvInfoV1_0(5, V1_0::GnssConstellationType::GPS, 27.0,
365 29.0, 56.5, kGpsL1FreqHz),
366 V2_0::GnssConstellationType::GPS),
367 22.0),
368 getMockSvInfoV2_1(
369 getMockSvInfoV2_0(getMockSvInfoV1_0(17, V1_0::GnssConstellationType::GPS, 30.5,
370 71.0, 77.0, kGpsL5FreqHz),
371 V2_0::GnssConstellationType::GPS),
372 25.5),
373 getMockSvInfoV2_1(
374 getMockSvInfoV2_0(getMockSvInfoV1_0(26, V1_0::GnssConstellationType::GPS, 24.1,
375 28.0, 253.0, kGpsL5FreqHz),
376 V2_0::GnssConstellationType::GPS),
377 19.1),
378 getMockSvInfoV2_1(
379 getMockSvInfoV2_0(getMockSvInfoV1_0(5, V1_0::GnssConstellationType::GLONASS,
380 20.5, 11.5, 116.0, kGloG1FreqHz),
381 V2_0::GnssConstellationType::GLONASS),
382 15.5),
383 getMockSvInfoV2_1(
384 getMockSvInfoV2_0(getMockSvInfoV1_0(17, V1_0::GnssConstellationType::GLONASS,
385 21.5, 28.5, 186.0, kGloG1FreqHz),
386 V2_0::GnssConstellationType::GLONASS),
387 16.5),
388 getMockSvInfoV2_1(
389 getMockSvInfoV2_0(getMockSvInfoV1_0(18, V1_0::GnssConstellationType::GLONASS,
390 28.3, 38.8, 69.0, kGloG1FreqHz),
391 V2_0::GnssConstellationType::GLONASS),
392 25.3),
393 getMockSvInfoV2_1(
394 getMockSvInfoV2_0(getMockSvInfoV1_0(10, V1_0::GnssConstellationType::GLONASS,
395 25.0, 66.0, 247.0, kGloG1FreqHz),
396 V2_0::GnssConstellationType::GLONASS),
397 20.0),
398 getMockSvInfoV2_1(
399 getMockSvInfoV2_0(getMockSvInfoV1_0(3, V1_0::GnssConstellationType::UNKNOWN,
400 22.0, 35.0, 112.0, kIrnssL5FreqHz),
401 V2_0::GnssConstellationType::IRNSS),
402 19.7),
403 };
404 return gnssSvInfoList;
405 }
406
getMockSvInfoV2_1(GnssSvInfoV2_0 gnssSvInfoV2_0,float basebandCN0DbHz)407 GnssSvInfoV2_1 Utils::getMockSvInfoV2_1(GnssSvInfoV2_0 gnssSvInfoV2_0, float basebandCN0DbHz) {
408 GnssSvInfoV2_1 gnssSvInfoV2_1 = {
409 .v2_0 = gnssSvInfoV2_0,
410 .basebandCN0DbHz = basebandCN0DbHz,
411 };
412 return gnssSvInfoV2_1;
413 }
414
getMockSvInfoV2_0(GnssSvInfoV1_0 gnssSvInfoV1_0,V2_0::GnssConstellationType type)415 GnssSvInfoV2_0 Utils::getMockSvInfoV2_0(GnssSvInfoV1_0 gnssSvInfoV1_0,
416 V2_0::GnssConstellationType type) {
417 GnssSvInfoV2_0 gnssSvInfoV2_0 = {
418 .v1_0 = gnssSvInfoV1_0,
419 .constellation = type,
420 };
421 return gnssSvInfoV2_0;
422 }
423
getMockSvInfoV1_0(int16_t svid,V1_0::GnssConstellationType type,float cN0DbHz,float elevationDegrees,float azimuthDegrees,float carrierFrequencyHz)424 GnssSvInfoV1_0 Utils::getMockSvInfoV1_0(int16_t svid, V1_0::GnssConstellationType type,
425 float cN0DbHz, float elevationDegrees, float azimuthDegrees,
426 float carrierFrequencyHz) {
427 GnssSvInfoV1_0 svInfo = {
428 .svid = svid,
429 .constellation = type,
430 .cN0Dbhz = cN0DbHz,
431 .elevationDegrees = elevationDegrees,
432 .azimuthDegrees = azimuthDegrees,
433 .carrierFrequencyHz = carrierFrequencyHz,
434 .svFlag = GnssSvFlagsV1_0::USED_IN_FIX | GnssSvFlagsV1_0::HAS_EPHEMERIS_DATA |
435 GnssSvFlagsV1_0::HAS_ALMANAC_DATA | GnssSvFlagsV1_0::HAS_CARRIER_FREQUENCY};
436 return svInfo;
437 }
438
getMockAntennaInfos()439 hidl_vec<GnssAntennaInfo> Utils::getMockAntennaInfos() {
440 GnssAntennaInfo mockAntennaInfo_1 = {
441 .carrierFrequencyMHz = kGpsL1FreqHz * 1e-6,
442 .phaseCenterOffsetCoordinateMillimeters = Coord{.x = 1,
443 .xUncertainty = 0.1,
444 .y = 2,
445 .yUncertainty = 0.1,
446 .z = 3,
447 .zUncertainty = 0.1},
448 .phaseCenterVariationCorrectionMillimeters =
449 {
450 Row{hidl_vec<double>{1, -1, 5, -2, 3, -1}},
451 Row{hidl_vec<double>{-2, 3, 2, 0, 1, 2}},
452 Row{hidl_vec<double>{1, 3, 2, -1, -3, 5}},
453 },
454 .phaseCenterVariationCorrectionUncertaintyMillimeters =
455 {
456 Row{hidl_vec<double>{0.1, 0.2, 0.4, 0.1, 0.2, 0.3}},
457 Row{hidl_vec<double>{0.3, 0.2, 0.3, 0.6, 0.1, 0.1}},
458 Row{hidl_vec<double>{0.1, 0.1, 0.4, 0.2, 0.5, 0.3}},
459 },
460 .signalGainCorrectionDbi =
461 {
462 Row{hidl_vec<double>{2, -3, 1, -3, 0, -4}},
463 Row{hidl_vec<double>{1, 0, -4, 1, 3, -2}},
464 Row{hidl_vec<double>{3, -2, 0, -2, 3, 0}},
465 },
466 .signalGainCorrectionUncertaintyDbi =
467 {
468 Row{hidl_vec<double>{0.3, 0.1, 0.2, 0.6, 0.1, 0.3}},
469 Row{hidl_vec<double>{0.1, 0.1, 0.5, 0.2, 0.3, 0.1}},
470 Row{hidl_vec<double>{0.2, 0.4, 0.2, 0.1, 0.1, 0.2}},
471 },
472 };
473
474 GnssAntennaInfo mockAntennaInfo_2 = {
475 .carrierFrequencyMHz = kGpsL5FreqHz * 1e-6,
476 .phaseCenterOffsetCoordinateMillimeters = Coord{.x = 5,
477 .xUncertainty = 0.1,
478 .y = 6,
479 .yUncertainty = 0.1,
480 .z = 7,
481 .zUncertainty = 0.1},
482 };
483
484 hidl_vec<GnssAntennaInfo> mockAntennaInfos = {
485 mockAntennaInfo_1,
486 mockAntennaInfo_2,
487 };
488 return mockAntennaInfos;
489 }
490
491 } // namespace common
492 } // namespace gnss
493 } // namespace hardware
494 } // namespace android
495