diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 1bd138ea..e5a50140 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -65,13 +65,13 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) // first if can not be MPQ if (TARGET_MPQ != loc_get_target()) { - if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask))) { + if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) { // only RPC is the option now void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); if (NULL != handle) { getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); if (NULL != getter) { - locApi = (*getter)(mMsgTask, exMask); + locApi = (*getter)(mMsgTask, exMask, this); } } } @@ -80,7 +80,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask) // locApi could still be NULL at this time // we would then create a dummy one if (NULL == locApi) { - locApi = new LocApiBase(mMsgTask, exMask); + locApi = new LocApiBase(mMsgTask, exMask, this); } return locApi; diff --git a/core/ContextBase.h b/core/ContextBase.h index d7135875..2adbedd6 100644 --- a/core/ContextBase.h +++ b/core/ContextBase.h @@ -62,6 +62,7 @@ public: unsigned long capabilities) { mLBSProxy->requestUlp(adapter, capabilities); } + inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } }; } // namespace loc_core diff --git a/core/LBSProxyBase.h b/core/LBSProxyBase.h index 99872eef..0b7dbdf1 100644 --- a/core/LBSProxyBase.h +++ b/core/LBSProxyBase.h @@ -35,12 +35,14 @@ namespace loc_core { class LocApiBase; class LocAdapterBase; +class ContextBase; class LBSProxyBase { friend class ContextBase; inline virtual LocApiBase* getLocApi(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask) const { + LOC_API_ADAPTER_EVENT_MASK_T exMask, + ContextBase* context) const { return NULL; } protected: @@ -51,6 +53,7 @@ public: unsigned long capabilities) const {} inline virtual bool hasAgpsExtendedCapabilities() const { return false; } inline virtual bool hasCPIExtendedCapabilities() const { return false; } + virtual void injectFeatureConfig(ContextBase* context) const {} }; typedef LBSProxyBase* (getLBSProxy_t)(); diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index 65d2c8d9..90f36531 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -33,6 +33,7 @@ #include #include #include +#include namespace loc_core { @@ -125,8 +126,9 @@ struct LocOpenMsg : public LocMsg { }; LocApiBase::LocApiBase(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T excludedMask) : - mMsgTask(msgTask), mExcludedMask(excludedMask), mMask(0) + LOC_API_ADAPTER_EVENT_MASK_T excludedMask, + ContextBase* context) : + mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0), mContext(context) { memset(mLocAdapters, 0, sizeof(mLocAdapters)); } @@ -206,6 +208,8 @@ void LocApiBase::handleEngineUpEvent() // This will take care of renegotiating the loc handle mMsgTask->sendMsg(new LocSsrMsg(this)); + LocDualContext::injectFeatureConfig(mContext); + // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent()); } @@ -443,11 +447,15 @@ enum loc_api_adapter_err LocApiBase:: DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - getZppFix(GpsLocation & zppLoc) + getWwanZppFix(GpsLocation & zppLoc) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) enum loc_api_adapter_err LocApiBase:: - getZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask) + getBestAvailableZppFix(GpsLocation & zppLoc) +DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) + +enum loc_api_adapter_err LocApiBase:: + getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) int LocApiBase:: diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 1603e6b4..bef03790 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -36,6 +36,7 @@ #include namespace loc_core { +class ContextBase; int hexcode(char *hexstring, int string_size, const char *data, int data_size); @@ -70,6 +71,7 @@ class LocApiBase { friend struct LocOpenMsg; friend class ContextBase; const MsgTask* mMsgTask; + ContextBase *mContext; LocAdapterBase* mLocAdapters[MAX_ADAPTERS]; protected: @@ -80,7 +82,8 @@ protected: LOC_API_ADAPTER_EVENT_MASK_T getEvtMask(); LOC_API_ADAPTER_EVENT_MASK_T mMask; LocApiBase(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T excludedMask); + LOC_API_ADAPTER_EVENT_MASK_T excludedMask, + ContextBase* context = NULL); inline virtual ~LocApiBase() { close(); } bool isInSession(); const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask; @@ -189,9 +192,11 @@ public: virtual enum loc_api_adapter_err setAGLONASSProtocol(unsigned long aGlonassProtocol); virtual enum loc_api_adapter_err - getZppFix(GpsLocation & zppLoc); + getWwanZppFix(GpsLocation & zppLoc); virtual enum loc_api_adapter_err - getZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask); + getBestAvailableZppFix(GpsLocation & zppLoc); + virtual enum loc_api_adapter_err + getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask); virtual int initDataServiceClient(); virtual int openAndStartDataCall(); virtual void stopDataCall(); @@ -215,7 +220,8 @@ public: }; typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask); + LOC_API_ADAPTER_EVENT_MASK_T exMask, + ContextBase *context); } // namespace loc_core diff --git a/core/LocDualContext.cpp b/core/LocDualContext.cpp index fa4c4d60..ab151109 100644 --- a/core/LocDualContext.cpp +++ b/core/LocDualContext.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -55,10 +55,10 @@ LocDualContext::mBgExclMask = const MsgTask* LocDualContext::mMsgTask = NULL; ContextBase* LocDualContext::mFgContext = NULL; ContextBase* LocDualContext::mBgContext = NULL; - +ContextBase* LocDualContext::mInjectContext = NULL; // the name must be shorter than 15 chars const char* LocDualContext::mLocationHalName = "Loc_hal_worker"; -const char* LocDualContext::mIzatLibName = "liblbs_core.so"; +const char* LocDualContext::mLBSLibName = "liblbs_core.so"; const MsgTask* LocDualContext::getMsgTask(MsgTask::tCreate tCreator, const char* name) @@ -88,6 +88,10 @@ ContextBase* LocDualContext::getLocFgContext(MsgTask::tCreate tCreator, mFgContext = new LocDualContext(msgTask, mFgExclMask); } + if(NULL == mInjectContext) { + mInjectContext = mFgContext; + injectFeatureConfig(mInjectContext); + } return mFgContext; } @@ -99,6 +103,11 @@ ContextBase* LocDualContext::getLocFgContext(MsgTask::tAssociate tAssociate, mFgContext = new LocDualContext(msgTask, mFgExclMask); } + if(NULL == mInjectContext) { + LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__); + mInjectContext = mFgContext; + injectFeatureConfig(mInjectContext); + } return mFgContext; } @@ -111,6 +120,11 @@ ContextBase* LocDualContext::getLocBgContext(MsgTask::tCreate tCreator, mBgContext = new LocDualContext(msgTask, mBgExclMask); } + if(NULL == mInjectContext) { + LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__); + mInjectContext = mBgContext; + injectFeatureConfig(mInjectContext); + } return mBgContext; } @@ -122,12 +136,28 @@ ContextBase* LocDualContext::getLocBgContext(MsgTask::tAssociate tAssociate, mBgContext = new LocDualContext(msgTask, mBgExclMask); } + if(NULL == mInjectContext) { + LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__); + mInjectContext = mBgContext; + injectFeatureConfig(mInjectContext); + } return mBgContext; } +void LocDualContext :: injectFeatureConfig(ContextBase *curContext) +{ + LOC_LOGD("%s:%d]: Enter", __func__, __LINE__); + if(curContext == mInjectContext) { + LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config", + __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy); + ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext); + } + LOC_LOGD("%s:%d]: Exit", __func__, __LINE__); +} + LocDualContext::LocDualContext(const MsgTask* msgTask, LOC_API_ADAPTER_EVENT_MASK_T exMask) : - ContextBase(msgTask, exMask, mIzatLibName) + ContextBase(msgTask, exMask, mLBSLibName) { } diff --git a/core/LocDualContext.h b/core/LocDualContext.h index e761e764..cdc4df3e 100644 --- a/core/LocDualContext.h +++ b/core/LocDualContext.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -40,7 +40,7 @@ class LocDualContext : public ContextBase { static const MsgTask* mMsgTask; static ContextBase* mFgContext; static ContextBase* mBgContext; - + static ContextBase* mInjectContext; static const MsgTask* getMsgTask(MsgTask::tCreate tCreator, const char* name); static const MsgTask* getMsgTask(MsgTask::tAssociate tAssociate, @@ -52,7 +52,7 @@ protected: inline virtual ~LocDualContext() {} public: - static const char* mIzatLibName; + static const char* mLBSLibName; static const LOC_API_ADAPTER_EVENT_MASK_T mFgExclMask; static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask; static const char* mLocationHalName; @@ -65,6 +65,7 @@ public: const char* name); static ContextBase* getLocBgContext(MsgTask::tAssociate tAssociate, const char* name); + static void injectFeatureConfig(ContextBase *context); }; } 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 55550e74..aafec635 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 @@ -1,4 +1,4 @@ -/* Copyright (c) 2011,2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011,2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -133,6 +133,7 @@ public: }; extern "C" LocApiBase* getLocApi(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask); + LOC_API_ADAPTER_EVENT_MASK_T exMask, + ContextBase *context); #endif //LOC_API_RPC_H 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 08474fc4..e1422923 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 @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -134,8 +134,9 @@ const rpc_loc_event_mask_type LocApiRpc::locBits[] = // constructor LocApiRpc::LocApiRpc(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask) : - LocApiBase(msgTask, exMask), + LOC_API_ADAPTER_EVENT_MASK_T exMask, + ContextBase* context) : + LocApiBase(msgTask, exMask, context), client_handle(RPC_LOC_CLIENT_HANDLE_INVALID), dataEnableLastSet(-1) { @@ -1388,8 +1389,9 @@ GpsNiEncodingType LocApiRpc::convertNiEncodingType(int loc_encoding) } LocApiBase* getLocApi(const MsgTask* msgTask, - LOC_API_ADAPTER_EVENT_MASK_T exMask) { - return new LocApiRpc(msgTask, exMask); + LOC_API_ADAPTER_EVENT_MASK_T exMask, + ContextBase *context) { + return new LocApiRpc(msgTask, exMask, context); } /*Values for lock diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h index 27fb0fa1..93f3dc29 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/loc_api/libloc_api_50001/LocEngAdapter.h @@ -254,7 +254,7 @@ public: inline enum loc_api_adapter_err getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask) { - return mLocApi->getZppFix(zppLoc, tech_mask); + return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask); } virtual void handleEngineDownEvent(); diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 49a38fbe..423f2c1d 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -115,7 +115,6 @@ static loc_param_s_type loc_parameter_table[] = {"SENSOR_CONTROL_MODE", &sap_conf.SENSOR_CONTROL_MODE, NULL, 'n'}, {"SENSOR_USAGE", &sap_conf.SENSOR_USAGE, NULL, 'n'}, {"SENSOR_ALGORITHM_CONFIG_MASK", &sap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'}, - {"QUIPC_ENABLED", &gps_conf.QUIPC_ENABLED, NULL, 'n'}, {"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'}, {"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'}, {"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'}, diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h index 3c5d5a7d..ff787da7 100644 --- a/loc_api/libloc_api_50001/loc_eng.h +++ b/loc_api/libloc_api_50001/loc_eng.h @@ -143,7 +143,6 @@ typedef struct loc_gps_cfg_s unsigned long ACCURACY_THRES; unsigned long SUPL_VER; unsigned long CAPABILITIES; - unsigned long QUIPC_ENABLED; unsigned long LPP_PROFILE; uint8_t NMEA_PROVIDER; unsigned long A_GLONASS_POS_PROTOCOL_SELECT;