• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2017-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 #ifndef GNSS_ADAPTER_H
30 #define GNSS_ADAPTER_H
31 
32 #include <LocAdapterBase.h>
33 #include <LocContext.h>
34 #include <IOsObserver.h>
35 #include <EngineHubProxyBase.h>
36 #include <LocationAPI.h>
37 #include <Agps.h>
38 #include <SystemStatus.h>
39 #include <XtraSystemStatusObserver.h>
40 #include <map>
41 
42 #define MAX_URL_LEN 256
43 #define NMEA_SENTENCE_MAX_LENGTH 200
44 #define GLONASS_SV_ID_OFFSET 64
45 #define MAX_SATELLITES_IN_USE 12
46 #define LOC_NI_NO_RESPONSE_TIME 20
47 #define LOC_GPS_NI_RESPONSE_IGNORE 4
48 #define ODCPI_EXPECTED_INJECTION_TIME_MS 10000
49 
50 class GnssAdapter;
51 
52 typedef std::map<LocationSessionKey, LocationOptions> LocationSessionMap;
53 typedef std::map<LocationSessionKey, TrackingOptions> TrackingOptionsMap;
54 
55 class OdcpiTimer : public LocTimer {
56 public:
OdcpiTimer(GnssAdapter * adapter)57     OdcpiTimer(GnssAdapter* adapter) :
58             LocTimer(), mAdapter(adapter), mActive(false) {}
59 
start()60     inline void start() {
61         mActive = true;
62         LocTimer::start(ODCPI_EXPECTED_INJECTION_TIME_MS, false);
63     }
stop()64     inline void stop() {
65         mActive = false;
66         LocTimer::stop();
67     }
restart()68     inline void restart() {
69         stop();
70         start();
71     }
isActive()72     inline bool isActive() {
73         return mActive;
74     }
75 
76 private:
77     // Override
78     virtual void timeOutCallback() override;
79 
80     GnssAdapter* mAdapter;
81     bool mActive;
82 };
83 
84 typedef struct {
85     pthread_t               thread;        /* NI thread */
86     uint32_t                respTimeLeft;  /* examine time for NI response */
87     bool                    respRecvd;     /* NI User reponse received or not from Java layer*/
88     void*                   rawRequest;
89     uint32_t                reqID;         /* ID to check against response */
90     GnssNiResponse          resp;
91     pthread_cond_t          tCond;
92     pthread_mutex_t         tLock;
93     GnssAdapter*            adapter;
94 } NiSession;
95 typedef struct {
96     NiSession session;    /* SUPL NI Session */
97     NiSession sessionEs;  /* Emergency SUPL NI Session */
98     uint32_t reqIDCounter;
99 } NiData;
100 
101 typedef enum {
102     NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA
103     NMEA_PROVIDER_MP      // Modem Processor Provider of NMEA
104 } NmeaProviderType;
105 typedef struct {
106     GnssSvType svType;
107     const char* talker;
108     uint64_t mask;
109     uint32_t svIdOffset;
110 } NmeaSvMeta;
111 
112 typedef struct {
113     double latitude;
114     double longitude;
115     float  accuracy;
116     // the CPI will be blocked until the boot time
117     // specified in blockedTillTsMs
118     int64_t blockedTillTsMs;
119     // CPIs whose both latitude and longitude differ
120     // no more than latLonThreshold will be blocked
121     // in units of degree
122     double latLonDiffThreshold;
123 } BlockCPIInfo;
124 
125 typedef struct {
126     bool isValid;
127     bool enable;
128     float tuncThresholdMs; // need to be specified if enable is true
129     uint32_t energyBudget; // need to be specified if enable is true
130 } TuncConfigInfo;
131 
132 typedef struct {
133     bool isValid;
134     bool enable;
135 } PaceConfigInfo;
136 
137 typedef struct {
138     bool isValid;
139     bool enable;
140     bool enableFor911;
141 } RobustLocationConfigInfo;
142 
143 typedef struct {
144     TuncConfigInfo tuncConfigInfo;
145     PaceConfigInfo paceConfigInfo;
146     RobustLocationConfigInfo robustLocationConfigInfo;
147 } LocIntegrationConfigInfo;
148 
149 using namespace loc_core;
150 
151 namespace loc_core {
152     class SystemStatus;
153 }
154 
155 typedef std::function<void(
156     uint64_t gnssEnergyConsumedFromFirstBoot
157 )> GnssEnergyConsumedCallback;
158 
159 typedef void (*powerStateCallback)(bool on);
160 
161 class GnssAdapter : public LocAdapterBase {
162 
163     /* ==== Engine Hub ===================================================================== */
164     EngineHubProxyBase* mEngHubProxy;
165     bool mNHzNeeded;
166     bool mSPEAlreadyRunningAtHighestInterval;
167 
168     /* ==== TRACKING ======================================================================= */
169     TrackingOptionsMap mTimeBasedTrackingSessions;
170     LocationSessionMap mDistanceBasedTrackingSessions;
171     LocPosMode mLocPositionMode;
172     GnssSvUsedInPosition mGnssSvIdUsedInPosition;
173     bool mGnssSvIdUsedInPosAvail;
174     GnssSvMbUsedInPosition mGnssMbSvIdUsedInPosition;
175     bool mGnssMbSvIdUsedInPosAvail;
176 
177     /* ==== CONTROL ======================================================================== */
178     LocationControlCallbacks mControlCallbacks;
179     uint32_t mAfwControlId;
180     uint32_t mNmeaMask;
181     GnssSvIdConfig mGnssSvIdConfig;
182     GnssSvTypeConfig mGnssSvTypeConfig;
183     GnssSvTypeConfigCallback mGnssSvTypeConfigCb;
184     bool mSupportNfwControl;
185     LocIntegrationConfigInfo mLocConfigInfo;
186 
187     /* ==== NI ============================================================================= */
188     NiData mNiData;
189 
190     /* ==== AGPS =========================================================================== */
191     // This must be initialized via initAgps()
192     AgpsManager mAgpsManager;
193     void initAgps(const AgpsCbInfo& cbInfo);
194 
195     /* ==== NFW =========================================================================== */
196     NfwStatusCb mNfwCb;
197     IsInEmergencySession mIsE911Session;
initNfw(const NfwCbInfo & cbInfo)198     inline void initNfw(const NfwCbInfo& cbInfo) {
199         mNfwCb = (NfwStatusCb)cbInfo.visibilityControlCb;
200         mIsE911Session = (IsInEmergencySession)cbInfo.isInEmergencySession;
201     }
202 
203     /* ==== ODCPI ========================================================================== */
204     OdcpiRequestCallback mOdcpiRequestCb;
205     bool mOdcpiRequestActive;
206     OdcpiTimer mOdcpiTimer;
207     OdcpiRequestInfo mOdcpiRequest;
208     void odcpiTimerExpire();
209 
210     /* === SystemStatus ===================================================================== */
211     SystemStatus* mSystemStatus;
212     std::string mServerUrl;
213     std::string mMoServerUrl;
214     XtraSystemStatusObserver mXtraObserver;
215     LocationSystemInfo mLocSystemInfo;
216     std::vector<GnssSvIdSource> mBlacklistedSvIds;
217     PowerStateType mSystemPowerState;
218 
219     /* === Misc ===================================================================== */
220     BlockCPIInfo mBlockCPIInfo;
221     bool mPowerOn;
222     uint32_t mAllowFlpNetworkFixes;
223 
224     /* === Misc callback from QMI LOC API ============================================== */
225     GnssEnergyConsumedCallback mGnssEnergyConsumedCb;
226     powerStateCallback mPowerStateCb;
227 
228     /*==== CONVERSION ===================================================================*/
229     static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions);
230     static void convertLocation(Location& out, const UlpLocation& ulpLocation,
231                                 const GpsLocationExtended& locationExtended,
232                                 const LocPosTechMask techMask);
233     static void convertLocationInfo(GnssLocationInfoNotification& out,
234                                     const GpsLocationExtended& locationExtended);
235     static uint16_t getNumSvUsed(uint64_t svUsedIdsMask,
236                                  int totalSvCntInThisConstellation);
237 
238     /* ======== UTILITIES ================================================================== */
239     inline void initOdcpi(const OdcpiRequestCallback& callback);
240     inline void injectOdcpi(const Location& location);
241     static bool isFlpClient(LocationCallbacks& locationCallbacks);
242 
243 protected:
244 
245     /* ==== CLIENT ========================================================================= */
246     virtual void updateClientsEventMask();
247     virtual void stopClientSessions(LocationAPI* client);
248 
249 public:
250 
251     GnssAdapter();
~GnssAdapter()252     virtual inline ~GnssAdapter() { }
253 
254     /* ==== SSR ============================================================================ */
255     /* ======== EVENTS ====(Called from QMI Thread)========================================= */
256     virtual void handleEngineUpEvent();
257     /* ======== UTILITIES ================================================================== */
258     void restartSessions(bool modemSSR = false);
259     void checkAndRestartTimeBasedSession();
260     void suspendSessions();
261 
262     /* ==== CLIENT ========================================================================= */
263     /* ======== COMMANDS ====(Called from Client Thread)==================================== */
264     virtual void addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks);
265 
266     /* ==== TRACKING ======================================================================= */
267     /* ======== COMMANDS ====(Called from Client Thread)==================================== */
268     uint32_t startTrackingCommand(
269             LocationAPI* client, TrackingOptions& trackingOptions);
270     void updateTrackingOptionsCommand(
271             LocationAPI* client, uint32_t id, TrackingOptions& trackingOptions);
272     void stopTrackingCommand(LocationAPI* client, uint32_t id);
273     /* ======== RESPONSES ================================================================== */
274     void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId);
275     /* ======== UTILITIES ================================================================== */
276     bool isTimeBasedTrackingSession(LocationAPI* client, uint32_t sessionId);
277     bool isDistanceBasedTrackingSession(LocationAPI* client, uint32_t sessionId);
278     bool hasCallbacksToStartTracking(LocationAPI* client);
279     bool isTrackingSession(LocationAPI* client, uint32_t sessionId);
280     void saveTrackingSession(LocationAPI* client, uint32_t sessionId,
281                              const TrackingOptions& trackingOptions);
282     void eraseTrackingSession(LocationAPI* client, uint32_t sessionId);
283 
284     bool setLocPositionMode(const LocPosMode& mode);
getLocPositionMode()285     LocPosMode& getLocPositionMode() { return mLocPositionMode; }
286 
287     bool startTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t sessionId,
288                                          const TrackingOptions& trackingOptions);
289     void startTimeBasedTracking(LocationAPI* client, uint32_t sessionId,
290             const TrackingOptions& trackingOptions);
291     bool stopTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t id);
292     void stopTracking(LocationAPI* client, uint32_t id);
293     bool updateTrackingMultiplex(LocationAPI* client, uint32_t id,
294             const TrackingOptions& trackingOptions);
295     void updateTracking(LocationAPI* client, uint32_t sessionId,
296             const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions);
297     bool checkAndSetSPEToRunforNHz(TrackingOptions & out);
298 
299     void setConstrainedTunc(bool enable, float tuncConstraint,
300                             uint32_t energyBudget, uint32_t sessionId);
301     void setPositionAssistedClockEstimator(bool enable, uint32_t sessionId);
302     void updateSvConfig(uint32_t sessionId, const GnssSvTypeConfig& svTypeConfig,
303                         const GnssSvIdConfig& svIdConfig);
304     void resetSvConfig(uint32_t sessionId);
305     void configLeverArm(uint32_t sessionId, const LeverArmConfigInfo& configInfo);
306     void configRobustLocation(uint32_t sessionId, bool enable, bool enableForE911);
307 
308     /* ==== NI ============================================================================= */
309     /* ======== COMMANDS ====(Called from Client Thread)==================================== */
310     void gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response);
311     /* ======================(Called from NI Thread)======================================== */
312     void gnssNiResponseCommand(GnssNiResponse response, void* rawRequest);
313     /* ======== UTILITIES ================================================================== */
314     bool hasNiNotifyCallback(LocationAPI* client);
getNiData()315     NiData& getNiData() { return mNiData; }
316 
317     /* ==== CONTROL CLIENT ================================================================= */
318     /* ======== COMMANDS ====(Called from Client Thread)==================================== */
319     uint32_t enableCommand(LocationTechnologyType techType);
320     void disableCommand(uint32_t id);
321     void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks);
322     void readConfigCommand();
323     void requestUlpCommand();
324     void initEngHubProxyCommand();
325     uint32_t* gnssUpdateConfigCommand(GnssConfig config);
326     uint32_t* gnssGetConfigCommand(GnssConfigFlagsMask mask);
327     uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data);
328     void deleteAidingData(const GnssAidingData &data, uint32_t sessionId);
329     void gnssUpdateXtraThrottleCommand(const bool enabled);
330     std::vector<LocationError> gnssUpdateConfig(const std::string& oldMoServerUrl,
331             GnssConfig& gnssConfigRequested,
332             GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0);
333 
334     /* ==== GNSS SV TYPE CONFIG ============================================================ */
335     /* ==== COMMANDS ====(Called from Client Thread)======================================== */
336     /* ==== These commands are received directly from client bypassing Location API ======== */
337     void gnssUpdateSvTypeConfigCommand(GnssSvTypeConfig config);
338     void gnssGetSvTypeConfigCommand(GnssSvTypeConfigCallback callback);
339     void gnssResetSvTypeConfigCommand();
340 
341     /* ==== UTILITIES ====================================================================== */
342     LocationError gnssSvIdConfigUpdateSync(const std::vector<GnssSvIdSource>& blacklistedSvIds);
343     LocationError gnssSvIdConfigUpdateSync();
344     void gnssSvIdConfigUpdate(const std::vector<GnssSvIdSource>& blacklistedSvIds);
345     void gnssSvIdConfigUpdate();
346     void gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config);
347     void gnssSvTypeConfigUpdate(bool sendReset = false);
gnssSetSvTypeConfig(const GnssSvTypeConfig & config)348     inline void gnssSetSvTypeConfig(const GnssSvTypeConfig& config)
349     { mGnssSvTypeConfig = config; }
gnssSetSvTypeConfigCallback(GnssSvTypeConfigCallback callback)350     inline void gnssSetSvTypeConfigCallback(GnssSvTypeConfigCallback callback)
351     { mGnssSvTypeConfigCb = callback; }
gnssGetSvTypeConfigCallback()352     inline GnssSvTypeConfigCallback gnssGetSvTypeConfigCallback()
353     { return mGnssSvTypeConfigCb; }
354     void setConfig();
355 
356     /* ========= AGPS ====================================================================== */
357     /* ======== COMMANDS ====(Called from Client Thread)==================================== */
358     void initDefaultAgpsCommand();
359     void initAgpsCommand(const AgpsCbInfo& cbInfo);
360     void initNfwCommand(const NfwCbInfo& cbInfo);
361     void dataConnOpenCommand(AGpsExtType agpsType,
362             const char* apnName, int apnLen, AGpsBearerType bearerType);
363     void dataConnClosedCommand(AGpsExtType agpsType);
364     void dataConnFailedCommand(AGpsExtType agpsType);
365     void getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb);
366     void nfwControlCommand(bool enable);
367     uint32_t setConstrainedTuncCommand (bool enable, float tuncConstraint,
368                                         uint32_t energyBudget);
369     uint32_t setPositionAssistedClockEstimatorCommand (bool enable);
370     uint32_t gnssUpdateSvConfigCommand(const GnssSvTypeConfig& svTypeConfig,
371                                        const GnssSvIdConfig& svIdConfig);
372     uint32_t gnssResetSvConfigCommand();
373     uint32_t configLeverArmCommand(const LeverArmConfigInfo& configInfo);
374     uint32_t configRobustLocationCommand(bool enable, bool enableForE911);
375 
376     /* ========= ODCPI ===================================================================== */
377     /* ======== COMMANDS ====(Called from Client Thread)==================================== */
378     void initOdcpiCommand(const OdcpiRequestCallback& callback);
379     void injectOdcpiCommand(const Location& location);
380     /* ======== RESPONSES ================================================================== */
381     void reportResponse(LocationError err, uint32_t sessionId);
382     void reportResponse(size_t count, LocationError* errs, uint32_t* ids);
383     /* ======== UTILITIES ================================================================== */
getControlCallbacks()384     LocationControlCallbacks& getControlCallbacks() { return mControlCallbacks; }
setControlCallbacks(const LocationControlCallbacks & controlCallbacks)385     void setControlCallbacks(const LocationControlCallbacks& controlCallbacks)
386     { mControlCallbacks = controlCallbacks; }
setAfwControlId(uint32_t id)387     void setAfwControlId(uint32_t id) { mAfwControlId = id; }
getAfwControlId()388     uint32_t getAfwControlId() { return mAfwControlId; }
isInSession()389     virtual bool isInSession() { return !mTimeBasedTrackingSessions.empty(); }
390     void initDefaultAgps();
391     bool initEngHubProxy();
392     void odcpiTimerExpireEvent();
393 
394     /* ==== REPORTS ======================================================================== */
395     /* ======== EVENTS ====(Called from QMI/EngineHub Thread)===================================== */
396     virtual void reportPositionEvent(const UlpLocation& ulpLocation,
397                                      const GpsLocationExtended& locationExtended,
398                                      enum loc_sess_status status,
399                                      LocPosTechMask techMask,
400                                      GnssDataNotification* pDataNotify = nullptr,
401                                      int msInWeek = -1);
402     virtual void reportEnginePositionsEvent(unsigned int count,
403                                             EngineLocationInfo* locationArr);
404 
405     virtual void reportSvEvent(const GnssSvNotification& svNotify,
406                                bool fromEngineHub=false);
407     virtual void reportNmeaEvent(const char* nmea, size_t length);
408     virtual void reportDataEvent(const GnssDataNotification& dataNotify, int msInWeek);
409     virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data,
410                                       const LocInEmergency emergencyState);
411     virtual void reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurements,
412                                                 int msInWeek);
413     virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial);
414     virtual void reportSvEphemerisEvent(GnssSvEphemerisReport & svEphemeris);
415     virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config);
416     virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config);
417     virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot);
418     virtual void reportLocationSystemInfoEvent(const LocationSystemInfo& locationSystemInfo);
419 
420     virtual bool requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask);
421     virtual bool releaseATL(int connHandle);
422     virtual bool requestOdcpiEvent(OdcpiRequestInfo& request);
423     virtual bool reportDeleteAidingDataEvent(GnssAidingData& aidingData);
424     virtual bool reportKlobucharIonoModelEvent(GnssKlobucharIonoModel& ionoModel);
425     virtual bool reportGnssAdditionalSystemInfoEvent(
426             GnssAdditionalSystemInfo& additionalSystemInfo);
427     virtual void reportNfwNotificationEvent(GnssNfwNotification& notification);
428 
429     /* ======== UTILITIES ================================================================= */
430     bool needReportForGnssClient(const UlpLocation& ulpLocation,
431             enum loc_sess_status status, LocPosTechMask techMask);
432     bool needReportForFlpClient(enum loc_sess_status status, LocPosTechMask techMask);
433     void reportPosition(const UlpLocation &ulpLocation,
434                         const GpsLocationExtended &locationExtended,
435                         enum loc_sess_status status,
436                         LocPosTechMask techMask);
437     void reportEnginePositions(unsigned int count,
438                                const EngineLocationInfo* locationArr);
439     void reportSv(GnssSvNotification& svNotify);
440     void reportNmea(const char* nmea, size_t length);
441     void reportData(GnssDataNotification& dataNotify);
442     bool requestNiNotify(const GnssNiNotification& notify, const void* data,
443                          const bool bInformNiAccept);
444     void reportGnssMeasurementData(const GnssMeasurementsNotification& measurements);
445     void reportGnssSvIdConfig(const GnssSvIdConfig& config);
446     void reportGnssSvTypeConfig(const GnssSvTypeConfig& config);
447     void requestOdcpi(const OdcpiRequestInfo& request);
448     void invokeGnssEnergyConsumedCallback(uint64_t energyConsumedSinceFirstBoot);
449     void saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb);
450     void reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo);
reportNfwNotification(const GnssNfwNotification & notification)451     inline void reportNfwNotification(const GnssNfwNotification& notification) {
452         if (NULL != mNfwCb) {
453             mNfwCb(notification);
454         }
455     }
getE911State(void)456     inline bool getE911State(void) {
457         if (NULL != mIsE911Session) {
458             return mIsE911Session();
459         }
460         return false;
461     }
462 
463     void updateSystemPowerState(PowerStateType systemPowerState);
464     void reportSvPolynomial(const GnssSvPolynomial &svPolynomial);
465     void requestSvPolyForClient(LocationAPI* client,
466                                 const LocationCallbacks& callbacks);
467 
468 
469     /*======== GNSSDEBUG ================================================================*/
470     bool getDebugReport(GnssDebugReport& report);
471     /* get AGC information from system status and fill it */
472     void getAgcInformation(GnssMeasurementsNotification& measurements, int msInWeek);
473     /* get Data information from system status and fill it */
474     void getDataInformation(GnssDataNotification& data, int msInWeek);
475 
476     /*==== SYSTEM STATUS ================================================================*/
getSystemStatus(void)477     inline SystemStatus* getSystemStatus(void) { return mSystemStatus; }
getServerUrl(void)478     std::string& getServerUrl(void) { return mServerUrl; }
getMoServerUrl(void)479     std::string& getMoServerUrl(void) { return mMoServerUrl; }
480 
481     /*==== CONVERSION ===================================================================*/
482     static uint32_t convertSuplVersion(const GnssConfigSuplVersion suplVersion);
483     static uint32_t convertLppProfile(const GnssConfigLppProfile lppProfile);
484     static uint32_t convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl);
485     static uint32_t convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices);
486     static uint32_t convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask);
487     static uint32_t convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask);
488     static uint32_t convertAGloProt(const GnssConfigAGlonassPositionProtocolMask);
489     static uint32_t convertSuplMode(const GnssConfigSuplModeMask suplModeMask);
490     static void convertSatelliteInfo(std::vector<GnssDebugSatelliteInfo>& out,
491                                      const GnssSvType& in_constellation,
492                                      const SystemStatusReports& in);
493     static bool convertToGnssSvIdConfig(
494             const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config);
495     static void convertFromGnssSvIdConfig(
496             const GnssSvIdConfig& svConfig, std::vector<GnssSvIdSource>& blacklistedSvIds);
497     static void convertGnssSvIdMaskToList(
498             uint64_t svIdMask, std::vector<GnssSvIdSource>& svIds,
499             GnssSvId initialSvId, GnssSvType svType);
500 
501     void injectLocationCommand(double latitude, double longitude, float accuracy);
502     void injectLocationExtCommand(const GnssLocationInfoNotification &locationInfo);
503 
504     void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty);
505     void blockCPICommand(double latitude, double longitude, float accuracy,
506                          int blockDurationMsec, double latLonDiffThreshold);
507 
508     /* ==== MISCELLANEOUS ================================================================== */
509     /* ======== COMMANDS ====(Called from Client Thread)==================================== */
510     void getPowerStateChangesCommand(void* powerStateCb);
511     /* ======== UTILITIES ================================================================== */
512     void reportPowerStateIfChanged();
savePowerStateCallback(powerStateCallback powerStateCb)513     void savePowerStateCallback(powerStateCallback powerStateCb){ mPowerStateCb = powerStateCb; }
getPowerState()514     bool getPowerState() { return mPowerOn; }
getSystemPowerState()515     inline PowerStateType getSystemPowerState() { return mSystemPowerState; }
516 
setAllowFlpNetworkFixes(uint32_t allow)517     void setAllowFlpNetworkFixes(uint32_t allow) { mAllowFlpNetworkFixes = allow; }
getAllowFlpNetworkFixes()518     uint32_t getAllowFlpNetworkFixes() { return mAllowFlpNetworkFixes; }
519     void setSuplHostServer(const char* server, int port, LocServerType type);
520     void notifyClientOfCachedLocationSystemInfo(LocationAPI* client,
521                                                 const LocationCallbacks& callbacks);
522     void updateSystemPowerStateCommand(PowerStateType systemPowerState);
523 };
524 
525 #endif //GNSS_ADAPTER_H
526