Merge remote-tracking branch 'quic/kitkat' into HEAD
Change-Id: I1b2ba3ecbfaedcc28623983e1d3a1e8e06c64b17
This commit is contained in:
commit
19150216bf
25 changed files with 683 additions and 292 deletions
|
@ -42,7 +42,8 @@ LOCAL_COPY_HEADERS:= \
|
||||||
UlpProxyBase.h \
|
UlpProxyBase.h \
|
||||||
gps_extended_c.h \
|
gps_extended_c.h \
|
||||||
gps_extended.h \
|
gps_extended.h \
|
||||||
loc_core_log.h
|
loc_core_log.h \
|
||||||
|
LocAdapterProxyBase.h
|
||||||
|
|
||||||
LOCAL_PRELINK_MODULE := false
|
LOCAL_PRELINK_MODULE := false
|
||||||
|
|
||||||
|
|
|
@ -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 <LocAdapterBase.h>
|
#include <LocAdapterBase.h>
|
||||||
#include <loc_target.h>
|
#include <loc_target.h>
|
||||||
#include <log_util.h>
|
#include <log_util.h>
|
||||||
|
#include <LocAdapterProxyBase.h>
|
||||||
|
|
||||||
namespace loc_core {
|
namespace loc_core {
|
||||||
|
|
||||||
|
@ -41,16 +42,27 @@ namespace loc_core {
|
||||||
// But if getLocApi(targetEnumType target) is overriden,
|
// But if getLocApi(targetEnumType target) is overriden,
|
||||||
// the right locApi should get created.
|
// the right locApi should get created.
|
||||||
LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||||
ContextBase* context) :
|
ContextBase* context, LocAdapterProxyBase *adapterProxyBase) :
|
||||||
mEvtMask(mask), mContext(context),
|
mEvtMask(mask), mContext(context),
|
||||||
mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
|
mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase),
|
||||||
|
mMsgTask(context->getMsgTask())
|
||||||
{
|
{
|
||||||
mLocApi->addAdapter(this);
|
mLocApi->addAdapter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocAdapterBase::
|
void LocAdapterBase::handleEngineUpEvent()
|
||||||
handleEngineDownEvent()
|
{
|
||||||
DEFAULT_IMPL()
|
if (mLocAdapterProxyBase) {
|
||||||
|
mLocAdapterProxyBase->handleEngineUpEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocAdapterBase::handleEngineDownEvent()
|
||||||
|
{
|
||||||
|
if (mLocAdapterProxyBase) {
|
||||||
|
mLocAdapterProxyBase->handleEngineDownEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LocAdapterBase::
|
void LocAdapterBase::
|
||||||
reportPosition(UlpLocation &location,
|
reportPosition(UlpLocation &location,
|
||||||
|
|
|
@ -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
|
||||||
|
@ -35,19 +35,22 @@
|
||||||
|
|
||||||
namespace loc_core {
|
namespace loc_core {
|
||||||
|
|
||||||
|
class LocAdapterProxyBase;
|
||||||
|
|
||||||
class LocAdapterBase {
|
class LocAdapterBase {
|
||||||
protected:
|
protected:
|
||||||
const LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
|
const LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
|
||||||
ContextBase* mContext;
|
ContextBase* mContext;
|
||||||
LocApiBase* mLocApi;
|
LocApiBase* mLocApi;
|
||||||
|
LocAdapterProxyBase* mLocAdapterProxyBase;
|
||||||
const MsgTask* mMsgTask;
|
const MsgTask* mMsgTask;
|
||||||
|
|
||||||
inline LocAdapterBase(const MsgTask* msgTask) :
|
inline LocAdapterBase(const MsgTask* msgTask) :
|
||||||
mEvtMask(0), mContext(NULL), mLocApi(NULL), mMsgTask(msgTask) {}
|
mEvtMask(0), mContext(NULL), mLocApi(NULL), mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}
|
||||||
public:
|
public:
|
||||||
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
|
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
|
||||||
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||||
ContextBase* context);
|
ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL);
|
||||||
inline LOC_API_ADAPTER_EVENT_MASK_T
|
inline LOC_API_ADAPTER_EVENT_MASK_T
|
||||||
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
|
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
|
||||||
return mEvtMask & mask;
|
return mEvtMask & mask;
|
||||||
|
@ -68,7 +71,7 @@ public:
|
||||||
// This will be overridden by the individual adapters
|
// This will be overridden by the individual adapters
|
||||||
// if necessary.
|
// if necessary.
|
||||||
inline virtual void setUlpProxy(UlpProxyBase* ulp) {}
|
inline virtual void setUlpProxy(UlpProxyBase* ulp) {}
|
||||||
inline virtual void handleEngineUpEvent() {}
|
virtual void handleEngineUpEvent();
|
||||||
virtual void handleEngineDownEvent();
|
virtual void handleEngineDownEvent();
|
||||||
inline virtual void setPositionModeInt(LocPosMode& posMode) {}
|
inline virtual void setPositionModeInt(LocPosMode& posMode) {}
|
||||||
virtual void startFixInt() {}
|
virtual void startFixInt() {}
|
||||||
|
|
56
core/LocAdapterProxyBase.h
Normal file
56
core/LocAdapterProxyBase.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/* Copyright (c) 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LOC_ADAPTER_PROXY_BASE_H
|
||||||
|
#define LOC_ADAPTER_PROXY_BASE_H
|
||||||
|
|
||||||
|
#include <ContextBase.h>
|
||||||
|
#include <gps_extended.h>
|
||||||
|
|
||||||
|
namespace loc_core {
|
||||||
|
|
||||||
|
class LocAdapterProxyBase {
|
||||||
|
private:
|
||||||
|
const LocAdapterBase *mLocAdapterBase;
|
||||||
|
protected:
|
||||||
|
inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||||
|
ContextBase* context):
|
||||||
|
mLocAdapterBase(new LocAdapterBase(mask, context, this)) {
|
||||||
|
}
|
||||||
|
inline virtual ~LocAdapterProxyBase() {
|
||||||
|
delete mLocAdapterBase;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
inline virtual void handleEngineUpEvent() {};
|
||||||
|
inline virtual void handleEngineDownEvent() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace loc_core
|
||||||
|
|
||||||
|
#endif //LOC_ADAPTER_PROXY_BASE_H
|
|
@ -404,7 +404,8 @@ 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::
|
||||||
setSensorControlConfig(int sensorUsage)
|
setSensorControlConfig(int sensorUsage,
|
||||||
|
int sensorProvider)
|
||||||
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::
|
||||||
|
|
|
@ -158,7 +158,7 @@ public:
|
||||||
virtual enum loc_api_adapter_err
|
virtual enum loc_api_adapter_err
|
||||||
setLPPConfig(uint32_t profile);
|
setLPPConfig(uint32_t profile);
|
||||||
virtual enum loc_api_adapter_err
|
virtual enum loc_api_adapter_err
|
||||||
setSensorControlConfig(int sensorUsage);
|
setSensorControlConfig(int sensorUsage, int sensorProvider);
|
||||||
virtual enum loc_api_adapter_err
|
virtual enum loc_api_adapter_err
|
||||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
|
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
|
||||||
float gyroBiasVarianceRandomWalk,
|
float gyroBiasVarianceRandomWalk,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2013-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
|
||||||
|
@ -37,11 +37,19 @@ class LocAdapterBase;
|
||||||
|
|
||||||
class UlpProxyBase {
|
class UlpProxyBase {
|
||||||
public:
|
public:
|
||||||
inline UlpProxyBase() {}
|
LocPosMode mPosMode;
|
||||||
|
bool mFixSet;
|
||||||
|
inline UlpProxyBase() {
|
||||||
|
mPosMode.mode = LOC_POSITION_MODE_INVALID;
|
||||||
|
mFixSet = false;
|
||||||
|
}
|
||||||
inline virtual ~UlpProxyBase() {}
|
inline virtual ~UlpProxyBase() {}
|
||||||
inline virtual bool sendStartFix() { return false;}
|
inline virtual bool sendStartFix() { mFixSet = true; return false; }
|
||||||
inline virtual bool sendStopFix() { return false;}
|
inline virtual bool sendStopFix() { mFixSet = false; return false; }
|
||||||
inline virtual bool sendFixMode(LocPosMode ¶ms) { return false;}
|
inline virtual bool sendFixMode(LocPosMode ¶ms) {
|
||||||
|
mPosMode = params;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
inline virtual bool reportPosition(UlpLocation &location,
|
inline virtual bool reportPosition(UlpLocation &location,
|
||||||
GpsLocationExtended &locationExtended,
|
GpsLocationExtended &locationExtended,
|
||||||
void* locationExt,
|
void* locationExt,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2013-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
|
||||||
|
@ -61,6 +61,8 @@ extern "C" {
|
||||||
|
|
||||||
#define ULP_MIN_INTERVAL_INVALID 0xffffffff
|
#define ULP_MIN_INTERVAL_INVALID 0xffffffff
|
||||||
|
|
||||||
|
/*Emergency SUPL*/
|
||||||
|
#define GPS_NI_TYPE_EMERGENCY_SUPL 4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** set to sizeof(UlpLocation) */
|
/** set to sizeof(UlpLocation) */
|
||||||
|
@ -306,6 +308,7 @@ enum loc_api_adapter_event_index {
|
||||||
LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA, // Wifi ap data
|
LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA, // Wifi ap data
|
||||||
LOC_API_ADAPTER_BATCH_FULL, // Batching on full
|
LOC_API_ADAPTER_BATCH_FULL, // Batching on full
|
||||||
LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix
|
LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix
|
||||||
|
LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT, //
|
||||||
|
|
||||||
LOC_API_ADAPTER_EVENT_MAX
|
LOC_API_ADAPTER_EVENT_MAX
|
||||||
};
|
};
|
||||||
|
@ -326,6 +329,7 @@ enum loc_api_adapter_event_index {
|
||||||
#define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
|
#define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
|
||||||
#define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
|
#define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
|
||||||
#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
|
#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
|
||||||
|
#define LOC_API_ADAPTER_BIT_BATCHED_GENFENCE_BREACH_REPORT (1<<LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT)
|
||||||
#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
|
#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
|
||||||
#define LOC_API_ADAPTER_BIT_MOTION_CTRL (1<<LOC_API_ADAPTER_MOTION_CTRL)
|
#define LOC_API_ADAPTER_BIT_MOTION_CTRL (1<<LOC_API_ADAPTER_MOTION_CTRL)
|
||||||
#define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
|
#define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
|
||||||
|
|
|
@ -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
|
||||||
|
@ -161,7 +161,8 @@ static loc_name_val_s_type loc_eng_ni_types[] =
|
||||||
{
|
{
|
||||||
NAME_VAL( GPS_NI_TYPE_VOICE ),
|
NAME_VAL( GPS_NI_TYPE_VOICE ),
|
||||||
NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
|
NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
|
||||||
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE )
|
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ),
|
||||||
|
NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL )
|
||||||
};
|
};
|
||||||
static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
|
static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ INTERMEDIATE_POS=0
|
||||||
# supl version 1.0
|
# supl version 1.0
|
||||||
SUPL_VER=0x10000
|
SUPL_VER=0x10000
|
||||||
|
|
||||||
|
# Emergency SUPL, 1=enable, 0=disable
|
||||||
|
SUPL_ES=1
|
||||||
|
|
||||||
# GPS Capabilities bit mask
|
# GPS Capabilities bit mask
|
||||||
# SCHEDULING = 0x01
|
# SCHEDULING = 0x01
|
||||||
# MSB = 0x02
|
# MSB = 0x02
|
||||||
|
|
|
@ -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
|
||||||
|
@ -52,22 +52,6 @@ void LocInternalAdapter::stopFixInt() {
|
||||||
void LocInternalAdapter::getZppInt() {
|
void LocInternalAdapter::getZppInt() {
|
||||||
sendMsg(new LocEngGetZpp(mLocEngAdapter));
|
sendMsg(new LocEngGetZpp(mLocEngAdapter));
|
||||||
}
|
}
|
||||||
void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
|
|
||||||
struct LocSetUlpProxy : public LocMsg {
|
|
||||||
LocAdapterBase* mAdapter;
|
|
||||||
UlpProxyBase* mUlp;
|
|
||||||
inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) :
|
|
||||||
LocMsg(), mAdapter(adapter), mUlp(ulp) {
|
|
||||||
}
|
|
||||||
virtual void proc() const {
|
|
||||||
LOC_LOGV("%s] ulp %p adapter %p", __func__,
|
|
||||||
mUlp, mAdapter);
|
|
||||||
mAdapter->setUlpProxy(mUlp);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp));
|
|
||||||
}
|
|
||||||
|
|
||||||
LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
|
LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||||
void* owner, ContextBase* context,
|
void* owner, ContextBase* context,
|
||||||
|
@ -95,6 +79,23 @@ LocEngAdapter::~LocEngAdapter()
|
||||||
LOC_LOGV("LocEngAdapter deleted");
|
LOC_LOGV("LocEngAdapter deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
|
||||||
|
struct LocSetUlpProxy : public LocMsg {
|
||||||
|
LocAdapterBase* mAdapter;
|
||||||
|
UlpProxyBase* mUlp;
|
||||||
|
inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) :
|
||||||
|
LocMsg(), mAdapter(adapter), mUlp(ulp) {
|
||||||
|
}
|
||||||
|
virtual void proc() const {
|
||||||
|
LOC_LOGV("%s] ulp %p adapter %p", __func__,
|
||||||
|
mUlp, mAdapter);
|
||||||
|
mAdapter->setUlpProxy(mUlp);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp));
|
||||||
|
}
|
||||||
|
|
||||||
void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
|
void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
|
||||||
{
|
{
|
||||||
if (ulp == mUlp) {
|
if (ulp == mUlp) {
|
||||||
|
@ -102,18 +103,24 @@ void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
|
||||||
//and we get the same object back for UlpProxyBase . Do nothing
|
//and we get the same object back for UlpProxyBase . Do nothing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete mUlp;
|
|
||||||
LOC_LOGV("%s] %p", __func__, ulp);
|
LOC_LOGV("%s] %p", __func__, ulp);
|
||||||
if (NULL == ulp) {
|
if (NULL == ulp) {
|
||||||
|
LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__);
|
||||||
ulp = new UlpProxyBase();
|
ulp = new UlpProxyBase();
|
||||||
}
|
}
|
||||||
mUlp = ulp;
|
|
||||||
|
|
||||||
if (LOC_POSITION_MODE_INVALID != mFixCriteria.mode) {
|
if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) {
|
||||||
// need to send this mode and start msg to ULP
|
// need to send this mode and start msg to ULP
|
||||||
mUlp->sendFixMode(mFixCriteria);
|
ulp->sendFixMode(mUlp->mPosMode);
|
||||||
mUlp->sendStartFix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mUlp->mFixSet) {
|
||||||
|
ulp->sendStartFix();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete mUlp;
|
||||||
|
mUlp = ulp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocInternalAdapter::reportPosition(UlpLocation &location,
|
void LocInternalAdapter::reportPosition(UlpLocation &location,
|
||||||
|
@ -294,4 +301,3 @@ void LocEngAdapter::handleEngineUpEvent()
|
||||||
{
|
{
|
||||||
sendMsg(new LocEngUp(mOwner));
|
sendMsg(new LocEngUp(mOwner));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,9 +185,9 @@ public:
|
||||||
return mLocApi->setLPPConfig(profile);
|
return mLocApi->setLPPConfig(profile);
|
||||||
}
|
}
|
||||||
inline enum loc_api_adapter_err
|
inline enum loc_api_adapter_err
|
||||||
setSensorControlConfig(int sensorUsage)
|
setSensorControlConfig(int sensorUsage, int sensorProvider)
|
||||||
{
|
{
|
||||||
return mLocApi->setSensorControlConfig(sensorUsage);
|
return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider);
|
||||||
}
|
}
|
||||||
inline enum loc_api_adapter_err
|
inline enum loc_api_adapter_err
|
||||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
|
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2009-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
|
||||||
|
@ -118,6 +118,7 @@ static loc_param_s_type loc_parameter_table[] =
|
||||||
{"QUIPC_ENABLED", &gps_conf.QUIPC_ENABLED, 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'},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void loc_default_parameters(void)
|
static void loc_default_parameters(void)
|
||||||
|
@ -160,6 +161,9 @@ static void loc_default_parameters(void)
|
||||||
|
|
||||||
/*By default no positioning protocol is selected on A-GLONASS system*/
|
/*By default no positioning protocol is selected on A-GLONASS system*/
|
||||||
gps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
|
gps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
|
||||||
|
|
||||||
|
/* default provider is SSC */
|
||||||
|
sap_conf.SENSOR_PROVIDER = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd half of init(), singled out for
|
// 2nd half of init(), singled out for
|
||||||
|
@ -497,18 +501,20 @@ struct LocEngLppConfig : public LocMsg {
|
||||||
struct LocEngSensorControlConfig : public LocMsg {
|
struct LocEngSensorControlConfig : public LocMsg {
|
||||||
LocEngAdapter* mAdapter;
|
LocEngAdapter* mAdapter;
|
||||||
const int mSensorsDisabled;
|
const int mSensorsDisabled;
|
||||||
|
const int mSensorProvider;
|
||||||
inline LocEngSensorControlConfig(LocEngAdapter* adapter,
|
inline LocEngSensorControlConfig(LocEngAdapter* adapter,
|
||||||
int sensorsDisabled) :
|
int sensorsDisabled, int sensorProvider) :
|
||||||
LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled)
|
LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled),
|
||||||
|
mSensorProvider(sensorProvider)
|
||||||
{
|
{
|
||||||
locallog();
|
locallog();
|
||||||
}
|
}
|
||||||
inline virtual void proc() const {
|
inline virtual void proc() const {
|
||||||
mAdapter->setSensorControlConfig(mSensorsDisabled);
|
mAdapter->setSensorControlConfig(mSensorsDisabled, mSensorProvider);
|
||||||
}
|
}
|
||||||
inline void locallog() const {
|
inline void locallog() const {
|
||||||
LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d",
|
LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d, Sensor Provider: %d",
|
||||||
mSensorsDisabled);
|
mSensorsDisabled, mSensorProvider);
|
||||||
}
|
}
|
||||||
inline virtual void log() const {
|
inline virtual void log() const {
|
||||||
locallog();
|
locallog();
|
||||||
|
@ -1554,7 +1560,8 @@ static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data)
|
||||||
LocEngAdapter* adapter = loc_eng_data.adapter;
|
LocEngAdapter* adapter = loc_eng_data.adapter;
|
||||||
adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));
|
adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));
|
||||||
adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));
|
adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));
|
||||||
adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE));
|
adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE,
|
||||||
|
sap_conf.SENSOR_PROVIDER));
|
||||||
adapter->sendMsg(new LocEngAGlonassProtocol(adapter, gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));
|
adapter->sendMsg(new LocEngAGlonassProtocol(adapter, gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));
|
||||||
|
|
||||||
/* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */
|
/* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */
|
||||||
|
@ -2086,9 +2093,9 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call
|
||||||
AGPS_TYPE_SUPL,
|
AGPS_TYPE_SUPL,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
if (adapter->mAgpsEnabled) {
|
||||||
loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data));
|
loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data));
|
||||||
|
|
||||||
if (adapter->mAgpsEnabled) {
|
|
||||||
loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,
|
loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,
|
||||||
NULL, NULL, &loc_eng_data);
|
NULL, NULL, &loc_eng_data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@ typedef struct
|
||||||
double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
|
double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
|
||||||
uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
|
uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
|
||||||
double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
|
double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
|
||||||
|
unsigned long SENSOR_PROVIDER;
|
||||||
} loc_sap_cfg_s_type;
|
} loc_sap_cfg_s_type;
|
||||||
|
|
||||||
extern loc_gps_cfg_s_type gps_conf;
|
extern loc_gps_cfg_s_type gps_conf;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2011-2012,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,11 +33,11 @@
|
||||||
|
|
||||||
#ifdef _ANDROID_
|
#ifdef _ANDROID_
|
||||||
|
|
||||||
#define GPSONE_LOC_API_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_q"
|
#define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q"
|
||||||
#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_resp_q"
|
#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q"
|
||||||
#define QUIPC_CTRL_Q_PATH "/data/misc/gpsone_d/quipc_ctrl_q"
|
#define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q"
|
||||||
#define MSAPM_CTRL_Q_PATH "/data/misc/gpsone_d/msapm_ctrl_q"
|
#define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q"
|
||||||
#define MSAPU_CTRL_Q_PATH "/data/misc/gpsone_d/msapu_ctrl_q"
|
#define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2009-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
|
||||||
|
@ -218,6 +218,8 @@ static void* ni_thread_proc(void *args)
|
||||||
"pthread_cond_timedwait = %d\n",rc );
|
"pthread_cond_timedwait = %d\n",rc );
|
||||||
loc_eng_ni_data_p->respRecvd = FALSE; /* Reset the user response flag for the next session*/
|
loc_eng_ni_data_p->respRecvd = FALSE; /* Reset the user response flag for the next session*/
|
||||||
|
|
||||||
|
LOC_LOGD("loc_eng_ni_data_p->resp is %d\n",loc_eng_ni_data_p->resp);
|
||||||
|
|
||||||
// adding this check to support modem restart, in which case, we need the thread
|
// adding this check to support modem restart, in which case, we need the thread
|
||||||
// to exit without calling sending data. We made sure that rawRequest is NULL in
|
// to exit without calling sending data. We made sure that rawRequest is NULL in
|
||||||
// loc_eng_ni_reset_on_engine_restart()
|
// loc_eng_ni_reset_on_engine_restart()
|
||||||
|
@ -225,9 +227,14 @@ static void* ni_thread_proc(void *args)
|
||||||
LocEngInformNiResponse *msg = NULL;
|
LocEngInformNiResponse *msg = NULL;
|
||||||
|
|
||||||
if (NULL != loc_eng_ni_data_p->rawRequest) {
|
if (NULL != loc_eng_ni_data_p->rawRequest) {
|
||||||
|
if (loc_eng_ni_data_p->resp != GPS_NI_RESPONSE_IGNORE) {
|
||||||
|
LOC_LOGD("loc_eng_ni_data_p->resp != GPS_NI_RESPONSE_IGNORE \n");
|
||||||
msg = new LocEngInformNiResponse(adapter,
|
msg = new LocEngInformNiResponse(adapter,
|
||||||
loc_eng_ni_data_p->resp,
|
loc_eng_ni_data_p->resp,
|
||||||
loc_eng_ni_data_p->rawRequest);
|
loc_eng_ni_data_p->rawRequest);
|
||||||
|
} else {
|
||||||
|
LOC_LOGD("this is the ignore reply for SUPL ES\n");
|
||||||
|
}
|
||||||
loc_eng_ni_data_p->rawRequest = NULL;
|
loc_eng_ni_data_p->rawRequest = NULL;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
|
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
|
||||||
|
@ -236,6 +243,7 @@ static void* ni_thread_proc(void *args)
|
||||||
loc_eng_ni_data_p->reqID++;
|
loc_eng_ni_data_p->reqID++;
|
||||||
|
|
||||||
if (NULL != msg) {
|
if (NULL != msg) {
|
||||||
|
LOC_LOGD("ni_thread_proc: adapter->sendMsg(msg)\n");
|
||||||
adapter->sendMsg(msg);
|
adapter->sendMsg(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2009,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
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
|
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
|
||||||
#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
|
#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
|
||||||
|
#define GPS_NI_RESPONSE_IGNORE 4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
pthread_t thread; /* NI thread */
|
pthread_t thread; /* NI thread */
|
||||||
|
|
|
@ -19,7 +19,8 @@ LOCAL_SRC_FILES += \
|
||||||
linked_list.c \
|
linked_list.c \
|
||||||
loc_target.cpp \
|
loc_target.cpp \
|
||||||
loc_timer.c \
|
loc_timer.c \
|
||||||
../platform_lib_abstractions/elapsed_millis_since_boot.cpp
|
../platform_lib_abstractions/elapsed_millis_since_boot.cpp \
|
||||||
|
loc_misc_utils.cpp
|
||||||
|
|
||||||
LOCAL_CFLAGS += \
|
LOCAL_CFLAGS += \
|
||||||
-fno-short-enums \
|
-fno-short-enums \
|
||||||
|
@ -46,7 +47,8 @@ LOCAL_COPY_HEADERS:= \
|
||||||
loc_timer.h \
|
loc_timer.h \
|
||||||
../platform_lib_abstractions/platform_lib_includes.h \
|
../platform_lib_abstractions/platform_lib_includes.h \
|
||||||
../platform_lib_abstractions/platform_lib_time.h \
|
../platform_lib_abstractions/platform_lib_time.h \
|
||||||
../platform_lib_abstractions/platform_lib_macros.h
|
../platform_lib_abstractions/platform_lib_macros.h \
|
||||||
|
loc_misc_utils.h
|
||||||
|
|
||||||
LOCAL_MODULE := libgps.utils
|
LOCAL_MODULE := libgps.utils
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <loc_cfg.h>
|
#include <loc_cfg.h>
|
||||||
#include <log_util.h>
|
#include <log_util.h>
|
||||||
|
#include <loc_misc_utils.h>
|
||||||
#ifdef USE_GLIB
|
#ifdef USE_GLIB
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,54 +63,9 @@ static loc_param_s_type loc_parameter_table[] =
|
||||||
};
|
};
|
||||||
int loc_param_num = sizeof(loc_parameter_table) / sizeof(loc_param_s_type);
|
int loc_param_num = sizeof(loc_parameter_table) / sizeof(loc_param_s_type);
|
||||||
|
|
||||||
/*===========================================================================
|
|
||||||
FUNCTION trim_space
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
Removes leading and trailing spaces of the string
|
|
||||||
|
|
||||||
DEPENDENCIES
|
|
||||||
N/A
|
|
||||||
|
|
||||||
RETURN VALUE
|
|
||||||
None
|
|
||||||
|
|
||||||
SIDE EFFECTS
|
|
||||||
N/A
|
|
||||||
===========================================================================*/
|
|
||||||
void trim_space(char *org_string)
|
|
||||||
{
|
|
||||||
char *scan_ptr, *write_ptr;
|
|
||||||
char *first_nonspace = NULL, *last_nonspace = NULL;
|
|
||||||
|
|
||||||
scan_ptr = write_ptr = org_string;
|
|
||||||
|
|
||||||
while (*scan_ptr)
|
|
||||||
{
|
|
||||||
if ( !isspace(*scan_ptr) && first_nonspace == NULL)
|
|
||||||
{
|
|
||||||
first_nonspace = scan_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first_nonspace != NULL)
|
|
||||||
{
|
|
||||||
*(write_ptr++) = *scan_ptr;
|
|
||||||
if ( !isspace(*scan_ptr))
|
|
||||||
{
|
|
||||||
last_nonspace = write_ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scan_ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (last_nonspace) { *last_nonspace = '\0'; }
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct loc_param_v_type
|
typedef struct loc_param_v_type
|
||||||
{
|
{
|
||||||
char* param_name;
|
char* param_name;
|
||||||
|
|
||||||
char* param_str_value;
|
char* param_str_value;
|
||||||
int param_int_value;
|
int param_int_value;
|
||||||
double param_double_value;
|
double param_double_value;
|
||||||
|
@ -136,12 +92,13 @@ RETURN VALUE
|
||||||
SIDE EFFECTS
|
SIDE EFFECTS
|
||||||
N/A
|
N/A
|
||||||
===========================================================================*/
|
===========================================================================*/
|
||||||
void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
|
int loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
|
||||||
{
|
{
|
||||||
|
int ret=-1;
|
||||||
if(NULL == config_entry || NULL == config_value)
|
if(NULL == config_entry || NULL == config_value)
|
||||||
{
|
{
|
||||||
LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
|
LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
|
if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
|
||||||
|
@ -166,6 +123,7 @@ void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* conf
|
||||||
{
|
{
|
||||||
*(config_entry->param_set) = 1;
|
*(config_entry->param_set) = 1;
|
||||||
}
|
}
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
*((int *)config_entry->param_ptr) = config_value->param_int_value;
|
*((int *)config_entry->param_ptr) = config_value->param_int_value;
|
||||||
|
@ -176,6 +134,7 @@ void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* conf
|
||||||
{
|
{
|
||||||
*(config_entry->param_set) = 1;
|
*(config_entry->param_set) = 1;
|
||||||
}
|
}
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
*((double *)config_entry->param_ptr) = config_value->param_double_value;
|
*((double *)config_entry->param_ptr) = config_value->param_double_value;
|
||||||
|
@ -186,11 +145,113 @@ void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* conf
|
||||||
{
|
{
|
||||||
*(config_entry->param_set) = 1;
|
*(config_entry->param_set) = 1;
|
||||||
}
|
}
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
|
LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
FUNCTION loc_read_conf_r (repetitive)
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Reads the specified configuration file and sets defined values based on
|
||||||
|
the passed in configuration table. This table maps strings to values to
|
||||||
|
set along with the type of each of these values.
|
||||||
|
The difference between this and loc_read_conf is that this function returns
|
||||||
|
the file pointer position at the end of filling a config table. Also, it
|
||||||
|
reads a fixed number of parameters at a time which is equal to the length
|
||||||
|
of the configuration table. This functionality enables the caller to
|
||||||
|
repeatedly call the function to read data from the same file.
|
||||||
|
|
||||||
|
PARAMETERS:
|
||||||
|
conf_fp : file pointer
|
||||||
|
config_table: table definition of strings to places to store information
|
||||||
|
table_length: length of the configuration table
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
N/A
|
||||||
|
|
||||||
|
RETURN VALUE
|
||||||
|
0: Table filled successfully
|
||||||
|
1: No more parameters to read
|
||||||
|
-1: Error filling table
|
||||||
|
|
||||||
|
SIDE EFFECTS
|
||||||
|
N/A
|
||||||
|
===========================================================================*/
|
||||||
|
int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length)
|
||||||
|
{
|
||||||
|
char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
|
||||||
|
char *lasts;
|
||||||
|
loc_param_v_type config_value;
|
||||||
|
uint32_t i;
|
||||||
|
int ret=0;
|
||||||
|
|
||||||
|
unsigned int num_params=table_length;
|
||||||
|
if(conf_fp == NULL) {
|
||||||
|
LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__);
|
||||||
|
ret = -1;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear all validity bits */
|
||||||
|
for(i = 0; NULL != config_table && i < table_length; i++)
|
||||||
|
{
|
||||||
|
if(NULL != config_table[i].param_set)
|
||||||
|
{
|
||||||
|
*(config_table[i].param_set) = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
|
||||||
|
while(num_params)
|
||||||
|
{
|
||||||
|
if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) {
|
||||||
|
LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&config_value, 0, sizeof(config_value));
|
||||||
|
|
||||||
|
/* Separate variable and value */
|
||||||
|
config_value.param_name = strtok_r(input_buf, "=", &lasts);
|
||||||
|
/* skip lines that do not contain "=" */
|
||||||
|
if (config_value.param_name == NULL) continue;
|
||||||
|
config_value.param_str_value = strtok_r(NULL, "=", &lasts);
|
||||||
|
/* skip lines that do not contain two operands */
|
||||||
|
if (config_value.param_str_value == NULL) continue;
|
||||||
|
|
||||||
|
/* Trim leading and trailing spaces */
|
||||||
|
loc_util_trim_space(config_value.param_name);
|
||||||
|
loc_util_trim_space(config_value.param_str_value);
|
||||||
|
|
||||||
|
/* Parse numerical value */
|
||||||
|
if ((strlen(config_value.param_str_value) >=3) &&
|
||||||
|
(config_value.param_str_value[0] == '0') &&
|
||||||
|
(tolower(config_value.param_str_value[1]) == 'x'))
|
||||||
|
{
|
||||||
|
/* hex */
|
||||||
|
config_value.param_int_value = (int) strtol(&config_value.param_str_value[2],
|
||||||
|
(char**) NULL, 16);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
|
||||||
|
config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; NULL != config_table && i < table_length; i++)
|
||||||
|
{
|
||||||
|
if(!loc_set_config_entry(&config_table[i], &config_value)) {
|
||||||
|
num_params--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================
|
/*===========================================================================
|
||||||
|
@ -215,7 +276,8 @@ RETURN VALUE
|
||||||
SIDE EFFECTS
|
SIDE EFFECTS
|
||||||
N/A
|
N/A
|
||||||
===========================================================================*/
|
===========================================================================*/
|
||||||
void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, uint32_t table_length)
|
void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table,
|
||||||
|
uint32_t table_length)
|
||||||
{
|
{
|
||||||
FILE *gps_conf_fp = NULL;
|
FILE *gps_conf_fp = NULL;
|
||||||
char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
|
char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
|
||||||
|
@ -226,61 +288,13 @@ void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, u
|
||||||
if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
|
if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
|
||||||
{
|
{
|
||||||
LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
|
LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
|
||||||
|
if(table_length && config_table) {
|
||||||
|
loc_read_conf_r(gps_conf_fp, config_table, table_length);
|
||||||
|
rewind(gps_conf_fp);
|
||||||
}
|
}
|
||||||
else
|
loc_read_conf_r(gps_conf_fp, loc_parameter_table, loc_param_num);
|
||||||
{
|
|
||||||
LOC_LOGW("%s: no %s file found", __FUNCTION__, conf_file_name);
|
|
||||||
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
|
|
||||||
return; /* no parameter file */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear all validity bits */
|
|
||||||
for(i = 0; NULL != config_table && i < table_length; i++)
|
|
||||||
{
|
|
||||||
if(NULL != config_table[i].param_set)
|
|
||||||
{
|
|
||||||
*(config_table[i].param_set) = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(fgets(input_buf, LOC_MAX_PARAM_LINE, gps_conf_fp) != NULL)
|
|
||||||
{
|
|
||||||
memset(&config_value, 0, sizeof(config_value));
|
|
||||||
|
|
||||||
/* Separate variable and value */
|
|
||||||
config_value.param_name = strtok_r(input_buf, "=", &lasts);
|
|
||||||
if (config_value.param_name == NULL) continue; /* skip lines that do not contain "=" */
|
|
||||||
config_value.param_str_value = strtok_r(NULL, "=", &lasts);
|
|
||||||
if (config_value.param_str_value == NULL) continue; /* skip lines that do not contain two operands */
|
|
||||||
|
|
||||||
/* Trim leading and trailing spaces */
|
|
||||||
trim_space(config_value.param_name);
|
|
||||||
trim_space(config_value.param_str_value);
|
|
||||||
|
|
||||||
/* Parse numerical value */
|
|
||||||
if (config_value.param_str_value[0] == '0' && tolower(config_value.param_str_value[1]) == 'x')
|
|
||||||
{
|
|
||||||
/* hex */
|
|
||||||
config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], (char**) NULL, 16);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
|
|
||||||
config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; NULL != config_table && i < table_length; i++)
|
|
||||||
{
|
|
||||||
loc_set_config_entry(&config_table[i], &config_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < loc_param_num; i++)
|
|
||||||
{
|
|
||||||
loc_set_config_entry(&loc_parameter_table[i], &config_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(gps_conf_fp);
|
fclose(gps_conf_fp);
|
||||||
|
}
|
||||||
/* Initialize logging mechanism with parsed data */
|
/* Initialize logging mechanism with parsed data */
|
||||||
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
|
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
#ifndef LOC_CFG_H
|
#ifndef LOC_CFG_H
|
||||||
#define LOC_CFG_H
|
#define LOC_CFG_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define LOC_MAX_PARAM_NAME 48
|
#define LOC_MAX_PARAM_NAME 48
|
||||||
|
@ -75,7 +76,7 @@ extern "C" {
|
||||||
extern void loc_read_conf(const char* conf_file_name,
|
extern void loc_read_conf(const char* conf_file_name,
|
||||||
loc_param_s_type* config_table,
|
loc_param_s_type* config_table,
|
||||||
uint32_t table_length);
|
uint32_t table_length);
|
||||||
|
extern int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
114
utils/loc_misc_utils.cpp
Normal file
114
utils/loc_misc_utils.cpp
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
/* Copyright (c) 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <log_util.h>
|
||||||
|
#include <loc_misc_utils.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#define LOG_NDDEBUG 0
|
||||||
|
#define LOG_TAG "LocSvc_misc_utils"
|
||||||
|
|
||||||
|
int loc_util_split_string(char *raw_string, char **split_strings_ptr,
|
||||||
|
int max_num_substrings, char delimiter)
|
||||||
|
{
|
||||||
|
int raw_string_index=0;
|
||||||
|
int num_split_strings=0;
|
||||||
|
unsigned char end_string=0;
|
||||||
|
int raw_string_length=0;
|
||||||
|
|
||||||
|
if(!raw_string || !split_strings_ptr) {
|
||||||
|
LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__);
|
||||||
|
num_split_strings = -1;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string);
|
||||||
|
raw_string_length = strlen(raw_string) + 1;
|
||||||
|
split_strings_ptr[num_split_strings] = &raw_string[raw_string_index];
|
||||||
|
for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) {
|
||||||
|
if(raw_string[raw_string_index] == '\0')
|
||||||
|
end_string=1;
|
||||||
|
if((raw_string[raw_string_index] == delimiter) || end_string) {
|
||||||
|
raw_string[raw_string_index] = '\0';
|
||||||
|
LOC_LOGD("%s:%d]: split string: %s\n",
|
||||||
|
__func__, __LINE__, split_strings_ptr[num_split_strings]);
|
||||||
|
num_split_strings++;
|
||||||
|
if(((raw_string_index + 1) < raw_string_length) &&
|
||||||
|
(num_split_strings < max_num_substrings)) {
|
||||||
|
split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(end_string)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
err:
|
||||||
|
LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings);
|
||||||
|
return num_split_strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loc_util_trim_space(char *org_string)
|
||||||
|
{
|
||||||
|
char *scan_ptr, *write_ptr;
|
||||||
|
char *first_nonspace = NULL, *last_nonspace = NULL;
|
||||||
|
|
||||||
|
if(org_string == NULL) {
|
||||||
|
LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
scan_ptr = write_ptr = org_string;
|
||||||
|
|
||||||
|
while (*scan_ptr) {
|
||||||
|
//Find the first non-space character
|
||||||
|
if ( !isspace(*scan_ptr) && first_nonspace == NULL) {
|
||||||
|
first_nonspace = scan_ptr;
|
||||||
|
}
|
||||||
|
//Once the first non-space character is found in the
|
||||||
|
//above check, keep shifting the characters to the left
|
||||||
|
//to replace the spaces
|
||||||
|
if (first_nonspace != NULL) {
|
||||||
|
*(write_ptr++) = *scan_ptr;
|
||||||
|
//Keep track of which was the last non-space character
|
||||||
|
//encountered
|
||||||
|
//last_nonspace will not be updated in the case where
|
||||||
|
//the string ends with spaces
|
||||||
|
if ( !isspace(*scan_ptr)) {
|
||||||
|
last_nonspace = write_ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scan_ptr++;
|
||||||
|
}
|
||||||
|
//Add NULL terminator after the last non-space character
|
||||||
|
if (last_nonspace) { *last_nonspace = '\0'; }
|
||||||
|
err:
|
||||||
|
return;
|
||||||
|
}
|
99
utils/loc_misc_utils.h
Normal file
99
utils/loc_misc_utils.h
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
/* Copyright (c) 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation, nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef _LOC_MISC_UTILS_H_
|
||||||
|
#define _LOC_MISC_UTILS_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
FUNCTION loc_split_string
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
This function is used to split a delimiter separated string into
|
||||||
|
sub-strings. This function does not allocate new memory to store the split
|
||||||
|
strings. Instead, it places '\0' in places of delimiters and assings the
|
||||||
|
starting address of the substring within the raw string as the string address
|
||||||
|
The input raw_string no longer remains to be a collection of sub-strings
|
||||||
|
after this function is executed.
|
||||||
|
Please make a copy of the input string before calling this function if
|
||||||
|
necessary
|
||||||
|
|
||||||
|
PARAMETERS:
|
||||||
|
char *raw_string: is the original string with delimiter separated substrings
|
||||||
|
char **split_strings_ptr: is the arraw of pointers which will hold the addresses
|
||||||
|
of individual substrings
|
||||||
|
int max_num_substrings: is the maximum number of substrings that are expected
|
||||||
|
by the caller. The array of pointers in the above parameter
|
||||||
|
is usually this long
|
||||||
|
char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';'
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
N/A
|
||||||
|
|
||||||
|
RETURN VALUE
|
||||||
|
int Number of split strings
|
||||||
|
|
||||||
|
SIDE EFFECTS
|
||||||
|
The input raw_string no longer remains a delimiter separated single string.
|
||||||
|
|
||||||
|
EXAMPLE
|
||||||
|
delimiter = ' ' //space
|
||||||
|
raw_string = "hello new user" //delimiter is space ' '
|
||||||
|
addresses = 0123456789abcd
|
||||||
|
split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello"
|
||||||
|
split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new"
|
||||||
|
split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user"
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings,
|
||||||
|
char delimiter);
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
FUNCTION trim_space
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Removes leading and trailing spaces of the string
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
N/A
|
||||||
|
|
||||||
|
RETURN VALUE
|
||||||
|
None
|
||||||
|
|
||||||
|
SIDE EFFECTS
|
||||||
|
N/A
|
||||||
|
===========================================================================*/
|
||||||
|
void loc_util_trim_space(char *org_string);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //_LOC_MISC_UTILS_H_
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2012-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
|
||||||
|
@ -56,7 +56,10 @@
|
||||||
#define LENGTH(s) (sizeof(s) - 1)
|
#define LENGTH(s) (sizeof(s) - 1)
|
||||||
#define GPS_CHECK_NO_ERROR 0
|
#define GPS_CHECK_NO_ERROR 0
|
||||||
#define GPS_CHECK_NO_GPS_HW 1
|
#define GPS_CHECK_NO_GPS_HW 1
|
||||||
#define QCA1530_DETECT_TIMEOUT 30
|
/* When system server is started, it uses 20 seconds as ActivityManager
|
||||||
|
* timeout. After that it sends SIGSTOP signal to process.
|
||||||
|
*/
|
||||||
|
#define QCA1530_DETECT_TIMEOUT 15
|
||||||
#define QCA1530_DETECT_PRESENT "yes"
|
#define QCA1530_DETECT_PRESENT "yes"
|
||||||
#define QCA1530_DETECT_PROGRESS "detect"
|
#define QCA1530_DETECT_PROGRESS "detect"
|
||||||
|
|
||||||
|
@ -98,7 +101,7 @@ static int read_a_line(const char * file_path, char * line, int line_size)
|
||||||
*/
|
*/
|
||||||
static bool is_qca1530(void)
|
static bool is_qca1530(void)
|
||||||
{
|
{
|
||||||
static const char qca1530_property_name[] = "persist.qca1530";
|
static const char qca1530_property_name[] = "sys.qca1530";
|
||||||
bool res = false;
|
bool res = false;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
char buf[PROPERTY_VALUE_MAX];
|
char buf[PROPERTY_VALUE_MAX];
|
||||||
|
@ -141,6 +144,34 @@ static bool is_qca1530(void)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*The character array passed to this function should have length
|
||||||
|
of atleast PROPERTY_VALUE_MAX*/
|
||||||
|
void loc_get_target_baseband(char *baseband, int array_length)
|
||||||
|
{
|
||||||
|
if(baseband && (array_length >= PROPERTY_VALUE_MAX)) {
|
||||||
|
property_get("ro.baseband", baseband, "");
|
||||||
|
LOC_LOGD("%s:%d]: Baseband: %s\n", __func__, __LINE__, baseband);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOC_LOGE("%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*The character array passed to this function should have length
|
||||||
|
of atleast PROPERTY_VALUE_MAX*/
|
||||||
|
void loc_get_platform_name(char *platform_name, int array_length)
|
||||||
|
{
|
||||||
|
if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) {
|
||||||
|
property_get("ro.board.platform", platform_name, "");
|
||||||
|
LOC_LOGD("%s:%d]: Target name: %s\n", __func__, __LINE__, platform_name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int loc_get_target(void)
|
unsigned int loc_get_target(void)
|
||||||
{
|
{
|
||||||
if (gTarget != (unsigned int)-1)
|
if (gTarget != (unsigned int)-1)
|
||||||
|
@ -163,7 +194,8 @@ unsigned int loc_get_target(void)
|
||||||
goto detected;
|
goto detected;
|
||||||
}
|
}
|
||||||
|
|
||||||
property_get("ro.baseband", baseband, "");
|
loc_get_target_baseband(baseband, sizeof(baseband));
|
||||||
|
|
||||||
if (!access(hw_platform, F_OK)) {
|
if (!access(hw_platform, F_OK)) {
|
||||||
read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
|
read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2012-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
|
||||||
|
@ -45,6 +45,13 @@ extern "C"
|
||||||
|
|
||||||
unsigned int loc_get_target(void);
|
unsigned int loc_get_target(void);
|
||||||
|
|
||||||
|
/*The character array passed to this function should have length
|
||||||
|
of atleast PROPERTY_VALUE_MAX*/
|
||||||
|
void loc_get_target_baseband(char *baseband, int array_length);
|
||||||
|
/*The character array passed to this function should have length
|
||||||
|
of atleast PROPERTY_VALUE_MAX*/
|
||||||
|
void loc_get_platform_name(char *platform_name, int array_length);
|
||||||
|
|
||||||
/* Please remember to update 'target_name' in loc_log.cpp,
|
/* Please remember to update 'target_name' in loc_log.cpp,
|
||||||
if do any changes to this enum. */
|
if do any changes to this enum. */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2011 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
|
||||||
|
@ -96,24 +96,34 @@ extern char* get_timestamp(char* str, unsigned long buf_size);
|
||||||
if that value remains unchanged, it means gps.conf did not
|
if that value remains unchanged, it means gps.conf did not
|
||||||
provide a value and we default to the initial value to use
|
provide a value and we default to the initial value to use
|
||||||
Android's logging levels*/
|
Android's logging levels*/
|
||||||
|
#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||||
|
|
||||||
|
#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||||
|
|
||||||
|
#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||||
|
|
||||||
|
#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||||
|
|
||||||
|
#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5))
|
||||||
|
|
||||||
#define LOC_LOGE(...) \
|
#define LOC_LOGE(...) \
|
||||||
if ((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
|
IF_LOC_LOGE { ALOGE("E/"__VA_ARGS__); } \
|
||||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("W/"__VA_ARGS__); }
|
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("E/"__VA_ARGS__); }
|
||||||
|
|
||||||
#define LOC_LOGW(...) \
|
#define LOC_LOGW(...) \
|
||||||
if ((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
|
IF_LOC_LOGW { ALOGE("W/"__VA_ARGS__); } \
|
||||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/"__VA_ARGS__); }
|
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/"__VA_ARGS__); }
|
||||||
|
|
||||||
#define LOC_LOGI(...) \
|
#define LOC_LOGI(...) \
|
||||||
if ((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("I/"__VA_ARGS__); } \
|
IF_LOC_LOGI { ALOGE("I/"__VA_ARGS__); } \
|
||||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/"__VA_ARGS__); }
|
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/"__VA_ARGS__); }
|
||||||
|
|
||||||
#define LOC_LOGD(...) \
|
#define LOC_LOGD(...) \
|
||||||
if ((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("D/"__VA_ARGS__); } \
|
IF_LOC_LOGD { ALOGE("D/"__VA_ARGS__); } \
|
||||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/"__VA_ARGS__); }
|
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/"__VA_ARGS__); }
|
||||||
|
|
||||||
#define LOC_LOGV(...) \
|
#define LOC_LOGV(...) \
|
||||||
if ((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("V/"__VA_ARGS__); } \
|
IF_LOC_LOGV { ALOGE("V/"__VA_ARGS__); } \
|
||||||
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/"__VA_ARGS__); }
|
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/"__VA_ARGS__); }
|
||||||
|
|
||||||
#else /* DEBUG_DMN_LOC_API */
|
#else /* DEBUG_DMN_LOC_API */
|
||||||
|
|
Loading…
Reference in a new issue