From 79c877db2447b8e08560fa01a5a825ebbb2f58ee Mon Sep 17 00:00:00 2001 From: Jiafei Wen Date: Mon, 1 Sep 2014 19:07:58 -0700 Subject: [PATCH] Checking messages supported or not When device boots up, get a list of message supported by modem, based on which some adapeters will be able to update register masks. CRs-fixed: 601349 Change-Id: I6af282f8e551f1f3c6bf8795e968fdbc7b0a9fa3 --- core/LocAdapterBase.h | 14 ++++++++++++-- core/LocAdapterProxyBase.h | 7 ++++++- core/LocApiBase.cpp | 13 ++++++++++++- core/LocApiBase.h | 11 +++++++++++ core/gps_extended_c.h | 11 +++++++++++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h index 9348a89c..2fec3128 100644 --- a/core/LocAdapterBase.h +++ b/core/LocAdapterBase.h @@ -39,14 +39,15 @@ class LocAdapterProxyBase; class LocAdapterBase { protected: - const LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; + LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; ContextBase* mContext; LocApiBase* mLocApi; LocAdapterProxyBase* mLocAdapterProxyBase; const MsgTask* mMsgTask; inline LocAdapterBase(const MsgTask* msgTask) : - mEvtMask(0), mContext(NULL), mLocApi(NULL), mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} + mEvtMask(0), mContext(NULL), mLocApi(NULL), + mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} public: inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, @@ -68,6 +69,15 @@ public: mMsgTask->sendMsg(msg); } + inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled) + { + mEvtMask = + isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event); + + mLocApi->updateEvtMask(); + } + // This will be overridden by the individual adapters // if necessary. inline virtual void setUlpProxy(UlpProxyBase* ulp) {} diff --git a/core/LocAdapterProxyBase.h b/core/LocAdapterProxyBase.h index 25af10be..df5a48bd 100644 --- a/core/LocAdapterProxyBase.h +++ b/core/LocAdapterProxyBase.h @@ -37,7 +37,7 @@ namespace loc_core { class LocAdapterProxyBase { private: - const LocAdapterBase *mLocAdapterBase; + LocAdapterBase *mLocAdapterBase; protected: inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, ContextBase* context): @@ -49,6 +49,11 @@ protected: ContextBase* getContext() const { return mLocAdapterBase->getContext(); } + inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, + loc_registration_mask_status isEnabled) { + mLocAdapterBase->updateEvtMask(event,isEnabled); + } + public: inline virtual void handleEngineUpEvent() {}; inline virtual void handleEngineDownEvent() {}; diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 97c282df..5c9380bd 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -128,7 +128,8 @@ struct LocOpenMsg : public LocMsg { LocApiBase::LocApiBase(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T excludedMask, ContextBase* context) : - mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0), mContext(context) + mExcludedMask(excludedMask), mMsgTask(msgTask), + mMask(0), mSupportedMsg(0), mContext(context) { memset(mLocAdapters, 0, sizeof(mLocAdapters)); } @@ -203,6 +204,11 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter) } } +void LocApiBase::updateEvtMask() +{ + mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask())); +} + void LocApiBase::handleEngineUpEvent() { // This will take care of renegotiating the loc handle @@ -322,6 +328,11 @@ void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data) TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data)); } +void LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList) +{ + mSupportedMsg = supportedMsgList; +} + void* LocApiBase :: getSibling() DEFAULT_IMPL(NULL) diff --git a/core/LocApiBase.h b/core/LocApiBase.h index f489f63f..5da6b6d1 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -80,6 +80,7 @@ class LocApiBase { const MsgTask* mMsgTask; ContextBase *mContext; LocAdapterBase* mLocAdapters[MAX_ADAPTERS]; + uint64_t mSupportedMsg; protected: virtual enum loc_api_adapter_err @@ -128,6 +129,7 @@ public: void reportDataCallOpened(); void reportDataCallClosed(); void requestNiNotify(GpsNiNotification ¬ify, const void* data); + void saveSupportedMsgList(uint64_t supportedMsgList); // downward calls // All below functions are to be defined by adapter specific modules: @@ -210,6 +212,15 @@ public: virtual void closeDataCall(); inline virtual void setInSession(bool inSession) {} + inline bool isMessageSupported (LocCheckingMessagesID msgID) const { + if (msgID > (sizeof(mSupportedMsg) << 3)) { + return false; + } else { + uint32_t messageChecker = 1 << msgID; + return (messageChecker & mSupportedMsg) == messageChecker; + } + } + void updateEvtMask(); /*Values for lock 1 = Do not lock any position sessions diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h index 81e0fa00..44ff5ae8 100644 --- a/core/gps_extended_c.h +++ b/core/gps_extended_c.h @@ -68,6 +68,11 @@ extern "C" { /*Emergency SUPL*/ #define GPS_NI_TYPE_EMERGENCY_SUPL 4 +enum loc_registration_mask_status { + LOC_REGISTRATION_MASK_ENABLED, + LOC_REGISTRATION_MASK_DISABLED +}; + typedef struct { /** set to sizeof(UlpLocation) */ size_t size; @@ -365,6 +370,12 @@ enum loc_api_adapter_event_index { typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T; +typedef enum loc_api_adapter_msg_to_check_supported { + LOC_API_ADAPTER_MESSAGE_LOCATION_BATCHING, // Batching + LOC_API_ADAPTER_MESSAGE_BATCHED_GENFENCE_BREACH, // Geofence Batched Breach + + LOC_API_ADAPTER_MESSAGE_MAX +} LocCheckingMessagesID; #ifdef __cplusplus }