1 /* Copyright (c) 2017-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 #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 TuncConfigInfo tuncConfigInfo; 139 PaceConfigInfo paceConfigInfo; 140 } LocIntegrationConfigInfo; 141 142 using namespace loc_core; 143 144 namespace loc_core { 145 class SystemStatus; 146 } 147 148 typedef std::function<void( 149 uint64_t gnssEnergyConsumedFromFirstBoot 150 )> GnssEnergyConsumedCallback; 151 152 typedef void (*powerStateCallback)(bool on); 153 154 class GnssAdapter : public LocAdapterBase { 155 156 /* ==== Engine Hub ===================================================================== */ 157 EngineHubProxyBase* mEngHubProxy; 158 bool mNHzNeeded; 159 bool mSPEAlreadyRunningAtHighestInterval; 160 161 /* ==== TRACKING ======================================================================= */ 162 TrackingOptionsMap mTimeBasedTrackingSessions; 163 LocationSessionMap mDistanceBasedTrackingSessions; 164 LocPosMode mLocPositionMode; 165 GnssSvUsedInPosition mGnssSvIdUsedInPosition; 166 bool mGnssSvIdUsedInPosAvail; 167 GnssSvMbUsedInPosition mGnssMbSvIdUsedInPosition; 168 bool mGnssMbSvIdUsedInPosAvail; 169 170 /* ==== CONTROL ======================================================================== */ 171 LocationControlCallbacks mControlCallbacks; 172 uint32_t mAfwControlId; 173 uint32_t mNmeaMask; 174 GnssSvIdConfig mGnssSvIdConfig; 175 GnssSvTypeConfig mGnssSvTypeConfig; 176 GnssSvTypeConfigCallback mGnssSvTypeConfigCb; 177 bool mSupportNfwControl; 178 LocIntegrationConfigInfo mLocConfigInfo; 179 180 /* ==== NI ============================================================================= */ 181 NiData mNiData; 182 183 /* ==== AGPS =========================================================================== */ 184 // This must be initialized via initAgps() 185 AgpsManager mAgpsManager; 186 void initAgps(const AgpsCbInfo& cbInfo); 187 188 /* ==== NFW =========================================================================== */ 189 NfwStatusCb mNfwCb; 190 IsInEmergencySession mIsE911Session; initNfw(const NfwCbInfo & cbInfo)191 inline void initNfw(const NfwCbInfo& cbInfo) { 192 mNfwCb = (NfwStatusCb)cbInfo.visibilityControlCb; 193 mIsE911Session = (IsInEmergencySession)cbInfo.isInEmergencySession; 194 } 195 196 /* ==== ODCPI ========================================================================== */ 197 OdcpiRequestCallback mOdcpiRequestCb; 198 bool mOdcpiRequestActive; 199 OdcpiTimer mOdcpiTimer; 200 OdcpiRequestInfo mOdcpiRequest; 201 void odcpiTimerExpire(); 202 203 /* === SystemStatus ===================================================================== */ 204 SystemStatus* mSystemStatus; 205 std::string mServerUrl; 206 std::string mMoServerUrl; 207 XtraSystemStatusObserver mXtraObserver; 208 LocationSystemInfo mLocSystemInfo; 209 std::vector<GnssSvIdSource> mBlacklistedSvIds; 210 PowerStateType mSystemPowerState; 211 212 /* === Misc ===================================================================== */ 213 BlockCPIInfo mBlockCPIInfo; 214 bool mPowerOn; 215 uint32_t mAllowFlpNetworkFixes; 216 217 /* === Misc callback from QMI LOC API ============================================== */ 218 GnssEnergyConsumedCallback mGnssEnergyConsumedCb; 219 powerStateCallback mPowerStateCb; 220 221 /*==== CONVERSION ===================================================================*/ 222 static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions); 223 static void convertLocation(Location& out, const UlpLocation& ulpLocation, 224 const GpsLocationExtended& locationExtended, 225 const LocPosTechMask techMask); 226 static void convertLocationInfo(GnssLocationInfoNotification& out, 227 const GpsLocationExtended& locationExtended); 228 static uint16_t getNumSvUsed(uint64_t svUsedIdsMask, 229 int totalSvCntInThisConstellation); 230 231 /* ======== UTILITIES ================================================================== */ 232 inline void initOdcpi(const OdcpiRequestCallback& callback); 233 inline void injectOdcpi(const Location& location); 234 static bool isFlpClient(LocationCallbacks& locationCallbacks); 235 236 protected: 237 238 /* ==== CLIENT ========================================================================= */ 239 virtual void updateClientsEventMask(); 240 virtual void stopClientSessions(LocationAPI* client); 241 242 public: 243 244 GnssAdapter(); ~GnssAdapter()245 virtual inline ~GnssAdapter() { } 246 247 /* ==== SSR ============================================================================ */ 248 /* ======== EVENTS ====(Called from QMI Thread)========================================= */ 249 virtual void handleEngineUpEvent(); 250 /* ======== UTILITIES ================================================================== */ 251 void restartSessions(); 252 void checkAndRestartTimeBasedSession(); 253 254 /* ==== CLIENT ========================================================================= */ 255 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 256 virtual void addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks); 257 258 /* ==== TRACKING ======================================================================= */ 259 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 260 uint32_t startTrackingCommand( 261 LocationAPI* client, TrackingOptions& trackingOptions); 262 void updateTrackingOptionsCommand( 263 LocationAPI* client, uint32_t id, TrackingOptions& trackingOptions); 264 void stopTrackingCommand(LocationAPI* client, uint32_t id); 265 /* ======== RESPONSES ================================================================== */ 266 void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId); 267 /* ======== UTILITIES ================================================================== */ 268 bool isTimeBasedTrackingSession(LocationAPI* client, uint32_t sessionId); 269 bool isDistanceBasedTrackingSession(LocationAPI* client, uint32_t sessionId); 270 bool hasCallbacksToStartTracking(LocationAPI* client); 271 bool isTrackingSession(LocationAPI* client, uint32_t sessionId); 272 void saveTrackingSession(LocationAPI* client, uint32_t sessionId, 273 const TrackingOptions& trackingOptions); 274 void eraseTrackingSession(LocationAPI* client, uint32_t sessionId); 275 276 bool setLocPositionMode(const LocPosMode& mode); getLocPositionMode()277 LocPosMode& getLocPositionMode() { return mLocPositionMode; } 278 279 bool startTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t sessionId, 280 const TrackingOptions& trackingOptions); 281 void startTimeBasedTracking(LocationAPI* client, uint32_t sessionId, 282 const TrackingOptions& trackingOptions); 283 bool stopTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t id); 284 void stopTracking(LocationAPI* client, uint32_t id); 285 bool updateTrackingMultiplex(LocationAPI* client, uint32_t id, 286 const TrackingOptions& trackingOptions); 287 void updateTracking(LocationAPI* client, uint32_t sessionId, 288 const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions); 289 bool checkAndSetSPEToRunforNHz(TrackingOptions & out); 290 291 void setConstrainedTunc(bool enable, float tuncConstraint, 292 uint32_t energyBudget, uint32_t sessionId); 293 void setPositionAssistedClockEstimator(bool enable, uint32_t sessionId); 294 void updateSvConfig(uint32_t sessionId, const GnssSvTypeConfig& svTypeConfig, 295 const GnssSvIdConfig& svIdConfig); 296 void resetSvConfig(uint32_t sessionId); 297 void configLeverArm(uint32_t sessionId, const LeverArmConfigInfo& configInfo); 298 299 /* ==== NI ============================================================================= */ 300 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 301 void gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response); 302 /* ======================(Called from NI Thread)======================================== */ 303 void gnssNiResponseCommand(GnssNiResponse response, void* rawRequest); 304 /* ======== UTILITIES ================================================================== */ 305 bool hasNiNotifyCallback(LocationAPI* client); getNiData()306 NiData& getNiData() { return mNiData; } 307 308 /* ==== CONTROL CLIENT ================================================================= */ 309 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 310 uint32_t enableCommand(LocationTechnologyType techType); 311 void disableCommand(uint32_t id); 312 void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks); 313 void readConfigCommand(); 314 void requestUlpCommand(); 315 void initEngHubProxyCommand(); 316 uint32_t* gnssUpdateConfigCommand(GnssConfig config); 317 uint32_t* gnssGetConfigCommand(GnssConfigFlagsMask mask); 318 uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data); 319 void deleteAidingData(const GnssAidingData &data, uint32_t sessionId); 320 void gnssUpdateXtraThrottleCommand(const bool enabled); 321 std::vector<LocationError> gnssUpdateConfig(const std::string& oldMoServerUrl, 322 GnssConfig& gnssConfigRequested, 323 GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0); 324 325 /* ==== GNSS SV TYPE CONFIG ============================================================ */ 326 /* ==== COMMANDS ====(Called from Client Thread)======================================== */ 327 /* ==== These commands are received directly from client bypassing Location API ======== */ 328 void gnssUpdateSvTypeConfigCommand(GnssSvTypeConfig config); 329 void gnssGetSvTypeConfigCommand(GnssSvTypeConfigCallback callback); 330 void gnssResetSvTypeConfigCommand(); 331 332 /* ==== UTILITIES ====================================================================== */ 333 LocationError gnssSvIdConfigUpdateSync(const std::vector<GnssSvIdSource>& blacklistedSvIds); 334 LocationError gnssSvIdConfigUpdateSync(); 335 void gnssSvIdConfigUpdate(const std::vector<GnssSvIdSource>& blacklistedSvIds); 336 void gnssSvIdConfigUpdate(); 337 void gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config); 338 void gnssSvTypeConfigUpdate(bool sendReset = false); gnssSetSvTypeConfig(const GnssSvTypeConfig & config)339 inline void gnssSetSvTypeConfig(const GnssSvTypeConfig& config) 340 { mGnssSvTypeConfig = config; } gnssSetSvTypeConfigCallback(GnssSvTypeConfigCallback callback)341 inline void gnssSetSvTypeConfigCallback(GnssSvTypeConfigCallback callback) 342 { mGnssSvTypeConfigCb = callback; } gnssGetSvTypeConfigCallback()343 inline GnssSvTypeConfigCallback gnssGetSvTypeConfigCallback() 344 { return mGnssSvTypeConfigCb; } 345 void setConfig(); 346 347 /* ========= AGPS ====================================================================== */ 348 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 349 void initDefaultAgpsCommand(); 350 void initAgpsCommand(const AgpsCbInfo& cbInfo); 351 void initNfwCommand(const NfwCbInfo& cbInfo); 352 void dataConnOpenCommand(AGpsExtType agpsType, 353 const char* apnName, int apnLen, AGpsBearerType bearerType); 354 void dataConnClosedCommand(AGpsExtType agpsType); 355 void dataConnFailedCommand(AGpsExtType agpsType); 356 void getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb); 357 void nfwControlCommand(bool enable); 358 uint32_t setConstrainedTuncCommand (bool enable, float tuncConstraint, 359 uint32_t energyBudget); 360 uint32_t setPositionAssistedClockEstimatorCommand (bool enable); 361 uint32_t gnssUpdateSvConfigCommand(const GnssSvTypeConfig& svTypeConfig, 362 const GnssSvIdConfig& svIdConfig); 363 uint32_t gnssResetSvConfigCommand(); 364 uint32_t configLeverArmCommand(const LeverArmConfigInfo& configInfo); 365 366 /* ========= ODCPI ===================================================================== */ 367 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 368 void initOdcpiCommand(const OdcpiRequestCallback& callback); 369 void injectOdcpiCommand(const Location& location); 370 /* ======== RESPONSES ================================================================== */ 371 void reportResponse(LocationError err, uint32_t sessionId); 372 void reportResponse(size_t count, LocationError* errs, uint32_t* ids); 373 /* ======== UTILITIES ================================================================== */ getControlCallbacks()374 LocationControlCallbacks& getControlCallbacks() { return mControlCallbacks; } setControlCallbacks(const LocationControlCallbacks & controlCallbacks)375 void setControlCallbacks(const LocationControlCallbacks& controlCallbacks) 376 { mControlCallbacks = controlCallbacks; } setAfwControlId(uint32_t id)377 void setAfwControlId(uint32_t id) { mAfwControlId = id; } getAfwControlId()378 uint32_t getAfwControlId() { return mAfwControlId; } isInSession()379 virtual bool isInSession() { return !mTimeBasedTrackingSessions.empty(); } 380 void initDefaultAgps(); 381 bool initEngHubProxy(); 382 void odcpiTimerExpireEvent(); 383 384 /* ==== REPORTS ======================================================================== */ 385 /* ======== EVENTS ====(Called from QMI/EngineHub Thread)===================================== */ 386 virtual void reportPositionEvent(const UlpLocation& ulpLocation, 387 const GpsLocationExtended& locationExtended, 388 enum loc_sess_status status, 389 LocPosTechMask techMask, 390 GnssDataNotification* pDataNotify = nullptr, 391 int msInWeek = -1); 392 virtual void reportEnginePositionsEvent(unsigned int count, 393 EngineLocationInfo* locationArr); 394 395 virtual void reportSvEvent(const GnssSvNotification& svNotify, 396 bool fromEngineHub=false); 397 virtual void reportNmeaEvent(const char* nmea, size_t length); 398 virtual void reportDataEvent(const GnssDataNotification& dataNotify, int msInWeek); 399 virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data, 400 const LocInEmergency emergencyState); 401 virtual void reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurements, 402 int msInWeek); 403 virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial); 404 virtual void reportSvEphemerisEvent(GnssSvEphemerisReport & svEphemeris); 405 virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config); 406 virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config); 407 virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot); 408 virtual void reportLocationSystemInfoEvent(const LocationSystemInfo& locationSystemInfo); 409 410 virtual bool requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask); 411 virtual bool releaseATL(int connHandle); 412 virtual bool requestOdcpiEvent(OdcpiRequestInfo& request); 413 virtual bool reportDeleteAidingDataEvent(GnssAidingData& aidingData); 414 virtual bool reportKlobucharIonoModelEvent(GnssKlobucharIonoModel& ionoModel); 415 virtual bool reportGnssAdditionalSystemInfoEvent( 416 GnssAdditionalSystemInfo& additionalSystemInfo); 417 virtual void reportNfwNotificationEvent(GnssNfwNotification& notification); 418 419 /* ======== UTILITIES ================================================================= */ 420 bool needReportForGnssClient(const UlpLocation& ulpLocation, 421 enum loc_sess_status status, LocPosTechMask techMask); 422 bool needReportForFlpClient(enum loc_sess_status status, LocPosTechMask techMask); 423 void reportPosition(const UlpLocation &ulpLocation, 424 const GpsLocationExtended &locationExtended, 425 enum loc_sess_status status, 426 LocPosTechMask techMask); 427 void reportEnginePositions(unsigned int count, 428 const EngineLocationInfo* locationArr); 429 void reportSv(GnssSvNotification& svNotify); 430 void reportNmea(const char* nmea, size_t length); 431 void reportData(GnssDataNotification& dataNotify); 432 bool requestNiNotify(const GnssNiNotification& notify, const void* data, 433 const bool bInformNiAccept); 434 void reportGnssMeasurementData(const GnssMeasurementsNotification& measurements); 435 void reportGnssSvIdConfig(const GnssSvIdConfig& config); 436 void reportGnssSvTypeConfig(const GnssSvTypeConfig& config); 437 void requestOdcpi(const OdcpiRequestInfo& request); 438 void invokeGnssEnergyConsumedCallback(uint64_t energyConsumedSinceFirstBoot); 439 void saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb); 440 void reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo); reportNfwNotification(const GnssNfwNotification & notification)441 inline void reportNfwNotification(const GnssNfwNotification& notification) { 442 if (NULL != mNfwCb) { 443 mNfwCb(notification); 444 } 445 } getE911State(void)446 inline bool getE911State(void) { 447 if (NULL != mIsE911Session) { 448 return mIsE911Session(); 449 } 450 return false; 451 } 452 453 void updateSystemPowerState(PowerStateType systemPowerState); 454 455 /*======== GNSSDEBUG ================================================================*/ 456 bool getDebugReport(GnssDebugReport& report); 457 /* get AGC information from system status and fill it */ 458 void getAgcInformation(GnssMeasurementsNotification& measurements, int msInWeek); 459 /* get Data information from system status and fill it */ 460 void getDataInformation(GnssDataNotification& data, int msInWeek); 461 462 /*==== SYSTEM STATUS ================================================================*/ getSystemStatus(void)463 inline SystemStatus* getSystemStatus(void) { return mSystemStatus; } getServerUrl(void)464 std::string& getServerUrl(void) { return mServerUrl; } getMoServerUrl(void)465 std::string& getMoServerUrl(void) { return mMoServerUrl; } 466 467 /*==== CONVERSION ===================================================================*/ 468 static uint32_t convertSuplVersion(const GnssConfigSuplVersion suplVersion); 469 static uint32_t convertLppProfile(const GnssConfigLppProfile lppProfile); 470 static uint32_t convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl); 471 static uint32_t convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices); 472 static uint32_t convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask); 473 static uint32_t convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask); 474 static uint32_t convertAGloProt(const GnssConfigAGlonassPositionProtocolMask); 475 static uint32_t convertSuplMode(const GnssConfigSuplModeMask suplModeMask); 476 static void convertSatelliteInfo(std::vector<GnssDebugSatelliteInfo>& out, 477 const GnssSvType& in_constellation, 478 const SystemStatusReports& in); 479 static bool convertToGnssSvIdConfig( 480 const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config); 481 static void convertFromGnssSvIdConfig( 482 const GnssSvIdConfig& svConfig, GnssConfig& config); 483 static void convertGnssSvIdMaskToList( 484 uint64_t svIdMask, std::vector<GnssSvIdSource>& svIds, 485 GnssSvId initialSvId, GnssSvType svType); 486 487 void injectLocationCommand(double latitude, double longitude, float accuracy); 488 void injectLocationExtCommand(const GnssLocationInfoNotification &locationInfo); 489 490 void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty); 491 void blockCPICommand(double latitude, double longitude, float accuracy, 492 int blockDurationMsec, double latLonDiffThreshold); 493 494 /* ==== MISCELLANEOUS ================================================================== */ 495 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 496 void getPowerStateChangesCommand(void* powerStateCb); 497 /* ======== UTILITIES ================================================================== */ 498 void reportPowerStateIfChanged(); savePowerStateCallback(powerStateCallback powerStateCb)499 void savePowerStateCallback(powerStateCallback powerStateCb){ mPowerStateCb = powerStateCb; } getPowerState()500 bool getPowerState() { return mPowerOn; } getSystemPowerState()501 inline PowerStateType getSystemPowerState() { return mSystemPowerState; } 502 setAllowFlpNetworkFixes(uint32_t allow)503 void setAllowFlpNetworkFixes(uint32_t allow) { mAllowFlpNetworkFixes = allow; } getAllowFlpNetworkFixes()504 uint32_t getAllowFlpNetworkFixes() { return mAllowFlpNetworkFixes; } 505 void setSuplHostServer(const char* server, int port, LocServerType type); 506 void notifyClientOfCachedLocationSystemInfo(LocationAPI* client, 507 const LocationCallbacks& callbacks); 508 void updateSystemPowerStateCommand(PowerStateType systemPowerState); 509 }; 510 511 #endif //GNSS_ADAPTER_H 512