• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2011-2014, 2016-2020 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 "/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              locationExtended.gnss_sv_used_ids.navic_sv_used_ids_mask);
345     // loop through adapters, and deliver to all adapters.
346     TO_ALL_LOCADAPTERS(
347         mLocAdapters[i]->reportPositionEvent(location, locationExtended,
348                                              status, loc_technology_mask,
349                                              pDataNotify, msInWeek)
350     );
351 }
352 
reportWwanZppFix(LocGpsLocation & zppLoc)353 void LocApiBase::reportWwanZppFix(LocGpsLocation &zppLoc)
354 {
355     // loop through adapters, and deliver to the first handling adapter.
356     TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportWwanZppFix(zppLoc));
357 }
358 
reportZppBestAvailableFix(LocGpsLocation & zppLoc,GpsLocationExtended & location_extended,LocPosTechMask tech_mask)359 void LocApiBase::reportZppBestAvailableFix(LocGpsLocation &zppLoc,
360         GpsLocationExtended &location_extended, LocPosTechMask tech_mask)
361 {
362     // loop through adapters, and deliver to the first handling adapter.
363     TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportZppBestAvailableFix(zppLoc,
364             location_extended, tech_mask));
365 }
366 
requestOdcpi(OdcpiRequestInfo & request)367 void LocApiBase::requestOdcpi(OdcpiRequestInfo& request)
368 {
369     // loop through adapters, and deliver to the first handling adapter.
370     TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestOdcpiEvent(request));
371 }
372 
reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot)373 void LocApiBase::reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot)
374 {
375     // loop through adapters, and deliver to the first handling adapter.
376     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssEngEnergyConsumedEvent(
377             energyConsumedSinceFirstBoot));
378 }
379 
reportDeleteAidingDataEvent(GnssAidingData & aidingData)380 void LocApiBase::reportDeleteAidingDataEvent(GnssAidingData& aidingData) {
381     // loop through adapters, and deliver to the first handling adapter.
382     TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDeleteAidingDataEvent(aidingData));
383 }
384 
reportKlobucharIonoModel(GnssKlobucharIonoModel & ionoModel)385 void LocApiBase::reportKlobucharIonoModel(GnssKlobucharIonoModel & ionoModel) {
386     // loop through adapters, and deliver to the first handling adapter.
387     TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportKlobucharIonoModelEvent(ionoModel));
388 }
389 
reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo & additionalSystemInfo)390 void LocApiBase::reportGnssAdditionalSystemInfo(GnssAdditionalSystemInfo& additionalSystemInfo) {
391     // loop through adapters, and deliver to the first handling adapter.
392     TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportGnssAdditionalSystemInfoEvent(
393             additionalSystemInfo));
394 }
395 
sendNfwNotification(GnssNfwNotification & notification)396 void LocApiBase::sendNfwNotification(GnssNfwNotification& notification)
397 {
398     // loop through adapters, and deliver to the first handling adapter.
399     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNfwNotificationEvent(notification));
400 
401 }
402 
reportSv(GnssSvNotification & svNotify)403 void LocApiBase::reportSv(GnssSvNotification& svNotify)
404 {
405     const char* constellationString[] = { "Unknown", "GPS", "SBAS", "GLONASS",
406         "QZSS", "BEIDOU", "GALILEO", "NAVIC" };
407 
408     // print the SV info before delivering
409     LOC_LOGV("num sv: %u\n"
410         "      sv: constellation svid         cN0  basebandCN0"
411         "    elevation    azimuth    flags",
412         svNotify.count);
413     for (size_t i = 0; i < svNotify.count && i < GNSS_SV_MAX; i++) {
414         if (svNotify.gnssSvs[i].type >
415             sizeof(constellationString) / sizeof(constellationString[0]) - 1) {
416             svNotify.gnssSvs[i].type = GNSS_SV_TYPE_UNKNOWN;
417         }
418         // Display what we report to clients
419         LOC_LOGV("   %03zu: %*s  %02d    %f    %f    %f    %f    %f    0x%02X 0x%2X",
420             i,
421             13,
422             constellationString[svNotify.gnssSvs[i].type],
423             svNotify.gnssSvs[i].svId,
424             svNotify.gnssSvs[i].cN0Dbhz,
425             svNotify.gnssSvs[i].basebandCarrierToNoiseDbHz,
426             svNotify.gnssSvs[i].elevation,
427             svNotify.gnssSvs[i].azimuth,
428             svNotify.gnssSvs[i].carrierFrequencyHz,
429             svNotify.gnssSvs[i].gnssSvOptionsMask,
430             svNotify.gnssSvs[i].gnssSignalTypeMask);
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 &notify, 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 ",\n"
545               "navicBlacklistSvMask: %" PRIu64,
546              config.gloBlacklistSvMask, config.bdsBlacklistSvMask,
547              config.qzssBlacklistSvMask, config.galBlacklistSvMask, config.navicBlacklistSvMask);
548 
549     // Loop through adapters, and deliver to all adapters.
550     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssSvIdConfigEvent(config));
551 }
552 
reportGnssSvTypeConfig(const GnssSvTypeConfig & config)553 void LocApiBase::reportGnssSvTypeConfig(const GnssSvTypeConfig& config)
554 {
555     // Print the config
556     LOC_LOGv("blacklistedMask: %" PRIu64 ", enabledMask: %" PRIu64,
557              config.blacklistedSvTypesMask, config.enabledSvTypesMask);
558 
559     // Loop through adapters, and deliver to all adapters.
560     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssSvTypeConfigEvent(config));
561 }
562 
geofenceBreach(size_t count,uint32_t * hwIds,Location & location,GeofenceBreachType breachType,uint64_t timestamp)563 void LocApiBase::geofenceBreach(size_t count, uint32_t* hwIds, Location& location,
564                                 GeofenceBreachType breachType, uint64_t timestamp)
565 {
566     TO_ALL_LOCADAPTERS(mLocAdapters[i]->geofenceBreachEvent(count, hwIds, location, breachType,
567                                                             timestamp));
568 }
569 
geofenceStatus(GeofenceStatusAvailable available)570 void LocApiBase::geofenceStatus(GeofenceStatusAvailable available)
571 {
572     TO_ALL_LOCADAPTERS(mLocAdapters[i]->geofenceStatusEvent(available));
573 }
574 
reportDBTPosition(UlpLocation & location,GpsLocationExtended & locationExtended,enum loc_sess_status status,LocPosTechMask loc_technology_mask)575 void LocApiBase::reportDBTPosition(UlpLocation &location, GpsLocationExtended &locationExtended,
576                                    enum loc_sess_status status, LocPosTechMask loc_technology_mask)
577 {
578     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportPositionEvent(location, locationExtended, status,
579                                                             loc_technology_mask));
580 }
581 
reportLocations(Location * locations,size_t count,BatchingMode batchingMode)582 void LocApiBase::reportLocations(Location* locations, size_t count, BatchingMode batchingMode)
583 {
584     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportLocationsEvent(locations, count, batchingMode));
585 }
586 
reportCompletedTrips(uint32_t accumulated_distance)587 void LocApiBase::reportCompletedTrips(uint32_t accumulated_distance)
588 {
589     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportCompletedTripsEvent(accumulated_distance));
590 }
591 
handleBatchStatusEvent(BatchingStatus batchStatus)592 void LocApiBase::handleBatchStatusEvent(BatchingStatus batchStatus)
593 {
594     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportBatchStatusChangeEvent(batchStatus));
595 }
596 
reportGnssConfig(uint32_t sessionId,const GnssConfig & gnssConfig)597 void LocApiBase::reportGnssConfig(uint32_t sessionId, const GnssConfig& gnssConfig)
598 {
599     // loop through adapters, and deliver to the first handling adapter.
600     TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssConfigEvent(sessionId, gnssConfig));
601 }
602 
603 enum loc_api_adapter_err LocApiBase::
604    open(LOC_API_ADAPTER_EVENT_MASK_T /*mask*/)
605 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
606 
607 enum loc_api_adapter_err LocApiBase::
608     close()
609 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
610 
611 void LocApiBase::startFix(const LocPosMode& /*posMode*/, LocApiResponse* /*adapterResponse*/)
612 DEFAULT_IMPL()
613 
614 void LocApiBase::stopFix(LocApiResponse* /*adapterResponse*/)
615 DEFAULT_IMPL()
616 
617 void LocApiBase::
618     deleteAidingData(const GnssAidingData& /*data*/, LocApiResponse* /*adapterResponse*/)
619 DEFAULT_IMPL()
620 
621 void LocApiBase::
622     injectPosition(double /*latitude*/, double /*longitude*/, float /*accuracy*/)
623 DEFAULT_IMPL()
624 
625 void LocApiBase::
626     injectPosition(const Location& /*location*/, bool /*onDemandCpi*/)
627 DEFAULT_IMPL()
628 
629 void LocApiBase::
630     injectPosition(const GnssLocationInfoNotification & /*locationInfo*/, bool /*onDemandCpi*/)
631 DEFAULT_IMPL()
632 
633 void LocApiBase::
634     setTime(LocGpsUtcTime /*time*/, int64_t /*timeReference*/, int /*uncertainty*/)
635 DEFAULT_IMPL()
636 
637 enum loc_api_adapter_err LocApiBase::
638     setXtraData(char* /*data*/, int /*length*/)
639 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
640 
641 void LocApiBase::
642    atlOpenStatus(int /*handle*/, int /*is_succ*/, char* /*apn*/, uint32_t /*apnLen*/,
643                  AGpsBearerType /*bear*/, LocAGpsType /*agpsType*/,
644                  LocApnTypeMask /*mask*/)
645 DEFAULT_IMPL()
646 
647 void LocApiBase::
648     atlCloseStatus(int /*handle*/, int /*is_succ*/)
649 DEFAULT_IMPL()
650 
651 LocationError LocApiBase::
652     setServerSync(const char* /*url*/, int /*len*/, LocServerType /*type*/)
653 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
654 
655 LocationError LocApiBase::
656     setServerSync(unsigned int /*ip*/, int /*port*/, LocServerType /*type*/)
657 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
658 
659 void LocApiBase::
660     informNiResponse(GnssNiResponse /*userResponse*/, const void* /*passThroughData*/)
661 DEFAULT_IMPL()
662 
663 LocationError LocApiBase::
664     setSUPLVersionSync(GnssConfigSuplVersion /*version*/)
665 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
666 
667 enum loc_api_adapter_err LocApiBase::
668     setNMEATypesSync (uint32_t /*typesMask*/)
669 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
670 
671 LocationError LocApiBase::
672     setLPPConfigSync(GnssConfigLppProfile /*profile*/)
673 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
674 
675 
676 enum loc_api_adapter_err LocApiBase::
677     setSensorPropertiesSync(bool /*gyroBiasVarianceRandomWalk_valid*/,
678                         float /*gyroBiasVarianceRandomWalk*/,
679                         bool /*accelBiasVarianceRandomWalk_valid*/,
680                         float /*accelBiasVarianceRandomWalk*/,
681                         bool /*angleBiasVarianceRandomWalk_valid*/,
682                         float /*angleBiasVarianceRandomWalk*/,
683                         bool /*rateBiasVarianceRandomWalk_valid*/,
684                         float /*rateBiasVarianceRandomWalk*/,
685                         bool /*velocityBiasVarianceRandomWalk_valid*/,
686                         float /*velocityBiasVarianceRandomWalk*/)
687 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
688 
689 enum loc_api_adapter_err LocApiBase::
690     setSensorPerfControlConfigSync(int /*controlMode*/,
691                                int /*accelSamplesPerBatch*/,
692                                int /*accelBatchesPerSec*/,
693                                int /*gyroSamplesPerBatch*/,
694                                int /*gyroBatchesPerSec*/,
695                                int /*accelSamplesPerBatchHigh*/,
696                                int /*accelBatchesPerSecHigh*/,
697                                int /*gyroSamplesPerBatchHigh*/,
698                                int /*gyroBatchesPerSecHigh*/,
699                                int /*algorithmConfig*/)
700 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
701 
702 LocationError LocApiBase::
703     setAGLONASSProtocolSync(GnssConfigAGlonassPositionProtocolMask /*aGlonassProtocol*/)
704 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
705 
706 LocationError LocApiBase::
707     setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask /*lppeCP*/)
708 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
709 
710 LocationError LocApiBase::
711     setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask /*lppeUP*/)
712 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
713 
714 GnssConfigSuplVersion LocApiBase::convertSuplVersion(const uint32_t /*suplVersion*/)
715 DEFAULT_IMPL(GNSS_CONFIG_SUPL_VERSION_1_0_0)
716 
717 GnssConfigLppProfile LocApiBase::convertLppProfile(const uint32_t /*lppProfile*/)
718 DEFAULT_IMPL(GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE)
719 
720 GnssConfigLppeControlPlaneMask LocApiBase::convertLppeCp(const uint32_t /*lppeControlPlaneMask*/)
721 DEFAULT_IMPL(0)
722 
723 GnssConfigLppeUserPlaneMask LocApiBase::convertLppeUp(const uint32_t /*lppeUserPlaneMask*/)
724 DEFAULT_IMPL(0)
725 
726 LocationError LocApiBase::setEmergencyExtensionWindowSync(
727         const uint32_t /*emergencyExtensionSeconds*/)
728 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
729 
730 LocationError LocApiBase::setMeasurementCorrections(
731         const GnssMeasurementCorrections /*gnssMeasurementCorrections*/)
732 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
733 
734 void LocApiBase::
735    getWwanZppFix()
736 DEFAULT_IMPL()
737 
738 void LocApiBase::
739    getBestAvailableZppFix()
740 DEFAULT_IMPL()
741 
742 LocationError LocApiBase::
743     setGpsLockSync(GnssConfigGpsLock /*lock*/)
744 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
745 
746 void LocApiBase::
747     requestForAidingData(GnssAidingDataSvMask /*svDataMask*/)
748 DEFAULT_IMPL()
749 
750 void LocApiBase::
751     installAGpsCert(const LocDerEncodedCertificate* /*pData*/,
752                     size_t /*length*/,
753                     uint32_t /*slotBitMask*/)
754 DEFAULT_IMPL()
755 
756 LocationError LocApiBase::
757     setXtraVersionCheckSync(uint32_t /*check*/)
758 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
759 
760 LocationError LocApiBase::setBlacklistSvSync(const GnssSvIdConfig& /*config*/)
761 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
762 
763 void LocApiBase::setBlacklistSv(const GnssSvIdConfig& /*config*/)
764 DEFAULT_IMPL()
765 
766 void LocApiBase::getBlacklistSv()
767 DEFAULT_IMPL()
768 
769 void LocApiBase::setConstellationControl(const GnssSvTypeConfig& /*config*/,
770                                          LocApiResponse* /*adapterResponse*/)
771 DEFAULT_IMPL()
772 
773 void LocApiBase::getConstellationControl()
774 DEFAULT_IMPL()
775 
776 void LocApiBase::resetConstellationControl(LocApiResponse* /*adapterResponse*/)
777 DEFAULT_IMPL()
778 
779 void LocApiBase::
780     setConstrainedTuncMode(bool /*enabled*/,
781                            float /*tuncConstraint*/,
782                            uint32_t /*energyBudget*/,
783                            LocApiResponse* /*adapterResponse*/)
784 DEFAULT_IMPL()
785 
786 void LocApiBase::
787     setPositionAssistedClockEstimatorMode(bool /*enabled*/,
788                                           LocApiResponse* /*adapterResponse*/)
789 DEFAULT_IMPL()
790 
791 LocationError LocApiBase::getGnssEnergyConsumed()
792 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
793 
794 
795 void LocApiBase::addGeofence(uint32_t /*clientId*/, const GeofenceOption& /*options*/,
796         const GeofenceInfo& /*info*/,
797         LocApiResponseData<LocApiGeofenceData>* /*adapterResponseData*/)
798 DEFAULT_IMPL()
799 
800 void LocApiBase::removeGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
801         LocApiResponse* /*adapterResponse*/)
802 DEFAULT_IMPL()
803 
804 void LocApiBase::pauseGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
805         LocApiResponse* /*adapterResponse*/)
806 DEFAULT_IMPL()
807 
808 void LocApiBase::resumeGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
809         LocApiResponse* /*adapterResponse*/)
810 DEFAULT_IMPL()
811 
812 void LocApiBase::modifyGeofence(uint32_t /*hwId*/, uint32_t /*clientId*/,
813          const GeofenceOption& /*options*/, LocApiResponse* /*adapterResponse*/)
814 DEFAULT_IMPL()
815 
816 void LocApiBase::startTimeBasedTracking(const TrackingOptions& /*options*/,
817         LocApiResponse* /*adapterResponse*/)
818 DEFAULT_IMPL()
819 
820 void LocApiBase::stopTimeBasedTracking(LocApiResponse* /*adapterResponse*/)
821 DEFAULT_IMPL()
822 
823 void LocApiBase::startDistanceBasedTracking(uint32_t /*sessionId*/,
824         const LocationOptions& /*options*/, LocApiResponse* /*adapterResponse*/)
825 DEFAULT_IMPL()
826 
827 void LocApiBase::stopDistanceBasedTracking(uint32_t /*sessionId*/,
828         LocApiResponse* /*adapterResponse*/)
829 DEFAULT_IMPL()
830 
831 void LocApiBase::startBatching(uint32_t /*sessionId*/, const LocationOptions& /*options*/,
832         uint32_t /*accuracy*/, uint32_t /*timeout*/, LocApiResponse* /*adapterResponse*/)
833 DEFAULT_IMPL()
834 
835 void LocApiBase::stopBatching(uint32_t /*sessionId*/, LocApiResponse* /*adapterResponse*/)
836 DEFAULT_IMPL()
837 
838 LocationError LocApiBase::startOutdoorTripBatchingSync(uint32_t /*tripDistance*/,
839         uint32_t /*tripTbf*/, uint32_t /*timeout*/)
840 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
841 
842 void LocApiBase::startOutdoorTripBatching(uint32_t /*tripDistance*/, uint32_t /*tripTbf*/,
843         uint32_t /*timeout*/, LocApiResponse* /*adapterResponse*/)
844 DEFAULT_IMPL()
845 
846 void LocApiBase::reStartOutdoorTripBatching(uint32_t /*ongoingTripDistance*/,
847         uint32_t /*ongoingTripInterval*/, uint32_t /*batchingTimeout,*/,
848         LocApiResponse* /*adapterResponse*/)
849 DEFAULT_IMPL()
850 
851 LocationError LocApiBase::stopOutdoorTripBatchingSync(bool /*deallocBatchBuffer*/)
852 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
853 
854 void LocApiBase::stopOutdoorTripBatching(bool /*deallocBatchBuffer*/,
855         LocApiResponse* /*adapterResponse*/)
856 DEFAULT_IMPL()
857 
858 LocationError LocApiBase::getBatchedLocationsSync(size_t /*count*/)
859 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
860 
861 void LocApiBase::getBatchedLocations(size_t /*count*/, LocApiResponse* /*adapterResponse*/)
862 DEFAULT_IMPL()
863 
864 LocationError LocApiBase::getBatchedTripLocationsSync(size_t /*count*/,
865         uint32_t /*accumulatedDistance*/)
866 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
867 
868 void LocApiBase::getBatchedTripLocations(size_t /*count*/, uint32_t /*accumulatedDistance*/,
869         LocApiResponse* /*adapterResponse*/)
870 DEFAULT_IMPL()
871 
872 LocationError LocApiBase::queryAccumulatedTripDistanceSync(uint32_t& /*accumulated_trip_distance*/,
873         uint32_t& /*numOfBatchedPositions*/)
874 DEFAULT_IMPL(LOCATION_ERROR_SUCCESS)
875 
876 void LocApiBase::queryAccumulatedTripDistance(
877         LocApiResponseData<LocApiBatchData>* /*adapterResponseData*/)
878 DEFAULT_IMPL()
879 
880 void LocApiBase::setBatchSize(size_t /*size*/)
881 DEFAULT_IMPL()
882 
883 void LocApiBase::setTripBatchSize(size_t /*size*/)
884 DEFAULT_IMPL()
885 
886 void LocApiBase::addToCallQueue(LocApiResponse* /*adapterResponse*/)
887 DEFAULT_IMPL()
888 
889 void LocApiBase::updateSystemPowerState(PowerStateType /*powerState*/)
890 DEFAULT_IMPL()
891 
892 void LocApiBase::
893     configRobustLocation(bool /*enabled*/,
894                          bool /*enableForE911*/,
895                          LocApiResponse* /*adapterResponse*/)
896 DEFAULT_IMPL()
897 
898 void LocApiBase::
899     getRobustLocationConfig(uint32_t sessionId, LocApiResponse* /*adapterResponse*/)
900 DEFAULT_IMPL()
901 
902 void LocApiBase::
903     configMinGpsWeek(uint16_t minGpsWeek,
904                      LocApiResponse* /*adapterResponse*/)
905 DEFAULT_IMPL()
906 
907 void LocApiBase::
908     getMinGpsWeek(uint32_t sessionId, LocApiResponse* /*adapterResponse*/)
909 DEFAULT_IMPL()
910 
911 } // namespace loc_core
912