From 73573ef752430b0d54772e9167bb90cf44691351 Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Wed, 4 Sep 2013 17:51:18 -0700 Subject: [PATCH 01/10] Fix ATL handling Always register for ATL events reguardless of hw target or MSA/MSB capabilities. For APQ target, do not handle certain types of ATL events that it doen't support. For APQ target, use only position mode of Standalone. CRs-fixed: 533932 Change-Id: Icd626e3e7155d5c2ba871a343430e441924ce93c --- loc_api/libloc_api_50001/loc.cpp | 14 +-- loc_api/libloc_api_50001/loc_eng.cpp | 146 ++++++++++++++++----------- utils/loc_target.cpp | 14 +-- utils/loc_target.h | 1 + 4 files changed, 95 insertions(+), 80 deletions(-) diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index 90b3b86e..6cca8544 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -571,19 +571,7 @@ const void* loc_get_extension(const char* name) } else if (strcmp(name, AGPS_INTERFACE) == 0) { - //Return an interface to AGPS only if MSA or MSB capabilities - //are present. If the target is an APQ, these masks are - //cleared in get_gps_interface() and the below logic will - //return NULL as the interface for AGPS - if((gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) || - (gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) ) { - LOC_LOGD("%s:%d]: AGPS capabilities found\n", __func__, __LINE__); - ret_val = &sLocEngAGpsInterface; - } - else { - LOC_LOGD("%s:%d]: Returning NULL AgpsInterface\n", __func__, __LINE__); - ret_val = NULL; - } + ret_val = &sLocEngAGpsInterface; } else if (strcmp(name, GPS_NI_INTERFACE) == 0) { diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 3f3fffc9..ad6e54fa 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -978,8 +978,10 @@ LocEngSuplEsOpened::LocEngSuplEsOpened(void* locEng) : } void LocEngSuplEsOpened::proc() const { loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - AgpsStateMachine* sm = locEng->ds_nif; - sm->onRsrcEvent(RSRC_GRANTED); + if (locEng->ds_nif) { + AgpsStateMachine* sm = locEng->ds_nif; + sm->onRsrcEvent(RSRC_GRANTED); + } } void LocEngSuplEsOpened::locallog() const { LOC_LOGV("LocEngSuplEsOpened"); @@ -995,8 +997,10 @@ LocEngSuplEsClosed::LocEngSuplEsClosed(void* locEng) : } void LocEngSuplEsClosed::proc() const { loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - AgpsStateMachine* sm = locEng->ds_nif; - sm->onRsrcEvent(RSRC_RELEASED); + if (locEng->ds_nif) { + AgpsStateMachine* sm = locEng->ds_nif; + sm->onRsrcEvent(RSRC_RELEASED); + } } void LocEngSuplEsClosed::locallog() const { LOC_LOGV("LocEngSuplEsClosed"); @@ -1013,9 +1017,13 @@ LocEngRequestSuplEs::LocEngRequestSuplEs(void* locEng, int id) : } void LocEngRequestSuplEs::proc() const { loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - AgpsStateMachine* sm = locEng->ds_nif; - DSSubscriber s(sm, mID); - sm->subscribeRsrc((Subscriber*)&s); + if (locEng->ds_nif) { + AgpsStateMachine* sm = locEng->ds_nif; + DSSubscriber s(sm, mID); + sm->subscribeRsrc((Subscriber*)&s); + } else { + locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, -1); + } } inline void LocEngRequestSuplEs::locallog() const { LOC_LOGV("LocEngRequestSuplEs"); @@ -1034,11 +1042,15 @@ void LocEngRequestATL::proc() const { loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; AgpsStateMachine* sm = (AgpsStateMachine*) getAgpsStateMachine(*locEng, mType); - ATLSubscriber s(mID, - sm, - locEng->adapter, - AGPS_TYPE_INVALID == mType); - sm->subscribeRsrc((Subscriber*)&s); + if (sm) { + ATLSubscriber s(mID, + sm, + locEng->adapter, + AGPS_TYPE_INVALID == mType); + sm->subscribeRsrc((Subscriber*)&s); + } else { + locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, mType); + } } inline void LocEngRequestATL::locallog() const { LOC_LOGV("LocEngRequestATL"); @@ -1054,28 +1066,38 @@ LocEngReleaseATL::LocEngReleaseATL(void* locEng, int id) : } void LocEngReleaseATL::proc() const { loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - ATLSubscriber s1(mID, locEng->agnss_nif, locEng->adapter, false); - if (locEng->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) { - LOC_LOGD("%s:%d]: Unsubscribed from agnss_nif", - __func__, __LINE__); - } else { + + if (locEng->agnss_nif) { + ATLSubscriber s1(mID, locEng->agnss_nif, locEng->adapter, false); + if (locEng->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) { + LOC_LOGD("%s:%d]: Unsubscribed from agnss_nif", + __func__, __LINE__); + return; + } + } + + if (locEng->internet_nif) { ATLSubscriber s2(mID, locEng->internet_nif, locEng->adapter, false); if (locEng->internet_nif->unsubscribeRsrc((Subscriber*)&s2)) { LOC_LOGD("%s:%d]: Unsubscribed from internet_nif", __func__, __LINE__); - } else { - DSSubscriber s3(locEng->ds_nif, mID); - if(locEng->ds_nif->unsubscribeRsrc((Subscriber*)&s3)) { - LOC_LOGD("%s:%d]: Unsubscribed from ds_nif", - __func__, __LINE__); - } else { - LOC_LOGW("%s:%d]: Could not release ATL. " - "No subscribers found\n", - __func__, __LINE__); - locEng->adapter->atlCloseStatus(mID, 0); - } + return; } } + + if (locEng->ds_nif) { + DSSubscriber s3(locEng->ds_nif, mID); + if (locEng->ds_nif->unsubscribeRsrc((Subscriber*)&s3)) { + LOC_LOGD("%s:%d]: Unsubscribed from ds_nif", + __func__, __LINE__); + return; + } + } + + LOC_LOGW("%s:%d]: Could not release ATL. " + "No subscribers found\n", + __func__, __LINE__); + locEng->adapter->atlCloseStatus(mID, 0); } inline void LocEngReleaseATL::locallog() const { LOC_LOGV("LocEngReleaseATL"); @@ -1109,11 +1131,15 @@ LocEngReqRelWifi::~LocEngReqRelWifi() { } void LocEngReqRelWifi::proc() const { loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng; - WIFISubscriber s(locEng->wifi_nif, mSSID, mPassword, mSenderId); - if (mIsReq) { - locEng->wifi_nif->subscribeRsrc((Subscriber*)&s); + if (locEng->wifi_nif) { + WIFISubscriber s(locEng->wifi_nif, mSSID, mPassword, mSenderId); + if (mIsReq) { + locEng->wifi_nif->subscribeRsrc((Subscriber*)&s); + } else { + locEng->wifi_nif->unsubscribeRsrc((Subscriber*)&s); + } } else { - locEng->wifi_nif->unsubscribeRsrc((Subscriber*)&s); + locEng->adapter->atlOpenStatus(mSenderId, 0, NULL, -1, mType); } } inline void LocEngReqRelWifi::locallog() const { @@ -1477,13 +1503,6 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, loc_eng_data.generateNmea = false; } - //Disable AGPS if capabilities are not present - if(!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) && - !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB)) { - event &= ~(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST | - LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST); - } - loc_eng_data.adapter = new LocEngAdapter(event, &loc_eng_data, (MsgTask::tCreate)callbacks->create_thread_cb); @@ -1751,6 +1770,13 @@ int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, ENTRY_LOG_CALLFLOW(); INIT_CHECK(loc_eng_data.adapter, return -1); + // The position mode for APQ target can only be standalone + bool isAPQ = (getTargetGnssType(get_target()) == GNSS_GSS); + if (isAPQ && params.mode != LOC_POSITION_MODE_STANDALONE) { + params.mode = LOC_POSITION_MODE_STANDALONE; + LOC_LOGD("Position mode changed to standalone for APQ target."); + } + if(! loc_eng_data.adapter->getUlpProxy()->sendFixMode(params)) { LocEngAdapter* adapter = loc_eng_data.adapter; @@ -1975,28 +2001,14 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call STATE_CHECK((NULL == loc_eng_data.agps_status_cb), "agps instance already initialized", return); - if(callbacks == NULL) { + if (callbacks == NULL) { LOC_LOGE("loc_eng_agps_init: bad parameters cb %p", callbacks); EXIT_LOG(%s, VOID_RET); return; } - - //Proceed to create AGPS framework only if MSA or MSB capabilities - //are present. If the target is an APQ, these masks are - //cleared in get_gps_interface() - if(!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) && - !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) ) { - LOC_LOGD("%s:%d]: No AGPS capabilities found. Returning\n", - __func__, __LINE__); - return; - } LocEngAdapter* adapter = loc_eng_data.adapter; loc_eng_data.agps_status_cb = callbacks->status_cb; - loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps, - (void *)loc_eng_data.agps_status_cb, - AGPS_TYPE_SUPL, - false); loc_eng_data.internet_nif = new AgpsStateMachine(servicerTypeAgps, (void *)loc_eng_data.agps_status_cb, AGPS_TYPE_WWAN_ANY, @@ -2005,13 +2017,23 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call (void *)loc_eng_data.agps_status_cb, AGPS_TYPE_WIFI, true); - loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data)); - if (adapter->mAgpsEnabled) { - loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb, - NULL, NULL, &loc_eng_data); + bool isAPQ = (getTargetGnssType(get_target()) == GNSS_GSS); + if (!isAPQ) { + loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps, + (void *)loc_eng_data.agps_status_cb, + AGPS_TYPE_SUPL, + false); + + loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data)); + + if (adapter->mAgpsEnabled) { + loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb, + NULL, NULL, &loc_eng_data); + } + loc_eng_agps_reinit(loc_eng_data); } - loc_eng_agps_reinit(loc_eng_data); + EXIT_LOG(%s, VOID_RET); } @@ -2436,8 +2458,10 @@ void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) loc_eng_reinit(loc_eng_data); if (loc_eng_data.agps_status_cb != NULL) { - loc_eng_data.agnss_nif->dropAllSubscribers(); - loc_eng_data.internet_nif->dropAllSubscribers(); + if (loc_eng_data.agnss_nif) + loc_eng_data.agnss_nif->dropAllSubscribers(); + if (loc_eng_data.internet_nif) + loc_eng_data.internet_nif->dropAllSubscribers(); loc_eng_agps_reinit(loc_eng_data); } diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index d68d6c9f..cd781c05 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -58,6 +58,7 @@ #define GPS_CHECK_NO_GPS_HW 1 static int gss_fd = 0; +static unsigned int gTarget = TARGET_UNKNOWN; static int read_a_line(const char * file_path, char * line, int line_size) { @@ -83,7 +84,8 @@ static int read_a_line(const char * file_path, char * line, int line_size) unsigned int get_target(void) { - unsigned int target = TARGET_DEFAULT; + if (gTarget != TARGET_UNKNOWN) + return gTarget; char hw_platform[] = "/sys/devices/soc0/hw_platform"; char id[] = "/sys/devices/soc0/soc_id"; @@ -111,9 +113,9 @@ unsigned int get_target(void) if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){ if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) ) - target = TARGET_MPQ; + gTarget = TARGET_MPQ; else - target = TARGET_APQ_SA; + gTarget = TARGET_APQ_SA; } else { if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID)) @@ -124,13 +126,13 @@ unsigned int get_target(void) && IS_STR_END(rd_hw_platform[LENGTH(STR_MTP)]))) { if (!read_a_line( mdm, rd_mdm, LINE_LEN)) - target = TARGET_MDM; + gTarget = TARGET_MDM; } else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) || (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) - target = TARGET_MSM_NO_SSC; + gTarget = TARGET_MSM_NO_SSC; } - return target; + return gTarget; } diff --git a/utils/loc_target.h b/utils/loc_target.h index 12cff1d2..be68f928 100644 --- a/utils/loc_target.h +++ b/utils/loc_target.h @@ -34,6 +34,7 @@ #define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC) #define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC) #define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC) +#define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC) #define getTargetGnssType(target) (target>>1) #ifdef __cplusplus From 2daacc49050c81ec08d1383613ba81aa97908a99 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Tue, 17 Sep 2013 10:19:55 -0700 Subject: [PATCH 02/10] Add LocApi to get Zpp fix. Added get zpp fix API so that different other features can make use of this feature in the AP space. Change-Id: I32e750626704c5d0069723ee1ca949fda4a5505e --- core/LocApiBase.cpp | 4 ++++ core/LocApiBase.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 6ba72f9e..577d21bf 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -413,6 +413,10 @@ enum loc_api_adapter_err LocApiBase:: setAGLONASSProtocol(unsigned long aGlonassProtocol) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) +enum loc_api_adapter_err LocApiBase:: + getZppFix(GpsLocation & zppLoc) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + int LocApiBase:: initDataServiceClient() DEFAULT_IMPL(-1) diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 861b36f5..2fcac845 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -174,6 +174,8 @@ public: setExtPowerConfig(int isBatteryCharging); virtual enum loc_api_adapter_err setAGLONASSProtocol(unsigned long aGlonassProtocol); + virtual enum loc_api_adapter_err + getZppFix(GpsLocation & zppLoc); virtual int initDataServiceClient(); virtual int openAndStartDataCall(); virtual void stopDataCall(); From c66c2fc5f6451e78b63c1eee3febcfe7b703e751 Mon Sep 17 00:00:00 2001 From: Tushar Janefalkar Date: Mon, 23 Sep 2013 16:50:09 -0700 Subject: [PATCH 03/10] Add check for mAgpsEnabled requestSuplES did not have the check for mAgpsEnabled Change-Id: I314fe6bc933e5201e1ac6c6632ee3b53240955b1 CRs-fixed: 543639 --- loc_api/libloc_api_50001/LocEngAdapter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp index 9545681a..5224473f 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -234,8 +234,9 @@ bool LocEngAdapter::requestNiNotify(GpsNiNotification ¬if, const void* data) inline bool LocEngAdapter::requestSuplES(int connHandle) { - sendMsg(new LocEngRequestSuplEs(mOwner, connHandle)); - return true; + if (mAgpsEnabled) + sendMsg(new LocEngRequestSuplEs(mOwner, connHandle)); + return mAgpsEnabled; } inline From 969604adfde63faffabb733efa92df458e58d0a9 Mon Sep 17 00:00:00 2001 From: Tushar Janefalkar Date: Fri, 13 Sep 2013 18:38:26 -0700 Subject: [PATCH 04/10] Changes for liblbs_core Added new module liblbs_core to make LocApiV02 independent of pre-built binaries. This patch provies the necessary changes to support the new module CRs-fixed: 538124 Change-Id: I716cf169de9dae164a141651af971793099a927d --- core/Android.mk | 2 +- core/ContextBase.cpp | 15 ++++++++------- core/ContextBase.h | 12 ++++++------ core/{IzatProxyBase.h => LBSProxyBase.h} | 9 ++++----- core/LocApiBase.cpp | 5 +++++ core/LocApiBase.h | 7 ++++--- core/LocDualContext.cpp | 2 +- 7 files changed, 29 insertions(+), 23 deletions(-) rename core/{IzatProxyBase.h => LBSProxyBase.h} (94%) diff --git a/core/Android.mk b/core/Android.mk index 298c4131..11cecc65 100644 --- a/core/Android.mk +++ b/core/Android.mk @@ -38,7 +38,7 @@ LOCAL_COPY_HEADERS:= \ LocAdapterBase.h \ ContextBase.h \ LocDualContext.h \ - IzatProxyBase.h \ + LBSProxyBase.h \ UlpProxyBase.h \ gps_extended_c.h \ gps_extended.h \ diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 1826ec79..7879015f 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -40,21 +40,22 @@ namespace loc_core { - -IzatProxyBase* ContextBase::getIzatProxy(const char* libName) +LBSProxyBase* ContextBase::getLBSProxy(const char* libName) { - IzatProxyBase* proxy = NULL; + LBSProxyBase* proxy = NULL; + LOC_LOGD("%s:%d]: getLBSProxy libname: %s\n", __func__, __LINE__, libName); void* lib = dlopen(libName, RTLD_NOW); if ((void*)NULL != lib) { - getIzatProxy_t* getter = (getIzatProxy_t*)dlsym(lib, "getIzatProxy"); + getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, "getLBSProxy"); if (NULL != getter) { proxy = (*getter)(); } } if (NULL == proxy) { - proxy = new IzatProxyBase(); + proxy = new LBSProxyBase(); } + LOC_LOGD("%s:%d]: Exiting\n", __func__, __LINE__); return proxy; } @@ -64,7 +65,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) // first if can not be MPQ if (TARGET_MPQ != get_target()) { - if (NULL == (locApi = mIzatProxy->getLocApi(mMsgTask, exMask))) { + if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask))) { // only RPC is the option now void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); if (NULL != handle) { @@ -88,7 +89,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) ContextBase::ContextBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask, const char* libName) : - mIzatProxy(getIzatProxy(libName)), + mLBSProxy(getLBSProxy(libName)), mMsgTask(msgTask), mLocApi(createLocApi(exMask)) { diff --git a/core/ContextBase.h b/core/ContextBase.h index fc60db42..93cb31ff 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -33,17 +33,17 @@ #include #include #include -#include +#include namespace loc_core { class LocAdapterBase; class ContextBase { - static IzatProxyBase* getIzatProxy(const char* libName); + static LBSProxyBase* getLBSProxy(const char* libName); LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask); protected: - const IzatProxyBase* mIzatProxy; + const LBSProxyBase* mLBSProxy; const MsgTask* mMsgTask; LocApiBase* mLocApi; @@ -51,14 +51,14 @@ public: ContextBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask, const char* libName); - inline virtual ~ContextBase() { delete mLocApi; delete mIzatProxy; } + inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; } inline const MsgTask* getMsgTask() { return mMsgTask; } inline LocApiBase* getLocApi() { return mLocApi; } - inline bool hasAgpsExt() { return mIzatProxy->hasAgpsExt(); } + inline bool hasAgpsExt() { return mLBSProxy->hasAgpsExt(); } inline void requestUlp(LocAdapterBase* adapter, unsigned long capabilities) { - mIzatProxy->requestUlp(adapter, capabilities); + mLBSProxy->requestUlp(adapter, capabilities); } }; diff --git a/core/IzatProxyBase.h b/core/LBSProxyBase.h similarity index 94% rename from core/IzatProxyBase.h rename to core/LBSProxyBase.h index e7e3d3fa..e643d126 100644 --- a/core/IzatProxyBase.h +++ b/core/LBSProxyBase.h @@ -28,7 +28,6 @@ */ #ifndef IZAT_PROXY_BASE_H #define IZAT_PROXY_BASE_H - #include #include @@ -37,7 +36,7 @@ namespace loc_core { class LocApiBase; class LocAdapterBase; -class IzatProxyBase { +class LBSProxyBase { friend class ContextBase; inline virtual LocApiBase* getLocApi(const MsgTask* msgTask, @@ -45,15 +44,15 @@ class IzatProxyBase { return NULL; } protected: - inline IzatProxyBase() {} + inline LBSProxyBase() {} public: - inline virtual ~IzatProxyBase() {} + inline virtual ~LBSProxyBase() {} inline virtual void requestUlp(LocAdapterBase* adapter, unsigned long capabilities) const {} inline virtual bool hasAgpsExt() const { return false; } }; -typedef IzatProxyBase* (getIzatProxy_t)(); +typedef LBSProxyBase* (getLBSProxy_t)(); } // namespace loc_core diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 6ba72f9e..025bce02 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -296,6 +296,11 @@ void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data) TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data)); } +void* LocApiBase :: getSibling() + DEFAULT_IMPL(NULL) +void* LocApiBase :: getSibling2() + DEFAULT_IMPL(NULL) + enum loc_api_adapter_err LocApiBase:: open(LOC_API_ADAPTER_EVENT_MASK_T mask) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 861b36f5..5542d4c3 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -33,7 +33,7 @@ #include #include #include - +#include namespace loc_core { int hexcode(char *hexstring, int string_size, @@ -77,8 +77,6 @@ protected: bool isInSession(); public: - inline virtual void* getSibling() { return NULL; } - void addAdapter(LocAdapterBase* adapter); void removeAdapter(LocAdapterBase* adapter); @@ -111,6 +109,9 @@ public: // downward calls // All below functions are to be defined by adapter specific modules: // RPC, QMI, etc. The default implementation is empty. + + virtual void* getSibling(); + virtual void* getSibling2(); virtual enum loc_api_adapter_err startFix(const LocPosMode& posMode); virtual enum loc_api_adapter_err diff --git a/core/LocDualContext.cpp b/core/LocDualContext.cpp index 5c0c9a72..86c3613a 100644 --- a/core/LocDualContext.cpp +++ b/core/LocDualContext.cpp @@ -58,7 +58,7 @@ ContextBase* LocDualContext::mBgContext = NULL; // the name must be shorter than 15 chars const char* LocDualContext::mLocationHalName = "Loc_hal_worker"; -const char* LocDualContext::mIzatLibName = "libizat_core.so"; +const char* LocDualContext::mIzatLibName = "liblbs_core.so"; const MsgTask* LocDualContext::getMsgTask(MsgTask::tCreate tCreator, const char* name) From dc020ef75130b82be37f9c22cd0d159acb625d11 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Fri, 4 Oct 2013 18:59:00 -0700 Subject: [PATCH 05/10] Correct print for xtra server urls. The offset calculation on the 2nd and 3rd server urls were wrong. The are off by 1 and 2 bytes respectively. Change-Id: Iab9da5dbd2b0c779e18a6fe4615ad7e705800654 --- loc_api/libloc_api_50001/loc_eng.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 90df5290..098d403b 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -895,7 +895,7 @@ void LocEngReportXtraServer::proc() const { inline void LocEngReportXtraServer::locallog() const { LOC_LOGV("LocEngReportXtraServers: server1: %s\n server2: %s\n" " server3: %s\n", - mServers, &mServers[mMaxLen], &mServers[mMaxLen<<1]); + mServers, &mServers[mMaxLen+1], &mServers[(mMaxLen+1)<<1]); } inline void LocEngReportXtraServer::log() const { locallog(); From 351cb70668c3e3fac04bd942c187f8becde0b2b3 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Wed, 9 Oct 2013 18:35:04 -0700 Subject: [PATCH 06/10] enhance ulp handshake send ULP the position mode if it is valid when ULP handle is first received. This helps handling a race condition where ULP handshake happens when a GPS session is about to happen or already happening. Change-Id: I029e5c3bbb9d8e89b220ca44e9704b5a1d1451ff CRs-Fixed: 554340 --- core/gps_extended_c.h | 4 +++- loc_api/libloc_api_50001/LocEngAdapter.cpp | 16 ++++++++++++++++ loc_api/libloc_api_50001/LocEngAdapter.h | 3 +-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h index d11016ec..e7aa0b98 100644 --- a/core/gps_extended_c.h +++ b/core/gps_extended_c.h @@ -161,7 +161,8 @@ typedef enum loc_server_type { } LocServerType; typedef enum loc_position_mode_type { - LOC_POSITION_MODE_STANDALONE, + LOC_POSITION_MODE_INVALID = -1, + LOC_POSITION_MODE_STANDALONE = 0, LOC_POSITION_MODE_MS_BASED, LOC_POSITION_MODE_MS_ASSISTED, LOC_POSITION_MODE_RESERVED_1, @@ -169,6 +170,7 @@ typedef enum loc_position_mode_type { LOC_POSITION_MODE_RESERVED_3, LOC_POSITION_MODE_RESERVED_4, LOC_POSITION_MODE_RESERVED_5 + } LocPositionMode; #define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */ diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp index 5224473f..9e337f12 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -78,6 +78,7 @@ LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask, mAgpsEnabled(false) { memset(&mFixCriteria, 0, sizeof(mFixCriteria)); + mFixCriteria.mode = LOC_POSITION_MODE_INVALID; LOC_LOGD("LocEngAdapter created"); } @@ -101,6 +102,12 @@ void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp) ulp = new UlpProxyBase(); } mUlp = ulp; + + if (LOC_POSITION_MODE_INVALID != mFixCriteria.mode) { + // need to send this mode and start msg to ULP + mUlp->sendFixMode(mFixCriteria); + mUlp->sendStartFix(); + } } void LocInternalAdapter::reportPosition(UlpLocation &location, @@ -157,6 +164,15 @@ void LocEngAdapter::reportSv(GpsSvStatus &svStatus, } } +void LocEngAdapter::setInSession(bool inSession) +{ + mNavigating = inSession; + mLocApi->setInSession(inSession); + if (!mNavigating) { + mFixCriteria.mode = LOC_POSITION_MODE_INVALID; + } +} + inline void LocEngAdapter::reportStatus(GpsStatusValue status) { diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h index 53a5aca0..e0fd2ee5 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/loc_api/libloc_api_50001/LocEngAdapter.h @@ -264,8 +264,7 @@ public: {return mFixCriteria;} inline virtual bool isInSession() { return mNavigating; } - inline void setInSession(bool inSession) - { mNavigating = inSession; mLocApi->setInSession(inSession); } + void setInSession(bool inSession); /*Values for lock 1 = Do not lock any position sessions From 412275d48c53175c509eadf59b26f0b26b5431a1 Mon Sep 17 00:00:00 2001 From: Tushar Janefalkar Date: Wed, 23 Oct 2013 10:58:06 -0700 Subject: [PATCH 07/10] Check mAgpsEnabled for data call Check AGPS flag to ensure the request is handled by the right adapter Change-Id: I6fb7271ec0be5aec14e9d667c07e5b01b1736c1d CRs-fixed: 551808 --- loc_api/libloc_api_50001/LocEngAdapter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp index 5224473f..3ff3ac7a 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -242,15 +242,17 @@ bool LocEngAdapter::requestSuplES(int connHandle) inline bool LocEngAdapter::reportDataCallOpened() { - sendMsg(new LocEngSuplEsOpened(mOwner)); - return true; + if(mAgpsEnabled) + sendMsg(new LocEngSuplEsOpened(mOwner)); + return mAgpsEnabled; } inline bool LocEngAdapter::reportDataCallClosed() { - sendMsg(new LocEngSuplEsClosed(mOwner)); - return true; + if(mAgpsEnabled) + sendMsg(new LocEngSuplEsClosed(mOwner)); + return mAgpsEnabled; } inline From 41d3c44644b843c82688292ad41d31ea6f121cd4 Mon Sep 17 00:00:00 2001 From: Tushar Janefalkar Date: Wed, 25 Sep 2013 11:01:43 -0700 Subject: [PATCH 08/10] Send status report msg through ULP In order to preserve the ordering of position reports and status reports from the GPS engine, status reports are sent through the ULP too CRS-Fixed: 538143 Change-Id: I41be2121493c6a0b35a5726fd546eb0fa5e9b20c --- core/UlpProxyBase.h | 3 +++ loc_api/libloc_api_50001/LocEngAdapter.cpp | 10 ++++++++-- loc_api/libloc_api_50001/LocEngAdapter.h | 1 + loc_api/libloc_api_50001/loc_eng.cpp | 7 ++++--- loc_api/libloc_api_50001/loc_eng_msg.h | 4 ++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/UlpProxyBase.h b/core/UlpProxyBase.h index 02ba1678..0873748b 100644 --- a/core/UlpProxyBase.h +++ b/core/UlpProxyBase.h @@ -54,6 +54,9 @@ public: void* svExt) { return false; } + inline virtual bool reportStatus(GpsStatusValue status) { + return false; + } inline virtual void setAdapter(LocAdapterBase* adapter) {} inline virtual void setCapabilities(unsigned long capabilities) {} }; diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp index 5224473f..468fe973 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.cpp +++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -157,10 +157,16 @@ void LocEngAdapter::reportSv(GpsSvStatus &svStatus, } } -inline +void LocInternalAdapter::reportStatus(GpsStatusValue status) +{ + sendMsg(new LocEngReportStatus(mLocEngAdapter, status)); +} + void LocEngAdapter::reportStatus(GpsStatusValue status) { - sendMsg(new LocEngReportStatus(mOwner, status)); + if (!mUlp->reportStatus(status)) { + mInternalAdapter->reportStatus(status); + } } inline diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h index 53a5aca0..a31cebbb 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/loc_api/libloc_api_50001/LocEngAdapter.h @@ -58,6 +58,7 @@ public: virtual void reportSv(GpsSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt); + virtual void reportStatus(GpsStatusValue status); virtual void setPositionModeInt(LocPosMode& posMode); virtual void startFixInt(); virtual void stopFixInt(); diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 90df5290..f6fd54d2 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -821,15 +821,16 @@ void LocEngReportSv::send() const { } // case LOC_ENG_MSG_REPORT_STATUS: -LocEngReportStatus::LocEngReportStatus(void* locEng, +LocEngReportStatus::LocEngReportStatus(LocAdapterBase* adapter, GpsStatusValue engineStatus) : - LocMsg(), mLocEng(locEng), mStatus(engineStatus) + LocMsg(), mAdapter(adapter), mStatus(engineStatus) { locallog(); } inline void LocEngReportStatus::proc() const { - loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng; + LocEngAdapter* adapter = (LocEngAdapter*)mAdapter; + loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner(); loc_eng_report_status(*locEng, mStatus); update_aiding_data_for_deletion(*locEng); diff --git a/loc_api/libloc_api_50001/loc_eng_msg.h b/loc_api/libloc_api_50001/loc_eng_msg.h index 1a318946..4790bbee 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg.h +++ b/loc_api/libloc_api_50001/loc_eng_msg.h @@ -119,9 +119,9 @@ struct LocEngReportSv : public LocMsg { }; struct LocEngReportStatus : public LocMsg { - void* mLocEng; + LocAdapterBase* mAdapter; const GpsStatusValue mStatus; - LocEngReportStatus(void* locEng, + LocEngReportStatus(LocAdapterBase* adapter, GpsStatusValue engineStatus); virtual void proc() const; void locallog() const; From a8dff296173f88015cf7c627ad7329c9544090ca Mon Sep 17 00:00:00 2001 From: Jiafei Wen Date: Wed, 23 Oct 2013 11:28:51 -0700 Subject: [PATCH 09/10] Add LocApiProxyBase to context This is so that the izat adapters can get access to LocApiProxy through the context. Change-Id: I15a477d159375740047cd7386f8c8c5163fdaf87 --- core/ContextBase.cpp | 3 ++- core/ContextBase.h | 3 ++- core/LocAdapterBase.cpp | 22 +--------------------- core/LocAdapterBase.h | 6 ++---- core/LocApiBase.cpp | 29 ++++++++++++++++++++++++++--- core/LocApiBase.h | 18 ++++++++++++++---- 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 7879015f..dc47ffbd 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -91,7 +91,8 @@ ContextBase::ContextBase(const MsgTask* msgTask, const char* libName) : mLBSProxy(getLBSProxy(libName)), mMsgTask(msgTask), - mLocApi(createLocApi(exMask)) + mLocApi(createLocApi(exMask)), + mLocApiProxy(mLocApi->getLocApiProxy()) { } diff --git a/core/ContextBase.h b/core/ContextBase.h index 93cb31ff..b41dd780 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -46,7 +46,7 @@ protected: const LBSProxyBase* mLBSProxy; const MsgTask* mMsgTask; LocApiBase* mLocApi; - + LocApiProxyBase *mLocApiProxy; public: ContextBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask, @@ -55,6 +55,7 @@ public: inline const MsgTask* getMsgTask() { return mMsgTask; } inline LocApiBase* getLocApi() { return mLocApi; } + inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; } inline bool hasAgpsExt() { return mLBSProxy->hasAgpsExt(); } inline void requestUlp(LocAdapterBase* adapter, unsigned long capabilities) { diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 48d179f5..8bbe873f 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -36,26 +36,6 @@ namespace loc_core { -struct LocOpenMsg : public LocMsg { - LocAdapterBase* mLocAdapter; - LocApiBase* mLocApi; - inline LocOpenMsg(LocAdapterBase* locAdapter, - LocApiBase* locApi) : - LocMsg(), mLocAdapter(locAdapter), mLocApi(locApi) - { - locallog(); - } - inline virtual void proc() const { - mLocApi->addAdapter(mLocAdapter); - } - inline void locallog() { - LOC_LOGV("LocOpen"); - } - inline virtual void log() { - locallog(); - } -}; - // This is the top level class, so the constructor will // always gets called. Here we prepare for the default. // But if getLocApi(targetEnumType target) is overriden, @@ -65,7 +45,7 @@ LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, mEvtMask(mask), mContext(context), mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask()) { - sendMsg(new LocOpenMsg(this, mLocApi)); + mLocApi->addAdapter(this); } void LocAdapterBase:: diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index f279f9fd..be31de6e 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -44,12 +44,10 @@ protected: inline LocAdapterBase(const MsgTask* msgTask) : mEvtMask(0), mContext(NULL), mLocApi(NULL), mMsgTask(msgTask) {} - +public: + inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, ContextBase* context); - inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } - -public: inline LOC_API_ADAPTER_EVENT_MASK_T checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const { return mEvtMask & mask; diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 7a6456c1..2978fb3f 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -103,6 +103,27 @@ struct LocSsrMsg : public LocMsg { } }; +struct LocOpenMsg : public LocMsg { + LocApiBase* mLocApi; + LOC_API_ADAPTER_EVENT_MASK_T mMask; + inline LocOpenMsg(LocApiBase* locApi, + LOC_API_ADAPTER_EVENT_MASK_T mask) : + LocMsg(), mLocApi(locApi), mMask(mask) + { + locallog(); + } + inline virtual void proc() const { + mLocApi->open(mMask); + } + inline void locallog() { + LOC_LOGV("%s:%d]: LocOpen Mask: %x\n", + __func__, __LINE__, mMask); + } + inline virtual void log() { + locallog(); + } +}; + LocApiBase::LocApiBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T excludedMask) : mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0) @@ -137,7 +158,8 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter) for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) { if (mLocAdapters[i] == NULL) { mLocAdapters[i] = adapter; - open(mMask | (adapter->getEvtMask() & ~mExcludedMask)); + mMsgTask->sendMsg(new LocOpenMsg(this, + (adapter->getEvtMask()))); break; } } @@ -173,7 +195,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter) close(); } else { // else we need to remove the bit - open(getEvtMask() & ~mExcludedMask); + mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); } } } @@ -298,7 +320,8 @@ void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data) void* LocApiBase :: getSibling() DEFAULT_IMPL(NULL) -void* LocApiBase :: getSibling2() + +LocApiProxyBase* LocApiBase :: getLocApiProxy() DEFAULT_IMPL(NULL) enum loc_api_adapter_err LocApiBase:: diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 4ddc57f1..04afa53a 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -34,6 +34,7 @@ #include #include #include + namespace loc_core { int hexcode(char *hexstring, int string_size, @@ -51,14 +52,23 @@ int decodeAddress(char *addr_string, int string_size, #define TO_1ST_HANDLING_ADAPTER(adapters, call) \ for (int i = 0; i Date: Tue, 12 Nov 2013 15:49:32 -0800 Subject: [PATCH 10/10] Memset the xtra url to assure null termination Fixes a potential crash in jni layer caused by invalid characters in the string. CRs-fixed: 555829 Change-Id: I03ae100c4b7e65c95bac5841fcf00b27e2940741 --- loc_api/libloc_api_50001/loc_eng.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index f6fd54d2..d6e69cfc 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -875,6 +875,7 @@ LocEngReportXtraServer::LocEngReportXtraServer(void* locEng, LocMsg(), mLocEng(locEng), mMaxLen(maxlength), mServers(new char[3*(mMaxLen+1)]) { + memset(mServers, 0, 3*(mMaxLen+1)); strlcpy(mServers, url1, mMaxLen); strlcpy(&(mServers[mMaxLen+1]), url2, mMaxLen); strlcpy(&(mServers[(mMaxLen+1)<<1]), url3, mMaxLen);