summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerTeufel <dominik-kassel@gmx.de>2014-11-29 23:42:59 +0100
committersbrissen <sbrissen@hotmail.com>2014-12-05 14:42:15 -0500
commita740abcb1819b583d1bede6eaf4f075167864a0e (patch)
treedef3a48ff9fe044b1bed2c4f55a6426012aed939
parent52f8310213c22172ce1ddd0753637df2c9162139 (diff)
downloadandroid_device_samsung_smdk4412-qcom-common-a740abcb1819b583d1bede6eaf4f075167864a0e.tar.gz
android_device_samsung_smdk4412-qcom-common-a740abcb1819b583d1bede6eaf4f075167864a0e.tar.bz2
android_device_samsung_smdk4412-qcom-common-a740abcb1819b583d1bede6eaf4f075167864a0e.zip
update gps hal from jf
Change-Id: I8d08e1c871d9b9e4338f4823c8cdd1d33f6a2b6b
-rw-r--r--BoardCommonConfig.mk3
-rw-r--r--common.mk12
-rw-r--r--gps/Android.mk2
-rw-r--r--gps/core/Android.mk51
-rw-r--r--gps/core/ContextBase.cpp114
-rw-r--r--gps/core/ContextBase.h69
-rw-r--r--gps/core/LBSProxyBase.h60
-rw-r--r--gps/core/LocAdapterBase.cpp126
-rw-r--r--gps/core/LocAdapterBase.h107
-rw-r--r--gps/core/LocApiBase.cpp496
-rw-r--r--gps/core/LocApiBase.h232
-rw-r--r--gps/core/LocDualContext.cpp134
-rw-r--r--gps/core/LocDualContext.h72
-rw-r--r--gps/core/MsgTask.cpp147
-rw-r--r--gps/core/MsgTask.h67
-rw-r--r--gps/core/UlpProxyBase.h82
-rw-r--r--gps/core/gps_extended.h92
-rw-r--r--gps/core/gps_extended_c.h940
-rw-r--r--gps/core/loc_core_log.cpp (renamed from gps/libloc_api_50001/loc_eng_log.cpp)114
-rw-r--r--gps/core/loc_core_log.h (renamed from gps/libloc_api_50001/loc_eng_log.h)14
-rw-r--r--gps/etc/gps.conf86
-rw-r--r--gps/etc/sap.conf42
-rw-r--r--gps/gps-cdma.conf104
-rw-r--r--gps/gps.conf104
-rw-r--r--gps/libloc_api_50001/.loc_eng_msg_id.h.swpbin16384 -> 0 bytes
-rwxr-xr-xgps/libloc_api_50001/LocApiAdapter.cpp242
-rwxr-xr-xgps/libloc_api_50001/LocApiAdapter.h246
-rwxr-xr-xgps/libloc_api_50001/loc_eng.cpp2214
-rw-r--r--gps/libloc_api_50001/loc_eng_msg.cpp133
-rwxr-xr-xgps/libloc_api_50001/loc_eng_msg.h904
-rwxr-xr-xgps/libloc_api_50001/loc_eng_msg_id.h139
-rw-r--r--gps/libloc_api_50001/loc_eng_nmea.cpp703
-rw-r--r--gps/libloc_api_50001/loc_eng_xtra.cpp95
-rw-r--r--gps/loc_api/Android.mk13
-rw-r--r--gps/loc_api/NOTICE (renamed from gps/NOTICE)0
-rw-r--r--gps/loc_api/libloc_api_50001/Android.mk (renamed from gps/libloc_api_50001/Android.mk)82
-rw-r--r--gps/loc_api/libloc_api_50001/LocEngAdapter.cpp343
-rw-r--r--gps/loc_api/libloc_api_50001/LocEngAdapter.h306
-rw-r--r--gps/loc_api/libloc_api_50001/Makefile.am76
-rw-r--r--gps/loc_api/libloc_api_50001/gps.c (renamed from gps/libloc_api_50001/gps.c)6
-rw-r--r--[-rwxr-xr-x]gps/loc_api/libloc_api_50001/loc.cpp (renamed from gps/libloc_api_50001/loc.cpp)502
-rw-r--r--[-rwxr-xr-x]gps/loc_api/libloc_api_50001/loc.h (renamed from gps/libloc_api_50001/loc.h)45
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng.cpp2634
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng.h (renamed from gps/libloc_api_50001/loc_eng.h)165
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_agps.cpp (renamed from gps/libloc_api_50001/loc_eng_agps.cpp)291
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_agps.h (renamed from gps/libloc_api_50001/loc_eng_agps.h)156
-rw-r--r--[-rwxr-xr-x]gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp (renamed from gps/libloc_api_50001/loc_eng_dmn_conn.cpp)8
-rw-r--r--[-rwxr-xr-x]gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn.h)14
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c)2
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h)0
-rw-r--r--[-rwxr-xr-x]gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c)6
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h)0
-rw-r--r--[-rwxr-xr-x]gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp)137
-rw-r--r--[-rwxr-xr-x]gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_handler.h)10
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c)1
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h)0
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_log.cpp35
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_log.h44
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_msg.h296
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_ni.cpp (renamed from gps/libloc_api_50001/loc_eng_ni.cpp)229
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_ni.h (renamed from gps/libloc_api_50001/loc_eng_ni.h)11
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp836
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_nmea.h (renamed from gps/libloc_api_50001/loc_eng_nmea.h)4
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp213
-rw-r--r--gps/loc_api/libloc_api_50001/loc_eng_xtra.h (renamed from gps/libloc_api_50001/loc_eng_xtra.h)3
-rw-r--r--gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp46
-rw-r--r--gps/platform_lib_abstractions/platform_lib_includes.h (renamed from gps/ulp/inc/ulp.h)34
-rw-r--r--gps/platform_lib_abstractions/platform_lib_macros.h81
-rw-r--r--gps/platform_lib_abstractions/platform_lib_time.h35
-rw-r--r--gps/utils/Android.mk21
-rw-r--r--gps/utils/Makefile.am44
-rw-r--r--gps/utils/linked_list.c2
-rw-r--r--gps/utils/loc_cfg.cpp382
-rw-r--r--gps/utils/loc_cfg.h12
-rw-r--r--gps/utils/loc_log.cpp42
-rw-r--r--gps/utils/loc_log.h6
-rw-r--r--gps/utils/loc_misc_utils.cpp114
-rw-r--r--gps/utils/loc_misc_utils.h99
-rw-r--r--gps/utils/loc_target.cpp183
-rw-r--r--gps/utils/loc_target.h42
-rw-r--r--gps/utils/loc_timer.c202
-rw-r--r--gps/utils/loc_timer.h63
-rw-r--r--gps/utils/log_util.h66
-rw-r--r--gps/utils/msg_q.c20
-rw-r--r--gps/utils/msg_q.h20
-rw-r--r--gps/utils/sec_gps.c12
-rw-r--r--include/hardware/gps.h1417
87 files changed, 10869 insertions, 6488 deletions
diff --git a/BoardCommonConfig.mk b/BoardCommonConfig.mk
index 2796efc..73f46e5 100644
--- a/BoardCommonConfig.mk
+++ b/BoardCommonConfig.mk
@@ -19,4 +19,5 @@ COMMON_PATH := device/samsung/smdk4412-qcom-common
TARGET_SPECIFIC_HEADER_PATH := device/samsung/smdk4412-qcom-common/include
# GPS
-BOARD_HAVE_NEW_QC_GPS := true
+TARGET_NO_RPC := true
+#BOARD_HAVE_NEW_QC_GPS := true
diff --git a/common.mk b/common.mk
index ec75e0f..ca58aab 100644
--- a/common.mk
+++ b/common.mk
@@ -18,14 +18,18 @@ COMMON_PATH := device/samsung/smdk4412-qcom-common
# GPS
PRODUCT_PACKAGES += \
- gps.default
+ gps.default \
+ libgps.utils \
+ libloc_core \
+ libloc_eng
ifeq ($(TARGET_VOICE_TECH), cdma)
- GPS_CONF := $(COMMON_PATH)/gps/gps-cdma.conf
+ GPS_CONF := $(COMMON_PATH)/gps/etc/gps-cdma.conf
else
- GPS_CONF := $(COMMON_PATH)/gps/gps.conf
+ GPS_CONF := $(COMMON_PATH)/gps/etc/gps.conf
endif
PRODUCT_COPY_FILES += \
- $(GPS_CONF):/system/etc/gps.conf
+ $(GPS_CONF):/system/etc/gps.conf \
+ $(LOCAL_PATH)/gps/etc/sap.conf:/system/etc/sap.conf
diff --git a/gps/Android.mk b/gps/Android.mk
index 484a48d..a92484d 100644
--- a/gps/Android.mk
+++ b/gps/Android.mk
@@ -22,4 +22,4 @@
LOCAL_PATH := $(call my-dir)
-include $(call all-subdir-makefiles,$(LOCAL_PATH)) \ No newline at end of file
+include $(call all-subdir-makefiles,$(LOCAL_PATH))
diff --git a/gps/core/Android.mk b/gps/core/Android.mk
new file mode 100644
index 0000000..178e559
--- /dev/null
+++ b/gps/core/Android.mk
@@ -0,0 +1,51 @@
+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
+
+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 \
+ LBSProxyBase.h \
+ UlpProxyBase.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
+
diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp
new file mode 100644
index 0000000..8c2f8f0
--- /dev/null
+++ b/gps/core/ContextBase.cpp
@@ -0,0 +1,114 @@
+/* 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 <loc_target.h>
+#include <log_util.h>
+#include <loc_log.h>
+
+namespace loc_core {
+
+LBSProxyBase* ContextBase::getLBSProxy(const char* libName)
+{
+ LBSProxyBase* proxy = NULL;
+ LOC_LOGD("%s:%d]: getLBSProxy libname: %s\n", __func__, __LINE__, libName);
+ void* lib = dlopen(libName, RTLD_NOW);
+
+ if ((void*)NULL != lib) {
+ getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, "getLBSProxy");
+ if (NULL != getter) {
+ proxy = (*getter)();
+ }
+ }
+ if (NULL == proxy) {
+ proxy = new LBSProxyBase();
+ }
+ LOC_LOGD("%s:%d]: Exiting\n", __func__, __LINE__);
+ return proxy;
+}
+
+LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
+{
+ LocApiBase* locApi = NULL;
+
+ // first if can not be MPQ
+ if (TARGET_MPQ != loc_get_target()) {
+ if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask))) {
+ void *handle = NULL;
+ //try to see if LocApiV02 is present
+ if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) {
+ LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__);
+ getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
+ if(getter != NULL) {
+ LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__);
+ locApi = (*getter)(mMsgTask,exMask);
+ }
+ }
+ // only RPC is the option now
+ else {
+ LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC",
+ __func__, __LINE__);
+ handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
+ if (NULL != handle) {
+ getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
+ if (NULL != getter) {
+ LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__);
+ locApi = (*getter)(mMsgTask, exMask);
+ }
+ }
+ }
+ }
+ }
+
+ // locApi could still be NULL at this time
+ // we would then create a dummy one
+ if (NULL == locApi) {
+ locApi = new LocApiBase(mMsgTask, exMask);
+ }
+
+ return locApi;
+}
+
+ContextBase::ContextBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask,
+ const char* libName) :
+ mLBSProxy(getLBSProxy(libName)),
+ mMsgTask(msgTask),
+ mLocApi(createLocApi(exMask)),
+ mLocApiProxy(mLocApi->getLocApiProxy())
+{
+}
+
+}
diff --git a/gps/core/ContextBase.h b/gps/core/ContextBase.h
new file mode 100644
index 0000000..d713587
--- /dev/null
+++ b/gps/core/ContextBase.h
@@ -0,0 +1,69 @@
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * 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>
+#include <LBSProxyBase.h>
+
+namespace loc_core {
+
+class LocAdapterBase;
+
+class ContextBase {
+ static LBSProxyBase* getLBSProxy(const char* libName);
+ LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
+protected:
+ const LBSProxyBase* mLBSProxy;
+ const MsgTask* mMsgTask;
+ LocApiBase* mLocApi;
+ LocApiProxyBase *mLocApiProxy;
+public:
+ ContextBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask,
+ const char* libName);
+ inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; }
+
+ inline const MsgTask* getMsgTask() { return mMsgTask; }
+ inline LocApiBase* getLocApi() { return mLocApi; }
+ inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
+ inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }
+ inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); }
+ inline void requestUlp(LocAdapterBase* adapter,
+ unsigned long capabilities) {
+ mLBSProxy->requestUlp(adapter, capabilities);
+ }
+};
+
+} // namespace loc_core
+
+#endif //__LOC_CONTEXT_BASE__
diff --git a/gps/core/LBSProxyBase.h b/gps/core/LBSProxyBase.h
new file mode 100644
index 0000000..99872ee
--- /dev/null
+++ b/gps/core/LBSProxyBase.h
@@ -0,0 +1,60 @@
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef IZAT_PROXY_BASE_H
+#define IZAT_PROXY_BASE_H
+#include <gps_extended.h>
+#include <MsgTask.h>
+
+namespace loc_core {
+
+class LocApiBase;
+class LocAdapterBase;
+
+class LBSProxyBase {
+ friend class ContextBase;
+ inline virtual LocApiBase*
+ getLocApi(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask) const {
+ return NULL;
+ }
+protected:
+ inline LBSProxyBase() {}
+public:
+ inline virtual ~LBSProxyBase() {}
+ inline virtual void requestUlp(LocAdapterBase* adapter,
+ unsigned long capabilities) const {}
+ inline virtual bool hasAgpsExtendedCapabilities() const { return false; }
+ inline virtual bool hasCPIExtendedCapabilities() const { return false; }
+};
+
+typedef LBSProxyBase* (getLBSProxy_t)();
+
+} // namespace loc_core
+
+#endif // IZAT_PROXY_BASE_H
diff --git a/gps/core/LocAdapterBase.cpp b/gps/core/LocAdapterBase.cpp
new file mode 100644
index 0000000..f54fdce
--- /dev/null
+++ b/gps/core/LocAdapterBase.cpp
@@ -0,0 +1,126 @@
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * 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 {
+
+// 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())
+{
+ mLocApi->addAdapter(this);
+}
+
+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::
+ reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
+DEFAULT_IMPL()
+
+void LocAdapterBase::
+ reportSvPolynomial(GnssSvPolynomial &svPolynomial)
+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 &notify, const void* data)
+DEFAULT_IMPL(false)
+} // namespace loc_core
diff --git a/gps/core/LocAdapterBase.h b/gps/core/LocAdapterBase.h
new file mode 100644
index 0000000..e1b7831
--- /dev/null
+++ b/gps/core/LocAdapterBase.h
@@ -0,0 +1,107 @@
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * 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 <UlpProxyBase.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;
+
+ inline LocAdapterBase(const MsgTask* msgTask) :
+ mEvtMask(0), mContext(NULL), mLocApi(NULL), mMsgTask(msgTask) {}
+public:
+ inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
+ LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
+ ContextBase* context);
+ 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 setUlpProxy(UlpProxyBase* ulp) {}
+ inline virtual void handleEngineUpEvent() {}
+ virtual void handleEngineDownEvent();
+ inline virtual void setPositionModeInt(LocPosMode& posMode) {}
+ virtual void startFixInt() {}
+ virtual void stopFixInt() {}
+ virtual void getZppInt() {}
+ 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 reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
+ virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
+ 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 &notify,
+ const void* data);
+ inline virtual bool isInSession() { return false; }
+ ContextBase* getContext() const { return mContext; }
+};
+
+} // namespace loc_core
+
+#endif //LOC_API_ADAPTER_BASE_H
diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp
new file mode 100644
index 0000000..d6ee53b
--- /dev/null
+++ b/gps/core/LocApiBase.cpp
@@ -0,0 +1,496 @@
+/* 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 <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();
+ }
+};
+
+struct LocOpenMsg : public LocMsg {
+ LocApiBase* mLocApi;
+ LOC_API_ADAPTER_EVENT_MASK_T mMask;
+ inline LocOpenMsg(LocApiBase* locApi,
+ LOC_API_ADAPTER_EVENT_MASK_T mask) :
+ LocMsg(), mLocApi(locApi), mMask(mask)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mLocApi->open(mMask);
+ }
+ inline void locallog() {
+ LOC_LOGV("%s:%d]: LocOpen Mask: %x\n",
+ __func__, __LINE__, mMask);
+ }
+ inline virtual void log() {
+ locallog();
+ }
+};
+
+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;
+
+ for (int i = 0;
+ !inSession && i < MAX_ADAPTERS && NULL != mLocAdapters[i];
+ i++) {
+ 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;
+ mMsgTask->sendMsg(new LocOpenMsg(this,
+ (adapter->getEvtMask())));
+ 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
+ mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
+ }
+ }
+ }
+}
+
+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::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(
+ mLocAdapters[i]->reportSvMeasurement(svMeasurementSet)
+ );
+}
+
+void LocApiBase::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
+{
+ // loop through adapters, and deliver to all adapters.
+ TO_ALL_LOCADAPTERS(
+ mLocAdapters[i]->reportSvPolynomial(svPolynomial)
+ );
+}
+
+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 &notify, const void* data)
+{
+ // loop through adapters, and deliver to the first handling adapter.
+ TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data));
+}
+
+void* LocApiBase :: getSibling()
+ DEFAULT_IMPL(NULL)
+
+LocApiProxyBase* LocApiBase :: getLocApiProxy()
+ DEFAULT_IMPL(NULL)
+
+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,
+ int sensorProvider)
+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)
+
+enum loc_api_adapter_err LocApiBase::
+ getZppFix(GpsLocation & zppLoc)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+
+enum loc_api_adapter_err LocApiBase::
+ getZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask)
+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()
+
+int LocApiBase::
+ setGpsLock(unsigned int lock)
+DEFAULT_IMPL(-1)
+
+int LocApiBase::
+ getGpsLock()
+DEFAULT_IMPL(-1)
+
+enum loc_api_adapter_err LocApiBase::
+ setXtraVersionCheck(enum xtra_version_check check)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
+} // namespace loc_core
diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h
new file mode 100644
index 0000000..ef64dda
--- /dev/null
+++ b/gps/core/LocApiBase.h
@@ -0,0 +1,232 @@
+/* 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>
+#include <log_util.h>
+
+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);
+
+#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++);
+
+enum xtra_version_check {
+ DISABLED,
+ AUTO,
+ XTRA2,
+ XTRA3
+};
+
+class LocAdapterBase;
+struct LocSsrMsg;
+struct LocOpenMsg;
+
+class LocApiProxyBase {
+public:
+ inline LocApiProxyBase() {}
+ inline virtual ~LocApiProxyBase() {}
+ inline virtual void* getSibling2() { return NULL; }
+};
+
+class LocApiBase {
+ friend struct LocSsrMsg;
+ //LocOpenMsg calls open() which makes it necessary to declare
+ //it as a friend
+ friend struct LocOpenMsg;
+ friend class ContextBase;
+ const MsgTask* mMsgTask;
+ LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
+
+protected:
+ virtual enum loc_api_adapter_err
+ open(LOC_API_ADAPTER_EVENT_MASK_T mask);
+ virtual enum loc_api_adapter_err
+ close();
+ LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
+ LOC_API_ADAPTER_EVENT_MASK_T mMask;
+ LocApiBase(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
+ inline virtual ~LocApiBase() { close(); }
+ bool isInSession();
+ const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
+
+public:
+ inline void sendMsg(const LocMsg* msg) const {
+ mMsgTask->sendMsg(msg);
+ }
+
+ 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 reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
+ void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
+ 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 &notify, 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 void* getSibling();
+ virtual LocApiProxyBase* getLocApiProxy();
+ 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, int sensorProvider);
+ 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 enum loc_api_adapter_err
+ getZppFix(GpsLocation & zppLoc);
+ virtual enum loc_api_adapter_err
+ getZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask);
+ virtual int initDataServiceClient();
+ virtual int openAndStartDataCall();
+ virtual void stopDataCall();
+ virtual void closeDataCall();
+
+ inline virtual void setInSession(bool inSession) {}
+
+ /*Values for lock
+ 1 = Do not lock any position sessions
+ 2 = Lock MI position sessions
+ 3 = Lock MT position sessions
+ 4 = Lock all position sessions
+ */
+ virtual int setGpsLock(unsigned int lock);
+ /*
+ Returns
+ Current value of GPS Lock on success
+ -1 on failure
+ */
+ virtual int getGpsLock(void);
+ virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check);
+};
+
+typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask);
+
+} // namespace loc_core
+
+#endif //LOC_API_BASE_H
diff --git a/gps/core/LocDualContext.cpp b/gps/core/LocDualContext.cpp
new file mode 100644
index 0000000..fa4c4d6
--- /dev/null
+++ b/gps/core/LocDualContext.cpp
@@ -0,0 +1,134 @@
+/* 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;
+
+// the name must be shorter than 15 chars
+const char* LocDualContext::mLocationHalName = "Loc_hal_worker";
+const char* LocDualContext::mIzatLibName = "liblbs_core.so";
+
+const MsgTask* LocDualContext::getMsgTask(MsgTask::tCreate tCreator,
+ const char* name)
+{
+ if (NULL == mMsgTask) {
+ mMsgTask = new MsgTask(tCreator, name);
+ }
+ return mMsgTask;
+}
+
+const MsgTask* LocDualContext::getMsgTask(MsgTask::tAssociate tAssociate,
+ const char* name)
+{
+ if (NULL == mMsgTask) {
+ mMsgTask = new MsgTask(tAssociate, name);
+ } else if (tAssociate) {
+ mMsgTask->associate(tAssociate);
+ }
+ 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::getLocFgContext(MsgTask::tAssociate tAssociate,
+ const char* name)
+{
+ if (NULL == mFgContext) {
+ const MsgTask* msgTask = getMsgTask(tAssociate, name);
+ mFgContext = new LocDualContext(msgTask,
+ mFgExclMask);
+ }
+ return mFgContext;
+
+}
+
+ContextBase* LocDualContext::getLocBgContext(MsgTask::tCreate tCreator,
+ const char* name)
+{
+ if (NULL == mBgContext) {
+ const MsgTask* msgTask = getMsgTask(tCreator, name);
+ mBgContext = new LocDualContext(msgTask,
+ mBgExclMask);
+ }
+ return mBgContext;
+}
+
+ContextBase* LocDualContext::getLocBgContext(MsgTask::tAssociate tAssociate,
+ const char* name)
+{
+ if (NULL == mBgContext) {
+ const MsgTask* msgTask = getMsgTask(tAssociate, name);
+ mBgContext = new LocDualContext(msgTask,
+ mBgExclMask);
+ }
+ return mBgContext;
+}
+
+LocDualContext::LocDualContext(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask) :
+ ContextBase(msgTask, exMask, mIzatLibName)
+{
+}
+
+}
diff --git a/gps/core/LocDualContext.h b/gps/core/LocDualContext.h
new file mode 100644
index 0000000..e761e76
--- /dev/null
+++ b/gps/core/LocDualContext.h
@@ -0,0 +1,72 @@
+/* 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 const MsgTask* getMsgTask(MsgTask::tCreate tCreator,
+ const char* name);
+ static const MsgTask* getMsgTask(MsgTask::tAssociate tAssociate,
+ const char* name);
+
+protected:
+ LocDualContext(const MsgTask* msgTask,
+ LOC_API_ADAPTER_EVENT_MASK_T exMask);
+ inline virtual ~LocDualContext() {}
+
+public:
+ static const char* mIzatLibName;
+ 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* getLocFgContext(MsgTask::tAssociate tAssociate,
+ const char* name);
+ static ContextBase* getLocBgContext(MsgTask::tCreate tCreator,
+ const char* name);
+ static ContextBase* getLocBgContext(MsgTask::tAssociate tAssociate,
+ const char* name);
+};
+
+}
+
+#endif //__LOC_ENG_CONTEXT__
diff --git a/gps/core/MsgTask.cpp b/gps/core/MsgTask.cpp
new file mode 100644
index 0000000..5d375aa
--- /dev/null
+++ b/gps/core/MsgTask.cpp
@@ -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_MsgTask"
+
+#include <cutils/sched_policy.h>
+#include <unistd.h>
+#include <MsgTask.h>
+#include <msg_q.h>
+#include <log_util.h>
+#include <loc_log.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::associate(tAssociate tAssociator) const {
+ struct LocAssociateMsg : public LocMsg {
+ tAssociate mAssociator;
+ inline LocAssociateMsg(tAssociate associator) :
+ LocMsg(), mAssociator(associator) {}
+ inline virtual void proc() const {
+ if (mAssociator) {
+ LOC_LOGD("MsgTask::associate");
+ mAssociator();
+ }
+ }
+ };
+ sendMsg(new LocAssociateMsg(tAssociator));
+}
+
+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;
+}
+
+}
diff --git a/gps/core/MsgTask.h b/gps/core/MsgTask.h
new file mode 100644
index 0000000..d50bb31
--- /dev/null
+++ b/gps/core/MsgTask.h
@@ -0,0 +1,67 @@
+/* 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;
+ void associate(tAssociate tAssociator) 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__
diff --git a/gps/core/UlpProxyBase.h b/gps/core/UlpProxyBase.h
new file mode 100644
index 0000000..e1fb5cd
--- /dev/null
+++ b/gps/core/UlpProxyBase.h
@@ -0,0 +1,82 @@
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef ULP_PROXY_BASE_H
+#define ULP_PROXY_BASE_H
+
+#include <gps_extended.h>
+
+namespace loc_core {
+
+class LocAdapterBase;
+
+class UlpProxyBase {
+public:
+ LocPosMode mPosMode;
+ bool mFixSet;
+ inline UlpProxyBase() {
+ mPosMode.mode = LOC_POSITION_MODE_INVALID;
+ mFixSet = false;
+ }
+ inline virtual ~UlpProxyBase() {}
+ inline virtual bool sendStartFix() { mFixSet = true; return false; }
+ inline virtual bool sendStopFix() { mFixSet = false; return false; }
+ inline virtual bool sendFixMode(LocPosMode &params) {
+ mPosMode = params;
+ return false;
+ }
+ inline virtual bool reportPosition(UlpLocation &location,
+ GpsLocationExtended &locationExtended,
+ void* locationExt,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask) {
+ return false;
+ }
+ inline virtual bool reportSv(GpsSvStatus &svStatus,
+ GpsLocationExtended &locationExtended,
+ void* svExt) {
+ return false;
+ }
+ inline virtual bool reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet) {
+ return false;
+ }
+
+ inline virtual bool reportSvPolynomial(GnssSvPolynomial &svPolynomial)
+ {
+ return false;
+ }
+ inline virtual bool reportStatus(GpsStatusValue status) {
+ return false;
+ }
+ inline virtual void setAdapter(LocAdapterBase* adapter) {}
+ inline virtual void setCapabilities(unsigned long capabilities) {}
+};
+
+} // namespace loc_core
+
+#endif // ULP_PROXY_BASE_H
diff --git a/gps/core/gps_extended.h b/gps/core/gps_extended.h
new file mode 100644
index 0000000..88b0415
--- /dev/null
+++ b/gps/core/gps_extended.h
@@ -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 */
+
diff --git a/gps/core/gps_extended_c.h b/gps/core/gps_extended_c.h
new file mode 100644
index 0000000..df20bdc
--- /dev/null
+++ b/gps/core/gps_extended_c.h
@@ -0,0 +1,940 @@
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef 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
+/** Position source is ZPP only */
+#define ULP_LOCATION_IS_FROM_ZPP 0x0004
+/** Position is from a Geofence Breach Event */
+#define ULP_LOCATION_IS_FROM_GEOFENCE 0X0008
+/** Position is from a Geofence Breach Event */
+#define ULP_LOCATION_IS_FROM_EXT_DR 0X0010
+
+#define ULP_MIN_INTERVAL_INVALID 0xffffffff
+
+/*Emergency SUPL*/
+#define GPS_NI_TYPE_EMERGENCY_SUPL 4
+
+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
+
+/** 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_INVALID = -1,
+ LOC_POSITION_MODE_STANDALONE = 0,
+ 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 */
+
+/** GpsLocationExtended has valid latitude and longitude. */
+#define GPS_LOCATION_EXTENDED_HAS_LAT_LONG (1U<<0)
+/** GpsLocationExtended has valid altitude. */
+#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE (1U<<1)
+/** GpsLocationExtended has valid speed. */
+#define GPS_LOCATION_EXTENDED_HAS_SPEED (1U<<2)
+/** GpsLocationExtended has valid bearing. */
+#define GPS_LOCATION_EXTENDED_HAS_BEARING (1U<<4)
+/** GpsLocationExtended has valid accuracy. */
+#define GPS_LOCATION_EXTENDED_HAS_ACCURACY (1U<<8)
+
+/** GPS extended supports geofencing */
+#define GPS_EXTENDED_CAPABILITY_GEOFENCE 0x0000001
+/** GPS extended supports batching */
+#define GPS_EXTENDED_CAPABILITY_BATCHING 0x0000002
+
+/** 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;
+
+
+#define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
+#define MAX_APN_LEN 100
+
+// This will be overridden by the individual adapters
+// if necessary.
+#define DEFAULT_IMPL(rtv) \
+{ \
+ LOC_LOGD("%s: default implementation invoked", __func__); \
+ return rtv; \
+}
+
+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_INTERNAL = 10,
+
+ /* equating engine down to phone offline, as they are the same errror */
+ LOC_API_ADAPTER_ERR_ENGINE_DOWN = LOC_API_ADAPTER_ERR_PHONE_OFFLINE,
+ LOC_API_ADAPTER_ERR_FAILURE = 101,
+ 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_REQUEST_WIFI_AP_DATA, // Wifi ap data
+ LOC_API_ADAPTER_BATCH_FULL, // Batching on full
+ LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix
+ LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT, //
+ LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT, //GNSS Measurement Report
+ LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT, //GNSS SV Polynomial Report
+
+ 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_BATCHED_GENFENCE_BREACH_REPORT (1<<LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT)
+#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
+#define LOC_API_ADAPTER_BIT_MOTION_CTRL (1<<LOC_API_ADAPTER_MOTION_CTRL)
+#define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
+#define LOC_API_ADAPTER_BIT_BATCH_FULL (1<<LOC_API_ADAPTER_BATCH_FULL)
+#define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)
+#define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT_REPORT (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT)
+#define LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT (1<<LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT)
+
+
+
+typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
+
+/*++ ***********************************************
+** Satellite Measurement and Satellite Polynomial
+** Structure definitions
+** ***********************************************
+--*/
+#define GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE 12
+#define GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE 3
+#define GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE 9
+#define GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE 4
+#define GNSS_LOC_SV_MEAS_LIST_MAX_SIZE 16
+
+enum ulp_gnss_sv_measurement_valid_flags{
+
+ ULP_GNSS_SV_MEAS_GPS_TIME = 0,
+ ULP_GNSS_SV_MEAS_PSUEDO_RANGE,
+ ULP_GNSS_SV_MEAS_MS_IN_WEEK,
+ ULP_GNSS_SV_MEAS_SUB_MSEC,
+ ULP_GNSS_SV_MEAS_CARRIER_PHASE,
+ ULP_GNSS_SV_MEAS_DOPPLER_SHIFT,
+ ULP_GNSS_SV_MEAS_CNO,
+ ULP_GNSS_SV_MEAS_LOSS_OF_LOCK,
+
+ ULP_GNSS_SV_MEAS_MAX_VALID_FLAGS
+};
+
+#define ULP_GNSS_SV_MEAS_BIT_GPS_TIME (1<<ULP_GNSS_SV_MEAS_GPS_TIME)
+#define ULP_GNSS_SV_MEAS_BIT_PSUEDO_RANGE (1<<ULP_GNSS_SV_MEAS_PSUEDO_RANGE)
+#define ULP_GNSS_SV_MEAS_BIT_MS_IN_WEEK (1<<ULP_GNSS_SV_MEAS_MS_IN_WEEK)
+#define ULP_GNSS_SV_MEAS_BIT_SUB_MSEC (1<<ULP_GNSS_SV_MEAS_SUB_MSEC)
+#define ULP_GNSS_SV_MEAS_BIT_CARRIER_PHASE (1<<ULP_GNSS_SV_MEAS_CARRIER_PHASE)
+#define ULP_GNSS_SV_MEAS_BIT_DOPPLER_SHIFT (1<<ULP_GNSS_SV_MEAS_DOPPLER_SHIFT)
+#define ULP_GNSS_SV_MEAS_BIT_CNO (1<<ULP_GNSS_SV_MEAS_CNO)
+#define ULP_GNSS_SV_MEAS_BIT_LOSS_OF_LOCK (1<<ULP_GNSS_SV_MEAS_LOSS_OF_LOCK)
+
+enum ulp_gnss_sv_poly_valid_flags{
+
+ ULP_GNSS_SV_POLY_GLO_FREQ = 0,
+ ULP_GNSS_SV_POLY_T0,
+ ULP_GNSS_SV_POLY_IODE,
+ ULP_GNSS_SV_POLY_FLAG,
+ ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0,
+ ULP_GNSS_SV_POLY_POLYCOEFF_XYZN,
+ ULP_GNSS_SV_POLY_POLYCOEFF_OTHER,
+ ULP_GNSS_SV_POLY_SV_POSUNC,
+ ULP_GNSS_SV_POLY_IONODELAY,
+ ULP_GNSS_SV_POLY_IONODOT,
+ ULP_GNSS_SV_POLY_SBAS_IONODELAY,
+ ULP_GNSS_SV_POLY_SBAS_IONODOT,
+ ULP_GNSS_SV_POLY_TROPODELAY,
+ ULP_GNSS_SV_POLY_ELEVATION,
+ ULP_GNSS_SV_POLY_ELEVATIONDOT,
+ ULP_GNSS_SV_POLY_ELEVATIONUNC,
+ ULP_GNSS_SV_POLY_VELO_COEFF,
+
+ ULP_GNSS_SV_POLY_VALID_FLAGS
+
+};
+
+#define ULP_GNSS_SV_POLY_BIT_GLO_FREQ (1<<ULP_GNSS_SV_POLY_GLO_FREQ)
+#define ULP_GNSS_SV_POLY_BIT_T0 (1<<ULP_GNSS_SV_POLY_T0)
+#define ULP_GNSS_SV_POLY_BIT_IODE (1<<ULP_GNSS_SV_POLY_IODE)
+#define ULP_GNSS_SV_POLY_BIT_FLAG (1<<ULP_GNSS_SV_POLY_FLAG)
+#define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZ0 (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0)
+#define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZN (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZN)
+#define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_OTHER (1<<ULP_GNSS_SV_POLY_POLYCOEFF_OTHER)
+#define ULP_GNSS_SV_POLY_BIT_SV_POSUNC (1<<ULP_GNSS_SV_POLY_SV_POSUNC)
+#define ULP_GNSS_SV_POLY_BIT_IONODELAY (1<<ULP_GNSS_SV_POLY_IONODELAY)
+#define ULP_GNSS_SV_POLY_BIT_IONODOT (1<<ULP_GNSS_SV_POLY_IONODOT)
+#define ULP_GNSS_SV_POLY_BIT_SBAS_IONODELAY (1<<ULP_GNSS_SV_POLY_SBAS_IONODELAY)
+#define ULP_GNSS_SV_POLY_BIT_SBAS_IONODOT (1<<ULP_GNSS_SV_POLY_SBAS_IONODOT)
+#define ULP_GNSS_SV_POLY_BIT_TROPODELAY (1<<ULP_GNSS_SV_POLY_TROPODELAY)
+#define ULP_GNSS_SV_POLY_BIT_ELEVATION (1<<ULP_GNSS_SV_POLY_ELEVATION)
+#define ULP_GNSS_SV_POLY_BIT_ELEVATIONDOT (1<<ULP_GNSS_SV_POLY_ELEVATIONDOT)
+#define ULP_GNSS_SV_POLY_BIT_ELEVATIONUNC (1<<ULP_GNSS_SV_POLY_ELEVATIONUNC)
+#define ULP_GNSS_SV_POLY_BIT_VELO_COEFF (1<<ULP_GNSS_SV_POLY_VELO_COEFF)
+
+
+typedef enum
+{
+ GNSS_LOC_SV_SYSTEM_GPS = 1,
+ /**< GPS satellite. */
+ GNSS_LOC_SV_SYSTEM_GALILEO = 2,
+ /**< GALILEO satellite. */
+ GNSS_LOC_SV_SYSTEM_SBAS = 3,
+ /**< SBAS satellite. */
+ GNSS_LOC_SV_SYSTEM_COMPASS = 4,
+ /**< COMPASS satellite. */
+ GNSS_LOC_SV_SYSTEM_GLONASS = 5,
+ /**< GLONASS satellite. */
+ GNSS_LOC_SV_SYSTEM_BDS = 6
+ /**< BDS satellite. */
+} Gnss_LocSvSystemEnumType;
+
+typedef enum
+{
+ GNSS_LOC_FREQ_SOURCE_INVALID = 0,
+ /**< Source of the frequency is invalid */
+ GNSS_LOC_FREQ_SOURCE_EXTERNAL = 1,
+ /**< Source of the frequency is from external injection */
+ GNSS_LOC_FREQ_SOURCE_PE_CLK_REPORT = 2,
+ /**< Source of the frequency is from Navigation engine */
+ GNSS_LOC_FREQ_SOURCE_UNKNOWN = 3
+ /**< Source of the frequency is unknown */
+} Gnss_LocSourceofFreqEnumType;
+
+typedef struct
+{
+ size_t size;
+ float clockDrift;
+ /**< Receiver clock Drift \n
+ - Units: meter per sec \n
+ */
+ float clockDriftUnc;
+ /**< Receiver clock Drift uncertainty \n
+ - Units: meter per sec \n
+ */
+ Gnss_LocSourceofFreqEnumType sourceOfFreq;
+}Gnss_LocRcvrClockFrequencyInfoStructType;
+
+typedef struct
+{
+ size_t size;
+ uint8_t leapSec;
+ /**< GPS time leap second delta to UTC time \n
+ - Units: sec \n
+ */
+ uint8_t leapSecUnc;
+ /**< Uncertainty for GPS leap second \n
+ - Units: sec \n
+ */
+}Gnss_LeapSecondInfoStructType;
+
+typedef enum
+{
+ GNSS_LOC_SYS_TIME_BIAS_VALID = 0x01,
+ /**< System time bias valid */
+ GNSS_LOC_SYS_TIME_BIAS_UNC_VALID = 0x02,
+ /**< System time bias uncertainty valid */
+}Gnss_LocInterSystemBiasValidMaskType;
+
+typedef struct
+{
+ size_t size;
+ uint32_t validMask;
+ /* Validity mask as per Gnss_LocInterSystemBiasValidMaskType */
+
+ float timeBias;
+ /**< System-1 to System-2 Time Bias \n
+ - Units: msec \n
+ */
+ float timeBiasUnc;
+ /**< System-1 to System-2 Time Bias uncertainty \n
+ - Units: msec \n
+ */
+}Gnss_InterSystemBiasStructType;
+
+
+typedef struct
+{
+ size_t size;
+ uint16_t systemWeek;
+ /**< System week number for GPS, BDS and GAL satellite systems. \n
+ Set to 65535 when invalid or not available. \n
+ Not valid for GLONASS system. \n
+ */
+
+ uint32_t systemMsec;
+ /**< System time msec. Time of Week for GPS, BDS, GAL and
+ Time of Day for GLONASS.
+ - Units: msec \n
+ */
+ float systemClkTimeBias;
+ /**< System clock time bias \n
+ - Units: msec \n
+ System time = systemMsec - systemClkTimeBias \n
+ */
+ float systemClkTimeUncMs;
+ /**< Single sided maximum time bias uncertainty \n
+ - Units: msec \n
+ */
+}Gnss_LocSystemTimeStructType;
+
+typedef struct {
+
+ size_t size;
+ uint8_t gloFourYear;
+ /**< GLONASS four year number from 1996. Refer to GLONASS ICD.\n
+ Applicable only for GLONASS and shall be ignored for other constellations. \n
+ If unknown shall be set to 255
+ */
+
+ uint16_t gloDays;
+ /**< GLONASS day number in four years. Refer to GLONASS ICD.
+ Applicable only for GLONASS and shall be ignored for other constellations. \n
+ If unknown shall be set to 65535
+ */
+
+ uint32_t gloMsec;
+ /**< GLONASS time of day in msec. Refer to GLONASS ICD.
+ - Units: msec \n
+ */
+
+ float gloClkTimeBias;
+ /**< System clock time bias (sub-millisecond) \n
+ - Units: msec \n
+ System time = systemMsec - systemClkTimeBias \n
+ */
+
+ float gloClkTimeUncMs;
+ /**< Single sided maximum time bias uncertainty \n
+ - Units: msec \n
+ */
+}Gnss_LocGloTimeStructType; /* Type */
+
+typedef struct {
+
+ size_t size;
+ uint32_t refFCount;
+ /**< Receiver frame counter value at reference tick */
+
+ uint8_t systemRtc_valid;
+ /**< Validity indicator for System RTC */
+
+ uint64_t systemRtcMs;
+ /**< Platform system RTC value \n
+ - Units: msec \n
+ */
+
+ uint32_t sourceOfTime;
+ /**< Source of time information */
+
+}Gnss_LocGnssTimeExtStructType;
+
+
+
+typedef enum
+{
+ GNSS_LOC_MEAS_STATUS_NULL = 0x00000000,
+ /**< No information state */
+ GNSS_LOC_MEAS_STATUS_SM_VALID = 0x00000001,
+ /**< Code phase is known */
+ GNSS_LOC_MEAS_STATUS_SB_VALID = 0x00000002,
+ /**< Sub-bit time is known */
+ GNSS_LOC_MEAS_STATUS_MS_VALID = 0x00000004,
+ /**< Satellite time is known */
+ GNSS_LOC_MEAS_STATUS_BE_CONFIRM = 0x00000008,
+ /**< Bit edge is confirmed from signal */
+ GNSS_LOC_MEAS_STATUS_VELOCITY_VALID = 0x00000010,
+ /**< Satellite Doppler measured */
+ GNSS_LOC_MEAS_STATUS_VELOCITY_FINE = 0x00000020,
+ /**< TRUE: Fine Doppler measured, FALSE: Coarse Doppler measured */
+ GNSS_LOC_MEAS_STATUS_FROM_RNG_DIFF = 0x00000200,
+ /**< Range update from Satellite differences */
+ GNSS_LOC_MEAS_STATUS_FROM_VE_DIFF = 0x00000400,
+ /**< Doppler update from Satellite differences */
+ GNSS_LOC_MEAS_STATUS_DONT_USE_X = 0x00000800,
+ /**< Don't use measurement if bit is set */
+ GNSS_LOC_MEAS_STATUS_DONT_USE_M = 0x000001000,
+ /**< Don't use measurement if bit is set */
+ GNSS_LOC_MEAS_STATUS_DONT_USE_D = 0x000002000,
+ /**< Don't use measurement if bit is set */
+ GNSS_LOC_MEAS_STATUS_DONT_USE_S = 0x000004000,
+ /**< Don't use measurement if bit is set */
+ GNSS_LOC_MEAS_STATUS_DONT_USE_P = 0x000008000
+ /**< Don't use measurement if bit is set */
+}Gnss_LocSvMeasStatusMaskType;
+
+typedef struct
+{
+ size_t size;
+ uint32_t svMs;
+ /**< Satellite time milisecond.\n
+ For GPS, BDS, GAL range of 0 thru (604800000-1) \n
+ For GLONASS range of 0 thru (86400000-1) \n
+ Valid when PD_LOC_MEAS_STATUS_MS_VALID bit is set in measurement status \n
+ Note: All SV times in the current measurement block are alredy propagated to common reference time epoch. \n
+ - Units: msec \n
+ */
+ float svSubMs;
+ /**<Satellite time sub-millisecond. \n
+ Total SV Time = svMs + svSubMs \n
+ - Units: msec \n
+ */
+ float svTimeUncMs;
+ /**< Satellite Time uncertainty \n
+ - Units: msec \n
+ */
+ float dopplerShift;
+ /**< Satellite Doppler \n
+ - Units: meter per sec \n
+ */
+ float dopplerShiftUnc;
+ /**< Satellite Doppler uncertainty\n
+ - Units: meter per sec \n
+ */
+}Gnss_LocSVTimeSpeedStructType;
+
+typedef enum
+{
+ GNSS_SV_STATE_IDLE = 0,
+ GNSS_SV_STATE_SEARCH = 1,
+ GNSS_SV_STATE_SEARCH_VERIFY = 2,
+ GNSS_SV_STATE_BIT_EDGE = 3,
+ GNSS_SV_STATE_VERIFY_TRACK = 4,
+ GNSS_SV_STATE_TRACK = 5,
+ GNSS_SV_STATE_RESTART = 6,
+ GNSS_SV_STATE_DPO_TRACK = 7
+} Gnss_LocSVStateEnumType;
+
+typedef enum
+{
+ GNSS_LOC_SVINFO_MASK_HAS_EPHEMERIS = 0x01,
+ /**< Ephemeris is available for this SV */
+ GNSS_LOC_SVINFO_MASK_HAS_ALMANAC = 0x02
+ /**< Almanac is available for this SV */
+}Gnss_LocSvInfoMaskT;
+
+typedef enum
+{
+ GNSS_LOC_SV_SRCH_STATUS_IDLE = 1,
+ /**< SV is not being actively processed */
+ GNSS_LOC_SV_SRCH_STATUS_SEARCH = 2,
+ /**< The system is searching for this SV */
+ GNSS_LOC_SV_SRCH_STATUS_TRACK = 3
+ /**< SV is being tracked */
+}Gnss_LocSvSearchStatusEnumT;
+
+
+typedef struct
+{
+ size_t size;
+ uint16_t gnssSvId;
+ /**< GNSS SV ID.
+ \begin{itemize1}
+ \item Range: \begin{itemize1}
+ \item For GPS: 1 to 32
+ \item For GLONASS: 1 to 32
+ \item For SBAS: 120 to 151
+ \item For BDS: 201 to 237
+ \end{itemize1} \end{itemize1}
+ The GPS and GLONASS SVs can be disambiguated using the system field.
+ */
+ uint8_t gloFrequency;
+ /**< GLONASS frequency number + 7 \n
+ Valid only for GLONASS System \n
+ Shall be ignored for all other systems \n
+ - Range: 1 to 14 \n
+ */
+ Gnss_LocSvSearchStatusEnumT svStatus;
+ /**< Satellite search state \n
+ @ENUM()
+ */
+ bool healthStatus_valid;
+ /**< SV Health Status validity flag\n
+ - 0: Not valid \n
+ - 1: Valid \n
+ */
+ uint8_t healthStatus;
+ /**< Health status.
+ \begin{itemize1}
+ \item Range: 0 to 1; 0 = unhealthy, \n 1 = healthy, 2 = unknown
+ \vspace{-0.18in} \end{itemize1}
+ */
+ Gnss_LocSvInfoMaskT svInfoMask;
+ /**< Indicates whether almanac and ephemeris information is available. \n
+ @MASK()
+ */
+ uint64_t measurementStatus;
+ /**< Bitmask indicating SV measurement status.
+ Valid bitmasks: \n
+ @MASK()
+ */
+ uint16_t CNo;
+ /**< Carrier to Noise ratio \n
+ - Units: 0.1 dBHz \n
+ */
+ uint16_t gloRfLoss;
+ /**< GLONASS Rf loss reference to Antenna. \n
+ - Units: dB, Scale: 0.1 \n
+ */
+ bool lossOfLock;
+ /**< Loss of signal lock indicator \n
+ - 0: Signal in continuous track \n
+ - 1: Signal not in track \n
+ */
+ int16_t measLatency;
+ /**< Age of the measurement. Positive value means measurement precedes ref time. \n
+ - Units: msec \n
+ */
+ Gnss_LocSVTimeSpeedStructType svTimeSpeed;
+ /**< Unfiltered SV Time and Speed information
+ */
+ float dopplerAccel;
+ /**< Satellite Doppler Accelertion\n
+ - Units: Hz/s \n
+ */
+ bool multipathEstValid;
+ /**< Multipath estimate validity flag\n
+ - 0: Multipath estimate not valid \n
+ - 1: Multipath estimate valid \n
+ */
+ float multipathEstimate;
+ /**< Estimate of multipath in measurement\n
+ - Units: Meters \n
+ */
+ bool fineSpeedValid;
+ /**< Fine speed validity flag\n
+ - 0: Fine speed not valid \n
+ - 1: Fine speed valid \n
+ */
+ float fineSpeed;
+ /**< Carrier phase derived speed \n
+ - Units: m/s \n
+ */
+ bool fineSpeedUncValid;
+ /**< Fine speed uncertainty validity flag\n
+ - 0: Fine speed uncertainty not valid \n
+ - 1: Fine speed uncertainty valid \n
+ */
+ float fineSpeedUnc;
+ /**< Carrier phase derived speed \n
+ - Units: m/s \n
+ */
+ bool carrierPhaseValid;
+ /**< Carrier Phase measurement validity flag\n
+ - 0: Carrier Phase not valid \n
+ - 1: Carrier Phase valid \n
+ */
+ double carrierPhase;
+ /**< Carrier phase measurement [L1 cycles] \n
+ */
+ bool cycleSlipCountValid;
+ /**< Cycle slup count validity flag\n
+ - 0: Not valid \n
+ - 1: Valid \n
+ */
+ uint8_t cycleSlipCount;
+ /**< Increments when a CSlip is detected */
+
+ bool svDirectionValid;
+ /**< Validity flag for SV direction */
+
+ float svAzimuth;
+ /**< Satellite Azimuth
+ - Units: radians \n
+ */
+ float svElevation;
+ /**< Satellite Elevation
+ - Units: radians \n
+ */
+} Gnss_SVMeasurementStructType;
+
+/**< Maximum number of satellites in measurement block for given system. */
+
+typedef struct
+{
+ size_t size;
+ Gnss_LocSvSystemEnumType system;
+ /**< Specifies the Satellite System Type
+ */
+ bool isSystemTimeValid;
+ /**< Indicates whether System Time is Valid:\n
+ - 0x01 (TRUE) -- System Time is valid \n
+ - 0x00 (FALSE) -- System Time is not valid
+ */
+ Gnss_LocSystemTimeStructType systemTime;
+ /**< System Time Information \n
+ */
+ bool isGloTime_valid;
+ Gnss_LocGloTimeStructType gloTime;
+
+ bool isSystemTimeExt_valid;
+ Gnss_LocGnssTimeExtStructType systemTimeExt;
+
+ uint8_t numSvs;
+ /* Number of SVs in this report block */
+
+ Gnss_SVMeasurementStructType svMeasurement[GNSS_LOC_SV_MEAS_LIST_MAX_SIZE];
+ /**< Satellite measurement Information \n
+ */
+} Gnss_ClockMeasurementStructType;
+
+typedef struct
+{
+ size_t size;
+ uint8_t seqNum;
+ /**< Current message Number */
+ uint8_t maxMessageNum;
+ /**< Maximum number of message that will be sent for present time epoch. */
+
+ bool leapSecValid;
+ Gnss_LeapSecondInfoStructType leapSec;
+
+ Gnss_InterSystemBiasStructType gpsGloInterSystemBias;
+
+ Gnss_InterSystemBiasStructType gpsBdsInterSystemBias;
+
+ Gnss_InterSystemBiasStructType gpsGalInterSystemBias;
+
+ Gnss_InterSystemBiasStructType bdsGloInterSystemBias;
+
+ Gnss_InterSystemBiasStructType galGloInterSystemBias;
+
+ Gnss_InterSystemBiasStructType galBdsInterSystemBias;
+
+ bool clockFreqValid;
+ Gnss_LocRcvrClockFrequencyInfoStructType clockFreq; /* Freq */
+ bool gnssMeasValid;
+ Gnss_ClockMeasurementStructType gnssMeas;
+} GnssSvMeasurementSet;
+
+typedef enum
+{
+ GNSS_SV_POLY_COEFF_VALID = 0x01,
+ /**< SV position in orbit coefficients are valid */
+ GNSS_SV_POLY_IONO_VALID = 0x02,
+ /**< Iono estimates are valid */
+
+ GNSS_SV_POLY_TROPO_VALID = 0x04,
+ /**< Tropo estimates are valid */
+
+ GNSS_SV_POLY_ELEV_VALID = 0x08,
+ /**< Elevation, rate, uncertainty are valid */
+
+ GNSS_SV_POLY_SRC_ALM_CORR = 0x10,
+ /**< Polynomials based on XTRA */
+
+ GNSS_SV_POLY_SBAS_IONO_VALID = 0x20,
+ /**< SBAS IONO and rate are valid */
+
+ GNSS_SV_POLY_GLO_STR4 = 0x40
+ /**< GLONASS String 4 has been received */
+}Gnss_SvPolyStatusMaskType;
+
+
+typedef struct
+{
+ size_t size;
+ uint8_t gnssSvId;
+ /* GPS: 1-32, GLO: 65-96, 0: Invalid
+ All others are reserved
+ */
+ int8_t freqNum;
+ /* Freq index, only valid if u_SysInd is GLO */
+
+ uint8_t svPolyFlags;
+ /* Indicate the validity of the elements
+ as per Gnss_SvPolyStatusMaskType
+ */
+
+ uint16_t is_valid;
+
+ uint8_t iode;
+ /* Ephemeris reference time
+ GPS:Issue of Data Ephemeris used [unitless].
+ GLO: Tb 7-bit, refer to ICD02
+ */
+ double T0;
+ /* Reference time for polynominal calculations
+ GPS: Secs in week.
+ GLO: Full secs since Jan/01/96
+ */
+ double polyCoeffXYZ0[GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE];
+ /* C0X, C0Y, C0Z */
+ double polyCoefXYZN[GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE];
+ /* C1X, C2X ... C2Z, C3Z */
+ float polyCoefOther[GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE];
+ /* C0T, C1T, C2T, C3T */
+ float svPosUnc; /* SV position uncertainty [m]. */
+ float ionoDelay; /* Ionospheric delay at d_T0 [m]. */
+ float ionoDot; /* Iono delay rate [m/s]. */
+ float sbasIonoDelay;/* SBAS Ionospheric delay at d_T0 [m]. */
+ float sbasIonoDot; /* SBAS Iono delay rate [m/s]. */
+ float tropoDelay; /* Tropospheric delay [m]. */
+ float elevation; /* Elevation [rad] at d_T0 */
+ float elevationDot; /* Elevation rate [rad/s] */
+ float elevationUnc; /* SV elevation [rad] uncertainty */
+ double velCoef[GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE];
+ /* Coefficients of velocity poly */
+} GnssSvPolynomial;
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GPS_EXTENDED_C_H */
diff --git a/gps/libloc_api_50001/loc_eng_log.cpp b/gps/core/loc_core_log.cpp
index 6e1b4db..d2eda66 100644
--- a/gps/libloc_api_50001/loc_eng_log.cpp
+++ b/gps/core/loc_core_log.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011,2012 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -28,12 +28,25 @@
*/
#define LOG_NDDEBUG 0
-#define LOG_TAG "LocSvc_eng"
+#define LOG_TAG "LocSvc_core_log"
-#include "hardware/gps.h"
-#include "loc_log.h"
-#include "loc_eng_log.h"
-#include "loc_eng_msg_id.h"
+#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[] =
@@ -55,68 +68,6 @@ const char* loc_get_gps_status_name(GpsStatusValue gps_status)
-static loc_name_val_s_type loc_eng_msgs[] =
-{
- NAME_VAL( LOC_ENG_MSG_QUIT ),
- NAME_VAL( LOC_ENG_MSG_ENGINE_DOWN ),
- NAME_VAL( LOC_ENG_MSG_ENGINE_UP ),
- NAME_VAL( LOC_ENG_MSG_START_FIX ),
- NAME_VAL( LOC_ENG_MSG_STOP_FIX ),
- NAME_VAL( LOC_ENG_MSG_SET_POSITION_MODE ),
- NAME_VAL( LOC_ENG_MSG_SET_TIME ),
- NAME_VAL( LOC_ENG_MSG_INJECT_XTRA_DATA ),
- NAME_VAL( LOC_ENG_MSG_INJECT_LOCATION ),
- NAME_VAL( LOC_ENG_MSG_DELETE_AIDING_DATA ),
- NAME_VAL( LOC_ENG_MSG_SET_APN ),
- NAME_VAL( LOC_ENG_MSG_SET_SERVER_URL ),
- NAME_VAL( LOC_ENG_MSG_SET_SERVER_IPV4 ),
- NAME_VAL( LOC_ENG_MSG_ENABLE_DATA ),
- NAME_VAL( LOC_ENG_MSG_SUPL_VERSION ),
- NAME_VAL( LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG ),
- NAME_VAL( LOC_ENG_MSG_SET_SENSOR_PROPERTIES ),
- NAME_VAL( LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG ),
- NAME_VAL( LOC_ENG_MSG_MUTE_SESSION ),
- NAME_VAL( LOC_ENG_MSG_ATL_OPEN_SUCCESS ),
- NAME_VAL( LOC_ENG_MSG_ATL_CLOSED ),
- NAME_VAL( LOC_ENG_MSG_ATL_OPEN_FAILED ),
- NAME_VAL( LOC_ENG_MSG_REPORT_POSITION ),
- NAME_VAL( LOC_ENG_MSG_REPORT_SV ),
- NAME_VAL( LOC_ENG_MSG_REPORT_STATUS ),
- NAME_VAL( LOC_ENG_MSG_REPORT_NMEA ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_ATL ),
- NAME_VAL( LOC_ENG_MSG_RELEASE_ATL ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_BIT ),
- NAME_VAL( LOC_ENG_MSG_RELEASE_BIT ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_WIFI ),
- NAME_VAL( LOC_ENG_MSG_RELEASE_WIFI ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_NI ),
- NAME_VAL( LOC_ENG_MSG_INFORM_NI_RESPONSE ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_XTRA_DATA ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_TIME ),
- NAME_VAL( LOC_ENG_MSG_EXT_POWER_CONFIG ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_POSITION ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_PHONE_CONTEXT ),
- NAME_VAL( LOC_ENG_MSG_REQUEST_NETWORK_POSIITON ),
- NAME_VAL( ULP_MSG_UPDATE_CRITERIA ),
- NAME_VAL( ULP_MSG_START_FIX ),
- NAME_VAL( ULP_MSG_STOP_FIX ),
- NAME_VAL( ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS ),
- NAME_VAL( ULP_MSG_INJECT_NETWORK_POSITION ),
- NAME_VAL( ULP_MSG_REPORT_QUIPC_POSITION ),
- NAME_VAL( ULP_MSG_REQUEST_COARSE_POSITION ),
- NAME_VAL( LOC_ENG_MSG_LPP_CONFIG ),
- NAME_VAL( LOC_ENG_MSG_PRIVACY )
-};
-static int loc_eng_msgs_num = sizeof(loc_eng_msgs) / sizeof(loc_name_val_s_type);
-
-/* Find Android GPS status name */
-const char* loc_get_msg_name(int id)
-{
- return loc_get_name_from_val(loc_eng_msgs, loc_eng_msgs_num, (long) id);
-}
-
-
-
static loc_name_val_s_type loc_eng_position_modes[] =
{
NAME_VAL( LOC_POSITION_MODE_STANDALONE ),
@@ -167,13 +118,20 @@ static loc_name_val_s_type loc_eng_aiding_data_bits[] =
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( GLO_DELETE_EPHEMERIS ),
+ NAME_VAL( GLO_DELETE_ALMANAC ),
+ NAME_VAL( GLO_DELETE_SVDIR ),
+ NAME_VAL( GLO_DELETE_SVSTEER ),
+ NAME_VAL( GLO_DELETE_ALMANAC_CORR ),
NAME_VAL( GPS_DELETE_TIME_GPS ),
- NAME_VAL( GPS_DELETE_TIME_GLO )
+ NAME_VAL( GLO_DELETE_TIME ),
+ NAME_VAL( BDS_DELETE_SVDIR ),
+ NAME_VAL( BDS_DELETE_SVSTEER ),
+ NAME_VAL( BDS_DELETE_TIME ),
+ NAME_VAL( BDS_DELETE_ALMANAC_CORR ),
+ NAME_VAL( BDS_DELETE_EPHEMERIS ),
+ NAME_VAL( BDS_DELETE_ALMANAC ),
+ NAME_VAL( GPS_DELETE_ALL)
};
static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
@@ -203,7 +161,8 @@ 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 )
+ NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ),
+ NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL )
};
static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
@@ -242,12 +201,11 @@ 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_IPV6 ),
NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
};
static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);
diff --git a/gps/libloc_api_50001/loc_eng_log.h b/gps/core/loc_core_log.h
index 925e3b4..8a1825a 100644
--- a/gps/libloc_api_50001/loc_eng_log.h
+++ b/gps/core/loc_core_log.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -27,8 +27,8 @@
*
*/
-#ifndef LOC_ENG_LOG_H
-#define LOC_ENG_LOG_H
+#ifndef LOC_CORE_LOG_H
+#define LOC_CORE_LOG_H
#ifdef __cplusplus
extern "C"
@@ -36,11 +36,9 @@ extern "C"
#endif
#include <ctype.h>
-#include <hardware/gps.h>
-#include <loc.h>
+#include <gps_extended.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);
@@ -57,4 +55,4 @@ const char* loc_get_agps_status_name(AGpsStatusValue status);
}
#endif
-#endif /* LOC_ENG_LOG_H */
+#endif /* LOC_CORE_LOG_H */
diff --git a/gps/etc/gps.conf b/gps/etc/gps.conf
new file mode 100644
index 0000000..18a0d5b
--- /dev/null
+++ b/gps/etc/gps.conf
@@ -0,0 +1,86 @@
+#Uncommenting these urls would only enable
+#the power up auto injection and force injection(test case).
+XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra2.bin
+XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra2.bin
+XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra2.bin
+
+#Version check for XTRA
+#DISABLE = 0
+#AUTO = 1
+#XTRA2 = 2
+#XTRA3 = 3
+XTRA_VERSION_CHECK=0
+
+# Error Estimate
+# _SET = 1
+# _CLEAR = 0
+ERR_ESTIMATE=0
+
+#Test
+NTP_SERVER=time.gpsonextra.net
+#Asia
+# NTP_SERVER=asia.pool.ntp.org
+#Europe
+# NTP_SERVER=europe.pool.ntp.org
+#North America
+# NTP_SERVER=north-america.pool.ntp.org
+
+# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
+# 4 - Debug, 5 - Verbose
+# If DEBUG_LEVEL is commented, Android's logging levels will be used
+DEBUG_LEVEL = 2
+
+# Intermediate position report, 1=enable, 0=disable
+INTERMEDIATE_POS=0
+
+# supl version 1.0
+SUPL_VER=0x10000
+
+# GPS Capabilities bit mask
+# SCHEDULING = 0x01
+# MSB = 0x02
+# MSA = 0x04
+# ON_DEMAND_TIME = 0x10
+# GEOFENCE = 0x20
+# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE
+CAPABILITIES=0x37
+
+# Accuracy threshold for intermediate positions
+# less accurate positions are ignored, 0 for passing all positions
+# ACCURACY_THRES=5000
+
+################################
+##### AGPS server settings #####
+################################
+
+# FOR SUPL SUPPORT, set the following
+# SUPL_HOST=supl.host.com or IP
+# SUPL_PORT=1234
+
+# FOR C2K PDE SUPPORT, set the following
+# C2K_HOST=c2k.pde.com or IP
+# C2K_PORT=1234
+
+####################################
+# LTE Positioning Profile Settings
+####################################
+# 0: Enable RRLP on LTE(Default)
+# 1: Enable LPP_User_Plane on LTE
+# 2: Enable LPP_Control_Plane
+# 3: Enable both LPP_User_Plane and LPP_Control_Plane
+# Sensor R&D : This will not be injected to MODEM
+LPP_PROFILE=3
+
+################################
+# EXTRA SETTINGS
+################################
+# NMEA provider (1=Modem Processor, 0=Application Processor)
+NMEA_PROVIDER=1
+
+##################################################
+# Select Positioning Protocol on A-GLONASS system
+##################################################
+# 0x1: RRC CPlane
+# 0x2: RRLP UPlane
+# 0x4: LLP Uplane
+A_GLONASS_POS_PROTOCOL_SELECT = 0x0
diff --git a/gps/etc/sap.conf b/gps/etc/sap.conf
new file mode 100644
index 0000000..6ef6a09
--- /dev/null
+++ b/gps/etc/sap.conf
@@ -0,0 +1,42 @@
+################################
+# Sensor Settings
+################################
+
+# Needs to be set explicitly based on sensor
+# There is no default value.
+# used in loc_eng_reinit
+#GYRO_BIAS_RANDOM_WALK=
+#ACCEL_RANDOM_WALK_SPECTRAL_DENSITY=
+#ANGLE_RANDOM_WALK_SPECTRAL_DENSITY=
+#RATE_RANDOM_WALK_SPECTRAL_DENSITY=
+#VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY=
+
+# Sensor Sampling Rate Parameters for Low-Data Rate Filter (should be greater than 0)
+# used in loc_eng_reinit
+SENSOR_ACCEL_BATCHES_PER_SEC=3
+SENSOR_ACCEL_SAMPLES_PER_BATCH=5
+SENSOR_GYRO_BATCHES_PER_SEC=3
+SENSOR_GYRO_SAMPLES_PER_BATCH=5
+# Sensor Sampling Rate Parameters for High-Data Rate Filter (should be greater than 0)
+SENSOR_ACCEL_BATCHES_PER_SEC_HIGH=4
+SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH=25
+SENSOR_GYRO_BATCHES_PER_SEC_HIGH=4
+SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH=25
+
+# Sensor Control Mode (0=AUTO, 1=FORCE_ON)
+# used in loc_eng_reinit
+SENSOR_CONTROL_MODE=0
+
+# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable)
+# used in loc_eng_reinit
+SENSOR_USAGE=0
+
+# Choose GSIFF sensor provider (1=Snapdragon Sensors Core, 2=Android NDK)
+SENSOR_PROVIDER=2
+
+# Bit mask used to define which sensor algorithms are used.
+# Setting each bit has the following definition:
+# 0x1 - DISABLE_INS_POSITIONING_FILTER
+# 0x0 - ENABLE_INS_POSITIONING_FILTER
+SENSOR_ALGORITHM_CONFIG_MASK=0x1
+
diff --git a/gps/gps-cdma.conf b/gps/gps-cdma.conf
deleted file mode 100644
index 90be633..0000000
--- a/gps/gps-cdma.conf
+++ /dev/null
@@ -1,104 +0,0 @@
-#Test
-NTP_SERVER=time.gpsonextra.net
-#Asia
-# NTP_SERVER=asia.pool.ntp.org
-#Europe
-# NTP_SERVER=europe.pool.ntp.org
-#North America
-# NTP_SERVER=north-america.pool.ntp.org
-
-XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra2.bin
-XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra2.bin
-XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin
-
-# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
-# 4 - Debug, 5 - Verbose
-DEBUG_LEVEL = 4
-
-# Intermediate position report, 1=enable, 0=disable
-INTERMEDIATE_POS=0
-
-# supl version 1.0
-SUPL_VER=0x10000
-
-# Error Estimate
-# _SET = 1
-# _CLEAR = 0
-ERR_ESTIMATE=0
-
-# GPS Capabilities bit mask
-# SCHEDULING = 1
-# MSB = 2
-# MSA = 4
-# ULP = 0x20
-# ON_DEMAND_TIME = 0x10 // yunu.lee
-# default = MSA | MSB | SCHEDULING | ULP
-CAPABILITIES=0x14
-
-# Accuracy threshold for intermediate positions
-# less accurate positions are ignored, 0 for passing all positions
-# ACCURACY_THRES=5000
-
-################################
-##### AGPS server settings #####
-################################
-
-# FOR SUPL SUPPORT, set the following
-# SUPL_HOST=supl.host.com or IP
-# SUPL_PORT=1234
-
-# FOR C2K PDE SUPPORT, set the following
-# C2K_HOST=c2k.pde.com or IP
-# C2K_PORT=1234
-
-################################
-# Sensor Settings
-################################
-
-# Needs to be set explicitly based on sensor
-# There is no default value.
-GYRO_BIAS_RANDOM_WALK=0.00001
-
-# Sensor Sampling Rate Parameters for Low-Data Rate Filter (should be greater than 0)
-SENSOR_ACCEL_BATCHES_PER_SEC=3
-SENSOR_ACCEL_SAMPLES_PER_BATCH=5
-SENSOR_GYRO_BATCHES_PER_SEC=3
-SENSOR_GYRO_SAMPLES_PER_BATCH=5
-# Sensor Sampling Rate Parameters for High-Data Rate Filter (should be greater than 0)
-SENSOR_ACCEL_BATCHES_PER_SEC_HIGH=4
-SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH=25
-SENSOR_GYRO_BATCHES_PER_SEC_HIGH=4
-SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH=25
-
-# INS Filter Mode (0=Enable, 1=Disable)
-SENSOR_ALGORITHM_CONFIG_MASK=1
-
-# Sensor Control Mode (0=AUTO, 1=FORCE_ON)
-SENSOR_CONTROL_MODE=0
-
-# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable)
-SENSOR_USAGE=0
-
-# Choose GSIFF sensor provider (1=DSPS, 2=Android NDK)
-SENSOR_PROVIDER=2
-
-################################
-# Indoor Positioning Settings
-################################
-# 0: QUIPC disabled, 1: QUIPC enabled, 2: forced QUIPC only
-QUIPC_ENABLED = 0
-
-################################
-# EXTRA SETTINGS
-################################
-# Enable or Disable Wiper (1=Enable, 0=Disable)
-ENABLE_WIPER=0
-# NMEA provider (1=Modem Processor, 0=Application Processor)
-NMEA_PROVIDER=1
-
-####################################
-# LTE Positioning Profile Settings
-####################################
-# 0: Enable RRLP on LTE(Default) 1: Enable LPP_User_Plane on LTE
-LPP_PROFILE = 0
-
diff --git a/gps/gps.conf b/gps/gps.conf
deleted file mode 100644
index a7b44bd..0000000
--- a/gps/gps.conf
+++ /dev/null
@@ -1,104 +0,0 @@
-#Test
-NTP_SERVER=time.gpsonextra.net
-#Asia
-# NTP_SERVER=asia.pool.ntp.org
-#Europe
-# NTP_SERVER=europe.pool.ntp.org
-#North America
-# NTP_SERVER=north-america.pool.ntp.org
-
-XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra2.bin
-XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra2.bin
-XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin
-
-# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
-# 4 - Debug, 5 - Verbose
-DEBUG_LEVEL = 4
-
-# Intermediate position report, 1=enable, 0=disable
-INTERMEDIATE_POS=0
-
-# supl version 1.0
-SUPL_VER=0x10000
-
-# Error Estimate
-# _SET = 1
-# _CLEAR = 0
-ERR_ESTIMATE=0
-
-# GPS Capabilities bit mask
-# SCHEDULING = 1
-# MSB = 2
-# MSA = 4
-# ULP = 0x20
-# ON_DEMAND_TIME = 0x10 // yunu.lee
-# default = MSA | MSB | SCHEDULING | ULP
-CAPABILITIES=0x16
-
-# Accuracy threshold for intermediate positions
-# less accurate positions are ignored, 0 for passing all positions
-# ACCURACY_THRES=5000
-
-################################
-##### AGPS server settings #####
-################################
-
-# FOR SUPL SUPPORT, set the following
-# SUPL_HOST=supl.host.com or IP
-# SUPL_PORT=1234
-
-# FOR C2K PDE SUPPORT, set the following
-# C2K_HOST=c2k.pde.com or IP
-# C2K_PORT=1234
-
-################################
-# Sensor Settings
-################################
-
-# Needs to be set explicitly based on sensor
-# There is no default value.
-GYRO_BIAS_RANDOM_WALK=0.00001
-
-# Sensor Sampling Rate Parameters for Low-Data Rate Filter (should be greater than 0)
-SENSOR_ACCEL_BATCHES_PER_SEC=3
-SENSOR_ACCEL_SAMPLES_PER_BATCH=5
-SENSOR_GYRO_BATCHES_PER_SEC=3
-SENSOR_GYRO_SAMPLES_PER_BATCH=5
-# Sensor Sampling Rate Parameters for High-Data Rate Filter (should be greater than 0)
-SENSOR_ACCEL_BATCHES_PER_SEC_HIGH=4
-SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH=25
-SENSOR_GYRO_BATCHES_PER_SEC_HIGH=4
-SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH=25
-
-# INS Filter Mode (0=Enable, 1=Disable)
-SENSOR_ALGORITHM_CONFIG_MASK=1
-
-# Sensor Control Mode (0=AUTO, 1=FORCE_ON)
-SENSOR_CONTROL_MODE=0
-
-# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable)
-SENSOR_USAGE=0
-
-# Choose GSIFF sensor provider (1=DSPS, 2=Android NDK)
-SENSOR_PROVIDER=2
-
-################################
-# Indoor Positioning Settings
-################################
-# 0: QUIPC disabled, 1: QUIPC enabled, 2: forced QUIPC only
-QUIPC_ENABLED = 0
-
-################################
-# EXTRA SETTINGS
-################################
-# Enable or Disable Wiper (1=Enable, 0=Disable)
-ENABLE_WIPER=0
-# NMEA provider (1=Modem Processor, 0=Application Processor)
-NMEA_PROVIDER=1
-
-####################################
-# LTE Positioning Profile Settings
-####################################
-# 0: Enable RRLP on LTE(Default) 1: Enable LPP_User_Plane on LTE
-LPP_PROFILE = 0
-
diff --git a/gps/libloc_api_50001/.loc_eng_msg_id.h.swp b/gps/libloc_api_50001/.loc_eng_msg_id.h.swp
deleted file mode 100644
index 736dc2f..0000000
--- a/gps/libloc_api_50001/.loc_eng_msg_id.h.swp
+++ /dev/null
Binary files differ
diff --git a/gps/libloc_api_50001/LocApiAdapter.cpp b/gps/libloc_api_50001/LocApiAdapter.cpp
deleted file mode 100755
index cd35646..0000000
--- a/gps/libloc_api_50001/LocApiAdapter.cpp
+++ /dev/null
@@ -1,242 +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) {
- LOC_LOGI("%s: dlopen(libloc_api_v02.so) failed, trying to load libloc_api-rpc-qc.so", __FUNCTION__);
- handle = dlopen ("libloc_api-rpc-qc.so", RTLD_NOW);
- }
- else
- LOC_LOGE("%s: dlopen(libloc_api_v02.so) succeeded.", __FUNCTION__);
-
- if (!handle) {
- LOC_LOGI("%s: dlopen(libloc_api-rpc-qc.so) failed, constructing LocApiAdapter", __FUNCTION__);
- adapter = new LocApiAdapter(locEng);
- } else {
- getLocApiAdapter_t* getHandle = (getLocApiAdapter_t*)dlsym(handle, "_Z16getLocApiAdapterR6LocEng");
- if (!getHandle) {
- LOC_LOGE("%s: dlsym(getLocApiAdapter) failed", __FUNCTION__);
- return NULL;
- }
- 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(GpsLocation &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::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::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 &notif, 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);
-}
diff --git a/gps/libloc_api_50001/LocApiAdapter.h b/gps/libloc_api_50001/LocApiAdapter.h
deleted file mode 100755
index 48ed7d1..0000000
--- a/gps/libloc_api_50001/LocApiAdapter.h
+++ /dev/null
@@ -1,246 +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.
- *
- */
-#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>
-
-#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(GpsLocation &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 reportAgpsStatus(AGpsStatus &agpsStatus);
- void requestXtraData();
- void requestTime();
- void requestLocation();
- void requestATL(int connHandle, AGpsType agps_type);
- void releaseATL(int connHandle);
- void requestNiNotify(GpsNiNotification &notify, const void* data);
- void handleEngineDownEvent();
- void handleEngineUpEvent();
-
- // 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
- 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 const LocPosMode& getPositionMode() const {return fixCriteria;}
-
- inline bool isInSession() { return navigating; }
- inline virtual void setInSession(bool inSession) { navigating = inSession; }
-
-private:
- // Pad out virtual method table so that the setPrivacy entry corresponds to
- // the same as LocApiV02Adapter.
- inline virtual void unknownVirtualMethod24() {}
- inline virtual void unknownVirtualMethod25() {}
- inline virtual void unknownVirtualMethod26() {}
- inline virtual void unknownVirtualMethod27() {}
- inline virtual void unknownVirtualMethod28() {}
- inline virtual void unknownVirtualMethod29() {}
- inline virtual void unknownVirtualMethod30() {}
-
-public:
- inline virtual enum loc_api_adapter_err
- setPrivacy(int8_t privacy_setting)
- {LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
-};
-
-extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng);
-
-typedef LocApiAdapter* (getLocApiAdapter_t)(LocEng&);
-
-#endif //LOC_API_RPC_ADAPTER_H
diff --git a/gps/libloc_api_50001/loc_eng.cpp b/gps/libloc_api_50001/loc_eng.cpp
deleted file mode 100755
index e092f0a..0000000
--- a/gps/libloc_api_50001/loc_eng.cpp
+++ /dev/null
@@ -1,2214 +0,0 @@
-/* Copyright (c) 2009-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_eng"
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <math.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <netinet/in.h> /* struct sockaddr_in */
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netdb.h>
-#include <time.h>
-
-#include "LocApiAdapter.h"
-
-#include <cutils/sched_policy.h>
-#include <utils/SystemClock.h>
-#include <utils/Log.h>
-#include <string.h>
-
-#include <loc_eng.h>
-#include <loc_eng_ni.h>
-#include <loc_eng_dmn_conn.h>
-#include <loc_eng_dmn_conn_handler.h>
-#include <loc_eng_msg.h>
-#include <loc_eng_msg_id.h>
-#include <loc_eng_nmea.h>
-#include <msg_q.h>
-#include <loc.h>
-
-#include "log_util.h"
-#include "loc_eng_log.h"
-
-#define SUCCESS TRUE
-#define FAILURE FALSE
-
-static void loc_eng_deferred_action_thread(void* context);
-static void* loc_eng_create_msg_q();
-static void loc_eng_free_msg(void* msg);
-
-pthread_mutex_t LocEngContext::lock = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t LocEngContext::cond = PTHREAD_COND_INITIALIZER;
-LocEngContext* LocEngContext::me = NULL;
-boolean gpsConfigAlreadyRead = false;
-
-loc_gps_cfg_s_type gps_conf;
-
-/* Parameter spec table */
-static loc_param_s_type loc_parameter_table[] =
-{
- {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'},
- {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'},
- {"ENABLE_WIPER", &gps_conf.ENABLE_WIPER, NULL, 'n'},
- {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'},
- {"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'},
- {"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'},
- {"GYRO_BIAS_RANDOM_WALK", &gps_conf.GYRO_BIAS_RANDOM_WALK, &gps_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
- {"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &gps_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &gps_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
- {"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &gps_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &gps_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
- {"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &gps_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &gps_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
- {"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &gps_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &gps_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
- {"SENSOR_ACCEL_BATCHES_PER_SEC", &gps_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'},
- {"SENSOR_ACCEL_SAMPLES_PER_BATCH", &gps_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'},
- {"SENSOR_GYRO_BATCHES_PER_SEC", &gps_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'},
- {"SENSOR_GYRO_SAMPLES_PER_BATCH", &gps_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'},
- {"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &gps_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'},
- {"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &gps_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
- {"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &gps_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'},
- {"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &gps_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
- {"SENSOR_CONTROL_MODE", &gps_conf.SENSOR_CONTROL_MODE, NULL, 'n'},
- {"SENSOR_USAGE", &gps_conf.SENSOR_USAGE, NULL, 'n'},
- {"SENSOR_ALGORITHM_CONFIG_MASK", &gps_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'},
- {"QUIPC_ENABLED", &gps_conf.QUIPC_ENABLED, NULL, 'n'},
- {"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'},
-};
-
-static void loc_default_parameters(void)
-{
- /* defaults */
- gps_conf.INTERMEDIATE_POS = 0;
- gps_conf.ACCURACY_THRES = 0;
- gps_conf.ENABLE_WIPER = 0;
- gps_conf.NMEA_PROVIDER = 0;
- gps_conf.SUPL_VER = 0x10000;
- gps_conf.CAPABILITIES = 0x7;
-
- gps_conf.GYRO_BIAS_RANDOM_WALK = 0;
- gps_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2;
- gps_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5;
- gps_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2;
- gps_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5;
- gps_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4;
- gps_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25;
- gps_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4;
- gps_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25;
- gps_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */
- gps_conf.SENSOR_USAGE = 0; /* Enabled */
- gps_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/
-
- /* Values MUST be set by OEMs in configuration for sensor-assisted
- navigation to work. There are NO default values */
- gps_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0;
- gps_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
- gps_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
- gps_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0;
-
- gps_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0;
- gps_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
- gps_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
- gps_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
- gps_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
-
- /* LTE Positioning Profile configuration is disable by default*/
- gps_conf.LPP_PROFILE = 0;
-}
-
-LocEngContext::LocEngContext(gps_create_thread threadCreator) :
- deferred_q((const void*)loc_eng_create_msg_q()),
- //TODO: should we conditionally create ulp msg q?
- ulp_q((const void*)loc_eng_create_msg_q()),
- deferred_action_thread(threadCreator("loc_eng",loc_eng_deferred_action_thread, this)),
- counter(0)
-{
- LOC_LOGV("LocEngContext %d : %d pthread_id %ld\n",
- getpid(), gettid(),
- deferred_action_thread);
-}
-
-LocEngContext* LocEngContext::get(gps_create_thread threadCreator)
-{
- pthread_mutex_lock(&lock);
- // gonna need mutex protection here...
- if (NULL == me) {
- me = new LocEngContext(threadCreator);
- }
- me->counter++;
-
- pthread_mutex_unlock(&lock);
- return me;
-}
-
-void LocEngContext::drop()
-{
- if (deferred_action_thread != pthread_self()) {
- pthread_mutex_lock(&lock);
- counter--;
- if (counter == 0) {
- loc_eng_msg *msg(new loc_eng_msg(this, LOC_ENG_MSG_QUIT));
- msg_q_snd((void*)deferred_q, msg, loc_eng_free_msg);
-
- // I am not sure if this is going to be hazardous. The calling thread
- // might be blocked for a while, if the q is loaded. I am wondering
- // if we should just dump all the msgs in the q upon QUIT.
- pthread_cond_wait(&cond, &lock);
-
- msg_q_destroy((void**)&deferred_q);
- msg_q_destroy((void**)&ulp_q);
- delete me;
- me = NULL;
- }
- pthread_mutex_unlock(&lock);
- } else {
- LOC_LOGE("The HAL thread cannot free itself");
- }
-}
-
-// 2nd half of init(), singled out for
-// modem restart to use.
-static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data);
-static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data);
-
-static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data,
- LocServerType type, const char *hostname, int port);
-// Internal functions
-static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data,
- GpsStatusValue status);
-static void loc_eng_report_status(loc_eng_data_s_type &loc_eng_data,
- GpsStatusValue status);
-static void loc_eng_process_conn_request(loc_eng_data_s_type &loc_eng_data,
- int connHandle, AGpsType agps_type);
-static void loc_eng_agps_close_status(loc_eng_data_s_type &loc_eng_data, int is_succ);
-static void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) ;
-static void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) ;
-static int loc_eng_set_privacy(loc_eng_data_s_type &loc_eng_data,
- int8_t privacy_setting);
-
-static char extra_data[100];
-/*********************************************************************
- * Initialization checking macros
- *********************************************************************/
-#define STATE_CHECK(ctx, x, ret) \
- if (!(ctx)) \
- { \
- /* Not intialized, abort */\
- LOC_LOGE("%s: log_eng state error: %s", __func__, x); \
- EXIT_LOG(%s, x); \
- ret; \
- }
-#define INIT_CHECK(ctx, ret) STATE_CHECK(ctx, "instance not initialized", ret)
-
-void loc_eng_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->deferred_q, msg, loc_eng_free_msg);
-}
-
-static void* loc_eng_create_msg_q()
-{
- void* q = NULL;
- if (eMSG_Q_SUCCESS != msg_q_init(&q)) {
- LOC_LOGE("loc_eng_create_msg_q Q init failed.");
- q = NULL;
- }
- return q;
-}
-
-static void loc_eng_free_msg(void* msg)
-{
- delete (loc_eng_msg*)msg;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_init
-
-DESCRIPTION
- Initialize the location engine, this include setting up global datas
- and registers location engien with loc api service.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
- LOC_API_ADAPTER_EVENT_MASK_T event,
- void (*loc_external_msg_sender) (void*, void*))
-
-{
- int ret_val =-1;
-
- ENTRY_LOG_CALLFLOW();
- if (NULL == callbacks || 0 == event) {
- LOC_LOGE("loc_eng_init: bad parameters cb %p eMask %d", callbacks, event);
- EXIT_LOG(%d, ret_val);
- return ret_val;
- }
-
- if (NULL != loc_eng_data.context) {
- // Current loc_eng_cleanup keeps context initialized, so must enable
- // here too.
- loc_eng_set_privacy(loc_eng_data, 1);
- }
-
- STATE_CHECK((NULL == loc_eng_data.context),
- "instance already initialized", return 0);
-
- memset(&loc_eng_data, 0, sizeof (loc_eng_data));
-
- // Create context (msg q + thread) (if not yet created)
- // This will also parse gps.conf, if not done.
- loc_eng_data.context = (void*)LocEngContext::get(callbacks->create_thread_cb);
- if (NULL != callbacks->set_capabilities_cb) {
- callbacks->set_capabilities_cb(gps_conf.CAPABILITIES);
- }
-
- // Save callbacks
- loc_eng_data.location_cb = callbacks->location_cb;
- loc_eng_data.sv_status_cb = callbacks->sv_status_cb;
- loc_eng_data.status_cb = callbacks->status_cb;
- loc_eng_data.nmea_cb = callbacks->nmea_cb;
- loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb;
- loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb;
- loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb;
- loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS;
-
- // initial states taken care of by the memset above
- // loc_eng_data.engine_status -- GPS_STATUS_NONE;
- // loc_eng_data.fix_session_status -- GPS_STATUS_NONE;
- // loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE;
-
- if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP))
- {
- event = event ^ LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; // unregister for modem NMEA report
- loc_eng_data.generateNmea = true;
- }
- else
- {
- loc_eng_data.generateNmea = false;
- }
-
- LocEng locEngHandle(&loc_eng_data, event, loc_eng_data.acquire_wakelock_cb,
- loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, loc_external_msg_sender,
- callbacks->location_ext_parser, callbacks->sv_ext_parser);
- loc_eng_data.client_handle = LocApiAdapter::getLocApiAdapter(locEngHandle);
-
- if (NULL == loc_eng_data.client_handle) {
- // drop the context and declare failure
- ((LocEngContext*)(loc_eng_data.context))->drop();
- loc_eng_data.context = NULL;
- } else {
- LOC_LOGD("loc_eng_init created client, id = %p\n", loc_eng_data.client_handle);
-
- // call reinit to send initialization messages
- int tries = 30;
- while (tries > 0 &&
- LOC_API_ADAPTER_ERR_SUCCESS != (ret_val = loc_eng_reinit(loc_eng_data))) {
- tries--;
- LOC_LOGD("loc_eng_init client open failed, %d more tries", tries);
- sleep(1);
- }
-
- if (LOC_API_ADAPTER_ERR_SUCCESS == ret_val) {
- loc_eng_set_privacy(loc_eng_data, 1);
- }
- }
-
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG();
- int ret_val = loc_eng_data.client_handle->reinit();
-
- if (LOC_API_ADAPTER_ERR_SUCCESS == ret_val) {
- LOC_LOGD("loc_eng_reinit reinit() successful");
-
- loc_eng_msg_suple_version *supl_msg(new loc_eng_msg_suple_version(&loc_eng_data,
- gps_conf.SUPL_VER));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- supl_msg, loc_eng_free_msg);
-
- loc_eng_msg_lpp_config *lpp_msg(new loc_eng_msg_lpp_config(&loc_eng_data,
- gps_conf.LPP_PROFILE));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- lpp_msg, loc_eng_free_msg);
-
- loc_eng_msg_sensor_control_config *sensor_control_config_msg(
- new loc_eng_msg_sensor_control_config(&loc_eng_data, gps_conf.SENSOR_USAGE));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- sensor_control_config_msg, loc_eng_free_msg);
-
- /* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */
- if( gps_conf.GYRO_BIAS_RANDOM_WALK_VALID ||
- gps_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
- gps_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
- gps_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
- gps_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID )
- {
- loc_eng_msg_sensor_properties *sensor_properties_msg(
- new loc_eng_msg_sensor_properties(&loc_eng_data,
- gps_conf.GYRO_BIAS_RANDOM_WALK_VALID,
- gps_conf.GYRO_BIAS_RANDOM_WALK,
- gps_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- gps_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,
- gps_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- gps_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,
- gps_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- gps_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,
- gps_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
- gps_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- sensor_properties_msg, loc_eng_free_msg);
- }
-
- loc_eng_msg_sensor_perf_control_config *sensor_perf_control_conf_msg(
- new loc_eng_msg_sensor_perf_control_config(&loc_eng_data,
- gps_conf.SENSOR_CONTROL_MODE,
- gps_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH,
- gps_conf.SENSOR_ACCEL_BATCHES_PER_SEC,
- gps_conf.SENSOR_GYRO_SAMPLES_PER_BATCH,
- gps_conf.SENSOR_GYRO_BATCHES_PER_SEC,
- gps_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH,
- gps_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,
- gps_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,
- gps_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,
- gps_conf.SENSOR_ALGORITHM_CONFIG_MASK));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- sensor_perf_control_conf_msg, loc_eng_free_msg);
- }
-
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_cleanup
-
-DESCRIPTION
- Cleans location engine. The location client handle will be released.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return);
-
- // XTRA has no state, so we are fine with it.
-
- // we need to check and clear NI
-#if 0
- // we need to check and clear ATL
- if (NULL != loc_eng_data.agnss_nif) {
- delete loc_eng_data.agnss_nif;
- loc_eng_data.agnss_nif = NULL;
- }
- if (NULL != loc_eng_data.internet_nif) {
- delete loc_eng_data.internet_nif;
- loc_eng_data.internet_nif = NULL;
- }
-#endif
- if (loc_eng_data.client_handle->isInSession())
- {
- LOC_LOGD("loc_eng_cleanup: fix not stopped. stop it now.");
- loc_eng_stop(loc_eng_data);
- }
-
- loc_eng_set_privacy(loc_eng_data, 0);
-
-#if 0 // can't afford to actually clean up, for many reason.
-
- ((LocEngContext*)(loc_eng_data.context))->drop();
- loc_eng_data.context = NULL;
-
- // De-initialize ulp
- if (locEngUlpInf != NULL)
- {
- locEngUlpInf = NULL;
- msg_q_destroy( &loc_eng_data.ulp_q);
- }
-
- if (loc_eng_data.client_handle != NULL)
- {
- LOC_LOGD("loc_eng_init: client opened. close it now.");
- delete loc_eng_data.client_handle;
- loc_eng_data.client_handle = NULL;
- }
-
-#ifdef FEATURE_GNSS_BIT_API
- {
- char baseband[PROPERTY_VALUE_MAX];
- property_get("ro.baseband", baseband, "msm");
- if ((strcmp(baseband,"svlte2a") == 0))
- {
- loc_eng_dmn_conn_loc_api_server_unblock();
- loc_eng_dmn_conn_loc_api_server_join();
- }
- }
-#endif /* FEATURE_GNSS_BIT_API */
-
-#endif
-
- EXIT_LOG(%s, VOID_RET);
-}
-
-
-/*===========================================================================
-FUNCTION loc_eng_start
-
-DESCRIPTION
- Starts the tracking session
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_start(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return -1);
-
- if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY))
- {
- //Pass the start messgage to ULP if present & activated
- loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, ULP_MSG_START_FIX));
- msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q,
- msg, loc_eng_free_msg);
- }else
- {
- loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, LOC_ENG_MSG_START_FIX));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
- }
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG();
- int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
-
- if (!loc_eng_data.client_handle->isInSession()) {
- ret_val = loc_eng_data.client_handle->startFix();
-
- if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS ||
- ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN)
- {
- loc_eng_data.client_handle->setInSession(TRUE);
- loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN);
- }
- }
-
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_stop_wrapper
-
-DESCRIPTION
- Stops the tracking session
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_stop(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return -1);
-
- if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY))
- {
- //Pass the start messgage to ULP if present & activated
- loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, ULP_MSG_STOP_FIX));
- msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q,
- msg, loc_eng_free_msg);
- }else
- {
- loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, LOC_ENG_MSG_STOP_FIX));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
- }
-
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG();
- int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
-
- if (loc_eng_data.client_handle->isInSession()) {
-
- ret_val = loc_eng_data.client_handle->stopFix();
- if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS)
- {
- loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_END);
- }
-
- loc_eng_data.client_handle->setInSession(FALSE);
- }
-
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_mute_one_session
-
-DESCRIPTION
- Mutes one session
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: Success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG();
- loc_eng_data.mute_session_state = LOC_MUTE_SESS_WAIT;
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_set_position_mode
-
-DESCRIPTION
- Sets the mode and fix frequency for the tracking session.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,
- LocPosMode &params)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return -1);
- loc_eng_msg_position_mode *msg(
- new loc_eng_msg_position_mode(&loc_eng_data, params));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
-
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_inject_time
-
-DESCRIPTION
- This is used by Java native function to do time injection.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time,
- int64_t timeReference, int uncertainty)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return -1);
- loc_eng_msg_set_time *msg(
- new loc_eng_msg_set_time(&loc_eng_data,
- time,
- timeReference,
- uncertainty));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-
-/*===========================================================================
-FUNCTION loc_eng_inject_location
-
-DESCRIPTION
- This is used by Java native function to do location injection.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0 : Successful
- error code : Failure
-
-SIDE EFFECTS
- N/A
-===========================================================================*/
-int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, double latitude,
- double longitude, float accuracy)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return -1);
- loc_eng_msg_inject_location *msg(
- new loc_eng_msg_inject_location(&loc_eng_data,
- latitude,
- longitude,
- accuracy));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
-
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-
-/*===========================================================================
-FUNCTION loc_eng_delete_aiding_data
-
-DESCRIPTION
- This is used by Java native function to delete the aiding data. The function
- updates the global variable for the aiding data to be deleted. If the GPS
- engine is off, the aiding data will be deleted. Otherwise, the actual action
- will happen when gps engine is turned off.
-
-DEPENDENCIES
- Assumes the aiding data type specified in GpsAidingData matches with
- LOC API specification.
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, GpsAidingData f)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return);
-
- loc_eng_msg_delete_aiding_data *msg(
- new loc_eng_msg_delete_aiding_data(&loc_eng_data,
- f));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
-
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-
-FUNCTION loc_inform_gps_state
-
-DESCRIPTION
- Informs the GPS Provider about the GPS status
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, GpsStatusValue status)
-{
- ENTRY_LOG();
-
- static GpsStatusValue last_status = GPS_STATUS_NONE;
-
- GpsStatus gs = { sizeof(gs),status };
-
-
- if (loc_eng_data.status_cb)
- {
- CALLBACK_LOG_CALLFLOW("status_cb", %s, loc_get_gps_status_name(gs.status));
- loc_eng_data.status_cb(&gs);
- }
-
- last_status = status;
-
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_agps_reinit
-
-DESCRIPTION
- 2nd half of loc_eng_agps_init(), singled out for modem restart to use.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG();
-
- // Set server addresses which came before init
- if (loc_eng_data.supl_host_set)
- {
- loc_eng_set_server(loc_eng_data, LOC_AGPS_SUPL_SERVER,
- loc_eng_data.supl_host_buf,
- loc_eng_data.supl_port_buf);
- }
-
- if (loc_eng_data.c2k_host_set)
- {
- loc_eng_set_server(loc_eng_data, LOC_AGPS_CDMA_PDE_SERVER,
- loc_eng_data.c2k_host_buf,
- loc_eng_data.c2k_port_buf);
- }
- EXIT_LOG(%s, VOID_RET);
-}
-/*===========================================================================
-FUNCTION loc_eng_agps_init
-
-DESCRIPTION
- Initialize the AGps interface.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsCallbacks* callbacks)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return);
- STATE_CHECK((NULL == loc_eng_data.agps_status_cb),
- "agps instance already initialized",
- return);
- if(callbacks == NULL) {
- LOC_LOGE("loc_eng_agps_init: bad parameters cb %p", callbacks);
- EXIT_LOG(%s, VOID_RET);
- return;
- }
- loc_eng_data.agps_status_cb = callbacks->status_cb;
-
- loc_eng_data.agnss_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb,
- AGPS_TYPE_SUPL,
- false);
- loc_eng_data.internet_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb,
- AGPS_TYPE_WWAN_ANY,
- false);
- loc_eng_data.wifi_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb,
- AGPS_TYPE_WIFI,
- true);
-
-#ifdef FEATURE_GNSS_BIT_API
- {
- char baseband[PROPERTY_VALUE_MAX];
- property_get("ro.baseband", baseband, "msm");
- if ((strcmp(baseband,"svlte2a") == 0) ||
- (strcmp(baseband,"sglte") == 0) ||
- (strcmp(baseband,"msm") == 0))
- {
- loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,
- NULL, NULL, &loc_eng_data);
- } else {
- LOC_LOGD("%s:%d] loc_eng_dmn_conn_loc_api_server was not initialized.baseband = %s\n",
- __func__, __LINE__, baseband);
- }
- }
-#endif /* FEATURE_GNSS_BIT_API */
-
- loc_eng_agps_reinit(loc_eng_data);
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_agps_open
-
-DESCRIPTION
- This function is called when on-demand data connection opening is successful.
-It should inform engine about the data open result.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType,
- const char* apn, AGpsBearerType bearerType)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context && loc_eng_data.agps_status_cb,
- return -1);
-
- if (apn == NULL)
- {
- LOC_LOGE("APN Name NULL\n");
- return 0;
- }
-
- LOC_LOGD("loc_eng_agps_open APN name = [%s]", apn);
-
- int apn_len = smaller_of(strlen (apn), MAX_APN_LEN);
- loc_eng_msg_atl_open_success *msg(
- new loc_eng_msg_atl_open_success(&loc_eng_data, agpsType, apn,
- apn_len, bearerType));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
-
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_agps_closed
-
-DESCRIPTION
- This function is called when on-demand data connection closing is done.
-It should inform engine about the data close result.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context && loc_eng_data.agps_status_cb,
- return -1);
-
- loc_eng_msg_atl_closed *msg(new loc_eng_msg_atl_closed(&loc_eng_data, agpsType));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
-
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_agps_open_failed
-
-DESCRIPTION
- This function is called when on-demand data connection opening has failed.
-It should inform engine about the data open result.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context && loc_eng_data.agps_status_cb,
- return -1);
-
- loc_eng_msg_atl_open_failed *msg(new loc_eng_msg_atl_open_failed(&loc_eng_data, agpsType));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
-
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-/*===========================================================================
-
-FUNCTION resolve_in_addr
-
-DESCRIPTION
- Translates a hostname to in_addr struct
-
-DEPENDENCIES
- n/a
-
-RETURN VALUE
- TRUE if successful
-
-SIDE EFFECTS
- n/a
-
-===========================================================================*/
-static boolean resolve_in_addr(const char *host_addr, struct in_addr *in_addr_ptr)
-{
- ENTRY_LOG();
- boolean ret_val = TRUE;
-
- struct hostent *hp;
- hp = gethostbyname(host_addr);
- if (hp != NULL) /* DNS OK */
- {
- memcpy(in_addr_ptr, hp->h_addr_list[0], hp->h_length);
- }
- else
- {
- /* Try IP representation */
- if (inet_aton(host_addr, in_addr_ptr) == 0)
- {
- /* IP not valid */
- LOC_LOGE("DNS query on '%s' failed\n", host_addr);
- ret_val = FALSE;
- }
- }
-
- EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_set_server
-
-DESCRIPTION
- This is used to set the default AGPS server. Server address is obtained
- from gps.conf.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data,
- LocServerType type, const char* hostname, int port)
-{
- ENTRY_LOG();
- int ret = 0;
-
- if (LOC_AGPS_SUPL_SERVER == type) {
- char url[MAX_URL_LEN];
- unsigned int len = snprintf(url, sizeof(url), "%s:%u", hostname, (unsigned) port);
-
- if (sizeof(url) > len) {
- loc_eng_msg_set_server_url *msg(new loc_eng_msg_set_server_url(&loc_eng_data,
- url, len));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
- }
- } else if (LOC_AGPS_CDMA_PDE_SERVER == type ||
- LOC_AGPS_CUSTOM_PDE_SERVER == type ||
- LOC_AGPS_MPC_SERVER == type) {
- struct in_addr addr;
- if (!resolve_in_addr(hostname, &addr))
- {
- LOC_LOGE("loc_eng_set_server, hostname %s cannot be resolved.\n", hostname);
- ret = -2;
- } else {
- unsigned int ip = htonl(addr.s_addr);
- loc_eng_msg_set_server_ipv4 *msg(new loc_eng_msg_set_server_ipv4(&loc_eng_data,
- ip,
- port,
- type));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
- }
- } else {
- LOC_LOGE("loc_eng_set_server, type %d cannot be resolved.\n", type);
- }
-
- EXIT_LOG(%d, ret);
- return ret;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_set_server_proxy
-
-DESCRIPTION
- If loc_eng_set_server is called before loc_eng_init, it doesn't work. This
- proxy buffers server settings and calls loc_eng_set_server when the client is
- open.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,
- LocServerType type,
- const char* hostname, int port)
-{
- ENTRY_LOG_CALLFLOW();
- int ret_val = 0;
-
- if (NULL != loc_eng_data.context)
- {
- ret_val = loc_eng_set_server(loc_eng_data, type, hostname, port);
- } else {
- LOC_LOGW("set_server called before init. save the address, type: %d, hostname: %s, port: %d",
- (int) type, hostname, port);
- switch (type)
- {
- case LOC_AGPS_SUPL_SERVER:
- strlcpy(loc_eng_data.supl_host_buf, hostname,
- sizeof(loc_eng_data.supl_host_buf));
- loc_eng_data.supl_port_buf = port;
- loc_eng_data.supl_host_set = 1;
- break;
- case LOC_AGPS_CDMA_PDE_SERVER:
- strlcpy(loc_eng_data.c2k_host_buf, hostname,
- sizeof(loc_eng_data.c2k_host_buf));
- loc_eng_data.c2k_port_buf = port;
- loc_eng_data.c2k_host_set = 1;
- break;
- default:
- LOC_LOGE("loc_eng_set_server_proxy, unknown server type = %d", (int) type);
- }
- }
-
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_agps_ril_update_network_availability
-
-DESCRIPTION
- Sets data call allow vs disallow flag to modem
- This is the only member of sLocEngAGpsRilInterface implemented.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
- int available, const char* apn)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return);
- if (apn != NULL)
- {
- LOC_LOGD("loc_eng_agps_ril_update_network_availability: APN Name = [%s]\n", apn);
- int apn_len = smaller_of(strlen (apn), MAX_APN_LEN);
- loc_eng_msg_set_data_enable *msg(new loc_eng_msg_set_data_enable(&loc_eng_data, apn,
- apn_len, available));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
- }
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_report_status
-
-DESCRIPTION
- Reports GPS engine state to Java layer.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- N/A
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusValue status)
-{
- ENTRY_LOG();
- // Switch from WAIT to MUTE, for "engine on" or "session begin" event
- if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_ENGINE_ON)
- {
- if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_WAIT)
- {
- LOC_LOGD("loc_eng_report_status: mute_session_state changed from WAIT to IN SESSION");
- loc_eng_data.mute_session_state = LOC_MUTE_SESS_IN_SESSION;
- }
- }
-
- // Switch off MUTE session
- if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_IN_SESSION &&
- (status == GPS_STATUS_SESSION_END || status == GPS_STATUS_ENGINE_OFF))
- {
- LOC_LOGD("loc_eng_report_status: mute_session_state changed from IN SESSION to NONE");
- loc_eng_data.mute_session_state = LOC_MUTE_SESS_NONE;
- }
-
- // Session End is not reported during Android navigating state
- boolean navigating = loc_eng_data.client_handle->isInSession();
- if (status != GPS_STATUS_NONE &&
- !(status == GPS_STATUS_SESSION_END && navigating) &&
- !(status == GPS_STATUS_SESSION_BEGIN && !navigating))
- {
- if (loc_eng_data.mute_session_state != LOC_MUTE_SESS_IN_SESSION)
- {
- // Inform GpsLocationProvider about mNavigating status
- loc_inform_gps_status(loc_eng_data, status);
- }
- else {
- LOC_LOGD("loc_eng_report_status: muting the status report.");
- }
- }
-
- // Only keeps ENGINE ON/OFF in engine_status
- if (status == GPS_STATUS_ENGINE_ON || status == GPS_STATUS_ENGINE_OFF)
- {
- loc_eng_data.engine_status = status;
- }
-
- // Only keeps SESSION BEGIN/END in fix_session_status
- if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_SESSION_END)
- {
- loc_eng_data.fix_session_status = status;
- }
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_handle_engine_down
- loc_eng_handle_engine_up
-
-DESCRIPTION
- Calls this function when it is detected that modem restart is happening.
- Either we detected the modem is down or received modem up event.
- This must be called from the deferred thread to avoid race condition.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG();
- loc_eng_ni_reset_on_engine_restart(loc_eng_data);
- loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_OFF);
- EXIT_LOG(%s, VOID_RET);
-}
-
-void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data)
-{
- ENTRY_LOG();
- loc_eng_reinit(loc_eng_data);
-
- if (loc_eng_data.agps_status_cb != NULL) {
- loc_eng_data.agnss_nif->dropAllSubscribers();
- loc_eng_data.internet_nif->dropAllSubscribers();
-
- loc_eng_agps_reinit(loc_eng_data);
- }
-
- loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_ON);
-
- // modem is back up. If we crashed in the middle of navigating, we restart.
- if (loc_eng_data.client_handle->isInSession()) {
- // This sets the copy in adapter to modem
- loc_eng_data.client_handle->setPositionMode(NULL);
- loc_eng_data.client_handle->setInSession(false);
- loc_eng_start_handler(loc_eng_data);
- }
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_deferred_action_thread
-
-DESCRIPTION
- Main routine for the thread to execute loc_eng commands.
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static void loc_eng_deferred_action_thread(void* arg)
-{
- ENTRY_LOG();
- loc_eng_msg *msg;
- static int cnt = 0;
- LocEngContext* context = (LocEngContext*)arg;
-
- // make sure we do not run in background scheduling group
- set_sched_policy(gettid(), SP_FOREGROUND);
-
- while (1)
- {
- LOC_LOGD("%s:%d] %d listening ...\n", __func__, __LINE__, cnt++);
-
- // we are only sending / receiving msg pointers
- msq_q_err_type result = msg_q_rcv((void*)context->deferred_q, (void **) &msg);
- if (eMSG_Q_SUCCESS != result) {
- LOC_LOGE("%s:%d] fail receiving msg: %s\n", __func__, __LINE__,
- loc_get_msg_q_status(result));
- return;
- }
-
- loc_eng_data_s_type* loc_eng_data_p = (loc_eng_data_s_type*)msg->owner;
-
- LOC_LOGD("%s:%d] received msg_id = %s context = %p\n",
- __func__, __LINE__, loc_get_msg_name(msg->msgid), loc_eng_data_p->context);
-
- // need to ensure the instance data is valid
- STATE_CHECK(NULL != loc_eng_data_p->context,
- "instance cleanup happened",
- delete msg; return);
-
- switch(msg->msgid) {
- case LOC_ENG_MSG_QUIT:
- {
- LocEngContext* context = (LocEngContext*)loc_eng_data_p->context;
- pthread_mutex_lock(&(context->lock));
- pthread_cond_signal(&(context->cond));
- pthread_mutex_unlock(&(context->lock));
- EXIT_LOG(%s, "LOC_ENG_MSG_QUIT, signal the main thread and return");
- }
- return;
-
- case LOC_ENG_MSG_REQUEST_NI:
- {
- loc_eng_msg_request_ni *niMsg = (loc_eng_msg_request_ni*)msg;
- loc_eng_ni_request_handler(*loc_eng_data_p, &niMsg->notify, niMsg->passThroughData);
- }
- break;
-
- case LOC_ENG_MSG_INFORM_NI_RESPONSE:
- {
- loc_eng_msg_inform_ni_response *nrMsg = (loc_eng_msg_inform_ni_response*)msg;
- loc_eng_data_p->client_handle->informNiResponse(nrMsg->response,
- nrMsg->passThroughData);
- }
- break;
-
- case LOC_ENG_MSG_START_FIX:
- loc_eng_start_handler(*loc_eng_data_p);
- break;
-
- case LOC_ENG_MSG_STOP_FIX:
- if (loc_eng_data_p->agps_request_pending)
- {
- loc_eng_data_p->stop_request_pending = true;
- LOC_LOGD("loc_eng_stop - deferring stop until AGPS data call is finished\n");
- } else {
- loc_eng_stop_handler(*loc_eng_data_p);
- }
- break;
-
- case LOC_ENG_MSG_SET_POSITION_MODE:
- {
- loc_eng_msg_position_mode *pmMsg = (loc_eng_msg_position_mode*)msg;
- loc_eng_data_p->client_handle->setPositionMode(&(pmMsg->pMode));
- }
- break;
-
- case LOC_ENG_MSG_SET_TIME:
- {
- loc_eng_msg_set_time *tMsg = (loc_eng_msg_set_time*)msg;
- loc_eng_data_p->client_handle->setTime(tMsg->time, tMsg->timeReference,
- tMsg->uncertainty);
- }
- break;
-
- case LOC_ENG_MSG_INJECT_LOCATION:
- {
- loc_eng_msg_inject_location *ilMsg = (loc_eng_msg_inject_location*) msg;
- loc_eng_data_p->client_handle->injectPosition(ilMsg->latitude, ilMsg->longitude,
- ilMsg->accuracy);
- }
- break;
-
- case LOC_ENG_MSG_SET_SERVER_IPV4:
- {
- loc_eng_msg_set_server_ipv4 *ssiMsg = (loc_eng_msg_set_server_ipv4*)msg;
- loc_eng_data_p->client_handle->setServer(ssiMsg->nl_addr,
- ssiMsg->port,
- ssiMsg->serverType);
- }
- break;
-
- case LOC_ENG_MSG_SET_SERVER_URL:
- {
- loc_eng_msg_set_server_url *ssuMsg = (loc_eng_msg_set_server_url*)msg;
- loc_eng_data_p->client_handle->setServer(ssuMsg->url, ssuMsg->len);
- }
- break;
-
- case LOC_ENG_MSG_SUPL_VERSION:
- {
- loc_eng_msg_suple_version *svMsg = (loc_eng_msg_suple_version*)msg;
- loc_eng_data_p->client_handle->setSUPLVersion(svMsg->supl_version);
- }
- break;
-
- case LOC_ENG_MSG_LPP_CONFIG:
- {
- loc_eng_msg_lpp_config *svMsg = (loc_eng_msg_lpp_config*)msg;
- loc_eng_data_p->client_handle->setLPPConfig(svMsg->lpp_config);
- }
- break;
-
- case LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG:
- {
- loc_eng_msg_sensor_control_config *sccMsg = (loc_eng_msg_sensor_control_config*)msg;
- loc_eng_data_p->client_handle->setSensorControlConfig(sccMsg->sensorsDisabled);
- }
- break;
-
- case LOC_ENG_MSG_SET_SENSOR_PROPERTIES:
- {
- loc_eng_msg_sensor_properties *spMsg = (loc_eng_msg_sensor_properties*)msg;
- loc_eng_data_p->client_handle->setSensorProperties(spMsg->gyroBiasVarianceRandomWalk_valid,
- spMsg->gyroBiasVarianceRandomWalk,
- spMsg->accelRandomWalk_valid,
- spMsg->accelRandomWalk,
- spMsg->angleRandomWalk_valid,
- spMsg->angleRandomWalk,
- spMsg->rateRandomWalk_valid,
- spMsg->rateRandomWalk,
- spMsg->velocityRandomWalk_valid,
- spMsg->velocityRandomWalk);
- }
- break;
-
- case LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG:
- {
- loc_eng_msg_sensor_perf_control_config *spccMsg = (loc_eng_msg_sensor_perf_control_config*)msg;
- loc_eng_data_p->client_handle->setSensorPerfControlConfig(spccMsg->controlMode, spccMsg->accelSamplesPerBatch, spccMsg->accelBatchesPerSec,
- spccMsg->gyroSamplesPerBatch, spccMsg->gyroBatchesPerSec,
- spccMsg->accelSamplesPerBatchHigh, spccMsg->accelBatchesPerSecHigh,
- spccMsg->gyroSamplesPerBatchHigh, spccMsg->gyroBatchesPerSecHigh,
- spccMsg->algorithmConfig);
- }
- break;
-
- case LOC_ENG_MSG_EXT_POWER_CONFIG:
- {
- loc_eng_msg_ext_power_config *pwrMsg = (loc_eng_msg_ext_power_config*)msg;
- loc_eng_data_p->client_handle->setExtPowerConfig(pwrMsg->isBatteryCharging);
- }
- break;
-
- case LOC_ENG_MSG_REPORT_POSITION:
- if (loc_eng_data_p->mute_session_state != LOC_MUTE_SESS_IN_SESSION)
- {
- bool reported = false;
- loc_eng_msg_report_position *rpMsg = (loc_eng_msg_report_position*)msg;
- if (loc_eng_data_p->location_cb != NULL) {
- if (LOC_SESS_FAILURE == rpMsg->status) {
- // in case we want to handle the failure case
- loc_eng_data_p->location_cb(NULL, NULL);
- reported = true;
- }
- // what's in the else if is... (line by line)
- // 1. this is a good fix; or
- // 1.1 there is source info; or
- // 1.1.1 this is from hybrid provider;
- // 1.2 it is a Satellite fix; or
- // 1.2.1 it is a sensor fix
- // 2. (must be intermediate fix... implicit)
- // 2.1 we accepte intermediate; and
- // 2.2 it is NOT the case that
- // 2.2.1 there is inaccuracy; and
- // 2.2.2 we care about inaccuracy; and
- // 2.2.3 the inaccuracy exceeds our tolerance
- else if ((LOC_SESS_SUCCESS == rpMsg->status &&
- (((LOCATION_HAS_SOURCE_INFO & rpMsg->location.flags) &&
- ULP_LOCATION_IS_FROM_HYBRID == rpMsg->location.position_source) ||
- ((LOC_POS_TECH_MASK_SATELLITE & rpMsg->technology_mask) ||
- (LOC_POS_TECH_MASK_SENSORS & rpMsg->technology_mask)))) ||
- (LOC_SESS_INTERMEDIATE == loc_eng_data_p->intermediateFix &&
- !((rpMsg->location.flags & GPS_LOCATION_HAS_ACCURACY) &&
- (gps_conf.ACCURACY_THRES != 0) &&
- (rpMsg->location.accuracy > gps_conf.ACCURACY_THRES)))) {
- loc_eng_data_p->location_cb((GpsLocation*)&(rpMsg->location),
- (void*)rpMsg->locationExt);
- reported = true;
- }
- }
-
- // if we have reported this fix
- if (reported &&
- // and if this is a singleshot
- GPS_POSITION_RECURRENCE_SINGLE ==
- loc_eng_data_p->client_handle->getPositionMode().recurrence) {
- if (LOC_SESS_INTERMEDIATE == rpMsg->status) {
- // modem could be still working for a final fix,
- // although we no longer need it. So stopFix().
- loc_eng_data_p->client_handle->stopFix();
- }
- // turn off the session flag.
- loc_eng_data_p->client_handle->setInSession(false);
- }
-
- if (loc_eng_data_p->generateNmea && rpMsg->location.position_source == ULP_LOCATION_IS_FROM_GNSS)
- {
- loc_eng_nmea_generate_pos(loc_eng_data_p, rpMsg->location, rpMsg->locationExtended);
- }
-
- // Free the allocated memory for rawData
- GpsLocation* gp = (GpsLocation*)&(rpMsg->location);
- if (gp != NULL && gp->rawData != NULL)
- {
- delete (char*)gp->rawData;
- gp->rawData = NULL;
- gp->rawDataSize = 0;
- }
- }
-
- break;
-
- case LOC_ENG_MSG_REPORT_SV:
- if (loc_eng_data_p->mute_session_state != LOC_MUTE_SESS_IN_SESSION)
- {
- loc_eng_msg_report_sv *rsMsg = (loc_eng_msg_report_sv*)msg;
- if (loc_eng_data_p->sv_status_cb != NULL) {
- loc_eng_data_p->sv_status_cb((GpsSvStatus*)&(rsMsg->svStatus),
- (void*)rsMsg->svExt);
- }
-
- if (loc_eng_data_p->generateNmea)
- {
- loc_eng_nmea_generate_sv(loc_eng_data_p, rsMsg->svStatus, rsMsg->locationExtended);
- }
-
- }
- break;
-
- case LOC_ENG_MSG_REPORT_STATUS:
- loc_eng_report_status(*loc_eng_data_p, ((loc_eng_msg_report_status*)msg)->status);
- break;
-
- case LOC_ENG_MSG_REPORT_NMEA:
- if (NULL != loc_eng_data_p->nmea_cb) {
- loc_eng_msg_report_nmea* nmMsg = (loc_eng_msg_report_nmea*)msg;
- struct timeval tv;
- gettimeofday(&tv, (struct timezone *) NULL);
- int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
- CALLBACK_LOG_CALLFLOW("nmea_cb", %p, nmMsg->nmea);
- loc_eng_data_p->nmea_cb(now, nmMsg->nmea, nmMsg->length);
- }
- break;
-
- case LOC_ENG_MSG_REQUEST_BIT:
- {
- AgpsStateMachine* stateMachine;
- loc_eng_msg_request_bit* brqMsg = (loc_eng_msg_request_bit*)msg;
- if (brqMsg->ifType == LOC_ENG_IF_REQUEST_TYPE_SUPL) {
- stateMachine = loc_eng_data_p->agnss_nif;
- } else if (brqMsg->ifType == LOC_ENG_IF_REQUEST_TYPE_ANY) {
- stateMachine = loc_eng_data_p->internet_nif;
- } else {
- LOC_LOGD("%s]%d: unknown I/F request type = 0x%x\n", __func__, __LINE__, brqMsg->ifType);
- break;
- }
- BITSubscriber subscriber(stateMachine, brqMsg->ipv4Addr, brqMsg->ipv6Addr);
-
- stateMachine->subscribeRsrc((Subscriber*)&subscriber);
- }
- break;
-
- case LOC_ENG_MSG_RELEASE_BIT:
- {
- AgpsStateMachine* stateMachine;
- loc_eng_msg_release_bit* brlMsg = (loc_eng_msg_release_bit*)msg;
- if (brlMsg->ifType == LOC_ENG_IF_REQUEST_TYPE_SUPL) {
- stateMachine = loc_eng_data_p->agnss_nif;
- } else if (brlMsg->ifType == LOC_ENG_IF_REQUEST_TYPE_ANY) {
- stateMachine = loc_eng_data_p->internet_nif;
- } else {
- LOC_LOGD("%s]%d: unknown I/F request type = 0x%x\n", __func__, __LINE__, brlMsg->ifType);
- break;
- }
- BITSubscriber subscriber(stateMachine, brlMsg->ipv4Addr, brlMsg->ipv6Addr);
-
- stateMachine->unsubscribeRsrc((Subscriber*)&subscriber);
- }
- break;
-
- case LOC_ENG_MSG_REQUEST_ATL:
- {
- loc_eng_msg_request_atl* arqMsg = (loc_eng_msg_request_atl*)msg;
- boolean backwardCompatibleMode = AGPS_TYPE_INVALID == arqMsg->type;
- AgpsStateMachine* stateMachine = (AGPS_TYPE_SUPL == arqMsg->type ||
- backwardCompatibleMode) ?
- loc_eng_data_p->agnss_nif :
- loc_eng_data_p->internet_nif;
- ATLSubscriber subscriber(arqMsg->handle,
- stateMachine,
- loc_eng_data_p->client_handle,
- backwardCompatibleMode);
-
- stateMachine->subscribeRsrc((Subscriber*)&subscriber);
- }
- break;
-
- case LOC_ENG_MSG_RELEASE_ATL:
- {
- loc_eng_msg_release_atl* arlMsg = (loc_eng_msg_release_atl*)msg;
- ATLSubscriber s1(arlMsg->handle,
- loc_eng_data_p->agnss_nif,
- loc_eng_data_p->client_handle,
- false);
- // attempt to unsubscribe from agnss_nif first
- if (! loc_eng_data_p->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) {
- ATLSubscriber s2(arlMsg->handle,
- loc_eng_data_p->internet_nif,
- loc_eng_data_p->client_handle,
- false);
- // if unsuccessful, try internet_nif
- loc_eng_data_p->internet_nif->unsubscribeRsrc((Subscriber*)&s2);
- }
- }
- break;
-
- case LOC_ENG_MSG_REQUEST_WIFI:
- {
- loc_eng_msg_request_wifi *wrqMsg = (loc_eng_msg_request_wifi *)msg;
- if (wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC ||
- wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM ||
- wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU) {
- AgpsStateMachine* stateMachine = loc_eng_data_p->wifi_nif;
- WIFISubscriber subscriber(stateMachine, wrqMsg->ssid, wrqMsg->password, wrqMsg->senderId);
- stateMachine->subscribeRsrc((Subscriber*)&subscriber);
- } else {
- LOC_LOGE("%s]%d ERROR: unknown sender ID", __func__, __LINE__);
- break;
- }
- }
- break;
-
- case LOC_ENG_MSG_RELEASE_WIFI:
- {
- AgpsStateMachine* stateMachine = loc_eng_data_p->wifi_nif;
- loc_eng_msg_release_wifi* wrlMsg = (loc_eng_msg_release_wifi*)msg;
- WIFISubscriber subscriber(stateMachine, wrlMsg->ssid, wrlMsg->password, wrlMsg->senderId);
- stateMachine->unsubscribeRsrc((Subscriber*)&subscriber);
- }
- break;
-
- case LOC_ENG_MSG_REQUEST_XTRA_DATA:
- if (loc_eng_data_p->xtra_module_data.download_request_cb != NULL)
- {
- loc_eng_data_p->xtra_module_data.download_request_cb();
- }
- break;
-
- case LOC_ENG_MSG_REQUEST_TIME:
- if (loc_eng_data_p->request_utc_time_cb != NULL)
- {
- loc_eng_data_p->request_utc_time_cb();
- }
- else
- {
- LOC_LOGE("%s] ERROR: Callback function for request_time is NULL", __func__);
- }
- break;
-
- case LOC_ENG_MSG_REQUEST_POSITION:
- break;
-
- case LOC_ENG_MSG_DELETE_AIDING_DATA:
- loc_eng_data_p->aiding_data_for_deletion |= ((loc_eng_msg_delete_aiding_data*)msg)->type;
- break;
-
- case LOC_ENG_MSG_ENABLE_DATA:
- {
- loc_eng_msg_set_data_enable *unaMsg = (loc_eng_msg_set_data_enable*)msg;
- loc_eng_data_p->client_handle->enableData(unaMsg->enable);
- loc_eng_data_p->client_handle->setAPN(unaMsg->apn, unaMsg->length);
- }
- break;
-
- case LOC_ENG_MSG_INJECT_XTRA_DATA:
- {
- loc_eng_msg_inject_xtra_data *xdMsg = (loc_eng_msg_inject_xtra_data*)msg;
- loc_eng_data_p->client_handle->setXtraData(xdMsg->data, xdMsg->length);
- }
- break;
-
- case LOC_ENG_MSG_ATL_OPEN_SUCCESS:
- {
- loc_eng_msg_atl_open_success *aosMsg = (loc_eng_msg_atl_open_success*)msg;
- AgpsStateMachine* stateMachine;
- switch (aosMsg->agpsType) {
- case AGPS_TYPE_WIFI: {
- stateMachine = loc_eng_data_p->wifi_nif;
- break;
- }
- case AGPS_TYPE_SUPL: {
- stateMachine = loc_eng_data_p->agnss_nif;
- break;
- }
- default: {
- stateMachine = loc_eng_data_p->internet_nif;
- }
- }
-
- stateMachine->setBearer(aosMsg->bearerType);
- stateMachine->setAPN(aosMsg->apn, aosMsg->length);
- stateMachine->onRsrcEvent(RSRC_GRANTED);
- }
- break;
-
- case LOC_ENG_MSG_ATL_CLOSED:
- {
- loc_eng_msg_atl_closed *acsMsg = (loc_eng_msg_atl_closed*)msg;
- AgpsStateMachine* stateMachine;
- switch (acsMsg->agpsType) {
- case AGPS_TYPE_WIFI: {
- stateMachine = loc_eng_data_p->wifi_nif;
- break;
- }
- case AGPS_TYPE_SUPL: {
- stateMachine = loc_eng_data_p->agnss_nif;
- break;
- }
- default: {
- stateMachine = loc_eng_data_p->internet_nif;
- }
- }
-
- stateMachine->onRsrcEvent(RSRC_RELEASED);
- }
- break;
-
- case LOC_ENG_MSG_ATL_OPEN_FAILED:
- {
- loc_eng_msg_atl_open_failed *aofMsg = (loc_eng_msg_atl_open_failed*)msg;
- AgpsStateMachine* stateMachine;
- switch (aofMsg->agpsType) {
- case AGPS_TYPE_WIFI: {
- stateMachine = loc_eng_data_p->wifi_nif;
- break;
- }
- case AGPS_TYPE_SUPL: {
- stateMachine = loc_eng_data_p->agnss_nif;
- break;
- }
- default: {
- stateMachine = loc_eng_data_p->internet_nif;
- }
- }
-
- stateMachine->onRsrcEvent(RSRC_DENIED);
- }
- break;
-
- case LOC_ENG_MSG_ENGINE_DOWN:
- loc_eng_handle_engine_down(*loc_eng_data_p);
- break;
-
- case LOC_ENG_MSG_ENGINE_UP:
- loc_eng_handle_engine_up(*loc_eng_data_p);
- break;
-
- case LOC_ENG_MSG_REQUEST_NETWORK_POSIITON:
- {
- loc_eng_msg_request_network_position *nlprequestmsg = (loc_eng_msg_request_network_position*)msg;
- //loc_eng_handle_request_network_position(nlprequestmsg );
- LOC_LOGD("Received n/w position request from ULP.Request type %d Periodicity: %d\n",
- nlprequestmsg->networkPosRequest.request_type,
- nlprequestmsg->networkPosRequest.interval_ms);
- if(loc_eng_data_p->ulp_network_callback != NULL)
- {
- loc_eng_data_p->ulp_network_callback((UlpNetworkRequestPos*)&(nlprequestmsg->networkPosRequest));
- }
- else
- LOC_LOGE("Ulp Network call back not initialized");
- }
- break;
-
- case LOC_ENG_MSG_REQUEST_PHONE_CONTEXT:
- {
- loc_eng_msg_request_phone_context *contextReqMsg = (loc_eng_msg_request_phone_context*)msg;
- LOC_LOGD("Received phone context request from ULP.context_type 0x%x,request_type 0x%x ",
- contextReqMsg->contextRequest.context_type,contextReqMsg->contextRequest.request_type)
- if(loc_eng_data_p->ulp_phone_context_req_cb != NULL)
- {
- loc_eng_data_p->ulp_phone_context_req_cb((UlpPhoneContextRequest*)&(contextReqMsg->contextRequest));
- }
- else
- LOC_LOGE("Ulp Phone context request call back not initialized");
- }
- break;
-
- case LOC_ENG_MSG_PRIVACY:
- {
- loc_eng_msg_privacy *privacyMsg = (loc_eng_msg_privacy*)msg;
-#ifdef SET_PRIVACY
- loc_eng_data_p->client_handle->setPrivacy(privacyMsg->privacy_setting);
-#else
- LOC_LOGE("Ignoring call to setPrivacy");
-#endif
- }
- break;
-
- default:
- LOC_LOGE("unsupported msgid = %d\n", msg->msgid);
- break;
- }
-
- if ( (msg->msgid == LOC_ENG_MSG_ATL_OPEN_FAILED) |
- (msg->msgid == LOC_ENG_MSG_ATL_CLOSED) |
- (msg->msgid == LOC_ENG_MSG_ATL_OPEN_SUCCESS) )
- {
- loc_eng_data_p->agps_request_pending = false;
- if (loc_eng_data_p->stop_request_pending) {
- loc_eng_stop_handler(*loc_eng_data_p);
- loc_eng_data_p->stop_request_pending = false;
- }
- }
- loc_eng_data_p->stop_request_pending = false;
-
- if (loc_eng_data_p->engine_status != GPS_STATUS_ENGINE_ON &&
- loc_eng_data_p->aiding_data_for_deletion != 0)
- {
- loc_eng_data_p->client_handle->deleteAidingData(loc_eng_data_p->aiding_data_for_deletion);
- loc_eng_data_p->aiding_data_for_deletion = 0;
- }
-
- delete msg;
- }
-
- EXIT_LOG(%s, VOID_RET);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_ulp_init
-
-DESCRIPTION
- This function dynamically loads the libulp.so and calls
- its init function to start up the ulp module
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: no error
- -1: errors
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_ulp_init(loc_eng_data_s_type &loc_eng_data, const ulpInterface * loc_eng_ulpInf)
-{
- ENTRY_LOG();
- int ret_val=-1;
- if((loc_eng_ulpInf != NULL) && (((ulpInterface *)loc_eng_ulpInf)->init != NULL))
- {
- // Initialize the ULP interface
- ((ulpInterface *)loc_eng_ulpInf)->init(loc_eng_data);
- loc_eng_data.ulp_initialized = TRUE;
- ret_val = 0;
- }
- else
- LOC_LOGE("ulp not initialized. NULL parameter");
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_inject_raw_command
-
-DESCRIPTION
- This is used to send special test modem commands from the applications
- down into the HAL
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-bool loc_eng_inject_raw_command(loc_eng_data_s_type &loc_eng_data,
- char* command, int length)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return -1);
- boolean ret_val;
- LOC_LOGD("loc_eng_send_extra_command: %s\n", command);
- ret_val = TRUE;
-
- if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY))
- {
- ulp_msg_inject_raw_command *msg(
- new ulp_msg_inject_raw_command(&loc_eng_data,command, length));
- msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q
- , msg, loc_eng_free_msg);
- ret_val = 0;
- }else
- {
- ret_val = -1;
- }
-
-
- EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);
- return ret_val;
-}
-/*===========================================================================
-FUNCTION loc_eng_update_criteria
-
-DESCRIPTION
- This is used to inform the ULP module of new unique criteria that are passed
- in by the applications
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_update_criteria(loc_eng_data_s_type &loc_eng_data,
- UlpLocationCriteria criteria)
-{
- ENTRY_LOG_CALLFLOW();
- INIT_CHECK(loc_eng_data.context, return -1);
- int ret_val;
-
- if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY))
- {
- LOC_LOGD("SJ:loc_eng_update_criteria: valid 0x%x action:%d, minTime:%ld, minDistance:%f, singleShot:%d, horizontalAccuracy:%d, powerRequirement:%d \n",
- criteria.valid_mask, criteria.action, criteria.min_interval, criteria.min_distance, criteria.recurrence_type, criteria.preferred_horizontal_accuracy,
- criteria.preferred_power_consumption );
- ulp_msg_update_criteria *msg(
- new ulp_msg_update_criteria(&loc_eng_data,criteria));
- msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q
- , msg, loc_eng_free_msg);
- ret_val = 0;
- }else
- {
- ret_val = -1;
- }
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_ulp_phone_context_settings_update
-
-DESCRIPTION
- This is used to inform the ULP module of phone settings changes carried out
- by the users
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-
-int loc_eng_ulp_phone_context_settings_update(loc_eng_data_s_type &loc_eng_data,
- UlpPhoneContextSettings *settings)
-{
- ENTRY_LOG();
- int ret_val = -1;
-
- LOC_LOGD("loc_eng_ulp_phone_context_settings: context_type - 0x%x is_agps_enabled - %d "
- "is_battery_charging %d ,is_gps_enabled %d, is_network_position_available %d,"
- "is_wifi_setting_enabled %d, is_agps_setting_enabled %d, is_enh_location_services_enabled %d\n",
- settings->context_type ,settings->is_agps_enabled,settings->is_battery_charging,
- settings->is_gps_enabled, settings->is_network_position_available,
- settings->is_wifi_setting_enabled, settings->is_agps_enabled,
- settings->is_enh_location_services_enabled );
-
- if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY))
- {
- ulp_msg_inject_phone_context_settings *msg
- (new ulp_msg_inject_phone_context_settings(&loc_eng_data, *settings));
- msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q, msg, loc_eng_free_msg);
- ret_val = 0;
- }
-
- // Send battery information to modem for processing.
- if(settings->context_type & ULP_PHONE_CONTEXT_BATTERY_CHARGING_STATE)
- {
- loc_eng_msg_ext_power_config *msg(new loc_eng_msg_ext_power_config(&loc_eng_data, settings->is_battery_charging));
- msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->deferred_q, msg, loc_eng_free_msg);
- }
-
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-/*===========================================================================
-FUNCTION loc_eng_ulp_network_init
-
-DESCRIPTION
- Initialize the ULP network interface.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data,UlpPhoneContextCallbacks *callback)
-{
- int ret_val = -1;
- ENTRY_LOG();
- if(callback != NULL) {
- loc_eng_data.ulp_phone_context_req_cb = callback->ulp_request_phone_context_cb ;
- ret_val = 0;
- }
- else
- LOC_LOGE("loc_eng_ulp_phone_context_init: bad parameters cb %p", callback);
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_ulp_network_init
-
-DESCRIPTION
- Initialize the ULP network interface.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data,
- UlpNetworkLocationCallbacks *callbacks)
-{
- int ret_val = -1;
- ENTRY_LOG_CALLFLOW();
- if(callbacks != NULL) {
- loc_eng_data.ulp_network_callback = callbacks->ulp_network_location_request_cb;
- ret_val = 0;
- }
- else
- LOC_LOGE("loc_eng_ulp_network_init: bad parameters cb %p", callbacks);
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-
-/*===========================================================================
-FUNCTION loc_eng_ulp_send_network_position
-
-DESCRIPTION
- Ulp send data
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_ulp_send_network_position(loc_eng_data_s_type &loc_eng_data,
- UlpNetworkPositionReport *position_report)
-{
- ENTRY_LOG();
- int ret_val = 0;
- if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY))
- {
- ulp_msg_inject_network_position *msg
- (new ulp_msg_inject_network_position(&loc_eng_data, *position_report));
- msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q
- , msg, loc_eng_free_msg);
- ret_val = 0;
- }else
- {
- ret_val = -1;
- }
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-/*===========================================================================
-FUNCTION loc_eng_read_config
-
-DESCRIPTION
- Initiates the reading of the gps config file stored in /etc dir
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_read_config(void)
-{
- ENTRY_LOG_CALLFLOW();
- if(gpsConfigAlreadyRead == false)
- {
- // Initialize our defaults before reading of configuration file overwrites them.
- loc_default_parameters();
- // Ee only want to parse the conf file once. This is a good place to ensure that.
- // In fact one day the conf file should go into context.
- UTIL_READ_CONF(GPS_CONF_FILE, loc_parameter_table);
- gpsConfigAlreadyRead = true;
- } else {
- LOC_LOGV("GPS Config file has already been read\n");
- }
-
- EXIT_LOG(%d, 0);
- return 0;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_set_privacy
-
-DESCRIPTION
- Sets the privacy lock setting (1. GPS on, 0. GPS off).
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static int loc_eng_set_privacy(loc_eng_data_s_type &loc_eng_data,
- int8_t privacy_setting)
-{
- ENTRY_LOG();
- INIT_CHECK(loc_eng_data.context, return -1);
-#ifdef SET_PRIVACY
- loc_eng_msg_privacy *msg(
- new loc_eng_msg_privacy(&loc_eng_data, privacy_setting));
- msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q,
- msg, loc_eng_free_msg);
-#endif
- EXIT_LOG(%d, 0);
- return 0;
-}
diff --git a/gps/libloc_api_50001/loc_eng_msg.cpp b/gps/libloc_api_50001/loc_eng_msg.cpp
deleted file mode 100644
index a296dce..0000000
--- a/gps/libloc_api_50001/loc_eng_msg.cpp
+++ /dev/null
@@ -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);
-}
diff --git a/gps/libloc_api_50001/loc_eng_msg.h b/gps/libloc_api_50001/loc_eng_msg.h
deleted file mode 100755
index 0728653..0000000
--- a/gps/libloc_api_50001/loc_eng_msg.h
+++ /dev/null
@@ -1,904 +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.
- *
- */
-#ifndef LOC_ENG_MSG_H
-#define LOC_ENG_MSG_H
-
-
-#include <hardware/gps.h>
-#include <stdlib.h>
-#include <string.h>
-#include "log_util.h"
-#include "loc.h"
-#include <loc_eng_log.h>
-#include "loc_eng_msg_id.h"
-
-#ifdef __cplusplus
-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
-/** GpsLocation has valid magnetic deviation. */
-#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004
-/** GpsLocation has valid mode indicator. */
-#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008
-
-/** 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;
-} 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;
-
-struct loc_eng_msg {
- const void* owner;
- const int msgid;
- inline loc_eng_msg(void* instance, int id) :
- owner(instance), msgid(id)
- {
- LOC_LOGV("creating msg %s", loc_get_msg_name(msgid));
- LOC_LOGV("creating msg ox%x", msgid);
- }
- virtual ~loc_eng_msg()
- {
- LOC_LOGV("deleting msg %s", loc_get_msg_name(msgid));
- LOC_LOGV("deleting msg ox%x", msgid);
- }
-};
-
-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,
- LocPosMode &mode) :
- loc_eng_msg(instance, LOC_ENG_MSG_SET_POSITION_MODE),
- pMode(mode)
- {
- pMode.logv();
- }
-};
-
-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 GpsLocation location;
- const GpsLocationExtended locationExtended;
- const void* locationExt;
- const enum loc_sess_status status;
- const LocPosTechMask technology_mask;
- inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, GpsLocationExtended &locExtended, void* locExt,
- enum loc_sess_status st) :
- loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION),
- location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(LOC_POS_TECH_MASK_DEFAULT)
- {
- LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %d\n Technology mask: %u",
- location.flags, location.position_source, location.latitude, location.longitude,
- location.altitude, location.speed, location.bearing, location.accuracy,
- location.timestamp, location.rawDataSize, location.rawData,status,technology_mask);
- }
- inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, GpsLocationExtended &locExtended, void* locExt,
- enum loc_sess_status st, LocPosTechMask technology) :
- loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION),
- location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(technology)
- {
- LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %d\n Technology mask: %u",
- location.flags, location.position_source, location.latitude, location.longitude,
- location.altitude, location.speed, location.bearing, location.accuracy,
- location.timestamp, location.rawDataSize, location.rawData,status,technology_mask);
- }
-};
-
-struct loc_eng_msg_report_sv : public loc_eng_msg {
- const GpsSvStatus svStatus;
- const GpsLocationExtended locationExtended;
- const void* svExt;
- inline loc_eng_msg_report_sv(void* instance, GpsSvStatus &sv, GpsLocationExtended &locExtended, void* ext) :
- loc_eng_msg(instance, LOC_ENG_MSG_REPORT_SV), svStatus(sv), locationExtended(locExtended), svExt(ext)
- {
- LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n used in fix mask: %x\n sv: prn snr elevation azimuth",
- svStatus.num_svs, svStatus.ephemeris_mask, svStatus.almanac_mask, svStatus.used_in_fix_mask);
- for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) {
- LOC_LOGV(" %d: %d %f %f %f\n ",
- i,
- svStatus.sv_list[i].prn,
- svStatus.sv_list[i].snr,
- svStatus.sv_list[i].elevation,
- svStatus.sv_list[i].azimuth);
- }
- }
-};
-
-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 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 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 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,
- 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;
- }
- }
-};
-
-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 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 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 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 loc_eng_msg_request_ni : public loc_eng_msg {
- const GpsNiNotification notify;
- const void *passThroughData;
- inline loc_eng_msg_request_ni(void* instance,
- GpsNiNotification &notif, 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_atl_open_success : public loc_eng_msg {
- const AGpsStatusValue agpsType;
- const int length;
- char* const apn;
- const AGpsBearerType bearerType;
- inline loc_eng_msg_atl_open_success(void* instance,
- AGpsStatusValue 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 AGpsStatusValue agpsType;
- inline loc_eng_msg_atl_closed(void* instance,
- AGpsStatusValue 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;
- }
-};
-
-struct loc_eng_msg_request_network_position : public loc_eng_msg {
- const UlpNetworkRequestPos networkPosRequest;
- inline loc_eng_msg_request_network_position (void* instance, UlpNetworkRequestPos networkPosReq) :
- loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_NETWORK_POSIITON),
- networkPosRequest(networkPosReq)
- {
- LOC_LOGV("network position request: desired pos source %d\n request type: %d\n interval ms: %d ",
- networkPosReq.desired_position_source,
- networkPosReq.request_type,
- networkPosReq.interval_ms);
- }
-};
-
-struct loc_eng_msg_request_phone_context : public loc_eng_msg {
- const UlpPhoneContextRequest contextRequest;
- inline loc_eng_msg_request_phone_context (void* instance, UlpPhoneContextRequest contextReq) :
- loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_PHONE_CONTEXT),
- contextRequest(contextReq)
- {
- LOC_LOGV("phone context request: request type 0x%x context type: 0x%x ",
- contextRequest.request_type,
- contextRequest.context_type);
- }
-};
-
-struct ulp_msg_update_criteria : public loc_eng_msg {
- const UlpLocationCriteria locationCriteria;
- inline ulp_msg_update_criteria (void* instance, UlpLocationCriteria criteria) :
- loc_eng_msg(instance, ULP_MSG_UPDATE_CRITERIA),
- locationCriteria(criteria)
- {
- LOC_LOGV("location criteria: aciton %d\n valid mask: %d\n provider source: %d\n accuracy %d\n recurrence type %d\n min interval %d\n power consumption %d\n intermediate pos %d ",
- locationCriteria.action,
- locationCriteria.valid_mask,
- locationCriteria.provider_source,
- locationCriteria.preferred_horizontal_accuracy,
- locationCriteria.recurrence_type,
- locationCriteria.min_interval,
- locationCriteria.preferred_power_consumption,
- locationCriteria.intermediate_pos_report_enabled);
- }
-};
-
-struct ulp_msg_inject_raw_command : public loc_eng_msg {
- const char* rawCommand;
- const int rawCommandLength;
- inline ulp_msg_inject_raw_command (void* instance, char* command, int length) :
- loc_eng_msg(instance, ULP_MSG_INJECT_RAW_COMMAND),
- rawCommand(new char[length]),
- rawCommandLength(length)
- {
- memcpy((void*)rawCommand, (void*)command, length);
- LOC_LOGV("inject raw command: command %s\n command length: %d\n ",
- rawCommand,
- rawCommandLength);
- }
-
- inline ~ulp_msg_inject_raw_command()
- {
- delete[] rawCommand;
- }
-};
-
-struct ulp_msg_inject_phone_context_settings : public loc_eng_msg {
- const UlpPhoneContextSettings phoneSetting;
- inline ulp_msg_inject_phone_context_settings(void* instance, UlpPhoneContextSettings setting) :
- loc_eng_msg(instance, ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS),
- phoneSetting(setting)
- {
- LOC_LOGV("context type: %d\n gps enabled: %d\n network position available %d\n wifi setting enabled %d\n battery charging %d"
- "is_agps_setting_enabled %d, is_enh_location_services_enabled %d\n",
- phoneSetting.context_type,
- phoneSetting.is_gps_enabled,
- phoneSetting.is_network_position_available,
- phoneSetting.is_wifi_setting_enabled,
- phoneSetting.is_battery_charging,
- phoneSetting.is_agps_enabled,
- phoneSetting.is_enh_location_services_enabled);
- }
-};
-
-struct ulp_msg_inject_network_position : public loc_eng_msg {
- const UlpNetworkPositionReport networkPosition;
- inline ulp_msg_inject_network_position(void* instance, UlpNetworkPositionReport networkPos) :
- loc_eng_msg(instance, ULP_MSG_INJECT_NETWORK_POSITION),
- networkPosition(networkPos)
- {
- LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n accuracy %d",
- networkPosition.valid_flag,
- networkPosition.position.pos_source,
- networkPosition.position.latitude,
- networkPosition.position.longitude,
- networkPosition.position.HEPE);
- }
-};
-
-struct ulp_msg_report_quipc_position : public loc_eng_msg {
- const GpsLocation location;
- const int quipc_error_code;
- inline ulp_msg_report_quipc_position(void* instance, GpsLocation &loc,
- int quipc_err) :
- loc_eng_msg(instance, ULP_MSG_REPORT_QUIPC_POSITION),
- location(loc), quipc_error_code(quipc_err)
- {
- LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Quipc error: %d",
- location.flags, location.position_source, location.latitude, location.longitude,
- location.altitude, location.speed, location.bearing, location.accuracy,
- location.timestamp, location.rawDataSize, location.rawData,
- quipc_error_code);
- }
-};
-
-struct loc_eng_msg_privacy : public loc_eng_msg {
- const int8_t privacy_setting;
- inline loc_eng_msg_privacy(void* instance, int8_t privacy_setting) :
- loc_eng_msg(instance, LOC_ENG_MSG_PRIVACY),
- privacy_setting(privacy_setting)
- {
- LOC_LOGV("privacy_setting: %d", privacy_setting);
- }
-};
-
-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
-}
-#endif /* __cplusplus */
-
-#endif /* LOC_ENG_MSG_H */
diff --git a/gps/libloc_api_50001/loc_eng_msg_id.h b/gps/libloc_api_50001/loc_eng_msg_id.h
deleted file mode 100755
index 0f374cd..0000000
--- a/gps/libloc_api_50001/loc_eng_msg_id.h
+++ /dev/null
@@ -1,139 +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.
- *
- */
-#ifndef LOC_ENG_MSG_ID_H
-#define LOC_ENG_MSG_ID_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-struct msgbuf {
- unsigned int msgsz;
- void* msgid;
-};
-
-enum loc_eng_msg_ids_t {
- /* 0x 0 - 0xEF is reserved for daemon internal */
- /* 0xF0 - 0x1FF is reserved for daemon & framework communication */
- LOC_ENG_MSG_QUIT = 0x200,
-
- LOC_ENG_MSG_ENGINE_DOWN,
- LOC_ENG_MSG_ENGINE_UP,
-
- LOC_ENG_MSG_START_FIX,
- LOC_ENG_MSG_STOP_FIX,
- LOC_ENG_MSG_SET_POSITION_MODE,
- LOC_ENG_MSG_SET_TIME,
- LOC_ENG_MSG_INJECT_XTRA_DATA,
- LOC_ENG_MSG_INJECT_LOCATION,
- LOC_ENG_MSG_DELETE_AIDING_DATA,
- LOC_ENG_MSG_SET_APN,
- LOC_ENG_MSG_SET_SERVER_URL,
- LOC_ENG_MSG_SET_SERVER_IPV4,
- LOC_ENG_MSG_ENABLE_DATA,
-
- LOC_ENG_MSG_SUPL_VERSION,
- LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG,
- LOC_ENG_MSG_SET_SENSOR_PROPERTIES,
- LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG,
- LOC_ENG_MSG_MUTE_SESSION,
-
- LOC_ENG_MSG_ATL_OPEN_SUCCESS,
- LOC_ENG_MSG_ATL_CLOSED,
- LOC_ENG_MSG_ATL_OPEN_FAILED,
-
- LOC_ENG_MSG_REPORT_POSITION,
- LOC_ENG_MSG_REPORT_SV,
- LOC_ENG_MSG_REPORT_STATUS,
- LOC_ENG_MSG_REPORT_NMEA,
- LOC_ENG_MSG_REQUEST_BIT,
- LOC_ENG_MSG_RELEASE_BIT,
- LOC_ENG_MSG_REQUEST_ATL,
- LOC_ENG_MSG_RELEASE_ATL,
- LOC_ENG_MSG_REQUEST_WIFI,
- LOC_ENG_MSG_RELEASE_WIFI,
- LOC_ENG_MSG_REQUEST_NI,
- LOC_ENG_MSG_INFORM_NI_RESPONSE,
- LOC_ENG_MSG_REQUEST_XTRA_DATA,
- LOC_ENG_MSG_REQUEST_TIME,
- LOC_ENG_MSG_REQUEST_POSITION,
- LOC_ENG_MSG_EXT_POWER_CONFIG,
-
- // The following messages are added for ulp
- LOC_ENG_MSG_REQUEST_PHONE_CONTEXT,
- LOC_ENG_MSG_REQUEST_NETWORK_POSIITON,
-
- /* Following messages are for ulp, start at index 0x600 */
-
- // Message is sent by GPS HAL layer to add/remove unique request criteria
- ULP_MSG_UPDATE_CRITERIA = 0x600,
-
- // Message is sent by GPS HAL layer to request ULP to start producing position fixes
-
- ULP_MSG_START_FIX,
-
- // Message is sent by Android framework(GpsLocationProvider)
- // to request ULP to stop producing position fixes
- ULP_MSG_STOP_FIX,
-
- // Message is sent by Android framework(GpsLocationProvider)
- // to inject phone context setting include initial phone context setting and subsequent changes
- ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS,
-
- // Message is sent by network provider to INJECT the position in UlpNetworkPositionReport format
- ULP_MSG_INJECT_NETWORK_POSITION,
-
- // Message is sent by QUIPC provider in order to report the position in GpsPosition format with QUIPC status
- ULP_MSG_REPORT_QUIPC_POSITION,
-
- // Message is sent by QUIPC module in order to request some info from ULP
- ULP_MSG_REQUEST_COARSE_POSITION,
-
- // Message is sent to ULP module to re-evaluate its subsystems
- ULP_MSG_MONITOR,
-
- // Last ULP MSG
- ULP_MSG_LAST = 0x700,
-
- /* Message is sent by HAL to LOC API to configure LTE Positioning
- Profile in modem */
- LOC_ENG_MSG_LPP_CONFIG,
-
- // Message is sent by Android framework (GpsLocationProvider)
- // to inject the raw command
- ULP_MSG_INJECT_RAW_COMMAND,
-
- LOC_ENG_MSG_PRIVACY,
-};
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* LOC_ENG_MSG_ID_H */
diff --git a/gps/libloc_api_50001/loc_eng_nmea.cpp b/gps/libloc_api_50001/loc_eng_nmea.cpp
deleted file mode 100644
index d2507a5..0000000
--- a/gps/libloc_api_50001/loc_eng_nmea.cpp
+++ /dev/null
@@ -1,703 +0,0 @@
-/* Copyright (c) 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_eng_nmea"
-
-#include <loc_eng.h>
-#include <loc_eng_nmea.h>
-#include <math.h>
-#include "log_util.h"
-
-/*===========================================================================
-FUNCTION loc_eng_nmea_send
-
-DESCRIPTION
- send out NMEA sentence
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- Total length of the nmea sentence
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p)
-{
- struct timeval tv;
- gettimeofday(&tv, (struct timezone *) NULL);
- int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
- CALLBACK_LOG_CALLFLOW("nmea_cb", %p, pNmea);
- loc_eng_data_p->nmea_cb(now, pNmea, length);
- LOC_LOGD("NMEA <%s", pNmea);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_nmea_put_checksum
-
-DESCRIPTION
- Generate NMEA sentences generated based on position report
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- Total length of the nmea sentence
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_nmea_put_checksum(char *pNmea, int maxSize)
-{
- uint8_t checksum = 0;
- int length = 0;
-
- pNmea++; //skip the $
- while (*pNmea != '\0')
- {
- checksum ^= *pNmea++;
- length++;
- }
-
- int checksumLength = snprintf(pNmea, maxSize,"*%02X\r\n", checksum);
- return (length + checksumLength);
-}
-
-/*===========================================================================
-FUNCTION loc_eng_nmea_generate_pos
-
-DESCRIPTION
- Generate NMEA sentences generated based on position report
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
- const GpsLocation &location, const GpsLocationExtended &locationExtended)
-{
- ENTRY_LOG();
-
- char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
- char* pMarker = sentence;
- int lengthRemaining = sizeof(sentence);
- int length = 0;
-
- time_t utcTime(location.timestamp/1000);
- tm * pTm = gmtime(&utcTime);
- int utcYear = pTm->tm_year % 100; // 2 digit year
- int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero
- int utcDay = pTm->tm_mday;
- int utcHours = pTm->tm_hour;
- int utcMinutes = pTm->tm_min;
- int utcSeconds = pTm->tm_sec;
-
- // ------------------
- // ------$GPGSA------
- // ------------------
-
- uint32_t svUsedCount = 0;
- uint32_t svUsedList[32] = {0};
- uint32_t mask = loc_eng_data_p->sv_used_mask;
- for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++)
- {
- if (mask & 1)
- svUsedList[svUsedCount++] = i;
- mask = mask >> 1;
- }
- // clear the cache so they can't be used again
- loc_eng_data_p->sv_used_mask = 0;
-
- char fixType;
- if (svUsedCount == 0)
- fixType = '1'; // no fix
- else if (svUsedCount <= 3)
- fixType = '2'; // 2D fix
- else
- fixType = '3'; // 3D fix
-
- length = snprintf(pMarker, lengthRemaining, "$GPGSA,A,%c,", fixType);
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence
- {
- if (i < svUsedCount)
- length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]);
- else
- length = snprintf(pMarker, lengthRemaining, ",");
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
- }
-
- if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
- { // dop is in locationExtended, (QMI)
- length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
- locationExtended.pdop,
- locationExtended.hdop,
- locationExtended.vdop);
- }
- else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
- { // dop was cached from sv report (RPC)
- length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
- loc_eng_data_p->pdop,
- loc_eng_data_p->hdop,
- loc_eng_data_p->vdop);
- }
- else
- { // no dop
- length = snprintf(pMarker, lengthRemaining, ",,");
- }
-
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
-
- // ------------------
- // ------$GPVTG------
- // ------------------
-
- pMarker = sentence;
- lengthRemaining = sizeof(sentence);
-
- if (location.flags & GPS_LOCATION_HAS_BEARING)
- {
- float magTrack = location.bearing;
- if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
- {
- float magTrack = location.bearing - locationExtended.magneticDeviation;
- if (magTrack < 0.0)
- magTrack += 360.0;
- else if (magTrack > 360.0)
- magTrack -= 360.0;
- }
-
- length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.bearing, magTrack);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining, "$GPVTG,,T,,M,");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (location.flags & GPS_LOCATION_HAS_SPEED)
- {
- float speedKnots = location.speed * (3600.0/1852.0);
- float speedKmPerHour = location.speed * 3.6;
-
- length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining, ",N,,K,");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (!(location.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)
- length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
- else
- length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
-
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
-
- // ------------------
- // ------$GPRMC------
- // ------------------
-
- pMarker = sentence;
- lengthRemaining = sizeof(sentence);
-
- length = snprintf(pMarker, lengthRemaining, "$GPRMC,%02d%02d%02d,A," ,
- utcHours, utcMinutes, utcSeconds);
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (location.flags & GPS_LOCATION_HAS_LAT_LONG)
- {
- double latitude = location.latitude;
- double longitude = location.longitude;
- char latHemisphere;
- char lonHemisphere;
- double latMinutes;
- double lonMinutes;
-
- if (latitude > 0)
- {
- latHemisphere = 'N';
- }
- else
- {
- latHemisphere = 'S';
- latitude *= -1.0;
- }
-
- if (longitude < 0)
- {
- lonHemisphere = 'W';
- longitude *= -1.0;
- }
- else
- {
- lonHemisphere = 'E';
- }
-
- latMinutes = fmod(latitude * 60.0 , 60.0);
- lonMinutes = fmod(longitude * 60.0 , 60.0);
-
- length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
- (uint8_t)floor(latitude), latMinutes, latHemisphere,
- (uint8_t)floor(longitude),lonMinutes, lonHemisphere);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining,",,,,");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (location.flags & GPS_LOCATION_HAS_SPEED)
- {
- float speedKnots = location.speed * (3600.0/1852.0);
- length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining, ",");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (location.flags & GPS_LOCATION_HAS_BEARING)
- {
- length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.bearing);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining, ",");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- length = snprintf(pMarker, lengthRemaining, "%2.2d%2.2d%2.2d,",
- utcDay, utcMonth, utcYear);
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
- {
- float magneticVariation = locationExtended.magneticDeviation;
- char direction;
- if (magneticVariation < 0.0)
- {
- direction = 'W';
- magneticVariation *= -1.0;
- }
- else
- {
- direction = 'E';
- }
-
- length = snprintf(pMarker, lengthRemaining, "%.1lf,%c,",
- magneticVariation, direction);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining, ",,");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (!(location.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)
- length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
- else
- length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
-
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
-
- // ------------------
- // ------$GPGGA------
- // ------------------
-
- pMarker = sentence;
- lengthRemaining = sizeof(sentence);
-
- length = snprintf(pMarker, lengthRemaining, "$GPGGA,%02d%02d%02d," ,
- utcHours, utcMinutes, utcSeconds);
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (location.flags & GPS_LOCATION_HAS_LAT_LONG)
- {
- double latitude = location.latitude;
- double longitude = location.longitude;
- char latHemisphere;
- char lonHemisphere;
- double latMinutes;
- double lonMinutes;
-
- if (latitude > 0)
- {
- latHemisphere = 'N';
- }
- else
- {
- latHemisphere = 'S';
- latitude *= -1.0;
- }
-
- if (longitude < 0)
- {
- lonHemisphere = 'W';
- longitude *= -1.0;
- }
- else
- {
- lonHemisphere = 'E';
- }
-
- latMinutes = fmod(latitude * 60.0 , 60.0);
- lonMinutes = fmod(longitude * 60.0 , 60.0);
-
- length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
- (uint8_t)floor(latitude), latMinutes, latHemisphere,
- (uint8_t)floor(longitude),lonMinutes, lonHemisphere);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining,",,,,");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- char gpsQuality;
- if (!(location.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)
- gpsQuality = '1'; // 1 means GPS fix
- else
- gpsQuality = '2'; // 2 means DGPS fix
-
- if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
- { // dop is in locationExtended, (QMI)
- length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
- gpsQuality, svUsedCount, locationExtended.hdop);
- }
- else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
- { // dop was cached from sv report (RPC)
- length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
- gpsQuality, svUsedCount, loc_eng_data_p->hdop);
- }
- else
- { // no hdop
- length = snprintf(pMarker, lengthRemaining, "%c,%02d,,",
- gpsQuality, svUsedCount);
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)
- {
- length = snprintf(pMarker, lengthRemaining, "%.1lf,M,",
- locationExtended.altitudeMeanSeaLevel);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining,",,");
- }
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if ((location.flags & GPS_LOCATION_HAS_ALTITUDE) &&
- (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL))
- {
- length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,",
- location.altitude - locationExtended.altitudeMeanSeaLevel);
- }
- else
- {
- length = snprintf(pMarker, lengthRemaining,",,,");
- }
-
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
-
- // clear the dop cache so they can't be used again
- loc_eng_data_p->pdop = 0;
- loc_eng_data_p->hdop = 0;
- loc_eng_data_p->vdop = 0;
-
- EXIT_LOG(%d, 0);
-}
-
-
-
-/*===========================================================================
-FUNCTION loc_eng_nmea_generate_sv
-
-DESCRIPTION
- Generate NMEA sentences generated based on sv report
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p,
- const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended)
-{
- ENTRY_LOG();
-
- char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
- char* pMarker = sentence;
- int lengthRemaining = sizeof(sentence);
- int length = 0;
-
- // ------------------
- // ------$GPGSV------
- // ------------------
-
- if (svStatus.num_svs <= 0)
- {
- // no svs in view, so just send a blank $GPGSV sentence
- strlcpy(sentence, "$GPGSV,1,1,0,", sizeof(sentence));
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
- }
- else
- {
- int svCount = svStatus.num_svs;
- int sentenceCount = svCount / 4;
- if (svStatus.num_svs % 4)
- sentenceCount++;
- int sentenceNumber = 1;
- int svNumber = 1;
-
- while (sentenceNumber <= sentenceCount)
- {
- pMarker = sentence;
- lengthRemaining = sizeof(sentence);
-
- length = snprintf(pMarker, lengthRemaining, "$GPGSV,%d,%d,%02d",
- sentenceCount, sentenceNumber, svCount);
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- for (int i=0; (svNumber <= svCount) && (i < 4); i++, svNumber++)
- {
- length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,",
- svStatus.sv_list[svNumber-1].prn,
- (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int
- (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
-
- if (svStatus.sv_list[svNumber-1].snr > 0)
- {
- length = snprintf(pMarker, lengthRemaining,"%02d",
- (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int
-
- if (length < 0 || length >= lengthRemaining)
- {
- LOC_LOGE("NMEA Error in string formatting");
- return;
- }
- pMarker += length;
- lengthRemaining -= length;
- }
- }
-
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
- sentenceNumber++;
-
- }
- }
-
- if (svStatus.used_in_fix_mask == 0)
- { // No sv used, so there will be no position report, so send
- // blank NMEA sentences
- strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence));
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
-
- strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence));
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
-
- strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence));
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
-
- strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence));
- length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
- loc_eng_nmea_send(sentence, length, loc_eng_data_p);
- }
- else
- { // cache the used in fix mask, as it will be needed to send $GPGSA
- // during the position report
- loc_eng_data_p->sv_used_mask = svStatus.used_in_fix_mask;
-
- // For RPC, the DOP are sent during sv report, so cache them
- // now to be sent during position report.
- // For QMI, the DOP will be in position report.
- if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
- {
- loc_eng_data_p->pdop = locationExtended.pdop;
- loc_eng_data_p->hdop = locationExtended.hdop;
- loc_eng_data_p->vdop = locationExtended.vdop;
- }
- else
- {
- loc_eng_data_p->pdop = 0;
- loc_eng_data_p->hdop = 0;
- loc_eng_data_p->vdop = 0;
- }
-
- }
-
- EXIT_LOG(%d, 0);
-}
diff --git a/gps/libloc_api_50001/loc_eng_xtra.cpp b/gps/libloc_api_50001/loc_eng_xtra.cpp
deleted file mode 100644
index b8d9218..0000000
--- a/gps/libloc_api_50001/loc_eng_xtra.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright (c) 2009,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.
- *
- */
-
-#define LOG_NDDEBUG 0
-#define LOG_TAG "LocSvc_eng"
-
-#include <loc_eng.h>
-#include <loc_eng_msg.h>
-#include "log_util.h"
-
-
-/*===========================================================================
-FUNCTION loc_eng_xtra_init
-
-DESCRIPTION
- Initialize XTRA module.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
- GpsXtraCallbacks* callbacks)
-{
- int ret_val = -1;
- loc_eng_xtra_data_s_type *xtra_module_data_ptr;
-
- if(callbacks == NULL)
- LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL");
- else {
- xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
- xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
- ret_val = 0;
- }
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_xtra_inject_data
-
-DESCRIPTION
- Injects XTRA file into the engine but buffers the data if engine is busy.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0: success
- >0: failure
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-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);
-
- return 0;
-}
diff --git a/gps/loc_api/Android.mk b/gps/loc_api/Android.mk
new file mode 100644
index 0000000..8bfdd1b
--- /dev/null
+++ b/gps/loc_api/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+# add RPC dirs if RPC is available
+ifneq ($(TARGET_NO_RPC),true)
+
+GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc-50001/
+
+endif #TARGET_NO_RPC
+
+GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api_50001/
+
+#call the subfolders
+include $(addsuffix Android.mk, $(GPS_DIR_LIST))
diff --git a/gps/NOTICE b/gps/loc_api/NOTICE
index 85b5740..85b5740 100644
--- a/gps/NOTICE
+++ b/gps/loc_api/NOTICE
diff --git a/gps/libloc_api_50001/Android.mk b/gps/loc_api/libloc_api_50001/Android.mk
index 063737a..75a5d2a 100644
--- a/gps/libloc_api_50001/Android.mk
+++ b/gps/loc_api/libloc_api_50001/Android.mk
@@ -1,61 +1,21 @@
ifneq ($(BUILD_TINY_ANDROID),true)
-
-ifeq ($(BOARD_GPS_SET_PRIVACY),true)
-LOCAL_CFLAGS += -DSET_PRIVACY
-endif
+#Compile this library only for builds with the latest modem image
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := libloc_adapter
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libcutils \
- libgps.utils \
- libdl
-
-LOCAL_SRC_FILES += \
- loc_eng_log.cpp \
- LocApiAdapter.cpp
-
-LOCAL_CFLAGS += \
- -fno-short-enums \
- -D_ANDROID_ \
- -DNEW_QC_GPS
-
-LOCAL_C_INCLUDES:= \
- $(TARGET_OUT_HEADERS)/gps.utils
-
-LOCAL_COPY_HEADERS_TO:= libloc_eng/
-LOCAL_COPY_HEADERS:= \
- LocApiAdapter.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)
-
-include $(CLEAR_VARS)
-
LOCAL_MODULE := libloc_eng
+LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
- libloc_adapter \
+ libdl \
+ liblog \
+ libloc_core \
libgps.utils
LOCAL_SRC_FILES += \
@@ -64,9 +24,8 @@ LOCAL_SRC_FILES += \
loc_eng_xtra.cpp \
loc_eng_ni.cpp \
loc_eng_log.cpp \
- loc_eng_nmea.cpp
-
-LOCAL_CFLAGS += -DFEATURE_GNSS_BIT_API
+ loc_eng_nmea.cpp \
+ LocEngAdapter.cpp
LOCAL_SRC_FILES += \
loc_eng_dmn_conn.cpp \
@@ -77,12 +36,23 @@ LOCAL_SRC_FILES += \
LOCAL_CFLAGS += \
-fno-short-enums \
- -D_ANDROID_ \
- -DNEW_QC_GPS
+ -D_ANDROID_
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
- $(LOCAL_PATH)/../ulp/inc
+ $(TARGET_OUT_HEADERS)/libloc_core \
+ device/samsung/jf-common/gps/loc_api/libloc_api_50001
+
+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_log.h
LOCAL_PRELINK_MODULE := false
@@ -91,6 +61,7 @@ include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gps.default
+LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_TAGS := optional
@@ -99,7 +70,9 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
+ liblog \
libloc_eng \
+ libloc_core \
libgps.utils \
libdl
@@ -110,12 +83,15 @@ LOCAL_SRC_FILES += \
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_ \
- -DNEW_QC_GPS
+
+ifeq ($(TARGET_USES_QCOM_BSP), true)
+LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP
+endif
## Includes
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
- $(LOCAL_PATH)/../ulp/inc
+ $(TARGET_OUT_HEADERS)/libloc_core
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp
new file mode 100644
index 0000000..3d015cb
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp
@@ -0,0 +1,343 @@
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * 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;
+
+LocInternalAdapter::LocInternalAdapter(LocEngAdapter* adapter) :
+ LocAdapterBase(adapter->getMsgTask()),
+ mLocEngAdapter(adapter)
+{
+}
+void LocInternalAdapter::setPositionModeInt(LocPosMode& posMode) {
+ sendMsg(new LocEngPositionMode(mLocEngAdapter, posMode));
+}
+void LocInternalAdapter::startFixInt() {
+ sendMsg(new LocEngStartFix(mLocEngAdapter));
+}
+void LocInternalAdapter::stopFixInt() {
+ sendMsg(new LocEngStopFix(mLocEngAdapter));
+}
+void LocInternalAdapter::getZppInt() {
+ sendMsg(new LocEngGetZpp(mLocEngAdapter));
+}
+
+LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
+ void* owner, ContextBase* context,
+ MsgTask::tCreate tCreator) :
+ LocAdapterBase(mask,
+ //Get the AFW context if VzW context has not already been intialized in
+ //loc_ext
+ context == NULL?
+ LocDualContext::getLocFgContext(tCreator,
+ LocDualContext::mLocationHalName)
+ :context),
+ mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)),
+ mUlp(new UlpProxyBase()), mNavigating(false),
+ mSupportsAgpsRequests(false),
+ mSupportsPositionInjection(false)
+{
+ memset(&mFixCriteria, 0, sizeof(mFixCriteria));
+ mFixCriteria.mode = LOC_POSITION_MODE_INVALID;
+ LOC_LOGD("LocEngAdapter created");
+}
+
+inline
+LocEngAdapter::~LocEngAdapter()
+{
+ delete mInternalAdapter;
+ LOC_LOGV("LocEngAdapter deleted");
+}
+
+void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
+ struct LocSetUlpProxy : public LocMsg {
+ LocAdapterBase* mAdapter;
+ UlpProxyBase* mUlp;
+ inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) :
+ LocMsg(), mAdapter(adapter), mUlp(ulp) {
+ }
+ virtual void proc() const {
+ LOC_LOGV("%s] ulp %p adapter %p", __func__,
+ mUlp, mAdapter);
+ mAdapter->setUlpProxy(mUlp);
+ }
+ };
+
+ sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp));
+}
+
+void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
+{
+ if (ulp == mUlp) {
+ //This takes care of the case when double initalization happens
+ //and we get the same object back for UlpProxyBase . Do nothing
+ return;
+ }
+
+ LOC_LOGV("%s] %p", __func__, ulp);
+ if (NULL == ulp) {
+ LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__);
+ ulp = new UlpProxyBase();
+ }
+
+ if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) {
+ // need to send this mode and start msg to ULP
+ ulp->sendFixMode(mUlp->mPosMode);
+ }
+
+ if(mUlp->mFixSet) {
+ ulp->sendStartFix();
+ }
+
+ delete mUlp;
+ mUlp = ulp;
+}
+
+void LocInternalAdapter::reportPosition(UlpLocation &location,
+ GpsLocationExtended &locationExtended,
+ void* locationExt,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask)
+{
+ sendMsg(new LocEngReportPosition(mLocEngAdapter,
+ location,
+ locationExtended,
+ locationExt,
+ status,
+ loc_technology_mask));
+}
+
+
+void LocEngAdapter::reportPosition(UlpLocation &location,
+ GpsLocationExtended &locationExtended,
+ void* locationExt,
+ enum loc_sess_status status,
+ LocPosTechMask loc_technology_mask)
+{
+ if (! mUlp->reportPosition(location,
+ locationExtended,
+ locationExt,
+ status,
+ loc_technology_mask )) {
+ mInternalAdapter->reportPosition(location,
+ locationExtended,
+ locationExt,
+ status,
+ loc_technology_mask);
+ }
+}
+
+void LocInternalAdapter::reportSv(GpsSvStatus &svStatus,
+ GpsLocationExtended &locationExtended,
+ void* svExt){
+ sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus,
+ locationExtended, svExt));
+}
+
+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 (! mUlp->reportSv(svStatus, locationExtended, svExt)) {
+ mInternalAdapter->reportSv(svStatus, locationExtended, svExt);
+ }
+}
+
+
+void LocEngAdapter::reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet)
+{
+ // We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary.
+ if (! mUlp->reportSvMeasurement(svMeasurementSet)) {
+ //Send to Internal Adapter later if needed by LA
+ }
+}
+
+void LocEngAdapter::reportSvPolynomial(GnssSvPolynomial &svPolynomial)
+{
+ // We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary.
+ if (! mUlp->reportSvPolynomial(svPolynomial)) {
+ //Send to Internal Adapter later if needed by LA
+ }
+}
+
+void LocEngAdapter::setInSession(bool inSession)
+{
+ mNavigating = inSession;
+ mLocApi->setInSession(inSession);
+ if (!mNavigating) {
+ mFixCriteria.mode = LOC_POSITION_MODE_INVALID;
+ }
+}
+
+void LocInternalAdapter::reportStatus(GpsStatusValue status)
+{
+ sendMsg(new LocEngReportStatus(mLocEngAdapter, status));
+}
+
+void LocEngAdapter::reportStatus(GpsStatusValue status)
+{
+ if (!mUlp->reportStatus(status)) {
+ mInternalAdapter->reportStatus(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 (mSupportsAgpsRequests) {
+ sendMsg(new LocEngReportXtraServer(mOwner, url1,
+ url2, url3, maxlength));
+ }
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type)
+{
+ if (mSupportsAgpsRequests) {
+ sendMsg(new LocEngRequestATL(mOwner,
+ connHandle, agps_type));
+ }
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::releaseATL(int connHandle)
+{
+ if (mSupportsAgpsRequests) {
+ sendMsg(new LocEngReleaseATL(mOwner, connHandle));
+ }
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::requestXtraData()
+{
+ if (mSupportsAgpsRequests) {
+ sendMsg(new LocEngRequestXtra(mOwner));
+ }
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::requestTime()
+{
+ if (mSupportsAgpsRequests) {
+ sendMsg(new LocEngRequestTime(mOwner));
+ }
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::requestNiNotify(GpsNiNotification &notif, const void* data)
+{
+ if (mSupportsAgpsRequests) {
+ notif.size = sizeof(notif);
+ notif.timeout = LOC_NI_NO_RESPONSE_TIME;
+
+ sendMsg(new LocEngRequestNi(mOwner, notif, data));
+ }
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::requestSuplES(int connHandle)
+{
+ if (mSupportsAgpsRequests)
+ sendMsg(new LocEngRequestSuplEs(mOwner, connHandle));
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::reportDataCallOpened()
+{
+ if(mSupportsAgpsRequests)
+ sendMsg(new LocEngSuplEsOpened(mOwner));
+ return mSupportsAgpsRequests;
+}
+
+inline
+bool LocEngAdapter::reportDataCallClosed()
+{
+ if(mSupportsAgpsRequests)
+ sendMsg(new LocEngSuplEsClosed(mOwner));
+ return mSupportsAgpsRequests;
+}
+
+inline
+void LocEngAdapter::handleEngineDownEvent()
+{
+ sendMsg(new LocEngDown(mOwner));
+}
+
+inline
+void LocEngAdapter::handleEngineUpEvent()
+{
+ sendMsg(new LocEngUp(mOwner));
+}
+
+enum loc_api_adapter_err LocEngAdapter::setXtraVersionCheck(int check)
+{
+ enum loc_api_adapter_err ret;
+ ENTRY_LOG();
+ enum xtra_version_check eCheck;
+ switch (check) {
+ case 0:
+ eCheck = DISABLED;
+ case 1:
+ eCheck = AUTO;
+ case 2:
+ eCheck = XTRA2;
+ case 3:
+ eCheck = XTRA3;
+ defaul:
+ eCheck = DISABLED;
+ }
+ ret = mLocApi->setXtraVersionCheck(eCheck);
+ EXIT_LOG(%d, ret);
+ return ret;
+}
diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.h b/gps/loc_api/libloc_api_50001/LocEngAdapter.h
new file mode 100644
index 0000000..01726d2
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -0,0 +1,306 @@
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * 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 <UlpProxyBase.h>
+#include <platform_lib_includes.h>
+
+#define MAX_URL_LEN 256
+
+using namespace loc_core;
+
+class LocEngAdapter;
+
+class LocInternalAdapter : public LocAdapterBase {
+ LocEngAdapter* mLocEngAdapter;
+public:
+ LocInternalAdapter(LocEngAdapter* adapter);
+
+ 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 setPositionModeInt(LocPosMode& posMode);
+ virtual void startFixInt();
+ virtual void stopFixInt();
+ virtual void getZppInt();
+ virtual void setUlpProxy(UlpProxyBase* ulp);
+};
+
+typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp);
+
+class LocEngAdapter : public LocAdapterBase {
+ void* mOwner;
+ LocInternalAdapter* mInternalAdapter;
+ UlpProxyBase* mUlp;
+ LocPosMode mFixCriteria;
+ bool mNavigating;
+
+public:
+ bool mSupportsAgpsRequests;
+ bool mSupportsPositionInjection;
+
+ LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
+ void* owner,ContextBase* context,
+ MsgTask::tCreate tCreator);
+ virtual ~LocEngAdapter();
+
+ virtual void setUlpProxy(UlpProxyBase* ulp);
+ inline void requestUlp(unsigned long capabilities) {
+ mContext->requestUlp(mInternalAdapter, capabilities);
+ }
+ inline LocInternalAdapter* getInternalAdapter() { return mInternalAdapter; }
+ inline UlpProxyBase* getUlpProxy() { return mUlp; }
+ inline void* getOwner() { return mOwner; }
+ inline bool hasAgpsExtendedCapabilities() {
+ return mContext->hasAgpsExtendedCapabilities();
+ }
+ inline bool hasCPIExtendedCapabilities() {
+ return mContext->hasCPIExtendedCapabilities();
+ }
+ inline const MsgTask* getMsgTask() { return mMsgTask; }
+
+ 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, int sensorProvider)
+ {
+ return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider);
+ }
+ 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();
+ }
+ inline enum loc_api_adapter_err
+ getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask)
+ {
+ return mLocApi->getZppFix(zppLoc, tech_mask);
+ }
+ enum loc_api_adapter_err setXtraVersionCheck(int check);
+ 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 reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
+ virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
+ 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 &notify, 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; }
+ void setInSession(bool inSession);
+
+ /*Values for lock
+ 1 = Do not lock any position sessions
+ 2 = Lock MI position sessions
+ 3 = Lock MT position sessions
+ 4 = Lock all position sessions
+ */
+ inline int setGpsLock(unsigned int lock)
+ {
+ return mLocApi->setGpsLock(lock);
+ }
+ /*
+ Returns
+ Current value of GPS lock on success
+ -1 on failure
+ */
+ inline int getGpsLock()
+ {
+ return mLocApi->getGpsLock();
+ }
+
+};
+
+#endif //LOC_API_ENG_ADAPTER_H
diff --git a/gps/loc_api/libloc_api_50001/Makefile.am b/gps/loc_api/libloc_api_50001/Makefile.am
new file mode 100644
index 0000000..2374357
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/Makefile.am
@@ -0,0 +1,76 @@
+AM_CFLAGS = \
+ -I../../utils \
+ -I../../platform_lib_abstractions \
+ -fno-short-enums \
+ -DFEATURE_GNSS_BIT_API
+
+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@
+libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS)
+libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la
+
+
+libloc_eng_so_la_SOURCES = \
+ loc_eng.cpp \
+ loc_eng_agps.cpp \
+ loc_eng_xtra.cpp \
+ loc_eng_ni.cpp \
+ loc_eng_log.cpp \
+ loc_eng_dmn_conn.cpp \
+ loc_eng_dmn_conn_handler.cpp \
+ loc_eng_dmn_conn_thread_helper.c \
+ loc_eng_dmn_conn_glue_msg.c \
+ loc_eng_dmn_conn_glue_pipe.c
+
+
+if USE_GLIB
+libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
+libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libloc_eng_so_la_CFLAGS = $(AM_CFLAGS)
+libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+
+libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la
+
+
+libgps_default_so_la_SOURCES = \
+ loc.cpp \
+ gps.c
+
+if USE_GLIB
+libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
+libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libgps_default_so_la_CFLAGS = $(AM_CFLAGS)
+libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+
+libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la
+
+library_include_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_log.h
+
+library_includedir = $(pkgincludedir)/libloc_api_50001
+
+#Create and Install libraries
+lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la
diff --git a/gps/libloc_api_50001/gps.c b/gps/loc_api/libloc_api_50001/gps.c
index 82bc742..87aca3d 100644
--- a/gps/libloc_api_50001/gps.c
+++ b/gps/loc_api/libloc_api_50001/gps.c
@@ -27,7 +27,7 @@
*
*/
-#include <hardware/gps.h>
+#include "hardware/gps.h"
#include <stdlib.h>
@@ -42,6 +42,10 @@ static int open_gps(const struct hw_module_t* module, char const* name,
struct hw_device_t** device)
{
struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t));
+
+ if(dev == NULL)
+ return -1;
+
memset(dev, 0, sizeof(*dev));
dev->common.tag = HARDWARE_DEVICE_TAG;
diff --git a/gps/libloc_api_50001/loc.cpp b/gps/loc_api/libloc_api_50001/loc.cpp
index 262a761..3708eb2 100755..100644
--- a/gps/libloc_api_50001/loc.cpp
+++ b/gps/loc_api/libloc_api_50001/loc.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 - 2012, 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -30,27 +30,31 @@
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_afw"
-#include <hardware/gps.h>
+#include "hardware/gps.h"
+#include <gps_extended.h>
#include <loc_eng.h>
#include <loc_target.h>
#include <loc_log.h>
-#include <msg_q.h>
+#include <fcntl.h>
+#include <errno.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
-
+#include <LocDualContext.h>
#include <cutils/properties.h>
+using namespace loc_core;
+
//Globals defns
-static const ulpInterface * loc_eng_ulp_inf = NULL;
-static const ulpInterface * loc_eng_get_ulp_inf(void);
static gps_location_callback gps_loc_cb = NULL;
static gps_sv_status_callback gps_sv_cb = NULL;
-static void loc_cb(GpsLocation* location, void* locExt);
-static void sv_cb(GpsSvStatus* sv_status, void* svExt);
+static void local_loc_cb(UlpLocation* location, void* locExt);
+static void local_sv_cb(GpsSvStatus* sv_status, void* svExt);
+
+static const GpsGeofencingInterface* get_geofence_interface(void);
// Function declarations for sLocEngInterface
static int loc_init(GpsCallbacks* callbacks);
@@ -64,12 +68,6 @@ static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence re
uint32_t min_interval, uint32_t preferred_accuracy,
uint32_t preferred_time);
static const void* loc_get_extension(const char* name);
-//ULP/Hybrid provider Function definitions
-static int loc_update_criteria(UlpLocationCriteria criteria);
-static int loc_ulp_network_init(UlpNetworkLocationCallbacks *callbacks);
-static int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report);
-static int loc_ulp_phone_context_init(UlpPhoneContextCallbacks *callback);
-static int loc_ulp_phone_context_settings_update(UlpPhoneContextSettings *settings);
// Defines the GpsInterface in gps.h
static const GpsInterface sLocEngInterface =
@@ -83,16 +81,14 @@ static const GpsInterface sLocEngInterface =
loc_inject_location,
loc_delete_aiding_data,
loc_set_position_mode,
- loc_get_extension,
- loc_update_criteria
+ loc_get_extension
};
// Function declarations for sLocEngAGpsInterface
static void loc_agps_init(AGpsCallbacks* callbacks);
-static int loc_agps_open(AGpsType agpsType,
- const char* apn, AGpsBearerType bearerType);
-static int loc_agps_closed(AGpsType agpsType);
-static int loc_agps_open_failed(AGpsType agpsType);
+static int loc_agps_open(const char* apn);
+static int loc_agps_closed();
+static int loc_agps_open_failed();
static int loc_agps_set_server(AGpsType type, const char *hostname, int port);
static const AGpsInterface sLocEngAGpsInterface =
@@ -143,29 +139,8 @@ static const AGpsRilInterface sLocEngAGpsRilInterface =
loc_agps_ril_update_network_availability
};
-static bool loc_inject_raw_command(char* command, int length);
-
-static const InjectRawCmdInterface sLocEngInjectRawCmdInterface =
-{
- sizeof(InjectRawCmdInterface),
- loc_inject_raw_command
-};
-
-//ULP/Hybrid provider interfaces
-static const UlpNetworkInterface sUlpNetworkInterface =
-{
- sizeof(UlpNetworkInterface),
- loc_ulp_network_init,
- loc_ulp_send_network_position
-};
-static const UlpPhoneContextInterface sLocEngUlpPhoneContextInterface =
-{
- sizeof(UlpPhoneContextInterface),
- loc_ulp_phone_context_init,
- loc_ulp_phone_context_settings_update
-};
static loc_eng_data_s_type loc_afw_data;
-static int gss_fd = 0;
+static int gss_fd = -1;
/*===========================================================================
FUNCTION gps_get_hardware_interface
@@ -191,6 +166,8 @@ const GpsInterface* gps_get_hardware_interface ()
char propBuf[PROPERTY_VALUE_MAX];
+ loc_eng_read_config();
+
// check to see if GPS should be disabled
property_get("gps.disable", propBuf, "");
if (propBuf[0] == '1')
@@ -201,6 +178,8 @@ const GpsInterface* gps_get_hardware_interface ()
ret_val = &sLocEngInterface;
}
+ loc_eng_read_config();
+
EXIT_LOG(%p, ret_val);
return ret_val;
}
@@ -208,45 +187,41 @@ const GpsInterface* gps_get_hardware_interface ()
// for gps.c
extern "C" const GpsInterface* get_gps_interface()
{
- targetEnumType target = TARGET_OTHER;
+ unsigned int target = TARGET_DEFAULT;
loc_eng_read_config();
- //We load up libulp module at this point itself if ULP configured to be On
- if(gps_conf.CAPABILITIES & ULP_CAPABILITY) {
- loc_eng_ulp_inf = loc_eng_get_ulp_inf();
- }
- target = get_target();
+ target = loc_get_target();
LOC_LOGD("Target name check returned %s", loc_get_target_name(target));
- //APQ8064
- if(target == TARGET_APQ8064_STANDALONE) {
+
+ int gnssType = getTargetGnssType(target);
+ switch (gnssType)
+ {
+ case GNSS_GSS:
+ case GNSS_AUTO:
+ //APQ8064
gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
gss_fd = open("/dev/gss", O_RDONLY);
- if (gss_fd < 0)
+ if (gss_fd < 0) {
LOC_LOGE("GSS open failed: %s\n", strerror(errno));
+ }
else {
- LOC_LOGD("GSS open success! CAPABILITIES %0lx\n", gps_conf.CAPABILITIES);
+ LOC_LOGD("GSS open success! CAPABILITIES %0lx\n",
+ gps_conf.CAPABILITIES);
}
- }
- //MPQ8064
- else if(target == TARGET_MPQ8064) {
- LOC_LOGE("No GPS HW on this target (MPQ8064). Not returning interface");
+ break;
+ case GNSS_NONE:
+ //MPQ8064
+ LOC_LOGE("No GPS HW on this target. Not returning interface.");
return NULL;
+ case GNSS_QCA1530:
+ // qca1530 chip is present
+ gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
+ LOC_LOGD("qca1530 present: CAPABILITIES %0lx\n", gps_conf.CAPABILITIES);
+ break;
}
return &sLocEngInterface;
}
-static void loc_free_msg(void* msg)
-{
- delete (loc_eng_msg*)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);
-}
-
/*===========================================================================
FUNCTION loc_init
@@ -267,24 +242,37 @@ SIDE EFFECTS
static int loc_init(GpsCallbacks* callbacks)
{
int retVal = -1;
+ unsigned int target = (unsigned int) -1;
+ LOC_API_ADAPTER_EVENT_MASK_T event;
ENTRY_LOG();
- if(callbacks == NULL) {
+
+ if (NULL == callbacks) {
LOC_LOGE("loc_init failed. cb = NULL\n");
EXIT_LOG(%d, retVal);
return retVal;
}
- LOC_API_ADAPTER_EVENT_MASK_T 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 |
- 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;
- LocCallbacks clientCallbacks = {loc_cb, /* location_cb */
+
+ 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 |
+ 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;
+
+ target = loc_get_target();
+
+ /*For "auto" platform enable Measurement report and SV Polynomial report*/
+ if(GNSS_AUTO == getTargetGnssType(target))
+ {
+ event |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT_REPORT |
+ LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT;
+ }
+
+ LocCallbacks clientCallbacks = {local_loc_cb, /* location_cb */
callbacks->status_cb, /* status_cb */
- sv_cb, /* sv_status_cb */
+ local_sv_cb, /* sv_status_cb */
callbacks->nmea_cb, /* nmea_cb */
callbacks->set_capabilities_cb, /* set_capabilities_cb */
callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */
@@ -293,17 +281,15 @@ static int loc_init(GpsCallbacks* callbacks)
NULL, /* location_ext_parser */
NULL, /* sv_ext_parser */
callbacks->request_utc_time_cb /* request_utc_time_cb */};
+
gps_loc_cb = callbacks->location_cb;
gps_sv_cb = callbacks->sv_status_cb;
- if (loc_eng_ulp_inf == NULL)
- retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event,
- NULL);
- else
- retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event,
- loc_ulp_msg_sender);
- int ret_val1 = loc_eng_ulp_init(loc_afw_data, loc_eng_ulp_inf);
- LOC_LOGD("loc_eng_ulp_init returned %d\n",ret_val1);
+ retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL);
+ loc_afw_data.adapter->requestUlp(gps_conf.CAPABILITIES);
+ loc_afw_data.adapter->mSupportsAgpsRequests = !loc_afw_data.adapter->hasAgpsExtendedCapabilities();
+ loc_afw_data.adapter->mSupportsPositionInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities();
+
EXIT_LOG(%d, retVal);
return retVal;
}
@@ -331,13 +317,14 @@ static void loc_cleanup()
gps_loc_cb = NULL;
gps_sv_cb = NULL;
- /*
- * if (get_target() == TARGET_NAME_APQ8064_STANDALONE)
- * {
- * close(gss_fd);
- * LOC_LOGD("GSS shutdown.\n");
- * }
- */
+/*
+ if (gss_fd >= 0)
+ {
+ close(gss_fd);
+ gss_fd = -1;
+ LOC_LOGD("GSS shutdown.\n");
+ }
+*/
EXIT_LOG(%s, VOID_RET);
}
@@ -386,7 +373,8 @@ SIDE EFFECTS
static int loc_stop()
{
ENTRY_LOG();
- int ret_val = loc_eng_stop(loc_afw_data);
+ int ret_val = -1;
+ ret_val = loc_eng_stop(loc_afw_data);
EXIT_LOG(%d, ret_val);
return ret_val;
@@ -415,6 +403,7 @@ static int loc_set_position_mode(GpsPositionMode mode,
uint32_t preferred_time)
{
ENTRY_LOG();
+ int ret_val = -1;
LocPositionMode locMode;
switch (mode) {
case GPS_POSITION_MODE_MS_BASED:
@@ -430,7 +419,7 @@ static int loc_set_position_mode(GpsPositionMode mode,
LocPosMode params(locMode, recurrence, min_interval,
preferred_accuracy, preferred_time, NULL, NULL);
- int ret_val = loc_eng_set_position_mode(loc_afw_data, params);
+ ret_val = loc_eng_set_position_mode(loc_afw_data, params);
EXIT_LOG(%d, ret_val);
return ret_val;
@@ -455,7 +444,11 @@ SIDE EFFECTS
static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty)
{
ENTRY_LOG();
- int ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty);
+ int ret_val = 0;
+
+ ret_val = loc_eng_inject_time(loc_afw_data, time,
+ timeReference, uncertainty);
+
EXIT_LOG(%d, ret_val);
return ret_val;
}
@@ -479,32 +472,11 @@ SIDE EFFECTS
===========================================================================*/
static int loc_inject_location(double latitude, double longitude, float accuracy)
{
- static bool initialized = false;
- static bool enable_cpi = true;
ENTRY_LOG();
- if(!initialized)
- {
- char value[PROPERTY_VALUE_MAX];
- memset(value, 0, sizeof(value));
- (void)property_get("persist.gps.qc_nlp_in_use", value, "0");
- if(0 == strcmp(value, "1"))
- {
- enable_cpi = false;
- LOC_LOGI("GPS HAL coarse position injection disabled");
- }
- else
- {
- LOC_LOGI("GPS HAL coarse position injection enabled");
- }
- initialized = true;
- }
-
int ret_val = 0;
- if(enable_cpi)
- {
- ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
- }
+ ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
+
EXIT_LOG(%d, ret_val);
return ret_val;
}
@@ -538,31 +510,39 @@ static void loc_delete_aiding_data(GpsAidingData f)
EXIT_LOG(%s, VOID_RET);
}
-/*===========================================================================
-FUNCTION loc_update_criteria
+const GpsGeofencingInterface* get_geofence_interface(void)
+{
+ ENTRY_LOG();
+ void *handle;
+ const char *error;
+ typedef const GpsGeofencingInterface* (*get_gps_geofence_interface_function) (void);
+ get_gps_geofence_interface_function get_gps_geofence_interface;
+ static const GpsGeofencingInterface* geofence_interface = NULL;
-DESCRIPTION
- This is used to inform the ULP module of new unique criteria that are passed
- in by the applications
-DEPENDENCIES
- N/A
+ dlerror(); /* Clear any existing error */
-RETURN VALUE
- 0: success
+ handle = dlopen ("libgeofence.so", RTLD_NOW);
-SIDE EFFECTS
- N/A
+ if (!handle)
+ {
+ if ((error = dlerror()) != NULL) {
+ LOC_LOGE ("%s, dlopen for libgeofence.so failed, error = %s\n", __func__, error);
+ }
+ goto exit;
+ }
+ dlerror(); /* Clear any existing error */
+ get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, "gps_geofence_get_interface");
+ if ((error = dlerror()) != NULL && NULL != get_gps_geofence_interface) {
+ LOC_LOGE ("%s, dlsym for get_gps_geofence_interface failed, error = %s\n", __func__, error);
+ goto exit;
+ }
-===========================================================================*/
-static int loc_update_criteria(UlpLocationCriteria criteria)
-{
- ENTRY_LOG();
- int ret_val = loc_eng_update_criteria(loc_afw_data, criteria);
+ geofence_interface = get_gps_geofence_interface();
- EXIT_LOG(%d, ret_val);
- return ret_val;
+exit:
+ EXIT_LOG(%d, geofence_interface == NULL);
+ return geofence_interface;
}
-
/*===========================================================================
FUNCTION loc_get_extension
@@ -579,26 +559,24 @@ SIDE EFFECTS
N/A
===========================================================================*/
-static const void* loc_get_extension(const char* name)
+const void* loc_get_extension(const char* name)
{
ENTRY_LOG();
const void* ret_val = NULL;
+ LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name);
if (strcmp(name, GPS_XTRA_INTERFACE) == 0)
{
- ret_val = &sLocEngXTRAInterface;
+ ret_val = &sLocEngXTRAInterface;
}
-
else if (strcmp(name, AGPS_INTERFACE) == 0)
{
- ret_val = &sLocEngAGpsInterface;
+ ret_val = &sLocEngAGpsInterface;
}
-
else if (strcmp(name, GPS_NI_INTERFACE) == 0)
{
- ret_val = &sLocEngNiInterface;
+ ret_val = &sLocEngNiInterface;
}
-
else if (strcmp(name, AGPS_RIL_INTERFACE) == 0)
{
char baseband[PROPERTY_VALUE_MAX];
@@ -608,20 +586,11 @@ static const void* loc_get_extension(const char* name)
ret_val = &sLocEngAGpsRilInterface;
}
}
- else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0)
- {
- ret_val = &sLocEngInjectRawCmdInterface;
- }
- else if(strcmp(name, ULP_PHONE_CONTEXT_INTERFACE) == 0)
+ else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0)
{
- ret_val = &sLocEngUlpPhoneContextInterface;
- }
- else if(strcmp(name, ULP_NETWORK_INTERFACE) == 0)
- {
- //Return a valid value for ULP Network Interface only if ULP
- //turned on in gps.conf
- if(gps_conf.CAPABILITIES & ULP_CAPABILITY)
- ret_val = &sUlpNetworkInterface;
+ if ((gps_conf.CAPABILITIES | GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES ){
+ ret_val = get_geofence_interface();
+ }
}
else
{
@@ -650,7 +619,7 @@ SIDE EFFECTS
static void loc_agps_init(AGpsCallbacks* callbacks)
{
ENTRY_LOG();
- loc_eng_agps_init(loc_afw_data, callbacks);
+ loc_eng_agps_init(loc_afw_data, (AGpsExtCallbacks*)callbacks);
EXIT_LOG(%s, VOID_RET);
}
@@ -671,10 +640,11 @@ SIDE EFFECTS
N/A
===========================================================================*/
-static int loc_agps_open(AGpsType agpsType,
- const char* apn, AGpsBearerType bearerType)
+static int loc_agps_open(const char* apn)
{
ENTRY_LOG();
+ AGpsType agpsType = AGPS_TYPE_SUPL;
+ AGpsBearerType bearerType = AGPS_APN_BEARER_IPV4;
int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType);
EXIT_LOG(%d, ret_val);
@@ -698,9 +668,10 @@ SIDE EFFECTS
N/A
===========================================================================*/
-static int loc_agps_closed(AGpsType agpsType)
+static int loc_agps_closed()
{
ENTRY_LOG();
+ AGpsType agpsType = AGPS_TYPE_SUPL;
int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType);
EXIT_LOG(%d, ret_val);
@@ -724,9 +695,10 @@ SIDE EFFECTS
N/A
===========================================================================*/
-int loc_agps_open_failed(AGpsType agpsType)
+int loc_agps_open_failed()
{
ENTRY_LOG();
+ AGpsType agpsType = AGPS_TYPE_SUPL;
int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType);
EXIT_LOG(%d, ret_val);
@@ -762,6 +734,8 @@ static int loc_agps_set_server(AGpsType type, const char* hostname, int port)
case AGPS_TYPE_C2K:
serverType = LOC_AGPS_CDMA_PDE_SERVER;
break;
+ default:
+ serverType = LOC_AGPS_SUPL_SERVER;
}
int ret_val = loc_eng_set_server_proxy(loc_afw_data, serverType, hostname, port);
@@ -770,7 +744,8 @@ static int loc_agps_set_server(AGpsType type, const char* hostname, int port)
}
/*===========================================================================
-FUNCTION loc_xtra_init
+FUNCTIONf571
+ loc_xtra_init
DESCRIPTION
Initialize XTRA module.
@@ -788,7 +763,7 @@ SIDE EFFECTS
static int loc_xtra_init(GpsXtraCallbacks* callbacks)
{
ENTRY_LOG();
- int ret_val = loc_eng_xtra_init(loc_afw_data, callbacks);
+ int ret_val = loc_eng_xtra_init(loc_afw_data, (GpsXtraExtCallbacks*)callbacks);
EXIT_LOG(%d, ret_val);
return ret_val;
@@ -843,7 +818,7 @@ SIDE EFFECTS
void loc_ni_init(GpsNiCallbacks *callbacks)
{
ENTRY_LOG();
- loc_eng_ni_init(loc_afw_data, callbacks);
+ loc_eng_ni_init(loc_afw_data,(GpsNiExtCallbacks*) callbacks);
EXIT_LOG(%s, VOID_RET);
}
@@ -901,42 +876,20 @@ static void loc_agps_ril_update_network_availability(int available, const char*
EXIT_LOG(%s, VOID_RET);
}
-/*===========================================================================
-FUNCTION loc_inject_raw_command
-
-DESCRIPTION
- This is used to send special test modem commands from the applications
- down into the HAL
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static bool loc_inject_raw_command(char* command, int length)
-{
- ENTRY_LOG();
- int ret_val = loc_eng_inject_raw_command(loc_afw_data, command, length);
- EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);
- return ret_val;
-}
-
-
-static void loc_cb(GpsLocation* location, void* locExt)
+static void local_loc_cb(UlpLocation* location, void* locExt)
{
ENTRY_LOG();
- if (NULL != gps_loc_cb && NULL != location) {
+ if (NULL != location) {
CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source);
- gps_loc_cb(location);
+
+ if (NULL != gps_loc_cb) {
+ gps_loc_cb(&location->gpsLocation);
+ }
}
EXIT_LOG(%s, VOID_RET);
}
-static void sv_cb(GpsSvStatus* sv_status, void* svExt)
+static void local_sv_cb(GpsSvStatus* sv_status, void* svExt)
{
ENTRY_LOG();
if (NULL != gps_sv_cb) {
@@ -945,156 +898,3 @@ static void sv_cb(GpsSvStatus* sv_status, void* svExt)
}
EXIT_LOG(%s, VOID_RET);
}
-/*===========================================================================
-FUNCTION loc_eng_get_ulp_inf
-
-DESCRIPTION
- This function checks if ULP is enabled, and loads the libulp2.so and
- returns its interface
-
-DEPENDENCIES
- None
-
-RETURN VALUE
- interface pointer to libulp: no error
- NULL: errors
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-const ulpInterface * loc_eng_get_ulp_inf(void)
-{
- ENTRY_LOG();
- void *handle;
- const char *error;
- get_ulp_interface* get_ulp_inf;
- const ulpInterface* loc_eng_ulpInf = NULL;
-
- if (!(gps_conf.CAPABILITIES & ULP_CAPABILITY)) {
- LOC_LOGD ("%s, ULP is not configured to be On in gps.conf\n", __func__);
- goto exit;
- }
- dlerror(); /* Clear any existing error */
-
- handle = dlopen ("libulp2.so", RTLD_NOW);
-
- if (!handle)
- {
- if ((error = dlerror()) != NULL) {
- LOC_LOGE ("%s, dlopen for libulp.so failed, error = %s\n", __func__, error);
- }
- goto exit;
- }
- dlerror(); /* Clear any existing error */
- get_ulp_inf = (get_ulp_interface*) dlsym(handle, "ulp_get_interface");
- if ((error = dlerror()) != NULL) {
- LOC_LOGE ("%s, dlsym for ulpInterface failed, error = %s\n", __func__, error);
- goto exit;
- }
-
- // Initialize the ULP interface
- loc_eng_ulpInf = get_ulp_inf();
-
-exit:
- EXIT_LOG(%d, loc_eng_ulpInf == NULL);
- return loc_eng_ulpInf;
-}
-
-/*===========================================================================
-FUNCTION loc_ulp_network_init
-
-DESCRIPTION
- Initialize the ULP network interface.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static int loc_ulp_phone_context_init(UlpPhoneContextCallbacks *callbacks)
-{
- ENTRY_LOG();
- int ret_val = loc_eng_ulp_phone_context_init(loc_afw_data, callbacks);
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-/*===========================================================================
-FUNCTION loc_ulp_phone_context_settings_update
-
-DESCRIPTION
- This is used to inform the ULP module of phone settings changes carried out
- by the users
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0: success
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-
-static int loc_ulp_phone_context_settings_update(UlpPhoneContextSettings *settings)
-{
- ENTRY_LOG();
- int ret_val = -1;
- ret_val = loc_eng_ulp_phone_context_settings_update(loc_afw_data, settings);
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_ulp_network_init
-
-DESCRIPTION
- Initialize the ULP network interface.
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static int loc_ulp_network_init(UlpNetworkLocationCallbacks *callbacks)
-{
- ENTRY_LOG();
- int ret_val = loc_eng_ulp_network_init(loc_afw_data, callbacks);
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
-
-/*===========================================================================
-FUNCTION loc_eng_ulp_send_network_position
-
-DESCRIPTION
- Ulp send data
-
-DEPENDENCIES
- NONE
-
-RETURN VALUE
- 0
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report)
-{
- ENTRY_LOG();
- int ret_val = -1;
- ret_val = loc_eng_ulp_send_network_position(loc_afw_data, position_report);
- EXIT_LOG(%d, ret_val);
- return ret_val;
-}
diff --git a/gps/libloc_api_50001/loc.h b/gps/loc_api/libloc_api_50001/loc.h
index 357ce51..c29d005 100755..100644
--- a/gps/libloc_api_50001/loc.h
+++ b/gps/loc_api/libloc_api_50001/loc.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -36,30 +36,12 @@ extern "C" {
#include <ctype.h>
#include <cutils/properties.h>
-#include <hardware/gps.h>
+#include "hardware/gps.h"
+#include <gps_extended.h>
-#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */
#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/
-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;
-
-typedef void (*loc_location_cb_ext) (GpsLocation* location, void* locExt);
+typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt);
typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt);
typedef void* (*loc_ext_parser)(void* data);
@@ -77,23 +59,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)
-
-void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gps/loc_api/libloc_api_50001/loc_eng.cpp b/gps/loc_api/libloc_api_50001/loc_eng.cpp
new file mode 100644
index 0000000..cb3dcc6
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/loc_eng.cpp
@@ -0,0 +1,2634 @@
+/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#define LOG_NDDEBUG 0
+#define LOG_TAG "LocSvc_eng"
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <ctype.h>
+#include <math.h>
+#include <pthread.h>
+#include <arpa/inet.h>
+#include <netinet/in.h> /* struct sockaddr_in */
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netdb.h>
+#include <time.h>
+#include <new>
+#include <LocEngAdapter.h>
+
+#include <cutils/sched_policy.h>
+#ifndef USE_GLIB
+#include <utils/SystemClock.h>
+#include <utils/Log.h>
+#endif /* USE_GLIB */
+
+#ifdef USE_GLIB
+#include <glib.h>
+#include <sys/syscall.h>
+#endif /* USE_GLIB */
+
+#include <string.h>
+
+#include <loc_eng.h>
+#include <loc_eng_ni.h>
+#include <loc_eng_dmn_conn.h>
+#include <loc_eng_dmn_conn_handler.h>
+#include <loc_eng_msg.h>
+#include <loc_eng_nmea.h>
+#include <msg_q.h>
+#include <loc.h>
+#include "log_util.h"
+#include "platform_lib_includes.h"
+#include "loc_core_log.h"
+#include "loc_eng_log.h"
+
+#define SUCCESS TRUE
+#define FAILURE FALSE
+
+#ifndef GPS_CONF_FILE
+#define GPS_CONF_FILE "/etc/gps.conf" //??? platform independent
+#endif
+
+#ifndef SAP_CONF_FILE
+#define SAP_CONF_FILE "/etc/sap.conf"
+#endif
+
+#define XTRA1_GPSONEXTRA "xtra1.gpsonextra.net"
+
+using namespace loc_core;
+
+boolean configAlreadyRead = false;
+unsigned int agpsStatus = 0;
+loc_gps_cfg_s_type gps_conf;
+loc_sap_cfg_s_type sap_conf;
+
+/* Parameter spec table */
+static loc_param_s_type loc_parameter_table[] =
+{
+ {"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'},
+ {"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'},
+ {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'},
+ {"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'},
+ {"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'},
+ {"GYRO_BIAS_RANDOM_WALK", &sap_conf.GYRO_BIAS_RANDOM_WALK, &sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
+ {"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
+ {"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
+ {"RATE_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
+ {"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
+ {"SENSOR_ACCEL_BATCHES_PER_SEC", &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, NULL, 'n'},
+ {"SENSOR_ACCEL_SAMPLES_PER_BATCH", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'},
+ {"SENSOR_GYRO_BATCHES_PER_SEC", &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC, NULL, 'n'},
+ {"SENSOR_GYRO_SAMPLES_PER_BATCH", &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, NULL, 'n'},
+ {"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH", &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, NULL, 'n'},
+ {"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
+ {"SENSOR_GYRO_BATCHES_PER_SEC_HIGH", &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, NULL, 'n'},
+ {"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH", &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
+ {"SENSOR_CONTROL_MODE", &sap_conf.SENSOR_CONTROL_MODE, NULL, 'n'},
+ {"SENSOR_USAGE", &sap_conf.SENSOR_USAGE, NULL, 'n'},
+ {"SENSOR_ALGORITHM_CONFIG_MASK", &sap_conf.SENSOR_ALGORITHM_CONFIG_MASK, NULL, 'n'},
+ {"QUIPC_ENABLED", &gps_conf.QUIPC_ENABLED, NULL, 'n'},
+ {"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'},
+ {"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
+ {"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'},
+ {"XTRA_VERSION_CHECK", &gps_conf.XTRA_VERSION_CHECK, NULL, 'n'},
+ {"XTRA_SERVER_1", &gps_conf.XTRA_SERVER_1, NULL, 's'},
+ {"XTRA_SERVER_2", &gps_conf.XTRA_SERVER_2, NULL, 's'},
+ {"XTRA_SERVER_3", &gps_conf.XTRA_SERVER_3, NULL, 's'}
+};
+
+static void loc_default_parameters(void)
+{
+ /*Defaults for gps.conf*/
+ gps_conf.INTERMEDIATE_POS = 0;
+ gps_conf.ACCURACY_THRES = 0;
+ gps_conf.NMEA_PROVIDER = 0;
+ gps_conf.SUPL_VER = 0x10000;
+ gps_conf.CAPABILITIES = 0x7;
+ /* LTE Positioning Profile configuration is disable by default*/
+ gps_conf.LPP_PROFILE = 0;
+ /*By default no positioning protocol is selected on A-GLONASS system*/
+ gps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
+ /*XTRA version check is disabled by default*/
+ gps_conf.XTRA_VERSION_CHECK=0;
+
+ /*Defaults for sap.conf*/
+ sap_conf.GYRO_BIAS_RANDOM_WALK = 0;
+ sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2;
+ sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5;
+ sap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2;
+ sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5;
+ sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4;
+ sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25;
+ sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4;
+ sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25;
+ sap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */
+ sap_conf.SENSOR_USAGE = 0; /* Enabled */
+ sap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/
+ /* Values MUST be set by OEMs in configuration for sensor-assisted
+ navigation to work. There are NO default values */
+ sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0;
+ sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
+ sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
+ sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0;
+ sap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0;
+ sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
+ sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
+ sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
+ sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
+ /* default provider is SSC */
+ sap_conf.SENSOR_PROVIDER = 1;
+}
+
+// 2nd half of init(), singled out for
+// modem restart to use.
+static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data);
+static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data);
+
+static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data,
+ LocServerType type, const char *hostname, int port);
+// Internal functions
+static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data,
+ GpsStatusValue status);
+static void loc_eng_report_status(loc_eng_data_s_type &loc_eng_data,
+ GpsStatusValue status);
+static void loc_eng_process_conn_request(loc_eng_data_s_type &loc_eng_data,
+ int connHandle, AGpsType agps_type);
+static void loc_eng_agps_close_status(loc_eng_data_s_type &loc_eng_data, int is_succ);
+static void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) ;
+static void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) ;
+
+static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data);
+static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data);
+static int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data);
+
+static void deleteAidingData(loc_eng_data_s_type &logEng);
+static AgpsStateMachine*
+getAgpsStateMachine(loc_eng_data_s_type& logEng, AGpsExtType agpsType);
+static int dataCallCb(void *cb_data);
+static void update_aiding_data_for_deletion(loc_eng_data_s_type& loc_eng_data) {
+ if (loc_eng_data.engine_status != GPS_STATUS_ENGINE_ON &&
+ loc_eng_data.aiding_data_for_deletion != 0)
+ {
+ loc_eng_data.adapter->deleteAidingData(loc_eng_data.aiding_data_for_deletion);
+ loc_eng_data.aiding_data_for_deletion = 0;
+ }
+}
+
+static void* noProc(void* data)
+{
+ return NULL;
+}
+
+
+/*********************************************************************
+ * definitions of the static messages used in the file
+ *********************************************************************/
+// case LOC_ENG_MSG_REQUEST_NI:
+LocEngRequestNi::LocEngRequestNi(void* locEng,
+ GpsNiNotification &notif,
+ const void* data) :
+ LocMsg(), mLocEng(locEng), mNotify(notif), mPayload(data) {
+ locallog();
+}
+void LocEngRequestNi::proc() const {
+ loc_eng_ni_request_handler(*((loc_eng_data_s_type*)mLocEng),
+ &mNotify, mPayload);
+}
+void LocEngRequestNi::locallog() const
+{
+ 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",
+ mNotify.notification_id,
+ loc_get_ni_type_name(mNotify.ni_type),
+ mNotify.notify_flags,
+ mNotify.timeout,
+ loc_get_ni_response_name(mNotify.default_response),
+ loc_get_ni_encoding_name(mNotify.requestor_id_encoding),
+ loc_get_ni_encoding_name(mNotify.text_encoding),
+ mPayload);
+}
+inline void LocEngRequestNi::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_INFORM_NI_RESPONSE:
+// in loc_eng_ni.cpp
+
+// case LOC_ENG_MSG_START_FIX:
+LocEngStartFix::LocEngStartFix(LocEngAdapter* adapter) :
+ LocMsg(), mAdapter(adapter)
+{
+ locallog();
+}
+inline void LocEngStartFix::proc() const
+{
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner();
+ loc_eng_start_handler(*locEng);
+}
+inline void LocEngStartFix::locallog() const
+{
+ LOC_LOGV("LocEngStartFix");
+}
+inline void LocEngStartFix::log() const
+{
+ locallog();
+}
+void LocEngStartFix::send() const {
+ mAdapter->sendMsg(this);
+}
+
+// case LOC_ENG_MSG_STOP_FIX:
+LocEngStopFix::LocEngStopFix(LocEngAdapter* adapter) :
+ LocMsg(), mAdapter(adapter)
+{
+ locallog();
+}
+inline void LocEngStopFix::proc() const
+{
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner();
+ loc_eng_stop_handler(*locEng);
+}
+inline void LocEngStopFix::locallog() const
+{
+ LOC_LOGV("LocEngStopFix");
+}
+inline void LocEngStopFix::log() const
+{
+ locallog();
+}
+void LocEngStopFix::send() const {
+ mAdapter->sendMsg(this);
+}
+
+// case LOC_ENG_MSG_SET_POSITION_MODE:
+LocEngPositionMode::LocEngPositionMode(LocEngAdapter* adapter,
+ LocPosMode &mode) :
+ LocMsg(), mAdapter(adapter), mPosMode(mode)
+{
+ mPosMode.logv();
+}
+inline void LocEngPositionMode::proc() const {
+ mAdapter->setPositionMode(&mPosMode);
+}
+inline void LocEngPositionMode::log() const {
+ mPosMode.logv();
+}
+void LocEngPositionMode::send() const {
+ mAdapter->sendMsg(this);
+}
+
+LocEngGetZpp::LocEngGetZpp(LocEngAdapter* adapter) :
+ LocMsg(), mAdapter(adapter)
+{
+ locallog();
+}
+inline void LocEngGetZpp::proc() const
+{
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner();
+ loc_eng_get_zpp_handler(*locEng);
+}
+inline void LocEngGetZpp::locallog() const
+{
+ LOC_LOGV("LocEngGetZpp");
+}
+inline void LocEngGetZpp::log() const
+{
+ locallog();
+}
+void LocEngGetZpp::send() const {
+ mAdapter->sendMsg(this);
+}
+
+// case LOC_ENG_MSG_SET_TIME:
+struct LocEngSetTime : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const GpsUtcTime mTime;
+ const int64_t mTimeReference;
+ const int mUncertainty;
+ inline LocEngSetTime(LocEngAdapter* adapter,
+ GpsUtcTime t, int64_t tf, int unc) :
+ LocMsg(), mAdapter(adapter),
+ mTime(t), mTimeReference(tf), mUncertainty(unc)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setTime(mTime, mTimeReference, mUncertainty);
+ }
+ inline void locallog() const {
+ LOC_LOGV("time: %lld\n timeReference: %lld\n uncertainty: %d",
+ mTime, mTimeReference, mUncertainty);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+ // case LOC_ENG_MSG_INJECT_LOCATION:
+struct LocEngInjectLocation : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const double mLatitude;
+ const double mLongitude;
+ const float mAccuracy;
+ inline LocEngInjectLocation(LocEngAdapter* adapter,
+ double lat, double lon, float accur) :
+ LocMsg(), mAdapter(adapter),
+ mLatitude(lat), mLongitude(lon), mAccuracy(accur)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->injectPosition(mLatitude, mLongitude, mAccuracy);
+ }
+ inline void locallog() const {
+ LOC_LOGV("latitude: %f\n longitude: %f\n accuracy: %f",
+ mLatitude, mLongitude, mAccuracy);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_SET_SERVER_IPV4:
+struct LocEngSetServerIpv4 : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const unsigned int mNlAddr;
+ const int mPort;
+ const LocServerType mServerType;
+ inline LocEngSetServerIpv4(LocEngAdapter* adapter,
+ unsigned int ip,
+ int port,
+ LocServerType type) :
+ LocMsg(), mAdapter(adapter),
+ mNlAddr(ip), mPort(port), mServerType(type)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setServer(mNlAddr, mPort, mServerType);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngSetServerIpv4 - addr: %x, port: %d, type: %s",
+ mNlAddr, mPort, loc_get_server_type_name(mServerType));
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_SET_SERVER_URL:
+struct LocEngSetServerUrl : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int mLen;
+ char* mUrl;
+ inline LocEngSetServerUrl(LocEngAdapter* adapter,
+ char* urlString,
+ int url_len) :
+ LocMsg(), mAdapter(adapter),
+ mLen(url_len), mUrl(new char[mLen+1])
+ {
+ memcpy((void*)mUrl, (void*)urlString, url_len);
+ mUrl[mLen] = 0;
+ locallog();
+ }
+ inline ~LocEngSetServerUrl()
+ {
+ delete[] mUrl;
+ }
+ inline virtual void proc() const {
+ mAdapter->setServer(mUrl, mLen);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngSetServerUrl - url: %s", mUrl);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_A_GLONASS_PROTOCOL:
+struct LocEngAGlonassProtocol : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const unsigned long mAGlonassProtocl;
+ inline LocEngAGlonassProtocol(LocEngAdapter* adapter,
+ unsigned long protocol) :
+ LocMsg(), mAdapter(adapter), mAGlonassProtocl(protocol)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setAGLONASSProtocol(mAGlonassProtocl);
+ }
+ inline void locallog() const {
+ LOC_LOGV("A-GLONASS protocol: 0x%lx", mAGlonassProtocl);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_SUPL_VERSION:
+struct LocEngSuplVer : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int mSuplVer;
+ inline LocEngSuplVer(LocEngAdapter* adapter,
+ int suplVer) :
+ LocMsg(), mAdapter(adapter), mSuplVer(suplVer)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setSUPLVersion(mSuplVer);
+ }
+ inline void locallog() const {
+ LOC_LOGV("SUPL Version: %d", mSuplVer);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_LPP_CONFIG:
+struct LocEngLppConfig : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int mLppConfig;
+ inline LocEngLppConfig(LocEngAdapter* adapter,
+ int lppConfig) :
+ LocMsg(), mAdapter(adapter), mLppConfig(lppConfig)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setLPPConfig(mLppConfig);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngLppConfig - profile: %d", mLppConfig);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG:
+struct LocEngSensorControlConfig : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int mSensorsDisabled;
+ const int mSensorProvider;
+ inline LocEngSensorControlConfig(LocEngAdapter* adapter,
+ int sensorsDisabled, int sensorProvider) :
+ LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled),
+ mSensorProvider(sensorProvider)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setSensorControlConfig(mSensorsDisabled, mSensorProvider);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d, Sensor Provider: %d",
+ mSensorsDisabled, mSensorProvider);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_SET_SENSOR_PROPERTIES:
+struct LocEngSensorProperties : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const bool mGyroBiasVarianceRandomWalkValid;
+ const float mGyroBiasVarianceRandomWalk;
+ const bool mAccelRandomWalkValid;
+ const float mAccelRandomWalk;
+ const bool mAngleRandomWalkValid;
+ const float mAngleRandomWalk;
+ const bool mRateRandomWalkValid;
+ const float mRateRandomWalk;
+ const bool mVelocityRandomWalkValid;
+ const float mVelocityRandomWalk;
+ inline LocEngSensorProperties(LocEngAdapter* adapter,
+ 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) :
+ LocMsg(), mAdapter(adapter),
+ mGyroBiasVarianceRandomWalkValid(gyroBiasRandomWalk_valid),
+ mGyroBiasVarianceRandomWalk(gyroBiasRandomWalk),
+ mAccelRandomWalkValid(accelRandomWalk_valid),
+ mAccelRandomWalk(accelRandomWalk),
+ mAngleRandomWalkValid(angleRandomWalk_valid),
+ mAngleRandomWalk(angleRandomWalk),
+ mRateRandomWalkValid(rateRandomWalk_valid),
+ mRateRandomWalk(rateRandomWalk),
+ mVelocityRandomWalkValid(velocityRandomWalk_valid),
+ mVelocityRandomWalk(velocityRandomWalk)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setSensorProperties(mGyroBiasVarianceRandomWalkValid,
+ mGyroBiasVarianceRandomWalk,
+ mAccelRandomWalkValid,
+ mAccelRandomWalk,
+ mAngleRandomWalkValid,
+ mAngleRandomWalk,
+ mRateRandomWalkValid,
+ mRateRandomWalk,
+ mVelocityRandomWalkValid,
+ mVelocityRandomWalk);
+ }
+ inline void locallog() const {
+ 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\n"
+ "Sensor properties, Gyro Random walk: %f "
+ "Accel Random Walk: %f "
+ "Angle Random Walk: %f Rate Random Walk: %f "
+ "Velocity Random Walk: %f",
+ mGyroBiasVarianceRandomWalkValid,
+ mAccelRandomWalkValid,
+ mAngleRandomWalkValid,
+ mRateRandomWalkValid,
+ mVelocityRandomWalkValid,
+ mGyroBiasVarianceRandomWalk,
+ mAccelRandomWalk,
+ mAngleRandomWalk,
+ mRateRandomWalk,
+ mVelocityRandomWalk
+ );
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG:
+struct LocEngSensorPerfControlConfig : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int mControlMode;
+ const int mAccelSamplesPerBatch;
+ const int mAccelBatchesPerSec;
+ const int mGyroSamplesPerBatch;
+ const int mGyroBatchesPerSec;
+ const int mAccelSamplesPerBatchHigh;
+ const int mAccelBatchesPerSecHigh;
+ const int mGyroSamplesPerBatchHigh;
+ const int mGyroBatchesPerSecHigh;
+ const int mAlgorithmConfig;
+ inline LocEngSensorPerfControlConfig(LocEngAdapter* adapter,
+ int controlMode,
+ int accelSamplesPerBatch,
+ int accelBatchesPerSec,
+ int gyroSamplesPerBatch,
+ int gyroBatchesPerSec,
+ int accelSamplesPerBatchHigh,
+ int accelBatchesPerSecHigh,
+ int gyroSamplesPerBatchHigh,
+ int gyroBatchesPerSecHigh,
+ int algorithmConfig) :
+ LocMsg(), mAdapter(adapter),
+ mControlMode(controlMode),
+ mAccelSamplesPerBatch(accelSamplesPerBatch),
+ mAccelBatchesPerSec(accelBatchesPerSec),
+ mGyroSamplesPerBatch(gyroSamplesPerBatch),
+ mGyroBatchesPerSec(gyroBatchesPerSec),
+ mAccelSamplesPerBatchHigh(accelSamplesPerBatchHigh),
+ mAccelBatchesPerSecHigh(accelBatchesPerSecHigh),
+ mGyroSamplesPerBatchHigh(gyroSamplesPerBatchHigh),
+ mGyroBatchesPerSecHigh(gyroBatchesPerSecHigh),
+ mAlgorithmConfig(algorithmConfig)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setSensorPerfControlConfig(mControlMode,
+ mAccelSamplesPerBatch,
+ mAccelBatchesPerSec,
+ mGyroSamplesPerBatch,
+ mGyroBatchesPerSec,
+ mAccelSamplesPerBatchHigh,
+ mAccelBatchesPerSecHigh,
+ mGyroSamplesPerBatchHigh,
+ mGyroBatchesPerSecHigh,
+ mAlgorithmConfig);
+ }
+ inline void locallog() const {
+ 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",
+ mControlMode,
+ mAccelSamplesPerBatch, mAccelBatchesPerSec,
+ mGyroSamplesPerBatch, mGyroBatchesPerSec,
+ mAccelSamplesPerBatchHigh, mAccelBatchesPerSecHigh,
+ mGyroSamplesPerBatchHigh, mGyroBatchesPerSecHigh,
+ mAlgorithmConfig);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_EXT_POWER_CONFIG:
+struct LocEngExtPowerConfig : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int mIsBatteryCharging;
+ inline LocEngExtPowerConfig(LocEngAdapter* adapter,
+ int isBatteryCharging) :
+ LocMsg(), mAdapter(adapter),
+ mIsBatteryCharging(isBatteryCharging)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setExtPowerConfig(mIsBatteryCharging);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngExtPowerConfig - isBatteryCharging: %d",
+ mIsBatteryCharging);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_REPORT_POSITION:
+LocEngReportPosition::LocEngReportPosition(LocAdapterBase* adapter,
+ UlpLocation &loc,
+ GpsLocationExtended &locExtended,
+ void* locExt,
+ enum loc_sess_status st,
+ LocPosTechMask technology) :
+ LocMsg(), mAdapter(adapter), mLocation(loc),
+ mLocationExtended(locExtended),
+ mLocationExt(((loc_eng_data_s_type*)
+ ((LocEngAdapter*)
+ (mAdapter))->getOwner())->location_ext_parser(locExt)),
+ mStatus(st), mTechMask(technology)
+{
+ locallog();
+}
+void LocEngReportPosition::proc() const {
+ LocEngAdapter* adapter = (LocEngAdapter*)mAdapter;
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner();
+
+ if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) {
+ bool reported = false;
+ if (locEng->location_cb != NULL) {
+ if (LOC_SESS_FAILURE == mStatus) {
+ // in case we want to handle the failure case
+ locEng->location_cb(NULL, NULL);
+ reported = true;
+ }
+ // what's in the else if is... (line by line)
+ // 1. this is a final fix; and
+ // 1.1 it is a Satellite fix; or
+ // 1.2 it is a sensor fix
+ // 2. (must be intermediate fix... implicit)
+ // 2.1 we accepte intermediate; and
+ // 2.2 it is NOT the case that
+ // 2.2.1 there is inaccuracy; and
+ // 2.2.2 we care about inaccuracy; and
+ // 2.2.3 the inaccuracy exceeds our tolerance
+ else if ((LOC_SESS_SUCCESS == mStatus &&
+ ((LOC_POS_TECH_MASK_SATELLITE |
+ LOC_POS_TECH_MASK_SENSORS |
+ LOC_POS_TECH_MASK_HYBRID) &
+ mTechMask)) ||
+ (LOC_SESS_INTERMEDIATE == locEng->intermediateFix &&
+ !((mLocation.gpsLocation.flags &
+ GPS_LOCATION_HAS_ACCURACY) &&
+ (gps_conf.ACCURACY_THRES != 0) &&
+ (mLocation.gpsLocation.accuracy >
+ gps_conf.ACCURACY_THRES)))) {
+ locEng->location_cb((UlpLocation*)&(mLocation),
+ (void*)mLocationExt);
+ reported = true;
+ }
+ }
+
+ // if we have reported this fix
+ if (reported &&
+ // and if this is a singleshot
+ GPS_POSITION_RECURRENCE_SINGLE ==
+ locEng->adapter->getPositionMode().recurrence) {
+ if (LOC_SESS_INTERMEDIATE == mStatus) {
+ // modem could be still working for a final fix,
+ // although we no longer need it. So stopFix().
+ locEng->adapter->stopFix();
+ }
+ // turn off the session flag.
+ locEng->adapter->setInSession(false);
+ }
+
+ if (locEng->generateNmea &&
+ mLocation.position_source == ULP_LOCATION_IS_FROM_GNSS &&
+ mTechMask & (LOC_POS_TECH_MASK_SATELLITE |
+ LOC_POS_TECH_MASK_SENSORS |
+ LOC_POS_TECH_MASK_HYBRID))
+ {
+ unsigned char generate_nmea = reported &&
+ (mStatus != LOC_SESS_FAILURE);
+ loc_eng_nmea_generate_pos(locEng, mLocation, mLocationExtended,
+ generate_nmea);
+ }
+
+ // Free the allocated memory for rawData
+ UlpLocation* gp = (UlpLocation*)&(mLocation);
+ if (gp != NULL && gp->rawData != NULL)
+ {
+ delete (char*)gp->rawData;
+ gp->rawData = NULL;
+ gp->rawDataSize = 0;
+ }
+ }
+}
+void LocEngReportPosition::locallog() const {
+ LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n "
+ "altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n "
+ "timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Session"
+ " status: %d\n Technology mask: %u",
+ mLocation.gpsLocation.flags, mLocation.position_source,
+ mLocation.gpsLocation.latitude, mLocation.gpsLocation.longitude,
+ mLocation.gpsLocation.altitude, mLocation.gpsLocation.speed,
+ mLocation.gpsLocation.bearing, mLocation.gpsLocation.accuracy,
+ mLocation.gpsLocation.timestamp, mLocation.rawDataSize,
+ mLocation.rawData, mStatus, mTechMask);
+}
+void LocEngReportPosition::log() const {
+ locallog();
+}
+void LocEngReportPosition::send() const {
+ mAdapter->sendMsg(this);
+}
+
+
+// case LOC_ENG_MSG_REPORT_SV:
+LocEngReportSv::LocEngReportSv(LocAdapterBase* adapter,
+ GpsSvStatus &sv,
+ GpsLocationExtended &locExtended,
+ void* svExt) :
+ LocMsg(), mAdapter(adapter), mSvStatus(sv),
+ mLocationExtended(locExtended),
+ mSvExt(((loc_eng_data_s_type*)
+ ((LocEngAdapter*)
+ (mAdapter))->getOwner())->sv_ext_parser(svExt))
+{
+ locallog();
+}
+void LocEngReportSv::proc() const {
+ LocEngAdapter* adapter = (LocEngAdapter*)mAdapter;
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner();
+
+ if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION)
+ {
+ if (locEng->sv_status_cb != NULL) {
+ locEng->sv_status_cb((GpsSvStatus*)&(mSvStatus),
+ (void*)mSvExt);
+ }
+
+ if (locEng->generateNmea)
+ {
+ loc_eng_nmea_generate_sv(locEng, mSvStatus, mLocationExtended);
+ }
+ }
+}
+void LocEngReportSv::locallog() const {
+ LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n "
+ "used in fix mask: %x\n sv: prn snr "
+ "elevation azimuth",
+ mSvStatus.num_svs, mSvStatus.ephemeris_mask,
+ mSvStatus.almanac_mask, mSvStatus.used_in_fix_mask);
+ for (int i = 0; i < mSvStatus.num_svs && i < GPS_MAX_SVS; i++) {
+ LOC_LOGV(" %d: %d %f %f %f\n ",
+ i,
+ mSvStatus.sv_list[i].prn,
+ mSvStatus.sv_list[i].snr,
+ mSvStatus.sv_list[i].elevation,
+ mSvStatus.sv_list[i].azimuth);
+ }
+}
+inline void LocEngReportSv::log() const {
+ locallog();
+}
+void LocEngReportSv::send() const {
+ mAdapter->sendMsg(this);
+}
+
+// case LOC_ENG_MSG_REPORT_STATUS:
+LocEngReportStatus::LocEngReportStatus(LocAdapterBase* adapter,
+ GpsStatusValue engineStatus) :
+ LocMsg(), mAdapter(adapter), mStatus(engineStatus)
+{
+ locallog();
+}
+inline void LocEngReportStatus::proc() const
+{
+ LocEngAdapter* adapter = (LocEngAdapter*)mAdapter;
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner();
+
+ loc_eng_report_status(*locEng, mStatus);
+ update_aiding_data_for_deletion(*locEng);
+}
+inline void LocEngReportStatus::locallog() const {
+ LOC_LOGV("LocEngReportStatus");
+}
+inline void LocEngReportStatus::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_REPORT_NMEA:
+LocEngReportNmea::LocEngReportNmea(void* locEng,
+ const char* data, int len) :
+ LocMsg(), mLocEng(locEng), mNmea(new char[len]), mLen(len)
+{
+ memcpy((void*)mNmea, (void*)data, len);
+ locallog();
+}
+void LocEngReportNmea::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng;
+
+ struct timeval tv;
+ gettimeofday(&tv, (struct timezone *) NULL);
+ int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
+ CALLBACK_LOG_CALLFLOW("nmea_cb", %d, mLen);
+
+ if (locEng->nmea_cb != NULL)
+ locEng->nmea_cb(now, mNmea, mLen);
+}
+inline void LocEngReportNmea::locallog() const {
+ LOC_LOGV("LocEngReportNmea");
+}
+inline void LocEngReportNmea::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_REPORT_XTRA_SERVER:
+LocEngReportXtraServer::LocEngReportXtraServer(void* locEng,
+ const char *url1,
+ const char *url2,
+ const char *url3,
+ const int maxlength) :
+ LocMsg(), mLocEng(locEng), mMaxLen(maxlength),
+ mServers(new char[3*(mMaxLen+1)])
+{
+ char * cptr = mServers;
+ memset(mServers, 0, 3*(mMaxLen+1));
+
+ // Override modem URLs with uncommented gps.conf urls
+ if( gps_conf.XTRA_SERVER_1[0] != '\0' ) {
+ url1 = &gps_conf.XTRA_SERVER_1[0];
+ }
+ if( gps_conf.XTRA_SERVER_2[0] != '\0' ) {
+ url2 = &gps_conf.XTRA_SERVER_2[0];
+ }
+ if( gps_conf.XTRA_SERVER_3[0] != '\0' ) {
+ url3 = &gps_conf.XTRA_SERVER_3[0];
+ }
+ // copy non xtra1.gpsonextra.net URLs into the forwarding buffer.
+ if( NULL == strcasestr(url1, XTRA1_GPSONEXTRA) ) {
+ strlcpy(cptr, url1, mMaxLen + 1);
+ cptr += mMaxLen + 1;
+ }
+ if( NULL == strcasestr(url2, XTRA1_GPSONEXTRA) ) {
+ strlcpy(cptr, url2, mMaxLen + 1);
+ cptr += mMaxLen + 1;
+ }
+ if( NULL == strcasestr(url3, XTRA1_GPSONEXTRA) ) {
+ strlcpy(cptr, url3, mMaxLen + 1);
+ }
+ locallog();
+}
+
+void LocEngReportXtraServer::proc() const {
+ loc_eng_xtra_data_s_type* locEngXtra =
+ &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data);
+
+ if (locEngXtra->report_xtra_server_cb != NULL) {
+ CALLBACK_LOG_CALLFLOW("report_xtra_server_cb", %s, mServers);
+ locEngXtra->report_xtra_server_cb(mServers,
+ &(mServers[mMaxLen+1]),
+ &(mServers[(mMaxLen+1)<<1]));
+ } else {
+ LOC_LOGE("Callback function for request xtra is NULL");
+ }
+}
+inline void LocEngReportXtraServer::locallog() const {
+ LOC_LOGV("LocEngReportXtraServers: server1: %s\n server2: %s\n"
+ " server3: %s\n",
+ mServers, &mServers[mMaxLen+1], &mServers[(mMaxLen+1)<<1]);
+}
+inline void LocEngReportXtraServer::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_REQUEST_BIT:
+// case LOC_ENG_MSG_RELEASE_BIT:
+LocEngReqRelBIT::LocEngReqRelBIT(void* locEng, AGpsExtType type,
+ int ipv4, char* ipv6, bool isReq) :
+ LocMsg(), mLocEng(locEng), mType(type), mIPv4Addr(ipv4),
+ mIPv6Addr(ipv6 ? new char[16] : NULL), mIsReq(isReq) {
+ if (NULL != ipv6)
+ memcpy(mIPv6Addr, ipv6, 16);
+ locallog();
+}
+inline LocEngReqRelBIT::~LocEngReqRelBIT() {
+ if (mIPv6Addr) {
+ delete[] mIPv6Addr;
+ }
+}
+void LocEngReqRelBIT::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ BITSubscriber s(getAgpsStateMachine(*locEng, mType),
+ mIPv4Addr, mIPv6Addr);
+ AgpsStateMachine* sm = (AgpsStateMachine*)s.mStateMachine;
+
+ if (mIsReq) {
+ sm->subscribeRsrc((Subscriber*)&s);
+ } else {
+ sm->unsubscribeRsrc((Subscriber*)&s);
+ }
+}
+inline void LocEngReqRelBIT::locallog() const {
+ LOC_LOGV("LocEngRequestBIT - ipv4: %d.%d.%d.%d, ipv6: %s",
+ (unsigned char)mIPv4Addr,
+ (unsigned char)(mIPv4Addr>>8),
+ (unsigned char)(mIPv4Addr>>16),
+ (unsigned char)(mIPv4Addr>>24),
+ NULL != mIPv6Addr ? mIPv6Addr : "");
+}
+inline void LocEngReqRelBIT::log() const {
+ locallog();
+}
+void LocEngReqRelBIT::send() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ locEng->adapter->sendMsg(this);
+}
+
+// case LOC_ENG_MSG_RELEASE_BIT:
+struct LocEngReleaseBIT : public LocMsg {
+ const BITSubscriber mSubscriber;
+ inline LocEngReleaseBIT(const AgpsStateMachine* stateMachine,
+ unsigned int ipv4, char* ipv6) :
+ LocMsg(),
+ mSubscriber(stateMachine, ipv4, ipv6)
+ {
+ locallog();
+ }
+ inline virtual void proc() const
+ {
+ AgpsStateMachine* sm = (AgpsStateMachine*)mSubscriber.mStateMachine;
+ sm->unsubscribeRsrc((Subscriber*)&mSubscriber);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngReleaseBIT - ipv4: %d.%d.%d.%d, ipv6: %s",
+ (unsigned char)(mSubscriber.ID>>24),
+ (unsigned char)(mSubscriber.ID>>16),
+ (unsigned char)(mSubscriber.ID>>8),
+ (unsigned char)mSubscriber.ID,
+ NULL != mSubscriber.mIPv6Addr ? mSubscriber.mIPv6Addr : "");
+ }
+ virtual void log() const {
+ locallog();
+ }
+};
+
+// LocEngSuplEsOpened
+LocEngSuplEsOpened::LocEngSuplEsOpened(void* locEng) :
+ LocMsg(), mLocEng(locEng) {
+ locallog();
+}
+void LocEngSuplEsOpened::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ if (locEng->ds_nif) {
+ AgpsStateMachine* sm = locEng->ds_nif;
+ sm->onRsrcEvent(RSRC_GRANTED);
+ }
+}
+void LocEngSuplEsOpened::locallog() const {
+ LOC_LOGV("LocEngSuplEsOpened");
+}
+void LocEngSuplEsOpened::log() const {
+ locallog();
+}
+
+// LocEngSuplEsClosed
+LocEngSuplEsClosed::LocEngSuplEsClosed(void* locEng) :
+ LocMsg(), mLocEng(locEng) {
+ locallog();
+}
+void LocEngSuplEsClosed::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ if (locEng->ds_nif) {
+ AgpsStateMachine* sm = locEng->ds_nif;
+ sm->onRsrcEvent(RSRC_RELEASED);
+ }
+}
+void LocEngSuplEsClosed::locallog() const {
+ LOC_LOGV("LocEngSuplEsClosed");
+}
+void LocEngSuplEsClosed::log() const {
+ locallog();
+}
+
+
+// case LOC_ENG_MSG_REQUEST_SUPL_ES:
+LocEngRequestSuplEs::LocEngRequestSuplEs(void* locEng, int id) :
+ LocMsg(), mLocEng(locEng), mID(id) {
+ locallog();
+}
+void LocEngRequestSuplEs::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ if (locEng->ds_nif) {
+ AgpsStateMachine* sm = locEng->ds_nif;
+ DSSubscriber s(sm, mID);
+ sm->subscribeRsrc((Subscriber*)&s);
+ } else {
+ locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, -1);
+ }
+}
+inline void LocEngRequestSuplEs::locallog() const {
+ LOC_LOGV("LocEngRequestSuplEs");
+}
+inline void LocEngRequestSuplEs::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_REQUEST_ATL:
+LocEngRequestATL::LocEngRequestATL(void* locEng, int id,
+ AGpsExtType agps_type) :
+ LocMsg(), mLocEng(locEng), mID(id), mType(agps_type) {
+ locallog();
+}
+void LocEngRequestATL::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ AgpsStateMachine* sm = (AgpsStateMachine*)
+ getAgpsStateMachine(*locEng, mType);
+ if (sm) {
+ ATLSubscriber s(mID,
+ sm,
+ locEng->adapter,
+ AGPS_TYPE_INVALID == mType);
+ sm->subscribeRsrc((Subscriber*)&s);
+ } else {
+ locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, mType);
+ }
+}
+inline void LocEngRequestATL::locallog() const {
+ LOC_LOGV("LocEngRequestATL");
+}
+inline void LocEngRequestATL::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_RELEASE_ATL:
+LocEngReleaseATL::LocEngReleaseATL(void* locEng, int id) :
+ LocMsg(), mLocEng(locEng), mID(id) {
+ locallog();
+}
+void LocEngReleaseATL::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+
+ if (locEng->agnss_nif) {
+ ATLSubscriber s1(mID, locEng->agnss_nif, locEng->adapter, false);
+ if (locEng->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) {
+ LOC_LOGD("%s:%d]: Unsubscribed from agnss_nif",
+ __func__, __LINE__);
+ return;
+ }
+ }
+
+ if (locEng->internet_nif) {
+ ATLSubscriber s2(mID, locEng->internet_nif, locEng->adapter, false);
+ if (locEng->internet_nif->unsubscribeRsrc((Subscriber*)&s2)) {
+ LOC_LOGD("%s:%d]: Unsubscribed from internet_nif",
+ __func__, __LINE__);
+ return;
+ }
+ }
+
+ if (locEng->ds_nif) {
+ DSSubscriber s3(locEng->ds_nif, mID);
+ if (locEng->ds_nif->unsubscribeRsrc((Subscriber*)&s3)) {
+ LOC_LOGD("%s:%d]: Unsubscribed from ds_nif",
+ __func__, __LINE__);
+ return;
+ }
+ }
+
+ LOC_LOGW("%s:%d]: Could not release ATL. "
+ "No subscribers found\n",
+ __func__, __LINE__);
+ locEng->adapter->atlCloseStatus(mID, 0);
+}
+inline void LocEngReleaseATL::locallog() const {
+ LOC_LOGV("LocEngReleaseATL");
+}
+inline void LocEngReleaseATL::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_REQUEST_WIFI:
+// case LOC_ENG_MSG_RELEASE_WIFI:
+LocEngReqRelWifi::LocEngReqRelWifi(void* locEng, AGpsExtType type,
+ loc_if_req_sender_id_e_type sender_id,
+ char* s, char* p, bool isReq) :
+ LocMsg(), mLocEng(locEng), mType(type), mSenderId(sender_id),
+ mSSID(NULL == s ? NULL : new char[SSID_BUF_SIZE]),
+ mPassword(NULL == p ? NULL : new char[SSID_BUF_SIZE]),
+ mIsReq(isReq) {
+ if (NULL != s)
+ strlcpy(mSSID, s, SSID_BUF_SIZE);
+ if (NULL != p)
+ strlcpy(mPassword, p, SSID_BUF_SIZE);
+ locallog();
+}
+LocEngReqRelWifi::~LocEngReqRelWifi() {
+ if (NULL != mSSID) {
+ delete[] mSSID;
+ }
+ if (NULL != mPassword) {
+ delete[] mPassword;
+ }
+}
+void LocEngReqRelWifi::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ if (locEng->wifi_nif) {
+ WIFISubscriber s(locEng->wifi_nif, mSSID, mPassword, mSenderId);
+ if (mIsReq) {
+ locEng->wifi_nif->subscribeRsrc((Subscriber*)&s);
+ } else {
+ locEng->wifi_nif->unsubscribeRsrc((Subscriber*)&s);
+ }
+ } else {
+ locEng->adapter->atlOpenStatus(mSenderId, 0, NULL, -1, mType);
+ }
+}
+inline void LocEngReqRelWifi::locallog() const {
+ LOC_LOGV("%s - senderId: %d, ssid: %s, password: %s",
+ mIsReq ? "LocEngRequestWifi" : "LocEngReleaseWifi",
+ mSenderId,
+ NULL != mSSID ? mSSID : "",
+ NULL != mPassword ? mPassword : "");
+}
+inline void LocEngReqRelWifi::log() const {
+ locallog();
+}
+void LocEngReqRelWifi::send() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ locEng->adapter->sendMsg(this);
+}
+
+// case LOC_ENG_MSG_REQUEST_XTRA_DATA:
+LocEngRequestXtra::LocEngRequestXtra(void* locEng) :
+ mLocEng(locEng) {
+ locallog();
+}
+void LocEngRequestXtra::proc() const
+{
+ loc_eng_xtra_data_s_type* locEngXtra =
+ &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data);
+
+ if (locEngXtra->download_request_cb != NULL) {
+ CALLBACK_LOG_CALLFLOW("download_request_cb", %p, mLocEng);
+ locEngXtra->download_request_cb();
+ } else {
+ LOC_LOGE("Callback function for request xtra is NULL");
+ }
+}
+inline void LocEngRequestXtra::locallog() const {
+ LOC_LOGV("LocEngReqXtra");
+}
+inline void LocEngRequestXtra::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_REQUEST_TIME:
+LocEngRequestTime::LocEngRequestTime(void* locEng) :
+ LocMsg(), mLocEng(locEng)
+{
+ locallog();
+}
+void LocEngRequestTime::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ if (gps_conf.CAPABILITIES & GPS_CAPABILITY_ON_DEMAND_TIME) {
+ if (locEng->request_utc_time_cb != NULL) {
+ locEng->request_utc_time_cb();
+ } else {
+ LOC_LOGE("Callback function for request time is NULL");
+ }
+ }
+}
+inline void LocEngRequestTime::locallog() const {
+ LOC_LOGV("LocEngReqTime");
+}
+inline void LocEngRequestTime::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_DELETE_AIDING_DATA:
+struct LocEngDelAidData : public LocMsg {
+ loc_eng_data_s_type* mLocEng;
+ const GpsAidingData mType;
+ inline LocEngDelAidData(loc_eng_data_s_type* locEng,
+ GpsAidingData f) :
+ LocMsg(), mLocEng(locEng), mType(f)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mLocEng->aiding_data_for_deletion = mType;
+ update_aiding_data_for_deletion(*mLocEng);
+ }
+ inline void locallog() const {
+ LOC_LOGV("aiding data msak %d", mType);
+ }
+ virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_ENABLE_DATA:
+struct LocEngEnableData : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int mEnable;
+ char* mAPN;
+ const int mLen;
+ inline LocEngEnableData(LocEngAdapter* adapter,
+ const char* name, int len, int enable) :
+ LocMsg(), mAdapter(adapter),
+ mEnable(enable), mAPN(NULL), mLen(len)
+ {
+ if (NULL != name) {
+ mAPN = new char[len+1];
+ memcpy((void*)mAPN, (void*)name, len);
+ mAPN[len] = 0;
+ }
+ locallog();
+ }
+ inline ~LocEngEnableData() {
+ if (NULL != mAPN) {
+ delete[] mAPN;
+ }
+ }
+ inline virtual void proc() const {
+ mAdapter->enableData(mEnable);
+ if (NULL != mAPN) {
+ mAdapter->setAPN(mAPN, mLen);
+ }
+ }
+ inline void locallog() const {
+ LOC_LOGV("apn: %s\n enable: %d",
+ (NULL == mAPN) ? "NULL" : mAPN, mEnable);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_INJECT_XTRA_DATA:
+// loc_eng_xtra.cpp
+
+// case LOC_ENG_MSG_LOC_INIT:
+struct LocEngInit : public LocMsg {
+ loc_eng_data_s_type* mLocEng;
+ inline LocEngInit(loc_eng_data_s_type* locEng) :
+ LocMsg(), mLocEng(locEng)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ loc_eng_reinit(*mLocEng);
+ }
+ inline void locallog() const
+ {
+ LOC_LOGV("LocEngInit");
+ }
+ inline virtual void log() const
+ {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_REQUEST_XTRA_SERVER:
+// loc_eng_xtra.cpp
+
+// case LOC_ENG_MSG_ATL_OPEN_SUCCESS:
+struct LocEngAtlOpenSuccess : public LocMsg {
+ AgpsStateMachine* mStateMachine;
+ const int mLen;
+ char* mAPN;
+ const AGpsBearerType mBearerType;
+ inline LocEngAtlOpenSuccess(AgpsStateMachine* statemachine,
+ const char* name,
+ int len,
+ AGpsBearerType btype) :
+ LocMsg(),
+ mStateMachine(statemachine), mLen(len),
+ mAPN(new char[len+1]), mBearerType(btype)
+ {
+ memcpy((void*)mAPN, (void*)name, len);
+ mAPN[len] = 0;
+ locallog();
+ }
+ inline ~LocEngAtlOpenSuccess()
+ {
+ delete[] mAPN;
+ }
+ inline virtual void proc() const {
+ mStateMachine->setBearer(mBearerType);
+ mStateMachine->setAPN(mAPN, mLen);
+ mStateMachine->onRsrcEvent(RSRC_GRANTED);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngAtlOpenSuccess agps type: %s\n apn: %s\n"
+ " bearer type: %s",
+ loc_get_agps_type_name(mStateMachine->getType()),
+ mAPN,
+ loc_get_agps_bear_name(mBearerType));
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_ATL_CLOSED:
+struct LocEngAtlClosed : public LocMsg {
+ AgpsStateMachine* mStateMachine;
+ inline LocEngAtlClosed(AgpsStateMachine* statemachine) :
+ LocMsg(), mStateMachine(statemachine) {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mStateMachine->onRsrcEvent(RSRC_RELEASED);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngAtlClosed");
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_ATL_OPEN_FAILED:
+struct LocEngAtlOpenFailed : public LocMsg {
+ AgpsStateMachine* mStateMachine;
+ inline LocEngAtlOpenFailed(AgpsStateMachine* statemachine) :
+ LocMsg(), mStateMachine(statemachine) {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mStateMachine->onRsrcEvent(RSRC_DENIED);
+ }
+ inline void locallog() const {
+ LOC_LOGV("LocEngAtlOpenFailed");
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+// case LOC_ENG_MSG_ENGINE_DOWN:
+LocEngDown::LocEngDown(void* locEng) :
+ LocMsg(), mLocEng(locEng) {
+ locallog();
+}
+inline void LocEngDown::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ loc_eng_handle_engine_down(*locEng);
+}
+inline void LocEngDown::locallog() const {
+ LOC_LOGV("LocEngDown");
+}
+inline void LocEngDown::log() const {
+ locallog();
+}
+
+// case LOC_ENG_MSG_ENGINE_UP:
+LocEngUp::LocEngUp(void* locEng) :
+ LocMsg(), mLocEng(locEng) {
+ locallog();
+}
+inline void LocEngUp::proc() const {
+ loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;
+ loc_eng_handle_engine_up(*locEng);
+}
+inline void LocEngUp::locallog() const {
+ LOC_LOGV("LocEngUp");
+}
+inline void LocEngUp::log() const {
+ locallog();
+}
+
+struct LocEngDataClientInit : public LocMsg {
+ loc_eng_data_s_type* mLocEng;
+ inline LocEngDataClientInit(loc_eng_data_s_type* locEng) :
+ LocMsg(), mLocEng(locEng) {
+ locallog();
+ }
+ virtual void proc() const {
+ loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng;
+ if(!locEng->adapter->initDataServiceClient()) {
+ locEng->ds_nif = new DSStateMachine(servicerTypeExt,
+ (void *)dataCallCb,
+ locEng->adapter);
+ }
+ }
+ void locallog() const {
+ LOC_LOGV("LocEngDataClientInit\n");
+ }
+ virtual void log() const {
+ locallog();
+ }
+};
+
+
+/*********************************************************************
+ * Initialization checking macros
+ *********************************************************************/
+#define STATE_CHECK(ctx, x, ret) \
+ if (!(ctx)) \
+ { \
+ /* Not intialized, abort */\
+ LOC_LOGE("%s: log_eng state error: %s", __func__, x); \
+ EXIT_LOG(%s, x); \
+ ret; \
+ }
+#define INIT_CHECK(ctx, ret) STATE_CHECK(ctx, "instance not initialized", ret)
+
+/*===========================================================================
+FUNCTION loc_eng_init
+
+DESCRIPTION
+ Initialize the location engine, this include setting up global datas
+ and registers location engien with loc api service.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
+ LOC_API_ADAPTER_EVENT_MASK_T event, ContextBase* context)
+
+{
+ int ret_val = 0;
+
+ ENTRY_LOG_CALLFLOW();
+ if (NULL == callbacks || 0 == event) {
+ LOC_LOGE("loc_eng_init: bad parameters cb %p eMask %d", callbacks, event);
+ ret_val = -1;
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+ }
+
+ STATE_CHECK((NULL == loc_eng_data.adapter),
+ "instance already initialized", return 0);
+
+ memset(&loc_eng_data, 0, sizeof (loc_eng_data));
+
+ if (NULL != callbacks->set_capabilities_cb) {
+ callbacks->set_capabilities_cb(gps_conf.CAPABILITIES);
+ }
+
+ // Save callbacks
+ loc_eng_data.location_cb = callbacks->location_cb;
+ loc_eng_data.sv_status_cb = callbacks->sv_status_cb;
+ loc_eng_data.status_cb = callbacks->status_cb;
+ loc_eng_data.nmea_cb = callbacks->nmea_cb;
+ loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb;
+ loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb;
+ loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb;
+ loc_eng_data.location_ext_parser = callbacks->location_ext_parser ?
+ callbacks->location_ext_parser : noProc;
+ loc_eng_data.sv_ext_parser = callbacks->sv_ext_parser ?
+ callbacks->sv_ext_parser : noProc;
+ loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS;
+
+ // initial states taken care of by the memset above
+ // loc_eng_data.engine_status -- GPS_STATUS_NONE;
+ // loc_eng_data.fix_session_status -- GPS_STATUS_NONE;
+ // loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE;
+
+ if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP))
+ {
+ event = event ^ LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; // unregister for modem NMEA report
+ loc_eng_data.generateNmea = true;
+ }
+ else
+ {
+ loc_eng_data.generateNmea = false;
+ }
+
+ loc_eng_data.adapter =
+ new LocEngAdapter(event, &loc_eng_data, context,
+ (MsgTask::tCreate)callbacks->create_thread_cb);
+
+ LOC_LOGD("loc_eng_init created client, id = %p\n",
+ loc_eng_data.adapter);
+ loc_eng_data.adapter->sendMsg(new LocEngInit(&loc_eng_data));
+
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+
+ adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));
+ adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));
+ adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE,
+ sap_conf.SENSOR_PROVIDER));
+ adapter->sendMsg(new LocEngAGlonassProtocol(adapter, gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));
+
+ /* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */
+ if( sap_conf.GYRO_BIAS_RANDOM_WALK_VALID ||
+ sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
+ sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
+ sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
+ sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) {
+ adapter->sendMsg(new LocEngSensorProperties(adapter,
+ sap_conf.GYRO_BIAS_RANDOM_WALK_VALID,
+ sap_conf.GYRO_BIAS_RANDOM_WALK,
+ sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,
+ sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,
+ sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,
+ sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
+ sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY));
+ }
+
+ adapter->sendMsg(new LocEngSensorPerfControlConfig(adapter,
+ sap_conf.SENSOR_CONTROL_MODE,
+ sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH,
+ sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC,
+ sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH,
+ sap_conf.SENSOR_GYRO_BATCHES_PER_SEC,
+ sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH,
+ sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,
+ sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,
+ sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,
+ sap_conf.SENSOR_ALGORITHM_CONFIG_MASK));
+
+ adapter->sendMsg(new LocEngEnableData(adapter, NULL, 0, (agpsStatus ? 1:0)));
+
+ loc_eng_xtra_version_check(loc_eng_data, gps_conf.XTRA_VERSION_CHECK);
+
+ LOC_LOGD("loc_eng_reinit reinit() successful");
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_cleanup
+
+DESCRIPTION
+ Cleans location engine. The location client handle will be released.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ None
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return);
+
+ // XTRA has no state, so we are fine with it.
+
+ // we need to check and clear NI
+#if 0
+ // we need to check and clear ATL
+ if (NULL != loc_eng_data.agnss_nif) {
+ delete loc_eng_data.agnss_nif;
+ loc_eng_data.agnss_nif = NULL;
+ }
+ if (NULL != loc_eng_data.internet_nif) {
+ delete loc_eng_data.internet_nif;
+ loc_eng_data.internet_nif = NULL;
+ }
+#endif
+ if (loc_eng_data.adapter->isInSession())
+ {
+ LOC_LOGD("loc_eng_cleanup: fix not stopped. stop it now.");
+ loc_eng_stop(loc_eng_data);
+ }
+
+#if 0 // can't afford to actually clean up, for many reason.
+
+ LOC_LOGD("loc_eng_init: client opened. close it now.");
+ delete loc_eng_data.adapter;
+ loc_eng_data.adapter = NULL;
+
+ loc_eng_dmn_conn_loc_api_server_unblock();
+ loc_eng_dmn_conn_loc_api_server_join();
+
+#endif
+
+ EXIT_LOG(%s, VOID_RET);
+}
+
+
+/*===========================================================================
+FUNCTION loc_eng_start
+
+DESCRIPTION
+ Starts the tracking session
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_start(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return -1);
+
+ if(! loc_eng_data.adapter->getUlpProxy()->sendStartFix())
+ {
+ loc_eng_data.adapter->sendMsg(new LocEngStartFix(loc_eng_data.adapter));
+ }
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
+
+ if (!loc_eng_data.adapter->isInSession()) {
+ ret_val = loc_eng_data.adapter->startFix();
+
+ if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS ||
+ ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN ||
+ ret_val == LOC_API_ADAPTER_ERR_PHONE_OFFLINE ||
+ ret_val == LOC_API_ADAPTER_ERR_INTERNAL)
+ {
+ loc_eng_data.adapter->setInSession(TRUE);
+ loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN);
+ }
+ }
+
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_stop_wrapper
+
+DESCRIPTION
+ Stops the tracking session
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_stop(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return -1);
+
+ if(! loc_eng_data.adapter->getUlpProxy()->sendStopFix())
+ {
+ loc_eng_data.adapter->sendMsg(new LocEngStopFix(loc_eng_data.adapter));
+ }
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
+
+ if (loc_eng_data.adapter->isInSession()) {
+
+ ret_val = loc_eng_data.adapter->stopFix();
+ if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS)
+ {
+ loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_END);
+ }
+
+ loc_eng_data.adapter->setInSession(FALSE);
+ }
+
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_mute_one_session
+
+DESCRIPTION
+ Mutes one session
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: Success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ loc_eng_data.mute_session_state = LOC_MUTE_SESS_WAIT;
+ EXIT_LOG(%s, VOID_RET);
+}
+
+/*===========================================================================
+FUNCTION loc_eng_set_position_mode
+
+DESCRIPTION
+ Sets the mode and fix frequency for the tracking session.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,
+ LocPosMode &params)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return -1);
+
+ int gnssType = getTargetGnssType(loc_get_target());
+
+ // The position mode for GSS/QCA1530 can only be standalone
+ bool is1530 = gnssType == GNSS_QCA1530;
+ bool isAPQ = gnssType == GNSS_GSS;
+ if ((isAPQ || is1530) && params.mode != LOC_POSITION_MODE_STANDALONE) {
+ params.mode = LOC_POSITION_MODE_STANDALONE;
+ LOC_LOGD("Position mode changed to standalone for target with GSS/qca1530.");
+ }
+
+ if(! loc_eng_data.adapter->getUlpProxy()->sendFixMode(params))
+ {
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngPositionMode(adapter, params));
+ }
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_inject_time
+
+DESCRIPTION
+ This is used by Java native function to do time injection.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time,
+ int64_t timeReference, int uncertainty)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return -1);
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+
+ adapter->sendMsg(new LocEngSetTime(adapter, time, timeReference,
+ uncertainty));
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+
+/*===========================================================================
+FUNCTION loc_eng_inject_location
+
+DESCRIPTION
+ This is used by Java native function to do location injection.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0 : Successful
+ error code : Failure
+
+SIDE EFFECTS
+ N/A
+===========================================================================*/
+int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, double latitude,
+ double longitude, float accuracy)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return -1);
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ if(adapter->mSupportsPositionInjection)
+ {
+ adapter->sendMsg(new LocEngInjectLocation(adapter, latitude, longitude,
+ accuracy));
+ }
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+
+/*===========================================================================
+FUNCTION loc_eng_delete_aiding_data
+
+DESCRIPTION
+ This is used by Java native function to delete the aiding data. The function
+ updates the global variable for the aiding data to be deleted. If the GPS
+ engine is off, the aiding data will be deleted. Otherwise, the actual action
+ will happen when gps engine is turned off.
+
+DEPENDENCIES
+ Assumes the aiding data type specified in GpsAidingData matches with
+ LOC API specification.
+
+RETURN VALUE
+ None
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, GpsAidingData f)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return);
+
+ loc_eng_data.adapter->sendMsg(new LocEngDelAidData(&loc_eng_data, f));
+
+ EXIT_LOG(%s, VOID_RET);
+}
+
+/*===========================================================================
+
+FUNCTION loc_inform_gps_state
+
+DESCRIPTION
+ Informs the GPS Provider about the GPS status
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ None
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, GpsStatusValue status)
+{
+ ENTRY_LOG();
+
+ if (loc_eng_data.status_cb)
+ {
+ GpsStatus gs = { sizeof(gs),status };
+ CALLBACK_LOG_CALLFLOW("status_cb", %s,
+ loc_get_gps_status_name(gs.status));
+ loc_eng_data.status_cb(&gs);
+ }
+
+ EXIT_LOG(%s, VOID_RET);
+}
+
+static int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;
+ UlpLocation location;
+ LocPosTechMask tech_mask = LOC_POS_TECH_MASK_DEFAULT;
+ GpsLocationExtended locationExtended;
+ memset(&locationExtended, 0, sizeof (GpsLocationExtended));
+ locationExtended.size = sizeof(locationExtended);
+
+ ret_val = loc_eng_data.adapter->getZpp(location.gpsLocation, tech_mask);
+ //Mark the location source as from ZPP
+ location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO;
+ location.position_source = ULP_LOCATION_IS_FROM_ZPP;
+
+ loc_eng_data.adapter->getUlpProxy()->reportPosition(location,
+ locationExtended,
+ NULL,
+ LOC_SESS_SUCCESS,
+ tech_mask);
+
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+/*
+ Callback function passed to Data Services State Machine
+ This becomes part of the state machine's servicer and
+ is used to send requests to the data services client
+*/
+static int dataCallCb(void *cb_data)
+{
+ LOC_LOGD("Enter dataCallCb\n");
+ int ret=0;
+ if(cb_data != NULL) {
+ dsCbData *cbData = (dsCbData *)cb_data;
+ LocEngAdapter *locAdapter = (LocEngAdapter *)cbData->mAdapter;
+ if(cbData->action == GPS_REQUEST_AGPS_DATA_CONN) {
+ LOC_LOGD("dataCallCb GPS_REQUEST_AGPS_DATA_CONN\n");
+ ret = locAdapter->openAndStartDataCall();
+ }
+ else if(cbData->action == GPS_RELEASE_AGPS_DATA_CONN) {
+ LOC_LOGD("dataCallCb GPS_RELEASE_AGPS_DATA_CONN\n");
+ locAdapter->stopDataCall();
+ }
+ }
+ else {
+ LOC_LOGE("NULL argument received. Failing.\n");
+ ret = -1;
+ goto err;
+ }
+
+err:
+ LOC_LOGD("Exit dataCallCb ret = %d\n", ret);
+ return ret;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_agps_reinit
+
+DESCRIPTION
+ 2nd half of loc_eng_agps_init(), singled out for modem restart to use.
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+static void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+
+ // Set server addresses which came before init
+ if (loc_eng_data.supl_host_set)
+ {
+ loc_eng_set_server(loc_eng_data, LOC_AGPS_SUPL_SERVER,
+ loc_eng_data.supl_host_buf,
+ loc_eng_data.supl_port_buf);
+ }
+
+ if (loc_eng_data.c2k_host_set)
+ {
+ loc_eng_set_server(loc_eng_data, LOC_AGPS_CDMA_PDE_SERVER,
+ loc_eng_data.c2k_host_buf,
+ loc_eng_data.c2k_port_buf);
+ }
+ EXIT_LOG(%s, VOID_RET);
+}
+/*===========================================================================
+FUNCTION loc_eng_agps_init
+
+DESCRIPTION
+ Initialize the AGps interface.
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* callbacks)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter, return);
+ STATE_CHECK((NULL == loc_eng_data.agps_status_cb),
+ "agps instance already initialized",
+ return);
+ if (callbacks == NULL) {
+ LOC_LOGE("loc_eng_agps_init: bad parameters cb %p", callbacks);
+ EXIT_LOG(%s, VOID_RET);
+ return;
+ }
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ loc_eng_data.agps_status_cb = callbacks->status_cb;
+
+ loc_eng_data.internet_nif = new AgpsStateMachine(servicerTypeAgps,
+ (void *)loc_eng_data.agps_status_cb,
+ AGPS_TYPE_WWAN_ANY,
+ false);
+ loc_eng_data.wifi_nif = new AgpsStateMachine(servicerTypeAgps,
+ (void *)loc_eng_data.agps_status_cb,
+ AGPS_TYPE_WIFI,
+ true);
+
+ int gnssType = getTargetGnssType(loc_get_target());
+ bool isAPQ = (gnssType == GNSS_GSS);
+ bool is1530 = (gnssType == GNSS_QCA1530);
+ if (!isAPQ && !is1530) {
+ loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps,
+ (void *)loc_eng_data.agps_status_cb,
+ AGPS_TYPE_SUPL,
+ false);
+
+ if (adapter->mSupportsAgpsRequests) {
+ loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data));
+
+ loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,
+ NULL, NULL, &loc_eng_data);
+ }
+ loc_eng_agps_reinit(loc_eng_data);
+ }
+
+ EXIT_LOG(%s, VOID_RET);
+}
+
+static void deleteAidingData(loc_eng_data_s_type &logEng) {
+ if (logEng.engine_status != GPS_STATUS_ENGINE_ON &&
+ logEng.aiding_data_for_deletion != 0) {
+ logEng.adapter->deleteAidingData(logEng.aiding_data_for_deletion);
+ logEng.aiding_data_for_deletion = 0;
+ }
+}
+
+static AgpsStateMachine*
+getAgpsStateMachine(loc_eng_data_s_type &locEng, AGpsExtType agpsType) {
+ AgpsStateMachine* stateMachine;
+ switch (agpsType) {
+ case AGPS_TYPE_WIFI: {
+ stateMachine = locEng.wifi_nif;
+ break;
+ }
+ case AGPS_TYPE_INVALID:
+ case AGPS_TYPE_SUPL: {
+ stateMachine = locEng.agnss_nif;
+ break;
+ }
+ case AGPS_TYPE_SUPL_ES: {
+ stateMachine = locEng.ds_nif;
+ break;
+ }
+ default:
+ stateMachine = locEng.internet_nif;
+ }
+ return stateMachine;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_agps_open
+
+DESCRIPTION
+ This function is called when on-demand data connection opening is successful.
+It should inform engine about the data open result.
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType,
+ const char* apn, AGpsBearerType bearerType)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb,
+ return -1);
+
+ if (apn == NULL)
+ {
+ LOC_LOGE("APN Name NULL\n");
+ return 0;
+ }
+
+ LOC_LOGD("loc_eng_agps_open APN name = [%s]", apn);
+
+ int apn_len = smaller_of(strlen (apn), MAX_APN_LEN);
+ AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType);
+
+ loc_eng_data.adapter->sendMsg(
+ new LocEngAtlOpenSuccess(sm, apn, apn_len, bearerType));
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_agps_closed
+
+DESCRIPTION
+ This function is called when on-demand data connection closing is done.
+It should inform engine about the data close result.
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb,
+ return -1);
+
+ AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType);
+ loc_eng_data.adapter->sendMsg(new LocEngAtlClosed(sm));
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_agps_open_failed
+
+DESCRIPTION
+ This function is called when on-demand data connection opening has failed.
+It should inform engine about the data open result.
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType)
+{
+ ENTRY_LOG_CALLFLOW();
+ INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb,
+ return -1);
+
+ AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType);
+ loc_eng_data.adapter->sendMsg(new LocEngAtlOpenFailed(sm));
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+
+/*===========================================================================
+
+FUNCTION resolve_in_addr
+
+DESCRIPTION
+ Translates a hostname to in_addr struct
+
+DEPENDENCIES
+ n/a
+
+RETURN VALUE
+ TRUE if successful
+
+SIDE EFFECTS
+ n/a
+
+===========================================================================*/
+static boolean resolve_in_addr(const char *host_addr, struct in_addr *in_addr_ptr)
+{
+ ENTRY_LOG();
+ boolean ret_val = TRUE;
+
+ struct hostent *hp;
+ hp = gethostbyname(host_addr);
+ if (hp != NULL) /* DNS OK */
+ {
+ memcpy(in_addr_ptr, hp->h_addr_list[0], hp->h_length);
+ }
+ else
+ {
+ /* Try IP representation */
+ if (inet_aton(host_addr, in_addr_ptr) == 0)
+ {
+ /* IP not valid */
+ LOC_LOGE("DNS query on '%s' failed\n", host_addr);
+ ret_val = FALSE;
+ }
+ }
+
+ EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);
+ return ret_val;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_set_server
+
+DESCRIPTION
+ This is used to set the default AGPS server. Server address is obtained
+ from gps.conf.
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data,
+ LocServerType type, const char* hostname, int port)
+{
+ ENTRY_LOG();
+ int ret = 0;
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+
+ if (LOC_AGPS_SUPL_SERVER == type) {
+ char url[MAX_URL_LEN];
+ unsigned int len = snprintf(url, sizeof(url), "%s:%u", hostname, (unsigned) port);
+
+ if (sizeof(url) > len) {
+ adapter->sendMsg(new LocEngSetServerUrl(adapter, url, len));
+ }
+ } else if (LOC_AGPS_CDMA_PDE_SERVER == type ||
+ LOC_AGPS_CUSTOM_PDE_SERVER == type ||
+ LOC_AGPS_MPC_SERVER == type) {
+ struct in_addr addr;
+ if (!resolve_in_addr(hostname, &addr))
+ {
+ LOC_LOGE("loc_eng_set_server, hostname %s cannot be resolved.\n", hostname);
+ ret = -2;
+ } else {
+ unsigned int ip = htonl(addr.s_addr);
+ adapter->sendMsg(new LocEngSetServerIpv4(adapter, ip, port, type));
+ }
+ } else {
+ LOC_LOGE("loc_eng_set_server, type %d cannot be resolved.\n", type);
+ }
+
+ EXIT_LOG(%d, ret);
+ return ret;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_set_server_proxy
+
+DESCRIPTION
+ If loc_eng_set_server is called before loc_eng_init, it doesn't work. This
+ proxy buffers server settings and calls loc_eng_set_server when the client is
+ open.
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,
+ LocServerType type,
+ const char* hostname, int port)
+{
+ ENTRY_LOG_CALLFLOW();
+ int ret_val = 0;
+
+ if (NULL != loc_eng_data.adapter)
+ {
+ ret_val = loc_eng_set_server(loc_eng_data, type, hostname, port);
+ } else {
+ LOC_LOGW("set_server called before init. save the address, type: %d, hostname: %s, port: %d",
+ (int) type, hostname, port);
+ switch (type)
+ {
+ case LOC_AGPS_SUPL_SERVER:
+ strlcpy(loc_eng_data.supl_host_buf, hostname,
+ sizeof(loc_eng_data.supl_host_buf));
+ loc_eng_data.supl_port_buf = port;
+ loc_eng_data.supl_host_set = 1;
+ break;
+ case LOC_AGPS_CDMA_PDE_SERVER:
+ strlcpy(loc_eng_data.c2k_host_buf, hostname,
+ sizeof(loc_eng_data.c2k_host_buf));
+ loc_eng_data.c2k_port_buf = port;
+ loc_eng_data.c2k_host_set = 1;
+ break;
+ default:
+ LOC_LOGE("loc_eng_set_server_proxy, unknown server type = %d", (int) type);
+ }
+ }
+
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_agps_ril_update_network_availability
+
+DESCRIPTION
+ Sets data call allow vs disallow flag to modem
+ This is the only member of sLocEngAGpsRilInterface implemented.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
+ int available, const char* apn)
+{
+ ENTRY_LOG_CALLFLOW();
+
+ //This is to store the status of data availability over the network.
+ //If GPS is not enabled, the INIT_CHECK will fail and the modem will
+ //not be updated with the network's availability. Since the data status
+ //can change before GPS is enabled the, storing the status will enable
+ //us to inform the modem after GPS is enabled
+ agpsStatus = available;
+
+ INIT_CHECK(loc_eng_data.adapter, return);
+ if (apn != NULL)
+ {
+ LOC_LOGD("loc_eng_agps_ril_update_network_availability: APN Name = [%s]\n", apn);
+ int apn_len = smaller_of(strlen (apn), MAX_APN_LEN);
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngEnableData(adapter, apn, apn_len, available));
+ }
+ EXIT_LOG(%s, VOID_RET);
+}
+
+/*===========================================================================
+FUNCTION loc_eng_report_status
+
+DESCRIPTION
+ Reports GPS engine state to Java layer.
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ N/A
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+static void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusValue status)
+{
+ ENTRY_LOG();
+ // Switch from WAIT to MUTE, for "engine on" or "session begin" event
+ if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_ENGINE_ON)
+ {
+ if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_WAIT)
+ {
+ LOC_LOGD("loc_eng_report_status: mute_session_state changed from WAIT to IN SESSION");
+ loc_eng_data.mute_session_state = LOC_MUTE_SESS_IN_SESSION;
+ }
+ }
+
+ // Switch off MUTE session
+ if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_IN_SESSION &&
+ (status == GPS_STATUS_SESSION_END || status == GPS_STATUS_ENGINE_OFF))
+ {
+ LOC_LOGD("loc_eng_report_status: mute_session_state changed from IN SESSION to NONE");
+ loc_eng_data.mute_session_state = LOC_MUTE_SESS_NONE;
+ }
+
+ // Session End is not reported during Android navigating state
+ boolean navigating = loc_eng_data.adapter->isInSession();
+ if (status != GPS_STATUS_NONE &&
+ !(status == GPS_STATUS_SESSION_END && navigating) &&
+ !(status == GPS_STATUS_SESSION_BEGIN && !navigating))
+ {
+ if (loc_eng_data.mute_session_state != LOC_MUTE_SESS_IN_SESSION)
+ {
+ // Inform GpsLocationProvider about mNavigating status
+ loc_inform_gps_status(loc_eng_data, status);
+ }
+ else {
+ LOC_LOGD("loc_eng_report_status: muting the status report.");
+ }
+ }
+
+ // Only keeps ENGINE ON/OFF in engine_status
+ if (status == GPS_STATUS_ENGINE_ON || status == GPS_STATUS_ENGINE_OFF)
+ {
+ loc_eng_data.engine_status = status;
+ }
+
+ // Only keeps SESSION BEGIN/END in fix_session_status
+ if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_SESSION_END)
+ {
+ loc_eng_data.fix_session_status = status;
+ }
+ EXIT_LOG(%s, VOID_RET);
+}
+
+/*===========================================================================
+FUNCTION loc_eng_handle_engine_down
+ loc_eng_handle_engine_up
+
+DESCRIPTION
+ Calls this function when it is detected that modem restart is happening.
+ Either we detected the modem is down or received modem up event.
+ This must be called from the deferred thread to avoid race condition.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ None
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ loc_eng_ni_reset_on_engine_restart(loc_eng_data);
+ loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_OFF);
+ EXIT_LOG(%s, VOID_RET);
+}
+
+void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ loc_eng_reinit(loc_eng_data);
+
+ if (loc_eng_data.agps_status_cb != NULL) {
+ if (loc_eng_data.agnss_nif)
+ loc_eng_data.agnss_nif->dropAllSubscribers();
+ if (loc_eng_data.internet_nif)
+ loc_eng_data.internet_nif->dropAllSubscribers();
+
+ loc_eng_agps_reinit(loc_eng_data);
+ }
+
+ loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_ON);
+
+ // modem is back up. If we crashed in the middle of navigating, we restart.
+ if (loc_eng_data.adapter->isInSession()) {
+ // This sets the copy in adapter to modem
+ loc_eng_data.adapter->setPositionMode(NULL);
+ loc_eng_data.adapter->setInSession(false);
+ loc_eng_start_handler(loc_eng_data);
+ }
+ EXIT_LOG(%s, VOID_RET);
+}
+
+#ifdef USE_GLIB
+/*===========================================================================
+FUNCTION set_sched_policy
+
+DESCRIPTION
+ Local copy of this function which bypasses android set_sched_policy
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+static int set_sched_policy(int tid, SchedPolicy policy)
+{
+ return 0;
+}
+#endif /* USE_GLIB */
+
+/*===========================================================================
+FUNCTION loc_eng_read_config
+
+DESCRIPTION
+ Initiates the reading of the gps config file stored in /etc dir
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_read_config(void)
+{
+ ENTRY_LOG_CALLFLOW();
+ if(configAlreadyRead == false)
+ {
+ // Initialize our defaults before reading of configuration file overwrites them.
+ loc_default_parameters();
+ // We only want to parse the conf file once. This is a good place to ensure that.
+ // In fact one day the conf file should go into context.
+ UTIL_READ_CONF(GPS_CONF_FILE, loc_parameter_table);
+ UTIL_READ_CONF(SAP_CONF_FILE, loc_parameter_table);
+ configAlreadyRead = true;
+ } else {
+ LOC_LOGV("GPS Config file has already been read\n");
+ }
+
+ EXIT_LOG(%d, 0);
+ return 0;
+}
diff --git a/gps/libloc_api_50001/loc_eng.h b/gps/loc_api/libloc_api_50001/loc_eng.h
index 253d9ef..d5560b7 100644
--- a/gps/libloc_api_50001/loc_eng.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -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 */
@@ -68,6 +67,8 @@ typedef unsigned char boolean;
#define FAILURE FALSE
#define INVALID_ATL_CONNECTION_HANDLE -1
+#define MAX_XTRA_SERVER_URL_LENGTH 256
+
enum loc_nmea_provider_e_type {
NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA
NMEA_PROVIDER_MP // Modem Processor Provider of NMEA
@@ -79,41 +80,21 @@ 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
+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;
- agps_status_callback agps_status_cb;
+ agps_status_extended agps_status_cb;
gps_nmea_callback nmea_cb;
gps_ni_notify_callback ni_notify_cb;
gps_acquire_wakelock acquire_wakelock_cb;
gps_release_wakelock release_wakelock_cb;
gps_request_utc_time request_utc_time_cb;
- ulp_network_location_request ulp_network_callback;
- ulp_request_phone_context ulp_phone_context_req_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;
@@ -121,6 +102,8 @@ typedef struct
AgpsStateMachine* agnss_nif;
AgpsStateMachine* internet_nif;
AgpsStateMachine* wifi_nif;
+ //State machine for Data Services
+ AgpsStateMachine* ds_nif;
// GPS engine status
GpsStatusValue engine_status;
@@ -129,8 +112,6 @@ typedef struct
// 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,52 +132,62 @@ typedef struct
int mpc_host_set;
char mpc_host_buf[101];
int mpc_port_buf;
- bool ulp_initialized;
-} loc_eng_data_s_type;
-#include "ulp.h"
+ loc_ext_parser location_ext_parser;
+ loc_ext_parser sv_ext_parser;
+} loc_eng_data_s_type;
/* GPS.conf support */
typedef struct loc_gps_cfg_s
{
- unsigned long INTERMEDIATE_POS;
- unsigned long ACCURACY_THRES;
- unsigned long ENABLE_WIPER;
- uint8_t NMEA_PROVIDER;
- unsigned long SUPL_VER;
- unsigned long CAPABILITIES;
- uint8_t GYRO_BIAS_RANDOM_WALK_VALID;
- double GYRO_BIAS_RANDOM_WALK;
- unsigned long SENSOR_ACCEL_BATCHES_PER_SEC;
- unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH;
- unsigned long SENSOR_GYRO_BATCHES_PER_SEC;
- unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH;
- unsigned long SENSOR_ACCEL_BATCHES_PER_SEC_HIGH;
- unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH;
- unsigned long SENSOR_GYRO_BATCHES_PER_SEC_HIGH;
- unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH;
- unsigned long SENSOR_CONTROL_MODE;
- unsigned long SENSOR_USAGE;
- unsigned long QUIPC_ENABLED;
- unsigned long LPP_PROFILE;
- unsigned long SENSOR_ALGORITHM_CONFIG_MASK;
- uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
- double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY;
- uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
- double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY;
- uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
- double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
- uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
- double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
+ unsigned long INTERMEDIATE_POS;
+ unsigned long ACCURACY_THRES;
+ unsigned long SUPL_VER;
+ unsigned long CAPABILITIES;
+ unsigned long QUIPC_ENABLED;
+ unsigned long LPP_PROFILE;
+ uint8_t NMEA_PROVIDER;
+ unsigned long A_GLONASS_POS_PROTOCOL_SELECT;
+ unsigned long XTRA_VERSION_CHECK;
+ char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH];
+ char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH];
+ char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH];
} loc_gps_cfg_s_type;
+typedef struct
+{
+ uint8_t GYRO_BIAS_RANDOM_WALK_VALID;
+ double GYRO_BIAS_RANDOM_WALK;
+ unsigned long SENSOR_ACCEL_BATCHES_PER_SEC;
+ unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH;
+ unsigned long SENSOR_GYRO_BATCHES_PER_SEC;
+ unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH;
+ unsigned long SENSOR_ACCEL_BATCHES_PER_SEC_HIGH;
+ unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH;
+ unsigned long SENSOR_GYRO_BATCHES_PER_SEC_HIGH;
+ unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH;
+ unsigned long SENSOR_CONTROL_MODE;
+ unsigned long SENSOR_USAGE;
+ unsigned long SENSOR_ALGORITHM_CONFIG_MASK;
+ uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY;
+ uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY;
+ uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
+ uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
+ double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
+ unsigned long SENSOR_PROVIDER;
+} loc_sap_cfg_s_type;
+
extern loc_gps_cfg_s_type gps_conf;
+extern loc_sap_cfg_s_type sap_conf;
+//loc_eng functions
int loc_eng_init(loc_eng_data_s_type &loc_eng_data,
LocCallbacks* callbacks,
LOC_API_ADAPTER_EVENT_MASK_T event,
- void (*loc_external_msg_sender) (void*, void*));
-int loc_eng_ulp_init(loc_eng_data_s_type &loc_eng_data, const ulpInterface * loc_eng_ulpInf);
+ ContextBase* context);
int loc_eng_start(loc_eng_data_s_type &loc_eng_data);
int loc_eng_stop(loc_eng_data_s_type &loc_eng_data);
void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data);
@@ -212,53 +203,39 @@ int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,
LocPosMode &params);
const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data,
const char* name);
-int loc_eng_update_criteria(loc_eng_data_s_type &loc_eng_data,
- UlpLocationCriteria criteria);
-
-
-void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data,
- AGpsCallbacks* callbacks);
-int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType,
- const char* apn, AGpsBearerType bearerType);
-int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType);
-int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType);
int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,
LocServerType type, const char *hostname, int port);
+void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data);
+int loc_eng_read_config(void);
+//loc_eng_agps functions
+void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data,
+ AGpsExtCallbacks* callbacks);
+int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType,
+ const char* apn, AGpsBearerType bearerType);
+int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
+int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
int avaiable, const char* apn);
-
-bool loc_eng_inject_raw_command(loc_eng_data_s_type &loc_eng_data,
- char* command, int length);
-
-
-void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data);
-
-int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
- GpsXtraCallbacks* callbacks);
-
-int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
+//loc_eng_xtra functions
+int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
+ GpsXtraExtCallbacks* callbacks);
+int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
char* data, int length);
+int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data);
+void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, int check);
+//loc_eng_ni functions
extern void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data,
- GpsNiCallbacks *callbacks);
+ GpsNiExtCallbacks *callbacks);
extern void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
int notif_id, GpsUserResponseType user_response);
extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
const GpsNiNotification *notif,
const void* passThrough);
extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);
-int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data, UlpNetworkLocationCallbacks *callbacks);
-
-int loc_eng_ulp_phone_context_settings_update(loc_eng_data_s_type &loc_eng_data,
- UlpPhoneContextSettings *settings);
-int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data,
- UlpPhoneContextCallbacks *callback);
-int loc_eng_ulp_send_network_position(loc_eng_data_s_type &loc_eng_data,
- UlpNetworkPositionReport *position_report);
-int loc_eng_read_config(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gps/libloc_api_50001/loc_eng_agps.cpp b/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp
index 5788040..d6cc136 100644
--- a/gps/libloc_api_50001/loc_eng_agps.cpp
+++ b/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011,2012, 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -33,8 +33,10 @@
#include <loc_eng_agps.h>
#include <loc_eng_log.h>
#include <log_util.h>
+#include <platform_lib_includes.h>
#include <loc_eng_dmn_conn_handler.h>
#include <loc_eng_dmn_conn.h>
+#include <sys/time.h>
//======================================================================
// C callbacks
@@ -84,8 +86,8 @@ static bool notifySubscriber(void* fromCaller, void* fromList)
const int Notification::BROADCAST_ALL = 0x80000000;
const int Notification::BROADCAST_ACTIVE = 0x80000001;
const int Notification::BROADCAST_INACTIVE = 0x80000002;
-
-
+const unsigned char DSStateMachine::MAX_START_DATA_CALL_RETRIES = 4;
+const unsigned int DSStateMachine::DATA_CALL_RETRY_DELAY_MSEC = 500;
//======================================================================
// Subscriber: BITSubscriber / ATLSubscriber / WIFISubscriber
//======================================================================
@@ -107,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 &notification)
@@ -150,13 +152,13 @@ bool ATLSubscriber::notifyRsrcStatus(Notification &notification)
{
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
- ((LocApiAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
+ ((LocEngAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
break;
case RSRC_DENIED:
{
- AGpsType type = mBackwardCompatibleMode ?
+ AGpsExtType type = mBackwardCompatibleMode ?
AGPS_TYPE_INVALID : mStateMachine->getType();
- ((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
+ ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
(char*)mStateMachine->getAPN(),
mStateMachine->getBearer(),
type);
@@ -164,9 +166,9 @@ bool ATLSubscriber::notifyRsrcStatus(Notification &notification)
break;
case RSRC_GRANTED:
{
- AGpsType type = mBackwardCompatibleMode ?
+ AGpsExtType type = mBackwardCompatibleMode ?
AGPS_TYPE_INVALID : mStateMachine->getType();
- ((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
+ ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
(char*)mStateMachine->getAPN(),
mStateMachine->getBearer(),
type);
@@ -211,8 +213,29 @@ bool WIFISubscriber::notifyRsrcStatus(Notification &notification)
return notify;
}
-
-
+bool DSSubscriber::notifyRsrcStatus(Notification &notification)
+{
+ bool notify = forMe(notification);
+ LOC_LOGD("DSSubscriber::notifyRsrcStatus. notify:%d \n",(int)(notify));
+ if(notify) {
+ switch(notification.rsrcStatus) {
+ case RSRC_UNSUBSCRIBE:
+ case RSRC_RELEASED:
+ case RSRC_DENIED:
+ case RSRC_GRANTED:
+ ((DSStateMachine *)mStateMachine)->informStatus(notification.rsrcStatus, ID);
+ break;
+ default:
+ notify = false;
+ }
+ }
+ return notify;
+}
+void DSSubscriber :: setInactive()
+{
+ mIsInactive = true;
+ ((DSStateMachine *)mStateMachine)->informStatus(RSRC_UNSUBSCRIBE, ID);
+}
//======================================================================
// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState
//======================================================================
@@ -234,13 +257,14 @@ public:
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
+ LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event);
if (mStateMachine->hasSubscribers()) {
LOC_LOGE("Error: %s subscriber list not empty!!!", whoami());
// I don't know how to recover from it. I am adding this rather
// for debugging purpose.
}
- AgpsState* nextState = this;;
+ AgpsState* nextState = this;
switch (event)
{
case RSRC_SUBSCRIBE:
@@ -248,13 +272,16 @@ AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
// no notification until we get RSRC_GRANTED
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
- // move the state to PENDING
- nextState = mPendingState;
-
// request from connecivity service for NIF
- mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);
+ //The if condition is added so that if the data call setup fails
+ //for DS State Machine, we want to retry in released state.
+ //for AGps State Machine, sendRsrcRequest() will always return success
+ if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) {
+ // move the state to PENDING
+ nextState = mPendingState;
+ }
}
- break;
+ break;
case RSRC_UNSUBSCRIBE:
{
@@ -298,6 +325,7 @@ public:
AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
+ LOC_LOGD("AgpsPendingState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
@@ -336,7 +364,7 @@ AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
}
}
- break;
+ break;
case RSRC_GRANTED:
{
@@ -393,6 +421,7 @@ public:
AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;
+ LOC_LOGD("AgpsAcquiredState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
@@ -485,7 +514,9 @@ public:
AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
- switch (event)
+ LOC_LOGD("AgpsReleasingState::onRsrcEvent; event:%d\n", (int)event);
+
+ switch (event)
{
case RSRC_SUBSCRIBE:
{
@@ -526,7 +557,7 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
// by setting false, we keep subscribers on the linked list
mStateMachine->notifySubscribers(notification);
- if (mStateMachine->hasSubscribers()) {
+ if (mStateMachine->hasActiveSubscribers()) {
nextState = mPendingState;
// request from connecivity service for NIF
mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);
@@ -546,20 +577,59 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
whoami(), nextState->whoami(), event);
return nextState;
}
+//======================================================================
+//Servicer
+//======================================================================
+Servicer* Servicer :: getServicer(servicerType type, void *cb_func)
+{
+ LOC_LOGD(" Enter getServicer type:%d\n", (int)type);
+ switch(type) {
+ case servicerTypeNoCbParam:
+ return (new Servicer(cb_func));
+ case servicerTypeExt:
+ return (new ExtServicer(cb_func));
+ case servicerTypeAgps:
+ return (new AGpsServicer(cb_func));
+ default:
+ return NULL;
+ }
+}
+
+int Servicer :: requestRsrc(void *cb_data)
+{
+ callback();
+ return 0;
+}
+
+int ExtServicer :: requestRsrc(void *cb_data)
+{
+ int ret=-1;
+ LOC_LOGD("Enter ExtServicer :: requestRsrc\n");
+ ret = callbackExt(cb_data);
+ LOC_LOGD("Exit ExtServicer :: requestRsrc\n");
+ return(ret);
+}
+int AGpsServicer :: requestRsrc(void *cb_data)
+{
+ callbackAGps((AGpsStatus *)cb_data);
+ return 0;
+}
//======================================================================
// AgpsStateMachine
//======================================================================
-AgpsStateMachine::AgpsStateMachine(void (*servicer)(AGpsStatus* status),
- AGpsType type,
+AgpsStateMachine::AgpsStateMachine(servicerType servType,
+ void *cb_func,
+ AGpsExtType type,
bool enforceSingleSubscriber) :
- mServicer(servicer), mType(type),
- mStatePtr(new AgpsReleasedState(this)),
+ mStatePtr(new AgpsReleasedState(this)),mType(type),
mAPN(NULL),
mAPNLen(0),
- mEnforceSingleSubscriber(enforceSingleSubscriber)
+ mBearer(AGPS_APN_BEARER_INVALID),
+ mEnforceSingleSubscriber(enforceSingleSubscriber),
+ mServicer(Servicer :: getServicer(servType, (void *)cb_func))
{
linked_list_init(&mSubscribers);
@@ -600,6 +670,7 @@ AgpsStateMachine::~AgpsStateMachine()
delete releasedState;
delete pendindState;
delete releasingState;
+ delete mServicer;
linked_list_destroy(&mSubscribers);
if (NULL != mAPN) {
@@ -654,6 +725,7 @@ void AgpsStateMachine::notifySubscribers(Notification& notification) const
// rest of the list unprocessed. So we need a loop.
linked_list_search(mSubscribers, (void**)&s, notifySubscriber,
(void*)&notification, true);
+ delete s;
}
} else {
// no loop needed if it the last param sets to false, which
@@ -675,7 +747,7 @@ void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const
}
}
-void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
+int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
@@ -683,7 +755,7 @@ void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
(void*)&notification, false);
if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) {
- AGpsStatus nifRequest;
+ AGpsExtStatus nifRequest;
nifRequest.size = sizeof(nifRequest);
nifRequest.type = mType;
nifRequest.status = action;
@@ -699,8 +771,9 @@ void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
}
CALLBACK_LOG_CALLFLOW("agps_cb", %s, loc_get_agps_status_name(action));
- (*mServicer)(&nifRequest);
+ mServicer->requestRsrc((void *)&nifRequest);
}
+ return 0;
}
void AgpsStateMachine::subscribeRsrc(Subscriber *subscriber)
@@ -735,3 +808,163 @@ bool AgpsStateMachine::hasActiveSubscribers() const
hasSubscriber, (void*)&notification, false);
return NULL != s;
}
+
+//======================================================================
+// DSStateMachine
+//======================================================================
+void delay_callback(void *callbackData, int result)
+{
+ if(callbackData) {
+ DSStateMachine *DSSMInstance = (DSStateMachine *)callbackData;
+ DSSMInstance->retryCallback();
+ }
+ else {
+ LOC_LOGE(" NULL argument received. Failing.\n");
+ goto err;
+ }
+err:
+ return;
+}
+
+DSStateMachine :: DSStateMachine(servicerType type, void *cb_func,
+ LocEngAdapter* adapterHandle):
+ AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false),
+ mLocAdapter(adapterHandle)
+{
+ LOC_LOGD("%s:%d]: New DSStateMachine\n", __func__, __LINE__);
+ mRetries = 0;
+}
+
+void DSStateMachine :: retryCallback(void)
+{
+ DSSubscriber *subscriber = NULL;
+ Notification notification(Notification::BROADCAST_ACTIVE);
+ linked_list_search(mSubscribers, (void**)&subscriber, hasSubscriber,
+ (void*)&notification, false);
+ if(subscriber)
+ mLocAdapter->requestSuplES(subscriber->ID);
+ else
+ LOC_LOGE("DSStateMachine :: retryCallback: No subscriber found." \
+ "Cannot retry data call\n");
+ return;
+}
+
+int DSStateMachine :: sendRsrcRequest(AGpsStatusValue action) const
+{
+ DSSubscriber* s = NULL;
+ dsCbData cbData;
+ int ret=-1;
+ int connHandle=-1;
+ LOC_LOGD("Enter DSStateMachine :: sendRsrcRequest\n");
+ Notification notification(Notification::BROADCAST_ACTIVE);
+ linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
+ (void*)&notification, false);
+ if(s) {
+ connHandle = s->ID;
+ LOC_LOGD("DSStateMachine :: sendRsrcRequest - subscriber found\n");
+ }
+ else
+ LOC_LOGD("DSStateMachine :: sendRsrcRequest - No subscriber found\n");
+
+ cbData.action = action;
+ cbData.mAdapter = mLocAdapter;
+ ret = mServicer->requestRsrc((void *)&cbData);
+ //Only the request to start data call returns a success/failure
+ //The request to stop data call will always succeed
+ //Hence, the below block will only be executed when the
+ //request to start the data call fails
+ switch(ret) {
+ case LOC_API_ADAPTER_ERR_ENGINE_BUSY:
+ LOC_LOGD("DSStateMachine :: sendRsrcRequest - Failure returned: %d\n",ret);
+ ((DSStateMachine *)this)->incRetries();
+ if(mRetries > MAX_START_DATA_CALL_RETRIES) {
+ LOC_LOGE(" Failed to start Data call. Fallback to normal ATL SUPL\n");
+ informStatus(RSRC_DENIED, connHandle);
+ }
+ else {
+ if(loc_timer_start(DATA_CALL_RETRY_DELAY_MSEC, delay_callback, (void *)this)) {
+ LOC_LOGE("Error: Could not start delay thread\n");
+ ret = -1;
+ goto err;
+ }
+ }
+ break;
+ case LOC_API_ADAPTER_ERR_UNSUPPORTED:
+ LOC_LOGE("No profile found for emergency call. Fallback to normal SUPL ATL\n");
+ informStatus(RSRC_DENIED, connHandle);
+ break;
+ case LOC_API_ADAPTER_ERR_SUCCESS:
+ LOC_LOGD("%s:%d]: Request to start data call sent\n", __func__, __LINE__);
+ break;
+ case -1:
+ //One of the ways this case can be encountered is if the callback function
+ //receives a null argument, it just exits with -1 error
+ LOC_LOGE("Error: Something went wrong somewhere. Falling back to normal SUPL ATL\n");
+ informStatus(RSRC_DENIED, connHandle);
+ break;
+ default:
+ LOC_LOGE("%s:%d]: Unrecognized return value\n", __func__, __LINE__);
+ }
+err:
+ LOC_LOGD("EXIT DSStateMachine :: sendRsrcRequest; ret = %d\n", ret);
+ return ret;
+}
+
+void DSStateMachine :: onRsrcEvent(AgpsRsrcStatus event)
+{
+ void* currState = (void *)mStatePtr;
+ LOC_LOGD("Enter DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
+ switch (event)
+ {
+ case RSRC_GRANTED:
+ LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_GRANTED\n");
+ mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
+ break;
+ case RSRC_RELEASED:
+ LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_RELEASED\n");
+ mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
+ //To handle the case where we get a RSRC_RELEASED in
+ //pending state, we translate that to a RSRC_DENIED state
+ //since the callback from DSI is either RSRC_GRANTED or RSRC_RELEASED
+ //for when the call is connected or disconnected respectively.
+ if((void *)mStatePtr != currState)
+ break;
+ else {
+ event = RSRC_DENIED;
+ LOC_LOGE(" Switching event to RSRC_DENIED\n");
+ }
+ case RSRC_DENIED:
+ mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
+ break;
+ default:
+ LOC_LOGW("AgpsStateMachine: unrecognized event %d", event);
+ break;
+ }
+ LOC_LOGD("Exit DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
+}
+
+void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const
+{
+ LOC_LOGD("DSStateMachine :: informStatus. Status=%d\n",(int)status);
+ switch(status) {
+ case RSRC_UNSUBSCRIBE:
+ mLocAdapter->atlCloseStatus(ID, 1);
+ break;
+ case RSRC_RELEASED:
+ mLocAdapter->closeDataCall();
+ break;
+ case RSRC_DENIED:
+ ((DSStateMachine *)this)->mRetries = 0;
+ mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL);
+ break;
+ case RSRC_GRANTED:
+ mLocAdapter->atlOpenStatus(ID, 1,
+ NULL,
+ AGPS_APN_BEARER_INVALID,
+ AGPS_TYPE_INVALID);
+ break;
+ default:
+ LOC_LOGW("DSStateMachine :: informStatus - unknown status");
+ }
+ return;
+}
diff --git a/gps/libloc_api_50001/loc_eng_agps.h b/gps/loc_api/libloc_api_50001/loc_eng_agps.h
index b453cdc..9915a70 100644
--- a/gps/libloc_api_50001/loc_eng_agps.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_agps.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011,2012, 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -34,10 +34,12 @@
#include <ctype.h>
#include <string.h>
#include <arpa/inet.h>
-#include <hardware/gps.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;
@@ -53,6 +55,18 @@ typedef enum {
RSRC_STATUS_MAX
} AgpsRsrcStatus;
+typedef enum {
+ servicerTypeNoCbParam,
+ servicerTypeAgps,
+ servicerTypeExt
+}servicerType;
+
+//DS Callback struct
+typedef struct {
+ LocEngAdapter *mAdapter;
+ AGpsStatusValue action;
+}dsCbData;
+
// information bundle for subscribers
struct Notification {
// goes to every subscriber
@@ -101,7 +115,7 @@ class AgpsState {
// no class members are public. We don't want
// anyone but state machine to use state.
friend class AgpsStateMachine;
-
+ friend class DSStateMachine;
// state transitions are done here.
// Each state implements its own transitions (of course).
inline virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data) = 0;
@@ -129,21 +143,56 @@ public:
inline virtual char* whoami() = 0;
};
+class Servicer {
+ void (*callback)(void);
+public:
+ static Servicer* getServicer(servicerType type, void *cb_func);
+ virtual int requestRsrc(void *cb_data);
+ Servicer() {}
+ Servicer(void *cb_func)
+ { callback = (void(*)(void))(cb_func); }
+ virtual ~Servicer(){}
+ inline virtual char *whoami() {return (char*)"Servicer";}
+};
+
+class ExtServicer : public Servicer {
+ int (*callbackExt)(void *cb_data);
+public:
+ int requestRsrc(void *cb_data);
+ ExtServicer() {}
+ ExtServicer(void *cb_func)
+ { callbackExt = (int(*)(void *))(cb_func); }
+ virtual ~ExtServicer(){}
+ inline virtual char *whoami() {return (char*)"ExtServicer";}
+};
+
+class AGpsServicer : public Servicer {
+ void (*callbackAGps)(AGpsStatus* status);
+public:
+ int requestRsrc(void *cb_data);
+ AGpsServicer() {}
+ AGpsServicer(void *cb_func)
+ { callbackAGps = (void(*)(AGpsStatus *))(cb_func); }
+ virtual ~AGpsServicer(){}
+ inline virtual char *whoami() {return (char*)"AGpsServicer";}
+};
+
class AgpsStateMachine {
+protected:
+ // a linked list of subscribers.
+ void* mSubscribers;
+ //handle to whoever provides the service
+ Servicer *mServicer;
// allows AgpsState to access private data
// each state is really internal data to the
// state machine, so it should be able to
// access anything within the state machine.
friend class AgpsState;
-
- // handle to whoever provides the service
- void (* const mServicer)(AGpsStatus* status);
- // NIF type: AGNSS or INTERNET.
- const AGpsType mType;
// pointer to the current state.
AgpsState* mStatePtr;
- // a linked list of subscribers.
- void* mSubscribers;
+private:
+ // NIF type: AGNSS or INTERNET.
+ const AGpsExtType mType;
// apn to the NIF. Each state machine tracks
// resource state of a particular NIF. For each
// NIF, there is also an active APN.
@@ -156,7 +205,8 @@ class AgpsStateMachine {
bool mEnforceSingleSubscriber;
public:
- AgpsStateMachine(void (*servicer)(AGpsStatus* status), AGpsType type, bool enforceSingleSubscriber);
+ AgpsStateMachine(servicerType servType, void *cb_func,
+ AGpsExtType type, bool enforceSingleSubscriber);
virtual ~AgpsStateMachine();
// self explanatory methods below
@@ -164,7 +214,7 @@ public:
inline const char* getAPN() const { return (const char*)mAPN; }
inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; }
inline AGpsBearerType getBearer() const { return mBearer; }
- inline AGpsType getType() const { return (AGpsType)mType; }
+ inline AGpsExtType getType() const { return (AGpsExtType)mType; }
// someone, a ATL client or BIT, is asking for NIF
void subscribeRsrc(Subscriber *subscriber);
@@ -175,11 +225,15 @@ public:
// add a subscriber in the linked list, if not already there.
void addSubscriber(Subscriber* subscriber) const;
- void onRsrcEvent(AgpsRsrcStatus event);
+ virtual void onRsrcEvent(AgpsRsrcStatus event);
// put the data together and send the FW
- void sendRsrcRequest(AGpsStatusValue action) const;
+ virtual int sendRsrcRequest(AGpsStatusValue action) const;
+ //if list is empty, linked_list_empty returns 1
+ //else if list is not empty, returns 0
+ //so hasSubscribers() returns 1 if list is not empty
+ //and returns 0 if list is empty
inline bool hasSubscribers() const
{ return !linked_list_empty(mSubscribers); }
@@ -190,20 +244,38 @@ public:
// private. Only a state gets to call this.
void notifySubscribers(Notification& notification) const;
+
+};
+
+class DSStateMachine : public AgpsStateMachine {
+ static const unsigned char MAX_START_DATA_CALL_RETRIES;
+ static const unsigned int DATA_CALL_RETRY_DELAY_MSEC;
+ LocEngAdapter* mLocAdapter;
+ unsigned char mRetries;
+public:
+ DSStateMachine(servicerType type,
+ void *cb_func,
+ LocEngAdapter* adapterHandle);
+ int sendRsrcRequest(AGpsStatusValue action) const;
+ void onRsrcEvent(AgpsRsrcStatus event);
+ void retryCallback();
+ void informStatus(AgpsRsrcStatus status, int ID) const;
+ inline void incRetries() {mRetries++;}
+ inline virtual char *whoami() {return (char*)"DSStateMachine";}
};
// each subscriber is a AGPS client. In the case of ATL, there could be
// multiple clients from modem. In the case of BIT, there is only one
// cilent from BIT daemon.
struct Subscriber {
- const int ID;
+ const uint32_t ID;
const AgpsStateMachine* mStateMachine;
inline Subscriber(const int id,
const AgpsStateMachine* stateMachine) :
ID(id), mStateMachine(stateMachine) {}
inline virtual ~Subscriber() {}
- virtual void setIPAddresses(int &v4, char* v6) = 0;
+ virtual void setIPAddresses(uint32_t &v4, char* v6) = 0;
inline virtual void setWifiInfo(char* ssid, char* password)
{ ssid[0] = 0; password[0] = 0; }
@@ -226,46 +298,46 @@ 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 &notification);
- inline virtual void setIPAddresses(int &v4, char* v6)
- { v4 = ID; memcpy(v6, ipv6Addr, sizeof(ipv6Addr)); }
+ inline virtual void setIPAddresses(uint32_t &v4, char* v6)
+ { 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;
-
-private:
- char ipv6Addr[16];
+ inline virtual ~BITSubscriber(){}
};
// 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){}
virtual bool notifyRsrcStatus(Notification &notification);
- inline virtual void setIPAddresses(int &v4, char* v6)
+ inline virtual void setIPAddresses(uint32_t &v4, char* v6)
{ v4 = INADDR_NONE; v6[0] = 0; }
inline virtual Subscriber* clone()
@@ -273,6 +345,7 @@ struct ATLSubscriber : public Subscriber {
return new ATLSubscriber(ID, mStateMachine, mLocAdapter,
mBackwardCompatibleMode);
}
+ inline virtual ~ATLSubscriber(){}
};
// WIFISubscriber, created with requests from MSAPM or QuIPC
@@ -297,7 +370,7 @@ struct WIFISubscriber : public Subscriber {
virtual bool notifyRsrcStatus(Notification &notification);
- inline virtual void setIPAddresses(int &v4, char* v6) {}
+ inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
inline virtual void setWifiInfo(char* ssid, char* password)
{
@@ -320,6 +393,27 @@ struct WIFISubscriber : public Subscriber {
{
return new WIFISubscriber(mStateMachine, mSSID, mPassword, senderId);
}
+ inline virtual ~WIFISubscriber(){}
+};
+
+struct DSSubscriber : public Subscriber {
+ bool mIsInactive;
+ inline DSSubscriber(const AgpsStateMachine *stateMachine,
+ const int id) :
+ Subscriber(id, stateMachine)
+ {
+ mIsInactive = false;
+ }
+ inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
+ virtual Subscriber* clone()
+ {return new DSSubscriber(mStateMachine, ID);}
+ virtual bool notifyRsrcStatus(Notification &notification);
+ inline virtual bool waitForCloseComplete() { return true; }
+ virtual void setInactive();
+ inline virtual bool isInactive()
+ { return mIsInactive; }
+ inline virtual ~DSSubscriber(){}
+ inline virtual char *whoami() {return (char*)"DSSubscriber";}
};
#endif //__LOC_ENG_AGPS_H__
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp
index bc5edc2..c257dff 100755..100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn.cpp
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011,2012, The Linux Foundation. All rights reserved.
+/* 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -38,7 +38,7 @@
#include <sys/stat.h>
#include "log_util.h"
-
+#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
#include "loc_eng_dmn_conn.h"
@@ -137,7 +137,7 @@ static int loc_api_server_proc(void *context)
free(p_cmsgbuf);
LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__);
usleep(1000);
- return 0;
+ return -1;
}
LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type);
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h
index 9aebd4f..1d8c142 100755..100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011,2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -33,11 +33,11 @@
#ifdef _ANDROID_
-#define GPSONE_LOC_API_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_q"
-#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_resp_q"
-#define QUIPC_CTRL_Q_PATH "/data/misc/gpsone_d/quipc_ctrl_q"
-#define MSAPM_CTRL_Q_PATH "/data/misc/gpsone_d/msapm_ctrl_q"
-#define MSAPU_CTRL_Q_PATH "/data/misc/gpsone_d/msapu_ctrl_q"
+#define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q"
+#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q"
+#define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q"
+#define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q"
+#define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q"
#else
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c
index 6b97a23..a1076ff 100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c
@@ -32,7 +32,7 @@
#include <linux/types.h>
#include "log_util.h"
-
+#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h
index d685c87..d685c87 100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
index 5c24f46..dffcad0 100755..100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
+/* 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -38,7 +38,7 @@
#include "loc_eng_dmn_conn_glue_pipe.h"
#include "log_util.h"
-
+#include "platform_lib_includes.h"
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipeget
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h
index b2fa3a0..b2fa3a0 100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp
index cc81dff..edd53f2 100755..100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011,2012, The Linux Foundation. All rights reserved.
+/* 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -32,6 +32,7 @@
#include <unistd.h>
#include "log_util.h"
+#include "platform_lib_includes.h"
#include "loc_eng_msg.h"
#include "loc_eng_dmn_conn.h"
#include "loc_eng_dmn_conn_handler.h"
@@ -48,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:
@@ -78,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,
- 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);
+ 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,
+ 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,
- 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);
+ 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,
+ 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,
- 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);
+ 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,
+ 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,
- type,
- pmsg->cmsg.cmsg_if_request.ipv4_addr,
- (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr));
- loc_eng_msg_sender(loc_api_handle, msg);
+ LocEngReqRelBIT* msg =
+ new LocEngReqRelBIT(loc_api_handle,
+ type,
+ pmsg->cmsg.cmsg_if_request.ipv4_addr,
+ (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,
+ true);
+ msg->send();
break;
}
default:
@@ -140,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:
@@ -170,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,
- 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);
+ 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,
+ 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,
- 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);
+ 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,
+ 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,
- 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);
+ 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,
+ 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,
- type,
- pmsg->cmsg.cmsg_if_request.ipv4_addr,
- (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr));
- loc_eng_msg_sender(loc_api_handle, msg);
+ LocEngReqRelBIT* msg =
+ new LocEngReqRelBIT(loc_api_handle,
+ type,
+ pmsg->cmsg.cmsg_if_request.ipv4_addr,
+ (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,
+ false);
+ msg->send();
break;
}
default:
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h
index f5b3ee0..8cbb353 100755..100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011,2012, The Linux Foundation. All rights reserved.
+/* 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -33,7 +33,11 @@
#include <arpa/inet.h>
//for SSID_BUF_SIZE
-#include <hardware/gps.h>
+#include "hardware/gps.h"
+
+#ifndef SSID_BUF_SIZE
+ #define SSID_BUF_SIZE (32+1)
+#endif
enum {
/* 0x0 - 0xEF is reserved for daemon internal */
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c
index 67e3187..9fed9d4 100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include "log_util.h"
+#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_thread_helper.h"
/*===========================================================================
diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h
index 89e598b..89e598b 100644
--- a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h
diff --git a/gps/loc_api/libloc_api_50001/loc_eng_log.cpp b/gps/loc_api/libloc_api_50001/loc_eng_log.cpp
new file mode 100644
index 0000000..3a34167
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/loc_eng_log.cpp
@@ -0,0 +1,35 @@
+/* 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_eng"
+
+#include "loc_log.h"
+#include "loc_eng_log.h"
+
diff --git a/gps/loc_api/libloc_api_50001/loc_eng_log.h b/gps/loc_api/libloc_api_50001/loc_eng_log.h
new file mode 100644
index 0000000..a68bd84
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/loc_eng_log.h
@@ -0,0 +1,44 @@
+/* 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_LOG_H
+#define LOC_ENG_LOG_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <ctype.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LOC_ENG_LOG_H */
diff --git a/gps/loc_api/libloc_api_50001/loc_eng_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_msg.h
new file mode 100644
index 0000000..c2e991a
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/loc_eng_msg.h
@@ -0,0 +1,296 @@
+/* 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_MSG_H
+#define LOC_ENG_MSG_H
+
+
+#include "hardware/gps.h"
+#include <gps_extended.h>
+#include <stdlib.h>
+#include <string.h>
+#include <log_util.h>
+#include <loc_eng_log.h>
+#include <loc_eng.h>
+#include <MsgTask.h>
+#include <LocEngAdapter.h>
+
+#ifndef SSID_BUF_SIZE
+ #define SSID_BUF_SIZE (32+1)
+#endif
+#ifdef USE_GLIB
+
+#include <glib.h>
+
+#endif /* USE_GLIB */
+#include "platform_lib_includes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+using namespace loc_core;
+
+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 LocEngStartFix : public LocMsg {
+ LocEngAdapter* mAdapter;
+ LocEngStartFix(LocEngAdapter* adapter);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+ void send() const;
+};
+
+struct LocEngStopFix : public LocMsg {
+ LocEngAdapter* mAdapter;
+ LocEngStopFix(LocEngAdapter* adapter);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+ void send() const;
+};
+
+struct LocEngReportPosition : public LocMsg {
+ LocAdapterBase* mAdapter;
+ const UlpLocation mLocation;
+ const GpsLocationExtended mLocationExtended;
+ const void* mLocationExt;
+ const enum loc_sess_status mStatus;
+ const LocPosTechMask mTechMask;
+ LocEngReportPosition(LocAdapterBase* adapter,
+ 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 LocEngReportSv : public LocMsg {
+ LocAdapterBase* mAdapter;
+ const GpsSvStatus mSvStatus;
+ const GpsLocationExtended mLocationExtended;
+ const void* mSvExt;
+ LocEngReportSv(LocAdapterBase* adapter,
+ GpsSvStatus &sv,
+ GpsLocationExtended &locExtended,
+ void* svExtended);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+ void send() const;
+};
+
+struct LocEngReportStatus : public LocMsg {
+ LocAdapterBase* mAdapter;
+ const GpsStatusValue mStatus;
+ LocEngReportStatus(LocAdapterBase* adapter,
+ 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, bool isReq);
+ virtual ~LocEngReqRelWifi();
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+ void send() const;
+};
+
+struct LocEngRequestXtra : public LocMsg {
+ void* mLocEng;
+ LocEngRequestXtra(void* locEng);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+};
+
+struct LocEngRequestTime : public LocMsg {
+ void* mLocEng;
+ LocEngRequestTime(void* locEng);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+};
+
+struct LocEngRequestNi : public LocMsg {
+ void* mLocEng;
+ const GpsNiNotification mNotify;
+ const void *mPayload;
+ LocEngRequestNi(void* locEng,
+ GpsNiNotification &notif,
+ const void* data);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+};
+
+struct LocEngDown : public LocMsg {
+ void* mLocEng;
+ LocEngDown(void* locEng);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+};
+
+struct LocEngUp : public LocMsg {
+ void* mLocEng;
+ LocEngUp(void* locEng);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+};
+
+struct LocEngGetZpp : public LocMsg {
+ LocEngAdapter* mAdapter;
+ LocEngGetZpp(LocEngAdapter* adapter);
+ virtual void proc() const;
+ void locallog() const;
+ virtual void log() const;
+ void send() const;
+};
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LOC_ENG_MSG_H */
diff --git a/gps/libloc_api_50001/loc_eng_ni.cpp b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp
index 3a6e1d0..4597b98 100644
--- a/gps/libloc_api_50001/loc_eng_ni.cpp
+++ b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -39,10 +39,14 @@
#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;
/*=============================================================================
*
@@ -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
@@ -76,28 +116,45 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
ENTRY_LOG();
char lcs_addr[32]; // Decoded LCS address for UMTS CP NI
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
+ loc_eng_ni_session_s_type* pSession = NULL;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
- /* If busy, use default or deny */
- if (NULL != loc_eng_ni_data_p->rawRequest)
- {
- /* XXX Consider sending a NO RESPONSE reply or queue the request */
- LOC_LOGW("loc_eng_ni_request_handler, notification in progress, new NI request ignored, type: %d",
- notif->ni_type);
- if (NULL != passThrough) {
- free((void*)passThrough);
+ if (notif->ni_type == GPS_NI_TYPE_EMERGENCY_SUPL) {
+ if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
+ LOC_LOGW("loc_eng_ni_request_handler, supl es NI in progress, new supl es NI ignored, type: %d",
+ notif->ni_type);
+ if (NULL != passThrough) {
+ free((void*)passThrough);
+ }
+ } else {
+ pSession = &loc_eng_ni_data_p->sessionEs;
+ }
+ } else {
+ if (NULL != loc_eng_ni_data_p->session.rawRequest ||
+ NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
+ LOC_LOGW("loc_eng_ni_request_handler, supl NI in progress, new supl NI ignored, type: %d",
+ notif->ni_type);
+ if (NULL != passThrough) {
+ free((void*)passThrough);
+ }
+ } else {
+ pSession = &loc_eng_ni_data_p->session;
}
}
- else {
+
+
+ if (pSession) {
/* Save request */
- loc_eng_ni_data_p->rawRequest = (void*)passThrough;
+ pSession->rawRequest = (void*)passThrough;
+ pSession->reqID = ++loc_eng_ni_data_p->reqIDCounter;
+ pSession->adapter = loc_eng_data.adapter;
/* Fill in notification */
- ((GpsNiNotification*)notif)->notification_id = loc_eng_ni_data_p->reqID;
+ ((GpsNiNotification*)notif)->notification_id = pSession->reqID;
if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE)
{
@@ -116,16 +173,16 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
/* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though
* the OEM layer in java does not do so.
**/
- loc_eng_ni_data_p->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);
- LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", loc_eng_ni_data_p->respTimeLeft);
+ pSession->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);
+ LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", pSession->respTimeLeft);
int rc = 0;
- rc = pthread_create(&loc_eng_ni_data_p->thread, NULL, ni_thread_proc, &loc_eng_data);
+ rc = pthread_create(&pSession->thread, NULL, ni_thread_proc, pSession);
if (rc)
{
LOC_LOGE("Loc NI thread is not created.\n");
}
- rc = pthread_detach(loc_eng_ni_data_p->thread);
+ rc = pthread_detach(pSession->thread);
if (rc)
{
LOC_LOGE("Loc NI thread is not detached.\n");
@@ -146,57 +203,65 @@ static void* ni_thread_proc(void *args)
{
ENTRY_LOG();
- loc_eng_data_s_type* loc_eng_data_p = (loc_eng_data_s_type*)args;
- loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data_p->loc_eng_ni_data;
+ loc_eng_ni_session_s_type* pSession = (loc_eng_ni_session_s_type*)args;
int rc = 0; /* return code from pthread calls */
struct timeval present_time;
struct timespec expire_time;
LOC_LOGD("Starting Loc NI thread...\n");
- pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
+ pthread_mutex_lock(&pSession->tLock);
/* Calculate absolute expire time */
gettimeofday(&present_time, NULL);
- expire_time.tv_sec = present_time.tv_sec + loc_eng_ni_data_p->respTimeLeft;
+ expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft;
expire_time.tv_nsec = present_time.tv_usec * 1000;
LOC_LOGD("ni_thread_proc-Time out set for abs time %ld with delay %d sec\n",
- (long) expire_time.tv_sec, loc_eng_ni_data_p->respTimeLeft );
+ (long) expire_time.tv_sec, pSession->respTimeLeft );
- while (!loc_eng_ni_data_p->respRecvd)
+ while (!pSession->respRecvd)
{
- rc = pthread_cond_timedwait(&loc_eng_ni_data_p->tCond,
- &loc_eng_ni_data_p->tLock,
+ rc = pthread_cond_timedwait(&pSession->tCond,
+ &pSession->tLock,
&expire_time);
if (rc == ETIMEDOUT)
{
- loc_eng_ni_data_p->resp = GPS_NI_RESPONSE_NORESP;
+ pSession->resp = GPS_NI_RESPONSE_NORESP;
LOC_LOGD("ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\n",rc );
break;
}
}
LOC_LOGD("ni_thread_proc-Java layer has sent us a user response and return value from "
"pthread_cond_timedwait = %d\n",rc );
- loc_eng_ni_data_p->respRecvd = FALSE; /* Reset the user response flag for the next session*/
+ pSession->respRecvd = FALSE; /* Reset the user response flag for the next session*/
+
+ LOC_LOGD("pSession->resp is %d\n",pSession->resp);
// 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;
-
- 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,
- loc_eng_ni_data_p->resp,
- loc_eng_ni_data_p->rawRequest);
- loc_eng_ni_data_p->rawRequest = NULL;
+ // to exit without calling sending data. We made sure that rawRequest is NULL in
+ // loc_eng_ni_reset_on_engine_restart()
+ LocEngAdapter* adapter = pSession->adapter;
+ LocEngInformNiResponse *msg = NULL;
+
+ if (NULL != pSession->rawRequest) {
+ if (pSession->resp != GPS_NI_RESPONSE_IGNORE) {
+ LOC_LOGD("pSession->resp != GPS_NI_RESPONSE_IGNORE \n");
+ msg = new LocEngInformNiResponse(adapter,
+ pSession->resp,
+ pSession->rawRequest);
+ } else {
+ LOC_LOGD("this is the ignore reply for SUPL ES\n");
+ free(pSession->rawRequest);
+ }
+ pSession->rawRequest = NULL;
}
- pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
+ pthread_mutex_unlock(&pSession->tLock);
- loc_eng_ni_data_p->respTimeLeft = 0;
- loc_eng_ni_data_p->reqID++;
+ pSession->respTimeLeft = 0;
+ pSession->reqID = 0;
if (NULL != msg) {
- loc_eng_msg_sender(loc_eng_data_p, msg);
+ LOC_LOGD("ni_thread_proc: adapter->sendMsg(msg)\n");
+ adapter->sendMsg(msg);
}
EXIT_LOG(%s, VOID_RET);
@@ -214,16 +279,28 @@ void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data)
}
// only if modem has requested but then died.
- if (NULL != loc_eng_ni_data_p->rawRequest) {
- free(loc_eng_ni_data_p->rawRequest);
- loc_eng_ni_data_p->rawRequest = NULL;
+ if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
+ free(loc_eng_ni_data_p->sessionEs.rawRequest);
+ loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
+
+ pthread_mutex_lock(&loc_eng_ni_data_p->sessionEs.tLock);
+ // the goal is to wake up ni_thread_proc
+ // and let it exit.
+ loc_eng_ni_data_p->sessionEs.respRecvd = TRUE;
+ pthread_cond_signal(&loc_eng_ni_data_p->sessionEs.tCond);
+ pthread_mutex_unlock(&loc_eng_ni_data_p->sessionEs.tLock);
+ }
- pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
+ if (NULL != loc_eng_ni_data_p->session.rawRequest) {
+ free(loc_eng_ni_data_p->session.rawRequest);
+ loc_eng_ni_data_p->session.rawRequest = NULL;
+
+ pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
// the goal is to wake up ni_thread_proc
// and let it exit.
- loc_eng_ni_data_p->respRecvd = TRUE;
- pthread_cond_signal(&loc_eng_ni_data_p->tCond);
- pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
+ loc_eng_ni_data_p->session.respRecvd = TRUE;
+ pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
+ pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
}
EXIT_LOG(%s, VOID_RET);
@@ -245,7 +322,7 @@ SIDE EFFECTS
N/A
===========================================================================*/
-void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiCallbacks *callbacks)
+void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiExtCallbacks *callbacks)
{
ENTRY_LOG_CALLFLOW();
@@ -257,12 +334,19 @@ void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiCallbacks *callback
EXIT_LOG(%s, "loc_eng_ni_init: already inited.");
} else {
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
- loc_eng_ni_data_p->respTimeLeft = 0;
- loc_eng_ni_data_p->respRecvd = FALSE;
- loc_eng_ni_data_p->rawRequest = NULL;
- loc_eng_ni_data_p->reqID = 0;
- pthread_cond_init(&loc_eng_ni_data_p->tCond, NULL);
- pthread_mutex_init(&loc_eng_ni_data_p->tLock, NULL);
+ loc_eng_ni_data_p->sessionEs.respTimeLeft = 0;
+ loc_eng_ni_data_p->sessionEs.respRecvd = FALSE;
+ loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
+ loc_eng_ni_data_p->sessionEs.reqID = 0;
+ pthread_cond_init(&loc_eng_ni_data_p->sessionEs.tCond, NULL);
+ pthread_mutex_init(&loc_eng_ni_data_p->sessionEs.tLock, NULL);
+
+ loc_eng_ni_data_p->session.respTimeLeft = 0;
+ loc_eng_ni_data_p->session.respRecvd = FALSE;
+ loc_eng_ni_data_p->session.rawRequest = NULL;
+ loc_eng_ni_data_p->session.reqID = 0;
+ pthread_cond_init(&loc_eng_ni_data_p->session.tCond, NULL);
+ pthread_mutex_init(&loc_eng_ni_data_p->session.tLock, NULL);
loc_eng_data.ni_notify_cb = callbacks->notify_cb;
EXIT_LOG(%s, VOID_RET);
@@ -290,25 +374,40 @@ void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
{
ENTRY_LOG_CALLFLOW();
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
+ loc_eng_ni_session_s_type* pSession = NULL;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
- if (notif_id == loc_eng_ni_data_p->reqID &&
- NULL != loc_eng_ni_data_p->rawRequest)
- {
+ if (notif_id == loc_eng_ni_data_p->sessionEs.reqID &&
+ NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
+ pSession = &loc_eng_ni_data_p->sessionEs;
+ // ignore any SUPL NI non-Es session if a SUPL NI ES is accepted
+ if (user_response == GPS_NI_RESPONSE_ACCEPT &&
+ NULL != loc_eng_ni_data_p->session.rawRequest) {
+ pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
+ loc_eng_ni_data_p->session.resp = GPS_NI_RESPONSE_IGNORE;
+ loc_eng_ni_data_p->session.respRecvd = TRUE;
+ pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
+ pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
+ }
+ } else if (notif_id == loc_eng_ni_data_p->session.reqID &&
+ NULL != loc_eng_ni_data_p->session.rawRequest) {
+ pSession = &loc_eng_ni_data_p->session;
+ }
+
+ if (pSession) {
LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
- pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
- loc_eng_ni_data_p->resp = user_response;
- loc_eng_ni_data_p->respRecvd = TRUE;
- pthread_cond_signal(&loc_eng_ni_data_p->tCond);
- pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
+ pthread_mutex_lock(&pSession->tLock);
+ pSession->resp = user_response;
+ pSession->respRecvd = TRUE;
+ pthread_cond_signal(&pSession->tCond);
+ pthread_mutex_unlock(&pSession->tLock);
}
else {
- LOC_LOGE("loc_eng_ni_respond: reqID %d and notif_id %d mismatch or rawRequest %p, response: %d",
- loc_eng_ni_data_p->reqID, notif_id, loc_eng_ni_data_p->rawRequest, user_response);
+ LOC_LOGE("loc_eng_ni_respond: notif_id %d not an active session", notif_id);
}
EXIT_LOG(%s, VOID_RET);
diff --git a/gps/libloc_api_50001/loc_eng_ni.h b/gps/loc_api/libloc_api_50001/loc_eng_ni.h
index 9cbc57d..068f5cd 100644
--- a/gps/libloc_api_50001/loc_eng_ni.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_ni.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2009,2011,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,9 +31,11 @@
#define LOC_ENG_NI_H
#include <stdbool.h>
+#include <LocEngAdapter.h>
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
+#define GPS_NI_RESPONSE_IGNORE 4
typedef struct {
pthread_t thread; /* NI thread */
@@ -44,6 +46,13 @@ typedef struct {
GpsUserResponseType resp;
pthread_cond_t tCond;
pthread_mutex_t tLock;
+ LocEngAdapter* adapter;
+} loc_eng_ni_session_s_type;
+
+typedef struct {
+ loc_eng_ni_session_s_type session; /* SUPL NI Session */
+ loc_eng_ni_session_s_type sessionEs; /* Emergency SUPL NI Session */
+ int reqIDCounter;
} loc_eng_ni_data_s_type;
diff --git a/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp
new file mode 100644
index 0000000..4c6b9a3
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp
@@ -0,0 +1,836 @@
+/* Copyright (c) 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_eng_nmea"
+#define GPS_PRN_START 1
+#define GPS_PRN_END 32
+#define GLONASS_PRN_START 65
+#define GLONASS_PRN_END 96
+#include <loc_eng.h>
+#include <loc_eng_nmea.h>
+#include <math.h>
+#include "log_util.h"
+
+/*===========================================================================
+FUNCTION loc_eng_nmea_send
+
+DESCRIPTION
+ send out NMEA sentence
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ Total length of the nmea sentence
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p)
+{
+ struct timeval tv;
+ gettimeofday(&tv, (struct timezone *) NULL);
+ int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
+ CALLBACK_LOG_CALLFLOW("nmea_cb", %p, pNmea);
+ if (loc_eng_data_p->nmea_cb != NULL)
+ loc_eng_data_p->nmea_cb(now, pNmea, length);
+ LOC_LOGD("NMEA <%s", pNmea);
+}
+
+/*===========================================================================
+FUNCTION loc_eng_nmea_put_checksum
+
+DESCRIPTION
+ Generate NMEA sentences generated based on position report
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ Total length of the nmea sentence
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_nmea_put_checksum(char *pNmea, int maxSize)
+{
+ uint8_t checksum = 0;
+ int length = 0;
+
+ pNmea++; //skip the $
+ while (*pNmea != '\0')
+ {
+ checksum ^= *pNmea++;
+ length++;
+ }
+
+ int checksumLength = snprintf(pNmea,(maxSize-length-1),"*%02X\r\n", checksum);
+ return (length + checksumLength);
+}
+
+/*===========================================================================
+FUNCTION loc_eng_nmea_generate_pos
+
+DESCRIPTION
+ Generate NMEA sentences generated based on position report
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
+ const UlpLocation &location,
+ const GpsLocationExtended &locationExtended,
+ unsigned char generate_nmea)
+{
+ ENTRY_LOG();
+ time_t utcTime(location.gpsLocation.timestamp/1000);
+ tm * pTm = gmtime(&utcTime);
+ if (NULL == pTm) {
+ LOC_LOGE("gmtime failed");
+ return;
+ }
+
+ char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
+ char* pMarker = sentence;
+ int lengthRemaining = sizeof(sentence);
+ int length = 0;
+ int utcYear = pTm->tm_year % 100; // 2 digit year
+ int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero
+ int utcDay = pTm->tm_mday;
+ int utcHours = pTm->tm_hour;
+ int utcMinutes = pTm->tm_min;
+ int utcSeconds = pTm->tm_sec;
+
+ if (generate_nmea) {
+ // ------------------
+ // ------$GPGSA------
+ // ------------------
+
+ uint32_t svUsedCount = 0;
+ uint32_t svUsedList[32] = {0};
+ uint32_t mask = loc_eng_data_p->sv_used_mask;
+ for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++)
+ {
+ if (mask & 1)
+ svUsedList[svUsedCount++] = i;
+ mask = mask >> 1;
+ }
+ // clear the cache so they can't be used again
+ loc_eng_data_p->sv_used_mask = 0;
+
+ char fixType;
+ if (svUsedCount == 0)
+ fixType = '1'; // no fix
+ else if (svUsedCount <= 3)
+ fixType = '2'; // 2D fix
+ else
+ fixType = '3'; // 3D fix
+
+ length = snprintf(pMarker, lengthRemaining, "$GPGSA,A,%c,", fixType);
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence
+ {
+ if (i < svUsedCount)
+ length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]);
+ else
+ length = snprintf(pMarker, lengthRemaining, ",");
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+ }
+
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
+ { // dop is in locationExtended, (QMI)
+ length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
+ locationExtended.pdop,
+ locationExtended.hdop,
+ locationExtended.vdop);
+ }
+ else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
+ { // dop was cached from sv report (RPC)
+ length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
+ loc_eng_data_p->pdop,
+ loc_eng_data_p->hdop,
+ loc_eng_data_p->vdop);
+ }
+ else
+ { // no dop
+ length = snprintf(pMarker, lengthRemaining, ",,");
+ }
+
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ // ------------------
+ // ------$GPVTG------
+ // ------------------
+
+ pMarker = sentence;
+ lengthRemaining = sizeof(sentence);
+
+ if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)
+ {
+ float magTrack = location.gpsLocation.bearing;
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
+ {
+ float magTrack = location.gpsLocation.bearing - locationExtended.magneticDeviation;
+ if (magTrack < 0.0)
+ magTrack += 360.0;
+ else if (magTrack > 360.0)
+ magTrack -= 360.0;
+ }
+
+ length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.gpsLocation.bearing, magTrack);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining, "$GPVTG,,T,,M,");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)
+ {
+ float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);
+ float speedKmPerHour = location.gpsLocation.speed * 3.6;
+
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining, ",N,,K,");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ 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->adapter->getPositionMode().mode)
+ length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
+ else
+ length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
+
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ // ------------------
+ // ------$GPRMC------
+ // ------------------
+
+ pMarker = sentence;
+ lengthRemaining = sizeof(sentence);
+
+ length = snprintf(pMarker, lengthRemaining, "$GPRMC,%02d%02d%02d,A," ,
+ utcHours, utcMinutes, utcSeconds);
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)
+ {
+ double latitude = location.gpsLocation.latitude;
+ double longitude = location.gpsLocation.longitude;
+ char latHemisphere;
+ char lonHemisphere;
+ double latMinutes;
+ double lonMinutes;
+
+ if (latitude > 0)
+ {
+ latHemisphere = 'N';
+ }
+ else
+ {
+ latHemisphere = 'S';
+ latitude *= -1.0;
+ }
+
+ if (longitude < 0)
+ {
+ lonHemisphere = 'W';
+ longitude *= -1.0;
+ }
+ else
+ {
+ lonHemisphere = 'E';
+ }
+
+ latMinutes = fmod(latitude * 60.0 , 60.0);
+ lonMinutes = fmod(longitude * 60.0 , 60.0);
+
+ length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
+ (uint8_t)floor(latitude), latMinutes, latHemisphere,
+ (uint8_t)floor(longitude),lonMinutes, lonHemisphere);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining,",,,,");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)
+ {
+ float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining, ",");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)
+ {
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.gpsLocation.bearing);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining, ",");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ length = snprintf(pMarker, lengthRemaining, "%2.2d%2.2d%2.2d,",
+ utcDay, utcMonth, utcYear);
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
+ {
+ float magneticVariation = locationExtended.magneticDeviation;
+ char direction;
+ if (magneticVariation < 0.0)
+ {
+ direction = 'W';
+ magneticVariation *= -1.0;
+ }
+ else
+ {
+ direction = 'E';
+ }
+
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,%c,",
+ magneticVariation, direction);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining, ",,");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ 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->adapter->getPositionMode().mode)
+ length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
+ else
+ length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
+
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ // ------------------
+ // ------$GPGGA------
+ // ------------------
+
+ pMarker = sentence;
+ lengthRemaining = sizeof(sentence);
+
+ length = snprintf(pMarker, lengthRemaining, "$GPGGA,%02d%02d%02d," ,
+ utcHours, utcMinutes, utcSeconds);
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)
+ {
+ double latitude = location.gpsLocation.latitude;
+ double longitude = location.gpsLocation.longitude;
+ char latHemisphere;
+ char lonHemisphere;
+ double latMinutes;
+ double lonMinutes;
+
+ if (latitude > 0)
+ {
+ latHemisphere = 'N';
+ }
+ else
+ {
+ latHemisphere = 'S';
+ latitude *= -1.0;
+ }
+
+ if (longitude < 0)
+ {
+ lonHemisphere = 'W';
+ longitude *= -1.0;
+ }
+ else
+ {
+ lonHemisphere = 'E';
+ }
+
+ latMinutes = fmod(latitude * 60.0 , 60.0);
+ lonMinutes = fmod(longitude * 60.0 , 60.0);
+
+ length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
+ (uint8_t)floor(latitude), latMinutes, latHemisphere,
+ (uint8_t)floor(longitude),lonMinutes, lonHemisphere);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining,",,,,");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ 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->adapter->getPositionMode().mode)
+ gpsQuality = '1'; // 1 means GPS fix
+ else
+ gpsQuality = '2'; // 2 means DGPS fix
+
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
+ { // dop is in locationExtended, (QMI)
+ length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
+ gpsQuality, svUsedCount, locationExtended.hdop);
+ }
+ else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
+ { // dop was cached from sv report (RPC)
+ length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
+ gpsQuality, svUsedCount, loc_eng_data_p->hdop);
+ }
+ else
+ { // no hdop
+ length = snprintf(pMarker, lengthRemaining, "%c,%02d,,",
+ gpsQuality, svUsedCount);
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)
+ {
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,M,",
+ locationExtended.altitudeMeanSeaLevel);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining,",,");
+ }
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) &&
+ (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL))
+ {
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,",
+ location.gpsLocation.altitude - locationExtended.altitudeMeanSeaLevel);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining,",,,");
+ }
+
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ }
+ //Send blank NMEA reports for non-final fixes
+ else {
+ strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+ }
+ // clear the dop cache so they can't be used again
+ loc_eng_data_p->pdop = 0;
+ loc_eng_data_p->hdop = 0;
+ loc_eng_data_p->vdop = 0;
+
+ EXIT_LOG(%d, 0);
+}
+
+
+
+/*===========================================================================
+FUNCTION loc_eng_nmea_generate_sv
+
+DESCRIPTION
+ Generate NMEA sentences generated based on sv report
+
+DEPENDENCIES
+ NONE
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p,
+ const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended)
+{
+ ENTRY_LOG();
+
+ char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
+ char* pMarker = sentence;
+ int lengthRemaining = sizeof(sentence);
+ int length = 0;
+ int svCount = svStatus.num_svs;
+ int sentenceCount = 0;
+ int sentenceNumber = 1;
+ int svNumber = 1;
+ int gpsCount = 0;
+ int glnCount = 0;
+
+ //Count GPS SVs for saparating GPS from GLONASS and throw others
+
+ for(svNumber=1; svNumber <= svCount; svNumber++) {
+ if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START)&&
+ (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) )
+ {
+ gpsCount++;
+ }
+ else if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) &&
+ (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) )
+ {
+ glnCount++;
+ }
+ }
+
+ // ------------------
+ // ------$GPGSV------
+ // ------------------
+
+ if (gpsCount <= 0)
+ {
+ // no svs in view, so just send a blank $GPGSV sentence
+ strlcpy(sentence, "$GPGSV,1,1,0,", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+ }
+ else
+ {
+ svNumber = 1;
+ sentenceNumber = 1;
+ sentenceCount = gpsCount/4 + (gpsCount % 4 != 0);
+
+ while (sentenceNumber <= sentenceCount)
+ {
+ pMarker = sentence;
+ lengthRemaining = sizeof(sentence);
+
+ length = snprintf(pMarker, lengthRemaining, "$GPGSV,%d,%d,%02d",
+ sentenceCount, sentenceNumber, gpsCount);
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ for (int i=0; (svNumber <= svCount) && (i < 4); svNumber++)
+ {
+ if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START) &&
+ (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) )
+ {
+ length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,",
+ svStatus.sv_list[svNumber-1].prn,
+ (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int
+ (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (svStatus.sv_list[svNumber-1].snr > 0)
+ {
+ length = snprintf(pMarker, lengthRemaining,"%02d",
+ (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+ }
+
+ i++;
+ }
+
+ }
+
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+ sentenceNumber++;
+
+ } //while
+
+ } //if
+
+ // ------------------
+ // ------$GLGSV------
+ // ------------------
+
+ if (glnCount <= 0)
+ {
+ // no svs in view, so just send a blank $GLGSV sentence
+ strlcpy(sentence, "$GLGSV,1,1,0,", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+ }
+ else
+ {
+ svNumber = 1;
+ sentenceNumber = 1;
+ sentenceCount = glnCount/4 + (glnCount % 4 != 0);
+
+ while (sentenceNumber <= sentenceCount)
+ {
+ pMarker = sentence;
+ lengthRemaining = sizeof(sentence);
+
+ length = snprintf(pMarker, lengthRemaining, "$GLGSV,%d,%d,%02d",
+ sentenceCount, sentenceNumber, glnCount);
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ for (int i=0; (svNumber <= svCount) && (i < 4); svNumber++)
+ {
+ if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) &&
+ (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) ) {
+
+ length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,",
+ svStatus.sv_list[svNumber-1].prn,
+ (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int
+ (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (svStatus.sv_list[svNumber-1].snr > 0)
+ {
+ length = snprintf(pMarker, lengthRemaining,"%02d",
+ (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int
+
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+ }
+
+ i++;
+ }
+
+ }
+
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+ sentenceNumber++;
+
+ } //while
+
+ }//if
+
+ if (svStatus.used_in_fix_mask == 0)
+ { // No sv used, so there will be no position report, so send
+ // blank NMEA sentences
+ strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+
+ strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence));
+ length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
+ loc_eng_nmea_send(sentence, length, loc_eng_data_p);
+ }
+ else
+ { // cache the used in fix mask, as it will be needed to send $GPGSA
+ // during the position report
+ loc_eng_data_p->sv_used_mask = svStatus.used_in_fix_mask;
+
+ // For RPC, the DOP are sent during sv report, so cache them
+ // now to be sent during position report.
+ // For QMI, the DOP will be in position report.
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
+ {
+ loc_eng_data_p->pdop = locationExtended.pdop;
+ loc_eng_data_p->hdop = locationExtended.hdop;
+ loc_eng_data_p->vdop = locationExtended.vdop;
+ }
+ else
+ {
+ loc_eng_data_p->pdop = 0;
+ loc_eng_data_p->hdop = 0;
+ loc_eng_data_p->vdop = 0;
+ }
+
+ }
+
+ EXIT_LOG(%d, 0);
+}
diff --git a/gps/libloc_api_50001/loc_eng_nmea.h b/gps/loc_api/libloc_api_50001/loc_eng_nmea.h
index 29ca6c5..c8f3b0e 100644
--- a/gps/libloc_api_50001/loc_eng_nmea.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.h
@@ -30,13 +30,13 @@
#ifndef LOC_ENG_NMEA_H
#define LOC_ENG_NMEA_H
-#include <hardware/gps.h>
+#include "hardware/gps.h"
#define NMEA_SENTENCE_MAX_LENGTH 200
void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p);
int loc_eng_nmea_put_checksum(char *pNmea, int maxSize);
void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended);
-void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const GpsLocation &location, const GpsLocationExtended &locationExtended);
+void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea);
#endif // LOC_ENG_NMEA_H
diff --git a/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp b/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp
new file mode 100644
index 0000000..7bb8083
--- /dev/null
+++ b/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp
@@ -0,0 +1,213 @@
+/* Copyright (c) 2009-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_eng"
+
+#include <loc_eng.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();
+ }
+};
+
+struct LocEngSetXtraVersionCheck : public LocMsg {
+ LocEngAdapter *mAdapter;
+ int mCheck;
+ inline LocEngSetXtraVersionCheck(LocEngAdapter* adapter,
+ int check):
+ mAdapter(adapter), mCheck(check) {}
+ inline virtual void proc() const {
+ locallog();
+ mAdapter->setXtraVersionCheck(mCheck);
+ }
+ inline void locallog() const {
+ LOC_LOGD("%s:%d]: mCheck: %d",
+ __func__, __LINE__, mCheck);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
+/*===========================================================================
+FUNCTION loc_eng_xtra_init
+
+DESCRIPTION
+ Initialize XTRA module.
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
+ GpsXtraExtCallbacks* callbacks)
+{
+ int ret_val = -1;
+ loc_eng_xtra_data_s_type *xtra_module_data_ptr;
+ ENTRY_LOG();
+
+ if(callbacks == NULL) {
+ LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL");
+ } else {
+ xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
+ xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
+ xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb;
+
+ ret_val = 0;
+ }
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
+}
+
+/*===========================================================================
+FUNCTION loc_eng_xtra_inject_data
+
+DESCRIPTION
+ Injects XTRA file into the engine but buffers the data if engine is busy.
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
+ char* data, int length)
+{
+ ENTRY_LOG();
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length));
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+/*===========================================================================
+FUNCTION loc_eng_xtra_request_server
+
+DESCRIPTION
+ Request the Xtra server url from the modem
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ 0
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+int loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data)
+{
+ ENTRY_LOG();
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngRequestXtraServer(adapter));
+ EXIT_LOG(%d, 0);
+ return 0;
+}
+/*===========================================================================
+FUNCTION loc_eng_xtra_version_check
+
+DESCRIPTION
+ Injects the enable/disable value for checking XTRA version
+ that is specified in gps.conf
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ none
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+void loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data,
+ int check)
+{
+ ENTRY_LOG();
+ LocEngAdapter *adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngSetXtraVersionCheck(adapter, check));
+ EXIT_LOG(%d, 0);
+}
diff --git a/gps/libloc_api_50001/loc_eng_xtra.h b/gps/loc_api/libloc_api_50001/loc_eng_xtra.h
index 614348d..d8f4641 100644
--- a/gps/libloc_api_50001/loc_eng_xtra.h
+++ b/gps/loc_api/libloc_api_50001/loc_eng_xtra.h
@@ -30,13 +30,14 @@
#ifndef LOC_ENG_XTRA_H
#define LOC_ENG_XTRA_H
-#include <hardware/gps.h>
+#include "hardware/gps.h"
// Module data
typedef struct
{
// loc_eng_ioctl_cb_data_s_type ioctl_cb_data;
gps_xtra_download_request download_request_cb;
+ report_xtra_server report_xtra_server_cb;
// XTRA data buffer
char *xtra_data_for_injection; // NULL if no pending data
diff --git a/gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp b/gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp
new file mode 100644
index 0000000..e8cb93a
--- /dev/null
+++ b/gps/platform_lib_abstractions/elapsed_millis_since_boot.cpp
@@ -0,0 +1,46 @@
+/* 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.
+ */
+
+#include <stdlib.h>
+#include <sys/time.h>
+#include "platform_lib_time.h"
+
+int64_t systemTime(int clock)
+{
+ struct timeval t;
+ t.tv_sec = t.tv_usec = 0;
+ gettimeofday(&t, NULL);
+ return t.tv_sec*1000000LL + t.tv_usec;
+}
+
+
+int64_t elapsedMillisSinceBoot()
+{
+ int64_t t_us = systemTime(0);
+ return (int64_t) t_us / 1000LL;
+}
diff --git a/gps/ulp/inc/ulp.h b/gps/platform_lib_abstractions/platform_lib_includes.h
index ce27c96..5858674 100644
--- a/gps/ulp/inc/ulp.h
+++ b/gps/platform_lib_abstractions/platform_lib_includes.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
+/* 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
@@ -24,36 +24,12 @@
* 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 ULP_H
-#define ULP_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <hardware/gps.h>
-#include "loc_eng.h"
+#ifndef _PLATFORM_LIB_INCLUDES_H_
+#define _PLATFORM_LIB_INCLUDES_H_
-/** Represents the standard ulp module interface. */
-typedef struct {
- /** set to sizeof(ulpInterface) */
- size_t size;
+#include "platform_lib_time.h"
+#include "platform_lib_macros.h"
- /**
- * Starts the libulp module. 0: success
- */
- int (*init)(loc_eng_data_s_type &loc_eng_data);
-
-}ulpInterface;
-
-typedef const ulpInterface* (get_ulp_interface) (void);
-
-#ifdef __cplusplus
-}
#endif
-#endif /* ULP_H */
-
diff --git a/gps/platform_lib_abstractions/platform_lib_macros.h b/gps/platform_lib_abstractions/platform_lib_macros.h
new file mode 100644
index 0000000..bc48dd9
--- /dev/null
+++ b/gps/platform_lib_abstractions/platform_lib_macros.h
@@ -0,0 +1,81 @@
+/* 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 __PLATFORM_LIB_MACROS_H__
+#define __PLATFORM_LIB_MACROS_H__
+
+#include <sys/time.h>
+
+#define TS_PRINTF(format, x...) \
+{ \
+ struct timeval tv; \
+ struct timezone tz; \
+ int hh, mm, ss; \
+ gettimeofday(&tv, &tz); \
+ hh = tv.tv_sec/3600%24; \
+ mm = (tv.tv_sec%3600)/60; \
+ ss = tv.tv_sec%60; \
+ fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec,##x); \
+}
+
+
+#ifdef USE_GLIB
+
+#define strlcat g_strlcat
+#define strlcpy g_strlcpy
+
+#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x)
+#define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x)
+#define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x)
+#define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x)
+#define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x)
+
+#define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid))
+
+#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread
+#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot())
+
+
+#else
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+pid_t gettid(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#define GETTID_PLATFORM_LIB_ABSTRACTION (gettid())
+#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION android::AndroidRuntime::createJavaThread
+#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (android::elapsedRealtime())
+
+#endif
+
+#endif
diff --git a/gps/platform_lib_abstractions/platform_lib_time.h b/gps/platform_lib_abstractions/platform_lib_time.h
new file mode 100644
index 0000000..ce013af
--- /dev/null
+++ b/gps/platform_lib_abstractions/platform_lib_time.h
@@ -0,0 +1,35 @@
+/* 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 _PLATFORM_LIB_TIME_H_
+#define _PLATFORM_LIB_TIME_H_
+
+int64_t systemTime(int clock);
+int64_t elapsedMillisSinceBoot();
+
+#endif
diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk
index 205fb16..a91a6ed 100644
--- a/gps/utils/Android.mk
+++ b/gps/utils/Android.mk
@@ -8,14 +8,20 @@ include $(CLEAR_VARS)
## Libs
LOCAL_SHARED_LIBRARIES := \
libutils \
- libcutils
+ libcutils \
+ liblog
LOCAL_SRC_FILES += \
+ sec_gps.c \
loc_log.cpp \
loc_cfg.cpp \
msg_q.c \
linked_list.c \
- loc_target.cpp
+ loc_target.cpp \
+ loc_timer.c \
+ ../platform_lib_abstractions/elapsed_millis_since_boot.cpp \
+ loc_misc_utils.cpp
+
LOCAL_CFLAGS += \
-fno-short-enums \
@@ -24,7 +30,8 @@ LOCAL_CFLAGS += \
LOCAL_LDFLAGS += -Wl,--export-dynamic
## Includes
-LOCAL_C_INCLUDES:=
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/../platform_lib_abstractions
LOCAL_COPY_HEADERS_TO:= gps.utils/
LOCAL_COPY_HEADERS:= \
@@ -33,7 +40,13 @@ LOCAL_COPY_HEADERS:= \
log_util.h \
linked_list.h \
msg_q.h \
- loc_target.h
+ loc_target.h \
+ loc_timer.h \
+ ../platform_lib_abstractions/platform_lib_includes.h \
+ ../platform_lib_abstractions/platform_lib_time.h \
+ ../platform_lib_abstractions/platform_lib_macros.h \
+ loc_misc_utils.h
+
LOCAL_MODULE := libgps.utils
diff --git a/gps/utils/Makefile.am b/gps/utils/Makefile.am
new file mode 100644
index 0000000..e5935f0
--- /dev/null
+++ b/gps/utils/Makefile.am
@@ -0,0 +1,44 @@
+AM_CFLAGS = -Wundef \
+ -MD \
+ -Wno-trigraphs \
+ -g -O0 \
+ -fno-inline \
+ -fno-short-enums \
+ -fpic \
+ -I../platform_lib_abstractions
+
+libgps_utils_so_la_h_sources = log_util.h \
+ msg_q.h \
+ linked_list.h \
+ loc_cfg.h \
+ loc_log.h \
+ ../platform_lib_abstractions/platform_lib_includes.h \
+ ../platform_lib_abstractions/platform_lib_time.h \
+ ../platform_lib_abstractions/platform_lib_macros.h
+
+libgps_utils_so_la_c_sources = linked_list.c \
+ msg_q.c \
+ loc_cfg.cpp \
+ loc_log.cpp \
+ ../platform_lib_abstractions/elapsed_millis_since_boot.cpp
+
+library_includedir = $(pkgincludedir)/utils
+
+library_include_HEADERS = $(libgps_utils_so_la_h_sources)
+
+libgps_utils_so_la_SOURCES = $(libgps_utils_so_la_c_sources)
+
+if USE_GLIB
+libgps_utils_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
+libgps_utils_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
+libgps_utils_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
+else
+libgps_utils_so_la_CFLAGS = $(AM_CFLAGS)
+libgps_utils_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
+libgps_utils_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
+endif
+
+libgps_utils_so_la_LIBADD = -lstdc++ -lcutils
+
+#Create and Install libraries
+lib_LTLIBRARIES = libgps_utils_so.la
diff --git a/gps/utils/linked_list.c b/gps/utils/linked_list.c
index 31ec52d..92617fe 100644
--- a/gps/utils/linked_list.c
+++ b/gps/utils/linked_list.c
@@ -32,7 +32,7 @@
#define LOG_TAG "LocSvc_utils_ll"
#include "log_util.h"
-
+#include "platform_lib_includes.h"
#include <stdlib.h>
#include <stdint.h>
diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp
index 3f7dec9..abf8086 100644
--- a/gps/utils/loc_cfg.cpp
+++ b/gps/utils/loc_cfg.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -39,6 +39,11 @@
#include <time.h>
#include <loc_cfg.h>
#include <log_util.h>
+#include <loc_misc_utils.h>
+#ifdef USE_GLIB
+#include <glib.h>
+#endif
+#include "platform_lib_includes.h"
/*=============================================================================
*
@@ -47,49 +52,36 @@
*============================================================================*/
/* Parameter data */
-static uint8_t DEBUG_LEVEL = 3;
+static uint8_t DEBUG_LEVEL = 0xff;
static uint8_t TIMESTAMP = 0;
/* Parameter spec table */
static loc_param_s_type loc_parameter_table[] =
{
- {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'},
- {"TIMESTAMP", &TIMESTAMP, NULL, 'n'},
+ {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'},
+ {"TIMESTAMP", &TIMESTAMP, NULL, 'n'},
};
-
int loc_param_num = sizeof(loc_parameter_table) / sizeof(loc_param_s_type);
-/*===========================================================================
-FUNCTION loc_default_parameters
-
-DESCRIPTION
- Resets the parameters to default
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-===========================================================================*/
-
-static void loc_default_parameters()
+typedef struct loc_param_v_type
{
- /* defaults */
- DEBUG_LEVEL = 3; /* debug level */
- TIMESTAMP = 0;
-
- /* reset logging mechanism */
- loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
-}
+ char* param_name;
+ char* param_str_value;
+ int param_int_value;
+ double param_double_value;
+}loc_param_v_type;
/*===========================================================================
-FUNCTION trim_space
+FUNCTION loc_set_config_entry
DESCRIPTION
- Removes leading and trailing spaces of the string
+ Potentially sets a given configuration table entry based on the passed in
+ configuration value. This is done by using a string comparison of the
+ parameter names and those found in the configuration file.
+
+PARAMETERS:
+ config_entry: configuration entry in the table to possibly set
+ config_value: value to store in the entry if the parameter names match
DEPENDENCIES
N/A
@@ -100,120 +92,166 @@ RETURN VALUE
SIDE EFFECTS
N/A
===========================================================================*/
-void trim_space(char *org_string)
+int loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
{
- char *scan_ptr, *write_ptr;
- char *first_nonspace = NULL, *last_nonspace = NULL;
-
- scan_ptr = write_ptr = org_string;
-
- while (*scan_ptr)
- {
- if ( !isspace(*scan_ptr) && first_nonspace == NULL)
- {
- first_nonspace = scan_ptr;
- }
-
- if (first_nonspace != NULL)
- {
- *(write_ptr++) = *scan_ptr;
- if ( !isspace(*scan_ptr))
- {
- last_nonspace = write_ptr;
- }
- }
-
- scan_ptr++;
- }
-
- if (last_nonspace) { *last_nonspace = '\0'; }
+ int ret=-1;
+ if(NULL == config_entry || NULL == config_value)
+ {
+ LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
+ return ret;
+ }
+
+ if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
+ config_entry->param_ptr)
+ {
+ switch (config_entry->param_type)
+ {
+ case 's':
+ if (strcmp(config_value->param_str_value, "NULL") == 0)
+ {
+ *((char*)config_entry->param_ptr) = '\0';
+ }
+ else {
+ strlcpy((char*) config_entry->param_ptr,
+ config_value->param_str_value,
+ LOC_MAX_PARAM_STRING + 1);
+ }
+ /* Log INI values */
+ LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr);
+
+ if(NULL != config_entry->param_set)
+ {
+ *(config_entry->param_set) = 1;
+ }
+ ret = 0;
+ break;
+ case 'n':
+ *((int *)config_entry->param_ptr) = config_value->param_int_value;
+ /* Log INI values */
+ LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value);
+
+ if(NULL != config_entry->param_set)
+ {
+ *(config_entry->param_set) = 1;
+ }
+ ret = 0;
+ break;
+ case 'f':
+ *((double *)config_entry->param_ptr) = config_value->param_double_value;
+ /* Log INI values */
+ LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value);
+
+ if(NULL != config_entry->param_set)
+ {
+ *(config_entry->param_set) = 1;
+ }
+ ret = 0;
+ break;
+ default:
+ LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
+ }
+ }
+ return ret;
}
-typedef struct loc_param_v_type
-{
- char* param_name;
-
- char* param_str_value;
- int param_int_value;
- double param_double_value;
-}loc_param_v_type;
-
/*===========================================================================
-FUNCTION loc_set_config_entry
+FUNCTION loc_read_conf_r (repetitive)
DESCRIPTION
- Potentially sets a given configuration table entry based on the passed in
- configuration value. This is done by using a string comparison of the
- parameter names and those found in the configuration file.
+ Reads the specified configuration file and sets defined values based on
+ the passed in configuration table. This table maps strings to values to
+ set along with the type of each of these values.
+ The difference between this and loc_read_conf is that this function returns
+ the file pointer position at the end of filling a config table. Also, it
+ reads a fixed number of parameters at a time which is equal to the length
+ of the configuration table. This functionality enables the caller to
+ repeatedly call the function to read data from the same file.
PARAMETERS:
- config_entry: configuration entry in the table to possibly set
- config_value: value to store in the entry if the parameter names match
+ conf_fp : file pointer
+ config_table: table definition of strings to places to store information
+ table_length: length of the configuration table
DEPENDENCIES
N/A
RETURN VALUE
- None
+ 0: Table filled successfully
+ 1: No more parameters to read
+ -1: Error filling table
SIDE EFFECTS
N/A
===========================================================================*/
-void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
+int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length)
{
- if(NULL == config_entry || NULL == config_value)
- {
- LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
- return;
- }
-
- if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
- config_entry->param_ptr)
- {
- switch (config_entry->param_type)
- {
- case 's':
- if (strcmp(config_value->param_str_value, "NULL") == 0)
- {
- *((char*)config_entry->param_ptr) = '\0';
- }
- else {
- strlcpy((char*) config_entry->param_ptr,
- config_value->param_str_value,
- LOC_MAX_PARAM_STRING + 1);
- }
- /* Log INI values */
- LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr);
-
- if(NULL != config_entry->param_set)
- {
- *(config_entry->param_set) = 1;
- }
- break;
- case 'n':
- *((int *)config_entry->param_ptr) = config_value->param_int_value;
- /* Log INI values */
- LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value);
-
- if(NULL != config_entry->param_set)
- {
- *(config_entry->param_set) = 1;
- }
- break;
- case 'f':
- *((double *)config_entry->param_ptr) = config_value->param_double_value;
- /* Log INI values */
- LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value);
-
- if(NULL != config_entry->param_set)
- {
- *(config_entry->param_set) = 1;
- }
- break;
- default:
- LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
- }
- }
+ char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
+ char *lasts;
+ loc_param_v_type config_value;
+ uint32_t i;
+ int ret=0;
+
+ unsigned int num_params=table_length;
+ if(conf_fp == NULL) {
+ LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__);
+ ret = -1;
+ goto err;
+ }
+
+ /* Clear all validity bits */
+ for(i = 0; NULL != config_table && i < table_length; i++)
+ {
+ if(NULL != config_table[i].param_set)
+ {
+ *(config_table[i].param_set) = 0;
+ }
+ }
+ LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
+ while(num_params)
+ {
+ if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) {
+ LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__);
+ break;
+ }
+
+ memset(&config_value, 0, sizeof(config_value));
+
+ /* Separate variable and value */
+ config_value.param_name = strtok_r(input_buf, "=", &lasts);
+ /* skip lines that do not contain "=" */
+ if (config_value.param_name == NULL) continue;
+ config_value.param_str_value = strtok_r(NULL, "=", &lasts);
+ /* skip lines that do not contain two operands */
+ if (config_value.param_str_value == NULL) continue;
+
+ /* Trim leading and trailing spaces */
+ loc_util_trim_space(config_value.param_name);
+ loc_util_trim_space(config_value.param_str_value);
+
+ /* Parse numerical value */
+ if ((strlen(config_value.param_str_value) >=3) &&
+ (config_value.param_str_value[0] == '0') &&
+ (tolower(config_value.param_str_value[1]) == 'x'))
+ {
+ /* hex */
+ config_value.param_int_value = (int) strtol(&config_value.param_str_value[2],
+ (char**) NULL, 16);
+ }
+ else {
+ config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
+ config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
+ }
+
+ for(i = 0; NULL != config_table && i < table_length; i++)
+ {
+ if(!loc_set_config_entry(&config_table[i], &config_value)) {
+ num_params--;
+ }
+ }
+ }
+
+err:
+ return ret;
}
/*===========================================================================
@@ -238,73 +276,25 @@ RETURN VALUE
SIDE EFFECTS
N/A
===========================================================================*/
-void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, uint32_t table_length)
+void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table,
+ uint32_t table_length)
{
- FILE *gps_conf_fp = NULL;
- char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
- char *lasts;
- loc_param_v_type config_value;
- uint32_t i;
-
- loc_default_parameters();
-
- if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
- {
- LOC_LOGD("%s: using %s", __FUNCTION__, GPS_CONF_FILE);
- }
- else
- {
- LOC_LOGW("%s: no %s file found", __FUNCTION__, GPS_CONF_FILE);
- return; /* no parameter file */
- }
-
- /* Clear all validity bits */
- for(i = 0; NULL != config_table && i < table_length; i++)
- {
- if(NULL != config_table[i].param_set)
- {
- *(config_table[i].param_set) = 0;
- }
- }
-
- while(fgets(input_buf, LOC_MAX_PARAM_LINE, gps_conf_fp) != NULL)
- {
- memset(&config_value, 0, sizeof(config_value));
-
- /* Separate variable and value */
- config_value.param_name = strtok_r(input_buf, "=", &lasts);
- if (config_value.param_name == NULL) continue; /* skip lines that do not contain "=" */
- config_value.param_str_value = strtok_r(NULL, "=", &lasts);
- if (config_value.param_str_value == NULL) continue; /* skip lines that do not contain two operands */
-
- /* Trim leading and trailing spaces */
- trim_space(config_value.param_name);
- trim_space(config_value.param_str_value);
-
- /* Parse numerical value */
- if (config_value.param_str_value[0] == '0' && tolower(config_value.param_str_value[1]) == 'x')
- {
- /* hex */
- config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], (char**) NULL, 16);
- }
- else {
- config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
- config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
- }
-
- for(i = 0; NULL != config_table && i < table_length; i++)
- {
- loc_set_config_entry(&config_table[i], &config_value);
- }
-
- for(i = 0; i < loc_param_num; i++)
- {
- loc_set_config_entry(&loc_parameter_table[i], &config_value);
- }
- }
-
- fclose(gps_conf_fp);
-
- /* Initialize logging mechanism with parsed data */
- loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
+ FILE *gps_conf_fp = NULL;
+ char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
+ char *lasts;
+ loc_param_v_type config_value;
+ uint32_t i;
+
+ if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
+ {
+ LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
+ if(table_length && config_table) {
+ loc_read_conf_r(gps_conf_fp, config_table, table_length);
+ rewind(gps_conf_fp);
+ }
+ loc_read_conf_r(gps_conf_fp, loc_parameter_table, loc_param_num);
+ fclose(gps_conf_fp);
+ }
+ /* Initialize logging mechanism with parsed data */
+ loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
}
diff --git a/gps/utils/loc_cfg.h b/gps/utils/loc_cfg.h
index 155db65..268f4c2 100644
--- a/gps/utils/loc_cfg.h
+++ b/gps/utils/loc_cfg.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -30,17 +30,13 @@
#ifndef LOC_CFG_H
#define LOC_CFG_H
+#include <stdio.h>
#include <stdint.h>
#define LOC_MAX_PARAM_NAME 48
#define LOC_MAX_PARAM_STRING 80
#define LOC_MAX_PARAM_LINE 80
-// Don't want to overwrite the pre-def'ed value
-#ifndef GPS_CONF_FILE
-#define GPS_CONF_FILE "/etc/gps.conf" //??? platform independent
-#endif
-
#define UTIL_READ_CONF_DEFAULT(filename) \
loc_read_conf((filename), NULL, 0);
@@ -80,7 +76,7 @@ extern "C" {
extern void loc_read_conf(const char* conf_file_name,
loc_param_s_type* config_table,
uint32_t table_length);
-
+extern int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length);
#ifdef __cplusplus
}
#endif
diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp
index b75cf93..9a7ce5e 100644
--- a/gps/utils/loc_log.cpp
+++ b/gps/utils/loc_log.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
+/* 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -34,7 +34,13 @@
#include <sys/time.h>
#include "loc_log.h"
#include "msg_q.h"
+#ifdef USE_GLIB
+#include <time.h>
+#endif /* USE_GLIB */
#include "log_util.h"
+#include "platform_lib_includes.h"
+
+#define BUFFER_SIZE 120
// Logging Improvements
const char *loc_logger_boolStr[]={"False","True"};
@@ -102,11 +108,13 @@ const char* log_succ_fail_string(int is_succ)
//Target names
loc_name_val_s_type target_name[] =
{
- NAME_VAL(TARGET_OTHER),
- NAME_VAL(TARGET_APQ8064_STANDALONE),
- NAME_VAL(TARGET_APQ8064_FUSION3),
- NAME_VAL(TARGET_MPQ8064),
- NAME_VAL(TARGET_MSM8930)
+ NAME_VAL(GNSS_NONE),
+ NAME_VAL(GNSS_MSM),
+ NAME_VAL(GNSS_GSS),
+ NAME_VAL(GNSS_MDM),
+ NAME_VAL(GNSS_QCA1530),
+ NAME_VAL(GNSS_AUTO),
+ NAME_VAL(GNSS_UNKNOWN)
};
static int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type);
@@ -124,11 +132,27 @@ RETURN VALUE
The target name string
===========================================================================*/
-const char *loc_get_target_name(targetEnumType target)
+const char *loc_get_target_name(unsigned int target)
{
- return loc_get_name_from_val(target_name, target_name_num, (long)target);
+ int index = 0;
+ static char ret[BUFFER_SIZE];
+
+ index = getTargetGnssType(target);
+ if( index >= target_name_num || index < 0)
+ index = target_name_num - 1;
+
+ if( (target & HAS_SSC) == HAS_SSC ) {
+ snprintf(ret, sizeof(ret), " %s with SSC",
+ loc_get_name_from_val(target_name, target_name_num, (long)index) );
+ }
+ else {
+ snprintf(ret, sizeof(ret), " %s without SSC",
+ loc_get_name_from_val(target_name, target_name_num, (long)index) );
+ }
+ return ret;
}
+
/*===========================================================================
FUNCTION loc_get_time
diff --git a/gps/utils/loc_log.h b/gps/utils/loc_log.h
index 46f4e3e..82dc636 100644
--- a/gps/utils/loc_log.h
+++ b/gps/utils/loc_log.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
+/* 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -55,7 +55,7 @@ typedef struct
const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask);
const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value);
const char* loc_get_msg_q_status(int status);
-const char* loc_get_target_name(targetEnumType target);
+const char* loc_get_target_name(unsigned int target);
extern const char* log_succ_fail_string(int is_succ);
diff --git a/gps/utils/loc_misc_utils.cpp b/gps/utils/loc_misc_utils.cpp
new file mode 100644
index 0000000..7e96313
--- /dev/null
+++ b/gps/utils/loc_misc_utils.cpp
@@ -0,0 +1,114 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <stdio.h>
+#include <string.h>
+#include <log_util.h>
+#include <loc_misc_utils.h>
+#include <ctype.h>
+
+#define LOG_NDDEBUG 0
+#define LOG_TAG "LocSvc_misc_utils"
+
+int loc_util_split_string(char *raw_string, char **split_strings_ptr,
+ int max_num_substrings, char delimiter)
+{
+ int raw_string_index=0;
+ int num_split_strings=0;
+ unsigned char end_string=0;
+ int raw_string_length=0;
+
+ if(!raw_string || !split_strings_ptr) {
+ LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__);
+ num_split_strings = -1;
+ goto err;
+ }
+ LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string);
+ raw_string_length = strlen(raw_string) + 1;
+ split_strings_ptr[num_split_strings] = &raw_string[raw_string_index];
+ for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) {
+ if(raw_string[raw_string_index] == '\0')
+ end_string=1;
+ if((raw_string[raw_string_index] == delimiter) || end_string) {
+ raw_string[raw_string_index] = '\0';
+ LOC_LOGD("%s:%d]: split string: %s\n",
+ __func__, __LINE__, split_strings_ptr[num_split_strings]);
+ num_split_strings++;
+ if(((raw_string_index + 1) < raw_string_length) &&
+ (num_split_strings < max_num_substrings)) {
+ split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1];
+ }
+ else {
+ break;
+ }
+ }
+ if(end_string)
+ break;
+ }
+err:
+ LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings);
+ return num_split_strings;
+}
+
+void loc_util_trim_space(char *org_string)
+{
+ char *scan_ptr, *write_ptr;
+ char *first_nonspace = NULL, *last_nonspace = NULL;
+
+ if(org_string == NULL) {
+ LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__);
+ goto err;
+ }
+
+ scan_ptr = write_ptr = org_string;
+
+ while (*scan_ptr) {
+ //Find the first non-space character
+ if ( !isspace(*scan_ptr) && first_nonspace == NULL) {
+ first_nonspace = scan_ptr;
+ }
+ //Once the first non-space character is found in the
+ //above check, keep shifting the characters to the left
+ //to replace the spaces
+ if (first_nonspace != NULL) {
+ *(write_ptr++) = *scan_ptr;
+ //Keep track of which was the last non-space character
+ //encountered
+ //last_nonspace will not be updated in the case where
+ //the string ends with spaces
+ if ( !isspace(*scan_ptr)) {
+ last_nonspace = write_ptr;
+ }
+ }
+ scan_ptr++;
+ }
+ //Add NULL terminator after the last non-space character
+ if (last_nonspace) { *last_nonspace = '\0'; }
+err:
+ return;
+}
diff --git a/gps/utils/loc_misc_utils.h b/gps/utils/loc_misc_utils.h
new file mode 100644
index 0000000..7d66d84
--- /dev/null
+++ b/gps/utils/loc_misc_utils.h
@@ -0,0 +1,99 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef _LOC_MISC_UTILS_H_
+#define _LOC_MISC_UTILS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*===========================================================================
+FUNCTION loc_split_string
+
+DESCRIPTION:
+ This function is used to split a delimiter separated string into
+ sub-strings. This function does not allocate new memory to store the split
+ strings. Instead, it places '\0' in places of delimiters and assings the
+ starting address of the substring within the raw string as the string address
+ The input raw_string no longer remains to be a collection of sub-strings
+ after this function is executed.
+ Please make a copy of the input string before calling this function if
+ necessary
+
+PARAMETERS:
+ char *raw_string: is the original string with delimiter separated substrings
+ char **split_strings_ptr: is the arraw of pointers which will hold the addresses
+ of individual substrings
+ int max_num_substrings: is the maximum number of substrings that are expected
+ by the caller. The array of pointers in the above parameter
+ is usually this long
+ char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';'
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ int Number of split strings
+
+SIDE EFFECTS
+ The input raw_string no longer remains a delimiter separated single string.
+
+EXAMPLE
+ delimiter = ' ' //space
+ raw_string = "hello new user" //delimiter is space ' '
+ addresses = 0123456789abcd
+ split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello"
+ split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new"
+ split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user"
+
+===========================================================================*/
+int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings,
+ char delimiter);
+
+/*===========================================================================
+FUNCTION trim_space
+
+DESCRIPTION
+ Removes leading and trailing spaces of the string
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ None
+
+SIDE EFFECTS
+ N/A
+===========================================================================*/
+void loc_util_trim_space(char *org_string);
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_LOC_MISC_UTILS_H_
diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp
index 348ad9d..4c41d93 100644
--- a/gps/utils/loc_target.cpp
+++ b/gps/utils/loc_target.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,7 +33,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
-#include <hardware/gps.h>
+#include "hardware/gps.h"
#include <cutils/properties.h>
#include "loc_target.h"
#include "loc_log.h"
@@ -44,16 +44,24 @@
#define MPQ8064_ID_1 "130"
#define MSM8930_ID_1 "142"
#define MSM8930_ID_2 "116"
+#define APQ8030_ID_1 "157"
+#define APQ8074_ID_1 "184"
#define LINE_LEN 100
#define STR_LIQUID "Liquid"
#define STR_SURF "Surf"
+#define STR_MTP "MTP"
+#define STR_APQ "apq"
+#define STR_AUTO "auto"
#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r')
#define LENGTH(s) (sizeof(s) - 1)
#define GPS_CHECK_NO_ERROR 0
#define GPS_CHECK_NO_GPS_HW 1
+#define QCA1530_DETECT_TIMEOUT 30
+#define QCA1530_DETECT_PRESENT "yes"
+#define QCA1530_DETECT_PROGRESS "detect"
-static int gss_fd = 0;
+static unsigned int gTarget = (unsigned int)-1;
static int read_a_line(const char * file_path, char * line, int line_size)
{
@@ -77,33 +85,160 @@ static int read_a_line(const char * file_path, char * line, int line_size)
return result;
}
-targetEnumType get_target(void)
+/*!
+ * \brief Checks if QCA1530 is avalable.
+ *
+ * Function verifies if qca1530 SoC is configured on the device. The test is
+ * based on property value. For 1530 scenario, the value shall be one of the
+ * following: "yes", "no", "detect". All other values are treated equally to
+ * "no". When the value is "detect" the system waits for SoC detection to
+ * finish before returning result.
+ *
+ * \retval true - QCA1530 is available.
+ * \retval false - QCA1530 is not available.
+ */
+static bool is_qca1530(void)
+{
+ static const char qca1530_property_name[] = "persist.qca1530";
+ bool res = false;
+ int ret, i;
+ char buf[PROPERTY_VALUE_MAX];
+
+ memset(buf, 0, sizeof(buf));
+
+ for (i = 0; i < QCA1530_DETECT_TIMEOUT; ++i)
+ {
+ ret = property_get(qca1530_property_name, buf, NULL);
+ if (ret < 0)
+ {
+ LOC_LOGV( "qca1530: property %s is not accessible, ret=%d",
+ qca1530_property_name,
+ ret);
+
+ break;
+ }
+
+ LOC_LOGV( "qca1530: property %s is set to %s",
+ qca1530_property_name,
+ buf);
+
+ if (!memcmp(buf, QCA1530_DETECT_PRESENT,
+ sizeof(QCA1530_DETECT_PRESENT)))
+ {
+ res = true;
+ break;
+ }
+ if (!memcmp(buf, QCA1530_DETECT_PROGRESS,
+ sizeof(QCA1530_DETECT_PROGRESS)))
+ {
+ LOC_LOGV("qca1530: SoC detection is in progress.");
+ sleep(1);
+ continue;
+ }
+ break;
+ }
+
+ LOC_LOGD("qca1530: detected=%s", res ? "true" : "false");
+ return res;
+}
+
+/*The character array passed to this function should have length
+ of atleast PROPERTY_VALUE_MAX*/
+void loc_get_target_baseband(char *baseband, int array_length)
+{
+ if(baseband && (array_length >= PROPERTY_VALUE_MAX)) {
+ property_get("ro.baseband", baseband, "");
+ LOC_LOGD("%s:%d]: Baseband: %s\n", __func__, __LINE__, baseband);
+ }
+ else {
+ LOC_LOGE("%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\n",
+ __func__, __LINE__);
+ }
+}
+
+/*The character array passed to this function should have length
+ of atleast PROPERTY_VALUE_MAX*/
+void loc_get_platform_name(char *platform_name, int array_length)
{
- targetEnumType target = TARGET_OTHER;
+ if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) {
+ property_get("ro.board.platform", platform_name, "");
+ LOC_LOGD("%s:%d]: Target name: %s\n", __func__, __LINE__, platform_name);
+ }
+ else {
+ LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n",
+ __func__, __LINE__);
+ }
+}
+
+unsigned int loc_get_target(void)
+{
+ if (gTarget != (unsigned int)-1)
+ return gTarget;
- char hw_platform[] = "/sys/devices/system/soc/soc0/hw_platform";
- char id[] = "/sys/devices/system/soc/soc0/id";
- char mdm[] = "/dev/mdm"; // No such file or directory
+ static const char hw_platform[] = "/sys/devices/soc0/hw_platform";
+ static const char id[] = "/sys/devices/soc0/soc_id";
+ static const char hw_platform_dep[] =
+ "/sys/devices/system/soc/soc0/hw_platform";
+ static const char id_dep[] = "/sys/devices/system/soc/soc0/id";
+ static const char mdm[] = "/dev/mdm"; // No such file or directory
char rd_hw_platform[LINE_LEN];
char rd_id[LINE_LEN];
char rd_mdm[LINE_LEN];
+ char baseband[LINE_LEN];
+
+ if (is_qca1530()) {
+ gTarget = TARGET_QCA1530;
+ goto detected;
+ }
+
+ loc_get_target_baseband(baseband, sizeof(baseband));
+
+ if (!access(hw_platform, F_OK)) {
+ read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
+ } else {
+ read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN);
+ }
+ if (!access(id, F_OK)) {
+ read_a_line(id, rd_id, LINE_LEN);
+ } else {
+ read_a_line(id_dep, rd_id, LINE_LEN);
+ }
- read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
- read_a_line(id, rd_id, LINE_LEN);
-
- if(!memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) )
- target = TARGET_MPQ8064;
- else if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID)) && IS_STR_END(rd_hw_platform[LENGTH(STR_LIQUID)])) ||
- (!memcmp(rd_hw_platform, STR_SURF, LENGTH(STR_SURF)) && IS_STR_END(rd_hw_platform[LENGTH(STR_SURF)])) ) {
- if(!read_a_line( mdm, rd_mdm, LINE_LEN))
- target = TARGET_APQ8064_FUSION3;
- else if( (!memcmp(rd_id, APQ8064_ID_1, LENGTH(APQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(APQ8064_ID_1)])) ||
- (!memcmp(rd_id, APQ8064_ID_2, LENGTH(APQ8064_ID_2)) && IS_STR_END(rd_id[LENGTH(APQ8064_ID_2)])) )
- target = TARGET_APQ8064_STANDALONE;
+ if( !memcmp(baseband, STR_AUTO, LENGTH(STR_AUTO)) )
+ {
+ gTarget = TARGET_AUTO;
+ goto detected;
}
- else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) ||
- (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) )
- target = TARGET_MSM8930;
- return target;
+
+ if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){
+ if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1))
+ && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) )
+ gTarget = TARGET_MPQ;
+ else
+ gTarget = TARGET_APQ_SA;
+ }
+ else {
+ if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID))
+ && IS_STR_END(rd_hw_platform[LENGTH(STR_LIQUID)])) ||
+ (!memcmp(rd_hw_platform, STR_SURF, LENGTH(STR_SURF))
+ && IS_STR_END(rd_hw_platform[LENGTH(STR_SURF)])) ||
+ (!memcmp(rd_hw_platform, STR_MTP, LENGTH(STR_MTP))
+ && IS_STR_END(rd_hw_platform[LENGTH(STR_MTP)]))) {
+
+ if (!read_a_line( mdm, rd_mdm, LINE_LEN))
+ gTarget = TARGET_MDM;
+ }
+ else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1))
+ && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) ||
+ (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2))
+ && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) )
+ gTarget = TARGET_MSM_NO_SSC;
+ else
+ gTarget = TARGET_UNKNOWN;
+ }
+
+detected:
+ LOC_LOGD("HAL: %s returned %d", __FUNCTION__, gTarget);
+ return gTarget;
}
diff --git a/gps/utils/loc_target.h b/gps/utils/loc_target.h
index 489aadd..873ddfc 100644
--- a/gps/utils/loc_target.h
+++ b/gps/utils/loc_target.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,21 +28,47 @@
*/
#ifndef LOC_TARGET_H
#define LOC_TARGET_H
+#define TARGET_SET(gnss,ssc) ( (gnss<<1)|ssc )
+#define TARGET_DEFAULT TARGET_SET(GNSS_MSM, HAS_SSC)
+#define TARGET_MDM TARGET_SET(GNSS_MDM, HAS_SSC)
+#define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC)
+#define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC)
+#define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC)
+#define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC)
+#define TARGET_AUTO TARGET_SET(GNSS_AUTO, NO_SSC)
+#define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC)
+#define getTargetGnssType(target) (target>>1)
#ifdef __cplusplus
extern "C"
{
#endif
+unsigned int loc_get_target(void);
+
+/*The character array passed to this function should have length
+ of atleast PROPERTY_VALUE_MAX*/
+void loc_get_target_baseband(char *baseband, int array_length);
+/*The character array passed to this function should have length
+ of atleast PROPERTY_VALUE_MAX*/
+void loc_get_platform_name(char *platform_name, int array_length);
+
+/* Please remember to update 'target_name' in loc_log.cpp,
+ if do any changes to this enum. */
typedef enum {
- TARGET_OTHER = 0,
- TARGET_APQ8064_STANDALONE,
- TARGET_APQ8064_FUSION3,
- TARGET_MPQ8064,
- TARGET_MSM8930
-}targetEnumType;
+ GNSS_NONE = 0,
+ GNSS_MSM,
+ GNSS_GSS,
+ GNSS_MDM,
+ GNSS_QCA1530,
+ GNSS_AUTO,
+ GNSS_UNKNOWN
+}GNSS_TARGET;
-targetEnumType get_target(void);
+typedef enum {
+ NO_SSC = 0,
+ HAS_SSC
+}SSC_TYPE;
#ifdef __cplusplus
}
diff --git a/gps/utils/loc_timer.c b/gps/utils/loc_timer.c
new file mode 100644
index 0000000..2beca5f
--- /dev/null
+++ b/gps/utils/loc_timer.c
@@ -0,0 +1,202 @@
+/* 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.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<sys/time.h>
+#include "loc_timer.h"
+#include<time.h>
+#include<errno.h>
+
+enum timer_state {
+ READY = 100,
+ WAITING,
+ DONE,
+ ABORT
+};
+
+typedef struct {
+ loc_timer_callback callback_func;
+ void *user_data;
+ unsigned int time_msec;
+ pthread_cond_t timer_cond;
+ pthread_mutex_t timer_mutex;
+ enum timer_state state;
+}timer_data;
+
+static void *timer_thread(void *thread_data)
+{
+ int ret = -ETIMEDOUT;
+ struct timespec ts;
+ struct timeval tv;
+ timer_data* t = (timer_data*)thread_data;
+
+ LOC_LOGD("%s:%d]: Enter. Delay = %d\n", __func__, __LINE__, t->time_msec);
+
+ gettimeofday(&tv, NULL);
+ clock_gettime(CLOCK_REALTIME, &ts);
+ if(t->time_msec >= 1000) {
+ ts.tv_sec += t->time_msec/1000;
+ t->time_msec = t->time_msec % 1000;
+ }
+ if(t->time_msec)
+ ts.tv_nsec += t->time_msec * 1000000;
+ if(ts.tv_nsec > 999999999) {
+ LOC_LOGD("%s:%d]: Large nanosecs\n", __func__, __LINE__);
+ ts.tv_sec += 1;
+ ts.tv_nsec -= 1000000000;
+ }
+ LOC_LOGD("%s:%d]: ts.tv_sec:%d; ts.tv_nsec:%d\n"
+ "\t Current time: %d sec; %d nsec",
+ __func__, __LINE__, (int)ts.tv_sec, (int)ts.tv_nsec,
+ (int)tv.tv_sec, (int)tv.tv_usec*1000);
+
+ pthread_mutex_lock(&(t->timer_mutex));
+ if (READY == t->state) {
+ t->state = WAITING;
+ ret = pthread_cond_timedwait(&t->timer_cond, &t->timer_mutex, &ts);
+ t->state = DONE;
+ }
+ pthread_mutex_unlock(&(t->timer_mutex));
+
+ switch (ret) {
+ case ETIMEDOUT:
+ LOC_LOGV("%s:%d]: loc_timer timed out", __func__, __LINE__);
+ break;
+ case 0:
+ LOC_LOGV("%s:%d]: loc_timer stopped", __func__, __LINE__);
+ break;
+ case -ETIMEDOUT:
+ LOC_LOGV("%s:%d]: loc_timer cancelled", __func__, __LINE__);
+ break;
+ default:
+ LOC_LOGE("%s:%d]: Call to pthread timedwait failed; ret=%d\n",
+ __func__, __LINE__, ret);
+ break;
+ }
+
+ if(ETIMEDOUT == ret)
+ t->callback_func(t->user_data, ret);
+
+ // A (should be rare) race condition is that, when the loc_time_stop is called
+ // and acquired mutex, we reach here. pthread_mutex_destroy will fail with
+ // error code EBUSY. We give it 6 tries in 5 seconds. Should be eanough time
+ // for loc_timer_stop to complete. With the 7th try, we also perform unlock
+ // prior to destroy.
+ {
+ int i;
+ for (i = 0; EBUSY == pthread_mutex_destroy(&t->timer_mutex) && i <= 5; i++) {
+ if (i < 5) {
+ sleep(1);
+ } else {
+ // nah, forget it, something is seriously wrong. Mutex has been
+ // held too long. Unlock the mutext here.
+ pthread_mutex_unlock(&t->timer_mutex);
+ }
+ }
+ }
+ pthread_cond_destroy(&t->timer_cond);
+
+ free(t);
+ LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
+ return NULL;
+}
+
+void* loc_timer_start(unsigned int msec, loc_timer_callback cb_func,
+ void* caller_data)
+{
+ timer_data *t=NULL;
+ pthread_attr_t tattr;
+ pthread_t id;
+ LOC_LOGD("%s:%d]: Enter\n", __func__, __LINE__);
+ if(cb_func == NULL || msec == 0) {
+ LOC_LOGE("%s:%d]: Error: Wrong parameters\n", __func__, __LINE__);
+ goto _err;
+ }
+ t = (timer_data *)calloc(1, sizeof(timer_data));
+ if(t == NULL) {
+ LOC_LOGE("%s:%d]: Could not allocate memory. Failing.\n",
+ __func__, __LINE__);
+ goto _err;
+ }
+
+ if(pthread_cond_init(&(t->timer_cond), NULL)) {
+ LOC_LOGE("%s:%d]: Pthread cond init failed\n", __func__, __LINE__);
+ goto t_err;
+ }
+ if(pthread_mutex_init(&(t->timer_mutex), NULL)) {
+ LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__);
+ goto cond_err;
+ }
+
+ t->callback_func = cb_func;
+ t->user_data = caller_data;
+ t->time_msec = msec;
+ t->state = READY;
+
+ if (pthread_attr_init(&tattr)) {
+ LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__);
+ goto mutex_err;
+ }
+ pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
+
+ if(pthread_create(&(id), &tattr, timer_thread, (void *)t)) {
+ LOC_LOGE("%s:%d]: Could not create thread\n", __func__, __LINE__);
+ goto attr_err;
+ }
+
+ LOC_LOGD("%s:%d]: Created thread with id: %d\n",
+ __func__, __LINE__, (int)id);
+ goto _err;
+
+attr_err:
+ pthread_attr_destroy(&tattr);
+mutex_err:
+ pthread_mutex_destroy(&t->timer_mutex);
+cond_err:
+ pthread_cond_destroy(&t->timer_cond);
+t_err:
+ free(t);
+_err:
+ LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
+ return t;
+}
+
+void loc_timer_stop(void* handle) {
+ timer_data* t = (timer_data*)handle;
+
+ if (NULL != t && (READY == t->state || WAITING == t->state) &&
+ pthread_mutex_lock(&(t->timer_mutex)) == 0) {
+ if (READY == t->state || WAITING == t->state) {
+ pthread_cond_signal(&t->timer_cond);
+ t->state = ABORT;
+ }
+ pthread_mutex_unlock(&(t->timer_mutex));
+ }
+}
diff --git a/gps/utils/loc_timer.h b/gps/utils/loc_timer.h
new file mode 100644
index 0000000..0034d27
--- /dev/null
+++ b/gps/utils/loc_timer.h
@@ -0,0 +1,63 @@
+/* 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 __LOC_DELAY_H__
+#define __LOC_DELAY_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#include<pthread.h>
+#include "log_util.h"
+
+/*
+ Return values:
+ Success = 0
+ Failure = Non zero
+*/
+typedef void(*loc_timer_callback)(void *user_data, int result);
+
+
+/*
+ Returns the handle, which can be used to stop the timer
+*/
+void* loc_timer_start(unsigned int delay_msec,
+ loc_timer_callback,
+ void* user_data);
+
+/*
+ handle becomes invalid upon the return of the callback
+*/
+void loc_timer_stop(void* handle);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif //__LOC_DELAY_H__
diff --git a/gps/utils/log_util.h b/gps/utils/log_util.h
index 9187e4f..8ff6b5a 100644
--- a/gps/utils/log_util.h
+++ b/gps/utils/log_util.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,6 +30,23 @@
#ifndef __LOG_UTIL_H__
#define __LOG_UTIL_H__
+#ifndef USE_GLIB
+#include <utils/Log.h>
+#endif /* USE_GLIB */
+
+#ifdef USE_GLIB
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifndef LOG_TAG
+#define LOG_TAG "GPS_UTILS"
+
+#endif // LOG_TAG
+
+#endif /* USE_GLIB */
+
#ifdef __cplusplus
extern "C"
{
@@ -72,41 +89,54 @@ extern const char ENTRY_TAG[];
extern void loc_logger_init(unsigned long debug, unsigned long timestamp);
extern char* get_timestamp(char* str, unsigned long buf_size);
-
-#include <utils/Log.h>
-
#ifndef DEBUG_DMN_LOC_API
/* LOGGING MACROS */
-#define LOC_LOGE(...) ALOGE("E/"__VA_ARGS__)
+/*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp
+ if that value remains unchanged, it means gps.conf did not
+ provide a value and we default to the initial value to use
+ Android's logging levels*/
+#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5))
+
+#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5))
+
+#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5))
+
+#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5))
+
+#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5))
+
+#define LOC_LOGE(...) \
+IF_LOC_LOGE { ALOGE("E/" __VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("E/" __VA_ARGS__); }
#define LOC_LOGW(...) \
-if (loc_logger.DEBUG_LEVEL >= 2) { ALOGE("W/"__VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGW("W/"__VA_ARGS__); }
+IF_LOC_LOGW { ALOGE("W/" __VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/" __VA_ARGS__); }
#define LOC_LOGI(...) \
-if (loc_logger.DEBUG_LEVEL >= 3) { ALOGE("I/"__VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGI("W/"__VA_ARGS__); }
+IF_LOC_LOGI { ALOGE("I/" __VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/" __VA_ARGS__); }
#define LOC_LOGD(...) \
-if (loc_logger.DEBUG_LEVEL >= 4) { ALOGE("D/"__VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGD("W/"__VA_ARGS__); }
+IF_LOC_LOGD { ALOGE("D/" __VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/" __VA_ARGS__); }
#define LOC_LOGV(...) \
-if (loc_logger.DEBUG_LEVEL >= 5) { ALOGE("V/"__VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGV("W/"__VA_ARGS__); }
+IF_LOC_LOGV { ALOGE("V/" __VA_ARGS__); } \
+else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/" __VA_ARGS__); }
#else /* DEBUG_DMN_LOC_API */
-#define LOC_LOGE(...) ALOGE("E/"__VA_ARGS__)
+#define LOC_LOGE(...) ALOGE("E/" __VA_ARGS__)
-#define LOC_LOGW(...) ALOGW("W/"__VA_ARGS__)
+#define LOC_LOGW(...) ALOGW("W/" __VA_ARGS__)
-#define LOC_LOGI(...) ALOGI("I/"__VA_ARGS__)
+#define LOC_LOGI(...) ALOGI("I/" __VA_ARGS__)
-#define LOC_LOGD(...) ALOGD("D/"__VA_ARGS__)
+#define LOC_LOGD(...) ALOGD("D/" __VA_ARGS__)
-#define LOC_LOGV(...) ALOGV("V/"__VA_ARGS__)
+#define LOC_LOGV(...) ALOGV("V/" __VA_ARGS__)
#endif /* DEBUG_DMN_LOC_API */
diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c
index df1d7a5..f82d4c0 100644
--- a/gps/utils/msg_q.c
+++ b/gps/utils/msg_q.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
+/* 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
@@ -9,7 +9,7 @@
* 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
+ * * 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.
*
@@ -30,7 +30,7 @@
#define LOG_TAG "LocSvc_utils_q"
#include "log_util.h"
-
+#include "platform_lib_includes.h"
#include "linked_list.h"
#include <stdio.h>
#include <stdlib.h>
@@ -138,6 +138,20 @@ msq_q_err_type msg_q_init(void** msg_q_data)
/*===========================================================================
+ FUNCTION: msg_q_init2
+
+ ===========================================================================*/
+const void* msg_q_init2()
+{
+ void* q = NULL;
+ if (eMSG_Q_SUCCESS != msg_q_init(&q)) {
+ q = NULL;
+ }
+ return q;
+}
+
+/*===========================================================================
+
FUNCTION: msg_q_destroy
===========================================================================*/
diff --git a/gps/utils/msg_q.h b/gps/utils/msg_q.h
index d3d5cc5..453b8ce 100644
--- a/gps/utils/msg_q.h
+++ b/gps/utils/msg_q.h
@@ -58,7 +58,7 @@ FUNCTION msg_q_init
DESCRIPTION
Initializes internal structures for message queue.
- msg_q_data: State of message queue to be initialized.
+ msg_q_data: pointer to an opaque Q handle to be returned; NULL if fails
DEPENDENCIES
N/A
@@ -73,6 +73,24 @@ SIDE EFFECTS
msq_q_err_type msg_q_init(void** msg_q_data);
/*===========================================================================
+FUNCTION msg_q_init2
+
+DESCRIPTION
+ Initializes internal structures for message queue.
+
+DEPENDENCIES
+ N/A
+
+RETURN VALUE
+ opaque handle to the Q created; NULL if create fails
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+const void* msg_q_init2();
+
+/*===========================================================================
FUNCTION msg_q_destroy
DESCRIPTION
diff --git a/gps/utils/sec_gps.c b/gps/utils/sec_gps.c
new file mode 100644
index 0000000..d5b1226
--- /dev/null
+++ b/gps/utils/sec_gps.c
@@ -0,0 +1,12 @@
+
+
+int sec_gps_conf(void)
+{
+ return 0;
+}
+
+int Sec_Configuration(void)
+{
+ return 0;
+}
+
diff --git a/include/hardware/gps.h b/include/hardware/gps.h
index 66519c1..305a46f 100644
--- a/include/hardware/gps.h
+++ b/include/hardware/gps.h
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (c) 2011,2012 Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +18,11 @@
#define ANDROID_INCLUDE_HARDWARE_GPS_H
#include <stdint.h>
-#include <stdbool.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <pthread.h>
+#include <sys/socket.h>
+#include <stdbool.h>
#include <hardware/hardware.h>
@@ -32,7 +32,7 @@ __BEGIN_DECLS
* The id of this module
*/
#define GPS_HARDWARE_MODULE_ID "gps"
-#define ULP_NETWORK_INTERFACE "ulp-network-interface"
+
/** Milliseconds since January 1, 1970 */
typedef int64_t GpsUtcTime;
@@ -40,6 +40,9 @@ typedef int64_t GpsUtcTime;
/** Maximum number of SVs for gps_sv_status_callback(). */
#define GPS_MAX_SVS 32
+/** Maximum number of Measurements in gps_measurement_callback(). */
+#define GPS_MAX_MEASUREMENT 32
+
/** Requested operational mode for GPS operation. */
typedef uint32_t GpsPositionMode;
// IMPORTANT: Note that the following values must match
@@ -89,26 +92,6 @@ typedef uint16_t GpsLocationFlags;
#define GPS_LOCATION_HAS_BEARING 0x0008
/** GpsLocation has valid accuracy. */
#define GPS_LOCATION_HAS_ACCURACY 0x0010
-/** 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
-
-/** Location Information Source */
-/** Position source is ULP */
-#define ULP_LOCATION_IS_FROM_HYBRID 0x0001
-/** Position source is GNSS only */
-#define ULP_LOCATION_IS_FROM_GNSS 0x0002
/** Flags for the gps_set_capabilities callback. */
@@ -125,8 +108,13 @@ typedef uint16_t GpsLocationFlags;
#define GPS_CAPABILITY_SINGLE_SHOT 0x0000008
/** GPS supports on demand time injection */
#define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010
-/* Hybrid support, the Android Framework will query to see if this capability is set before using the ulp functionalities in HAL */
-#define ULP_CAPABILITY 0x0000020
+/** GPS supports Geofencing */
+#define GPS_CAPABILITY_GEOFENCING 0x0000020
+/** GPS supports Measurements */
+#define GPS_CAPABILITY_MEASUREMENTS 0x0000040
+/** GPS supports Navigation Messages */
+#define GPS_CAPABILITY_NAV_MESSAGES 0x0000080
+
/** Flags used to specify which aiding data to delete
when calling delete_aiding_data(). */
typedef uint32_t GpsAidingData;
@@ -146,38 +134,37 @@ typedef uint32_t GpsAidingData;
#define GPS_DELETE_CELLDB_INFO 0x00000800
#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 GLO_DELETE_EPHEMERIS 0x00004000
+#define GLO_DELETE_ALMANAC 0x00008000
+#define GLO_DELETE_SVDIR 0x00010000
+#define GLO_DELETE_SVSTEER 0x00020000
+#define GLO_DELETE_ALMANAC_CORR 0x00040000
#define GPS_DELETE_TIME_GPS 0x00080000
-#define GPS_DELETE_TIME_GLO 0x00100000
+#define GLO_DELETE_TIME 0x00100000
+#define BDS_DELETE_SVDIR 0X00200000
+#define BDS_DELETE_SVSTEER 0X00400000
+#define BDS_DELETE_TIME 0X00800000
+#define BDS_DELETE_ALMANAC_CORR 0X01000000
+#define BDS_DELETE_EPHEMERIS 0X02000000
+#define BDS_DELETE_ALMANAC 0X04000000
#define GPS_DELETE_ALL 0xFFFFFFFF
/** AGPS type */
-typedef int16_t AGpsType;
-#define AGPS_TYPE_INVALID -1
-#define AGPS_TYPE_ANY 0
+typedef uint16_t AGpsType;
#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 uint16_t AGpsSetIDType;
#define AGPS_SETID_TYPE_NONE 0
#define AGPS_SETID_TYPE_IMSI 1
#define AGPS_SETID_TYPE_MSISDN 2
-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
+typedef uint16_t ApnIpType;
+#define APN_IP_INVALID 0
+#define APN_IP_IPV4 1
+#define APN_IP_IPV6 2
+#define APN_IP_IPV4V6 3
/**
* String length constants
@@ -250,9 +237,135 @@ typedef uint16_t AGpsStatusValue;
#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6
/**
- * Name for the EXTRA CMD interface. To pass from app to HAL
+ * Flags to indicate what fields in GpsClock are valid.
+ */
+typedef uint16_t GpsClockFlags;
+/** A valid 'leap second' is stored in the data structure. */
+#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0)
+/** A valid 'time uncertainty' is stored in the data structure. */
+#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
+/** A valid 'full bias' is stored in the data structure. */
+#define GPS_CLOCK_HAS_FULL_BIAS (1<<2)
+/** A valid 'bias' is stored in the data structure. */
+#define GPS_CLOCK_HAS_BIAS (1<<3)
+/** A valid 'bias uncertainty' is stored in the data structure. */
+#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
+/** A valid 'drift' is stored in the data structure. */
+#define GPS_CLOCK_HAS_DRIFT (1<<5)
+/** A valid 'drift uncertainty' is stored in the data structure. */
+#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
+
+/**
+ * Enumeration of the available values for the GPS Clock type.
+ */
+typedef uint8_t GpsClockType;
+/** The type is not available ot it is unknown. */
+#define GPS_CLOCK_TYPE_UNKNOWN 0
+/** The source of the time value reported by GPS clock is the local hardware clock. */
+#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1
+/**
+ * The source of the time value reported by GPS clock is the GPS time derived from satellites
+ * (epoch = Jan 6, 1980)
+ */
+#define GPS_CLOCK_TYPE_GPS_TIME 2
+
+/**
+ * Flags to indicate what fields in GpsMeasurement are valid.
+ */
+typedef uint32_t GpsMeasurementFlags;
+/** A valid 'snr' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_SNR (1<<0)
+/** A valid 'elevation' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1)
+/** A valid 'elevation uncertainty' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2)
+/** A valid 'azimuth' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3)
+/** A valid 'azimuth uncertainty' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4)
+/** A valid 'pseudorange' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5)
+/** A valid 'pseudorange uncertainty' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6)
+/** A valid 'code phase' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7)
+/** A valid 'code phase uncertainty' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8)
+/** A valid 'carrier frequency' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
+/** A valid 'carrier cycles' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
+/** A valid 'carrier phase' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
+/** A valid 'carrier phase uncertainty' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
+/** A valid 'bit number' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13)
+/** A valid 'time from last bit' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14)
+/** A valid 'doppler shift' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15)
+/** A valid 'doppler shift uncertainty' is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16)
+/** A valid 'used in fix' flag is stored in the data structure. */
+#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17)
+
+/**
+ * Enumeration of the available values for the GPS Measurement's loss of lock.
+ */
+typedef uint8_t GpsLossOfLock;
+/** The indicator is not available or it is unknown. */
+#define GPS_LOSS_OF_LOCK_UNKNOWN 0
+/** The measurement does not present any indication of loss of lock. */
+#define GPS_LOSS_OF_LOCK_OK 1
+/** Loss of lock between previous and current observation: cycle slip possible. */
+#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2
+
+/**
+ * Enumeration of available values for the GPS Measurement's multipath indicator.
+ */
+typedef uint8_t GpsMultipathIndicator;
+/** The indicator is not available or unknown. */
+#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0
+/** The measurement has been indicated to use multipath. */
+#define GPS_MULTIPATH_INDICATOR_DETECTED 1
+/** The measurement has been indicated Not to use multipath. */
+#define GPS_MULTIPATH_INDICATOR_NOT_USED 2
+
+/**
+ * Flags indicating the GPS measurement state.
*/
-#define ULP_RAW_CMD_INTERFACE "ulp-raw-cmd"
+typedef uint16_t GpsMeasurementState;
+#define GPS_MEASUREMENT_STATE_UNKNOWN 0
+#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
+#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
+#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
+#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
+
+/**
+ * Flags indicating the Accumulated Delta Range's states.
+ */
+typedef uint16_t GpsAccumulatedDeltaRangeState;
+#define GPS_ADR_STATE_UNKNOWN 0
+#define GPS_ADR_STATE_VALID (1<<0)
+#define GPS_ADR_STATE_RESET (1<<1)
+#define GPS_ADR_STATE_CYCLE_SLIP (1<<2)
+
+/**
+ * Enumeration of available values to indicate the available GPS Natigation message types.
+ */
+typedef uint8_t GpsNavigationMessageType;
+/** The message type is unknown. */
+#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
+/** L1 C/A message contained in the structure. */
+#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1
+/** L2-CNAV message contained in the structure. */
+#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2
+/** L5-CNAV message contained in the structure. */
+#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3
+/** CNAV-2 message contained in the structure. */
+#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4
+
/**
* Name for the GPS XTRA interface.
@@ -270,6 +383,11 @@ typedef uint16_t AGpsStatusValue;
#define AGPS_INTERFACE "agps"
/**
+ * Name of the Supl Certificate interface.
+ */
+#define SUPL_CERTIFICATE_INTERFACE "supl-certificate"
+
+/**
* Name for NI interface
*/
#define GPS_NI_INTERFACE "gps-ni"
@@ -280,115 +398,25 @@ typedef uint16_t AGpsStatusValue;
#define AGPS_RIL_INTERFACE "agps_ril"
/**
- * The GPS chipset can use Psc for AGPS.
+ * Name for the GPS_Geofencing interface.
*/
-#define AGPS_USE_PSC
+#define GPS_GEOFENCING_INTERFACE "gps_geofencing"
/**
-* Name for ULP Phone Context Interface
-*/
-#define ULP_PHONE_CONTEXT_INTERFACE "ulp-phone-context"
-
-/*
- * Name for the GPS_Geofencing interface.
+ * Name of the GPS Measurements interface.
*/
-#define GPS_GEOFENCING_INTERFACE "gps_geofencing"
+#define GPS_MEASUREMENT_INTERFACE "gps_measurement"
-/** Represents recurrence of location */
-typedef enum{
- ULP_LOC_RECURRENCE_PERIODIC = 0,
- ULP_LOC_RECURRENCE_SINGLE,
-}UlpRecurrenceCriteria;
-
-/** Represents horizontal accuracy options */
-typedef enum {
- ULP_HORZ_ACCURACY_DONT_CARE = 0,
- ULP_HORZ_ACCURACY_LOW,
- ULP_HORZ_ACCURACY_MED,
- ULP_HORZ_ACCURACY_HIGH,
-}UlpHorzAccuracyCriteria;
-
-/** Represents accuracy options (for speed, altitude, and
- * bearing) */
-typedef enum {
- ULP_ACCURACY_DONT_CARE = 0,
- ULP_ACCURACY_LOW,
- ULP_ACCURACY_HIGH,
-}UlpAccuracyCriteria;
-
-/** Represents power consumption options */
-typedef enum {
- ULP_POWER_REQ_DONT_CARE = 0,
- ULP_POWER_REQ_LOW,
- ULP_POWER_REQ_HIGH,
-}UlpPowerCriteria;
-
-/** Represents data usage options */
-typedef enum {
- ULP_DATA_REQ_DONT_CARE = 0,
- ULP_DATA_ALLOW,
- ULP_DATA_DENY,
-}UlpDataUsageCriteria;
-
-/** Enable the reporting of altitude in location reports */
-#define ULP_ENABLE_ALTITUDE_REPORT 0x01
-/** Enable the reporting of speed in location reports */
-#define ULP_ENABLE_SPEED_REPORT 0x02
-/** Enable the reporting of bearing in location reports */
-#define ULP_ENABLE_BEARING_REPORT 0x04
-
-#define ULP_CRITERIA_HAS_ACTION 0x00000001
-#define ULP_CRITERIA_HAS_PROVIDER_SOURCE 0x00000002
-#define ULP_CRITERIA_HAS_RECURRENCE_TYPE 0x00000004
-#define ULP_CRITERIA_HAS_PREFERRED_RESPONSE_TIME 0x00000010
-#define ULP_CRITERIA_HAS_MIN_INTERVAL 0x00000020
-#define ULP_CRITERIA_HAS_MIN_DISTANCE 0x00000040
-#define ULP_CRITERIA_HAS_MIN_DIST_SAMPLE_INTERVAL 0x00000080
-#define ULP_CRITERIA_HAS_DESIRED_OUTPUT_PARAMETER 0x00000100
-#define ULP_CRITERIA_HAS_PREFERRED_HORIZONTAL_ACCURACY 0x00000200
-#define ULP_CRITERIA_HAS_PREFERRED_POWER_CONSUMPTION 0x00000400
-#define ULP_CRITERIA_HAS_PREFERRED_ALTITUDE_ACCURACY 0x00000800
-#define ULP_CRITERIA_HAS_PREFERRED_BEARING_ACCURACY 0x00001000
-#define ULP_CRITERIA_HAS_PREFERRED_DATA_USAGE 0x00002000
-#define ULP_CRITERIA_HAS_INTERMEDIATE_POS_REPORT_ENABLED 0x00004000
-
-#define ULP_PROVIDER_SOURCE_GNSS 0x00000001
-#define ULP_PROVIDER_SOURCE_HYBRID 0x00000002
-
-
-#define ULP_ADD_CRITERIA 1
-#define ULP_REMOVE_CRITERIA 2
+/**
+ * Name of the GPS navigation message interface.
+ */
+#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message"
-typedef struct {
+/**
+ * Name of the GNSS/GPS configuration interface.
+ */
+#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration"
- uint32_t valid_mask;
- /* delete or add. This is a mandatory field */
- int action;
- /*via gps or hybrid provider*/
- int provider_source;
- /** PERIODIC or SINGLE */
- UlpRecurrenceCriteria recurrence_type;
- /** obtain position within the specified response time */
- uint32_t preferred_response_time;
- /** Send updates after the specified interval */
- uint32_t min_interval;
- /** Send updates after device moved a specified distance */
- float min_distance;
- uint32_t min_dist_sample_interval;
- /** Fields specfied in the mask should be reported in the
- * position report (altitude, bearing and speed) */
- uint32_t desired_output_parameter;
- /** Desired accuracy for latitude, longitude */
- UlpHorzAccuracyCriteria preferred_horizontal_accuracy;
- /** Desired power consumption level */
- UlpPowerCriteria preferred_power_consumption;
- /** Desired accuracy for altitude */
- UlpAccuracyCriteria preferred_altitude_accuracy;
- /** Desired accuracy for bearing */
- UlpAccuracyCriteria preferred_bearing_accuracy;
- UlpDataUsageCriteria preferred_data_usage;
- bool intermediate_pos_report_enabled;
-} UlpLocationCriteria;
/** Represents a location. */
typedef struct {
@@ -396,8 +424,6 @@ typedef struct {
size_t size;
/** Contains GpsLocationFlags bits. */
uint16_t flags;
- /* Provider indicator for HYBRID or GPS */
- uint16_t position_source;
/** Represents latitude in degrees. */
double latitude;
/** Represents longitude in degrees. */
@@ -413,13 +439,6 @@ typedef struct {
float accuracy;
/** Timestamp for the location fix. */
GpsUtcTime timestamp;
- /*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];
} GpsLocation;
/** Represents the status. */
@@ -441,10 +460,7 @@ typedef struct {
float elevation;
/** Azimuth of SV in degrees. */
float azimuth;
-#if 1
- /** Placeholder for Samsung ABI compat */
- int unknown;
-#endif
+ int used;
} GpsSvInfo;
/** Represents SV status. */
@@ -475,6 +491,7 @@ typedef struct {
uint32_t used_in_fix_mask;
} GpsSvStatus;
+
/* 2G and 3G */
/* In 3G lac is discarded */
typedef struct {
@@ -482,9 +499,6 @@ typedef struct {
uint16_t mcc;
uint16_t mnc;
uint16_t lac;
-#ifdef AGPS_USE_PSC
- uint16_t psc;
-#endif
uint32_t cid;
} AGpsRefLocationCellID;
@@ -511,8 +525,9 @@ typedef void (* gps_location_callback)(GpsLocation* location);
*/
typedef void (* gps_status_callback)(GpsStatus* status);
-/** Callback with SV status information.
- * Can only be called from a thread created by create_thread_cb.
+/**
+ * Callback with SV status information.
+ * Can only be called from a thread created by create_thread_cb.
*/
typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
@@ -564,7 +579,7 @@ typedef struct {
size_t size;
/**
* Opens the interface and provides the callback routines
- * to the implemenation of this interface.
+ * to the implementation of this interface.
*/
int (*init)( GpsCallbacks* callbacks );
@@ -605,207 +620,8 @@ typedef struct {
/** Get a pointer to extension information. */
const void* (*get_extension)(const char* name);
-
- /* set criterias of location requests */
- int (*update_criteria) (UlpLocationCriteria criteria );
} GpsInterface;
-/** Extended interface for raw GPS command support. */
-typedef struct {
- /** set to sizeof(ExtraCmdInterface) */
- size_t size;
- /** Injects Android extra cmd into the ulp. Clarify if they are blocking calls */
- bool (*inject_raw_cmd)(char* bundle, int bundle_length );
-
-} InjectRawCmdInterface;
-
-/** ULP Network Interface */
-/** Request for network position status */
-#define ULP_NETWORK_POS_STATUS_REQUEST (0x01)
-/** Request for periodic network positions */
-#define ULP_NETWORK_POS_START_PERIODIC_REQUEST (0x02)
-/** Request last known location */
-#define ULP_NETWORK_POS_GET_LAST_KNOWN_LOCATION_REQUEST (0x03)
-/** Cancel request */
-#define ULP_NETWORK_POS_STOP_REQUEST (0x04)
-
-/** Position was obtained using Wifi Network */
-#define ULP_NETWORK_POSITION_SRC_WIFI (0x01)
-/** Position was obtained using Cell Network */
-#define ULP_NETWORK_POSITION_SRC_CELL (0x02)
-/** Position was obtained using an Unknown Network */
-#define ULP_NETWORK_POSITION_SRC_UNKNOWN (0x00)
-
-/** Represents the ULP network request */
-typedef struct {
- /** type of request */
- uint16_t request_type;
- /** Desired time between network positions/measurements in ms.
- * Shall be set to 0 if only one position is requested */
- int interval_ms;
- /** network position source to be used */
- uint16_t desired_position_source;
-}UlpNetworkRequestPos;
-
-/** Callback with network position request. */
-typedef void (*ulp_network_location_request)(UlpNetworkRequestPos *req);
-
-/** ULP Network callback structure. */
-typedef struct {
- ulp_network_location_request ulp_network_location_request_cb;
-} UlpNetworkLocationCallbacks;
-
-/** represent a network position */
-typedef struct {
- /** source of the position (Wifi, Cell) */
- uint16_t pos_source;
- /** latitude in degrees */
- double latitude;
- /** longitude in degrees */
- double longitude;
- /** Horzizontal error estimate in meters */
- uint16_t HEPE;
-} UlpNetworkPosition;
-
-/** Represents access point information */
-typedef struct {
- /** Mac adderess */
- char mac_addr[6];
- /** signal strength in dbM */
- int32_t rssi;
- /** Beacon channel for access point */
- uint16_t channel;
-
- /** Bit 0 = AP is used by WiFi positioning system
- * Bit 1 = AP doesn't broadcast SSID Bit 2 = AP has encrption
- * turned on Bit 3 = AP is in infrastructure mode and not in
- * ad-hoc/unknown mode */
- uint8_t ap_qualifier;
-} UlpNetworkAccessPointInfo;
-
-/** Represents Wifi information */
-typedef struct {
- /** Number of APs in the calculated position (-1 means
- * unknown) */
- uint8_t num_aps_in_pos;
- /** Information of the scanned ap's used in the position estimation*/
- UlpNetworkAccessPointInfo *ap_info;
-} UlpNetworkWifiInfo;
-
-
-/** Represent network landscape information */
-typedef struct {
- /** network type Cell/Wifi */
- uint8_t network_type;
- /** network information */
- union {
- UlpNetworkWifiInfo wifi_info;
- uint32_t cell_info;
- } u;
-} UlpNetworkLandscape;
-
-/** network report valid flags */
-/** fix time is valid */
-#define ULP_NETWORK_POSITION_REPORT_HAS_FIX_TIME (0x01)
-/** position is valid */
-#define ULP_NETWORK_POSITION_REPORT_HAS_POSITION (0x02)
-/** landscape is valid */
-#define ULP_NETWORK_POSITION_REPORT_HAS_LANDSCAPE (0x04)
-
-/** Represents the network position report */
-typedef struct
-{
- /** validity flags */
- uint16_t valid_flag;
- /** time fo network fix */
- GpsUtcTime fix_time;
- /** network position */
- UlpNetworkPosition position;
- /** network landscape */
- UlpNetworkLandscape landscape_info;
-}UlpNetworkPositionReport;
-
-/** represents ULP network interface extension */
-typedef struct
-{
- /** set to sizeof(UlpNetworkInterface) */
- size_t size;
- /** initialize network interface */
- int ( *init)(UlpNetworkLocationCallbacks *callback);
- /** send network position */
- int ( *ulp_send_network_position)(UlpNetworkPositionReport *position_report);
-}UlpNetworkInterface;
-
-/** Information for the ULP Phone context interface */
-
-/** the Location settings context supports only ON_CHANGE
- * request type */
-#define ULP_PHONE_CONTEXT_GPS_SETTING (0x01)
-#define ULP_PHONE_CONTEXT_NETWORK_POSITION_SETTING (0x02)
-#define ULP_PHONE_CONTEXT_WIFI_SETTING (0x04)
-/** The battery charging state context supports only
- * ON_CHANGE request type */
-#define ULP_PHONE_CONTEXT_BATTERY_CHARGING_STATE (0x08)
-#define ULP_PHONE_CONTEXT_AGPS_SETTING (0x010)
-#define ULP_PHONE_CONTEXT_ENH_LOCATION_SERVICES_SETTING (0x020)
-
-/** return phone context only once */
-#define ULP_PHONE_CONTEXT_REQUEST_TYPE_SINGLE (0x01)
-/** return phone context periodcially */
-#define ULP_PHONE_CONTEXT_REQUEST_TYPE_PERIODIC (0x02)
-/** return phone context when it changes */
-#define ULP_PHONE_CONTEXT_REQUEST_TYPE_ON_CHANGE (0x03)
-
-
-/** Represents ULP phone context request */
-typedef struct {
- /** context type requested */
- uint16_t context_type;
- /** request type */
- uint16_t request_type;
- /** interval in ms if request type is periodic */
- int interval_ms;
-}UlpPhoneContextRequest;
-
-/** Callback for phone context request. */
-typedef void (*ulp_request_phone_context)(UlpPhoneContextRequest *req);
-
-/** ULP Phone Context callback structure. */
-typedef struct {
- ulp_request_phone_context ulp_request_phone_context_cb;
-}UlpPhoneContextCallbacks;
-
-/** Represents the phone context settings */
-typedef struct {
- /** Phone context information type */
- uint16_t context_type;
-
- /** network information */
- /** gps setting */
- bool is_gps_enabled;
- /** is network positioning enabled */
- bool is_network_position_available;
- /** is wifi turned on */
- bool is_wifi_setting_enabled;
- /** is battery being currently charged */
- bool is_battery_charging;
- /* is agps enabled for single shot */
- bool is_agps_enabled;
- /* is Enhanced Location Services enabled by user*/
- bool is_enh_location_services_enabled;
-} UlpPhoneContextSettings;
-
-/** Represent the phone contxt interface */
-typedef struct
-{
- /** set to sizeof(UlpPhoneContextInterface) */
- size_t size;
- /** Initialize, register callback */
- int (*init)(UlpPhoneContextCallbacks *callback);
- /** send the phone context settings */
- int (*ulp_phone_context_settings_update) (UlpPhoneContextSettings *settings );
-}UlpPhoneContextInterface;
-
/** Callback to request the client to download XTRA data.
* The client should download XTRA data and inject it by calling inject_xtra_data().
* Can only be called from a thread created by create_thread_cb.
@@ -824,7 +640,7 @@ typedef struct {
size_t size;
/**
* Opens the XTRA interface and provides the callback routines
- * to the implemenation of this interface.
+ * to the implementation of this interface.
*/
int (*init)( GpsXtraCallbacks* callbacks );
/** Injects XTRA data into the GPS. */
@@ -845,16 +661,45 @@ typedef struct {
/** Represents the status of AGPS. */
typedef struct {
- /** set to sizeof(AGpsStatus) */
+ /** set to sizeof(AGpsStatus_v1) */
+ size_t size;
+
+ AGpsType type;
+ AGpsStatusValue status;
+} AGpsStatus_v1;
+
+/** Represents the status of AGPS augmented with a IPv4 address field. */
+typedef struct {
+ /** set to sizeof(AGpsStatus_v2) */
size_t size;
AGpsType type;
AGpsStatusValue status;
- int ipv4_addr;
- char ipv6_addr[16];
- char ssid[SSID_BUF_SIZE];
- char password[SSID_BUF_SIZE];
-} AGpsStatus;
+ uint32_t ipaddr;
+} AGpsStatus_v2;
+
+/* Represents the status of AGPS augmented to support IPv4 and IPv6. */
+typedef struct {
+ /** set to sizeof(AGpsStatus_v3) */
+ size_t size;
+
+ AGpsType type;
+ AGpsStatusValue status;
+
+ /**
+ * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
+ * address, or set to INADDR_NONE otherwise.
+ */
+ uint32_t ipaddr;
+
+ /**
+ * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
+ * Any other value of addr.ss_family will be rejected.
+ * */
+ struct sockaddr_storage addr;
+} AGpsStatus_v3;
+
+typedef AGpsStatus_v3 AGpsStatus;
/** Callback with AGPS status information.
* Can only be called from a thread created by create_thread_cb.
@@ -870,34 +715,142 @@ typedef struct {
/** Extended interface for AGPS support. */
typedef struct {
- /** set to sizeof(AGpsInterface) */
+ /** set to sizeof(AGpsInterface_v1) */
size_t size;
/**
* Opens the AGPS interface and provides the callback routines
- * to the implemenation of this interface.
+ * to the implementation of this interface.
*/
void (*init)( AGpsCallbacks* callbacks );
/**
* Notifies that a data connection is available and sets
* the name of the APN to be used for SUPL.
*/
- int (*data_conn_open)( AGpsType agpsType,
- const char* apn, AGpsBearerType bearerType );
+ int (*data_conn_open)( const char* apn );
/**
* Notifies that the AGPS data connection has been closed.
*/
- int (*data_conn_closed)( AGpsType agpsType );
+ int (*data_conn_closed)();
/**
* Notifies that a data connection is not available for AGPS.
*/
- int (*data_conn_failed)(AGpsType agpsType );
+ int (*data_conn_failed)();
/**
* Sets the hostname and port for the AGPS server.
*/
int (*set_server)( AGpsType type, const char* hostname, int port );
-} AGpsInterface;
+} AGpsInterface_v1;
+
+/**
+ * Extended interface for AGPS support, it is augmented to enable to pass
+ * extra APN data.
+ */
+typedef struct {
+ /** set to sizeof(AGpsInterface_v2) */
+ size_t size;
+
+ /**
+ * Opens the AGPS interface and provides the callback routines to the
+ * implementation of this interface.
+ */
+ void (*init)(AGpsCallbacks* callbacks);
+ /**
+ * Deprecated.
+ * If the HAL supports AGpsInterface_v2 this API will not be used, see
+ * data_conn_open_with_apn_ip_type for more information.
+ */
+ int (*data_conn_open)(const char* apn);
+ /**
+ * Notifies that the AGPS data connection has been closed.
+ */
+ int (*data_conn_closed)();
+ /**
+ * Notifies that a data connection is not available for AGPS.
+ */
+ int (*data_conn_failed)();
+ /**
+ * Sets the hostname and port for the AGPS server.
+ */
+ int (*set_server)(AGpsType type, const char* hostname, int port);
+
+ /**
+ * Notifies that a data connection is available and sets the name of the
+ * APN, and its IP type, to be used for SUPL connections.
+ */
+ int (*data_conn_open_with_apn_ip_type)(
+ const char* apn,
+ ApnIpType apnIpType);
+} AGpsInterface_v2;
+
+typedef AGpsInterface_v2 AGpsInterface;
+
+/** Error codes associated with certificate operations */
+#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0
+#define AGPS_CERTIFICATE_ERROR_GENERIC -100
+#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101
+/** A data structure that represents an X.509 certificate using DER encoding */
+typedef struct {
+ size_t length;
+ u_char* data;
+} DerEncodedCertificate;
+
+/**
+ * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
+ * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
+ */
+typedef struct {
+ u_char data[20];
+} Sha1CertificateFingerprint;
+
+/** AGPS Interface to handle SUPL certificate operations */
+typedef struct {
+ /** set to sizeof(SuplCertificateInterface) */
+ size_t size;
+
+ /**
+ * Installs a set of Certificates used for SUPL connections to the AGPS server.
+ * If needed the HAL should find out internally any certificates that need to be removed to
+ * accommodate the certificates to install.
+ * The certificates installed represent a full set of valid certificates needed to connect to
+ * AGPS SUPL servers.
+ * The list of certificates is required, and all must be available at the same time, when trying
+ * to establish a connection with the AGPS Server.
+ *
+ * Parameters:
+ * certificates - A pointer to an array of DER encoded certificates that are need to be
+ * installed in the HAL.
+ * length - The number of certificates to install.
+ * Returns:
+ * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
+ * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
+ * certificates attempted to be installed, the state of the certificates stored should
+ * remain the same as before on this error case.
+ *
+ * IMPORTANT:
+ * If needed the HAL should find out internally the set of certificates that need to be
+ * removed to accommodate the certificates to install.
+ */
+ int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length );
+
+ /**
+ * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
+ * expected that the given set of certificates is removed from the internal store of the HAL.
+ *
+ * Parameters:
+ * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
+ * certificates to revoke.
+ * length - The number of fingerprints provided.
+ * Returns:
+ * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
+ *
+ * IMPORTANT:
+ * If any of the certificates provided (through its fingerprint) is not known by the HAL,
+ * it should be ignored and continue revoking/deleting the rest of them.
+ */
+ int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length );
+} SuplCertificateInterface;
/** Represents an NI request */
typedef struct {
@@ -1023,7 +976,7 @@ typedef struct {
size_t size;
/**
* Opens the AGPS interface and provides the callback routines
- * to the implemenation of this interface.
+ * to the implementation of this interface.
*/
void (*init)( AGpsRilCallbacks* callbacks );
@@ -1053,6 +1006,7 @@ typedef struct {
*/
void (*update_network_availability) (int avaiable, const char* apn);
} AGpsRilInterface;
+
/**
* GPS Geofence.
* There are 3 states associated with a Geofence: Inside, Outside, Unknown.
@@ -1139,28 +1093,29 @@ typedef struct {
#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102
#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103
#define GPS_GEOFENCE_ERROR_GENERIC -149
+
/**
-* The callback associated with the geofence.
-* Parameters:
-* geofence_id - The id associated with the add_geofence_area.
-* location - The current GPS location.
-* transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
-* GPS_GEOFENCE_UNCERTAIN.
-* timestamp - Timestamp when the transition was detected.
-*
-* The callback should only be called when the caller is interested in that
-* particular transition. For instance, if the caller is interested only in
-* ENTERED transition, then the callback should NOT be called with the EXITED
-* transition.
-*
-* IMPORTANT: If a transition is triggered resulting in this callback, the GPS
-* subsystem will wake up the application processor, if its in suspend state.
-*/
+ * The callback associated with the geofence.
+ * Parameters:
+ * geofence_id - The id associated with the add_geofence_area.
+ * location - The current GPS location.
+ * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
+ * GPS_GEOFENCE_UNCERTAIN.
+ * timestamp - Timestamp when the transition was detected.
+ *
+ * The callback should only be called when the caller is interested in that
+ * particular transition. For instance, if the caller is interested only in
+ * ENTERED transition, then the callback should NOT be called with the EXITED
+ * transition.
+ *
+ * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
+ * subsystem will wake up the application processor, if its in suspend state.
+ */
typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location,
-int32_t transition, GpsUtcTime timestamp);
+ int32_t transition, GpsUtcTime timestamp);
/**
- * The callback associated with the availablity of the GPS system for geofencing
+ * The callback associated with the availability of the GPS system for geofencing
* monitoring. If the GPS system determines that it cannot monitor geofences
* because of lack of reliability or unavailability of the GPS signals, it will
* call this callback with GPS_GEOFENCE_UNAVAILABLE parameter.
@@ -1233,77 +1188,623 @@ typedef struct {
/** Extended interface for GPS_Geofencing support */
typedef struct {
- /** set to sizeof(GpsGeofencingInterface) */
- size_t size;
+ /** set to sizeof(GpsGeofencingInterface) */
+ size_t size;
+
+ /**
+ * Opens the geofence interface and provides the callback routines
+ * to the implementation of this interface.
+ */
+ void (*init)( GpsGeofenceCallbacks* callbacks );
+
+ /**
+ * Add a geofence area. This api currently supports circular geofences.
+ * Parameters:
+ * geofence_id - The id for the geofence. If a geofence with this id
+ * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
+ * should be returned.
+ * latitude, longtitude, radius_meters - The lat, long and radius
+ * (in meters) for the geofence
+ * last_transition - The current state of the geofence. For example, if
+ * the system already knows that the user is inside the geofence,
+ * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
+ * will be GPS_GEOFENCE_UNCERTAIN.
+ * monitor_transition - Which transitions to monitor. Bitwise OR of
+ * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
+ * GPS_GEOFENCE_UNCERTAIN.
+ * notification_responsiveness_ms - Defines the best-effort description
+ * of how soon should the callback be called when the transition
+ * associated with the Geofence is triggered. For instance, if set
+ * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
+ * should be called 1000 milliseconds within entering the geofence.
+ * This parameter is defined in milliseconds.
+ * NOTE: This is not to be confused with the rate that the GPS is
+ * polled at. It is acceptable to dynamically vary the rate of
+ * sampling the GPS for power-saving reasons; thus the rate of
+ * sampling may be faster or slower than this.
+ * unknown_timer_ms - The time limit after which the UNCERTAIN transition
+ * should be triggered. This parameter is defined in milliseconds.
+ * See above for a detailed explanation.
+ */
+ void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
+ double radius_meters, int last_transition, int monitor_transitions,
+ int notification_responsiveness_ms, int unknown_timer_ms);
+
+ /**
+ * Pause monitoring a particular geofence.
+ * Parameters:
+ * geofence_id - The id for the geofence.
+ */
+ void (*pause_geofence) (int32_t geofence_id);
+
+ /**
+ * Resume monitoring a particular geofence.
+ * Parameters:
+ * geofence_id - The id for the geofence.
+ * monitor_transitions - Which transitions to monitor. Bitwise OR of
+ * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
+ * GPS_GEOFENCE_UNCERTAIN.
+ * This supersedes the value associated provided in the
+ * add_geofence_area call.
+ */
+ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
+
+ /**
+ * Remove a geofence area. After the function returns, no notifications
+ * should be sent.
+ * Parameter:
+ * geofence_id - The id for the geofence.
+ */
+ void (*remove_geofence_area) (int32_t geofence_id);
+} GpsGeofencingInterface;
+
+
+/**
+ * Represents an estimate of the GPS clock time.
+ */
+typedef struct {
+ /** set to sizeof(GpsClock) */
+ size_t size;
+
+ /** A set of flags indicating the validity of the fields in this data structure. */
+ GpsClockFlags flags;
/**
- * Opens the geofence interface and provides the callback routines
- * to the implemenation of this interface.
+ * Leap second data.
+ * The sign of the value is defined by the following equation:
+ * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000
+ *
+ * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND.
*/
- void (*init)( GpsGeofenceCallbacks* callbacks );
+ int16_t leap_second;
/**
- * Add a geofence area. This api currently supports circular geofences.
- * Parameters:
- * geofence_id - The id for the geofence. If a geofence with this id
- * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
- * should be returned.
- * latitude, longtitude, radius_meters - The lat, long and radius
- * (in meters) for the geofence
- * last_transition - The current state of the geofence. For example, if
- * the system already knows that the user is inside the geofence,
- * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
- * will be GPS_GEOFENCE_UNCERTAIN.
- * monitor_transition - Which transitions to monitor. Bitwise OR of
- * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
- * GPS_GEOFENCE_UNCERTAIN.
- * notification_responsiveness_ms - Defines the best-effort description
- * of how soon should the callback be called when the transition
- * associated with the Geofence is triggered. For instance, if set
- * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
- * should be called 1000 milliseconds within entering the geofence.
- * This parameter is defined in milliseconds.
- * NOTE: This is not to be confused with the rate that the GPS is
- * polled at. It is acceptable to dynamically vary the rate of
- * sampling the GPS for power-saving reasons; thus the rate of
- * sampling may be faster or slower than this.
- * unknown_timer_ms - The time limit after which the UNCERTAIN transition
- * should be triggered. This paramter is defined in milliseconds.
- * See above for a detailed explanation.
- */
- void (*add_geofence_area) (int32_t geofence_id, double latitude,
- double longitude, double radius_meters,
- int last_transition, int monitor_transitions,
- int notification_responsiveness_ms,
- int unknown_timer_ms);
-
- /**
- * Pause monitoring a particular geofence.
- * Parameters:
- * geofence_id - The id for the geofence.
+ * Indicates the type of time reported by the 'time_ns' field.
+ * This is a Mandatory field.
*/
- void (*pause_geofence) (int32_t geofence_id);
+ GpsClockType type;
/**
- * Resume monitoring a particular geofence.
- * Parameters:
- * geofence_id - The id for the geofence.
- * monitor_transitions - Which transitions to monitor. Bitwise OR of
- * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
- * GPS_GEOFENCE_UNCERTAIN.
- * This supersedes the value associated provided in the
- * add_geofence_area call.
+ * The GPS receiver internal clock value. This can be either the local hardware clock value
+ * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver
+ * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported.
+ *
+ * For local hardware clock, this value is expected to be monotonically increasing during
+ * the reporting session. The real GPS time can be derived by compensating the 'full bias'
+ * (when it is available) from this value.
+ *
+ * For GPS time, this value is expected to be the best estimation of current GPS time that GPS
+ * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified.
+ *
+ * Sub-nanosecond accuracy can be provided by means of the 'bias' field.
+ * The value contains the 'time uncertainty' in it.
+ *
+ * This is a Mandatory field.
*/
- void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
+ int64_t time_ns;
/**
- * Remove a geofence area. After the function returns, no notifications
- * should be sent.
- * Parameter:
- * geofence_id - The id for the geofence.
+ * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
+ * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * This value should be set if GPS_CLOCK_TYPE_GPS_TIME is set.
+ * If the data is available 'flags' must contain GPS_CLOCK_HAS_TIME_UNCERTAINTY.
*/
- void (*remove_geofence_area) (int32_t geofence_id);
-} GpsGeofencingInterface;
+ double time_uncertainty_ns;
+
+ /**
+ * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS
+ * time since 0000Z, January 6, 1980, in nanoseconds.
+ * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver
+ * has solved the clock for GPS time.
+ * The caller is responsible for using the 'bias uncertainty' field for quality check.
+ *
+ * The sign of the value is defined by the following equation:
+ * true time (GPS time) = time_ns + (full_bias_ns + bias_ns)
+ *
+ * This value contains the 'bias uncertainty' in it.
+ * If the data is available 'flags' must contain GPS_CLOCK_HAS_FULL_BIAS.
+
+ */
+ int64_t full_bias_ns;
+
+ /**
+ * Sub-nanosecond bias.
+ * The value contains the 'bias uncertainty' in it.
+ *
+ * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS.
+ */
+ double bias_ns;
+
+ /**
+ * 1-Sigma uncertainty associated with the clock's bias in nanoseconds.
+ * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS_UNCERTAINTY.
+ */
+ double bias_uncertainty_ns;
+
+ /**
+ * The clock's drift in nanoseconds (per second).
+ * A positive value means that the frequency is higher than the nominal frequency.
+ *
+ * The value contains the 'drift uncertainty' in it.
+ * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT.
+ */
+ double drift_nsps;
+
+ /**
+ * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
+ * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT_UNCERTAINTY.
+ */
+ double drift_uncertainty_nsps;
+} GpsClock;
+
+/**
+ * Represents a GPS Measurement, it contains raw and computed information.
+ */
+typedef struct {
+ /** set to sizeof(GpsMeasurement) */
+ size_t size;
+
+ /** A set of flags indicating the validity of the fields in this data structure. */
+ GpsMeasurementFlags flags;
+
+ /**
+ * Pseudo-random number in the range of [1, 32]
+ * This is a Mandatory value.
+ */
+ int8_t prn;
+
+ /**
+ * Time offset at which the measurement was taken in nanoseconds.
+ * The reference receiver's time is specified by GpsData::clock::time_ns and should be
+ * interpreted in the same way as indicated by GpsClock::type.
+ *
+ * The sign of time_offset_ns is given by the following equation:
+ * measurement time = GpsClock::time_ns + time_offset_ns
+ *
+ * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
+ * This is a Mandatory value.
+ */
+ double time_offset_ns;
+
+ /**
+ * Per satellite sync state. It represents the current sync state for the associated satellite.
+ * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
+ *
+ * This is a Mandatory value.
+ */
+ GpsMeasurementState state;
+
+ /**
+ * Received GPS Time-of-Week at the measurement time, in nanoseconds.
+ * The value is relative to the beginning of the current GPS week.
+ *
+ * Given the sync state of GPS receiver, per each satellite, valid range for this field can be:
+ * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN
+ * Ranging code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set
+ * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set
+ * Subframe sync : [ 0 6ms ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
+ * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set
+ */
+ int64_t received_gps_tow_ns;
+
+ /**
+ * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
+ */
+ int64_t received_gps_tow_uncertainty_ns;
+
+ /**
+ * Carrier-to-noise density in dB-Hz, in the range [0, 63].
+ * It contains the measured C/N0 value for the signal at the antenna input.
+ *
+ * This is a Mandatory value.
+ */
+ double c_n0_dbhz;
+
+ /**
+ * Pseudorange rate at the timestamp in m/s.
+ * The value also includes the effects of the receiver clock frequency and satellite clock
+ * frequency errors.
+ *
+ * The value includes the 'pseudorange rate uncertainty' in it.
+ * A positive value indicates that the pseudorange is getting larger.
+ *
+ * This is a Mandatory value.
+ */
+ double pseudorange_rate_mps;
+
+ /**
+ * 1-Sigma uncertainty of the pseudurange rate in m/s.
+ * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * This is a Mandatory value.
+ */
+ double pseudorange_rate_uncertainty_mps;
+
+ /**
+ * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
+ * (indicating loss of lock).
+ *
+ * This is a Mandatory value.
+ */
+ GpsAccumulatedDeltaRangeState accumulated_delta_range_state;
+
+ /**
+ * Accumulated delta range since the last channel reset in meters.
+ * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
+ */
+ double accumulated_delta_range_m;
+
+ /**
+ * 1-Sigma uncertainty of the accumulated delta range in meters.
+ * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
+ */
+ double accumulated_delta_range_uncertainty_m;
+
+ /**
+ * Best derived Pseudorange by the chip-set, in meters.
+ * The value contains the 'pseudorange uncertainty' in it.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE.
+ */
+ double pseudorange_m;
+
+ /**
+ * 1-Sigma uncertainty of the pseudorange in meters.
+ * The value contains the 'pseudorange' and 'clock' uncertainty in it.
+ * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY.
+ */
+ double pseudorange_uncertainty_m;
+
+ /**
+ * A fraction of the current C/A code cycle, in the range [0.0, 1023.0]
+ * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch).
+ *
+ * The reference frequency is given by the field 'carrier_frequency_hz'.
+ * The value contains the 'code-phase uncertainty' in it.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE.
+ */
+ double code_phase_chips;
+
+ /**
+ * 1-Sigma uncertainty of the code-phase, in a fraction of chips.
+ * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY.
+ */
+ double code_phase_uncertainty_chips;
+
+ /**
+ * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
+ * If the field is not set, the carrier frequency is assumed to be L1.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
+ */
+ float carrier_frequency_hz;
+
+ /**
+ * The number of full carrier cycles between the satellite and the receiver.
+ * The reference frequency is given by the field 'carrier_frequency_hz'.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES.
+ */
+ int64_t carrier_cycles;
+
+ /**
+ * The RF phase detected by the receiver, in the range [0.0, 1.0].
+ * This is usually the fractional part of the complete carrier phase measurement.
+ *
+ * The reference frequency is given by the field 'carrier_frequency_hz'.
+ * The value contains the 'carrier-phase uncertainty' in it.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE.
+ */
+ double carrier_phase;
+
+ /**
+ * 1-Sigma uncertainty of the carrier-phase.
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
+ */
+ double carrier_phase_uncertainty;
+
+ /**
+ * An enumeration that indicates the 'loss of lock' state of the event.
+ */
+ GpsLossOfLock loss_of_lock;
+
+ /**
+ * The number of GPS bits transmitted since Sat-Sun midnight (GPS week).
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER.
+ */
+ int32_t bit_number;
+
+ /**
+ * The elapsed time since the last received bit in milliseconds, in the range [0, 20]
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT.
+ */
+ int16_t time_from_last_bit_ms;
+
+ /**
+ * Doppler shift in Hz.
+ * A positive value indicates that the SV is moving toward the receiver.
+ *
+ * The reference frequency is given by the field 'carrier_frequency_hz'.
+ * The value contains the 'doppler shift uncertainty' in it.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT.
+ */
+ double doppler_shift_hz;
+
+ /**
+ * 1-Sigma uncertainty of the doppler shift in Hz.
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY.
+ */
+ double doppler_shift_uncertainty_hz;
+
+ /**
+ * An enumeration that indicates the 'multipath' state of the event.
+ */
+ GpsMultipathIndicator multipath_indicator;
+
+ /**
+ * Signal-to-noise ratio in dB.
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR.
+ */
+ double snr_db;
+
+ /**
+ * Elevation in degrees, the valid range is [-90, 90].
+ * The value contains the 'elevation uncertainty' in it.
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION.
+ */
+ double elevation_deg;
+
+ /**
+ * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90].
+ * The uncertainty is represented as the absolute (single sided) value.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY.
+ */
+ double elevation_uncertainty_deg;
+
+ /**
+ * Azimuth in degrees, in the range [0, 360).
+ * The value contains the 'azimuth uncertainty' in it.
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH.
+ * */
+ double azimuth_deg;
+
+ /**
+ * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180].
+ * The uncertainty is represented as an absolute (single sided) value.
+ *
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY.
+ */
+ double azimuth_uncertainty_deg;
+
+ /**
+ * Whether the GPS represented by the measurement was used for computing the most recent fix.
+ * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX.
+ */
+ bool used_in_fix;
+} GpsMeasurement;
+
+/** Represents a reading of GPS measurements. */
+typedef struct {
+ /** set to sizeof(GpsData) */
+ size_t size;
+
+ /** Number of measurements. */
+ size_t measurement_count;
+
+ /** The array of measurements. */
+ GpsMeasurement measurements[GPS_MAX_MEASUREMENT];
+
+ /** The GPS clock time reading. */
+ GpsClock clock;
+} GpsData;
+
+/**
+ * The callback for to report measurements from the HAL.
+ *
+ * Parameters:
+ * data - A data structure containing the measurements.
+ */
+typedef void (*gps_measurement_callback) (GpsData* data);
+
+typedef struct {
+ /** set to sizeof(GpsMeasurementCallbacks) */
+ size_t size;
+ gps_measurement_callback measurement_callback;
+} GpsMeasurementCallbacks;
+
+#define GPS_MEASUREMENT_OPERATION_SUCCESS 0
+#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100
+#define GPS_MEASUREMENT_ERROR_GENERIC -101
+
+/**
+ * Extended interface for GPS Measurements support.
+ */
+typedef struct {
+ /** Set to sizeof(GpsMeasurementInterface) */
+ size_t size;
+
+ /**
+ * Initializes the interface and registers the callback routines with the HAL.
+ * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
+ *
+ * Status:
+ * GPS_MEASUREMENT_OPERATION_SUCCESS
+ * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
+ * corresponding call to 'close'
+ * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
+ * will not generate any updates upon returning this error code.
+ */
+ int (*init) (GpsMeasurementCallbacks* callbacks);
+
+ /**
+ * Stops updates from the HAL, and unregisters the callback routines.
+ * After a call to stop, the previously registered callbacks must be considered invalid by the
+ * HAL.
+ * If stop is invoked without a previous 'init', this function should perform no work.
+ */
+ void (*close) ();
+
+} GpsMeasurementInterface;
+
+
+/** Represents a GPS navigation message (or a fragment of it). */
+typedef struct {
+ /** set to sizeof(GpsNavigationMessage) */
+ size_t size;
+
+ /**
+ * Pseudo-random number in the range of [1, 32]
+ * This is a Mandatory value.
+ */
+ int8_t prn;
+
+ /**
+ * The type of message contained in the structure.
+ * This is a Mandatory value.
+ */
+ GpsNavigationMessageType type;
+
+ /**
+ * Message identifier.
+ * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A
+ * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message.
+ * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1.
+ */
+ int16_t message_id;
+
+ /**
+ * Sub-message identifier.
+ * If required by the message 'type', this value contains a sub-index within the current
+ * message (or frame) that is being transmitted.
+ * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message.
+ */
+ int16_t submessage_id;
+
+ /**
+ * The length of the data (in bytes) contained in the current message.
+ * If this value is different from zero, 'data' must point to an array of the same size.
+ * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word).
+ *
+ * This is a Mandatory value.
+ */
+ size_t data_length;
+
+ /**
+ * The data of the reported GPS message.
+ * The bytes (or words) specified using big endian format (MSB first).
+ *
+ * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be
+ * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first.
+ */
+ uint8_t* data;
+
+} GpsNavigationMessage;
+
+/**
+ * The callback to report an available fragment of a GPS navigation messages from the HAL.
+ *
+ * Parameters:
+ * message - The GPS navigation submessage/subframe representation.
+ */
+typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
+
+typedef struct {
+ /** set to sizeof(GpsNavigationMessageCallbacks) */
+ size_t size;
+ gps_navigation_message_callback navigation_message_callback;
+} GpsNavigationMessageCallbacks;
+
+#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0
+#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100
+#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101
+
+/**
+ * Extended interface for GPS navigation message reporting support.
+ */
+typedef struct {
+ /** Set to sizeof(GpsNavigationMessageInterface) */
+ size_t size;
+
+ /**
+ * Initializes the interface and registers the callback routines with the HAL.
+ * After a successful call to 'init' the HAL must begin to provide updates as they become
+ * available.
+ *
+ * Status:
+ * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
+ * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
+ * without a corresponding call to 'close'.
+ * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
+ * the HAL will not generate any updates upon returning this error code.
+ */
+ int (*init) (GpsNavigationMessageCallbacks* callbacks);
+
+ /**
+ * Stops updates from the HAL, and unregisters the callback routines.
+ * After a call to stop, the previously registered callbacks must be considered invalid by the
+ * HAL.
+ * If stop is invoked without a previous 'init', this function should perform no work.
+ */
+ void (*close) ();
+
+} GpsNavigationMessageInterface;
+
+/**
+ * Interface for passing GNSS configuration contents from platform to HAL.
+ */
+typedef struct {
+ /** Set to sizeof(GnssConfigurationInterface) */
+ size_t size;
+
+ /**
+ * Deliver GNSS configuration contents to HAL.
+ * Parameters:
+ * config_data - a pointer to a char array which holds what usually is expected from
+ file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
+ * length - total number of UTF8 characters in configuraiton data.
+ *
+ * IMPORTANT:
+ * GPS HAL should expect this function can be called multiple times. And it may be
+ * called even when GpsLocationProvider is already constructed and enabled. GPS HAL
+ * should maintain the existing requests for various callback regardless the change
+ * in configuration data.
+ */
+ void (*configuration_update) (const char* config_data, int32_t length);
+} GnssConfigurationInterface;
+
__END_DECLS
#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */