1 /* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation, nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29 #define LOG_NDEBUG 0 //Define to enable LOGV
30 #define LOG_TAG "LocSvc_LocApiBase"
31
32 #include <dlfcn.h>
33 #include <inttypes.h>
34 #include <gps_extended_c.h>
35 #include <LocApiBase.h>
36 #include <LocAdapterBase.h>
37 #include <log_util.h>
38 #include <LocContext.h>
39
40 namespace loc_core {
41
42 #define TO_ALL_LOCADAPTERS(call) TO_ALL_ADAPTERS(mLocAdapters, (call))
43 #define TO_1ST_HANDLING_LOCADAPTERS(call) TO_1ST_HANDLING_ADAPTER(mLocAdapters, (call))
44
hexcode(char * hexstring,int string_size,const char * data,int data_size)45 int hexcode(char *hexstring, int string_size,
46 const char *data, int data_size)
47 {
48 int i;
49 for (i = 0; i < data_size; i++)
50 {
51 char ch = data[i];
52 if (i*2 + 3 <= string_size)
53 {
54 snprintf(&hexstring[i*2], 3, "%02X", ch);
55 }
56 else {
57 break;
58 }
59 }
60 return i;
61 }
62
decodeAddress(char * addr_string,int string_size,const char * data,int data_size)63 int decodeAddress(char *addr_string, int string_size,
64 const char *data, int data_size)
65 {
66 const char addr_prefix = 0x91;
67 int i, idxOutput = 0;
68
69 if (!data || !addr_string) { return 0; }
70
71 if (data[0] != addr_prefix)
72 {
73 LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]);
74 addr_string[0] = '\0';
75 return 0; // prefix not correct
76 }
77
78 for (i = 1; i < data_size; i++)
79 {
80 unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4;
81 if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; }
82 if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; }
83 }
84
85 addr_string[idxOutput] = '\0'; // Terminates the string
86
87 return idxOutput;
88 }
89
90 struct LocSsrMsg : public LocMsg {
91 LocApiBase* mLocApi;
LocSsrMsgloc_core::LocSsrMsg92 inline LocSsrMsg(LocApiBase* locApi) :
93 LocMsg(), mLocApi(locApi)
94 {
95 locallog();
96 }
procloc_core::LocSsrMsg97 inline virtual void proc() const {
98 mLocApi->close();
99 if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask())) {
100 // Notify adapters that engine up after SSR
101 mLocApi->handleEngineUpEvent();
102 }
103 }
locallogloc_core::LocSsrMsg104 inline void locallog() const {
105 LOC_LOGV("LocSsrMsg");
106 }
logloc_core::LocSsrMsg107 inline virtual void log() const {
108 locallog();
109 }
110 };
111
112 struct LocOpenMsg : public LocMsg {
113 LocApiBase* mLocApi;
114 LocAdapterBase* mAdapter;
LocOpenMsgloc_core::LocOpenMsg115 inline LocOpenMsg(LocApiBase* locApi, LocAdapterBase* adapter = nullptr) :
116 LocMsg(), mLocApi(locApi), mAdapter(adapter)
117 {
118 locallog();
119 }
procloc_core::LocOpenMsg120 inline virtual void proc() const {
121 if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask()) &&
122 nullptr != mAdapter) {
123 mAdapter->handleEngineUpEvent();
124 }
125 }
locallogloc_core::LocOpenMsg126 inline void locallog() const {
127 LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask());
128 }
logloc_core::LocOpenMsg129 inline virtual void log() const {
130 locallog();
131 }
132 };
133
134 struct LocCloseMsg : public LocMsg {
135 LocApiBase* mLocApi;
LocCloseMsgloc_core::LocCloseMsg136 inline LocCloseMsg(LocApiBase* locApi) :
137 LocMsg(), mLocApi(locApi)
138 {
139 locallog();
140 }
procloc_core::LocCloseMsg141 inline virtual void proc() const {
142 mLocApi->close();
143 }
locallogloc_core::LocCloseMsg144 inline void locallog() const {
145 }
logloc_core::LocCloseMsg146 inline virtual void log() const {
147 locallog();
148 }
149 };
150
151 MsgTask* LocApiBase::mMsgTask = nullptr;
152 volatile int32_t LocApiBase::mMsgTaskRefCount = 0;
153
LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,ContextBase * context)154 LocApiBase::LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
155 ContextBase* context) :
156 mContext(context),
157 mMask(0), mExcludedMask(excludedMask)
158 {
159 memset(mLocAdapters, 0, sizeof(mLocAdapters));
160
161 android_atomic_inc(&mMsgTaskRefCount);
162 if (nullptr == mMsgTask) {
163 mMsgTask = new MsgTask("LocApiMsgTask", false);
164 }
165 }
166
getEvtMask()167 LOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask()
168 {
169 LOC_API_ADAPTER_EVENT_MASK_T mask = 0;
170
171 TO_ALL_LOCADAPTERS(mask |= mLocAdapters[i]->getEvtMask());
172
173 return mask & ~mExcludedMask;
174 }
175
isMaster()176 bool LocApiBase::isMaster()
177 {
178 bool isMaster = false;
179
180 for (int i = 0;
181 !isMaster && i < MAX_ADAPTERS && NULL != mLocAdapters[i];
182 i++) {
183 isMaster |= mLocAdapters[i]->isAdapterMaster();
184 }
185 return isMaster;
186 }
187
isInSession()188 bool LocApiBase::isInSession()
189 {
190 bool inSession = false;
191
192 for (int i = 0;
193 !inSession && i < MAX_ADAPTERS && NULL != mLocAdapters[i];
194 i++) {
195 inSession = mLocAdapters[i]->isInSession();
196 }
197
198 return inSession;
199 }
200
needReport(const UlpLocation & ulpLocation,enum loc_sess_status status,LocPosTechMask techMask)201 bool LocApiBase::needReport(const UlpLocation& ulpLocation,
202 enum loc_sess_status status,
203 LocPosTechMask techMask)
204 {
205 bool reported = false;
206
207 if (LOC_SESS_SUCCESS == status) {
208 // this is a final fix
209 LocPosTechMask mask =
210 LOC_POS_TECH_MASK_SATELLITE | LOC_POS_TECH_MASK_SENSORS | LOC_POS_TECH_MASK_HYBRID;
211 // it is a Satellite fix or a sensor fix
212 reported = (mask & techMask);
213 }
214 else if (LOC_SESS_INTERMEDIATE == status &&
215 LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS) {
216 // this is a intermediate fix and we accept intermediate
217
218 // it is NOT the case that
219 // there is inaccuracy; and
220 // we care about inaccuracy; and
221 // the inaccuracy exceeds our tolerance
222 reported = !((ulpLocation.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ACCURACY) &&
223 (ContextBase::mGps_conf.ACCURACY_THRES != 0) &&
224 (ulpLocation.gpsLocation.accuracy > ContextBase::mGps_conf.ACCURACY_THRES));
225 }
226
227 return reported;
228 }
229
addAdapter(LocAdapterBase * adapter)230 void LocApiBase::addAdapter(LocAdapterBase* adapter)
231 {
232 for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
233 if (mLocAdapters[i] == NULL) {
234 mLocAdapters[i] = adapter;
235 sendMsg(new LocOpenMsg(this, adapter));
236 break;
237 }
238 }
239 }
240
removeAdapter(LocAdapterBase * adapter)241 void LocApiBase::removeAdapter(LocAdapterBase* adapter)
242 {
243 for (int i = 0;
244 i < MAX_ADAPTERS && NULL != mLocAdapters[i];
245 i++) {
246 if (mLocAdapters[i] == adapter) {
247 mLocAdapters[i] = NULL;
248
249 // shift the rest of the adapters up so that the pointers
250 // in the array do not have holes. This should be more
251 // performant, because the array maintenance is much much
252 // less frequent than event handlings, which need to linear
253 // search all the adapters
254 int j = i;
255 while (++i < MAX_ADAPTERS && mLocAdapters[i] != NULL);
256
257 // i would be MAX_ADAPTERS or point to a NULL
258 i--;
259 // i now should point to a none NULL adapter within valid
260 // range although i could be equal to j, but it won't hurt.
261 // No need to check it, as it gains nothing.
262 mLocAdapters[j] = mLocAdapters[i];
263 // this makes sure that we exit the for loop
264 mLocAdapters[i] = NULL;
265
266 // if we have an empty list of adapters
267 if (0 == i) {
268 sendMsg(new LocCloseMsg(this));
269 } else {
270 // else we need to remove the bit
271 sendMsg(new LocOpenMsg(this));
272 }
273 }
274 }
275 }
276
updateEvtMask()277 void LocApiBase::updateEvtMask()
278 {
279 sendMsg(new LocOpenMsg(this));
280 }
281
updateNmeaMask(uint32_t mask)282 void LocApiBase::updateNmeaMask(uint32_t mask)
283 {
284 struct LocSetNmeaMsg : public LocMsg {
285 LocApiBase* mLocApi;
286 uint32_t mMask;
287 inline LocSetNmeaMsg(LocApiBase* locApi, uint32_t mask) :
288 LocMsg(), mLocApi(locApi), mMask(mask)
289 {
290 locallog();
291 }
292 inline virtual void proc() const {
293 mLocApi->setNMEATypesSync(mMask);
294 }
295 inline void locallog() const {
296 LOC_LOGv("LocSyncNmea NmeaMask: %" PRIx32 "\n", mMask);
297 }
298 inline virtual void log() const {
299 locallog();
300 }
301 };
302
303 sendMsg(new LocSetNmeaMsg(this, mask));
304 }
305
handleEngineUpEvent()306 void LocApiBase::handleEngineUpEvent()
307 {
308 // loop through adapters, and deliver to all adapters.
309 TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());
310 }
311
handleEngineDownEvent()312 void LocApiBase::handleEngineDownEvent()
313 { // This will take care of renegotiating the loc handle
314 sendMsg(new LocSsrMsg(this));
315
316 // loop through adapters, and deliver to all adapters.
317 TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
318 }
319
reportPosition(UlpLocation & location,GpsLocationExtended & locationExtended,enum loc_sess_status status,LocPosTechMask loc_technology_mask,GnssDataNotification * pDataNotify,int msInWeek)320 void LocApiBase::reportPosition(UlpLocation& location,
321 GpsLocationExtended& locationExtended,
322 enum loc_sess_status status,
323 LocPosTechMask loc_technology_mask,
324 GnssDataNotification* pDataNotify,
325 int msInWeek)
326 {
327 // print the location info before delivering
328 LOC_LOGD("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n "
329 "altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n "
330 "timestamp: %" PRId64 "\n"
331 "Session status: %d\n Technology mask: %u\n "
332 "SV used in fix (gps/glo/bds/gal/qzss) : \
333 (0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 "/0x%" PRIx64 ")",
334 location.gpsLocation.flags, location.position_source,
335 location.gpsLocation.latitude, location.gpsLocation.longitude,
336 location.gpsLocation.altitude, location.gpsLocation.speed,
337 location.gpsLocation.bearing, location.gpsLocation.accuracy,
338 location.gpsLocation.timestamp, status, loc_technology_mask,
339 locationExtended.gnss_sv_used_ids.gps_sv_used_ids_mask,
340 locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask,
341 locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask,
342 locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask,
343 locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask);
344 // loop through adapters, and deliver to all adapters.
345 TO_ALL_LOCADAPTERS(
346 mLocAdapters[i]->reportPositionEvent(location, locationExtended,
347 status, loc_technology_mask,
348 pDataNotify, msInWeek)
349 );
350 }
351
reportWwanZppFix(LocGpsLocation & zppLoc)352 void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc)
353 {
354 // loop through adapters, and deliver to the first handling adapter.
355 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc));
356 }
357
reportZppBestAvailableFix(LocGpsLocation & zppLoc,GpsLocationExtended & location_extended,LocPosTechMask tech_mask)358 void LocApiBase::reportZppBestAvailableFix(LocGpsLocation &zppLoc,
359 GpsLocationExtended &location_extended, LocPosTechMask tech_mask)
360 {
361 // loop through adapters, and deliver to the first handling adapter.
362 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportZppBestAvailableFix(zppLoc,
363 location_extended, tech_mask));
364 }
365
requestOdcpi(OdcpiRequestInfo & request)366 void LocApiBase::requestOdcpi(OdcpiRequestInfo& request)
367 {
368 // loop through adapters, and deliver to the first handling adapter.
369 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestOdcpiEvent(request));
370 }
371
reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot)372 void LocApiBase::reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot)
373 {
374 // loop through adapters, and deliver to the first handling adapter.
375 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssEngEnergyConsumedEvent(
376 energyConsumedSinceFirstBoot));
377 }
378
reportDeleteAidingDataEvent(GnssAidingData & aidingData)379 void LocApiBase::reportDeleteAidingDataEvent(GnssAidingData& aidingData) {
380 // loop through adapters, and deliver to the first handling adapter.
381 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDeleteAidingDataEvent(aidingData));
382 }
383
reportKlobucharIonoModel(GnssKlobucharIonoModel & ionoModel)384 void LocApiBase::reportKlobucharIonoModel(GnssKlobucharIonoModel & ionoModel) {
385 // loop through adapters, and deliver to the first handling adapter.
386 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportKlobucharIonoModelEvent(ionoModel));
387 }
388
reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo & additionalSystemInfo)389 void LocApiBase::reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo) {
390 // loop through adapters, and deliver to the first handling adapter.
391 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportGnssAdditionalSystemInfoEvent(
392 additionalSystemInfo));
393 }
394
sendNfwNotification(GnssNfwNotification & notification)395 void LocApiBase::sendNfwNotification(GnssNfwNotification& notification)
396 {
397 // loop through adapters, and deliver to the first handling adapter.
398 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNfwNotificationEvent(notification));
399
400 }
401
reportSv(GnssSvNotification & svNotify)402 void LocApiBase::reportSv(GnssSvNotification& svNotify)
403 {
404 const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
405 "QZSS", "BEIDOU", "GALILEO", "NAVIC" };
406
407 // print the SV info before delivering
408 LOC_LOGV("num sv: %u\n"
409 " sv: constellation svid cN0"
410 " elevation azimuth flags",
411 svNotify.count);
412 for (size_t i = 0; i < svNotify.count && i < LOC_GNSS_MAX_SVS; i++) {
413 if (svNotify.gnssSvs[i].type >
414 sizeof(constellationString) / sizeof(constellationString[0]) - 1) {
415 svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN;
416 }
417 // Display what we report to clients
418 uint16_t displaySvId = GNSS_SV_TYPE_QZSS == svNotify.gnssSvs[i].type ?
419 svNotify.gnssSvs[i].svId + QZSS_SV_PRN_MIN - 1 :
420 svNotify.gnssSvs[i].svId;
421 LOC_LOGV(" %03zu: %*s %02d %f %f %f %f 0x%02X",
422 i,
423 13,
424 constellationString[svNotify.gnssSvs[i].type],
425 displaySvId,
426 svNotify.gnssSvs[i].cN0Dbhz,
427 svNotify.gnssSvs[i].elevation,
428 svNotify.gnssSvs[i].azimuth,
429 svNotify.gnssSvs[i].carrierFrequencyHz,
430 svNotify.gnssSvs[i].gnssSvOptionsMask);
431 }
432 // loop through adapters, and deliver to all adapters.
433 TO_ALL_LOCADAPTERS(
434 mLocAdapters[i]->reportSvEvent(svNotify)
435 );
436 }
437
reportSvPolynomial(GnssSvPolynomial & svPolynomial)438 void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
439 {
440 // loop through adapters, and deliver to all adapters.
441 TO_ALL_LOCADAPTERS(
442 mLocAdapters[i]->reportSvPolynomialEvent(svPolynomial)
443 );
444 }
445
reportSvEphemeris(GnssSvEphemerisReport & svEphemeris)446 void LocApiBase::reportSvEphemeris(GnssSvEphemerisReport & svEphemeris)
447 {
448 // loop through adapters, and deliver to all adapters.
449 TO_ALL_LOCADAPTERS(
450 mLocAdapters[i]->reportSvEphemerisEvent(svEphemeris)
451 );
452 }
453
reportStatus(LocGpsStatusValue status)454 void LocApiBase::reportStatus(LocGpsStatusValue status)
455 {
456 // loop through adapters, and deliver to all adapters.
457 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status));
458 }
459
reportData(GnssDataNotification & dataNotify,int msInWeek)460 void LocApiBase::reportData(GnssDataNotification& dataNotify, int msInWeek)
461 {
462 // loop through adapters, and deliver to all adapters.
463 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportDataEvent(dataNotify, msInWeek));
464 }
465
reportNmea(const char * nmea,int length)466 void LocApiBase::reportNmea(const char* nmea, int length)
467 {
468 // loop through adapters, and deliver to all adapters.
469 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmeaEvent(nmea, length));
470 }
471
reportXtraServer(const char * url1,const char * url2,const char * url3,const int maxlength)472 void LocApiBase::reportXtraServer(const char* url1, const char* url2,
473 const char* url3, const int maxlength)
474 {
475 // loop through adapters, and deliver to the first handling adapter.
476 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportXtraServer(url1, url2, url3, maxlength));
477
478 }
479
reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo)480 void LocApiBase::reportLocationSystemInfo(const LocationSystemInfo& locationSystemInfo)
481 {
482 // loop through adapters, and deliver to all adapters.
483 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportLocationSystemInfoEvent(locationSystemInfo));
484 }
485
requestXtraData()486 void LocApiBase::requestXtraData()
487 {
488 // loop through adapters, and deliver to the first handling adapter.
489 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestXtraData());
490 }
491
requestTime()492 void LocApiBase::requestTime()
493 {
494 // loop through adapters, and deliver to the first handling adapter.
495 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestTime());
496 }
497
requestLocation()498 void LocApiBase::requestLocation()
499 {
500 // loop through adapters, and deliver to the first handling adapter.
501 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation());
502 }
503
requestATL(int connHandle,LocAGpsType agps_type,LocApnTypeMask apn_type_mask)504 void LocApiBase::requestATL(int connHandle, LocAGpsType agps_type,
505 LocApnTypeMask apn_type_mask)
506 {
507 // loop through adapters, and deliver to the first handling adapter.
508 TO_1ST_HANDLING_LOCADAPTERS(
509 mLocAdapters[i]->requestATL(connHandle, agps_type, apn_type_mask));
510 }
511
releaseATL(int connHandle)512 void LocApiBase::releaseATL(int connHandle)
513 {
514 // loop through adapters, and deliver to the first handling adapter.
515 TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle));
516 }
517
requestNiNotify(GnssNiNotification & notify,const void * data,const LocInEmergency emergencyState)518 void LocApiBase::requestNiNotify(GnssNiNotification ¬ify, const void* data,
519 const LocInEmergency emergencyState)
520 {
521 // loop through adapters, and deliver to the first handling adapter.
522 TO_1ST_HANDLING_LOCADAPTERS(
523 mLocAdapters[i]->requestNiNotifyEvent(notify,
524 data,
525 emergencyState));
526 }
527
getSibling()528 void* LocApiBase :: getSibling()
529 DEFAULT_IMPL(NULL)
530
531 LocApiProxyBase* LocApiBase :: getLocApiProxy()
532 DEFAULT_IMPL(NULL)
533
534 void LocApiBase::reportGnssMeasurements(GnssMeasurements& gnssMeasurements, int msInWeek)
535 {
536 // loop through adapters, and deliver to all adapters.
537 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementsEvent(gnssMeasurements, msInWeek));
538 }
539
reportGnssSvIdConfig(const GnssSvIdConfig & config)540 void LocApiBase::reportGnssSvIdConfig(const GnssSvIdConfig& config)
541 {
542 // Print the config
543 LOC_LOGv("gloBlacklistSvMask: %" PRIu64 ", bdsBlacklistSvMask: %" PRIu64 ",\n"
544 "qzssBlacklistSvMask: %" PRIu64 ", galBlacklistSvMask: %" PRIu64,
545 config.gloBlacklistSvMask, config.bdsBlacklistSvMask,
546 config.qzssBlacklistSvMask, config.galBlacklistSvMask);
547
548 // Loop through adapters, and deliver to all adapters.
549 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssSvIdConfigEvent(config));
550 }
551
reportGnssSvTypeConfig(const GnssSvTypeConfig & config)552 void LocApiBase::reportGnssSvTypeConfig(const GnssSvTypeConfig& config)
553 {
554 // Print the config
555 LOC_LOGv("blacklistedMask: %" PRIu64 ", enabledMask: %" PRIu64,
556 config.blacklistedSvTypesMask, config.enabledSvTypesMask);
557
558 // Loop through adapters, and deliver to all adapters.
559 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssSvTypeConfigEvent(config));
560 }
561
geofenceBreach(size_t count,uint32_t * hwIds,Location & location,GeofenceBreachType breachType,uint64_t timestamp)562 void LocApiBase::geofenceBreach(size_t count, uint32_t* hwIds, Location& location,
563 GeofenceBreachType breachType, uint64_t timestamp)
564 {
565 TO_ALL_LOCADAPTERS(mLocAdapters[i]->geofenceBreachEvent(count, hwIds, location, breachType,
566 timestamp));
567 }
568
geofenceStatus(GeofenceStatusAvailable available)569 void LocApiBase::geofenceStatus(GeofenceStatusAvailable available)
570 {
571 TO_ALL_LOCADAPTERS(mLocAdapters[i]->geofenceStatusEvent(available));
572 }
573
reportDBTPosition(UlpLocation & location,GpsLocationExtended & locationExtended,enum loc_sess_status status,LocPosTechMask loc_technology_mask)574 void LocApiBase::reportDBTPosition(UlpLocation &location, GpsLocationExtended &locationExtended,
575 enum loc_sess_status status, LocPosTechMask loc_technology_mask)
576 {
577 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportPositionEvent(location, locationExtended, status,
578 loc_technology_mask));
579 }
580
reportLocations(Location * locations,size_t count,BatchingMode batchingMode)581 void LocApiBase::reportLocations(Location* locations, size_t count, BatchingMode batchingMode)
582 {
583 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportLocationsEvent(locations, count, batchingMode));
584 }
585
reportCompletedTrips(uint32_t accumulated_distance)586 void LocApiBase::reportCompletedTrips(uint32_t accumulated_distance)
587 {
588 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportCompletedTripsEvent(accumulated_distance));
589 }
590
handleBatchStatusEvent(BatchingStatus batchStatus)591 void LocApiBase::handleBatchStatusEvent(BatchingStatus batchStatus)
592 {
593 TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportBatchStatusChangeEvent(batchStatus));
594 }
595
596
597 enum loc_api_adapter_err LocApiBase::
598 open(LOC_API_ADAPTER_EVENT_MASK_T /*mask*/)
599 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
600
601 enum loc_api_adapter_err LocApiBase::
602 close()
603 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
604
605 void LocApiBase::startFix(const LocPosMode& /*posMode*/, LocApiResponse* /*adapterResponse*/)
606 DEFAULT_IMPL()
607
608 void LocApiBase::stopFix(LocApiResponse* /*adapterResponse*/)
609 DEFAULT_IMPL()
610
611 void LocApiBase::
612 deleteAidingData(const GnssAidingData& /*data*/, LocApiResponse* /*adapterResponse*/)
613 DEFAULT_IMPL()
614
615 void LocApiBase::
616 injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/)
617 DEFAULT_IMPL()
618
619 void LocApiBase::
620 injectPosition(const Location& /*location*/, bool /*onDemandCpi*/)
621 DEFAULT_IMPL()
622
623 void LocApiBase::
624 injectPosition(const GnssLocationInfoNotification & /*locationInfo*/, bool /*onDemandCpi*/)
625 DEFAULT_IMPL()
626
627 void LocApiBase::
628 setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/)
629 DEFAULT_IMPL()
630
631 enum loc_api_adapter_err LocApiBase::
632 setXtraData(char* /*data*/, int /*length*/)
633 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
634
635 void LocApiBase::
636 atlOpenStatus(int /*handle*/, int /*is_succ*/, char* /*apn*/, uint32_t /*apnLen*/,
637 AGpsBearerType /*bear*/, LocAGpsType /*agpsType*/,
638 LocApnTypeMask /*mask*/)
639 DEFAULT_IMPL()
640
641 void LocApiBase::
642 atlCloseStatus(int /*handle*/, int /*is_succ*/)
643 DEFAULT_IMPL()
644
645 LocationError LocApiBase::
646 setServerSync(const char* /*url*/, int /*len*/, LocServerType /*type*/)
647 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
648
649 LocationError LocApiBase::
650 setServerSync(unsigned int /*ip*/, int /*port*/, LocServerType /*type*/)
651 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
652
653 void LocApiBase::
654 informNiResponse(GnssNiResponse /*userResponse*/, const void* /*passThroughData*/)
655 DEFAULT_IMPL()
656
657 LocationError LocApiBase::
658 setSUPLVersionSync(GnssConfigSuplVersion /*version*/)
659 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
660
661 enum loc_api_adapter_err LocApiBase::
662 setNMEATypesSync (uint32_t /*typesMask*/)
663 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
664
665 LocationError LocApiBase::
666 setLPPConfigSync(GnssConfigLppProfile /*profile*/)
667 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
668
669
670 enum loc_api_adapter_err LocApiBase::
671 setSensorPropertiesSync(bool /*gyroBiasVarianceRandomWalk_valid*/,
672 float /*gyroBiasVarianceRandomWalk*/,
673 bool /*accelBiasVarianceRandomWalk_valid*/,
674 float /*accelBiasVarianceRandomWalk*/,
675 bool /*angleBiasVarianceRandomWalk_valid*/,
676 float /*angleBiasVarianceRandomWalk*/,
677 bool /*rateBiasVarianceRandomWalk_valid*/,
678 float /*rateBiasVarianceRandomWalk*/,
679 bool /*velocityBiasVarianceRandomWalk_valid*/,
680 float /*velocityBiasVarianceRandomWalk*/)
681 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
682
683 enum loc_api_adapter_err LocApiBase::
684 setSensorPerfControlConfigSync(int /*controlMode*/,
685 int /*accelSamplesPerBatch*/,
686 int /*accelBatchesPerSec*/,
687 int /*gyroSamplesPerBatch*/,
688 int /*gyroBatchesPerSec*/,
689 int /*accelSamplesPerBatchHigh*/,
690 int /*accelBatchesPerSecHigh*/,
691 int /*gyroSamplesPerBatchHigh*/,
692 int /*gyroBatchesPerSecHigh*/,
693 int /*algorithmConfig*/)
694 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
695
696 LocationError LocApiBase::
697 setAGLONASSProtocolSync(GnssConfigAGlonassPositionProtocolMask /*aGlonassProtocol*/)
698 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
699
700 LocationError LocApiBase::
701 setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask /*lppeCP*/)
702 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
703
704 LocationError LocApiBase::
705 setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask /*lppeUP*/)
706 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
707
708 GnssConfigSuplVersion LocApiBase::convertSuplVersion(const uint32_t /*suplVersion*/)
709 DEFAULT_IMPL(GNSS_CONFIG_SUPL_VERSION_1_0_0)
710
711 GnssConfigLppProfile LocApiBase::convertLppProfile(const uint32_t /*lppProfile*/)
712 DEFAULT_IMPL(GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE)
713
714 GnssConfigLppeControlPlaneMask LocApiBase::convertLppeCp(const uint32_t /*lppeControlPlaneMask*/)
715 DEFAULT_IMPL(0)
716
717 GnssConfigLppeUserPlaneMask LocApiBase::convertLppeUp(const uint32_t /*lppeUserPlaneMask*/)
718 DEFAULT_IMPL(0)
719
720 LocationError LocApiBase::setEmergencyExtensionWindowSync(
721 const uint32_t /*emergencyExtensionSeconds*/)
722 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
723
724 void LocApiBase::
725 getWwanZppFix()
726 DEFAULT_IMPL()
727
728 void LocApiBase::
729 getBestAvailableZppFix()
730 DEFAULT_IMPL()
731
732 LocationError LocApiBase::
733 setGpsLockSync(GnssConfigGpsLock /*lock*/)
734 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
735
736 void LocApiBase::
737 requestForAidingData(GnssAidingDataSvMask /*svDataMask*/)
738 DEFAULT_IMPL()
739
740 void LocApiBase::
741 installAGpsCert(const LocDerEncodedCertificate* /*pData*/,
742 size_t /*length*/,
743 uint32_t /*slotBitMask*/)
744 DEFAULT_IMPL()
745
746 LocationError LocApiBase::
747 setXtraVersionCheckSync(uint32_t /*check*/)
748 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
749
750 LocationError LocApiBase::setBlacklistSvSync(const GnssSvIdConfig& /*config*/)
751 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
752
753 void LocApiBase::setBlacklistSv(const GnssSvIdConfig& /*config*/)
754 DEFAULT_IMPL()
755
756 void LocApiBase::getBlacklistSv()
757 DEFAULT_IMPL()
758
759 void LocApiBase::setConstellationControl(const GnssSvTypeConfig& /*config*/,
760 LocApiResponse* /*adapterResponse*/)
761 DEFAULT_IMPL()
762
763 void LocApiBase::getConstellationControl()
764 DEFAULT_IMPL()
765
766 void LocApiBase::resetConstellationControl(LocApiResponse* /*adapterResponse*/)
767 DEFAULT_IMPL()
768
769 void LocApiBase::
770 setConstrainedTuncMode(bool /*enabled*/,
771 float /*tuncConstraint*/,
772 uint32_t /*energyBudget*/,
773 LocApiResponse* /*adapterResponse*/)
774 DEFAULT_IMPL()
775
776 void LocApiBase::
777 setPositionAssistedClockEstimatorMode(bool /*enabled*/,
778 LocApiResponse* /*adapterResponse*/)
779 DEFAULT_IMPL()
780
781 LocationError LocApiBase::getGnssEnergyConsumed()
782 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
783
784
785 void LocApiBase::addGeofence(uint32_t /*clientId*/, const GeofenceOption& /*options*/,
786 const GeofenceInfo& /*info*/,
787 LocApiResponseData<LocApiGeofenceData>* /*adapterResponseData*/)
788 DEFAULT_IMPL()
789
790 void LocApiBase::removeGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
791 LocApiResponse* /*adapterResponse*/)
792 DEFAULT_IMPL()
793
794 void LocApiBase::pauseGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
795 LocApiResponse* /*adapterResponse*/)
796 DEFAULT_IMPL()
797
798 void LocApiBase::resumeGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
799 LocApiResponse* /*adapterResponse*/)
800 DEFAULT_IMPL()
801
802 void LocApiBase::modifyGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
803 const GeofenceOption& /*options*/, LocApiResponse* /*adapterResponse*/)
804 DEFAULT_IMPL()
805
806 void LocApiBase::startTimeBasedTracking(const TrackingOptions& /*options*/,
807 LocApiResponse* /*adapterResponse*/)
808 DEFAULT_IMPL()
809
810 void LocApiBase::stopTimeBasedTracking(LocApiResponse* /*adapterResponse*/)
811 DEFAULT_IMPL()
812
813 void LocApiBase::startDistanceBasedTracking(uint32_t /*sessionId*/,
814 const LocationOptions& /*options*/, LocApiResponse* /*adapterResponse*/)
815 DEFAULT_IMPL()
816
817 void LocApiBase::stopDistanceBasedTracking(uint32_t /*sessionId*/,
818 LocApiResponse* /*adapterResponse*/)
819 DEFAULT_IMPL()
820
821 void LocApiBase::startBatching(uint32_t /*sessionId*/, const LocationOptions& /*options*/,
822 uint32_t /*accuracy*/, uint32_t /*timeout*/, LocApiResponse* /*adapterResponse*/)
823 DEFAULT_IMPL()
824
825 void LocApiBase::stopBatching(uint32_t /*sessionId*/, LocApiResponse* /*adapterResponse*/)
826 DEFAULT_IMPL()
827
828 LocationError LocApiBase::startOutdoorTripBatchingSync(uint32_t /*tripDistance*/,
829 uint32_t /*tripTbf*/, uint32_t /*timeout*/)
830 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
831
832 void LocApiBase::startOutdoorTripBatching(uint32_t /*tripDistance*/, uint32_t /*tripTbf*/,
833 uint32_t /*timeout*/, LocApiResponse* /*adapterResponse*/)
834 DEFAULT_IMPL()
835
836 void LocApiBase::reStartOutdoorTripBatching(uint32_t /*ongoingTripDistance*/,
837 uint32_t /*ongoingTripInterval*/, uint32_t /*batchingTimeout,*/,
838 LocApiResponse* /*adapterResponse*/)
839 DEFAULT_IMPL()
840
841 LocationError LocApiBase::stopOutdoorTripBatchingSync(bool /*deallocBatchBuffer*/)
842 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
843
844 void LocApiBase::stopOutdoorTripBatching(bool /*deallocBatchBuffer*/,
845 LocApiResponse* /*adapterResponse*/)
846 DEFAULT_IMPL()
847
848 LocationError LocApiBase::getBatchedLocationsSync(size_t /*count*/)
849 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
850
851 void LocApiBase::getBatchedLocations(size_t /*count*/, LocApiResponse* /*adapterResponse*/)
852 DEFAULT_IMPL()
853
854 LocationError LocApiBase::getBatchedTripLocationsSync(size_t /*count*/,
855 uint32_t /*accumulatedDistance*/)
856 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
857
858 void LocApiBase::getBatchedTripLocations(size_t /*count*/, uint32_t /*accumulatedDistance*/,
859 LocApiResponse* /*adapterResponse*/)
860 DEFAULT_IMPL()
861
862 LocationError LocApiBase::queryAccumulatedTripDistanceSync(uint32_t& /*accumulated_trip_distance*/,
863 uint32_t& /*numOfBatchedPositions*/)
864 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
865
866 void LocApiBase::queryAccumulatedTripDistance(
867 LocApiResponseData<LocApiBatchData>* /*adapterResponseData*/)
868 DEFAULT_IMPL()
869
870 void LocApiBase::setBatchSize(size_t /*size*/)
871 DEFAULT_IMPL()
872
873 void LocApiBase::setTripBatchSize(size_t /*size*/)
874 DEFAULT_IMPL()
875
876 void LocApiBase::addToCallQueue(LocApiResponse* /*adapterResponse*/)
877 DEFAULT_IMPL()
878
879 void LocApiBase::updateSystemPowerState(PowerStateType /*powerState*/)
880 DEFAULT_IMPL()
881
882 } // namespace loc_core
883