Inject feature config

This change injects feature config
through using the first available
context

CRs-fixed: 616544

Change-Id: Idea5bd8acfff729589c071f20bec18679c89ab25
This commit is contained in:
Tushar Janefalkar 2014-02-24 11:13:57 -08:00
parent 3c8b3ff4fd
commit 9e585cb7bf
12 changed files with 82 additions and 32 deletions

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * 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 // first if can not be MPQ
if (TARGET_MPQ != loc_get_target()) { 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 // only RPC is the option now
void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
if (NULL != handle) { if (NULL != handle) {
getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi"); getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
if (NULL != getter) { 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 // locApi could still be NULL at this time
// we would then create a dummy one // we would then create a dummy one
if (NULL == locApi) { if (NULL == locApi) {
locApi = new LocApiBase(mMsgTask, exMask); locApi = new LocApiBase(mMsgTask, exMask, this);
} }
return locApi; return locApi;

View file

@ -62,6 +62,7 @@ public:
unsigned long capabilities) { unsigned long capabilities) {
mLBSProxy->requestUlp(adapter, capabilities); mLBSProxy->requestUlp(adapter, capabilities);
} }
inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); }
}; };
} // namespace loc_core } // namespace loc_core

View file

@ -35,12 +35,14 @@ namespace loc_core {
class LocApiBase; class LocApiBase;
class LocAdapterBase; class LocAdapterBase;
class ContextBase;
class LBSProxyBase { class LBSProxyBase {
friend class ContextBase; friend class ContextBase;
inline virtual LocApiBase* inline virtual LocApiBase*
getLocApi(const MsgTask* msgTask, getLocApi(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask) const { LOC_API_ADAPTER_EVENT_MASK_T exMask,
ContextBase* context) const {
return NULL; return NULL;
} }
protected: protected:
@ -51,6 +53,7 @@ public:
unsigned long capabilities) const {} unsigned long capabilities) const {}
inline virtual bool hasAgpsExtendedCapabilities() const { return false; } inline virtual bool hasAgpsExtendedCapabilities() const { return false; }
inline virtual bool hasCPIExtendedCapabilities() const { return false; } inline virtual bool hasCPIExtendedCapabilities() const { return false; }
virtual void injectFeatureConfig(ContextBase* context) const {}
}; };
typedef LBSProxyBase* (getLBSProxy_t)(); typedef LBSProxyBase* (getLBSProxy_t)();

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -33,6 +33,7 @@
#include <LocApiBase.h> #include <LocApiBase.h>
#include <LocAdapterBase.h> #include <LocAdapterBase.h>
#include <log_util.h> #include <log_util.h>
#include <LocDualContext.h>
namespace loc_core { namespace loc_core {
@ -125,8 +126,9 @@ struct LocOpenMsg : public LocMsg {
}; };
LocApiBase::LocApiBase(const MsgTask* msgTask, LocApiBase::LocApiBase(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T excludedMask) : LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
mMsgTask(msgTask), mExcludedMask(excludedMask), mMask(0) ContextBase* context) :
mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0), mContext(context)
{ {
memset(mLocAdapters, 0, sizeof(mLocAdapters)); memset(mLocAdapters, 0, sizeof(mLocAdapters));
} }
@ -206,6 +208,8 @@ void LocApiBase::handleEngineUpEvent()
// This will take care of renegotiating the loc handle // This will take care of renegotiating the loc handle
mMsgTask->sendMsg(new LocSsrMsg(this)); mMsgTask->sendMsg(new LocSsrMsg(this));
LocDualContext::injectFeatureConfig(mContext);
// loop through adapters, and deliver to all adapters. // loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent()); TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());
} }
@ -443,11 +447,15 @@ enum loc_api_adapter_err LocApiBase::
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase:: enum loc_api_adapter_err LocApiBase::
getZppFix(GpsLocation & zppLoc) getWwanZppFix(GpsLocation & zppLoc)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase:: 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) DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
int LocApiBase:: int LocApiBase::

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -36,6 +36,7 @@
#include <log_util.h> #include <log_util.h>
namespace loc_core { namespace loc_core {
class ContextBase;
int hexcode(char *hexstring, int string_size, int hexcode(char *hexstring, int string_size,
const char *data, int data_size); const char *data, int data_size);
@ -70,6 +71,7 @@ class LocApiBase {
friend struct LocOpenMsg; friend struct LocOpenMsg;
friend class ContextBase; friend class ContextBase;
const MsgTask* mMsgTask; const MsgTask* mMsgTask;
ContextBase *mContext;
LocAdapterBase* mLocAdapters[MAX_ADAPTERS]; LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
protected: protected:
@ -80,7 +82,8 @@ protected:
LOC_API_ADAPTER_EVENT_MASK_T getEvtMask(); LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
LOC_API_ADAPTER_EVENT_MASK_T mMask; LOC_API_ADAPTER_EVENT_MASK_T mMask;
LocApiBase(const MsgTask* msgTask, 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(); } inline virtual ~LocApiBase() { close(); }
bool isInSession(); bool isInSession();
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask; const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
@ -189,9 +192,11 @@ public:
virtual enum loc_api_adapter_err virtual enum loc_api_adapter_err
setAGLONASSProtocol(unsigned long aGlonassProtocol); setAGLONASSProtocol(unsigned long aGlonassProtocol);
virtual enum loc_api_adapter_err virtual enum loc_api_adapter_err
getZppFix(GpsLocation & zppLoc); getWwanZppFix(GpsLocation & zppLoc);
virtual enum loc_api_adapter_err 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 initDataServiceClient();
virtual int openAndStartDataCall(); virtual int openAndStartDataCall();
virtual void stopDataCall(); virtual void stopDataCall();
@ -215,7 +220,8 @@ public:
}; };
typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask, 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 } // namespace loc_core

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -55,10 +55,10 @@ LocDualContext::mBgExclMask =
const MsgTask* LocDualContext::mMsgTask = NULL; const MsgTask* LocDualContext::mMsgTask = NULL;
ContextBase* LocDualContext::mFgContext = NULL; ContextBase* LocDualContext::mFgContext = NULL;
ContextBase* LocDualContext::mBgContext = NULL; ContextBase* LocDualContext::mBgContext = NULL;
ContextBase* LocDualContext::mInjectContext = NULL;
// the name must be shorter than 15 chars // the name must be shorter than 15 chars
const char* LocDualContext::mLocationHalName = "Loc_hal_worker"; 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 MsgTask* LocDualContext::getMsgTask(MsgTask::tCreate tCreator,
const char* name) const char* name)
@ -88,6 +88,10 @@ ContextBase* LocDualContext::getLocFgContext(MsgTask::tCreate tCreator,
mFgContext = new LocDualContext(msgTask, mFgContext = new LocDualContext(msgTask,
mFgExclMask); mFgExclMask);
} }
if(NULL == mInjectContext) {
mInjectContext = mFgContext;
injectFeatureConfig(mInjectContext);
}
return mFgContext; return mFgContext;
} }
@ -99,6 +103,11 @@ ContextBase* LocDualContext::getLocFgContext(MsgTask::tAssociate tAssociate,
mFgContext = new LocDualContext(msgTask, mFgContext = new LocDualContext(msgTask,
mFgExclMask); mFgExclMask);
} }
if(NULL == mInjectContext) {
LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__);
mInjectContext = mFgContext;
injectFeatureConfig(mInjectContext);
}
return mFgContext; return mFgContext;
} }
@ -111,6 +120,11 @@ ContextBase* LocDualContext::getLocBgContext(MsgTask::tCreate tCreator,
mBgContext = new LocDualContext(msgTask, mBgContext = new LocDualContext(msgTask,
mBgExclMask); mBgExclMask);
} }
if(NULL == mInjectContext) {
LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__);
mInjectContext = mBgContext;
injectFeatureConfig(mInjectContext);
}
return mBgContext; return mBgContext;
} }
@ -122,12 +136,28 @@ ContextBase* LocDualContext::getLocBgContext(MsgTask::tAssociate tAssociate,
mBgContext = new LocDualContext(msgTask, mBgContext = new LocDualContext(msgTask,
mBgExclMask); mBgExclMask);
} }
if(NULL == mInjectContext) {
LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__);
mInjectContext = mBgContext;
injectFeatureConfig(mInjectContext);
}
return mBgContext; 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, LocDualContext::LocDualContext(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask) : LOC_API_ADAPTER_EVENT_MASK_T exMask) :
ContextBase(msgTask, exMask, mIzatLibName) ContextBase(msgTask, exMask, mLBSLibName)
{ {
} }

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -40,7 +40,7 @@ class LocDualContext : public ContextBase {
static const MsgTask* mMsgTask; static const MsgTask* mMsgTask;
static ContextBase* mFgContext; static ContextBase* mFgContext;
static ContextBase* mBgContext; static ContextBase* mBgContext;
static ContextBase* mInjectContext;
static const MsgTask* getMsgTask(MsgTask::tCreate tCreator, static const MsgTask* getMsgTask(MsgTask::tCreate tCreator,
const char* name); const char* name);
static const MsgTask* getMsgTask(MsgTask::tAssociate tAssociate, static const MsgTask* getMsgTask(MsgTask::tAssociate tAssociate,
@ -52,7 +52,7 @@ protected:
inline virtual ~LocDualContext() {} inline virtual ~LocDualContext() {}
public: 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 mFgExclMask;
static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask; static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask;
static const char* mLocationHalName; static const char* mLocationHalName;
@ -65,6 +65,7 @@ public:
const char* name); const char* name);
static ContextBase* getLocBgContext(MsgTask::tAssociate tAssociate, static ContextBase* getLocBgContext(MsgTask::tAssociate tAssociate,
const char* name); const char* name);
static void injectFeatureConfig(ContextBase *context);
}; };
} }

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -133,6 +133,7 @@ public:
}; };
extern "C" LocApiBase* getLocApi(const MsgTask* msgTask, 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 #endif //LOC_API_RPC_H

View file

@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -134,8 +134,9 @@ const rpc_loc_event_mask_type LocApiRpc::locBits[] =
// constructor // constructor
LocApiRpc::LocApiRpc(const MsgTask* msgTask, LocApiRpc::LocApiRpc(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask) : LOC_API_ADAPTER_EVENT_MASK_T exMask,
LocApiBase(msgTask, exMask), ContextBase* context) :
LocApiBase(msgTask, exMask, context),
client_handle(RPC_LOC_CLIENT_HANDLE_INVALID), client_handle(RPC_LOC_CLIENT_HANDLE_INVALID),
dataEnableLastSet(-1) dataEnableLastSet(-1)
{ {
@ -1388,8 +1389,9 @@ GpsNiEncodingType LocApiRpc::convertNiEncodingType(int loc_encoding)
} }
LocApiBase* getLocApi(const MsgTask* msgTask, LocApiBase* getLocApi(const MsgTask* msgTask,
LOC_API_ADAPTER_EVENT_MASK_T exMask) { LOC_API_ADAPTER_EVENT_MASK_T exMask,
return new LocApiRpc(msgTask, exMask); ContextBase *context) {
return new LocApiRpc(msgTask, exMask, context);
} }
/*Values for lock /*Values for lock

View file

@ -254,7 +254,7 @@ public:
inline enum loc_api_adapter_err inline enum loc_api_adapter_err
getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask) getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask)
{ {
return mLocApi->getZppFix(zppLoc, tech_mask); return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask);
} }
virtual void handleEngineDownEvent(); virtual void handleEngineDownEvent();

View file

@ -115,7 +115,6 @@ static loc_param_s_type loc_parameter_table[] =
{"SENSOR_CONTROL_MODE", &sap_conf.SENSOR_CONTROL_MODE, NULL, 'n'}, {"SENSOR_CONTROL_MODE", &sap_conf.SENSOR_CONTROL_MODE, NULL, 'n'},
{"SENSOR_USAGE", &sap_conf.SENSOR_USAGE, NULL, 'n'}, {"SENSOR_USAGE", &sap_conf.SENSOR_USAGE, NULL, 'n'},
{"SENSOR_ALGORITHM_CONFIG_MASK", &sap_conf.SENSOR_ALGORITHM_CONFIG_MASK, 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'}, {"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'},
{"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'}, {"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
{"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'}, {"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'},

View file

@ -143,7 +143,6 @@ typedef struct loc_gps_cfg_s
unsigned long ACCURACY_THRES; unsigned long ACCURACY_THRES;
unsigned long SUPL_VER; unsigned long SUPL_VER;
unsigned long CAPABILITIES; unsigned long CAPABILITIES;
unsigned long QUIPC_ENABLED;
unsigned long LPP_PROFILE; unsigned long LPP_PROFILE;
uint8_t NMEA_PROVIDER; uint8_t NMEA_PROVIDER;
unsigned long A_GLONASS_POS_PROTOCOL_SELECT; unsigned long A_GLONASS_POS_PROTOCOL_SELECT;