Location Hal Design Level Change for FLP Requirement
Changes can be highlighted with below summary: * Split the original LocApiAdapter to LocAdapter and LocApi. Now different adapter implementations can flexibly connect to different LocApi; * LocApi continues to abstract the API binding to RPC or QMI; * MsgTask which creates and owns a msg Q and a thread, and it define a LocMsg base msg class. The handler pulls a msg out of the Q and calls its proc() method. This makes it possible for msg sender to keep the data in the msg encapsulated, as it no longer requires a central msg handler who must under- stand all data format. This used to be where all the compile time dependencies are tangled together; * Added Context to bundle MsgTask and LocApi; * Added LocDualContext specifically for the FLP Location Hal architecture requirement; * Placed all the base classes of the above in loc_core folder / loc_core namespace / libloc_core.so, so other libraries can easily use derive from here without having to pull in the loc_eng implementation, which is a large library to include or link to; Change-Id: I40abfba96dea76757c98530c1f5e076b34ba4ac7
This commit is contained in:
parent
e5e62728a2
commit
a915406668
40 changed files with 4617 additions and 2987 deletions
49
core/Android.mk
Normal file
49
core/Android.mk
Normal file
|
@ -0,0 +1,49 @@
|
|||
ifneq ($(BUILD_TINY_ANDROID),true)
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libloc_core
|
||||
LOCAL_MODULE_OWNER := qcom
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
libcutils \
|
||||
libgps.utils \
|
||||
libdl \
|
||||
libandroid_runtime
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
MsgTask.cpp \
|
||||
LocApiBase.cpp \
|
||||
LocAdapterBase.cpp \
|
||||
ContextBase.cpp \
|
||||
LocDualContext.cpp \
|
||||
loc_core_log.cpp
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-fno-short-enums \
|
||||
-D_ANDROID_
|
||||
|
||||
LOCAL_C_INCLUDES:= \
|
||||
$(TARGET_OUT_HEADERS)/gps.utils
|
||||
|
||||
LOCAL_COPY_HEADERS_TO:= libloc_core/
|
||||
LOCAL_COPY_HEADERS:= \
|
||||
MsgTask.h \
|
||||
LocApiBase.h \
|
||||
LocAdapterBase.h \
|
||||
ContextBase.h \
|
||||
LocDualContext.h \
|
||||
gps_extended_c.h \
|
||||
gps_extended.h \
|
||||
loc_core_log.h
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
endif # not BUILD_TINY_ANDROID
|
63
core/ContextBase.cpp
Normal file
63
core/ContextBase.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* Copyright (c) 2011-2013, 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.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_CtxBase"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <cutils/sched_policy.h>
|
||||
#include <unistd.h>
|
||||
#include <ContextBase.h>
|
||||
#include <msg_q.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_log.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
const char* ContextBase::mIzatLibName = "libloc_api_v02.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.
|
||||
void* ContextBase::mIzatLibHandle = (void*)1;
|
||||
|
||||
void* ContextBase::getIzatLibHandle()
|
||||
{
|
||||
if ((void*)1 == mIzatLibHandle) {
|
||||
mIzatLibHandle = dlopen(mIzatLibName, RTLD_NOW);
|
||||
}
|
||||
return mIzatLibHandle;
|
||||
}
|
||||
|
||||
ContextBase::ContextBase(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask) :
|
||||
mMsgTask(msgTask),
|
||||
mLocApi(LocApiBase::create(mMsgTask, exMask, getIzatLibHandle()))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
61
core/ContextBase.h
Normal file
61
core/ContextBase.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* Copyright (c) 2011-2013, 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_CONTEXT_BASE__
|
||||
#define __LOC_CONTEXT_BASE__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
#include <MsgTask.h>
|
||||
#include <LocApiBase.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
class LocAdapterBase;
|
||||
|
||||
class ContextBase {
|
||||
static const char* mIzatLibName;
|
||||
static void* mIzatLibHandle;
|
||||
protected:
|
||||
const MsgTask* mMsgTask;
|
||||
LocApiBase* mLocApi;
|
||||
|
||||
protected:
|
||||
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; }
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__LOC_CONTEXT_BASE__
|
147
core/LocAdapterBase.cpp
Normal file
147
core/LocAdapterBase.cpp
Normal file
|
@ -0,0 +1,147 @@
|
|||
/* Copyright (c) 2011-2013, 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.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_LocAdapterBase"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <loc_target.h>
|
||||
#include <log_util.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
struct LocOpenMsg : public LocMsg {
|
||||
LocAdapterBase* mLocAdapter;
|
||||
LocApiBase* mLocApi;
|
||||
inline LocOpenMsg(LocAdapterBase* locAdapter,
|
||||
LocApiBase* locApi) :
|
||||
LocMsg(), mLocAdapter(locAdapter), mLocApi(locApi)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mLocApi->addAdapter(mLocAdapter);
|
||||
}
|
||||
inline void locallog() {
|
||||
LOC_LOGV("LocOpen");
|
||||
}
|
||||
inline virtual void log() {
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
|
||||
// This is the top level class, so the constructor will
|
||||
// always gets called. Here we prepare for the default.
|
||||
// But if getLocApi(targetEnumType target) is overriden,
|
||||
// the right locApi should get created.
|
||||
LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||
ContextBase* context) :
|
||||
mEvtMask(mask), mContext(context),
|
||||
mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
|
||||
{
|
||||
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()
|
||||
|
||||
void LocAdapterBase::
|
||||
reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
void LocAdapterBase::
|
||||
reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
|
||||
void LocAdapterBase::
|
||||
reportStatus(GpsStatusValue status)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
|
||||
void LocAdapterBase::
|
||||
reportNmea(const char* nmea, int length)
|
||||
DEFAULT_IMPL()
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestXtraData()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestTime()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestLocation()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestATL(int connHandle, AGpsType agps_type)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
releaseATL(int connHandle)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestSuplES(int connHandle)
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportDataCallOpened()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
reportDataCallClosed()
|
||||
DEFAULT_IMPL(false)
|
||||
|
||||
bool LocAdapterBase::
|
||||
requestNiNotify(GpsNiNotification ¬ify, const void* data)
|
||||
DEFAULT_IMPL(false)
|
||||
} // namespace loc_core
|
97
core/LocAdapterBase.h
Normal file
97
core/LocAdapterBase.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* Copyright (c) 2011-2013, 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_API_ADAPTER_BASE_H
|
||||
#define LOC_API_ADAPTER_BASE_H
|
||||
|
||||
#include <gps_extended.h>
|
||||
#include <ContextBase.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
class LocAdapterBase {
|
||||
protected:
|
||||
const LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;
|
||||
ContextBase* mContext;
|
||||
LocApiBase* mLocApi;
|
||||
const MsgTask* mMsgTask;
|
||||
|
||||
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||
ContextBase* context);
|
||||
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
|
||||
|
||||
public:
|
||||
inline LOC_API_ADAPTER_EVENT_MASK_T
|
||||
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
|
||||
return mEvtMask & mask;
|
||||
}
|
||||
|
||||
inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const {
|
||||
return mEvtMask;
|
||||
}
|
||||
|
||||
inline void sendMsg(const LocMsg* msg) const {
|
||||
mMsgTask->sendMsg(msg);
|
||||
}
|
||||
|
||||
inline void sendMsg(const LocMsg* msg) {
|
||||
mMsgTask->sendMsg(msg);
|
||||
}
|
||||
|
||||
// This will be overridden by the individual adapters
|
||||
// if necessary.
|
||||
inline virtual void handleEngineUpEvent() {}
|
||||
virtual void handleEngineDownEvent() ;
|
||||
virtual void reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask);
|
||||
virtual void reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt);
|
||||
virtual void reportStatus(GpsStatusValue status);
|
||||
virtual void reportNmea(const char* nmea, int length);
|
||||
virtual bool reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength);
|
||||
virtual bool requestXtraData();
|
||||
virtual bool requestTime();
|
||||
virtual bool requestLocation();
|
||||
virtual bool requestATL(int connHandle, AGpsType agps_type);
|
||||
virtual bool releaseATL(int connHandle);
|
||||
virtual bool requestSuplES(int connHandle);
|
||||
virtual bool reportDataCallOpened();
|
||||
virtual bool reportDataCallClosed();
|
||||
virtual bool requestNiNotify(GpsNiNotification ¬ify,
|
||||
const void* data);
|
||||
inline virtual bool isInSession() { return false; }
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //LOC_API_ADAPTER_BASE_H
|
475
core/LocApiBase.cpp
Normal file
475
core/LocApiBase.cpp
Normal file
|
@ -0,0 +1,475 @@
|
|||
/* Copyright (c) 2011-2013, 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.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_LocApiBase"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <LocApiBase.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <loc_target.h>
|
||||
#include <log_util.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
#define TO_ALL_LOCADAPTERS(call) TO_ALL_ADAPTERS(mLocAdapters, (call))
|
||||
#define TO_1ST_HANDLING_LOCADAPTERS(call) TO_1ST_HANDLING_ADAPTER(mLocAdapters, (call))
|
||||
|
||||
int hexcode(char *hexstring, int string_size,
|
||||
const char *data, int data_size)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < data_size; i++)
|
||||
{
|
||||
char ch = data[i];
|
||||
if (i*2 + 3 <= string_size)
|
||||
{
|
||||
snprintf(&hexstring[i*2], 3, "%02X", ch);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int decodeAddress(char *addr_string, int string_size,
|
||||
const char *data, int data_size)
|
||||
{
|
||||
const char addr_prefix = 0x91;
|
||||
int i, idxOutput = 0;
|
||||
|
||||
if (!data || !addr_string) { return 0; }
|
||||
|
||||
if (data[0] != addr_prefix)
|
||||
{
|
||||
LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]);
|
||||
addr_string[0] = '\0';
|
||||
return 0; // prefix not correct
|
||||
}
|
||||
|
||||
for (i = 1; i < data_size; i++)
|
||||
{
|
||||
unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4;
|
||||
if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; }
|
||||
if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; }
|
||||
}
|
||||
|
||||
addr_string[idxOutput] = '\0'; // Terminates the string
|
||||
|
||||
return idxOutput;
|
||||
}
|
||||
|
||||
struct LocSsrMsg : public LocMsg {
|
||||
LocApiBase* mLocApi;
|
||||
inline LocSsrMsg(LocApiBase* locApi) :
|
||||
LocMsg(), mLocApi(locApi)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mLocApi->close();
|
||||
mLocApi->open(mLocApi->getEvtMask());
|
||||
}
|
||||
inline void locallog() {
|
||||
LOC_LOGV("LocSsrMsg");
|
||||
}
|
||||
inline virtual void log() {
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
|
||||
LocApiBase* LocApiBase::create(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask,
|
||||
void* libHandle)
|
||||
{
|
||||
LocApiBase* locApi = NULL;
|
||||
|
||||
// first if can not be MPQ
|
||||
if (TARGET_MPQ != get_target()) {
|
||||
getLocApi_t* getter = NULL;
|
||||
// needto check if locaction.so exists
|
||||
void* handle = ContextBase::getIzatLibHandle();
|
||||
|
||||
if (NULL == handle ||
|
||||
NULL == (getter = (getLocApi_t*)dlsym(handle, "getLocApi")) ||
|
||||
NULL == (locApi = (*getter)(msgTask, exMask))) {
|
||||
// only RPC is the option now
|
||||
handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
|
||||
if (NULL != handle) {
|
||||
getter = (getLocApi_t*)dlsym(handle, "getLocApi");
|
||||
if (NULL != getter) {
|
||||
locApi = (*getter)(msgTask, exMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// locApi could still be NULL at this time
|
||||
// we would then create a dummy one
|
||||
if (NULL == locApi) {
|
||||
locApi = new LocApiBase(msgTask, exMask);
|
||||
}
|
||||
|
||||
return locApi;
|
||||
}
|
||||
|
||||
LocApiBase::LocApiBase(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T excludedMask) :
|
||||
mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0)
|
||||
{
|
||||
memset(mLocAdapters, 0, sizeof(mLocAdapters));
|
||||
}
|
||||
|
||||
LOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask()
|
||||
{
|
||||
LOC_API_ADAPTER_EVENT_MASK_T mask = 0;
|
||||
|
||||
TO_ALL_LOCADAPTERS(mask |= mLocAdapters[i]->getEvtMask());
|
||||
|
||||
return mask & ~mExcludedMask;
|
||||
}
|
||||
|
||||
bool LocApiBase::isInSession()
|
||||
{
|
||||
bool inSession = false;
|
||||
|
||||
TO_ALL_LOCADAPTERS(inSession = mLocAdapters[i]->isInSession());
|
||||
|
||||
return inSession;
|
||||
}
|
||||
|
||||
void LocApiBase::addAdapter(LocAdapterBase* adapter)
|
||||
{
|
||||
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
|
||||
if (mLocAdapters[i] == NULL) {
|
||||
mLocAdapters[i] = adapter;
|
||||
open(mMask | (adapter->getEvtMask() & ~mExcludedMask));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocApiBase::removeAdapter(LocAdapterBase* adapter)
|
||||
{
|
||||
for (int i = 0;
|
||||
i < MAX_ADAPTERS && NULL != mLocAdapters[i];
|
||||
i++) {
|
||||
if (mLocAdapters[i] == adapter) {
|
||||
mLocAdapters[i] = NULL;
|
||||
|
||||
// shift the rest of the adapters up so that the pointers
|
||||
// in the array do not have holes. This should be more
|
||||
// performant, because the array maintenance is much much
|
||||
// less frequent than event handlings, which need to linear
|
||||
// search all the adapters
|
||||
int j = i;
|
||||
while (++i < MAX_ADAPTERS && mLocAdapters[i] != NULL);
|
||||
|
||||
// i would be MAX_ADAPTERS or point to a NULL
|
||||
i--;
|
||||
// i now should point to a none NULL adapter within valid
|
||||
// range although i could be equal to j, but it won't hurt.
|
||||
// No need to check it, as it gains nothing.
|
||||
mLocAdapters[j] = mLocAdapters[i];
|
||||
// this makes sure that we exit the for loop
|
||||
mLocAdapters[i] = NULL;
|
||||
|
||||
// if we have an empty list of adapters
|
||||
if (0 == i) {
|
||||
close();
|
||||
} else {
|
||||
// else we need to remove the bit
|
||||
open(getEvtMask() & ~mExcludedMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocApiBase::handleEngineUpEvent()
|
||||
{
|
||||
// This will take care of renegotiating the loc handle
|
||||
mMsgTask->sendMsg(new LocSsrMsg(this));
|
||||
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());
|
||||
}
|
||||
|
||||
void LocApiBase::handleEngineDownEvent()
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
|
||||
}
|
||||
|
||||
void LocApiBase::reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(
|
||||
mLocAdapters[i]->reportPosition(location,
|
||||
locationExtended,
|
||||
locationExt,
|
||||
status,
|
||||
loc_technology_mask)
|
||||
);
|
||||
}
|
||||
|
||||
void LocApiBase::reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(
|
||||
mLocAdapters[i]->reportSv(svStatus,
|
||||
locationExtended,
|
||||
svExt)
|
||||
);
|
||||
}
|
||||
|
||||
void LocApiBase::reportStatus(GpsStatusValue status)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status));
|
||||
}
|
||||
|
||||
void LocApiBase::reportNmea(const char* nmea, int length)
|
||||
{
|
||||
// loop through adapters, and deliver to all adapters.
|
||||
TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length));
|
||||
}
|
||||
|
||||
void LocApiBase::reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportXtraServer(url1, url2, url3, maxlength));
|
||||
|
||||
}
|
||||
|
||||
void LocApiBase::requestXtraData()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestXtraData());
|
||||
}
|
||||
|
||||
void LocApiBase::requestTime()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestTime());
|
||||
}
|
||||
|
||||
void LocApiBase::requestLocation()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation());
|
||||
}
|
||||
|
||||
void LocApiBase::requestATL(int connHandle, AGpsType agps_type)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestATL(connHandle, agps_type));
|
||||
}
|
||||
|
||||
void LocApiBase::releaseATL(int connHandle)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle));
|
||||
}
|
||||
|
||||
void LocApiBase::requestSuplES(int connHandle)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestSuplES(connHandle));
|
||||
}
|
||||
|
||||
void LocApiBase::reportDataCallOpened()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallOpened());
|
||||
}
|
||||
|
||||
void LocApiBase::reportDataCallClosed()
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed());
|
||||
}
|
||||
|
||||
void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data)
|
||||
{
|
||||
// loop through adapters, and deliver to the first handling adapter.
|
||||
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)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
close()
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
startFix(const LocPosMode& posMode)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
stopFix()
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
deleteAidingData(GpsAidingData f)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
enableData(int enable)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setAPN(char* apn, int len)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
injectPosition(double latitude, double longitude, float accuracy)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setXtraData(char* data, int length)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
requestXtraServer()
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
atlOpenStatus(int handle, int is_succ, char* apn,
|
||||
AGpsBearerType bear, AGpsType agpsType)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
atlCloseStatus(int handle, int is_succ)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setPositionMode(const LocPosMode& posMode)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setServer(const char* url, int len)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setServer(unsigned int ip, int port,
|
||||
LocServerType type)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
informNiResponse(GpsUserResponseType userResponse,
|
||||
const void* passThroughData)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setSUPLVersion(uint32_t version)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setLPPConfig(uint32_t profile)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setSensorControlConfig(int sensorUsage)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
|
||||
float gyroBiasVarianceRandomWalk,
|
||||
bool accelBiasVarianceRandomWalk_valid,
|
||||
float accelBiasVarianceRandomWalk,
|
||||
bool angleBiasVarianceRandomWalk_valid,
|
||||
float angleBiasVarianceRandomWalk,
|
||||
bool rateBiasVarianceRandomWalk_valid,
|
||||
float rateBiasVarianceRandomWalk,
|
||||
bool velocityBiasVarianceRandomWalk_valid,
|
||||
float velocityBiasVarianceRandomWalk)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setSensorPerfControlConfig(int controlMode,
|
||||
int accelSamplesPerBatch,
|
||||
int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch,
|
||||
int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh,
|
||||
int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh,
|
||||
int gyroBatchesPerSecHigh,
|
||||
int algorithmConfig)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setExtPowerConfig(int isBatteryCharging)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
setAGLONASSProtocol(unsigned long aGlonassProtocol)
|
||||
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
|
||||
|
||||
int LocApiBase::
|
||||
initDataServiceClient()
|
||||
DEFAULT_IMPL(-1)
|
||||
|
||||
int LocApiBase::
|
||||
openAndStartDataCall()
|
||||
DEFAULT_IMPL(-1)
|
||||
|
||||
void LocApiBase::
|
||||
stopDataCall()
|
||||
DEFAULT_IMPL()
|
||||
|
||||
void LocApiBase::
|
||||
closeDataCall()
|
||||
DEFAULT_IMPL()
|
||||
|
||||
|
||||
} // namespace loc_core
|
254
core/LocApiBase.h
Normal file
254
core/LocApiBase.h
Normal file
|
@ -0,0 +1,254 @@
|
|||
/* Copyright (c) 2011-2013, 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_API_BASE_H
|
||||
#define LOC_API_BASE_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <gps_extended.h>
|
||||
#include <MsgTask.h>
|
||||
|
||||
#define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
|
||||
#define MAX_APN_LEN 100
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
int hexcode(char *hexstring, int string_size,
|
||||
const char *data, int data_size);
|
||||
int decodeAddress(char *addr_string, int string_size,
|
||||
const char *data, int data_size);
|
||||
|
||||
enum loc_api_adapter_err {
|
||||
LOC_API_ADAPTER_ERR_SUCCESS = 0,
|
||||
LOC_API_ADAPTER_ERR_GENERAL_FAILURE = 1,
|
||||
LOC_API_ADAPTER_ERR_UNSUPPORTED = 2,
|
||||
LOC_API_ADAPTER_ERR_INVALID_HANDLE = 4,
|
||||
LOC_API_ADAPTER_ERR_INVALID_PARAMETER = 5,
|
||||
LOC_API_ADAPTER_ERR_ENGINE_BUSY = 6,
|
||||
LOC_API_ADAPTER_ERR_PHONE_OFFLINE = 7,
|
||||
LOC_API_ADAPTER_ERR_TIMEOUT = 8,
|
||||
LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,
|
||||
|
||||
LOC_API_ADAPTER_ERR_ENGINE_DOWN = 100,
|
||||
LOC_API_ADAPTER_ERR_FAILURE,
|
||||
LOC_API_ADAPTER_ERR_UNKNOWN
|
||||
};
|
||||
|
||||
enum loc_api_adapter_event_index {
|
||||
LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type
|
||||
LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report
|
||||
LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate
|
||||
LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate
|
||||
LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request
|
||||
LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request
|
||||
LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server
|
||||
LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl
|
||||
LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state
|
||||
LOC_API_ADAPTER_REQUEST_WIFI, //
|
||||
LOC_API_ADAPTER_SENSOR_STATUS, //
|
||||
LOC_API_ADAPTER_REQUEST_TIME_SYNC, //
|
||||
LOC_API_ADAPTER_REPORT_SPI, //
|
||||
LOC_API_ADAPTER_REPORT_NI_GEOFENCE, //
|
||||
LOC_API_ADAPTER_GEOFENCE_GEN_ALERT, //
|
||||
LOC_API_ADAPTER_REPORT_GENFENCE_BREACH, //
|
||||
LOC_API_ADAPTER_PEDOMETER_CTRL, //
|
||||
LOC_API_ADAPTER_MOTION_CTRL, //
|
||||
|
||||
LOC_API_ADAPTER_EVENT_MAX
|
||||
};
|
||||
|
||||
#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_POSITION)
|
||||
#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
|
||||
#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
|
||||
#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
|
||||
#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
|
||||
#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
|
||||
#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
|
||||
#define LOC_API_ADAPTER_BIT_IOCTL_REPORT (1<<LOC_API_ADAPTER_REPORT_IOCTL)
|
||||
#define LOC_API_ADAPTER_BIT_STATUS_REPORT (1<<LOC_API_ADAPTER_REPORT_STATUS)
|
||||
#define LOC_API_ADAPTER_BIT_REQUEST_WIFI (1<<LOC_API_ADAPTER_REQUEST_WIFI)
|
||||
#define LOC_API_ADAPTER_BIT_SENSOR_STATUS (1<<LOC_API_ADAPTER_SENSOR_STATUS)
|
||||
#define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)
|
||||
#define LOC_API_ADAPTER_BIT_REPORT_SPI (1<<LOC_API_ADAPTER_REPORT_SPI)
|
||||
#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_REPORT_GENFENCE_BREACH (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
|
||||
#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)
|
||||
|
||||
typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
|
||||
#define MAX_ADAPTERS 10
|
||||
|
||||
#define TO_ALL_ADAPTERS(adapters, call) \
|
||||
for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) { \
|
||||
call; \
|
||||
}
|
||||
|
||||
#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
|
||||
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
|
||||
|
||||
|
||||
class LocAdapterBase;
|
||||
struct LocSsrMsg;
|
||||
|
||||
class LocApiBase {
|
||||
friend struct LocSsrMsg;
|
||||
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);
|
||||
|
||||
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);
|
||||
inline virtual ~LocApiBase() { close(); }
|
||||
bool isInSession();
|
||||
|
||||
public:
|
||||
void addAdapter(LocAdapterBase* adapter);
|
||||
void removeAdapter(LocAdapterBase* adapter);
|
||||
|
||||
// upward calls
|
||||
void handleEngineUpEvent();
|
||||
void handleEngineDownEvent();
|
||||
void reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask =
|
||||
LOC_POS_TECH_MASK_DEFAULT);
|
||||
void reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt);
|
||||
void reportStatus(GpsStatusValue status);
|
||||
void reportNmea(const char* nmea, int length);
|
||||
void reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength);
|
||||
void requestXtraData();
|
||||
void requestTime();
|
||||
void requestLocation();
|
||||
void requestATL(int connHandle, AGpsType agps_type);
|
||||
void releaseATL(int connHandle);
|
||||
void requestSuplES(int connHandle);
|
||||
void reportDataCallOpened();
|
||||
void reportDataCallClosed();
|
||||
void requestNiNotify(GpsNiNotification ¬ify, const void* data);
|
||||
|
||||
// downward calls
|
||||
// All below functions are to be defined by adapter specific modules:
|
||||
// RPC, QMI, etc. The default implementation is empty.
|
||||
virtual enum loc_api_adapter_err
|
||||
startFix(const LocPosMode& posMode);
|
||||
virtual enum loc_api_adapter_err
|
||||
stopFix();
|
||||
virtual enum loc_api_adapter_err
|
||||
deleteAidingData(GpsAidingData f);
|
||||
virtual enum loc_api_adapter_err
|
||||
enableData(int enable);
|
||||
virtual enum loc_api_adapter_err
|
||||
setAPN(char* apn, int len);
|
||||
virtual enum loc_api_adapter_err
|
||||
injectPosition(double latitude, double longitude, float accuracy);
|
||||
virtual enum loc_api_adapter_err
|
||||
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);
|
||||
virtual enum loc_api_adapter_err
|
||||
setXtraData(char* data, int length);
|
||||
virtual enum loc_api_adapter_err
|
||||
requestXtraServer();
|
||||
virtual enum loc_api_adapter_err
|
||||
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);
|
||||
virtual enum loc_api_adapter_err
|
||||
atlCloseStatus(int handle, int is_succ);
|
||||
virtual enum loc_api_adapter_err
|
||||
setPositionMode(const LocPosMode& posMode);
|
||||
virtual enum loc_api_adapter_err
|
||||
setServer(const char* url, int len);
|
||||
virtual enum loc_api_adapter_err
|
||||
setServer(unsigned int ip, int port,
|
||||
LocServerType type);
|
||||
virtual enum loc_api_adapter_err
|
||||
informNiResponse(GpsUserResponseType userResponse, const void* passThroughData);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSUPLVersion(uint32_t version);
|
||||
virtual enum loc_api_adapter_err
|
||||
setLPPConfig(uint32_t profile);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSensorControlConfig(int sensorUsage);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
|
||||
float gyroBiasVarianceRandomWalk,
|
||||
bool accelBiasVarianceRandomWalk_valid,
|
||||
float accelBiasVarianceRandomWalk,
|
||||
bool angleBiasVarianceRandomWalk_valid,
|
||||
float angleBiasVarianceRandomWalk,
|
||||
bool rateBiasVarianceRandomWalk_valid,
|
||||
float rateBiasVarianceRandomWalk,
|
||||
bool velocityBiasVarianceRandomWalk_valid,
|
||||
float velocityBiasVarianceRandomWalk);
|
||||
virtual enum loc_api_adapter_err
|
||||
setSensorPerfControlConfig(int controlMode,
|
||||
int accelSamplesPerBatch,
|
||||
int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch,
|
||||
int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh,
|
||||
int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh,
|
||||
int gyroBatchesPerSecHigh,
|
||||
int algorithmConfig);
|
||||
virtual enum loc_api_adapter_err
|
||||
setExtPowerConfig(int isBatteryCharging);
|
||||
virtual enum loc_api_adapter_err
|
||||
setAGLONASSProtocol(unsigned long aGlonassProtocol);
|
||||
virtual int initDataServiceClient();
|
||||
virtual int openAndStartDataCall();
|
||||
virtual void stopDataCall();
|
||||
virtual void closeDataCall();
|
||||
|
||||
inline virtual void setInSession(bool inSession) {}
|
||||
};
|
||||
|
||||
typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask);
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //LOC_API_BASE_H
|
117
core/LocDualContext.cpp
Normal file
117
core/LocDualContext.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
/* Copyright (c) 2011-2013, 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.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_DualCtx"
|
||||
|
||||
#include <cutils/sched_policy.h>
|
||||
#include <unistd.h>
|
||||
#include <LocDualContext.h>
|
||||
#include <msg_q.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_log.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
// nothing exclude for foreground
|
||||
const LOC_API_ADAPTER_EVENT_MASK_T
|
||||
LocDualContext::mFgExclMask = 0;
|
||||
// excluded events for background clients
|
||||
const LOC_API_ADAPTER_EVENT_MASK_T
|
||||
LocDualContext::mBgExclMask =
|
||||
(LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
|
||||
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
|
||||
LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
|
||||
LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT |
|
||||
LOC_API_ADAPTER_BIT_IOCTL_REPORT |
|
||||
LOC_API_ADAPTER_BIT_STATUS_REPORT |
|
||||
LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT);
|
||||
|
||||
const MsgTask* LocDualContext::mMsgTask = NULL;
|
||||
ContextBase* LocDualContext::mFgContext = NULL;
|
||||
ContextBase* LocDualContext::mBgContext = NULL;
|
||||
|
||||
char LocDualContext::mHasAgpsExt = 0xff;
|
||||
|
||||
// the name must be shorter than 15 chars
|
||||
const char* LocDualContext::mLocationHalName = "Loc_hal_worker";
|
||||
|
||||
const MsgTask* LocDualContext::getMsgTask(MsgTask::tCreate tCreator,
|
||||
const char* name)
|
||||
{
|
||||
if (NULL == mMsgTask) {
|
||||
mMsgTask = new MsgTask(tCreator, name);
|
||||
}
|
||||
return mMsgTask;
|
||||
}
|
||||
|
||||
ContextBase* LocDualContext::getLocFgContext(MsgTask::tCreate tCreator,
|
||||
const char* name)
|
||||
{
|
||||
if (NULL == mFgContext) {
|
||||
const MsgTask* msgTask = getMsgTask(tCreator, name);
|
||||
mFgContext = new LocDualContext(msgTask,
|
||||
mFgExclMask);
|
||||
}
|
||||
return mFgContext;
|
||||
}
|
||||
|
||||
ContextBase* LocDualContext::getLocBgContext(MsgTask::tCreate tCreator,
|
||||
const char* name)
|
||||
{
|
||||
if (NULL == mBgContext) {
|
||||
const MsgTask* msgTask = getMsgTask(tCreator, name);
|
||||
mBgContext = new LocDualContext(msgTask,
|
||||
mBgExclMask);
|
||||
}
|
||||
return mBgContext;
|
||||
}
|
||||
|
||||
bool LocDualContext::hasAgpsExt()
|
||||
{
|
||||
if (0xff == mHasAgpsExt) {
|
||||
mHasAgpsExt = 0;
|
||||
void* handle = ContextBase::getIzatLibHandle();
|
||||
if (NULL != handle) {
|
||||
bool(*getter)() = (bool(*)())dlsym(handle, "hasAgpsExt");
|
||||
if (NULL != getter && (*getter)()) {
|
||||
mHasAgpsExt = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mHasAgpsExt == 1;
|
||||
}
|
||||
|
||||
LocDualContext::LocDualContext(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask) :
|
||||
ContextBase(msgTask, exMask)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
68
core/LocDualContext.h
Normal file
68
core/LocDualContext.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* Copyright (c) 2011-2013, 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_ENG_CONTEXT__
|
||||
#define __LOC_ENG_CONTEXT__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
#include <ContextBase.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
class LocDualContext : public ContextBase {
|
||||
static const MsgTask* mMsgTask;
|
||||
static ContextBase* mFgContext;
|
||||
static ContextBase* mBgContext;
|
||||
static char mHasAgpsExt;
|
||||
|
||||
static const MsgTask* getMsgTask(MsgTask::tCreate tCreator,
|
||||
const char* name);
|
||||
|
||||
protected:
|
||||
LocDualContext(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask);
|
||||
inline virtual ~LocDualContext() {}
|
||||
|
||||
public:
|
||||
static const LOC_API_ADAPTER_EVENT_MASK_T mFgExclMask;
|
||||
static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask;
|
||||
static const char* mLocationHalName;
|
||||
|
||||
static ContextBase* getLocFgContext(MsgTask::tCreate tCreator,
|
||||
const char* name);
|
||||
static ContextBase* getLocBgContext(MsgTask::tCreate tCreator,
|
||||
const char* name);
|
||||
|
||||
static bool hasAgpsExt();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //__LOC_ENG_CONTEXT__
|
133
core/MsgTask.cpp
Normal file
133
core/MsgTask.cpp
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* Copyright (c) 2011-2013, 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.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_MsgTask"
|
||||
|
||||
#include <cutils/sched_policy.h>
|
||||
#include <unistd.h>
|
||||
#include <MsgTask.h>
|
||||
#include <msg_q.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_log.h>
|
||||
#include <android_runtime/AndroidRuntime.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
#define MAX_TASK_COMM_LEN 15
|
||||
|
||||
static void LocMsgDestroy(void* msg) {
|
||||
delete (LocMsg*)msg;
|
||||
}
|
||||
|
||||
MsgTask::MsgTask(tCreate tCreator, const char* threadName) :
|
||||
mQ(msg_q_init2()), mAssociator(NULL){
|
||||
if (tCreator) {
|
||||
tCreator(threadName, loopMain,
|
||||
(void*)new MsgTask(mQ, mAssociator));
|
||||
} else {
|
||||
createPThread(threadName);
|
||||
}
|
||||
}
|
||||
|
||||
MsgTask::MsgTask(tAssociate tAssociator, const char* threadName) :
|
||||
mQ(msg_q_init2()), mAssociator(tAssociator){
|
||||
createPThread(threadName);
|
||||
}
|
||||
|
||||
inline
|
||||
MsgTask::MsgTask(const void* q, tAssociate associator) :
|
||||
mQ(q), mAssociator(associator){
|
||||
}
|
||||
|
||||
MsgTask::~MsgTask() {
|
||||
msg_q_unblock((void*)mQ);
|
||||
}
|
||||
|
||||
void MsgTask::createPThread(const char* threadName) {
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
pthread_t tid;
|
||||
// create the thread here, then if successful
|
||||
// and a name is given, we set the thread name
|
||||
if (!pthread_create(&tid, &attr, loopMain,
|
||||
(void*)new MsgTask(mQ, mAssociator)) &&
|
||||
NULL != threadName) {
|
||||
char lname[MAX_TASK_COMM_LEN+1];
|
||||
memcpy(lname, threadName, MAX_TASK_COMM_LEN);
|
||||
lname[MAX_TASK_COMM_LEN] = 0;
|
||||
pthread_setname_np(tid, lname);
|
||||
}
|
||||
}
|
||||
|
||||
void MsgTask::sendMsg(const LocMsg* msg) const {
|
||||
msg_q_snd((void*)mQ, (void*)msg, LocMsgDestroy);
|
||||
}
|
||||
|
||||
void* MsgTask::loopMain(void* arg) {
|
||||
MsgTask* copy = (MsgTask*)arg;
|
||||
|
||||
// make sure we do not run in background scheduling group
|
||||
set_sched_policy(gettid(), SP_FOREGROUND);
|
||||
|
||||
if (NULL != copy->mAssociator) {
|
||||
copy->mAssociator();
|
||||
}
|
||||
|
||||
LocMsg* msg;
|
||||
int cnt = 0;
|
||||
|
||||
while (1) {
|
||||
LOC_LOGD("MsgTask::loop() %d listening ...\n", cnt++);
|
||||
|
||||
msq_q_err_type result = msg_q_rcv((void*)copy->mQ, (void **)&msg);
|
||||
|
||||
if (eMSG_Q_SUCCESS != result) {
|
||||
LOC_LOGE("%s:%d] fail receiving msg: %s\n", __func__, __LINE__,
|
||||
loc_get_msg_q_status(result));
|
||||
// destroy the Q and exit
|
||||
msg_q_destroy((void**)&(copy->mQ));
|
||||
delete copy;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msg->log();
|
||||
// there is where each individual msg handling is invoked
|
||||
msg->proc();
|
||||
|
||||
delete msg;
|
||||
}
|
||||
|
||||
delete copy;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
66
core/MsgTask.h
Normal file
66
core/MsgTask.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* Copyright (c) 2011-2013, 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 __MSG_TASK__
|
||||
#define __MSG_TASK__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
struct LocMsg {
|
||||
inline LocMsg() {}
|
||||
inline virtual ~LocMsg() {}
|
||||
virtual void proc() const = 0;
|
||||
inline virtual void log() const {}
|
||||
};
|
||||
|
||||
class MsgTask {
|
||||
public:
|
||||
typedef void* (*tStart)(void*);
|
||||
typedef pthread_t (*tCreate)(const char* name, tStart start, void* arg);
|
||||
typedef int (*tAssociate)();
|
||||
MsgTask(tCreate tCreator, const char* threadName);
|
||||
MsgTask(tAssociate tAssociator, const char* threadName);
|
||||
~MsgTask();
|
||||
void sendMsg(const LocMsg* msg) const;
|
||||
|
||||
private:
|
||||
const void* mQ;
|
||||
tAssociate mAssociator;
|
||||
MsgTask(const void* q, tAssociate associator);
|
||||
static void* loopMain(void* copy);
|
||||
void createPThread(const char* name);
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__MSG_TASK__
|
92
core/gps_extended.h
Normal file
92
core/gps_extended.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* Copyright (c) 2013, 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 GPS_EXTENDED_H
|
||||
#define GPS_EXTENDED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <gps_extended_c.h>
|
||||
|
||||
struct LocPosMode
|
||||
{
|
||||
LocPositionMode mode;
|
||||
GpsPositionRecurrence recurrence;
|
||||
uint32_t min_interval;
|
||||
uint32_t preferred_accuracy;
|
||||
uint32_t preferred_time;
|
||||
char credentials[14];
|
||||
char provider[8];
|
||||
LocPosMode(LocPositionMode m, GpsPositionRecurrence recr,
|
||||
uint32_t gap, uint32_t accu, uint32_t time,
|
||||
const char* cred, const char* prov) :
|
||||
mode(m), recurrence(recr),
|
||||
min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap),
|
||||
preferred_accuracy(accu), preferred_time(time) {
|
||||
memset(credentials, 0, sizeof(credentials));
|
||||
memset(provider, 0, sizeof(provider));
|
||||
if (NULL != cred) {
|
||||
memcpy(credentials, cred, sizeof(credentials)-1);
|
||||
}
|
||||
if (NULL != prov) {
|
||||
memcpy(provider, prov, sizeof(provider)-1);
|
||||
}
|
||||
}
|
||||
|
||||
inline LocPosMode() :
|
||||
mode(LOC_POSITION_MODE_MS_BASED),
|
||||
recurrence(GPS_POSITION_RECURRENCE_PERIODIC),
|
||||
min_interval(MIN_POSSIBLE_FIX_INTERVAL),
|
||||
preferred_accuracy(50), preferred_time(120000) {
|
||||
memset(credentials, 0, sizeof(credentials));
|
||||
memset(provider, 0, sizeof(provider));
|
||||
}
|
||||
|
||||
inline bool equals(const LocPosMode &anotherMode) const
|
||||
{
|
||||
return anotherMode.mode == mode &&
|
||||
anotherMode.recurrence == recurrence &&
|
||||
anotherMode.min_interval == min_interval &&
|
||||
anotherMode.preferred_accuracy == preferred_accuracy &&
|
||||
anotherMode.preferred_time == preferred_time &&
|
||||
!strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) &&
|
||||
!strncmp(anotherMode.provider, provider, sizeof(provider)-1);
|
||||
}
|
||||
|
||||
void logv() const;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* GPS_EXTENDED_H */
|
||||
|
256
core/gps_extended_c.h
Normal file
256
core/gps_extended_c.h
Normal file
|
@ -0,0 +1,256 @@
|
|||
/* Copyright (c) 2013, 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 GPS_EXTENDED_C_H
|
||||
#define GPS_EXTENDED_C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdbool.h>
|
||||
#include <hardware/gps.h>
|
||||
|
||||
/** Location has valid source information. */
|
||||
#define LOCATION_HAS_SOURCE_INFO 0x0020
|
||||
/** GpsLocation has valid "is indoor?" flag */
|
||||
#define GPS_LOCATION_HAS_IS_INDOOR 0x0040
|
||||
/** GpsLocation has valid floor number */
|
||||
#define GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080
|
||||
/** GpsLocation has valid map URL*/
|
||||
#define GPS_LOCATION_HAS_MAP_URL 0x0100
|
||||
/** GpsLocation has valid map index */
|
||||
#define GPS_LOCATION_HAS_MAP_INDEX 0x0200
|
||||
|
||||
/** Sizes for indoor fields */
|
||||
#define GPS_LOCATION_MAP_URL_SIZE 400
|
||||
#define GPS_LOCATION_MAP_INDEX_SIZE 16
|
||||
|
||||
/** Position source is ULP */
|
||||
#define ULP_LOCATION_IS_FROM_HYBRID 0x0001
|
||||
/** Position source is GNSS only */
|
||||
#define ULP_LOCATION_IS_FROM_GNSS 0x0002
|
||||
|
||||
#define ULP_MIN_INTERVAL_INVALID 0xffffffff
|
||||
|
||||
|
||||
typedef struct {
|
||||
/** set to sizeof(UlpLocation) */
|
||||
size_t size;
|
||||
GpsLocation gpsLocation;
|
||||
/* Provider indicator for HYBRID or GPS */
|
||||
uint16_t position_source;
|
||||
/*allows HAL to pass additional information related to the location */
|
||||
int rawDataSize; /* in # of bytes */
|
||||
void * rawData;
|
||||
bool is_indoor;
|
||||
float floor_number;
|
||||
char map_url[GPS_LOCATION_MAP_URL_SIZE];
|
||||
unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE];
|
||||
} UlpLocation;
|
||||
|
||||
/** AGPS type */
|
||||
typedef int16_t AGpsExtType;
|
||||
#define AGPS_TYPE_INVALID -1
|
||||
#define AGPS_TYPE_ANY 0
|
||||
#define AGPS_TYPE_SUPL 1
|
||||
#define AGPS_TYPE_C2K 2
|
||||
#define AGPS_TYPE_WWAN_ANY 3
|
||||
#define AGPS_TYPE_WIFI 4
|
||||
#define AGPS_TYPE_SUPL_ES 5
|
||||
|
||||
/** SSID length */
|
||||
#define SSID_BUF_SIZE (32+1)
|
||||
|
||||
typedef int16_t AGpsBearerType;
|
||||
#define AGPS_APN_BEARER_INVALID -1
|
||||
#define AGPS_APN_BEARER_IPV4 0
|
||||
#define AGPS_APN_BEARER_IPV6 1
|
||||
#define AGPS_APN_BEARER_IPV4V6 2
|
||||
|
||||
#define GPS_DELETE_ALMANAC_CORR 0x00001000
|
||||
#define GPS_DELETE_FREQ_BIAS_EST 0x00002000
|
||||
#define GPS_DELETE_EPHEMERIS_GLO 0x00004000
|
||||
#define GPS_DELETE_ALMANAC_GLO 0x00008000
|
||||
#define GPS_DELETE_SVDIR_GLO 0x00010000
|
||||
#define GPS_DELETE_SVSTEER_GLO 0x00020000
|
||||
#define GPS_DELETE_ALMANAC_CORR_GLO 0x00040000
|
||||
#define GPS_DELETE_TIME_GPS 0x00080000
|
||||
#define GPS_DELETE_TIME_GLO 0x00100000
|
||||
|
||||
/** GPS extended callback structure. */
|
||||
typedef struct {
|
||||
/** set to sizeof(GpsCallbacks) */
|
||||
size_t size;
|
||||
gps_set_capabilities set_capabilities_cb;
|
||||
gps_acquire_wakelock acquire_wakelock_cb;
|
||||
gps_release_wakelock release_wakelock_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
gps_request_utc_time request_utc_time_cb;
|
||||
} GpsExtCallbacks;
|
||||
|
||||
/** Callback to report the xtra server url to the client.
|
||||
* The client should use this url when downloading xtra unless overwritten
|
||||
* in the gps.conf file
|
||||
*/
|
||||
typedef void (* report_xtra_server)(const char*, const char*, const char*);
|
||||
|
||||
/** Callback structure for the XTRA interface. */
|
||||
typedef struct {
|
||||
gps_xtra_download_request download_request_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
report_xtra_server report_xtra_server_cb;
|
||||
} GpsXtraExtCallbacks;
|
||||
|
||||
/** Represents the status of AGPS. */
|
||||
typedef struct {
|
||||
/** set to sizeof(AGpsExtStatus) */
|
||||
size_t size;
|
||||
|
||||
AGpsExtType type;
|
||||
AGpsStatusValue status;
|
||||
uint32_t ipv4_addr;
|
||||
char ipv6_addr[16];
|
||||
char ssid[SSID_BUF_SIZE];
|
||||
char password[SSID_BUF_SIZE];
|
||||
} AGpsExtStatus;
|
||||
|
||||
/** Callback with AGPS status information.
|
||||
* Can only be called from a thread created by create_thread_cb.
|
||||
*/
|
||||
typedef void (* agps_status_extended)(AGpsExtStatus* status);
|
||||
|
||||
/** Callback structure for the AGPS interface. */
|
||||
typedef struct {
|
||||
agps_status_extended status_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
} AGpsExtCallbacks;
|
||||
|
||||
|
||||
/** GPS NI callback structure. */
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* Sends the notification request from HAL to GPSLocationProvider.
|
||||
*/
|
||||
gps_ni_notify_callback notify_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
} GpsNiExtCallbacks;
|
||||
|
||||
typedef enum loc_server_type {
|
||||
LOC_AGPS_CDMA_PDE_SERVER,
|
||||
LOC_AGPS_CUSTOM_PDE_SERVER,
|
||||
LOC_AGPS_MPC_SERVER,
|
||||
LOC_AGPS_SUPL_SERVER
|
||||
} LocServerType;
|
||||
|
||||
typedef enum loc_position_mode_type {
|
||||
LOC_POSITION_MODE_STANDALONE,
|
||||
LOC_POSITION_MODE_MS_BASED,
|
||||
LOC_POSITION_MODE_MS_ASSISTED,
|
||||
LOC_POSITION_MODE_RESERVED_1,
|
||||
LOC_POSITION_MODE_RESERVED_2,
|
||||
LOC_POSITION_MODE_RESERVED_3,
|
||||
LOC_POSITION_MODE_RESERVED_4,
|
||||
LOC_POSITION_MODE_RESERVED_5
|
||||
} LocPositionMode;
|
||||
|
||||
#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */
|
||||
|
||||
/** Flags to indicate which values are valid in a GpsLocationExtended. */
|
||||
typedef uint16_t GpsLocationExtendedFlags;
|
||||
/** GpsLocationExtended has valid pdop, hdop, vdop. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001
|
||||
/** GpsLocationExtended has valid altitude mean sea level. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002
|
||||
/** UlpLocation has valid magnetic deviation. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004
|
||||
/** UlpLocation has valid mode indicator. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008
|
||||
/** GpsLocationExtended has valid vertical uncertainty */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010
|
||||
/** GpsLocationExtended has valid speed uncertainty */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020
|
||||
|
||||
/** Represents gps location extended. */
|
||||
typedef struct {
|
||||
/** set to sizeof(GpsLocationExtended) */
|
||||
size_t size;
|
||||
/** Contains GpsLocationExtendedFlags bits. */
|
||||
uint16_t flags;
|
||||
/** Contains the Altitude wrt mean sea level */
|
||||
float altitudeMeanSeaLevel;
|
||||
/** Contains Position Dilusion of Precision. */
|
||||
float pdop;
|
||||
/** Contains Horizontal Dilusion of Precision. */
|
||||
float hdop;
|
||||
/** Contains Vertical Dilusion of Precision. */
|
||||
float vdop;
|
||||
/** Contains Magnetic Deviation. */
|
||||
float magneticDeviation;
|
||||
/** vertical uncertainty in meters */
|
||||
float vert_unc;
|
||||
/** speed uncertainty in m/s */
|
||||
float speed_unc;
|
||||
} GpsLocationExtended;
|
||||
|
||||
enum loc_sess_status {
|
||||
LOC_SESS_SUCCESS,
|
||||
LOC_SESS_INTERMEDIATE,
|
||||
LOC_SESS_FAILURE
|
||||
};
|
||||
|
||||
typedef uint32_t LocPosTechMask;
|
||||
#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000)
|
||||
#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001)
|
||||
#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002)
|
||||
#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004)
|
||||
#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008)
|
||||
#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010)
|
||||
#define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020)
|
||||
#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)
|
||||
#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)
|
||||
|
||||
typedef enum {
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MODEM,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN
|
||||
} loc_if_req_sender_id_e_type;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* GPS_EXTENDED_C_H */
|
||||
|
250
core/loc_core_log.cpp
Normal file
250
core/loc_core_log.cpp
Normal file
|
@ -0,0 +1,250 @@
|
|||
/* Copyright (c) 2011-2013, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_core_log"
|
||||
|
||||
#include <loc_log.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_core_log.h>
|
||||
|
||||
void LocPosMode::logv() const
|
||||
{
|
||||
LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n "
|
||||
"min interval: %d\n preferred accuracy: %d\n "
|
||||
"preferred time: %d\n credentials: %s provider: %s",
|
||||
loc_get_position_mode_name(mode),
|
||||
loc_get_position_recurrence_name(recurrence),
|
||||
min_interval,
|
||||
preferred_accuracy,
|
||||
preferred_time,
|
||||
credentials,
|
||||
provider);
|
||||
}
|
||||
|
||||
/* GPS status names */
|
||||
static loc_name_val_s_type gps_status_name[] =
|
||||
{
|
||||
NAME_VAL( GPS_STATUS_NONE ),
|
||||
NAME_VAL( GPS_STATUS_SESSION_BEGIN ),
|
||||
NAME_VAL( GPS_STATUS_SESSION_END ),
|
||||
NAME_VAL( GPS_STATUS_ENGINE_ON ),
|
||||
NAME_VAL( GPS_STATUS_ENGINE_OFF ),
|
||||
};
|
||||
static int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type);
|
||||
|
||||
/* Find Android GPS status name */
|
||||
const char* loc_get_gps_status_name(GpsStatusValue gps_status)
|
||||
{
|
||||
return loc_get_name_from_val(gps_status_name, gps_status_num,
|
||||
(long) gps_status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_position_modes[] =
|
||||
{
|
||||
NAME_VAL( LOC_POSITION_MODE_STANDALONE ),
|
||||
NAME_VAL( LOC_POSITION_MODE_MS_BASED ),
|
||||
NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_5 )
|
||||
};
|
||||
static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_position_mode_name(GpsPositionMode mode)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_position_recurrences[] =
|
||||
{
|
||||
NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ),
|
||||
NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE )
|
||||
};
|
||||
static int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_aiding_data_bits[] =
|
||||
{
|
||||
NAME_VAL( GPS_DELETE_EPHEMERIS ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC ),
|
||||
NAME_VAL( GPS_DELETE_POSITION ),
|
||||
NAME_VAL( GPS_DELETE_TIME ),
|
||||
NAME_VAL( GPS_DELETE_IONO ),
|
||||
NAME_VAL( GPS_DELETE_UTC ),
|
||||
NAME_VAL( GPS_DELETE_HEALTH ),
|
||||
NAME_VAL( GPS_DELETE_SVDIR ),
|
||||
NAME_VAL( GPS_DELETE_SVSTEER ),
|
||||
NAME_VAL( GPS_DELETE_SADATA ),
|
||||
NAME_VAL( GPS_DELETE_RTI ),
|
||||
NAME_VAL( GPS_DELETE_CELLDB_INFO ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC_CORR ),
|
||||
NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
|
||||
NAME_VAL( GPS_DELETE_EPHEMERIS_GLO ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC_GLO ),
|
||||
NAME_VAL( GPS_DELETE_SVDIR_GLO ),
|
||||
NAME_VAL( GPS_DELETE_SVSTEER_GLO ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC_CORR_GLO ),
|
||||
NAME_VAL( GPS_DELETE_TIME_GPS ),
|
||||
NAME_VAL( GPS_DELETE_TIME_GLO )
|
||||
};
|
||||
static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_aiding_data_mask_names(GpsAidingData data)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_agps_types[] =
|
||||
{
|
||||
NAME_VAL( AGPS_TYPE_INVALID ),
|
||||
NAME_VAL( AGPS_TYPE_ANY ),
|
||||
NAME_VAL( AGPS_TYPE_SUPL ),
|
||||
NAME_VAL( AGPS_TYPE_C2K ),
|
||||
NAME_VAL( AGPS_TYPE_WWAN_ANY )
|
||||
};
|
||||
static int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_agps_type_name(AGpsType type)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_ni_types[] =
|
||||
{
|
||||
NAME_VAL( GPS_NI_TYPE_VOICE ),
|
||||
NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
|
||||
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE )
|
||||
};
|
||||
static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_ni_type_name(GpsNiType type)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_ni_responses[] =
|
||||
{
|
||||
NAME_VAL( GPS_NI_RESPONSE_ACCEPT ),
|
||||
NAME_VAL( GPS_NI_RESPONSE_DENY ),
|
||||
NAME_VAL( GPS_NI_RESPONSE_DENY )
|
||||
};
|
||||
static int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_ni_response_name(GpsUserResponseType response)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_ni_encodings[] =
|
||||
{
|
||||
NAME_VAL( GPS_ENC_NONE ),
|
||||
NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ),
|
||||
NAME_VAL( GPS_ENC_SUPL_UTF8 ),
|
||||
NAME_VAL( GPS_ENC_SUPL_UCS2 ),
|
||||
NAME_VAL( GPS_ENC_UNKNOWN )
|
||||
};
|
||||
static int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_agps_bears[] =
|
||||
{
|
||||
NAME_VAL( AGPS_APN_BEARER_INVALID ),
|
||||
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
|
||||
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
|
||||
NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
|
||||
};
|
||||
static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_agps_bear_name(AGpsBearerType bearer)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_server_types[] =
|
||||
{
|
||||
NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ),
|
||||
NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ),
|
||||
NAME_VAL( LOC_AGPS_MPC_SERVER ),
|
||||
NAME_VAL( LOC_AGPS_SUPL_SERVER )
|
||||
};
|
||||
static int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_server_type_name(LocServerType type)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_position_sess_status_types[] =
|
||||
{
|
||||
NAME_VAL( LOC_SESS_SUCCESS ),
|
||||
NAME_VAL( LOC_SESS_INTERMEDIATE ),
|
||||
NAME_VAL( LOC_SESS_FAILURE )
|
||||
};
|
||||
static int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_position_sess_status_name(enum loc_sess_status status)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_agps_status_names[] =
|
||||
{
|
||||
NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ),
|
||||
NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ),
|
||||
NAME_VAL( GPS_AGPS_DATA_CONNECTED ),
|
||||
NAME_VAL( GPS_AGPS_DATA_CONN_DONE ),
|
||||
NAME_VAL( GPS_AGPS_DATA_CONN_FAILED )
|
||||
};
|
||||
static int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_agps_status_name(AGpsStatusValue status)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2011-2013, 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
|
||||
|
@ -27,58 +27,32 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef __LOC_ULP_H__
|
||||
#define __LOC_ULP_H__
|
||||
#ifndef LOC_CORE_LOG_H
|
||||
#define LOC_CORE_LOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdbool.h>
|
||||
#include <hardware/gps.h>
|
||||
|
||||
/** Location has valid source information. */
|
||||
#define LOCATION_HAS_SOURCE_INFO 0x0020
|
||||
/** GpsLocation has valid "is indoor?" flag */
|
||||
#define GPS_LOCATION_HAS_IS_INDOOR 0x0040
|
||||
/** GpsLocation has valid floor number */
|
||||
#define GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080
|
||||
/** GpsLocation has valid map URL*/
|
||||
#define GPS_LOCATION_HAS_MAP_URL 0x0100
|
||||
/** GpsLocation has valid map index */
|
||||
#define GPS_LOCATION_HAS_MAP_INDEX 0x0200
|
||||
|
||||
/** Sizes for indoor fields */
|
||||
#define GPS_LOCATION_MAP_URL_SIZE 400
|
||||
#define GPS_LOCATION_MAP_INDEX_SIZE 16
|
||||
|
||||
/** Position source is ULP */
|
||||
#define ULP_LOCATION_IS_FROM_HYBRID 0x0001
|
||||
/** Position source is GNSS only */
|
||||
#define ULP_LOCATION_IS_FROM_GNSS 0x0002
|
||||
|
||||
#define ULP_MIN_INTERVAL_INVALID 0xffffffff
|
||||
|
||||
|
||||
typedef struct {
|
||||
/** set to sizeof(UlpLocation) */
|
||||
size_t size;
|
||||
GpsLocation gpsLocation;
|
||||
/* Provider indicator for HYBRID or GPS */
|
||||
uint16_t position_source;
|
||||
/*allows HAL to pass additional information related to the location */
|
||||
int rawDataSize; /* in # of bytes */
|
||||
void * rawData;
|
||||
bool is_indoor;
|
||||
float floor_number;
|
||||
char map_url[GPS_LOCATION_MAP_URL_SIZE];
|
||||
unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE];
|
||||
} UlpLocation;
|
||||
#include <gps_extended.h>
|
||||
|
||||
const char* loc_get_gps_status_name(GpsStatusValue gps_status);
|
||||
const char* loc_get_position_mode_name(GpsPositionMode mode);
|
||||
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur);
|
||||
const char* loc_get_aiding_data_mask_names(GpsAidingData data);
|
||||
const char* loc_get_agps_type_name(AGpsType type);
|
||||
const char* loc_get_ni_type_name(GpsNiType type);
|
||||
const char* loc_get_ni_response_name(GpsUserResponseType response);
|
||||
const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding);
|
||||
const char* loc_get_agps_bear_name(AGpsBearerType bear);
|
||||
const char* loc_get_server_type_name(LocServerType type);
|
||||
const char* loc_get_position_sess_status_name(enum loc_sess_status status);
|
||||
const char* loc_get_agps_status_name(AGpsStatusValue status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif //__LOC_ULP_H__
|
||||
#endif /* LOC_CORE_LOG_H */
|
|
@ -6,8 +6,6 @@ LOCAL_PATH := $(call my-dir)
|
|||
ifneq ($(TARGET_NO_RPC),true)
|
||||
|
||||
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc-50001/
|
||||
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc/
|
||||
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api/
|
||||
|
||||
endif #TARGET_NO_RPC
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ source_files:= \
|
|||
src/loc_apicb_appinit.c \
|
||||
src/loc_api_fixup.c \
|
||||
src/loc_api_log.c \
|
||||
src/LocApiRpcAdapter.cpp
|
||||
src/LocApiRpc.cpp
|
||||
|
||||
LOCAL_SRC_FILES:= $(source_files)
|
||||
|
||||
|
@ -26,7 +26,7 @@ LOCAL_SHARED_LIBRARIES:= \
|
|||
libcutils \
|
||||
libcommondefs \
|
||||
libgps.utils \
|
||||
libloc_adapter
|
||||
libloc_core
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libloc_api_rpcgen
|
||||
|
@ -37,20 +37,20 @@ LOCAL_C_INCLUDES:= \
|
|||
$(LOCAL_PATH) \
|
||||
$(LOCAL_PATH)/rpc_inc \
|
||||
$(TARGET_OUT_HEADERS)/gps.utils \
|
||||
$(TARGET_OUT_HEADERS)/libloc_core \
|
||||
$(TARGET_OUT_HEADERS)/loc_api/rpcgen/inc \
|
||||
$(TARGET_OUT_HEADERS)/libcommondefs-rpc \
|
||||
$(TARGET_OUT_HEADERS)/libcommondefs/rpcgen/inc \
|
||||
$(TARGET_OUT_HEADERS)/librpc \
|
||||
$(TARGET_OUT_HEADERS)/libloc-rpc/rpc_inc \
|
||||
$(TARGET_OUT_HEADERS)/libloc_eng \
|
||||
hardware/msm7k/librpc
|
||||
$(TOP)/hardware/msm7k/librpc
|
||||
|
||||
LOCAL_COPY_HEADERS_TO:= libloc_api-rpc-qc/$(RPC_INC)
|
||||
LOCAL_COPY_HEADERS:= \
|
||||
$(RPC_INC)/loc_api_rpc_glue.h \
|
||||
$(RPC_INC)/loc_api_fixup.h \
|
||||
$(RPC_INC)/loc_api_sync_call.h \
|
||||
$(RPC_INC)/loc_apicb_appinit.h
|
||||
$(RPC_INC)/loc_apicb_appinit.h \
|
||||
$(RPC_INC)/LocApiRpc.h
|
||||
|
||||
LOCAL_MODULE:= libloc_api-rpc-qc
|
||||
LOCAL_MODULE_OWNER := qcom
|
||||
|
|
|
@ -26,24 +26,30 @@
|
|||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef LOC_API_RPC_ADAPTER_H
|
||||
#define LOC_API_RPC_ADAPTER_H
|
||||
#ifndef LOC_API_RPC_H
|
||||
#define LOC_API_RPC_H
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
#include <loc_api_rpcgen_common_rpc.h>
|
||||
#include <loc_api_rpc_glue.h>
|
||||
#include <LocApiAdapter.h>
|
||||
#include <LocApiBase.h>
|
||||
#include <loc_log.h>
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
class LocApiRpcAdapter : public LocApiAdapter {
|
||||
class LocApiRpc : public LocApiBase {
|
||||
// RPC communication establishment
|
||||
rpc_loc_client_handle_type client_handle;
|
||||
rpc_loc_event_mask_type eMask;
|
||||
int dataEnableLastSet;
|
||||
char apnLastSet[MAX_APN_LEN];
|
||||
|
||||
static const LOC_API_ADAPTER_EVENT_MASK_T maskAll;
|
||||
static const rpc_loc_event_mask_type locBits[];
|
||||
static rpc_loc_event_mask_type convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);
|
||||
static enum loc_api_adapter_err convertErr(int rpcErr);
|
||||
static GpsNiEncodingType convertNiEncodingType(int loc_encoding);
|
||||
static int NIEventFillVerfiyType(GpsNiNotification ¬if,
|
||||
rpc_loc_ni_notify_verify_e_type notif_priv);
|
||||
|
||||
void reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr);
|
||||
void reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr);
|
||||
|
@ -51,13 +57,16 @@ class LocApiRpcAdapter : public LocApiAdapter {
|
|||
void reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr);
|
||||
void ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr);
|
||||
void NIEvent(const rpc_loc_ni_event_s_type *ni_req_ptr);
|
||||
int NIEventFillVerfiyType(GpsNiNotification ¬if,
|
||||
rpc_loc_ni_notify_verify_e_type notif_priv);
|
||||
GpsNiEncodingType convertNiEncodingType(int loc_encoding);
|
||||
|
||||
virtual enum loc_api_adapter_err
|
||||
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
|
||||
virtual enum loc_api_adapter_err
|
||||
close();
|
||||
|
||||
public:
|
||||
LocApiRpcAdapter(LocEng &locEng);
|
||||
~LocApiRpcAdapter();
|
||||
LocApiRpc(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask);
|
||||
~LocApiRpc();
|
||||
|
||||
int locEventCB(rpc_loc_client_handle_type client_handle,
|
||||
rpc_loc_event_mask_type loc_event,
|
||||
|
@ -67,13 +76,11 @@ public:
|
|||
|
||||
// RPC adapter interface implementations
|
||||
virtual enum loc_api_adapter_err
|
||||
reinit();
|
||||
virtual enum loc_api_adapter_err
|
||||
startFix();
|
||||
startFix(const LocPosMode& posMode);
|
||||
virtual enum loc_api_adapter_err
|
||||
stopFix();
|
||||
virtual enum loc_api_adapter_err
|
||||
setPositionMode(const LocPosMode *mode);
|
||||
setPositionMode(const LocPosMode& mode);
|
||||
inline virtual enum loc_api_adapter_err
|
||||
enableData(int enable) { return enableData(enable, false); }
|
||||
virtual enum loc_api_adapter_err
|
||||
|
@ -108,4 +115,7 @@ public:
|
|||
virtual void setInSession(bool inSession);
|
||||
};
|
||||
|
||||
#endif //LOC_API_RPC_ADAPTER_H
|
||||
extern "C" LocApiBase* getLocApi(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask);
|
||||
|
||||
#endif //LOC_API_RPC_H
|
|
@ -27,24 +27,27 @@
|
|||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_adapter"
|
||||
#define LOG_TAG "LocSvc_api_rpc"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#ifndef USE_GLIB
|
||||
#include <utils/SystemClock.h>
|
||||
#endif /* USE_GLIB */
|
||||
#include "LocApiRpcAdapter.h"
|
||||
#include "loc_api_rpcgen_common_rpc.h"
|
||||
#include "log_util.h"
|
||||
#include "loc_log.h"
|
||||
#include "loc_api_log.h"
|
||||
#include <LocApiRpc.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <loc_api_fixup.h>
|
||||
#include <loc_api_rpc_glue.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_log.h>
|
||||
#include <loc_api_log.h>
|
||||
#ifdef USE_GLIB
|
||||
#include <glib.h>
|
||||
#endif
|
||||
#include "librpc.h"
|
||||
#include "platform_lib_includes.h"
|
||||
#include <librpc.h>
|
||||
#include <platform_lib_includes.h>
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
#define LOC_XTRA_INJECT_DEFAULT_TIMEOUT (3100)
|
||||
#define XTRA_BLOCK_SIZE (3072)
|
||||
|
@ -77,7 +80,7 @@ static int32 loc_event_cb
|
|||
{
|
||||
MODEM_LOG_CALLFLOW(%s, loc_get_event_name(loc_event));
|
||||
loc_callback_log(loc_event, loc_event_payload);
|
||||
int32 ret_val = ((LocApiRpcAdapter*)user)->locEventCB(client_handle, loc_event, loc_event_payload);
|
||||
int32 ret_val = ((LocApiRpc*)user)->locEventCB(client_handle, loc_event, loc_event_payload);
|
||||
EXIT_LOG(%d, ret_val);
|
||||
return ret_val;
|
||||
}
|
||||
|
@ -101,17 +104,21 @@ SIDE EFFECTS
|
|||
static void loc_rpc_global_cb(void* user, CLIENT* clnt, enum rpc_reset_event event)
|
||||
{
|
||||
MODEM_LOG_CALLFLOW(%s, loc_get_rpc_reset_event_name(event));
|
||||
((LocApiRpcAdapter*)user)->locRpcGlobalCB(clnt, event);
|
||||
((LocApiRpc*)user)->locRpcGlobalCB(clnt, event);
|
||||
EXIT_LOG(%p, VOID_RET);
|
||||
}
|
||||
|
||||
const LOC_API_ADAPTER_EVENT_MASK_T LocApiRpc::maskAll =
|
||||
LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
|
||||
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
|
||||
LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |
|
||||
LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |
|
||||
LOC_API_ADAPTER_BIT_IOCTL_REPORT |
|
||||
LOC_API_ADAPTER_BIT_STATUS_REPORT |
|
||||
LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
|
||||
LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;
|
||||
|
||||
LocApiAdapter* getLocApiAdapter(LocEng &locEng)
|
||||
{
|
||||
return new LocApiRpcAdapter(locEng);
|
||||
}
|
||||
|
||||
const rpc_loc_event_mask_type LocApiRpcAdapter::locBits[] =
|
||||
const rpc_loc_event_mask_type LocApiRpc::locBits[] =
|
||||
{
|
||||
RPC_LOC_EVENT_PARSED_POSITION_REPORT,
|
||||
RPC_LOC_EVENT_SATELLITE_REPORT,
|
||||
|
@ -124,27 +131,24 @@ const rpc_loc_event_mask_type LocApiRpcAdapter::locBits[] =
|
|||
RPC_LOC_EVENT_STATUS_REPORT
|
||||
};
|
||||
|
||||
LocApiRpcAdapter::LocApiRpcAdapter(LocEng &locEng) :
|
||||
LocApiAdapter(locEng),
|
||||
// constructor
|
||||
LocApiRpc::LocApiRpc(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask) :
|
||||
LocApiBase(msgTask, exMask),
|
||||
client_handle(RPC_LOC_CLIENT_HANDLE_INVALID),
|
||||
eMask(convertMask(locEng.eventMask)),
|
||||
dataEnableLastSet(-1)
|
||||
{
|
||||
memset(apnLastSet, 0, sizeof(apnLastSet));
|
||||
loc_api_glue_init();
|
||||
}
|
||||
|
||||
LocApiRpcAdapter::~LocApiRpcAdapter()
|
||||
LocApiRpc::~LocApiRpc()
|
||||
{
|
||||
if (RPC_LOC_CLIENT_HANDLE_INVALID != client_handle) {
|
||||
loc_clear(client_handle);
|
||||
}
|
||||
|
||||
loc_close(client_handle);
|
||||
close();
|
||||
}
|
||||
|
||||
rpc_loc_event_mask_type
|
||||
LocApiRpcAdapter::convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask)
|
||||
LocApiRpc::convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask)
|
||||
{
|
||||
rpc_loc_event_mask_type newMask = 0;
|
||||
|
||||
|
@ -159,7 +163,7 @@ LocApiRpcAdapter::convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask)
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::convertErr(int rpcErr)
|
||||
LocApiRpc::convertErr(int rpcErr)
|
||||
{
|
||||
switch(rpcErr)
|
||||
{
|
||||
|
@ -188,7 +192,7 @@ LocApiRpcAdapter::convertErr(int rpcErr)
|
|||
}
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event)
|
||||
void LocApiRpc::locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event)
|
||||
{
|
||||
static rpc_loc_engine_state_e_type last_state = RPC_LOC_ENGINE_STATE_MAX;
|
||||
|
||||
|
@ -208,12 +212,10 @@ void LocApiRpcAdapter::locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event)
|
|||
}
|
||||
}
|
||||
|
||||
int32 LocApiRpcAdapter::locEventCB(rpc_loc_client_handle_type client_handle,
|
||||
int32 LocApiRpc::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)
|
||||
{
|
||||
locEngHandle.acquireWakelock();
|
||||
|
||||
// Parsed report
|
||||
if (loc_event & RPC_LOC_EVENT_PARSED_POSITION_REPORT)
|
||||
{
|
||||
|
@ -269,60 +271,89 @@ int32 LocApiRpcAdapter::locEventCB(rpc_loc_client_handle_type client_handle,
|
|||
NIEvent(&loc_event_payload->rpc_loc_event_payload_u_type_u.ni_request);
|
||||
}
|
||||
|
||||
locEngHandle.releaseWakeLock();
|
||||
return RPC_LOC_API_SUCCESS;//We simply want to return sucess here as we do not want to
|
||||
// cause any issues in RPC thread context
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::reinit()
|
||||
LocApiRpc::open(LOC_API_ADAPTER_EVENT_MASK_T mask)
|
||||
{
|
||||
enum loc_api_adapter_err ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
|
||||
// RPC does not dynamically update the event mask. And in the
|
||||
// case of RPC, all we support are positioning (gps + agps)
|
||||
// masks anyways, so we simply mask all of them on always.
|
||||
// After doing so the first time in a power cycle, we know there
|
||||
// will the following if condition will never be true any more.
|
||||
mask = maskAll;
|
||||
|
||||
if (mask != mMask) {
|
||||
if (RPC_LOC_CLIENT_HANDLE_INVALID != client_handle) {
|
||||
loc_clear(client_handle);
|
||||
close();
|
||||
}
|
||||
|
||||
client_handle = loc_open(eMask, loc_event_cb, loc_rpc_global_cb, this);
|
||||
mMask = mask;
|
||||
// it is important to cap the mask here, because not all LocApi's
|
||||
// can enable the same bits, e.g. foreground and bckground.
|
||||
client_handle = loc_open(convertMask(mask),
|
||||
loc_event_cb,
|
||||
loc_rpc_global_cb, this);
|
||||
|
||||
if (client_handle < 0) {
|
||||
mMask = 0;
|
||||
client_handle = RPC_LOC_CLIENT_HANDLE_INVALID;
|
||||
ret_val = LOC_API_ADAPTER_ERR_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::startFix() {
|
||||
LOC_LOGD("LocApiRpcAdapter::startFix() called");
|
||||
LocApiRpc::close()
|
||||
{
|
||||
if (RPC_LOC_CLIENT_HANDLE_INVALID != client_handle) {
|
||||
loc_clear(client_handle);
|
||||
}
|
||||
|
||||
loc_close(client_handle);
|
||||
mMask = 0;
|
||||
client_handle = RPC_LOC_CLIENT_HANDLE_INVALID;
|
||||
|
||||
return LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpc::startFix(const LocPosMode& posMode) {
|
||||
LOC_LOGD("LocApiRpc::startFix() called");
|
||||
return convertErr(
|
||||
loc_start_fix(client_handle)
|
||||
);
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::stopFix() {
|
||||
LOC_LOGD("LocApiRpcAdapter::stopFix() called");
|
||||
LocApiRpc::stopFix() {
|
||||
LOC_LOGD("LocApiRpc::stopFix() called");
|
||||
return convertErr(
|
||||
loc_stop_fix(client_handle)
|
||||
);
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::setPositionMode(const LocPosMode *posMode)
|
||||
LocApiRpc::setPositionMode(const LocPosMode& posMode)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
rpc_loc_fix_criteria_s_type *fix_criteria_ptr;
|
||||
rpc_loc_fix_criteria_s_type *fix_criteria_ptr =
|
||||
&ioctl_data.rpc_loc_ioctl_data_u_type_u.fix_criteria;
|
||||
rpc_loc_ioctl_e_type ioctl_type = RPC_LOC_IOCTL_SET_FIX_CRITERIA;
|
||||
rpc_loc_operation_mode_e_type op_mode;
|
||||
int ret_val;
|
||||
|
||||
if (NULL != posMode)
|
||||
fixCriteria = *posMode;
|
||||
const LocPosMode* fixCriteria = &posMode;
|
||||
|
||||
ALOGD ("loc_eng_set_position mode, client = %d, interval = %d, mode = %d\n",
|
||||
(int32) client_handle, fixCriteria.min_interval, fixCriteria.mode);
|
||||
(int32) client_handle, fixCriteria->min_interval, fixCriteria->mode);
|
||||
|
||||
switch (fixCriteria.mode)
|
||||
switch (fixCriteria->mode)
|
||||
{
|
||||
case LOC_POSITION_MODE_MS_BASED:
|
||||
op_mode = RPC_LOC_OPER_MODE_MSB;
|
||||
|
@ -348,25 +379,24 @@ LocApiRpcAdapter::setPositionMode(const LocPosMode *posMode)
|
|||
op_mode = RPC_LOC_OPER_MODE_STANDALONE;
|
||||
}
|
||||
|
||||
fix_criteria_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.fix_criteria;
|
||||
fix_criteria_ptr->valid_mask = RPC_LOC_FIX_CRIT_VALID_PREFERRED_OPERATION_MODE |
|
||||
RPC_LOC_FIX_CRIT_VALID_RECURRENCE_TYPE;
|
||||
fix_criteria_ptr->min_interval = fixCriteria.min_interval;
|
||||
fix_criteria_ptr->min_interval = fixCriteria->min_interval;
|
||||
fix_criteria_ptr->preferred_operation_mode = op_mode;
|
||||
|
||||
fix_criteria_ptr->min_interval = fixCriteria.min_interval;
|
||||
fix_criteria_ptr->min_interval = fixCriteria->min_interval;
|
||||
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL;
|
||||
|
||||
if (fixCriteria.preferred_accuracy > 0) {
|
||||
fix_criteria_ptr->preferred_accuracy = fixCriteria.preferred_accuracy;
|
||||
if (fixCriteria->preferred_accuracy > 0) {
|
||||
fix_criteria_ptr->preferred_accuracy = fixCriteria->preferred_accuracy;
|
||||
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_PREFERRED_ACCURACY;
|
||||
}
|
||||
if (fixCriteria.preferred_time > 0) {
|
||||
fix_criteria_ptr->preferred_response_time = fixCriteria.preferred_time;
|
||||
if (fixCriteria->preferred_time > 0) {
|
||||
fix_criteria_ptr->preferred_response_time = fixCriteria->preferred_time;
|
||||
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_PREFERRED_RESPONSE_TIME;
|
||||
}
|
||||
|
||||
switch (fixCriteria.recurrence) {
|
||||
switch (fixCriteria->recurrence) {
|
||||
case GPS_POSITION_RECURRENCE_SINGLE:
|
||||
fix_criteria_ptr->recurrence_type = RPC_LOC_SINGLE_FIX;
|
||||
break;
|
||||
|
@ -387,7 +417,7 @@ LocApiRpcAdapter::setPositionMode(const LocPosMode *posMode)
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
|
||||
LocApiRpc::setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
rpc_loc_assist_data_time_s_type *time_info_ptr;
|
||||
|
@ -413,7 +443,7 @@ LocApiRpcAdapter::setTime(GpsUtcTime time, int64_t timeReference, int uncertaint
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::injectPosition(double latitude, double longitude, float accuracy)
|
||||
LocApiRpc::injectPosition(double latitude, double longitude, float accuracy)
|
||||
{
|
||||
/* IOCTL data */
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
|
@ -452,7 +482,7 @@ LocApiRpcAdapter::injectPosition(double latitude, double longitude, float accura
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::informNiResponse(GpsUserResponseType userResponse,
|
||||
LocApiRpc::informNiResponse(GpsUserResponseType userResponse,
|
||||
const void* passThroughData)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type data;
|
||||
|
@ -489,7 +519,7 @@ LocApiRpcAdapter::informNiResponse(GpsUserResponseType userResponse,
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::setAPN(char* apn, int len, boolean force)
|
||||
LocApiRpc::setAPN(char* apn, int len, boolean force)
|
||||
{
|
||||
enum loc_api_adapter_err rtv = LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
int size = sizeof(apnLastSet);
|
||||
|
@ -500,7 +530,7 @@ LocApiRpcAdapter::setAPN(char* apn, int len, boolean force)
|
|||
}
|
||||
memcpy(apnLastSet, apn, size);
|
||||
|
||||
if (false == navigating) {
|
||||
if (!isInSession()) {
|
||||
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_LBS_APN_PROFILE, {0}};
|
||||
ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].srv_system_type = LOC_APN_PROFILE_SRV_SYS_MAX;
|
||||
ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].pdp_type = LOC_APN_PROFILE_PDN_TYPE_IPV4;
|
||||
|
@ -518,17 +548,16 @@ LocApiRpcAdapter::setAPN(char* apn, int len, boolean force)
|
|||
return rtv;
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::setInSession(bool inSession)
|
||||
void LocApiRpc::setInSession(bool inSession)
|
||||
{
|
||||
LocApiAdapter::setInSession(inSession);
|
||||
if (false == navigating) {
|
||||
if (!inSession) {
|
||||
enableData(dataEnableLastSet, true);
|
||||
setAPN(apnLastSet, sizeof(apnLastSet)-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::setServer(const char* url, int len)
|
||||
LocApiRpc::setServer(const char* url, int len)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
rpc_loc_server_info_s_type *server_info_ptr;
|
||||
|
@ -559,7 +588,7 @@ LocApiRpcAdapter::setServer(const char* url, int len)
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::setServer(unsigned int ip, int port, LocServerType type)
|
||||
LocApiRpc::setServer(unsigned int ip, int port, LocServerType type)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
rpc_loc_server_info_s_type *server_info_ptr;
|
||||
|
@ -594,13 +623,13 @@ LocApiRpcAdapter::setServer(unsigned int ip, int port, LocServerType type)
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::enableData(int enable, boolean force)
|
||||
LocApiRpc::enableData(int enable, boolean force)
|
||||
{
|
||||
enum loc_api_adapter_err rtv = LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
if (force || dataEnableLastSet != enable) {
|
||||
dataEnableLastSet = enable;
|
||||
|
||||
if (false == navigating) {
|
||||
if (!isInSession()) {
|
||||
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_DATA_ENABLE, {0}};
|
||||
|
||||
ioctl_data.rpc_loc_ioctl_data_u_type_u.data_enable = enable;
|
||||
|
@ -617,7 +646,7 @@ LocApiRpcAdapter::enableData(int enable, boolean force)
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::deleteAidingData(GpsAidingData bits)
|
||||
LocApiRpc::deleteAidingData(GpsAidingData bits)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_DELETE_ASSIST_DATA, {0}};
|
||||
ioctl_data.rpc_loc_ioctl_data_u_type_u.assist_data_delete.type = bits;
|
||||
|
@ -631,7 +660,7 @@ LocApiRpcAdapter::deleteAidingData(GpsAidingData bits)
|
|||
);
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr)
|
||||
void LocApiRpc::reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr)
|
||||
{
|
||||
LocPosTechMask tech_Mask = LOC_POS_TECH_MASK_DEFAULT;
|
||||
|
||||
|
@ -723,30 +752,36 @@ void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *loca
|
|||
}
|
||||
|
||||
LOC_LOGV("reportPosition: fire callback\n");
|
||||
LocApiAdapter::reportPosition(location,
|
||||
enum loc_sess_status fixStatus =
|
||||
(location_report_ptr->session_status
|
||||
== RPC_LOC_SESS_STATUS_IN_PROGESS ?
|
||||
LOC_SESS_INTERMEDIATE : LOC_SESS_SUCCESS);
|
||||
LocApiBase::reportPosition(location,
|
||||
locationExtended,
|
||||
locEngHandle.extPosInfo((void*)location_report_ptr),
|
||||
(location_report_ptr->session_status == RPC_LOC_SESS_STATUS_IN_PROGESS ?
|
||||
LOC_SESS_INTERMEDIATE : LOC_SESS_SUCCESS),
|
||||
(void*)location_report_ptr,
|
||||
fixStatus,
|
||||
tech_Mask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LocApiAdapter::reportPosition(location,
|
||||
LocApiBase::reportPosition(location,
|
||||
locationExtended,
|
||||
NULL,
|
||||
LOC_SESS_FAILURE);
|
||||
LOC_LOGV("loc_eng_report_position: ignore position report when session status = %d\n", location_report_ptr->session_status);
|
||||
LOC_LOGV("loc_eng_report_position: ignore position report "
|
||||
"when session status = %d\n",
|
||||
location_report_ptr->session_status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOC_LOGV("loc_eng_report_position: ignore position report when session status is not set\n");
|
||||
LOC_LOGV("loc_eng_report_position: ignore position report "
|
||||
"when session status is not set\n");
|
||||
}
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr)
|
||||
void LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr)
|
||||
{
|
||||
GpsSvStatus SvStatus = {0};
|
||||
GpsLocationExtended locationExtended = {0};
|
||||
|
@ -846,51 +881,52 @@ void LocApiRpcAdapter::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr)
|
|||
|
||||
if (SvStatus.num_svs >= 0)
|
||||
{
|
||||
LocApiAdapter::reportSv(SvStatus,
|
||||
LocApiBase::reportSv(SvStatus,
|
||||
locationExtended,
|
||||
locEngHandle.extSvInfo((void*)gnss_report_ptr));
|
||||
(void*)gnss_report_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::reportStatus(const rpc_loc_status_event_s_type *status_report_ptr)
|
||||
void LocApiRpc::reportStatus(const rpc_loc_status_event_s_type *status_report_ptr)
|
||||
{
|
||||
|
||||
if (status_report_ptr->event == RPC_LOC_STATUS_EVENT_ENGINE_STATE) {
|
||||
if (status_report_ptr->payload.rpc_loc_status_event_payload_u_type_u.engine_state == RPC_LOC_ENGINE_STATE_ON)
|
||||
{
|
||||
LocApiAdapter::reportStatus(GPS_STATUS_ENGINE_ON);
|
||||
LocApiAdapter::reportStatus(GPS_STATUS_SESSION_BEGIN);
|
||||
LocApiBase::reportStatus(GPS_STATUS_ENGINE_ON);
|
||||
LocApiBase::reportStatus(GPS_STATUS_SESSION_BEGIN);
|
||||
}
|
||||
else if (status_report_ptr->payload.rpc_loc_status_event_payload_u_type_u.engine_state == RPC_LOC_ENGINE_STATE_OFF)
|
||||
{
|
||||
LocApiAdapter::reportStatus(GPS_STATUS_SESSION_END);
|
||||
LocApiAdapter::reportStatus(GPS_STATUS_ENGINE_OFF);
|
||||
LocApiBase::reportStatus(GPS_STATUS_SESSION_END);
|
||||
LocApiBase::reportStatus(GPS_STATUS_ENGINE_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocApiAdapter::reportStatus(GPS_STATUS_NONE);
|
||||
LocApiBase::reportStatus(GPS_STATUS_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr)
|
||||
void LocApiRpc::reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr)
|
||||
{
|
||||
|
||||
#if (AMSS_VERSION==3200)
|
||||
LocApiAdapter::reportNmea(nmea_report_ptr->nmea_sentences.nmea_sentences_val,
|
||||
LocApiBase::reportNmea(nmea_report_ptr->nmea_sentences.nmea_sentences_val,
|
||||
nmea_report_ptr->nmea_sentences.nmea_sentences_len);
|
||||
#else
|
||||
LocApiAdapter::reportNmea(nmea_report_ptr->nmea_sentences,
|
||||
LocApiBase::reportNmea(nmea_report_ptr->nmea_sentences,
|
||||
nmea_report_ptr->length);
|
||||
LOC_LOGD("loc_eng_report_nmea: $%c%c%c\n",
|
||||
nmea_report_ptr->nmea_sentences[3], nmea_report_ptr->nmea_sentences[4],
|
||||
nmea_report_ptr->nmea_sentences[3],
|
||||
nmea_report_ptr->nmea_sentences[4],
|
||||
nmea_report_ptr->nmea_sentences[5]);
|
||||
#endif /* #if (AMSS_VERSION==3200) */
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::setXtraData(char* data, int length)
|
||||
LocApiRpc::setXtraData(char* data, int length)
|
||||
{
|
||||
int rpc_ret_val = RPC_LOC_API_GENERAL_FAILURE;
|
||||
int total_parts;
|
||||
|
@ -968,7 +1004,7 @@ LocApiRpcAdapter::setXtraData(char* data, int length)
|
|||
|
||||
/* Request the Xtra Server Url from the modem */
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::requestXtraServer()
|
||||
LocApiRpc::requestXtraServer()
|
||||
{
|
||||
loc_api_adapter_err err;
|
||||
rpc_loc_ioctl_data_u_type data;
|
||||
|
@ -1001,16 +1037,19 @@ LocApiRpcAdapter::requestXtraServer()
|
|||
return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
LocApiAdapter::reportXtraServer(callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_source.servers[0],
|
||||
callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_source.servers[1],
|
||||
callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_source.servers[2],
|
||||
reportXtraServer(callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.
|
||||
predicted_orbits_data_source.servers[0],
|
||||
callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.
|
||||
predicted_orbits_data_source.servers[1],
|
||||
callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.
|
||||
predicted_orbits_data_source.servers[2],
|
||||
255);
|
||||
|
||||
return LOC_API_ADAPTER_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType)
|
||||
LocApiRpc::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType)
|
||||
{
|
||||
rpc_loc_server_open_status_e_type open_status = is_succ ? RPC_LOC_SERVER_OPEN_SUCCESS : RPC_LOC_SERVER_OPEN_FAIL;
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
|
@ -1084,7 +1123,7 @@ LocApiRpcAdapter::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerTy
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::atlCloseStatus(int handle, int is_succ)
|
||||
LocApiRpc::atlCloseStatus(int handle, int is_succ)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
ioctl_data.disc = RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS;
|
||||
|
@ -1104,7 +1143,7 @@ LocApiRpcAdapter::atlCloseStatus(int handle, int is_succ)
|
|||
);
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr)
|
||||
void LocApiRpc::ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr)
|
||||
{
|
||||
int connHandle;
|
||||
AGpsType agps_type;
|
||||
|
@ -1140,7 +1179,7 @@ void LocApiRpcAdapter::ATLEvent(const rpc_loc_server_request_s_type *server_requ
|
|||
}
|
||||
}
|
||||
|
||||
void LocApiRpcAdapter::NIEvent(const rpc_loc_ni_event_s_type *ni_req)
|
||||
void LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req)
|
||||
{
|
||||
GpsNiNotification notif = {0};
|
||||
|
||||
|
@ -1203,7 +1242,7 @@ void LocApiRpcAdapter::NIEvent(const rpc_loc_ni_event_s_type *ni_req)
|
|||
#endif /* #if (AMSS_VERSION==3200) */
|
||||
|
||||
char lcs_addr[32]; // Decoded LCS address for UMTS CP NI
|
||||
addr_len = LocApiAdapter::decodeAddress(lcs_addr, sizeof lcs_addr, address_source,
|
||||
addr_len = decodeAddress(lcs_addr, sizeof lcs_addr, address_source,
|
||||
umts_cp_req->ext_client_address_data.ext_client_address_len);
|
||||
|
||||
// The address is ASCII string
|
||||
|
@ -1283,10 +1322,10 @@ void LocApiRpcAdapter::NIEvent(const rpc_loc_ni_event_s_type *ni_req)
|
|||
// this copy will get freed in loc_eng_ni when loc_ni_respond() is called
|
||||
rpc_loc_ni_event_s_type *copy = (rpc_loc_ni_event_s_type *)malloc(sizeof(*copy));
|
||||
memcpy(copy, ni_req, sizeof(*copy));
|
||||
LocApiAdapter::requestNiNotify(notif, (const void*)copy);
|
||||
requestNiNotify(notif, (const void*)copy);
|
||||
}
|
||||
|
||||
int LocApiRpcAdapter::NIEventFillVerfiyType(GpsNiNotification ¬if,
|
||||
int LocApiRpc::NIEventFillVerfiyType(GpsNiNotification ¬if,
|
||||
rpc_loc_ni_notify_verify_e_type notif_priv)
|
||||
{
|
||||
switch (notif_priv)
|
||||
|
@ -1317,7 +1356,7 @@ int LocApiRpcAdapter::NIEventFillVerfiyType(GpsNiNotification ¬if,
|
|||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpcAdapter::setSUPLVersion(uint32_t version)
|
||||
LocApiRpc::setSUPLVersion(uint32_t version)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_SUPL_VERSION, {0}};
|
||||
ioctl_data.rpc_loc_ioctl_data_u_type_u.supl_version = (int)version;
|
||||
|
@ -1330,7 +1369,7 @@ LocApiRpcAdapter::setSUPLVersion(uint32_t version)
|
|||
);
|
||||
}
|
||||
|
||||
GpsNiEncodingType LocApiRpcAdapter::convertNiEncodingType(int loc_encoding)
|
||||
GpsNiEncodingType LocApiRpc::convertNiEncodingType(int loc_encoding)
|
||||
{
|
||||
switch (loc_encoding)
|
||||
{
|
||||
|
@ -1346,3 +1385,8 @@ GpsNiEncodingType LocApiRpcAdapter::convertNiEncodingType(int loc_encoding)
|
|||
return GPS_ENC_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
LocApiBase* getLocApi(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask) {
|
||||
return new LocApiRpc(msgTask, exMask);
|
||||
}
|
|
@ -5,7 +5,7 @@ LOCAL_PATH := $(call my-dir)
|
|||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libloc_adapter
|
||||
LOCAL_MODULE := libloc_eng
|
||||
LOCAL_MODULE_OWNER := qcom
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
@ -13,51 +13,9 @@ LOCAL_MODULE_TAGS := optional
|
|||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
libcutils \
|
||||
libdl \
|
||||
liblog \
|
||||
libgps.utils \
|
||||
libdl
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
loc_eng_log.cpp \
|
||||
LocApiAdapter.cpp
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-fno-short-enums \
|
||||
-D_ANDROID_
|
||||
|
||||
LOCAL_C_INCLUDES:= \
|
||||
$(TARGET_OUT_HEADERS)/gps.utils \
|
||||
hardware/qcom/gps/loc_api/libloc_api_50001
|
||||
|
||||
LOCAL_COPY_HEADERS_TO:= libloc_eng/
|
||||
LOCAL_COPY_HEADERS:= \
|
||||
LocApiAdapter.h \
|
||||
loc.h \
|
||||
gps_extended.h \
|
||||
loc_eng.h \
|
||||
loc_eng_xtra.h \
|
||||
loc_eng_ni.h \
|
||||
loc_eng_agps.h \
|
||||
loc_eng_msg.h \
|
||||
loc_eng_msg_id.h \
|
||||
loc_eng_log.h \
|
||||
loc_ulp.h
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libloc_eng
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils \
|
||||
libcutils \
|
||||
liblog \
|
||||
libloc_adapter \
|
||||
libloc_core \
|
||||
libgps.utils
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
|
@ -66,7 +24,8 @@ LOCAL_SRC_FILES += \
|
|||
loc_eng_xtra.cpp \
|
||||
loc_eng_ni.cpp \
|
||||
loc_eng_log.cpp \
|
||||
loc_eng_nmea.cpp
|
||||
loc_eng_nmea.cpp \
|
||||
LocEngAdapter.cpp
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
loc_eng_dmn_conn.cpp \
|
||||
|
@ -81,8 +40,22 @@ LOCAL_CFLAGS += \
|
|||
|
||||
LOCAL_C_INCLUDES:= \
|
||||
$(TARGET_OUT_HEADERS)/gps.utils \
|
||||
$(TARGET_OUT_HEADERS)/libloc_core \
|
||||
hardware/qcom/gps/loc_api/libloc_api_50001 \
|
||||
hardware/qcom/gps/loc_api/ulp/inc
|
||||
|
||||
LOCAL_COPY_HEADERS_TO:= libloc_eng/
|
||||
LOCAL_COPY_HEADERS:= \
|
||||
LocEngAdapter.h \
|
||||
loc.h \
|
||||
loc_eng.h \
|
||||
loc_eng_xtra.h \
|
||||
loc_eng_ni.h \
|
||||
loc_eng_agps.h \
|
||||
loc_eng_msg.h \
|
||||
loc_eng_msg_id.h \
|
||||
loc_eng_log.h
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
@ -90,6 +63,7 @@ include $(BUILD_SHARED_LIBRARY)
|
|||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := gps.$(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE)
|
||||
LOCAL_MODULE_OWNER := qcom
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
|
@ -100,6 +74,7 @@ LOCAL_SHARED_LIBRARIES := \
|
|||
libcutils \
|
||||
liblog \
|
||||
libloc_eng \
|
||||
libloc_core \
|
||||
libgps.utils \
|
||||
libdl \
|
||||
libandroid_runtime
|
||||
|
@ -119,6 +94,7 @@ endif
|
|||
## Includes
|
||||
LOCAL_C_INCLUDES:= \
|
||||
$(TARGET_OUT_HEADERS)/gps.utils \
|
||||
$(TARGET_OUT_HEADERS)/libloc_core \
|
||||
hardware/qcom/gps/loc_api/ulp/inc
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
|
|
@ -1,269 +0,0 @@
|
|||
/* Copyright (c) 2011-2012, 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.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_adapter"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <LocApiAdapter.h>
|
||||
#include "loc_eng_msg.h"
|
||||
#include "loc_log.h"
|
||||
#include "loc_eng_ni.h"
|
||||
|
||||
static void* noProc(void* data)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LocEng::LocEng(void* caller,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T emask,
|
||||
gps_acquire_wakelock acqwl,
|
||||
gps_release_wakelock relwl,
|
||||
loc_msg_sender msgSender,
|
||||
loc_msg_sender msgUlpSender,
|
||||
loc_ext_parser posParser,
|
||||
loc_ext_parser svParser) :
|
||||
owner(caller),
|
||||
eventMask(emask), acquireWakelock(acqwl),
|
||||
releaseWakeLock(relwl), sendMsge(msgSender),
|
||||
sendUlpMsg(msgUlpSender),
|
||||
extPosInfo(NULL == posParser ? noProc : posParser),
|
||||
extSvInfo(NULL == svParser ? noProc : svParser)
|
||||
{
|
||||
LOC_LOGV("LocEng constructor %p, %p", posParser, svParser);
|
||||
}
|
||||
|
||||
LocApiAdapter::LocApiAdapter(LocEng &locEng) :
|
||||
locEngHandle(locEng), fixCriteria(), navigating(false)
|
||||
{
|
||||
LOC_LOGD("LocApiAdapter created");
|
||||
}
|
||||
|
||||
LocApiAdapter::~LocApiAdapter()
|
||||
{
|
||||
LOC_LOGV("LocApiAdapter deleted");
|
||||
}
|
||||
|
||||
LocApiAdapter* LocApiAdapter::getLocApiAdapter(LocEng &locEng)
|
||||
{
|
||||
void* handle;
|
||||
LocApiAdapter* adapter = NULL;
|
||||
|
||||
handle = dlopen ("libloc_api_v02.so", RTLD_NOW);
|
||||
|
||||
if (!handle) {
|
||||
handle = dlopen ("libloc_api-rpc-qc.so", RTLD_NOW);
|
||||
}
|
||||
|
||||
if (!handle) {
|
||||
adapter = new LocApiAdapter(locEng);
|
||||
} else {
|
||||
getLocApiAdapter_t* getHandle = (getLocApiAdapter_t*)dlsym(handle, "getLocApiAdapter");
|
||||
|
||||
adapter = (*getHandle)(locEng);
|
||||
}
|
||||
|
||||
return adapter;
|
||||
}
|
||||
|
||||
int LocApiAdapter::hexcode(char *hexstring, int string_size,
|
||||
const char *data, int data_size)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < data_size; i++)
|
||||
{
|
||||
char ch = data[i];
|
||||
if (i*2 + 3 <= string_size)
|
||||
{
|
||||
snprintf(&hexstring[i*2], 3, "%02X", ch);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int LocApiAdapter::decodeAddress(char *addr_string, int string_size,
|
||||
const char *data, int data_size)
|
||||
{
|
||||
const char addr_prefix = 0x91;
|
||||
int i, idxOutput = 0;
|
||||
|
||||
if (!data || !addr_string) { return 0; }
|
||||
|
||||
if (data[0] != addr_prefix)
|
||||
{
|
||||
LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]);
|
||||
addr_string[0] = '\0';
|
||||
return 0; // prefix not correct
|
||||
}
|
||||
|
||||
for (i = 1; i < data_size; i++)
|
||||
{
|
||||
unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4;
|
||||
if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; }
|
||||
if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; }
|
||||
}
|
||||
|
||||
addr_string[idxOutput] = '\0'; // Terminates the string
|
||||
|
||||
return idxOutput;
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask )
|
||||
{
|
||||
loc_eng_msg_report_position *msg(new loc_eng_msg_report_position(locEngHandle.owner,
|
||||
location,
|
||||
locationExtended,
|
||||
locationExt,
|
||||
status,
|
||||
loc_technology_mask));
|
||||
if (locEngHandle.sendUlpMsg) {
|
||||
locEngHandle.sendUlpMsg(locEngHandle.owner, msg);
|
||||
} else {
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportSv(GpsSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt)
|
||||
{
|
||||
loc_eng_msg_report_sv *msg(new loc_eng_msg_report_sv(locEngHandle.owner, svStatus, locationExtended, svExt));
|
||||
|
||||
//We want to send SV info to ULP to help it in determining GNSS signal strength
|
||||
//ULP will forward the SV reports to HAL without any modifications
|
||||
if (locEngHandle.sendUlpMsg) {
|
||||
locEngHandle.sendUlpMsg(locEngHandle.owner, msg);
|
||||
} else {
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportStatus(GpsStatusValue status)
|
||||
{
|
||||
loc_eng_msg_report_status *msg(new loc_eng_msg_report_status(locEngHandle.owner, status));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportNmea(const char* nmea, int length)
|
||||
{
|
||||
loc_eng_msg_report_nmea *msg(new loc_eng_msg_report_nmea(locEngHandle.owner, nmea, length));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportXtraServer(const char* url1, const char* url2, const char* url3, const int maxlength)
|
||||
{
|
||||
loc_eng_msg_report_xtra_server *msg(new loc_eng_msg_report_xtra_server(locEngHandle.owner, url1, url2, url3, maxlength));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::requestATL(int connHandle, AGpsType agps_type)
|
||||
{
|
||||
loc_eng_msg_request_atl *msg(new loc_eng_msg_request_atl(locEngHandle.owner, connHandle, agps_type));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::requestSuplES(int connHandle)
|
||||
{
|
||||
loc_eng_msg_request_supl_es *msg(new loc_eng_msg_request_supl_es(locEngHandle.owner, connHandle));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::releaseDataHandle(void)
|
||||
{
|
||||
loc_eng_msg_close_data_call *msg(new loc_eng_msg_close_data_call(locEngHandle.owner));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::releaseATL(int connHandle)
|
||||
{
|
||||
loc_eng_msg_release_atl *msg(new loc_eng_msg_release_atl(locEngHandle.owner, connHandle));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::requestXtraData()
|
||||
{
|
||||
LOC_LOGD("XTRA download request");
|
||||
|
||||
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_XTRA_DATA));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::requestTime()
|
||||
{
|
||||
LOC_LOGD("loc_event_cb: XTRA time download request");
|
||||
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_TIME));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::requestLocation()
|
||||
{
|
||||
LOC_LOGD("loc_event_cb: XTRA time download request... not supported");
|
||||
// loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_POSITION));
|
||||
// locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::requestNiNotify(GpsNiNotification ¬if, const void* data)
|
||||
{
|
||||
notif.size = sizeof(notif);
|
||||
notif.timeout = LOC_NI_NO_RESPONSE_TIME;
|
||||
|
||||
loc_eng_msg_request_ni *msg(new loc_eng_msg_request_ni(locEngHandle.owner, notif, data));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::handleEngineDownEvent()
|
||||
{
|
||||
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_ENGINE_DOWN));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::handleEngineUpEvent()
|
||||
{
|
||||
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_ENGINE_UP));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportDataCallOpened()
|
||||
{
|
||||
loc_eng_msg_atl_open_success *msg(new loc_eng_msg_atl_open_success(locEngHandle.owner,
|
||||
AGPS_TYPE_INVALID,
|
||||
NULL, 0, 0));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
||||
|
||||
void LocApiAdapter::reportDataCallClosed()
|
||||
{
|
||||
loc_eng_msg_atl_closed *msg(new loc_eng_msg_atl_closed(locEngHandle.owner,
|
||||
AGPS_TYPE_INVALID));
|
||||
locEngHandle.sendMsge(locEngHandle.owner, msg);
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
/* Copyright (c) 2011-2013, 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_API_ADAPTER_H
|
||||
#define LOC_API_ADAPTER_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <hardware/gps.h>
|
||||
#include <loc.h>
|
||||
#include <loc_eng_log.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_eng_msg.h>
|
||||
#include "platform_lib_includes.h"
|
||||
|
||||
#define MAX_APN_LEN 100
|
||||
#define MAX_URL_LEN 256
|
||||
#define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
|
||||
|
||||
enum loc_api_adapter_err {
|
||||
LOC_API_ADAPTER_ERR_SUCCESS = 0,
|
||||
LOC_API_ADAPTER_ERR_GENERAL_FAILURE = 1,
|
||||
LOC_API_ADAPTER_ERR_UNSUPPORTED = 2,
|
||||
LOC_API_ADAPTER_ERR_INVALID_HANDLE = 4,
|
||||
LOC_API_ADAPTER_ERR_INVALID_PARAMETER = 5,
|
||||
LOC_API_ADAPTER_ERR_ENGINE_BUSY = 6,
|
||||
LOC_API_ADAPTER_ERR_PHONE_OFFLINE = 7,
|
||||
LOC_API_ADAPTER_ERR_TIMEOUT = 8,
|
||||
LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,
|
||||
|
||||
LOC_API_ADAPTER_ERR_ENGINE_DOWN = 100,
|
||||
LOC_API_ADAPTER_ERR_FAILURE,
|
||||
LOC_API_ADAPTER_ERR_UNKNOWN
|
||||
};
|
||||
|
||||
enum loc_api_adapter_event_index {
|
||||
LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type
|
||||
LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report
|
||||
LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate
|
||||
LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate
|
||||
LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request
|
||||
LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request
|
||||
LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server
|
||||
LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl
|
||||
LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state
|
||||
|
||||
LOC_API_ADAPTER_EVENT_MAX
|
||||
};
|
||||
|
||||
#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_POSITION)
|
||||
#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
|
||||
#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
|
||||
#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
|
||||
#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
|
||||
#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
|
||||
#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
|
||||
#define LOC_API_ADAPTER_BIT_IOCTL_REPORT (1<<LOC_API_ADAPTER_REPORT_IOCTL)
|
||||
#define LOC_API_ADAPTER_BIT_STATUS_REPORT (1<<LOC_API_ADAPTER_REPORT_STATUS)
|
||||
|
||||
typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
|
||||
typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp);
|
||||
|
||||
struct LocEng {
|
||||
void* owner;
|
||||
LOC_API_ADAPTER_EVENT_MASK_T eventMask;
|
||||
const gps_acquire_wakelock acquireWakelock;
|
||||
const gps_release_wakelock releaseWakeLock;
|
||||
const loc_msg_sender sendMsge;
|
||||
const loc_msg_sender sendUlpMsg;
|
||||
const loc_ext_parser extPosInfo;
|
||||
const loc_ext_parser extSvInfo;
|
||||
|
||||
LocEng(void* caller,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T emask,
|
||||
gps_acquire_wakelock acqwl,
|
||||
gps_release_wakelock relwl,
|
||||
loc_msg_sender msgSender,
|
||||
loc_msg_sender msgUlpSender,
|
||||
loc_ext_parser posParser,
|
||||
loc_ext_parser svParser);
|
||||
};
|
||||
|
||||
class LocApiAdapter {
|
||||
protected:
|
||||
const LocEng locEngHandle;
|
||||
LocPosMode fixCriteria;
|
||||
bool navigating;
|
||||
|
||||
LocApiAdapter(LocEng &locEng);
|
||||
|
||||
public:
|
||||
//LocApiAdapter(int q, reportCb_t[LOC_API_ADAPTER_EVENT_MAX] callbackTable);
|
||||
virtual ~LocApiAdapter();
|
||||
|
||||
static LocApiAdapter* getLocApiAdapter(LocEng &locEng);
|
||||
|
||||
static int hexcode(char *hexstring, int string_size,
|
||||
const char *data, int data_size);
|
||||
static int decodeAddress(char *addr_string, int string_size,
|
||||
const char *data, int data_size);
|
||||
|
||||
void reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask = LOC_POS_TECH_MASK_DEFAULT);
|
||||
void reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt);
|
||||
void reportStatus(GpsStatusValue status);
|
||||
void reportNmea(const char* nmea, int length);
|
||||
void reportXtraServer(const char* url1, const char* url2, const char* url3, const int maxlength);
|
||||
void reportAgpsStatus(AGpsStatus &agpsStatus);
|
||||
void requestXtraData();
|
||||
void requestTime();
|
||||
void requestLocation();
|
||||
void requestATL(int connHandle, AGpsType agps_type);
|
||||
void releaseATL(int connHandle);
|
||||
void requestNiNotify(GpsNiNotification ¬ify, const void* data);
|
||||
void handleEngineDownEvent();
|
||||
void handleEngineUpEvent();
|
||||
void requestSuplES(int connHandle);
|
||||
void releaseDataHandle(void);
|
||||
void reportDataCallOpened(void);
|
||||
void reportDataCallClosed(void);
|
||||
// All below functions are to be defined by adapter specific modules:
|
||||
// RPC, QMI, etc. The default implementation is empty.
|
||||
inline virtual enum loc_api_adapter_err
|
||||
reinit()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
startFix()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
stopFix()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
deleteAidingData(GpsAidingData f)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
enableData(int enable)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setAPN(char* apn, int len)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
injectPosition(double latitude, double longitude, float accuracy)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setXtraData(char* data, int length)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
requestXtraServer()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
atlCloseStatus(int handle, int is_succ)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setPositionMode(const LocPosMode *posMode)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setServer(const char* url, int len)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setServer(unsigned int ip, int port,
|
||||
LocServerType type)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
informNiResponse(GpsUserResponseType userResponse, const void* passThroughData)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setSUPLVersion(uint32_t version)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setLPPConfig(uint32_t profile)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__);
|
||||
return LOC_API_ADAPTER_ERR_SUCCESS; }
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setSensorControlConfig(int sensorUsage)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
|
||||
bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk,
|
||||
bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk,
|
||||
bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk,
|
||||
bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch, int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setExtPowerConfig(int isBatteryCharging)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setAGLONASSProtocol(unsigned long aGlonassProtocol)
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
|
||||
|
||||
inline const LocPosMode& getPositionMode() const {return fixCriteria;}
|
||||
|
||||
inline bool isInSession() { return navigating; }
|
||||
inline virtual void setInSession(bool inSession) { navigating = inSession; }
|
||||
inline virtual int openAndStartDataCall()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return -1;}
|
||||
inline virtual void stopDataCall()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__);}
|
||||
inline virtual void closeDataCall()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__);}
|
||||
inline virtual int initDataServiceClient()
|
||||
{LOC_LOGW("%s: default implementation invoked", __func__); return -1;}
|
||||
|
||||
};
|
||||
|
||||
extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng);
|
||||
|
||||
typedef LocApiAdapter* (getLocApiAdapter_t)(LocEng&);
|
||||
|
||||
#endif //LOC_API_RPC_ADAPTER_H
|
207
loc_api/libloc_api_50001/LocEngAdapter.cpp
Normal file
207
loc_api/libloc_api_50001/LocEngAdapter.cpp
Normal file
|
@ -0,0 +1,207 @@
|
|||
/* Copyright (c) 2011-2013, 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.
|
||||
*
|
||||
*/
|
||||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_EngAdapter"
|
||||
|
||||
#include <LocEngAdapter.h>
|
||||
#include "loc_eng_msg.h"
|
||||
#include "loc_log.h"
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||
void* owner, loc_msg_sender msgSender,
|
||||
MsgTask::tCreate tCreator) :
|
||||
LocAdapterBase(mask,
|
||||
LocDualContext::getLocFgContext(
|
||||
tCreator,
|
||||
LocDualContext::mLocationHalName)),
|
||||
mOwner(owner), mSendUlpMsg(msgSender), mNavigating(false),
|
||||
mAgpsEnabled(loc_core::LocDualContext::hasAgpsExt())
|
||||
{
|
||||
memset(&mFixCriteria, 0, sizeof(mFixCriteria));
|
||||
LOC_LOGD("LocEngAdapter created");
|
||||
}
|
||||
|
||||
inline
|
||||
LocEngAdapter::~LocEngAdapter()
|
||||
{
|
||||
LOC_LOGV("LocEngAdapter deleted");
|
||||
}
|
||||
|
||||
void LocEngAdapter::reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask )
|
||||
{
|
||||
if (mSendUlpMsg) {
|
||||
loc_eng_msg_report_position *msg(
|
||||
new loc_eng_msg_report_position(mOwner,
|
||||
location,
|
||||
locationExtended,
|
||||
locationExt,
|
||||
status,
|
||||
loc_technology_mask));
|
||||
mSendUlpMsg(mOwner, msg);
|
||||
} else {
|
||||
sendMsg(new LocEngReportPosition(mOwner,
|
||||
location,
|
||||
locationExtended,
|
||||
locationExt,
|
||||
status,
|
||||
loc_technology_mask));
|
||||
}
|
||||
}
|
||||
|
||||
void LocEngAdapter::reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt)
|
||||
{
|
||||
|
||||
// We want to send SV info to ULP to help it in determining GNSS
|
||||
// signal strength ULP will forward the SV reports to HAL without
|
||||
// any modifications
|
||||
if (mSendUlpMsg) {
|
||||
loc_eng_msg_report_sv *msg(
|
||||
new loc_eng_msg_report_sv(mOwner, svStatus,
|
||||
locationExtended, svExt));
|
||||
mSendUlpMsg(mOwner, msg);
|
||||
} else {
|
||||
sendMsg(new LocEngReportSv(mOwner, svStatus,
|
||||
locationExtended, svExt));
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void LocEngAdapter::reportStatus(GpsStatusValue status)
|
||||
{
|
||||
sendMsg(new LocEngReportStatus(mOwner, status));
|
||||
}
|
||||
|
||||
inline
|
||||
void LocEngAdapter::reportNmea(const char* nmea, int length)
|
||||
{
|
||||
sendMsg(new LocEngReportNmea(mOwner, nmea, length));
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::reportXtraServer(const char* url1,
|
||||
const char* url2,
|
||||
const char* url3,
|
||||
const int maxlength)
|
||||
{
|
||||
if (mAgpsEnabled) {
|
||||
sendMsg(new LocEngReportXtraServer(mOwner, url1,
|
||||
url2, url3, maxlength));
|
||||
}
|
||||
return mAgpsEnabled;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type)
|
||||
{
|
||||
if (mAgpsEnabled) {
|
||||
sendMsg(new LocEngRequestATL(mOwner,
|
||||
connHandle, agps_type));
|
||||
}
|
||||
return mAgpsEnabled;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::releaseATL(int connHandle)
|
||||
{
|
||||
if (mAgpsEnabled) {
|
||||
sendMsg(new LocEngReleaseATL(mOwner, connHandle));
|
||||
}
|
||||
return mAgpsEnabled;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestXtraData()
|
||||
{
|
||||
if (mAgpsEnabled) {
|
||||
sendMsg(new LocEngRequestXtra(mOwner));
|
||||
}
|
||||
return mAgpsEnabled;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestTime()
|
||||
{
|
||||
if (mAgpsEnabled) {
|
||||
sendMsg(new LocEngRequestXtra(mOwner));
|
||||
}
|
||||
return mAgpsEnabled;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestNiNotify(GpsNiNotification ¬if, const void* data)
|
||||
{
|
||||
if (mAgpsEnabled) {
|
||||
notif.size = sizeof(notif);
|
||||
notif.timeout = LOC_NI_NO_RESPONSE_TIME;
|
||||
|
||||
sendMsg(new LocEngRequestNi(mOwner, notif, data));
|
||||
}
|
||||
return mAgpsEnabled;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::requestSuplES(int connHandle)
|
||||
{
|
||||
sendMsg(new LocEngRequestSuplEs(mOwner, connHandle));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::reportDataCallOpened()
|
||||
{
|
||||
sendMsg(new LocEngSuplEsOpened(mOwner));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LocEngAdapter::reportDataCallClosed()
|
||||
{
|
||||
sendMsg(new LocEngSuplEsClosed(mOwner));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void LocEngAdapter::handleEngineDownEvent()
|
||||
{
|
||||
sendMsg(new LocEngDown(mOwner));
|
||||
}
|
||||
|
||||
inline
|
||||
void LocEngAdapter::handleEngineUpEvent()
|
||||
{
|
||||
sendMsg(new LocEngUp(mOwner));
|
||||
}
|
238
loc_api/libloc_api_50001/LocEngAdapter.h
Normal file
238
loc_api/libloc_api_50001/LocEngAdapter.h
Normal file
|
@ -0,0 +1,238 @@
|
|||
/* Copyright (c) 2011-2013, 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_API_ENG_ADAPTER_H
|
||||
#define LOC_API_ENG_ADAPTER_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <hardware/gps.h>
|
||||
#include <loc.h>
|
||||
#include <loc_eng_log.h>
|
||||
#include <log_util.h>
|
||||
#include <LocAdapterBase.h>
|
||||
#include <LocDualContext.h>
|
||||
#include <platform_lib_includes.h>
|
||||
|
||||
#define MAX_URL_LEN 256
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp);
|
||||
|
||||
class LocEngAdapter : public LocAdapterBase {
|
||||
void* mOwner;
|
||||
loc_msg_sender mSendUlpMsg;
|
||||
LocPosMode mFixCriteria;
|
||||
bool mNavigating;
|
||||
|
||||
public:
|
||||
const bool mAgpsEnabled;
|
||||
|
||||
LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||
void* owner, loc_msg_sender msgSender,
|
||||
MsgTask::tCreate tCreator);
|
||||
virtual ~LocEngAdapter();
|
||||
|
||||
inline enum loc_api_adapter_err
|
||||
startFix()
|
||||
{
|
||||
return mLocApi->startFix(mFixCriteria);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
stopFix()
|
||||
{
|
||||
return mLocApi->stopFix();
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
deleteAidingData(GpsAidingData f)
|
||||
{
|
||||
return mLocApi->deleteAidingData(f);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
enableData(int enable)
|
||||
{
|
||||
return mLocApi->enableData(enable);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setAPN(char* apn, int len)
|
||||
{
|
||||
return mLocApi->setAPN(apn, len);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
injectPosition(double latitude, double longitude, float accuracy)
|
||||
{
|
||||
return mLocApi->injectPosition(latitude, longitude, accuracy);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
|
||||
{
|
||||
return mLocApi->setTime(time, timeReference, uncertainty);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setXtraData(char* data, int length)
|
||||
{
|
||||
return mLocApi->setXtraData(data, length);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
requestXtraServer()
|
||||
{
|
||||
return mLocApi->requestXtraServer();
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType)
|
||||
{
|
||||
return mLocApi->atlOpenStatus(handle, is_succ, apn, bearer, agpsType);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
atlCloseStatus(int handle, int is_succ)
|
||||
{
|
||||
return mLocApi->atlCloseStatus(handle, is_succ);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setPositionMode(const LocPosMode *posMode)
|
||||
{
|
||||
if (NULL != posMode) {
|
||||
mFixCriteria = *posMode;
|
||||
}
|
||||
return mLocApi->setPositionMode(mFixCriteria);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setServer(const char* url, int len)
|
||||
{
|
||||
return mLocApi->setServer(url, len);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setServer(unsigned int ip, int port,
|
||||
LocServerType type)
|
||||
{
|
||||
return mLocApi->setServer(ip, port, type);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
informNiResponse(GpsUserResponseType userResponse, const void* passThroughData)
|
||||
{
|
||||
return mLocApi->informNiResponse(userResponse, passThroughData);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setSUPLVersion(uint32_t version)
|
||||
{
|
||||
return mLocApi->setSUPLVersion(version);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setLPPConfig(uint32_t profile)
|
||||
{
|
||||
return mLocApi->setLPPConfig(profile);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setSensorControlConfig(int sensorUsage)
|
||||
{
|
||||
return mLocApi->setSensorControlConfig(sensorUsage);
|
||||
}
|
||||
inline enum loc_api_adapter_err
|
||||
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
|
||||
bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk,
|
||||
bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk,
|
||||
bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk,
|
||||
bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk)
|
||||
{
|
||||
return mLocApi->setSensorProperties(gyroBiasVarianceRandomWalk_valid, gyroBiasVarianceRandomWalk,
|
||||
accelBiasVarianceRandomWalk_valid, accelBiasVarianceRandomWalk,
|
||||
angleBiasVarianceRandomWalk_valid, angleBiasVarianceRandomWalk,
|
||||
rateBiasVarianceRandomWalk_valid, rateBiasVarianceRandomWalk,
|
||||
velocityBiasVarianceRandomWalk_valid, velocityBiasVarianceRandomWalk);
|
||||
}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch, int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig)
|
||||
{
|
||||
return mLocApi->setSensorPerfControlConfig(controlMode, accelSamplesPerBatch, accelBatchesPerSec,
|
||||
gyroSamplesPerBatch, gyroBatchesPerSec,
|
||||
accelSamplesPerBatchHigh, accelBatchesPerSecHigh,
|
||||
gyroSamplesPerBatchHigh, gyroBatchesPerSecHigh,
|
||||
algorithmConfig);
|
||||
}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setExtPowerConfig(int isBatteryCharging)
|
||||
{
|
||||
return mLocApi->setExtPowerConfig(isBatteryCharging);
|
||||
}
|
||||
inline virtual enum loc_api_adapter_err
|
||||
setAGLONASSProtocol(unsigned long aGlonassProtocol)
|
||||
{
|
||||
return mLocApi->setAGLONASSProtocol(aGlonassProtocol);
|
||||
}
|
||||
inline virtual int initDataServiceClient()
|
||||
{
|
||||
return mLocApi->initDataServiceClient();
|
||||
}
|
||||
inline virtual int openAndStartDataCall()
|
||||
{
|
||||
return mLocApi->openAndStartDataCall();
|
||||
}
|
||||
inline virtual void stopDataCall()
|
||||
{
|
||||
mLocApi->stopDataCall();
|
||||
}
|
||||
inline virtual void closeDataCall()
|
||||
{
|
||||
mLocApi->closeDataCall();
|
||||
}
|
||||
|
||||
virtual void handleEngineDownEvent();
|
||||
virtual void handleEngineUpEvent();
|
||||
virtual void reportPosition(UlpLocation &location,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* locationExt,
|
||||
enum loc_sess_status status,
|
||||
LocPosTechMask loc_technology_mask);
|
||||
virtual void reportSv(GpsSvStatus &svStatus,
|
||||
GpsLocationExtended &locationExtended,
|
||||
void* svExt);
|
||||
virtual void reportStatus(GpsStatusValue status);
|
||||
virtual void reportNmea(const char* nmea, int length);
|
||||
virtual bool reportXtraServer(const char* url1, const char* url2,
|
||||
const char* url3, const int maxlength);
|
||||
virtual bool requestXtraData();
|
||||
virtual bool requestTime();
|
||||
virtual bool requestATL(int connHandle, AGpsType agps_type);
|
||||
virtual bool releaseATL(int connHandle);
|
||||
virtual bool requestNiNotify(GpsNiNotification ¬ify, const void* data);
|
||||
virtual bool requestSuplES(int connHandle);
|
||||
virtual bool reportDataCallOpened();
|
||||
virtual bool reportDataCallClosed();
|
||||
|
||||
inline const LocPosMode& getPositionMode() const
|
||||
{return mFixCriteria;}
|
||||
inline virtual bool isInSession()
|
||||
{ return mNavigating; }
|
||||
inline void setInSession(bool inSession)
|
||||
{ mNavigating = inSession; mLocApi->setInSession(inSession); }
|
||||
};
|
||||
|
||||
#endif //LOC_API_ENG_ADAPTER_H
|
|
@ -5,7 +5,7 @@ AM_CFLAGS = \
|
|||
-fno-short-enums \
|
||||
-DFEATURE_GNSS_BIT_API
|
||||
|
||||
libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocApiAdapter.cpp
|
||||
libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocEngAdapter.cpp
|
||||
|
||||
if USE_GLIB
|
||||
libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
|
||||
|
@ -62,7 +62,7 @@ endif
|
|||
libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la
|
||||
|
||||
library_include_HEADERS = \
|
||||
LocApiAdapter.h \
|
||||
LocEngAdapter.h \
|
||||
loc.h \
|
||||
loc_eng.h \
|
||||
loc_eng_xtra.h \
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Not a Contribution.
|
||||
*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef GPS_EXTENDED_H
|
||||
#define GPS_EXTENDED_H
|
||||
|
||||
/** AGPS type */
|
||||
typedef int16_t AGpsExtType;
|
||||
#define AGPS_TYPE_INVALID -1
|
||||
#define AGPS_TYPE_ANY 0
|
||||
#define AGPS_TYPE_SUPL 1
|
||||
#define AGPS_TYPE_C2K 2
|
||||
#define AGPS_TYPE_WWAN_ANY 3
|
||||
#define AGPS_TYPE_WIFI 4
|
||||
|
||||
/** SSID length */
|
||||
#define SSID_BUF_SIZE (32+1)
|
||||
|
||||
typedef int16_t AGpsBearerType;
|
||||
#define AGPS_APN_BEARER_INVALID -1
|
||||
#define AGPS_APN_BEARER_IPV4 0
|
||||
#define AGPS_APN_BEARER_IPV6 1
|
||||
#define AGPS_APN_BEARER_IPV4V6 2
|
||||
|
||||
#define GPS_DELETE_ALMANAC_CORR 0x00001000
|
||||
#define GPS_DELETE_FREQ_BIAS_EST 0x00002000
|
||||
#define GPS_DELETE_EPHEMERIS_GLO 0x00004000
|
||||
#define GPS_DELETE_ALMANAC_GLO 0x00008000
|
||||
#define GPS_DELETE_SVDIR_GLO 0x00010000
|
||||
#define GPS_DELETE_SVSTEER_GLO 0x00020000
|
||||
#define GPS_DELETE_ALMANAC_CORR_GLO 0x00040000
|
||||
#define GPS_DELETE_TIME_GPS 0x00080000
|
||||
#define GPS_DELETE_TIME_GLO 0x00100000
|
||||
|
||||
/** GPS extended callback structure. */
|
||||
typedef struct {
|
||||
/** set to sizeof(GpsCallbacks) */
|
||||
size_t size;
|
||||
gps_set_capabilities set_capabilities_cb;
|
||||
gps_acquire_wakelock acquire_wakelock_cb;
|
||||
gps_release_wakelock release_wakelock_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
gps_request_utc_time request_utc_time_cb;
|
||||
} GpsExtCallbacks;
|
||||
|
||||
/** Callback to report the xtra server url to the client.
|
||||
* The client should use this url when downloading xtra unless overwritten
|
||||
* in the gps.conf file
|
||||
*/
|
||||
typedef void (* report_xtra_server)(const char*, const char*, const char*);
|
||||
|
||||
/** Callback structure for the XTRA interface. */
|
||||
typedef struct {
|
||||
gps_xtra_download_request download_request_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
report_xtra_server report_xtra_server_cb;
|
||||
} GpsXtraExtCallbacks;
|
||||
|
||||
/** Represents the status of AGPS. */
|
||||
typedef struct {
|
||||
/** set to sizeof(AGpsExtStatus) */
|
||||
size_t size;
|
||||
|
||||
AGpsExtType type;
|
||||
AGpsStatusValue status;
|
||||
uint32_t ipv4_addr;
|
||||
char ipv6_addr[16];
|
||||
char ssid[SSID_BUF_SIZE];
|
||||
char password[SSID_BUF_SIZE];
|
||||
} AGpsExtStatus;
|
||||
|
||||
/** Callback with AGPS status information.
|
||||
* Can only be called from a thread created by create_thread_cb.
|
||||
*/
|
||||
typedef void (* agps_status_extended)(AGpsExtStatus* status);
|
||||
|
||||
/** Callback structure for the AGPS interface. */
|
||||
typedef struct {
|
||||
agps_status_extended status_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
} AGpsExtCallbacks;
|
||||
|
||||
|
||||
/** GPS NI callback structure. */
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* Sends the notification request from HAL to GPSLocationProvider.
|
||||
*/
|
||||
gps_ni_notify_callback notify_cb;
|
||||
gps_create_thread create_thread_cb;
|
||||
} GpsNiExtCallbacks;
|
||||
|
||||
#endif /* GPS_EXTENDED_H */
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
#define LOG_TAG "LocSvc_afw"
|
||||
|
||||
#include <hardware/gps.h>
|
||||
#include <loc_ulp.h>
|
||||
#include <gps_extended.h>
|
||||
#include <loc_eng.h>
|
||||
#include <loc_target.h>
|
||||
#include <loc_log.h>
|
||||
|
@ -43,9 +43,16 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <android_runtime/AndroidRuntime.h>
|
||||
|
||||
#include <LocDualContext.h>
|
||||
#include <loc_eng_msg.h>
|
||||
#include <cutils/properties.h>
|
||||
|
||||
namespace android {
|
||||
namespace AndroidRuntime {
|
||||
void* createJavaThread(const char* name, void (*start)(void *), void* arg);
|
||||
}
|
||||
}
|
||||
|
||||
//Globals defns
|
||||
static const ulpInterface * loc_eng_ulp_inf = NULL;
|
||||
static const ulpInterface * loc_eng_get_ulp_inf(void);
|
||||
|
@ -206,7 +213,7 @@ const GpsInterface* gps_get_hardware_interface ()
|
|||
extern "C" const GpsInterface* get_gps_interface()
|
||||
{
|
||||
unsigned int target = TARGET_DEFAULT;
|
||||
if (NULL == loc_afw_data.context) {
|
||||
if (NULL == loc_afw_data.adapter) {
|
||||
loc_eng_read_config();
|
||||
|
||||
//We load up libulp module at this point itself
|
||||
|
@ -245,8 +252,8 @@ static void loc_free_msg(void* msg)
|
|||
|
||||
void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg)
|
||||
{
|
||||
LocEngContext* loc_eng_context = (LocEngContext*)((loc_eng_data_s_type*)loc_eng_data_p)->context;
|
||||
msg_q_snd((void*)loc_eng_context->ulp_q, msg, loc_free_msg);
|
||||
loc_eng_data_s_type* loc_eng = (loc_eng_data_s_type*)loc_eng_data_p;
|
||||
msg_q_snd(loc_eng->ulp_q, msg, loc_free_msg);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
|
@ -270,17 +277,16 @@ static int loc_hal_init(void)
|
|||
{
|
||||
int retVal = -1;
|
||||
ENTRY_LOG();
|
||||
LOC_API_ADAPTER_EVENT_MASK_T event;
|
||||
|
||||
#ifdef TARGET_USES_QCOM_BSP
|
||||
LOC_API_ADAPTER_EVENT_MASK_T event =
|
||||
LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
|
||||
if (loc_core::LocDualContext::hasAgpsExt()) {
|
||||
event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
|
||||
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
|
||||
LOC_API_ADAPTER_BIT_IOCTL_REPORT |
|
||||
LOC_API_ADAPTER_BIT_STATUS_REPORT |
|
||||
LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT;
|
||||
#else
|
||||
LOC_API_ADAPTER_EVENT_MASK_T event =
|
||||
LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
|
||||
} else {
|
||||
event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
|
||||
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
|
||||
LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |
|
||||
LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |
|
||||
|
@ -288,7 +294,7 @@ static int loc_hal_init(void)
|
|||
LOC_API_ADAPTER_BIT_STATUS_REPORT |
|
||||
LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
|
||||
LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;
|
||||
#endif
|
||||
}
|
||||
LocCallbacks clientCallbacks = {local_loc_cb, /* location_cb */
|
||||
local_status_cb, /* status_cb */
|
||||
local_sv_cb, /* sv_status_cb */
|
||||
|
@ -467,9 +473,9 @@ static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertain
|
|||
ENTRY_LOG();
|
||||
int ret_val = 0;
|
||||
|
||||
#ifndef TARGET_USES_QCOM_BSP
|
||||
if (loc_core::LocDualContext::hasAgpsExt()) {
|
||||
ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty);
|
||||
#endif
|
||||
}
|
||||
|
||||
EXIT_LOG(%d, ret_val);
|
||||
return ret_val;
|
||||
|
@ -610,21 +616,21 @@ const void* loc_get_extension(const char* name)
|
|||
LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name);
|
||||
if (strcmp(name, GPS_XTRA_INTERFACE) == 0)
|
||||
{
|
||||
#ifndef TARGET_USES_QCOM_BSP
|
||||
if (loc_core::LocDualContext::hasAgpsExt()) {
|
||||
ret_val = &sLocEngXTRAInterface;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, AGPS_INTERFACE) == 0)
|
||||
{
|
||||
#ifndef TARGET_USES_QCOM_BSP
|
||||
if (loc_core::LocDualContext::hasAgpsExt()) {
|
||||
ret_val = &sLocEngAGpsInterface;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, GPS_NI_INTERFACE) == 0)
|
||||
{
|
||||
#ifndef TARGET_USES_QCOM_BSP
|
||||
if (loc_core::LocDualContext::hasAgpsExt()) {
|
||||
ret_val = &sLocEngNiInterface;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, AGPS_RIL_INTERFACE) == 0)
|
||||
{
|
||||
|
@ -1022,7 +1028,7 @@ static int loc_init(GpsCallbacks* callbacks)
|
|||
EXIT_LOG(%d, retVal);
|
||||
return retVal;
|
||||
}
|
||||
memset(&afw_cb_data, NULL, sizeof (LocCallbacks));
|
||||
memset(&afw_cb_data, 0, sizeof (afw_cb_data));
|
||||
gps_loc_cb = callbacks->location_cb;
|
||||
afw_cb_data.status_cb = callbacks->status_cb;
|
||||
gps_sv_cb = callbacks->sv_status_cb;
|
||||
|
|
|
@ -37,28 +37,7 @@ extern "C" {
|
|||
#include <ctype.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <hardware/gps.h>
|
||||
#include <loc_ulp.h>
|
||||
#include "gps_extended.h"
|
||||
|
||||
#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */
|
||||
|
||||
typedef enum loc_server_type {
|
||||
LOC_AGPS_CDMA_PDE_SERVER,
|
||||
LOC_AGPS_CUSTOM_PDE_SERVER,
|
||||
LOC_AGPS_MPC_SERVER,
|
||||
LOC_AGPS_SUPL_SERVER
|
||||
} LocServerType;
|
||||
|
||||
typedef enum loc_position_mode_type {
|
||||
LOC_POSITION_MODE_STANDALONE,
|
||||
LOC_POSITION_MODE_MS_BASED,
|
||||
LOC_POSITION_MODE_MS_ASSISTED,
|
||||
LOC_POSITION_MODE_RESERVED_1,
|
||||
LOC_POSITION_MODE_RESERVED_2,
|
||||
LOC_POSITION_MODE_RESERVED_3,
|
||||
LOC_POSITION_MODE_RESERVED_4,
|
||||
LOC_POSITION_MODE_RESERVED_5
|
||||
} LocPositionMode;
|
||||
#include <gps_extended.h>
|
||||
|
||||
typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt);
|
||||
typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt);
|
||||
|
@ -78,22 +57,6 @@ typedef struct {
|
|||
gps_request_utc_time request_utc_time_cb;
|
||||
} LocCallbacks;
|
||||
|
||||
enum loc_sess_status {
|
||||
LOC_SESS_SUCCESS,
|
||||
LOC_SESS_INTERMEDIATE,
|
||||
LOC_SESS_FAILURE
|
||||
};
|
||||
|
||||
typedef uint32_t LocPosTechMask;
|
||||
#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000)
|
||||
#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001)
|
||||
#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002)
|
||||
#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004)
|
||||
#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008)
|
||||
#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010)
|
||||
#define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020)
|
||||
#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)
|
||||
#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)
|
||||
void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -55,9 +55,8 @@ typedef unsigned char boolean;
|
|||
#include <loc_cfg.h>
|
||||
#include <loc_log.h>
|
||||
#include <log_util.h>
|
||||
#include <loc_eng_msg.h>
|
||||
#include <loc_eng_agps.h>
|
||||
#include <LocApiAdapter.h>
|
||||
#include <LocEngAdapter.h>
|
||||
|
||||
// The data connection minimal open time
|
||||
#define DATA_OPEN_MIN_TIME 1 /* sec */
|
||||
|
@ -79,25 +78,10 @@ enum loc_mute_session_e_type {
|
|||
LOC_MUTE_SESS_IN_SESSION
|
||||
};
|
||||
|
||||
struct LocEngContext {
|
||||
// Data variables used by deferred action thread
|
||||
const void* deferred_q;
|
||||
const void* ulp_q;
|
||||
const pthread_t deferred_action_thread;
|
||||
static LocEngContext* get(gps_create_thread threadCreator);
|
||||
void drop();
|
||||
static pthread_mutex_t lock;
|
||||
static pthread_cond_t cond;
|
||||
private:
|
||||
int counter;
|
||||
static LocEngContext *me;
|
||||
LocEngContext(gps_create_thread threadCreator);
|
||||
};
|
||||
|
||||
// Module data
|
||||
typedef struct loc_eng_data_s
|
||||
{
|
||||
LocApiAdapter *client_handle;
|
||||
LocEngAdapter *adapter;
|
||||
loc_location_cb_ext location_cb;
|
||||
gps_status_callback status_cb;
|
||||
loc_sv_status_cb_ext sv_status_cb;
|
||||
|
@ -109,9 +93,6 @@ typedef struct loc_eng_data_s
|
|||
gps_request_utc_time request_utc_time_cb;
|
||||
boolean intermediateFix;
|
||||
AGpsStatusValue agps_status;
|
||||
// used to defer stopping the GPS engine until AGPS data calls are done
|
||||
boolean agps_request_pending;
|
||||
boolean stop_request_pending;
|
||||
loc_eng_xtra_data_s_type xtra_module_data;
|
||||
loc_eng_ni_data_s_type loc_eng_ni_data;
|
||||
|
||||
|
@ -129,8 +110,6 @@ typedef struct loc_eng_data_s
|
|||
// Aiding data information to be deleted, aiding data can only be deleted when GPS engine is off
|
||||
GpsAidingData aiding_data_for_deletion;
|
||||
|
||||
void* context;
|
||||
|
||||
// For muting session broadcast
|
||||
loc_mute_session_e_type mute_session_state;
|
||||
|
||||
|
@ -151,7 +130,10 @@ typedef struct loc_eng_data_s
|
|||
int mpc_host_set;
|
||||
char mpc_host_buf[101];
|
||||
int mpc_port_buf;
|
||||
bool ulp_initialized;
|
||||
void *ulp_q;
|
||||
|
||||
loc_ext_parser location_ext_parser;
|
||||
loc_ext_parser sv_ext_parser;
|
||||
} loc_eng_data_s_type;
|
||||
|
||||
#include "ulp.h"
|
||||
|
@ -256,6 +238,7 @@ extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
|
|||
const void* passThrough);
|
||||
extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);
|
||||
int loc_eng_read_config(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <loc_eng_agps.h>
|
||||
#include <loc_eng_log.h>
|
||||
#include <log_util.h>
|
||||
#include "platform_lib_includes.h"
|
||||
#include <platform_lib_includes.h>
|
||||
#include <loc_eng_dmn_conn_handler.h>
|
||||
#include <loc_eng_dmn_conn.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -109,7 +109,7 @@ bool BITSubscriber::equals(const Subscriber *s) const
|
|||
|
||||
return (ID == bitS->ID &&
|
||||
(INADDR_NONE != (unsigned int)ID ||
|
||||
0 == strncmp(ipv6Addr, bitS->ipv6Addr, sizeof(ipv6Addr))));
|
||||
0 == strncmp(mIPv6Addr, bitS->mIPv6Addr, sizeof(mIPv6Addr))));
|
||||
}
|
||||
|
||||
bool BITSubscriber::notifyRsrcStatus(Notification ¬ification)
|
||||
|
@ -152,13 +152,13 @@ bool ATLSubscriber::notifyRsrcStatus(Notification ¬ification)
|
|||
{
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
case RSRC_RELEASED:
|
||||
((LocApiAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
|
||||
((LocEngAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
|
||||
break;
|
||||
case RSRC_DENIED:
|
||||
{
|
||||
AGpsExtType type = mBackwardCompatibleMode ?
|
||||
AGPS_TYPE_INVALID : mStateMachine->getType();
|
||||
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
|
||||
((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
|
||||
(char*)mStateMachine->getAPN(),
|
||||
mStateMachine->getBearer(),
|
||||
type);
|
||||
|
@ -168,7 +168,7 @@ bool ATLSubscriber::notifyRsrcStatus(Notification ¬ification)
|
|||
{
|
||||
AGpsExtType type = mBackwardCompatibleMode ?
|
||||
AGPS_TYPE_INVALID : mStateMachine->getType();
|
||||
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
|
||||
((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
|
||||
(char*)mStateMachine->getAPN(),
|
||||
mStateMachine->getBearer(),
|
||||
type);
|
||||
|
@ -627,6 +627,7 @@ AgpsStateMachine::AgpsStateMachine(servicerType servType,
|
|||
mStatePtr(new AgpsReleasedState(this)),mType(type),
|
||||
mAPN(NULL),
|
||||
mAPNLen(0),
|
||||
mBearer(AGPS_APN_BEARER_INVALID),
|
||||
mEnforceSingleSubscriber(enforceSingleSubscriber),
|
||||
mServicer(Servicer :: getServicer(servType, (void *)cb_func))
|
||||
{
|
||||
|
@ -826,7 +827,7 @@ err:
|
|||
}
|
||||
|
||||
DSStateMachine :: DSStateMachine(servicerType type, void *cb_func,
|
||||
LocApiAdapter* adapterHandle):
|
||||
LocEngAdapter* adapterHandle):
|
||||
AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false),
|
||||
mLocAdapter(adapterHandle)
|
||||
{
|
||||
|
@ -947,17 +948,17 @@ void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const
|
|||
LOC_LOGD("DSStateMachine :: informStatus. Status=%d\n",(int)status);
|
||||
switch(status) {
|
||||
case RSRC_UNSUBSCRIBE:
|
||||
((LocApiAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
|
||||
mLocAdapter->atlCloseStatus(ID, 1);
|
||||
break;
|
||||
case RSRC_RELEASED:
|
||||
((LocApiAdapter*)mLocAdapter)->releaseDataHandle();
|
||||
mLocAdapter->closeDataCall();
|
||||
break;
|
||||
case RSRC_DENIED:
|
||||
((DSStateMachine *)this)->mRetries = 0;
|
||||
mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL);
|
||||
break;
|
||||
case RSRC_GRANTED:
|
||||
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
|
||||
mLocAdapter->atlOpenStatus(ID, 1,
|
||||
NULL,
|
||||
AGPS_APN_BEARER_INVALID,
|
||||
AGPS_TYPE_INVALID);
|
||||
|
|
|
@ -35,10 +35,11 @@
|
|||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <hardware/gps.h>
|
||||
#include <gps_extended.h>
|
||||
#include <loc_core_log.h>
|
||||
#include <linked_list.h>
|
||||
#include <LocApiAdapter.h>
|
||||
#include "loc_eng_msg.h"
|
||||
#include <loc_timer.h>
|
||||
#include <LocEngAdapter.h>
|
||||
|
||||
// forward declaration
|
||||
class AgpsStateMachine;
|
||||
|
@ -62,7 +63,7 @@ typedef enum {
|
|||
|
||||
//DS Callback struct
|
||||
typedef struct {
|
||||
LocApiAdapter *mAdapter;
|
||||
LocEngAdapter *mAdapter;
|
||||
AGpsStatusValue action;
|
||||
}dsCbData;
|
||||
|
||||
|
@ -249,12 +250,12 @@ public:
|
|||
class DSStateMachine : public AgpsStateMachine {
|
||||
static const unsigned char MAX_START_DATA_CALL_RETRIES;
|
||||
static const unsigned int DATA_CALL_RETRY_DELAY_MSEC;
|
||||
LocApiAdapter* mLocAdapter;
|
||||
LocEngAdapter* mLocAdapter;
|
||||
unsigned char mRetries;
|
||||
public:
|
||||
DSStateMachine(servicerType type,
|
||||
void *cb_func,
|
||||
LocApiAdapter* adapterHandle);
|
||||
LocEngAdapter* adapterHandle);
|
||||
int sendRsrcRequest(AGpsStatusValue action) const;
|
||||
void onRsrcEvent(AgpsRsrcStatus event);
|
||||
void retryCallback();
|
||||
|
@ -297,40 +298,40 @@ struct Subscriber {
|
|||
|
||||
// BITSubscriber, created with requests from BIT daemon
|
||||
struct BITSubscriber : public Subscriber {
|
||||
char mIPv6Addr[16];
|
||||
|
||||
inline BITSubscriber(const AgpsStateMachine* stateMachine,
|
||||
unsigned int ipv4, char* ipv6) :
|
||||
Subscriber(ipv4, stateMachine)
|
||||
{
|
||||
if (NULL == ipv6) {
|
||||
ipv6Addr[0] = NULL;
|
||||
mIPv6Addr[0] = 0;
|
||||
} else {
|
||||
memcpy(ipv6Addr, ipv6, sizeof(ipv6Addr));
|
||||
memcpy(mIPv6Addr, ipv6, sizeof(mIPv6Addr));
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool notifyRsrcStatus(Notification ¬ification);
|
||||
|
||||
inline virtual void setIPAddresses(uint32_t &v4, char* v6)
|
||||
{ v4 = ID; memcpy(v6, ipv6Addr, sizeof(ipv6Addr)); }
|
||||
{ v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); }
|
||||
|
||||
virtual Subscriber* clone()
|
||||
{
|
||||
return new BITSubscriber(mStateMachine, ID, ipv6Addr);
|
||||
return new BITSubscriber(mStateMachine, ID, mIPv6Addr);
|
||||
}
|
||||
|
||||
virtual bool equals(const Subscriber *s) const;
|
||||
inline virtual ~BITSubscriber(){}
|
||||
private:
|
||||
char ipv6Addr[16];
|
||||
};
|
||||
|
||||
// ATLSubscriber, created with requests from ATL
|
||||
struct ATLSubscriber : public Subscriber {
|
||||
const LocApiAdapter* mLocAdapter;
|
||||
const LocEngAdapter* mLocAdapter;
|
||||
const bool mBackwardCompatibleMode;
|
||||
inline ATLSubscriber(const int id,
|
||||
const AgpsStateMachine* stateMachine,
|
||||
const LocApiAdapter* adapter,
|
||||
const LocEngAdapter* adapter,
|
||||
const bool compatibleMode) :
|
||||
Subscriber(id, stateMachine), mLocAdapter(adapter),
|
||||
mBackwardCompatibleMode(compatibleMode){}
|
||||
|
|
|
@ -49,24 +49,24 @@ int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg,
|
|||
}
|
||||
|
||||
if (NULL != loc_api_handle) {
|
||||
loc_if_req_type_e_type type;
|
||||
AGpsExtType type;
|
||||
switch (pmsg->cmsg.cmsg_if_request.type) {
|
||||
case IF_REQUEST_TYPE_SUPL:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_TYPE_SUPL");
|
||||
type = LOC_ENG_IF_REQUEST_TYPE_SUPL;
|
||||
type = AGPS_TYPE_SUPL;
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_TYPE_WIFI:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_TYPE_WIFI");
|
||||
type = LOC_ENG_IF_REQUEST_TYPE_WIFI;
|
||||
type = AGPS_TYPE_WIFI;
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_TYPE_ANY:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_TYPE_ANY");
|
||||
type = LOC_ENG_IF_REQUEST_TYPE_ANY;
|
||||
type = AGPS_TYPE_ANY;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -79,48 +79,52 @@ int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg,
|
|||
case IF_REQUEST_SENDER_ID_QUIPC:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC");
|
||||
loc_eng_msg_request_wifi *msg(
|
||||
new loc_eng_msg_request_wifi(loc_api_handle,
|
||||
LocEngReqRelWifi* msg =
|
||||
new LocEngReqRelWifi(loc_api_handle,
|
||||
type,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ssid,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password,
|
||||
true);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_SENDER_ID_MSAPM:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM");
|
||||
loc_eng_msg_request_wifi *msg(
|
||||
new loc_eng_msg_request_wifi(loc_api_handle,
|
||||
LocEngReqRelWifi* msg =
|
||||
new LocEngReqRelWifi(loc_api_handle,
|
||||
type,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ssid,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password,
|
||||
true);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_SENDER_ID_MSAPU:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU");
|
||||
loc_eng_msg_request_wifi *msg(
|
||||
new loc_eng_msg_request_wifi(loc_api_handle,
|
||||
LocEngReqRelWifi* msg =
|
||||
new LocEngReqRelWifi(loc_api_handle,
|
||||
type,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ssid,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password,
|
||||
true);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON");
|
||||
loc_eng_msg_request_bit *msg(
|
||||
new loc_eng_msg_request_bit(loc_api_handle,
|
||||
LocEngReqRelBIT* msg =
|
||||
new LocEngReqRelBIT(loc_api_handle,
|
||||
type,
|
||||
pmsg->cmsg.cmsg_if_request.ipv4_addr,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,
|
||||
true);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -141,24 +145,24 @@ int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg,
|
|||
{
|
||||
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
|
||||
#ifndef DEBUG_DMN_LOC_API
|
||||
loc_if_req_type_e_type type;
|
||||
AGpsExtType type;
|
||||
switch (pmsg->cmsg.cmsg_if_request.type) {
|
||||
case IF_REQUEST_TYPE_SUPL:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_TYPE_SUPL");
|
||||
type = LOC_ENG_IF_REQUEST_TYPE_SUPL;
|
||||
type = AGPS_TYPE_SUPL;
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_TYPE_WIFI:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_TYPE_WIFI");
|
||||
type = LOC_ENG_IF_REQUEST_TYPE_WIFI;
|
||||
type = AGPS_TYPE_WIFI;
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_TYPE_ANY:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_TYPE_ANY");
|
||||
type = LOC_ENG_IF_REQUEST_TYPE_ANY;
|
||||
type = AGPS_TYPE_ANY;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -171,48 +175,52 @@ int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg,
|
|||
case IF_REQUEST_SENDER_ID_QUIPC:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC");
|
||||
loc_eng_msg_release_wifi *msg(
|
||||
new loc_eng_msg_release_wifi(loc_api_handle,
|
||||
LocEngReqRelWifi* msg =
|
||||
new LocEngReqRelWifi(loc_api_handle,
|
||||
type,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ssid,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password,
|
||||
false);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_SENDER_ID_MSAPM:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM");
|
||||
loc_eng_msg_release_wifi *msg(
|
||||
new loc_eng_msg_release_wifi(loc_api_handle,
|
||||
LocEngReqRelWifi* msg =
|
||||
new LocEngReqRelWifi(loc_api_handle,
|
||||
type,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ssid,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password,
|
||||
false);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_SENDER_ID_MSAPU:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU");
|
||||
loc_eng_msg_release_wifi *msg(
|
||||
new loc_eng_msg_release_wifi(loc_api_handle,
|
||||
LocEngReqRelWifi* msg =
|
||||
new LocEngReqRelWifi(loc_api_handle,
|
||||
type,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ssid,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.password,
|
||||
false);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:
|
||||
{
|
||||
LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON");
|
||||
loc_eng_msg_release_bit *msg(
|
||||
new loc_eng_msg_release_bit(loc_api_handle,
|
||||
LocEngReqRelBIT* msg =
|
||||
new LocEngReqRelBIT(loc_api_handle,
|
||||
type,
|
||||
pmsg->cmsg.cmsg_if_request.ipv4_addr,
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr));
|
||||
loc_eng_msg_sender(loc_api_handle, msg);
|
||||
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,
|
||||
false);
|
||||
msg->send();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -30,31 +30,10 @@
|
|||
#define LOG_NDDEBUG 0
|
||||
#define LOG_TAG "LocSvc_eng"
|
||||
|
||||
#include "hardware/gps.h"
|
||||
#include "loc_log.h"
|
||||
#include "loc_eng_log.h"
|
||||
#include "loc_eng_msg_id.h"
|
||||
|
||||
/* GPS status names */
|
||||
static loc_name_val_s_type gps_status_name[] =
|
||||
{
|
||||
NAME_VAL( GPS_STATUS_NONE ),
|
||||
NAME_VAL( GPS_STATUS_SESSION_BEGIN ),
|
||||
NAME_VAL( GPS_STATUS_SESSION_END ),
|
||||
NAME_VAL( GPS_STATUS_ENGINE_ON ),
|
||||
NAME_VAL( GPS_STATUS_ENGINE_OFF ),
|
||||
};
|
||||
static int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type);
|
||||
|
||||
/* Find Android GPS status name */
|
||||
const char* loc_get_gps_status_name(GpsStatusValue gps_status)
|
||||
{
|
||||
return loc_get_name_from_val(gps_status_name, gps_status_num,
|
||||
(long) gps_status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_msgs[] =
|
||||
{
|
||||
NAME_VAL( LOC_ENG_MSG_QUIT ),
|
||||
|
@ -111,183 +90,3 @@ const char* loc_get_msg_name(int id)
|
|||
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_position_modes[] =
|
||||
{
|
||||
NAME_VAL( LOC_POSITION_MODE_STANDALONE ),
|
||||
NAME_VAL( LOC_POSITION_MODE_MS_BASED ),
|
||||
NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ),
|
||||
NAME_VAL( LOC_POSITION_MODE_RESERVED_5 )
|
||||
};
|
||||
static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_position_mode_name(GpsPositionMode mode)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_position_recurrences[] =
|
||||
{
|
||||
NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ),
|
||||
NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE )
|
||||
};
|
||||
static int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_aiding_data_bits[] =
|
||||
{
|
||||
NAME_VAL( GPS_DELETE_EPHEMERIS ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC ),
|
||||
NAME_VAL( GPS_DELETE_POSITION ),
|
||||
NAME_VAL( GPS_DELETE_TIME ),
|
||||
NAME_VAL( GPS_DELETE_IONO ),
|
||||
NAME_VAL( GPS_DELETE_UTC ),
|
||||
NAME_VAL( GPS_DELETE_HEALTH ),
|
||||
NAME_VAL( GPS_DELETE_SVDIR ),
|
||||
NAME_VAL( GPS_DELETE_SVSTEER ),
|
||||
NAME_VAL( GPS_DELETE_SADATA ),
|
||||
NAME_VAL( GPS_DELETE_RTI ),
|
||||
NAME_VAL( GPS_DELETE_CELLDB_INFO ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC_CORR ),
|
||||
NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
|
||||
NAME_VAL( GPS_DELETE_EPHEMERIS_GLO ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC_GLO ),
|
||||
NAME_VAL( GPS_DELETE_SVDIR_GLO ),
|
||||
NAME_VAL( GPS_DELETE_SVSTEER_GLO ),
|
||||
NAME_VAL( GPS_DELETE_ALMANAC_CORR_GLO ),
|
||||
NAME_VAL( GPS_DELETE_TIME_GPS ),
|
||||
NAME_VAL( GPS_DELETE_TIME_GLO )
|
||||
};
|
||||
static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_aiding_data_mask_names(GpsAidingData data)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_agps_types[] =
|
||||
{
|
||||
NAME_VAL( AGPS_TYPE_INVALID ),
|
||||
NAME_VAL( AGPS_TYPE_ANY ),
|
||||
NAME_VAL( AGPS_TYPE_SUPL ),
|
||||
NAME_VAL( AGPS_TYPE_C2K ),
|
||||
NAME_VAL( AGPS_TYPE_WWAN_ANY )
|
||||
};
|
||||
static int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_agps_type_name(AGpsType type)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_ni_types[] =
|
||||
{
|
||||
NAME_VAL( GPS_NI_TYPE_VOICE ),
|
||||
NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
|
||||
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE )
|
||||
};
|
||||
static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_ni_type_name(GpsNiType type)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_ni_responses[] =
|
||||
{
|
||||
NAME_VAL( GPS_NI_RESPONSE_ACCEPT ),
|
||||
NAME_VAL( GPS_NI_RESPONSE_DENY ),
|
||||
NAME_VAL( GPS_NI_RESPONSE_DENY )
|
||||
};
|
||||
static int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_ni_response_name(GpsUserResponseType response)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
|
||||
}
|
||||
|
||||
|
||||
static loc_name_val_s_type loc_eng_ni_encodings[] =
|
||||
{
|
||||
NAME_VAL( GPS_ENC_NONE ),
|
||||
NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ),
|
||||
NAME_VAL( GPS_ENC_SUPL_UTF8 ),
|
||||
NAME_VAL( GPS_ENC_SUPL_UCS2 ),
|
||||
NAME_VAL( GPS_ENC_UNKNOWN )
|
||||
};
|
||||
static int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_agps_bears[] =
|
||||
{
|
||||
NAME_VAL( AGPS_APN_BEARER_INVALID ),
|
||||
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
|
||||
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
|
||||
NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
|
||||
};
|
||||
static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_agps_bear_name(AGpsBearerType bearer)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_server_types[] =
|
||||
{
|
||||
NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ),
|
||||
NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ),
|
||||
NAME_VAL( LOC_AGPS_MPC_SERVER ),
|
||||
NAME_VAL( LOC_AGPS_SUPL_SERVER )
|
||||
};
|
||||
static int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_server_type_name(LocServerType type)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_position_sess_status_types[] =
|
||||
{
|
||||
NAME_VAL( LOC_SESS_SUCCESS ),
|
||||
NAME_VAL( LOC_SESS_INTERMEDIATE ),
|
||||
NAME_VAL( LOC_SESS_FAILURE )
|
||||
};
|
||||
static int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_position_sess_status_name(enum loc_sess_status status)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status);
|
||||
}
|
||||
|
||||
static loc_name_val_s_type loc_eng_agps_status_names[] =
|
||||
{
|
||||
NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ),
|
||||
NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ),
|
||||
NAME_VAL( GPS_AGPS_DATA_CONNECTED ),
|
||||
NAME_VAL( GPS_AGPS_DATA_CONN_DONE ),
|
||||
NAME_VAL( GPS_AGPS_DATA_CONN_FAILED )
|
||||
};
|
||||
static int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type);
|
||||
|
||||
const char* loc_get_agps_status_name(AGpsStatusValue status)
|
||||
{
|
||||
return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
|
||||
}
|
||||
|
|
|
@ -36,22 +36,8 @@ extern "C"
|
|||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <hardware/gps.h>
|
||||
#include <loc.h>
|
||||
|
||||
const char* loc_get_gps_status_name(GpsStatusValue gps_status);
|
||||
const char* loc_get_msg_name(int id);
|
||||
const char* loc_get_position_mode_name(GpsPositionMode mode);
|
||||
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur);
|
||||
const char* loc_get_aiding_data_mask_names(GpsAidingData data);
|
||||
const char* loc_get_agps_type_name(AGpsType type);
|
||||
const char* loc_get_ni_type_name(GpsNiType type);
|
||||
const char* loc_get_ni_response_name(GpsUserResponseType response);
|
||||
const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding);
|
||||
const char* loc_get_agps_bear_name(AGpsBearerType bear);
|
||||
const char* loc_get_server_type_name(LocServerType type);
|
||||
const char* loc_get_position_sess_status_name(enum loc_sess_status status);
|
||||
const char* loc_get_agps_status_name(AGpsStatusValue status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
/* Copyright (c) 2011, 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 <fcntl.h>
|
||||
#include "loc_eng_msg.h"
|
||||
#include "loc_eng_dmn_conn_glue_msg.h"
|
||||
|
||||
#ifdef _ANDROID_
|
||||
|
||||
#define LOC_ENG_MSG_REQ_Q_PATH "/data/misc/gpsone_d/loc_eng_msg_req_q"
|
||||
|
||||
#else
|
||||
|
||||
#define LOC_ENG_MSG_REQ_Q_PATH "/tmp/loc_eng_msg_req_q"
|
||||
|
||||
#endif
|
||||
|
||||
int loc_eng_msgget(int * p_req_msgq)
|
||||
{
|
||||
* p_req_msgq = loc_eng_dmn_conn_glue_msgget(LOC_ENG_MSG_REQ_Q_PATH, O_RDWR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loc_eng_msgremove(int req_msgq)
|
||||
{
|
||||
loc_eng_dmn_conn_glue_piperemove(LOC_ENG_MSG_REQ_Q_PATH, req_msgq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loc_eng_msgsnd(int msgqid, void * msgp)
|
||||
{
|
||||
int ret = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, sizeof(void*));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int loc_eng_msgsnd_raw(int msgqid, void * msgp, unsigned int msgsz)
|
||||
{
|
||||
int result;
|
||||
|
||||
struct msgbuf * pmsg = (struct msgbuf *) msgp;
|
||||
|
||||
if (msgsz < sizeof(struct msgbuf)) {
|
||||
LOC_LOGE("%s:%d] msgbuf is too small %d\n", __func__, __LINE__, msgsz);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pmsg->msgsz = msgsz;
|
||||
|
||||
result = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, msgsz);
|
||||
if (result != (int) msgsz) {
|
||||
LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) msgsz);
|
||||
return -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int loc_eng_msgrcv(int msgqid, void ** msgp)
|
||||
{
|
||||
int ret = loc_eng_dmn_conn_glue_piperead(msgqid, msgp, sizeof(void*));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int loc_eng_msgrcv_raw(int msgqid, void *msgp, unsigned int msgsz)
|
||||
{
|
||||
int result;
|
||||
struct msgbuf * pmsg = (struct msgbuf *) msgp;
|
||||
|
||||
if (msgsz < sizeof(struct msgbuf)) {
|
||||
LOC_LOGE("%s:%d] msgbuf is too small %d\n", __func__, __LINE__, msgsz);
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = loc_eng_dmn_conn_glue_piperead(msgqid, msgp, sizeof(struct msgbuf));
|
||||
if (result != sizeof(struct msgbuf)) {
|
||||
LOC_LOGE("%s:%d] pipe broken %d\n", __func__, __LINE__, result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (msgsz < pmsg->msgsz) {
|
||||
LOC_LOGE("%s:%d] msgbuf is too small %d < %d\n", __func__, __LINE__, (int) msgsz, (int) pmsg->msgsz);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pmsg->msgsz > sizeof(struct msgbuf)) {
|
||||
/* there is msg body */
|
||||
msgp += sizeof(struct msgbuf);
|
||||
|
||||
result = loc_eng_dmn_conn_glue_piperead(msgqid, msgp, pmsg->msgsz - sizeof(struct msgbuf));
|
||||
|
||||
if (result != (int) (pmsg->msgsz - sizeof(struct msgbuf))) {
|
||||
LOC_LOGE("%s:%d] pipe broken %d, msgid = %p, msgsz = %d\n", __func__, __LINE__, result,
|
||||
(pmsg->msgid), (int) pmsg->msgsz);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return pmsg->msgsz;
|
||||
}
|
||||
|
||||
int loc_eng_msgflush(int msgqid)
|
||||
{
|
||||
return loc_eng_dmn_conn_glue_msgflush(msgqid);
|
||||
}
|
||||
|
||||
int loc_eng_msgunblock(int msgqid)
|
||||
{
|
||||
return loc_eng_dmn_conn_glue_pipeunblock(msgqid);
|
||||
}
|
|
@ -31,13 +31,15 @@
|
|||
|
||||
|
||||
#include <hardware/gps.h>
|
||||
#include <loc_ulp.h>
|
||||
#include <gps_extended.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "log_util.h"
|
||||
#include "loc.h"
|
||||
#include <log_util.h>
|
||||
#include <loc_eng_log.h>
|
||||
#include "loc_eng_msg_id.h"
|
||||
#include <loc_eng.h>
|
||||
#include <loc_eng_msg_id.h>
|
||||
#include <MsgTask.h>
|
||||
#include <LocEngAdapter.h>
|
||||
|
||||
#ifndef SSID_BUF_SIZE
|
||||
#define SSID_BUF_SIZE (32+1)
|
||||
|
@ -53,113 +55,7 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct LocPosMode
|
||||
{
|
||||
LocPositionMode mode;
|
||||
GpsPositionRecurrence recurrence;
|
||||
uint32_t min_interval;
|
||||
uint32_t preferred_accuracy;
|
||||
uint32_t preferred_time;
|
||||
char credentials[14];
|
||||
char provider[8];
|
||||
LocPosMode(LocPositionMode m, GpsPositionRecurrence recr,
|
||||
uint32_t gap, uint32_t accu, uint32_t time,
|
||||
const char* cred, const char* prov) :
|
||||
mode(m), recurrence(recr),
|
||||
min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap),
|
||||
preferred_accuracy(accu), preferred_time(time) {
|
||||
memset(credentials, 0, sizeof(credentials));
|
||||
memset(provider, 0, sizeof(provider));
|
||||
if (NULL != cred) {
|
||||
memcpy(credentials, cred, sizeof(credentials)-1);
|
||||
}
|
||||
if (NULL != prov) {
|
||||
memcpy(provider, prov, sizeof(provider)-1);
|
||||
}
|
||||
}
|
||||
|
||||
LocPosMode() :
|
||||
mode(LOC_POSITION_MODE_MS_BASED), recurrence(GPS_POSITION_RECURRENCE_PERIODIC),
|
||||
min_interval(MIN_POSSIBLE_FIX_INTERVAL), preferred_accuracy(50), preferred_time(120000) {
|
||||
memset(credentials, 0, sizeof(credentials));
|
||||
memset(provider, 0, sizeof(provider));
|
||||
}
|
||||
|
||||
inline bool equals(const LocPosMode &anotherMode) const
|
||||
{
|
||||
return anotherMode.mode == mode &&
|
||||
anotherMode.recurrence == recurrence &&
|
||||
anotherMode.min_interval == min_interval &&
|
||||
anotherMode.preferred_accuracy == preferred_accuracy &&
|
||||
anotherMode.preferred_time == preferred_time &&
|
||||
!strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) &&
|
||||
!strncmp(anotherMode.provider, provider, sizeof(provider)-1);
|
||||
}
|
||||
|
||||
inline void logv() const
|
||||
{
|
||||
LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n min interval: %d\n preferred accuracy: %d\n preferred time: %d\n credentials: %s provider: %s",
|
||||
loc_get_position_mode_name(mode),
|
||||
loc_get_position_recurrence_name(recurrence),
|
||||
min_interval,
|
||||
preferred_accuracy,
|
||||
preferred_time,
|
||||
credentials,
|
||||
provider);
|
||||
}
|
||||
};
|
||||
|
||||
/** Flags to indicate which values are valid in a GpsLocationExtended. */
|
||||
typedef uint16_t GpsLocationExtendedFlags;
|
||||
/** GpsLocationExtended has valid pdop, hdop, vdop. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001
|
||||
/** GpsLocationExtended has valid altitude mean sea level. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002
|
||||
/** UlpLocation has valid magnetic deviation. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004
|
||||
/** UlpLocation has valid mode indicator. */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008
|
||||
/** GpsLocationExtended has valid vertical uncertainty */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010
|
||||
/** GpsLocationExtended has valid speed uncertainty */
|
||||
#define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020
|
||||
|
||||
/** Represents gps location extended. */
|
||||
typedef struct {
|
||||
/** set to sizeof(GpsLocationExtended) */
|
||||
size_t size;
|
||||
/** Contains GpsLocationExtendedFlags bits. */
|
||||
uint16_t flags;
|
||||
/** Contains the Altitude wrt mean sea level */
|
||||
float altitudeMeanSeaLevel;
|
||||
/** Contains Position Dilusion of Precision. */
|
||||
float pdop;
|
||||
/** Contains Horizontal Dilusion of Precision. */
|
||||
float hdop;
|
||||
/** Contains Vertical Dilusion of Precision. */
|
||||
float vdop;
|
||||
/** Contains Magnetic Deviation. */
|
||||
float magneticDeviation;
|
||||
/** vertical uncertainty in meters */
|
||||
float vert_unc;
|
||||
/** speed uncertainty in m/s */
|
||||
float speed_unc;
|
||||
} GpsLocationExtended;
|
||||
|
||||
typedef enum {
|
||||
LOC_ENG_IF_REQUEST_TYPE_SUPL = 0,
|
||||
LOC_ENG_IF_REQUEST_TYPE_WIFI,
|
||||
LOC_ENG_IF_REQUEST_TYPE_ANY
|
||||
} loc_if_req_type_e_type;
|
||||
|
||||
typedef enum {
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_MODEM,
|
||||
LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN
|
||||
} loc_if_req_sender_id_e_type;
|
||||
using namespace loc_core;
|
||||
|
||||
struct loc_eng_msg {
|
||||
const void* owner;
|
||||
|
@ -176,153 +72,6 @@ struct loc_eng_msg {
|
|||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_a_glonass_protocol : public loc_eng_msg {
|
||||
const unsigned long a_glonass_protocol;
|
||||
inline loc_eng_msg_a_glonass_protocol(void* instance, unsigned long protocol) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_A_GLONASS_PROTOCOL),
|
||||
a_glonass_protocol(protocol)
|
||||
{
|
||||
LOC_LOGV("A-GLONASS protocol: 0x%lx", protocol);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_suple_version : public loc_eng_msg {
|
||||
const int supl_version;
|
||||
inline loc_eng_msg_suple_version(void* instance, int version) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SUPL_VERSION),
|
||||
supl_version(version)
|
||||
{
|
||||
LOC_LOGV("SUPL Version: %d", version);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_lpp_config : public loc_eng_msg {
|
||||
const int lpp_config;
|
||||
inline loc_eng_msg_lpp_config(void *instance, int profile) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_LPP_CONFIG),
|
||||
lpp_config(profile)
|
||||
{
|
||||
LOC_LOGV("lpp profile: %d", profile);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_ext_power_config : public loc_eng_msg {
|
||||
const int isBatteryCharging;
|
||||
inline loc_eng_msg_ext_power_config(void* instance, int isBattCharging) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_EXT_POWER_CONFIG),
|
||||
isBatteryCharging(isBattCharging)
|
||||
{
|
||||
LOC_LOGV("isBatteryCharging: %d", isBatteryCharging);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_sensor_control_config : public loc_eng_msg {
|
||||
const int sensorsDisabled;
|
||||
inline loc_eng_msg_sensor_control_config(void* instance, int disabled) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG),
|
||||
sensorsDisabled(disabled)
|
||||
{
|
||||
LOC_LOGV("Sensors Disabled: %d", disabled);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_sensor_properties : public loc_eng_msg {
|
||||
const bool gyroBiasVarianceRandomWalk_valid;
|
||||
const float gyroBiasVarianceRandomWalk;
|
||||
const bool accelRandomWalk_valid;
|
||||
const float accelRandomWalk;
|
||||
const bool angleRandomWalk_valid;
|
||||
const float angleRandomWalk;
|
||||
const bool rateRandomWalk_valid;
|
||||
const float rateRandomWalk;
|
||||
const bool velocityRandomWalk_valid;
|
||||
const float velocityRandomWalk;
|
||||
inline loc_eng_msg_sensor_properties(void* instance, bool gyroBiasRandomWalk_valid, float gyroBiasRandomWalk,
|
||||
bool accelRandomWalk_valid, float accelRandomWalk,
|
||||
bool angleRandomWalk_valid, float angleRandomWalk,
|
||||
bool rateRandomWalk_valid, float rateRandomWalk,
|
||||
bool velocityRandomWalk_valid, float velocityRandomWalk) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_PROPERTIES),
|
||||
gyroBiasVarianceRandomWalk_valid(gyroBiasRandomWalk_valid),
|
||||
gyroBiasVarianceRandomWalk(gyroBiasRandomWalk),
|
||||
accelRandomWalk_valid(accelRandomWalk_valid),
|
||||
accelRandomWalk(accelRandomWalk),
|
||||
angleRandomWalk_valid(angleRandomWalk_valid),
|
||||
angleRandomWalk(angleRandomWalk),
|
||||
rateRandomWalk_valid(rateRandomWalk_valid),
|
||||
rateRandomWalk(rateRandomWalk),
|
||||
velocityRandomWalk_valid(velocityRandomWalk_valid),
|
||||
velocityRandomWalk(velocityRandomWalk)
|
||||
{
|
||||
LOC_LOGV("Sensor properties validity, Gyro Random walk: %d Accel Random Walk: %d "
|
||||
"Angle Random Walk: %d Rate Random Walk: %d "
|
||||
"Velocity Random Walk: %d",
|
||||
gyroBiasRandomWalk_valid,
|
||||
accelRandomWalk_valid,
|
||||
angleRandomWalk_valid,
|
||||
rateRandomWalk_valid,
|
||||
velocityRandomWalk_valid
|
||||
);
|
||||
LOC_LOGV("Sensor properties, Gyro Random walk: %f Accel Random Walk: %f "
|
||||
"Angle Random Walk: %f Rate Random Walk: %f "
|
||||
"Velocity Random Walk: %f",
|
||||
gyroBiasRandomWalk,
|
||||
accelRandomWalk,
|
||||
angleRandomWalk,
|
||||
rateRandomWalk,
|
||||
velocityRandomWalk
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_sensor_perf_control_config : public loc_eng_msg {
|
||||
const int controlMode;
|
||||
const int accelSamplesPerBatch;
|
||||
const int accelBatchesPerSec;
|
||||
const int gyroSamplesPerBatch;
|
||||
const int gyroBatchesPerSec;
|
||||
const int accelSamplesPerBatchHigh;
|
||||
const int accelBatchesPerSecHigh;
|
||||
const int gyroSamplesPerBatchHigh;
|
||||
const int gyroBatchesPerSecHigh;
|
||||
const int algorithmConfig;
|
||||
inline loc_eng_msg_sensor_perf_control_config(void* instance, int controlMode,
|
||||
int accelSamplesPerBatch, int accelBatchesPerSec,
|
||||
int gyroSamplesPerBatch, int gyroBatchesPerSec,
|
||||
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
|
||||
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh,
|
||||
int algorithmConfig) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG),
|
||||
controlMode(controlMode),
|
||||
accelSamplesPerBatch(accelSamplesPerBatch),
|
||||
accelBatchesPerSec(accelBatchesPerSec),
|
||||
gyroSamplesPerBatch(gyroSamplesPerBatch),
|
||||
gyroBatchesPerSec(gyroBatchesPerSec),
|
||||
accelSamplesPerBatchHigh(accelSamplesPerBatchHigh),
|
||||
accelBatchesPerSecHigh(accelBatchesPerSecHigh),
|
||||
gyroSamplesPerBatchHigh(gyroSamplesPerBatchHigh),
|
||||
gyroBatchesPerSecHigh(gyroBatchesPerSecHigh),
|
||||
algorithmConfig(algorithmConfig)
|
||||
{
|
||||
LOC_LOGV("Sensor Perf Control Config (performanceControlMode)(%u) "
|
||||
"accel(#smp,#batches) (%u,%u) gyro(#smp,#batches) (%u,%u), "
|
||||
"accel_high(#smp,#batches) (%u,%u) gyro_high(#smp,#batches) (%u,%u), "
|
||||
"algorithmConfig(%u)\n",
|
||||
controlMode,
|
||||
accelSamplesPerBatch,
|
||||
accelBatchesPerSec,
|
||||
gyroSamplesPerBatch,
|
||||
gyroBatchesPerSec,
|
||||
accelSamplesPerBatchHigh,
|
||||
accelBatchesPerSecHigh,
|
||||
gyroSamplesPerBatchHigh,
|
||||
gyroBatchesPerSecHigh,
|
||||
algorithmConfig
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct loc_eng_msg_position_mode : public loc_eng_msg {
|
||||
const LocPosMode pMode;
|
||||
inline loc_eng_msg_position_mode(void* instance,
|
||||
|
@ -334,45 +83,6 @@ struct loc_eng_msg_position_mode : public loc_eng_msg {
|
|||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_set_time : public loc_eng_msg {
|
||||
const GpsUtcTime time;
|
||||
const int64_t timeReference;
|
||||
const int uncertainty;
|
||||
inline loc_eng_msg_set_time(void* instance,
|
||||
GpsUtcTime t,
|
||||
int64_t tf,
|
||||
int unc) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SET_TIME),
|
||||
time(t), timeReference(tf), uncertainty(unc)
|
||||
{
|
||||
LOC_LOGV("time: %lld\n timeReference: %lld\n uncertainty: %d",
|
||||
time, timeReference, uncertainty);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_inject_location : public loc_eng_msg {
|
||||
const double latitude;
|
||||
const double longitude;
|
||||
const float accuracy;
|
||||
inline loc_eng_msg_inject_location(void* instance, double lat,
|
||||
double longi, float accur) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_INJECT_LOCATION),
|
||||
latitude(lat), longitude(longi), accuracy(accur)
|
||||
{
|
||||
LOC_LOGV("latitude: %f\n longitude: %f\n accuracy: %f",
|
||||
latitude, longitude, accuracy);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_delete_aiding_data : public loc_eng_msg {
|
||||
const GpsAidingData type;
|
||||
inline loc_eng_msg_delete_aiding_data(void* instance, GpsAidingData data) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_DELETE_AIDING_DATA), type(data)
|
||||
{
|
||||
LOC_LOGV("aiding data msak %d", type);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_report_position : public loc_eng_msg {
|
||||
const UlpLocation location;
|
||||
const GpsLocationExtended locationExtended;
|
||||
|
@ -427,438 +137,232 @@ struct loc_eng_msg_report_sv : public loc_eng_msg {
|
|||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_report_status : public loc_eng_msg {
|
||||
const GpsStatusValue status;
|
||||
inline loc_eng_msg_report_status(void* instance, GpsStatusValue engineStatus) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_STATUS), status(engineStatus)
|
||||
{
|
||||
LOC_LOGV("status: %s", loc_get_gps_status_name(status));
|
||||
}
|
||||
|
||||
struct LocEngPositionMode : public LocMsg {
|
||||
LocEngAdapter* mAdapter;
|
||||
const LocPosMode mPosMode;
|
||||
LocEngPositionMode(LocEngAdapter* adapter,
|
||||
LocPosMode &mode);
|
||||
virtual void proc() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_report_nmea : public loc_eng_msg {
|
||||
char* const nmea;
|
||||
const int length;
|
||||
inline loc_eng_msg_report_nmea(void* instance,
|
||||
const char* data,
|
||||
int len) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_NMEA),
|
||||
nmea(new char[len]), length(len)
|
||||
{
|
||||
memcpy((void*)nmea, (void*)data, len);
|
||||
LOC_LOGV("length: %d\n nmea: %p - %c%c%c",
|
||||
length, nmea, nmea[3], nmea[4], nmea[5]);
|
||||
}
|
||||
inline ~loc_eng_msg_report_nmea()
|
||||
{
|
||||
delete[] nmea;
|
||||
}
|
||||
|
||||
struct LocEngStartFix : public LocMsg {
|
||||
loc_eng_data_s_type* mLocEng;
|
||||
LocEngStartFix(loc_eng_data_s_type* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_report_xtra_server : public loc_eng_msg {
|
||||
char *server1;
|
||||
char *server2;
|
||||
char *server3;
|
||||
inline loc_eng_msg_report_xtra_server(void *instance,
|
||||
const char *url1,
|
||||
const char *url2,
|
||||
const char *url3,
|
||||
const int maxlength) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_XTRA_SERVER),
|
||||
server1(new char[maxlength+1]), server2(new char[maxlength+1]), server3(new char[maxlength+1])
|
||||
{
|
||||
strlcpy(server1, url1, maxlength);
|
||||
strlcpy(server2, url2, maxlength);
|
||||
strlcpy(server3, url3, maxlength);
|
||||
|
||||
LOC_LOGV("maxlength: %d\n server1: %s\n server2: %s\n server3: %s\n",
|
||||
maxlength, server1, server2, server3);
|
||||
}
|
||||
inline ~loc_eng_msg_report_xtra_server()
|
||||
{
|
||||
delete[] server1;
|
||||
delete[] server2;
|
||||
delete[] server3;
|
||||
}
|
||||
struct LocEngStopFix : public LocMsg {
|
||||
loc_eng_data_s_type* mLocEng;
|
||||
LocEngStopFix(loc_eng_data_s_type* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_bit : public loc_eng_msg {
|
||||
const loc_if_req_type_e_type ifType;
|
||||
const int ipv4Addr;
|
||||
char* const ipv6Addr;
|
||||
inline loc_eng_msg_request_bit(void* instance,
|
||||
loc_if_req_type_e_type type,
|
||||
int ipv4,
|
||||
char* ipv6) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_BIT),
|
||||
ifType(type), ipv4Addr(ipv4),
|
||||
ipv6Addr(NULL == ipv6 ? NULL : new char[16])
|
||||
{
|
||||
if (NULL != ipv6Addr)
|
||||
memcpy(ipv6Addr, ipv6, 16);
|
||||
LOC_LOGV("ifType: %d, ipv4: %d.%d.%d.%d, ipv6: %s", ifType,
|
||||
(unsigned char)(ipv4>>24),
|
||||
(unsigned char)(ipv4>>16),
|
||||
(unsigned char)(ipv4>>8),
|
||||
(unsigned char)ipv4,
|
||||
NULL != ipv6Addr ? ipv6Addr : "");
|
||||
}
|
||||
|
||||
inline ~loc_eng_msg_request_bit()
|
||||
{
|
||||
if (NULL != ipv6Addr) {
|
||||
delete[] ipv6Addr;
|
||||
}
|
||||
}
|
||||
struct LocEngReportPosition : public LocMsg {
|
||||
void* mLocEng;
|
||||
const UlpLocation mLocation;
|
||||
const GpsLocationExtended mLocationExtended;
|
||||
const void* mLocationExt;
|
||||
const enum loc_sess_status mStatus;
|
||||
const LocPosTechMask mTechMask;
|
||||
LocEngReportPosition(void* locEng,
|
||||
UlpLocation &loc,
|
||||
GpsLocationExtended &locExtended,
|
||||
void* locExt,
|
||||
enum loc_sess_status st,
|
||||
LocPosTechMask technology);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_wifi : public loc_eng_msg {
|
||||
const loc_if_req_type_e_type ifType;
|
||||
const loc_if_req_sender_id_e_type senderId;
|
||||
char* const ssid;
|
||||
char* const password;
|
||||
inline loc_eng_msg_request_wifi(void* instance,
|
||||
loc_if_req_type_e_type type,
|
||||
struct LocEngReportSv : public LocMsg {
|
||||
void* mLocEng;
|
||||
const GpsSvStatus mSvStatus;
|
||||
const GpsLocationExtended mLocationExtended;
|
||||
const void* mSvExt;
|
||||
LocEngReportSv(void* locEng,
|
||||
GpsSvStatus &sv,
|
||||
GpsLocationExtended &locExtended,
|
||||
void* svExtended);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
struct LocEngReportStatus : public LocMsg {
|
||||
void* mLocEng;
|
||||
const GpsStatusValue mStatus;
|
||||
LocEngReportStatus(void* locEng,
|
||||
GpsStatusValue engineStatus);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngReportNmea : public LocMsg {
|
||||
void* mLocEng;
|
||||
char* const mNmea;
|
||||
const int mLen;
|
||||
LocEngReportNmea(void* locEng,
|
||||
const char* data, int len);
|
||||
inline virtual ~LocEngReportNmea()
|
||||
{
|
||||
delete[] mNmea;
|
||||
}
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngReportXtraServer : public LocMsg {
|
||||
void* mLocEng;
|
||||
int mMaxLen;
|
||||
char *mServers;
|
||||
LocEngReportXtraServer(void* locEng,
|
||||
const char *url1, const char *url2,
|
||||
const char *url3, const int maxlength);
|
||||
inline virtual ~LocEngReportXtraServer()
|
||||
{
|
||||
delete[] mServers;
|
||||
}
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngSuplEsOpened : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngSuplEsOpened(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngSuplEsClosed : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngSuplEsClosed(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngRequestSuplEs : public LocMsg {
|
||||
void* mLocEng;
|
||||
const int mID;
|
||||
LocEngRequestSuplEs(void* locEng, int id);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngRequestATL : public LocMsg {
|
||||
void* mLocEng;
|
||||
const int mID;
|
||||
const AGpsExtType mType;
|
||||
LocEngRequestATL(void* locEng, int id,
|
||||
AGpsExtType agps_type);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngReleaseATL : public LocMsg {
|
||||
void* mLocEng;
|
||||
const int mID;
|
||||
LocEngReleaseATL(void* locEng, int id);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct LocEngReqRelBIT : public LocMsg {
|
||||
void* mLocEng;
|
||||
const AGpsExtType mType;
|
||||
const int mIPv4Addr;
|
||||
char* const mIPv6Addr;
|
||||
const bool mIsReq;
|
||||
LocEngReqRelBIT(void* instance, AGpsExtType type,
|
||||
int ipv4, char* ipv6, bool isReq);
|
||||
virtual ~LocEngReqRelBIT();
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
struct LocEngReqRelWifi : public LocMsg {
|
||||
void* mLocEng;
|
||||
const AGpsExtType mType;
|
||||
const loc_if_req_sender_id_e_type mSenderId;
|
||||
char* const mSSID;
|
||||
char* const mPassword;
|
||||
const bool mIsReq;
|
||||
LocEngReqRelWifi(void* locEng, AGpsExtType type,
|
||||
loc_if_req_sender_id_e_type sender_id,
|
||||
char* s,
|
||||
char* p) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_WIFI),
|
||||
ifType(type), senderId(sender_id),
|
||||
ssid(NULL == s ? NULL : new char[SSID_BUF_SIZE]),
|
||||
password(NULL == p ? NULL : new char[SSID_BUF_SIZE])
|
||||
{
|
||||
if (NULL != ssid)
|
||||
strlcpy(ssid, s, SSID_BUF_SIZE);
|
||||
if (NULL != password)
|
||||
strlcpy(password, p, SSID_BUF_SIZE);
|
||||
LOC_LOGV("ifType: %d, senderId: %d, ssid: %s, password: %s",
|
||||
ifType,
|
||||
senderId,
|
||||
NULL != ssid ? ssid : "",
|
||||
NULL != password ? password : "");
|
||||
}
|
||||
|
||||
inline ~loc_eng_msg_request_wifi()
|
||||
{
|
||||
if (NULL != ssid) {
|
||||
delete[] ssid;
|
||||
}
|
||||
if (NULL != password) {
|
||||
delete[] password;
|
||||
}
|
||||
}
|
||||
char* s, char* p, bool isReq);
|
||||
virtual ~LocEngReqRelWifi();
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
void send() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_release_bit : public loc_eng_msg {
|
||||
const loc_if_req_type_e_type ifType;
|
||||
const int ipv4Addr;
|
||||
char* const ipv6Addr;
|
||||
inline loc_eng_msg_release_bit(void* instance,
|
||||
loc_if_req_type_e_type type,
|
||||
int ipv4,
|
||||
char* ipv6) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_RELEASE_BIT),
|
||||
ifType(type), ipv4Addr(ipv4),
|
||||
ipv6Addr(NULL == ipv6 ? NULL : new char[16])
|
||||
{
|
||||
if (NULL != ipv6Addr)
|
||||
memcpy(ipv6Addr, ipv6, 16);
|
||||
LOC_LOGV("ifType: %d, ipv4: %d.%d.%d.%d, ipv6: %s", ifType,
|
||||
(unsigned char)(ipv4>>24),
|
||||
(unsigned char)(ipv4>>16),
|
||||
(unsigned char)(ipv4>>8),
|
||||
(unsigned char)ipv4,
|
||||
NULL != ipv6Addr ? ipv6Addr : "");
|
||||
}
|
||||
|
||||
inline ~loc_eng_msg_release_bit()
|
||||
{
|
||||
if (NULL != ipv6Addr) {
|
||||
delete[] ipv6Addr;
|
||||
}
|
||||
}
|
||||
struct LocEngRequestXtra : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngRequestXtra(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_release_wifi : public loc_eng_msg {
|
||||
const loc_if_req_type_e_type ifType;
|
||||
const loc_if_req_sender_id_e_type senderId;
|
||||
char* const ssid;
|
||||
char* const password;
|
||||
inline loc_eng_msg_release_wifi(void* instance,
|
||||
loc_if_req_type_e_type type,
|
||||
loc_if_req_sender_id_e_type sender_id,
|
||||
char* s,
|
||||
char* p) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_RELEASE_WIFI),
|
||||
ifType(type), senderId(sender_id),
|
||||
ssid(NULL == s ? NULL : new char[SSID_BUF_SIZE]),
|
||||
password(NULL == p ? NULL : new char[SSID_BUF_SIZE])
|
||||
{
|
||||
if (NULL != s)
|
||||
strlcpy(ssid, s, SSID_BUF_SIZE);
|
||||
if (NULL != p)
|
||||
strlcpy(password, p, SSID_BUF_SIZE);
|
||||
LOC_LOGV("ifType: %d, senderId: %d, ssid: %s, password: %s",
|
||||
ifType,
|
||||
senderId,
|
||||
NULL != ssid ? ssid : "",
|
||||
NULL != password ? password : "");
|
||||
}
|
||||
|
||||
inline ~loc_eng_msg_release_wifi()
|
||||
{
|
||||
if (NULL != ssid) {
|
||||
delete[] ssid;
|
||||
}
|
||||
if (NULL != password) {
|
||||
delete[] password;
|
||||
}
|
||||
}
|
||||
struct LocEngRequestTime : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngRequestTime(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_atl : public loc_eng_msg {
|
||||
const int handle;
|
||||
const AGpsType type;
|
||||
inline loc_eng_msg_request_atl(void* instance, int hndl,
|
||||
AGpsType agps_type) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_ATL),
|
||||
handle(hndl), type(agps_type)
|
||||
{
|
||||
LOC_LOGV("handle: %d\n agps type: %s",
|
||||
handle,
|
||||
loc_get_agps_type_name(type));
|
||||
}
|
||||
struct LocEngRequestNi : public LocMsg {
|
||||
void* mLocEng;
|
||||
const GpsNiNotification mNotify;
|
||||
const void *mPayload;
|
||||
LocEngRequestNi(void* locEng,
|
||||
GpsNiNotification ¬if,
|
||||
const void* data);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_supl_es : public loc_eng_msg {
|
||||
const int handle;
|
||||
inline loc_eng_msg_request_supl_es(void* instance, int hndl) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_SUPL_ES),
|
||||
handle(hndl)
|
||||
{
|
||||
LOC_LOGV("handle: %d\n", handle);
|
||||
}
|
||||
struct LocEngDown : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngDown(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_close_data_call: public loc_eng_msg {
|
||||
inline loc_eng_msg_close_data_call(void *instance) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_CLOSE_DATA_CALL)
|
||||
{
|
||||
LOC_LOGV("%s:%d]Close data call: ", __func__, __LINE__);
|
||||
}
|
||||
};
|
||||
struct loc_eng_msg_release_atl : public loc_eng_msg {
|
||||
const int handle;
|
||||
inline loc_eng_msg_release_atl(void* instance, int hndl) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_RELEASE_ATL), handle(hndl)
|
||||
{
|
||||
LOC_LOGV("handle: %d", handle);
|
||||
}
|
||||
struct LocEngUp : public LocMsg {
|
||||
void* mLocEng;
|
||||
LocEngUp(void* locEng);
|
||||
virtual void proc() const;
|
||||
void locallog() const;
|
||||
virtual void log() const;
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_ni : public loc_eng_msg {
|
||||
const GpsNiNotification notify;
|
||||
const void *passThroughData;
|
||||
inline loc_eng_msg_request_ni(void* instance,
|
||||
GpsNiNotification ¬if, const void* data) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_NI),
|
||||
notify(notif), passThroughData(data)
|
||||
{
|
||||
LOC_LOGV("id: %d\n type: %s\n flags: %d\n time out: %d\n default response: %s\n requestor id encoding: %s\n text encoding: %s\n passThroughData: %p",
|
||||
notify.notification_id,
|
||||
loc_get_ni_type_name(notify.ni_type),
|
||||
notify.notify_flags,
|
||||
notify.timeout,
|
||||
loc_get_ni_response_name(notify.default_response),
|
||||
loc_get_ni_encoding_name(notify.requestor_id_encoding),
|
||||
loc_get_ni_encoding_name(notify.text_encoding),
|
||||
passThroughData);
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_inform_ni_response : public loc_eng_msg {
|
||||
const GpsUserResponseType response;
|
||||
const void *passThroughData;
|
||||
inline loc_eng_msg_inform_ni_response(void* instance,
|
||||
GpsUserResponseType resp,
|
||||
const void* data) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_INFORM_NI_RESPONSE),
|
||||
response(resp), passThroughData(data)
|
||||
{
|
||||
LOC_LOGV("response: %s\n passThroughData: %p",
|
||||
loc_get_ni_response_name(response),
|
||||
passThroughData);
|
||||
}
|
||||
inline ~loc_eng_msg_inform_ni_response()
|
||||
{
|
||||
// this is a bit weird since passThroughData is not
|
||||
// allocated by this class. But there is no better way.
|
||||
// passThroughData actually won't be NULL here.
|
||||
// But better safer than sorry.
|
||||
if (NULL != passThroughData) {
|
||||
free((void*)passThroughData);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_set_apn : public loc_eng_msg {
|
||||
char* const apn;
|
||||
inline loc_eng_msg_set_apn(void* instance, const char* name, int len) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SET_APN),
|
||||
apn(new char[len+1])
|
||||
{
|
||||
memcpy((void*)apn, (void*)name, len);
|
||||
apn[len] = 0;
|
||||
LOC_LOGV("apn: %s", apn);
|
||||
}
|
||||
inline ~loc_eng_msg_set_apn()
|
||||
{
|
||||
delete[] apn;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct loc_eng_msg_set_server_ipv4 : public loc_eng_msg {
|
||||
const unsigned int nl_addr;
|
||||
const int port;
|
||||
const LocServerType serverType;
|
||||
inline loc_eng_msg_set_server_ipv4(void* instance,
|
||||
unsigned int ip,
|
||||
int p,
|
||||
LocServerType type) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SET_SERVER_IPV4),
|
||||
nl_addr(ip), port(p), serverType(type)
|
||||
{
|
||||
LOC_LOGV("addr: %x\n , port: %d\n type: %s", nl_addr, port, loc_get_server_type_name(serverType));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct loc_eng_msg_set_server_url : public loc_eng_msg {
|
||||
const int len;
|
||||
char* const url;
|
||||
inline loc_eng_msg_set_server_url(void* instance,
|
||||
const char* urlString,
|
||||
int url_len) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_SET_SERVER_URL),
|
||||
len(url_len), url(new char[len+1])
|
||||
{
|
||||
memcpy((void*)url, (void*)urlString, url_len);
|
||||
url[len] = 0;
|
||||
LOC_LOGV("url: %s", url);
|
||||
}
|
||||
inline ~loc_eng_msg_set_server_url()
|
||||
{
|
||||
delete[] url;
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_inject_xtra_data : public loc_eng_msg {
|
||||
char* const data;
|
||||
const int length;
|
||||
inline loc_eng_msg_inject_xtra_data(void* instance, char* d, int l) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_INJECT_XTRA_DATA),
|
||||
data(new char[l]), length(l)
|
||||
{
|
||||
memcpy((void*)data, (void*)d, l);
|
||||
LOC_LOGV("length: %d\n data: %p", length, data);
|
||||
}
|
||||
inline ~loc_eng_msg_inject_xtra_data()
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_request_xtra_server : public loc_eng_msg {
|
||||
inline loc_eng_msg_request_xtra_server(void *instance) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_XTRA_SERVER)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_atl_open_success : public loc_eng_msg {
|
||||
const AGpsType agpsType;
|
||||
const int length;
|
||||
char* const apn;
|
||||
const AGpsBearerType bearerType;
|
||||
inline loc_eng_msg_atl_open_success(void* instance,
|
||||
AGpsType atype,
|
||||
const char* name,
|
||||
int len,
|
||||
AGpsBearerType btype) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_ATL_OPEN_SUCCESS),
|
||||
agpsType(atype), length(len),
|
||||
apn(new char[len+1]), bearerType(btype)
|
||||
{
|
||||
memcpy((void*)apn, (void*)name, len);
|
||||
apn[len] = 0;
|
||||
LOC_LOGV("agps type: %s\n apn: %s\n bearer type: %s",
|
||||
loc_get_agps_type_name(agpsType),
|
||||
apn,
|
||||
loc_get_agps_bear_name(bearerType));
|
||||
}
|
||||
inline ~loc_eng_msg_atl_open_success()
|
||||
{
|
||||
delete[] apn;
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_atl_open_failed : public loc_eng_msg {
|
||||
const AGpsStatusValue agpsType;
|
||||
inline loc_eng_msg_atl_open_failed(void* instance,
|
||||
AGpsStatusValue atype) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_ATL_OPEN_FAILED),
|
||||
agpsType(atype)
|
||||
{
|
||||
LOC_LOGV("agps type %s",
|
||||
loc_get_agps_type_name(agpsType));
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_atl_closed : public loc_eng_msg {
|
||||
const AGpsType agpsType;
|
||||
inline loc_eng_msg_atl_closed(void* instance,
|
||||
AGpsType atype) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_ATL_CLOSED),
|
||||
agpsType(atype)
|
||||
{
|
||||
LOC_LOGV("agps type %s",
|
||||
loc_get_agps_type_name(agpsType));
|
||||
}
|
||||
};
|
||||
|
||||
struct loc_eng_msg_set_data_enable : public loc_eng_msg {
|
||||
const int enable;
|
||||
char* const apn;
|
||||
const int length;
|
||||
inline loc_eng_msg_set_data_enable(void* instance,
|
||||
const char* name,
|
||||
int len,
|
||||
int yes) :
|
||||
loc_eng_msg(instance, LOC_ENG_MSG_ENABLE_DATA),
|
||||
enable(yes), apn(new char[len+1]), length(len)
|
||||
{
|
||||
memcpy((void*)apn, (void*)name, len);
|
||||
apn[len] = 0;
|
||||
LOC_LOGV("apn: %s\n enable: %d", apn, enable);
|
||||
}
|
||||
inline ~loc_eng_msg_set_data_enable()
|
||||
{
|
||||
delete[] apn;
|
||||
}
|
||||
};
|
||||
|
||||
void loc_eng_msg_sender(void* loc_eng_data_p, void* msg);
|
||||
int loc_eng_msgget(int * p_req_msgq);
|
||||
int loc_eng_msgremove(int req_msgq);
|
||||
int loc_eng_msgsnd(int msgqid, void * msgp);
|
||||
int loc_eng_msgrcv(int msgqid, void ** msgp);
|
||||
int loc_eng_msgsnd_raw(int msgqid, void * msgp, unsigned int msgsz);
|
||||
int loc_eng_msgrcv_raw(int msgqid, void *msgp, unsigned int msgsz);
|
||||
int loc_eng_msgflush(int msgqid);
|
||||
int loc_eng_msgunblock(int msgqid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -39,11 +39,15 @@
|
|||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <MsgTask.h>
|
||||
|
||||
#include <loc_eng.h>
|
||||
|
||||
#include "log_util.h"
|
||||
#include "platform_lib_includes.h"
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
/*=============================================================================
|
||||
*
|
||||
* DATA DECLARATION
|
||||
|
@ -57,6 +61,42 @@
|
|||
*============================================================================*/
|
||||
static void* ni_thread_proc(void *args);
|
||||
|
||||
struct LocEngInformNiResponse : public LocMsg {
|
||||
LocEngAdapter* mAdapter;
|
||||
const GpsUserResponseType mResponse;
|
||||
const void *mPayload;
|
||||
inline LocEngInformNiResponse(LocEngAdapter* adapter,
|
||||
GpsUserResponseType resp,
|
||||
const void* data) :
|
||||
LocMsg(), mAdapter(adapter),
|
||||
mResponse(resp), mPayload(data)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline ~LocEngInformNiResponse()
|
||||
{
|
||||
// this is a bit weird since mPayload is not
|
||||
// allocated by this class. But there is no better way.
|
||||
// mPayload actually won't be NULL here.
|
||||
free((void*)mPayload);
|
||||
}
|
||||
inline virtual void proc() const
|
||||
{
|
||||
mAdapter->informNiResponse(mResponse, mPayload);
|
||||
}
|
||||
inline void locallog() const
|
||||
{
|
||||
LOC_LOGV("LocEngInformNiResponse - "
|
||||
"response: %s\n mPayload: %p",
|
||||
loc_get_ni_response_name(mResponse),
|
||||
mPayload);
|
||||
}
|
||||
inline virtual void log() const
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
|
||||
FUNCTION loc_eng_ni_request_handler
|
||||
|
@ -179,13 +219,13 @@ static void* ni_thread_proc(void *args)
|
|||
loc_eng_ni_data_p->respRecvd = FALSE; /* Reset the user response flag for the next session*/
|
||||
|
||||
// adding this check to support modem restart, in which case, we need the thread
|
||||
// to exit without calling sending data to loc_eng_msg_q. We made sure that
|
||||
// rawRequest is NULL in loc_eng_ni_reset_on_engine_restart()
|
||||
loc_eng_msg_inform_ni_response *msg = NULL;
|
||||
// to exit without calling sending data. We made sure that rawRequest is NULL in
|
||||
// loc_eng_ni_reset_on_engine_restart()
|
||||
LocEngAdapter* adapter = loc_eng_data_p->adapter;
|
||||
LocEngInformNiResponse *msg = NULL;
|
||||
|
||||
if (NULL != loc_eng_ni_data_p->rawRequest) {
|
||||
loc_eng_data_s_type *loc_eng_data_p = (loc_eng_data_s_type*)args;
|
||||
msg = new loc_eng_msg_inform_ni_response(loc_eng_data_p,
|
||||
msg = new LocEngInformNiResponse(adapter,
|
||||
loc_eng_ni_data_p->resp,
|
||||
loc_eng_ni_data_p->rawRequest);
|
||||
loc_eng_ni_data_p->rawRequest = NULL;
|
||||
|
@ -196,7 +236,7 @@ static void* ni_thread_proc(void *args)
|
|||
loc_eng_ni_data_p->reqID++;
|
||||
|
||||
if (NULL != msg) {
|
||||
loc_eng_msg_sender(loc_eng_data_p, msg);
|
||||
adapter->sendMsg(msg);
|
||||
}
|
||||
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
|
|
|
@ -259,7 +259,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
|
|||
|
||||
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode)
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
|
||||
else
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
|
||||
|
@ -412,7 +412,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
|
|||
|
||||
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode)
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
|
||||
else
|
||||
length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
|
||||
|
@ -490,7 +490,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
|
|||
char gpsQuality;
|
||||
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
|
||||
gpsQuality = '0'; // 0 means no fix
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode)
|
||||
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)
|
||||
gpsQuality = '1'; // 1 means GPS fix
|
||||
else
|
||||
gpsQuality = '2'; // 2 means DGPS fix
|
||||
|
|
|
@ -31,10 +31,57 @@
|
|||
#define LOG_TAG "LocSvc_eng"
|
||||
|
||||
#include <loc_eng.h>
|
||||
#include <loc_eng_msg.h>
|
||||
#include <MsgTask.h>
|
||||
#include "log_util.h"
|
||||
#include "platform_lib_includes.h"
|
||||
|
||||
using namespace loc_core;
|
||||
|
||||
struct LocEngRequestXtraServer : public LocMsg {
|
||||
LocEngAdapter* mAdapter;
|
||||
inline LocEngRequestXtraServer(LocEngAdapter* adapter) :
|
||||
LocMsg(), mAdapter(adapter)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mAdapter->requestXtraServer();
|
||||
}
|
||||
inline void locallog() const {
|
||||
LOC_LOGV("LocEngRequestXtraServer");
|
||||
}
|
||||
inline virtual void log() const {
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
|
||||
struct LocEngInjectXtraData : public LocMsg {
|
||||
LocEngAdapter* mAdapter;
|
||||
char* mData;
|
||||
const int mLen;
|
||||
inline LocEngInjectXtraData(LocEngAdapter* adapter,
|
||||
char* data, int len):
|
||||
LocMsg(), mAdapter(adapter),
|
||||
mData(new char[len]), mLen(len)
|
||||
{
|
||||
memcpy((void*)mData, (void*)data, len);
|
||||
locallog();
|
||||
}
|
||||
inline ~LocEngInjectXtraData()
|
||||
{
|
||||
delete[] mData;
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mAdapter->setXtraData(mData, mLen);
|
||||
}
|
||||
inline void locallog() const {
|
||||
LOC_LOGV("length: %d\n data: %p", mLen, mData);
|
||||
}
|
||||
inline virtual void log() const {
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION loc_eng_xtra_init
|
||||
|
||||
|
@ -89,9 +136,8 @@ SIDE EFFECTS
|
|||
int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
|
||||
char* data, int length)
|
||||
{
|
||||
loc_eng_msg_inject_xtra_data *msg(new loc_eng_msg_inject_xtra_data(&loc_eng_data,
|
||||
data, length));
|
||||
loc_eng_msg_sender(&loc_eng_data, msg);
|
||||
LocEngAdapter* adapter = loc_eng_data.adapter;
|
||||
adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -113,12 +159,8 @@ SIDE EFFECTS
|
|||
===========================================================================*/
|
||||
int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data)
|
||||
{
|
||||
loc_eng_msg_request_xtra_server *msg(new loc_eng_msg_request_xtra_server(&loc_eng_data));
|
||||
|
||||
if (NULL == msg)
|
||||
return -1;
|
||||
|
||||
loc_eng_msg_sender(&loc_eng_data, msg);
|
||||
LocEngAdapter* adapter = loc_eng_data.adapter;
|
||||
adapter->sendMsg(new LocEngRequestXtraServer(adapter));
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue