diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index e67f956b..35041f61 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -554,7 +554,7 @@ enum loc_api_adapter_err LocApiBase:: } int LocApiBase:: - initDataServiceClient() + initDataServiceClient(bool isDueToSsr) DEFAULT_IMPL(-1) int LocApiBase:: @@ -569,6 +569,10 @@ void LocApiBase:: closeDataCall() DEFAULT_IMPL() +void LocApiBase:: + releaseDataServiceClient() +DEFAULT_IMPL() + int LocApiBase:: setGpsLock(LOC_GPS_LOCK_MASK lock) DEFAULT_IMPL(-1) diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 4655332e..2d0cc8c6 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -215,10 +215,11 @@ public: getBestAvailableZppFix(GpsLocation & zppLoc); virtual enum loc_api_adapter_err getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask); - virtual int initDataServiceClient(); + virtual int initDataServiceClient(bool isDueToSsr); virtual int openAndStartDataCall(); virtual void stopDataCall(); virtual void closeDataCall(); + virtual void releaseDataServiceClient(); virtual void installAGpsCert(const DerEncodedCertificate* pData, size_t length, uint32_t slotBitMask); diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h index dd308b8e..7afdd001 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/loc_api/libloc_api_50001/LocEngAdapter.h @@ -261,9 +261,9 @@ public: { return mLocApi->setLPPeProtocol(lppeCP, lppeUP); } - inline virtual int initDataServiceClient() + inline virtual int initDataServiceClient(bool isDueToSsr) { - return mLocApi->initDataServiceClient(); + return mLocApi->initDataServiceClient(isDueToSsr); } inline virtual int openAndStartDataCall() { @@ -277,6 +277,10 @@ public: { mLocApi->closeDataCall(); } + inline virtual void releaseDataServiceClient() + { + mLocApi->releaseDataServiceClient(); + } inline enum loc_api_adapter_err getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask) { diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 86be6e15..545f3eb2 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -186,6 +186,7 @@ static void loc_default_parameters(void) // 2nd half of init(), singled out for // modem restart to use. static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data); +static void loc_eng_dsclient_release(loc_eng_data_s_type &loc_eng_data); static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data); static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data, @@ -2360,6 +2361,39 @@ static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data) } EXIT_LOG(%s, VOID_RET); } + +/*=========================================================================== +FUNCTION loc_eng_dsclient_release + +DESCRIPTION + Stop/Close/Release DS client when modem SSR happens. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static void loc_eng_dsclient_release(loc_eng_data_s_type &loc_eng_data) +{ + ENTRY_LOG(); + int result = 1; + LocEngAdapter* adapter = loc_eng_data.adapter; + if (NULL != adapter && gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) + { + // stop and close the ds client + adapter->stopDataCall(); + adapter->closeDataCall(); + adapter->releaseDataServiceClient(); + } + EXIT_LOG(%s, VOID_RET); +} + + /*=========================================================================== FUNCTION loc_eng_agps_init @@ -2430,7 +2464,7 @@ static void createAgnssNifs(loc_eng_data_s_type& locEng) { } if (NULL == locEng.ds_nif && gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL && - 0 == adapter->initDataServiceClient()) { + 0 == adapter->initDataServiceClient(false)) { locEng.ds_nif = new DSStateMachine(servicerTypeExt, (void *)dataCallCb, locEng.adapter); @@ -2964,6 +2998,12 @@ void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) if (loc_eng_data.internet_nif) loc_eng_data.internet_nif->dropAllSubscribers(); + // reinitialize DS client in SSR mode + loc_eng_dsclient_release(loc_eng_data); + if (loc_eng_data.adapter->mSupportsAgpsRequests && + gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) { + loc_eng_data.adapter->initDataServiceClient(true); + } loc_eng_agps_reinit(loc_eng_data); }