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)
This commit is contained in:
parent
11adbb371f
commit
3535edcfb0
11 changed files with 67 additions and 33 deletions
|
@ -13,8 +13,7 @@ LOCAL_SHARED_LIBRARIES := \
|
|||
libutils \
|
||||
libcutils \
|
||||
libgps.utils \
|
||||
libdl \
|
||||
libandroid_runtime
|
||||
libdl
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
MsgTask.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.
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue