From 3535edcfb0def6f298eea21f51fc91103004c984 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Sat, 20 Jul 2013 14:16:32 -0700 Subject: [PATCH] corresponding to izat_core and LBSAdapter changes. Removed makefile dependency to AndrodRuntime; Renamed library to be loaded from liblocation to libizat_core; Made some class private access to protected for the needs of inheritance; piggy bagged some optimizations. Change-Id: Id7e3127baa1833cbad7739f50808941c733b87f2 (cherry picked from commit c039ceaec84b25573d710b31831c9b06d4f3d1c6) --- core/Android.mk | 3 +- core/ContextBase.cpp | 2 +- core/ContextBase.h | 3 +- core/LocAdapterBase.cpp | 8 ---- core/LocApiBase.cpp | 10 ----- core/LocApiBase.h | 14 ++++++- core/LocDualContext.cpp | 37 ++++++++++++++++++- core/LocDualContext.h | 6 +++ .../libloc_api-rpc-glue/rpc_inc/LocApiRpc.h | 6 ++- .../libloc_api-rpc-glue/src/LocApiRpc.cpp | 3 +- loc_api/libloc_api_50001/loc_eng.cpp | 8 ++-- 11 files changed, 67 insertions(+), 33 deletions(-) diff --git a/core/Android.mk b/core/Android.mk index f9074dbd..bb222b87 100644 --- a/core/Android.mk +++ b/core/Android.mk @@ -13,8 +13,7 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ libgps.utils \ - libdl \ - libandroid_runtime + libdl LOCAL_SRC_FILES += \ MsgTask.cpp \ diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 7922cc21..3ab364f3 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -39,7 +39,7 @@ namespace loc_core { -const char* ContextBase::mIzatLibName = "libloc_api_v02.so "; +const char* ContextBase::mIzatLibName = "libizat_core.so"; // we initialized this handle to 1 because it can't possibly // 1 if it ever gets assigned a value. NULL on the otherhand // is possilbe. diff --git a/core/ContextBase.h b/core/ContextBase.h index b04def33..6ad9cad1 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -45,12 +45,11 @@ protected: const MsgTask* mMsgTask; LocApiBase* mLocApi; -protected: +public: ContextBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask); inline virtual ~ContextBase() { delete mLocApi; } -public: static void* getIzatLibHandle(); inline const MsgTask* getMsgTask() { return mMsgTask; } inline LocApiBase* getLocApi() { return mLocApi; } diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 27b9f61f..48d179f5 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -68,14 +68,6 @@ LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, sendMsg(new LocOpenMsg(this, mLocApi)); } -// This will be overridden by the individual adapters -// if necessary. -#define DEFAULT_IMPL(rtv) \ -{ \ - LOC_LOGW("%s: default implementation invoked", __func__); \ - return rtv; \ -} - void LocAdapterBase:: handleEngineDownEvent() DEFAULT_IMPL() diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index c6fef931..11d2ccb6 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -328,16 +328,6 @@ void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data) TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data)); } - -// downward calls -// All below functions are to be defined by adapter specific modules: -// RPC, QMI, etc. The default implementation is empty. -#define DEFAULT_IMPL(rtv) \ -{ \ - LOC_LOGW("%s: default implementation invoked", __func__); \ - return rtv; \ -} - 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 c027b3f8..3676bff6 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -37,6 +37,14 @@ #define smaller_of(a, b) (((a) > (b)) ? (b) : (a)) #define MAX_APN_LEN 100 +// This will be overridden by the individual adapters +// if necessary. +#define DEFAULT_IMPL(rtv) \ +{ \ + LOC_LOGW("%s: default implementation invoked", __func__); \ + return rtv; \ +} + namespace loc_core { int hexcode(char *hexstring, int string_size, @@ -122,20 +130,20 @@ class LocApiBase { friend class ContextBase; const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask; const MsgTask* mMsgTask; + LocAdapterBase* mLocAdapters[MAX_ADAPTERS]; static LocApiBase* create(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask, void* libHandle); +protected: virtual enum loc_api_adapter_err open(LOC_API_ADAPTER_EVENT_MASK_T mask); virtual enum loc_api_adapter_err close(); LOC_API_ADAPTER_EVENT_MASK_T getEvtMask(); - -protected: LOC_API_ADAPTER_EVENT_MASK_T mMask; LocApiBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T excludedMask); @@ -143,6 +151,8 @@ protected: bool isInSession(); public: + inline virtual void* getSibling() { return NULL; } + void addAdapter(LocAdapterBase* adapter); void removeAdapter(LocAdapterBase* adapter); diff --git a/core/LocDualContext.cpp b/core/LocDualContext.cpp index 2218621e..a62a7007 100644 --- a/core/LocDualContext.cpp +++ b/core/LocDualContext.cpp @@ -70,6 +70,15 @@ const MsgTask* LocDualContext::getMsgTask(MsgTask::tCreate tCreator, return mMsgTask; } +const MsgTask* LocDualContext::getMsgTask(MsgTask::tAssociate tAssociate, + const char* name) +{ + if (NULL == mMsgTask) { + mMsgTask = new MsgTask(tAssociate, name); + } + return mMsgTask; +} + ContextBase* LocDualContext::getLocFgContext(MsgTask::tCreate tCreator, const char* name) { @@ -81,6 +90,18 @@ ContextBase* LocDualContext::getLocFgContext(MsgTask::tCreate tCreator, return mFgContext; } +ContextBase* LocDualContext::getLocFgContext(MsgTask::tAssociate tAssociate, + const char* name) +{ + if (NULL == mFgContext) { + const MsgTask* msgTask = getMsgTask(tAssociate, name); + mFgContext = new LocDualContext(msgTask, + mFgExclMask); + } + return mFgContext; + +} + ContextBase* LocDualContext::getLocBgContext(MsgTask::tCreate tCreator, const char* name) { @@ -92,6 +113,18 @@ ContextBase* LocDualContext::getLocBgContext(MsgTask::tCreate tCreator, return mBgContext; } +ContextBase* LocDualContext::getLocBgContext(MsgTask::tAssociate tAssociate, + const char* name) +{ + if (NULL == mBgContext) { + const MsgTask* msgTask = getMsgTask(tAssociate, name); + mBgContext = new LocDualContext(msgTask, + mBgExclMask); + } + return mBgContext; +} + + bool LocDualContext::hasAgpsExt() { if (0xff == mHasAgpsExt) { @@ -99,8 +132,8 @@ bool LocDualContext::hasAgpsExt() void* handle = ContextBase::getIzatLibHandle(); if (NULL != handle) { bool(*getter)() = (bool(*)())dlsym(handle, "hasAgpsExt"); - if (NULL != getter && (*getter)()) { - mHasAgpsExt = 1; + if (NULL != getter) { + mHasAgpsExt = (*getter)(); } } } diff --git a/core/LocDualContext.h b/core/LocDualContext.h index 4e03bf44..488f5aa3 100644 --- a/core/LocDualContext.h +++ b/core/LocDualContext.h @@ -44,6 +44,8 @@ class LocDualContext : public ContextBase { static const MsgTask* getMsgTask(MsgTask::tCreate tCreator, const char* name); + static const MsgTask* getMsgTask(MsgTask::tAssociate tAssociate, + const char* name); protected: LocDualContext(const MsgTask* msgTask, @@ -57,8 +59,12 @@ public: static ContextBase* getLocFgContext(MsgTask::tCreate tCreator, const char* name); + static ContextBase* getLocFgContext(MsgTask::tAssociate tAssociate, + const char* name); static ContextBase* getLocBgContext(MsgTask::tCreate tCreator, const char* name); + static ContextBase* getLocBgContext(MsgTask::tAssociate tAssociate, + const char* name); static bool hasAgpsExt(); }; diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h index fef42199..1b4f3f74 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h @@ -38,8 +38,11 @@ using namespace loc_core; class LocApiRpc : public LocApiBase { +protected: // RPC communication establishment rpc_loc_client_handle_type client_handle; + +private: int dataEnableLastSet; char apnLastSet[MAX_APN_LEN]; @@ -58,6 +61,7 @@ class LocApiRpc : public LocApiBase { void ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr); void NIEvent(const rpc_loc_ni_event_s_type *ni_req_ptr); +protected: virtual enum loc_api_adapter_err open(LOC_API_ADAPTER_EVENT_MASK_T mask); virtual enum loc_api_adapter_err @@ -68,7 +72,7 @@ public: LOC_API_ADAPTER_EVENT_MASK_T exMask); ~LocApiRpc(); - int locEventCB(rpc_loc_client_handle_type client_handle, + virtual int locEventCB(rpc_loc_client_handle_type client_handle, rpc_loc_event_mask_type loc_event, const rpc_loc_event_payload_u_type* loc_event_payload); diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp index 879244da..428d5a20 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp @@ -128,7 +128,8 @@ const rpc_loc_event_mask_type LocApiRpc::locBits[] = RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST, RPC_LOC_EVENT_LOCATION_SERVER_REQUEST, RPC_LOC_EVENT_IOCTL_REPORT, - RPC_LOC_EVENT_STATUS_REPORT + RPC_LOC_EVENT_STATUS_REPORT, + RPC_LOC_EVENT_WPS_NEEDED_REQUEST }; // constructor diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index ff5fd63c..15f20cbb 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -878,8 +878,8 @@ LocEngReportXtraServer::LocEngReportXtraServer(void* locEng, mServers(new char[3*(mMaxLen+1)]) { strlcpy(mServers, url1, mMaxLen); - strlcpy(&mServers[mMaxLen], url2, mMaxLen); - strlcpy(&mServers[mMaxLen<<1], url3, mMaxLen); + strlcpy(&(mServers[mMaxLen+1]), url2, mMaxLen); + strlcpy(&(mServers[(mMaxLen+1)<<1]), url3, mMaxLen); locallog(); } void LocEngReportXtraServer::proc() const { @@ -889,8 +889,8 @@ void LocEngReportXtraServer::proc() const { if (locEngXtra->report_xtra_server_cb != NULL) { CALLBACK_LOG_CALLFLOW("report_xtra_server_cb", %s, mServers); locEngXtra->report_xtra_server_cb(mServers, - &mServers[mMaxLen], - &mServers[mMaxLen<<1]); + &(mServers[mMaxLen+1]), + &(mServers[(mMaxLen+1)<<1])); } else { LOC_LOGE("Callback function for request xtra is NULL"); }