aboutsummaryrefslogtreecommitdiff
path: root/gps/utils
diff options
context:
space:
mode:
authortunturn <arbiter1000@gmail.com>2017-03-09 19:54:15 +1100
committerMax Weffers <rcstar6696@gmail.com>2017-03-14 13:16:55 +0100
commit62c9df243a2031535c2d192d65bfe2112975b679 (patch)
treeacb120f7125d26316a272ff068baa7c5a745ebe3 /gps/utils
parent18bb4421f6a415c3a920527fe04b030839f9ba65 (diff)
shinano-common: don't build local GPS
Change-Id: I6b49d98264935f3ba39faab6550125ed406b54ad
Diffstat (limited to 'gps/utils')
-rw-r--r--gps/utils/Android.mk56
-rw-r--r--gps/utils/Makefile.am44
-rw-r--r--gps/utils/linked_list.c328
-rw-r--r--gps/utils/linked_list.h217
-rw-r--r--gps/utils/loc_cfg.cpp286
-rw-r--r--gps/utils/loc_cfg.h83
-rw-r--r--gps/utils/loc_log.cpp234
-rw-r--r--gps/utils/loc_log.h68
-rw-r--r--gps/utils/loc_target.cpp209
-rw-r--r--gps/utils/loc_target.h68
-rw-r--r--gps/utils/loc_timer.c186
-rw-r--r--gps/utils/loc_timer.h63
-rw-r--r--gps/utils/log_util.h171
-rw-r--r--gps/utils/msg_q.c336
-rw-r--r--gps/utils/msg_q.h207
15 files changed, 0 insertions, 2556 deletions
diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk
deleted file mode 100644
index 1a80b2d..0000000
--- a/gps/utils/Android.mk
+++ /dev/null
@@ -1,56 +0,0 @@
-ifneq ($(BUILD_TINY_ANDROID),true)
-#Compile this library only for builds with the latest modem image
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-## Libs
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libcutils \
- liblog
-
-LOCAL_SRC_FILES += \
- loc_log.cpp \
- loc_cfg.cpp \
- msg_q.c \
- linked_list.c \
- loc_target.cpp \
- loc_timer.c \
- ../platform_lib_abstractions/elapsed_millis_since_boot.cpp
-
-
-LOCAL_CFLAGS += \
- -fno-short-enums \
- -D_ANDROID_
-
-LOCAL_LDFLAGS += -Wl,--export-dynamic
-
-## Includes
-LOCAL_C_INCLUDES:= \
- $(LOCAL_PATH)/../platform_lib_abstractions
-
-LOCAL_COPY_HEADERS_TO:= gps.utils/
-LOCAL_COPY_HEADERS:= \
- loc_log.h \
- loc_cfg.h \
- log_util.h \
- linked_list.h \
- msg_q.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
-
-
-LOCAL_MODULE := libgps.utils
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
-include $(BUILD_SHARED_LIBRARY)
-endif # not BUILD_TINY_ANDROID
diff --git a/gps/utils/Makefile.am b/gps/utils/Makefile.am
deleted file mode 100644
index e5935f0..0000000
--- a/gps/utils/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-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
deleted file mode 100644
index 92617fe..0000000
--- a/gps/utils/linked_list.c
+++ /dev/null
@@ -1,328 +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 "linked_list.h"
-#include <stdio.h>
-#include <string.h>
-
-#define LOG_TAG "LocSvc_utils_ll"
-#include "log_util.h"
-#include "platform_lib_includes.h"
-#include <stdlib.h>
-#include <stdint.h>
-
-typedef struct list_element {
- struct list_element* next;
- struct list_element* prev;
- void* data_ptr;
- void (*dealloc_func)(void*);
-}list_element;
-
-typedef struct list_state {
- list_element* p_head;
- list_element* p_tail;
-} list_state;
-
-/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */
-
-/*===========================================================================
-
- FUNCTION: linked_list_init
-
- ===========================================================================*/
-linked_list_err_type linked_list_init(void** list_data)
-{
- if( list_data == NULL )
- {
- LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
- return eLINKED_LIST_INVALID_PARAMETER;
- }
-
- list_state* tmp_list;
- tmp_list = (list_state*)calloc(1, sizeof(list_state));
- if( tmp_list == NULL )
- {
- LOC_LOGE("%s: Unable to allocate space for list!\n", __FUNCTION__);
- return eLINKED_LIST_FAILURE_GENERAL;
- }
-
- tmp_list->p_head = NULL;
- tmp_list->p_tail = NULL;
-
- *list_data = tmp_list;
-
- return eLINKED_LIST_SUCCESS;
-}
-
-/*===========================================================================
-
- FUNCTION: linked_list_destroy
-
- ===========================================================================*/
-linked_list_err_type linked_list_destroy(void** list_data)
-{
- if( list_data == NULL )
- {
- LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
- return eLINKED_LIST_INVALID_HANDLE;
- }
-
- list_state* p_list = (list_state*)*list_data;
-
- linked_list_flush(p_list);
-
- free(*list_data);
- *list_data = NULL;
-
- return eLINKED_LIST_SUCCESS;
-}
-
-/*===========================================================================
-
- FUNCTION: linked_list_add
-
- ===========================================================================*/
-linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*))
-{
- LOC_LOGD("%s: Adding to list data_obj = 0x%08X\n", __FUNCTION__, data_obj);
- if( list_data == NULL )
- {
- LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
- return eLINKED_LIST_INVALID_HANDLE;
- }
-
- if( data_obj == NULL )
- {
- LOC_LOGE("%s: Invalid input parameter!\n", __FUNCTION__);
- return eLINKED_LIST_INVALID_PARAMETER;
- }
-
- list_state* p_list = (list_state*)list_data;
- list_element* elem = (list_element*)malloc(sizeof(list_element));
- if( elem == NULL )
- {
- LOC_LOGE("%s: Memory allocation failed\n", __FUNCTION__);
- return eLINKED_LIST_FAILURE_GENERAL;
- }
-
- /* Copy data to newly created element */
- elem->data_ptr = data_obj;
- elem->next = NULL;
- elem->prev = NULL;
- elem->dealloc_func = dealloc;
-
- /* Replace head element */
- list_element* tmp = p_list->p_head;
- p_list->p_head = elem;
- /* Point next to the previous head element */
- p_list->p_head->next = tmp;
-
- if( tmp != NULL )
- {
- tmp->prev = p_list->p_head;
- }
- else
- {
- p_list->p_tail = p_list->p_head;
- }
-
- return eLINKED_LIST_SUCCESS;
-}
-
-/*===========================================================================
-
- FUNCTION: linked_list_remove
-
- ===========================================================================*/
-linked_list_err_type linked_list_remove(void* list_data, void **data_obj)
-{
- LOC_LOGD("%s: Removing from list\n", __FUNCTION__);
- if( list_data == NULL )
- {
- LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
- return eLINKED_LIST_INVALID_HANDLE;
- }
-
- if( data_obj == NULL )
- {
- LOC_LOGE("%s: Invalid input parameter!\n", __FUNCTION__);
- return eLINKED_LIST_INVALID_PARAMETER;
- }
-
- list_state* p_list = (list_state*)list_data;
- if( p_list->p_tail == NULL )
- {
- return eLINKED_LIST_UNAVAILABLE_RESOURCE;
- }
-
- list_element* tmp = p_list->p_tail;
-
- /* Replace tail element */
- p_list->p_tail = tmp->prev;
-
- if( p_list->p_tail != NULL )
- {
- p_list->p_tail->next = NULL;
- }
- else
- {
- p_list->p_head = p_list->p_tail;
- }
-
- /* Copy data to output param */
- *data_obj = tmp->data_ptr;
-
- /* Free allocated list element */
- free(tmp);
-
- return eLINKED_LIST_SUCCESS;
-}
-
-/*===========================================================================
-
- FUNCTION: linked_list_empty
-
- ===========================================================================*/
-int linked_list_empty(void* list_data)
-{
- if( list_data == NULL )
- {
- LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
- return (int)eLINKED_LIST_INVALID_HANDLE;
- }
- else
- {
- list_state* p_list = (list_state*)list_data;
- return p_list->p_head == NULL ? 1 : 0;
- }
-}
-
-/*===========================================================================
-
- FUNCTION: linked_list_flush
-
- ===========================================================================*/
-linked_list_err_type linked_list_flush(void* list_data)
-{
- if( list_data == NULL )
- {
- LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__);
- return eLINKED_LIST_INVALID_HANDLE;
- }
-
- list_state* p_list = (list_state*)list_data;
-
- /* Remove all dynamically allocated elements */
- while( p_list->p_head != NULL )
- {
- list_element* tmp = p_list->p_head->next;
-
- /* Free data pointer if told to do so. */
- if( p_list->p_head->dealloc_func != NULL )
- {
- p_list->p_head->dealloc_func(p_list->p_head->data_ptr);
- }
-
- /* Free list element */
- free(p_list->p_head);
-
- p_list->p_head = tmp;
- }
-
- p_list->p_tail = NULL;
-
- return eLINKED_LIST_SUCCESS;
-}
-
-/*===========================================================================
-
- FUNCTION: linked_list_search
-
- ===========================================================================*/
-linked_list_err_type linked_list_search(void* list_data, void **data_p,
- bool (*equal)(void* data_0, void* data),
- void* data_0, bool rm_if_found)
-{
- LOC_LOGD("%s: Search the list\n", __FUNCTION__);
- if( list_data == NULL || NULL == equal )
- {
- LOC_LOGE("%s: Invalid list parameter! list_data %p equal %p\n",
- __FUNCTION__, list_data, equal);
- return eLINKED_LIST_INVALID_HANDLE;
- }
-
- list_state* p_list = (list_state*)list_data;
- if( p_list->p_tail == NULL )
- {
- return eLINKED_LIST_UNAVAILABLE_RESOURCE;
- }
-
- list_element* tmp = p_list->p_head;
-
- if (NULL != data_p) {
- *data_p = NULL;
- }
-
- while (NULL != tmp) {
- if ((*equal)(data_0, tmp->data_ptr)) {
- if (NULL != data_p) {
- *data_p = tmp->data_ptr;
- }
-
- if (rm_if_found) {
- if (NULL == tmp->prev) {
- p_list->p_head = tmp->next;
- } else {
- tmp->prev->next = tmp->next;
- }
-
- if (NULL == tmp->next) {
- p_list->p_tail = tmp->prev;
- } else {
- tmp->next->prev = tmp->prev;
- }
-
- tmp->prev = tmp->next = NULL;
-
- // dealloc data if it is not copied out && caller
- // has given us a dealloc function pointer.
- if (NULL == data_p && NULL != tmp->dealloc_func) {
- tmp->dealloc_func(tmp->data_ptr);
- }
- free(tmp);
- }
-
- tmp = NULL;
- } else {
- tmp = tmp->next;
- }
- }
-
- return eLINKED_LIST_SUCCESS;
-}
-
diff --git a/gps/utils/linked_list.h b/gps/utils/linked_list.h
deleted file mode 100644
index a85f09a..0000000
--- a/gps/utils/linked_list.h
+++ /dev/null
@@ -1,217 +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.
- */
-#ifndef __LINKED_LIST_H__
-#define __LINKED_LIST_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include <stdbool.h>
-#include <stdlib.h>
-
-/** Linked List Return Codes */
-typedef enum
-{
- eLINKED_LIST_SUCCESS = 0,
- /**< Request was successful. */
- eLINKED_LIST_FAILURE_GENERAL = -1,
- /**< Failed because of a general failure. */
- eLINKED_LIST_INVALID_PARAMETER = -2,
- /**< Failed because the request contained invalid parameters. */
- eLINKED_LIST_INVALID_HANDLE = -3,
- /**< Failed because an invalid handle was specified. */
- eLINKED_LIST_UNAVAILABLE_RESOURCE = -4,
- /**< Failed because an there were not enough resources. */
- eLINKED_LIST_INSUFFICIENT_BUFFER = -5,
- /**< Failed because an the supplied buffer was too small. */
-}linked_list_err_type;
-
-/*===========================================================================
-FUNCTION linked_list_init
-
-DESCRIPTION
- Initializes internal structures for linked list.
-
- list_data: State of list to be initialized.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-linked_list_err_type linked_list_init(void** list_data);
-
-/*===========================================================================
-FUNCTION linked_list_destroy
-
-DESCRIPTION
- Destroys internal structures for linked list.
-
- p_list_data: State of list to be destroyed.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-linked_list_err_type linked_list_destroy(void** list_data);
-
-/*===========================================================================
-FUNCTION linked_list_add
-
-DESCRIPTION
- Adds an element to the head of the linked list. The passed in data pointer
- is not modified or freed. Passed in data_obj is expected to live throughout
- the use of the linked_list (i.e. data is not allocated internally)
-
- p_list_data: List to add data to the head of.
- data_obj: Pointer to data to add into list
- dealloc: Function used to deallocate memory for this element. Pass NULL
- if you do not want data deallocated during a flush operation
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*));
-
-/*===========================================================================
-FUNCTION linked_list_remove
-
-DESCRIPTION
- Retrieves data from the list tail. data_obj is the tail element from the list
- passed in by linked_list_add.
-
- p_list_data: List to remove the tail from.
- data_obj: Pointer to data removed from list
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-linked_list_err_type linked_list_remove(void* list_data, void **data_obj);
-
-/*===========================================================================
-FUNCTION linked_list_empty
-
-DESCRIPTION
- Tells whether the list currently contains any elements
-
- p_list_data: List to check if empty.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- 0/FALSE : List contains elements
- 1/TRUE : List is Empty
- Otherwise look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-int linked_list_empty(void* list_data);
-
-/*===========================================================================
-FUNCTION linked_list_flush
-
-DESCRIPTION
- Removes all elements from the list and deallocates them using the provided
- dealloc function while adding elements.
-
- p_list_data: List to remove all elements from.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-linked_list_err_type linked_list_flush(void* list_data);
-
-/*===========================================================================
-FUNCTION linked_list_search
-
-DESCRIPTION
- Searches for an element in the linked list.
-
- p_list_data: List handle.
- data_p: to be stored with the data found; NUll if no match.
- if data_p passed in as NULL, then no write to it.
- equal: Function ptr takes in a list element, and returns
- indication if this the one looking for.
- data_0: The data being compared against.
- rm_if_found: Should data be removed if found?
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-linked_list_err_type linked_list_search(void* list_data, void **data_p,
- bool (*equal)(void* data_0, void* data),
- void* data_0, bool rm_if_found);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __LINKED_LIST_H__ */
diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp
deleted file mode 100644
index 73d1ca4..0000000
--- a/gps/utils/loc_cfg.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation, nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDDEBUG 0
-#define LOG_TAG "LocSvc_utils_cfg"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <time.h>
-#include <loc_cfg.h>
-#include <log_util.h>
-#ifdef USE_GLIB
-#include <glib.h>
-#endif
-#include "platform_lib_includes.h"
-
-/*=============================================================================
- *
- * GLOBAL DATA DECLARATION
- *
- *============================================================================*/
-
-/* Parameter data */
-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'},
-};
-int loc_param_num = sizeof(loc_parameter_table) / sizeof(loc_param_s_type);
-
-/*===========================================================================
-FUNCTION trim_space
-
-DESCRIPTION
- Removes leading and trailing spaces of the string
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-===========================================================================*/
-void trim_space(char *org_string)
-{
- char *scan_ptr, *write_ptr;
- char *first_nonspace = NULL, *last_nonspace = NULL;
-
- scan_ptr = write_ptr = org_string;
-
- while (*scan_ptr)
- {
- if ( !isspace(*scan_ptr) && first_nonspace == NULL)
- {
- first_nonspace = scan_ptr;
- }
-
- if (first_nonspace != NULL)
- {
- *(write_ptr++) = *scan_ptr;
- if ( !isspace(*scan_ptr))
- {
- last_nonspace = write_ptr;
- }
- }
-
- scan_ptr++;
- }
-
- if (last_nonspace) { *last_nonspace = '\0'; }
-}
-
-typedef struct loc_param_v_type
-{
- char* param_name;
-
- char* param_str_value;
- int param_int_value;
- double param_double_value;
-}loc_param_v_type;
-
-/*===========================================================================
-FUNCTION loc_set_config_entry
-
-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.
-
-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
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-===========================================================================*/
-void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
-{
- 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);
- }
- }
-}
-
-/*===========================================================================
-FUNCTION loc_read_conf
-
-DESCRIPTION
- Reads the specified configuration file and sets defined values based on
- the passed in configuration table. This table maps strings to values to
- set along with the type of each of these values.
-
-PARAMETERS:
- conf_file_name: configuration file to read
- config_table: table definition of strings to places to store information
- table_length: length of the configuration table
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-===========================================================================*/
-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;
-
- if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
- {
- LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
- }
- else
- {
- LOC_LOGW("%s: no %s file found", __FUNCTION__, conf_file_name);
- loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
- return; /* no parameter file */
- }
-
- /* Clear all validity bits */
- for(i = 0; NULL != config_table && i < table_length; i++)
- {
- if(NULL != config_table[i].param_set)
- {
- *(config_table[i].param_set) = 0;
- }
- }
-
- while(fgets(input_buf, LOC_MAX_PARAM_LINE, gps_conf_fp) != NULL)
- {
- memset(&config_value, 0, sizeof(config_value));
-
- /* Separate variable and value */
- config_value.param_name = strtok_r(input_buf, "=", &lasts);
- if (config_value.param_name == NULL) continue; /* skip lines that do not contain "=" */
- config_value.param_str_value = strtok_r(NULL, "=", &lasts);
- if (config_value.param_str_value == NULL) continue; /* skip lines that do not contain two operands */
-
- /* Trim leading and trailing spaces */
- trim_space(config_value.param_name);
- trim_space(config_value.param_str_value);
-
- /* Parse numerical value */
- if (config_value.param_str_value[0] == '0' && tolower(config_value.param_str_value[1]) == 'x')
- {
- /* hex */
- config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], (char**) NULL, 16);
- }
- else {
- config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
- config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
- }
-
- for(i = 0; NULL != config_table && i < table_length; i++)
- {
- loc_set_config_entry(&config_table[i], &config_value);
- }
-
- for(i = 0; i < loc_param_num; i++)
- {
- loc_set_config_entry(&loc_parameter_table[i], &config_value);
- }
- }
-
- fclose(gps_conf_fp);
-
- /* 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
deleted file mode 100644
index df83338..0000000
--- a/gps/utils/loc_cfg.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation, nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef LOC_CFG_H
-#define LOC_CFG_H
-
-#include <stdint.h>
-
-#define LOC_MAX_PARAM_NAME 48
-#define LOC_MAX_PARAM_STRING 80
-#define LOC_MAX_PARAM_LINE 80
-
-#define UTIL_READ_CONF_DEFAULT(filename) \
- loc_read_conf((filename), NULL, 0);
-
-#define UTIL_READ_CONF(filename, config_table) \
- loc_read_conf((filename), (config_table), sizeof(config_table) / sizeof(config_table[0]))
-
-/*=============================================================================
- *
- * MODULE TYPE DECLARATION
- *
- *============================================================================*/
-typedef struct
-{
- char param_name[LOC_MAX_PARAM_NAME];
- void *param_ptr;
- uint8_t *param_set; /* was this value set by config file? */
- char param_type; /* 'n' for number,
- 's' for string,
- 'f' for float */
-} loc_param_s_type;
-
-/*=============================================================================
- *
- * MODULE EXTERNAL DATA
- *
- *============================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*=============================================================================
- *
- * MODULE EXPORTED FUNCTIONS
- *
- *============================================================================*/
-extern void loc_read_conf(const char* conf_file_name,
- loc_param_s_type* config_table,
- uint32_t table_length);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LOC_CFG_H */
diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp
deleted file mode 100644
index 597b5b6..0000000
--- a/gps/utils/loc_log.cpp
+++ /dev/null
@@ -1,234 +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
-
-#include <stdio.h>
-#include <stdlib.h>
-#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"};
-const char VOID_RET[] = "None";
-const char FROM_AFW[] = "===>";
-const char TO_MODEM[] = "--->";
-const char FROM_MODEM[] = "<---";
-const char TO_AFW[] = "<===";
-const char EXIT_TAG[] = "Exiting";
-const char ENTRY_TAG[] = "Entering";
-
-/* Logging Mechanism */
-loc_logger_s_type loc_logger;
-
-/* Get names from value */
-const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask)
-{
- int i;
- for (i = 0; i < table_size; i++)
- {
- if (table[i].val & (long) mask)
- {
- return table[i].name;
- }
- }
- return UNKNOWN_STR;
-}
-
-/* Get names from value */
-const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value)
-{
- int i;
- for (i = 0; i < table_size; i++)
- {
- if (table[i].val == (long) value)
- {
- return table[i].name;
- }
- }
- return UNKNOWN_STR;
-}
-
-static loc_name_val_s_type loc_msg_q_status[] =
-{
- NAME_VAL( eMSG_Q_SUCCESS ),
- NAME_VAL( eMSG_Q_FAILURE_GENERAL ),
- NAME_VAL( eMSG_Q_INVALID_PARAMETER ),
- NAME_VAL( eMSG_Q_INVALID_HANDLE ),
- NAME_VAL( eMSG_Q_UNAVAILABLE_RESOURCE ),
- NAME_VAL( eMSG_Q_INSUFFICIENT_BUFFER )
-};
-static int loc_msg_q_status_num = sizeof(loc_msg_q_status) / sizeof(loc_name_val_s_type);
-
-/* Find msg_q status name */
-const char* loc_get_msg_q_status(int status)
-{
- return loc_get_name_from_val(loc_msg_q_status, loc_msg_q_status_num, (long) status);
-}
-
-const char* log_succ_fail_string(int is_succ)
-{
- return is_succ? "successful" : "failed";
-}
-
-//Target names
-loc_name_val_s_type target_name[] =
-{
- NAME_VAL(GNSS_NONE),
- NAME_VAL(GNSS_MSM),
- NAME_VAL(GNSS_GSS),
- NAME_VAL(GNSS_MDM),
- NAME_VAL(GNSS_QCA1530),
- NAME_VAL(GNSS_UNKNOWN)
-};
-
-static int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type);
-
-/*===========================================================================
-
-FUNCTION loc_get_target_name
-
-DESCRIPTION
- Returns pointer to a string that contains name of the target
-
- XX:XX:XX.000\0
-
-RETURN VALUE
- The target name string
-
-===========================================================================*/
-const char *loc_get_target_name(unsigned int 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
-
-DESCRIPTION
- Logs a callback event header.
- The pointer time_string should point to a buffer of at least 13 bytes:
-
- XX:XX:XX.000\0
-
-RETURN VALUE
- The time string
-
-===========================================================================*/
-char *loc_get_time(char *time_string, unsigned long buf_size)
-{
- struct timeval now; /* sec and usec */
- struct tm now_tm; /* broken-down time */
- char hms_string[80]; /* HH:MM:SS */
-
- gettimeofday(&now, NULL);
- localtime_r(&now.tv_sec, &now_tm);
-
- strftime(hms_string, sizeof hms_string, "%H:%M:%S", &now_tm);
- snprintf(time_string, buf_size, "%s.%03d", hms_string, (int) (now.tv_usec / 1000));
-
- return time_string;
-}
-
-
-/*===========================================================================
-FUNCTION loc_logger_init
-
-DESCRIPTION
- Initializes the state of DEBUG_LEVEL and TIMESTAMP
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- None
-
-SIDE EFFECTS
- N/A
-===========================================================================*/
-void loc_logger_init(unsigned long debug, unsigned long timestamp)
-{
- loc_logger.DEBUG_LEVEL = debug;
- loc_logger.TIMESTAMP = timestamp;
-}
-
-
-/*===========================================================================
-FUNCTION get_timestamp
-
-DESCRIPTION
- Generates a timestamp using the current system time
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Char pointer to the parameter str
-
-SIDE EFFECTS
- N/A
-===========================================================================*/
-char * get_timestamp(char *str, unsigned long buf_size)
-{
- 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;
- snprintf(str, buf_size, "%02d:%02d:%02d.%06ld", hh, mm, ss, tv.tv_usec);
- return str;
-}
-
diff --git a/gps/utils/loc_log.h b/gps/utils/loc_log.h
deleted file mode 100644
index 82dc636..0000000
--- a/gps/utils/loc_log.h
+++ /dev/null
@@ -1,68 +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_LOG_H
-#define LOC_LOG_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <ctype.h>
-#include "loc_target.h"
-
-typedef struct
-{
- char name[128];
- long val;
-} loc_name_val_s_type;
-
-#define NAME_VAL(x) {"" #x "", x }
-
-#define UNKNOWN_STR "UNKNOWN"
-
-#define CHECK_MASK(type, value, mask_var, mask) \
- ((mask_var & mask) ? (type) value : (type) (-1))
-
-/* Get names from value */
-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(unsigned int target);
-
-extern const char* log_succ_fail_string(int is_succ);
-
-extern char *loc_get_time(char *time_string, unsigned long buf_size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LOC_LOG_H */
diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp
deleted file mode 100644
index 2e9ee52..0000000
--- a/gps/utils/loc_target.cpp
+++ /dev/null
@@ -1,209 +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.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <hardware/gps.h>
-#include <cutils/properties.h>
-#include "loc_target.h"
-#include "loc_log.h"
-#include "log_util.h"
-
-#define APQ8064_ID_1 "109"
-#define APQ8064_ID_2 "153"
-#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 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 unsigned int gTarget = (unsigned int)-1;
-
-static int read_a_line(const char * file_path, char * line, int line_size)
-{
- FILE *fp;
- int result = 0;
-
- * line = '\0';
- fp = fopen(file_path, "r" );
- if( fp == NULL ) {
- LOC_LOGE("open failed: %s: %s\n", file_path, strerror(errno));
- result = -1;
- } else {
- int len;
- fgets(line, line_size, fp);
- len = strlen(line);
- len = len < line_size - 1? len : line_size - 1;
- line[len] = '\0';
- LOC_LOGD("cat %s: %s", file_path, line);
- fclose(fp);
- }
- return result;
-}
-
-/*!
- * \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;
-}
-
-unsigned int loc_get_target(void)
-{
- if (gTarget != (unsigned int)-1)
- return gTarget;
-
- 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;
- }
-
- property_get("ro.baseband", 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);
- }
-
- 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
deleted file mode 100644
index 4aebb85..0000000
--- a/gps/utils/loc_target.h
+++ /dev/null
@@ -1,68 +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.
- *
- */
-#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_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC)
-#define getTargetGnssType(target) (target>>1)
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-unsigned int loc_get_target(void);
-
-/* Please remember to update 'target_name' in loc_log.cpp,
- if do any changes to this enum. */
-typedef enum {
- GNSS_NONE = 0,
- GNSS_MSM,
- GNSS_GSS,
- GNSS_MDM,
- GNSS_QCA1530,
- GNSS_UNKNOWN
-}GNSS_TARGET;
-
-typedef enum {
- NO_SSC = 0,
- HAS_SSC
-}SSC_TYPE;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*LOC_TARGET_H*/
diff --git a/gps/utils/loc_timer.c b/gps/utils/loc_timer.c
deleted file mode 100644
index 1e4008e..0000000
--- a/gps/utils/loc_timer.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* 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;
- }
-
- pthread_mutex_destroy(&t->timer_mutex);
- pthread_cond_destroy(&t->timer_cond);
-
- if(ETIMEDOUT == ret)
- t->callback_func(t->user_data, ret);
-
- 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));
- 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
deleted file mode 100644
index 0034d27..0000000
--- a/gps/utils/loc_timer.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* 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
deleted file mode 100644
index b48c507..0000000
--- a/gps/utils/log_util.h
+++ /dev/null
@@ -1,171 +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.
- *
- */
-
-#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"
-{
-#endif
-/*=============================================================================
- *
- * LOC LOGGER TYPE DECLARATION
- *
- *============================================================================*/
-/* LOC LOGGER */
-typedef struct loc_logger_s
-{
- unsigned long DEBUG_LEVEL;
- unsigned long TIMESTAMP;
-} loc_logger_s_type;
-
-/*=============================================================================
- *
- * EXTERNAL DATA
- *
- *============================================================================*/
-extern loc_logger_s_type loc_logger;
-
-// Logging Improvements
-extern const char *loc_logger_boolStr[];
-
-extern const char *boolStr[];
-extern const char VOID_RET[];
-extern const char FROM_AFW[];
-extern const char TO_MODEM[];
-extern const char FROM_MODEM[];
-extern const char TO_AFW[];
-extern const char EXIT_TAG[];
-extern const char ENTRY_TAG[];
-/*=============================================================================
- *
- * MODULE EXPORTED FUNCTIONS
- *
- *============================================================================*/
-extern void loc_logger_init(unsigned long debug, unsigned long timestamp);
-extern char* get_timestamp(char* str, unsigned long buf_size);
-
-#ifndef DEBUG_DMN_LOC_API
-
-/* LOGGING MACROS */
-/*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 LOC_LOGE(...) \
-if ((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/" __VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("W/" __VA_ARGS__); }
-
-#define LOC_LOGW(...) \
-if ((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/" __VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/" __VA_ARGS__); }
-
-#define LOC_LOGI(...) \
-if ((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("I/" __VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/" __VA_ARGS__); }
-
-#define LOC_LOGD(...) \
-if ((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("D/" __VA_ARGS__); } \
-else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/" __VA_ARGS__); }
-
-#define LOC_LOGV(...) \
-if ((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) { 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_LOGW(...) ALOGW("W/" __VA_ARGS__)
-
-#define LOC_LOGI(...) ALOGI("I/" __VA_ARGS__)
-
-#define LOC_LOGD(...) ALOGD("D/" __VA_ARGS__)
-
-#define LOC_LOGV(...) ALOGV("V/" __VA_ARGS__)
-
-#endif /* DEBUG_DMN_LOC_API */
-
-/*=============================================================================
- *
- * LOGGING IMPROVEMENT MACROS
- *
- *============================================================================*/
-#define LOG_(LOC_LOG, ID, WHAT, SPEC, VAL) \
- do { \
- if (loc_logger.TIMESTAMP) { \
- char ts[32]; \
- LOC_LOG("[%s] %s %s line %d " #SPEC, \
- get_timestamp(ts, sizeof(ts)), ID, WHAT, __LINE__, VAL); \
- } else { \
- LOC_LOG("%s %s line %d " #SPEC, \
- ID, WHAT, __LINE__, VAL); \
- } \
- } while(0)
-
-
-#define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL)
-#define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL)
-
-#define ENTRY_LOG() LOG_V(ENTRY_TAG, __func__, %s, "")
-#define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __func__, SPEC, VAL)
-
-
-// Used for logging callflow from Android Framework
-#define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __func__, %s, "")
-// Used for logging callflow to Modem
-#define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __func__, SPEC, VAL)
-// Used for logging callflow from Modem(TO_MODEM, __func__, %s, "")
-#define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __func__, SPEC, VAL)
-// Used for logging callflow to Android Framework
-#define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __LOG_UTIL_H__
diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c
deleted file mode 100644
index f82d4c0..0000000
--- a/gps/utils/msg_q.c
+++ /dev/null
@@ -1,336 +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.
- */
-
-#include "msg_q.h"
-
-#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>
-#include <pthread.h>
-
-typedef struct msg_q {
- void* msg_list; /* Linked list to store information */
- pthread_cond_t list_cond; /* Condition variable for waiting on msg queue */
- pthread_mutex_t list_mutex; /* Mutex for exclusive access to message queue */
- int unblocked; /* Has this message queue been unblocked? */
-} msg_q;
-
-/*===========================================================================
-FUNCTION convert_linked_list_err_type
-
-DESCRIPTION
- Converts from one set of enum values to another.
-
- linked_list_val: Value to convert to msg_q_enum_type
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Corresponding linked_list_enum_type in msg_q_enum_type
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-static msq_q_err_type convert_linked_list_err_type(linked_list_err_type linked_list_val)
-{
- switch( linked_list_val )
- {
- case eLINKED_LIST_SUCCESS:
- return eMSG_Q_SUCCESS;
- case eLINKED_LIST_INVALID_PARAMETER:
- return eMSG_Q_INVALID_PARAMETER;
- case eLINKED_LIST_INVALID_HANDLE:
- return eMSG_Q_INVALID_HANDLE;
- case eLINKED_LIST_UNAVAILABLE_RESOURCE:
- return eMSG_Q_UNAVAILABLE_RESOURCE;
- case eLINKED_LIST_INSUFFICIENT_BUFFER:
- return eMSG_Q_INSUFFICIENT_BUFFER;
-
- case eLINKED_LIST_FAILURE_GENERAL:
- default:
- return eMSG_Q_FAILURE_GENERAL;
- }
-}
-
-/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */
-
-/*===========================================================================
-
- FUNCTION: msg_q_init
-
- ===========================================================================*/
-msq_q_err_type msg_q_init(void** msg_q_data)
-{
- if( msg_q_data == NULL )
- {
- LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_PARAMETER;
- }
-
- msg_q* tmp_msg_q;
- tmp_msg_q = (msg_q*)calloc(1, sizeof(msg_q));
- if( tmp_msg_q == NULL )
- {
- LOC_LOGE("%s: Unable to allocate space for message queue!\n", __FUNCTION__);
- return eMSG_Q_FAILURE_GENERAL;
- }
-
- if( linked_list_init(&tmp_msg_q->msg_list) != 0 )
- {
- LOC_LOGE("%s: Unable to initialize storage list!\n", __FUNCTION__);
- free(tmp_msg_q);
- return eMSG_Q_FAILURE_GENERAL;
- }
-
- if( pthread_mutex_init(&tmp_msg_q->list_mutex, NULL) != 0 )
- {
- LOC_LOGE("%s: Unable to initialize list mutex!\n", __FUNCTION__);
- linked_list_destroy(&tmp_msg_q->msg_list);
- free(tmp_msg_q);
- return eMSG_Q_FAILURE_GENERAL;
- }
-
- if( pthread_cond_init(&tmp_msg_q->list_cond, NULL) != 0 )
- {
- LOC_LOGE("%s: Unable to initialize msg q cond var!\n", __FUNCTION__);
- linked_list_destroy(&tmp_msg_q->msg_list);
- pthread_mutex_destroy(&tmp_msg_q->list_mutex);
- free(tmp_msg_q);
- return eMSG_Q_FAILURE_GENERAL;
- }
-
- tmp_msg_q->unblocked = 0;
-
- *msg_q_data = tmp_msg_q;
-
- return eMSG_Q_SUCCESS;
-}
-
-/*===========================================================================
-
- 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
-
- ===========================================================================*/
-msq_q_err_type msg_q_destroy(void** msg_q_data)
-{
- if( msg_q_data == NULL )
- {
- LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_HANDLE;
- }
-
- msg_q* p_msg_q = (msg_q*)*msg_q_data;
-
- linked_list_destroy(&p_msg_q->msg_list);
- pthread_mutex_destroy(&p_msg_q->list_mutex);
- pthread_cond_destroy(&p_msg_q->list_cond);
-
- p_msg_q->unblocked = 0;
-
- free(*msg_q_data);
- *msg_q_data = NULL;
-
- return eMSG_Q_SUCCESS;
-}
-
-/*===========================================================================
-
- FUNCTION: msg_q_snd
-
- ===========================================================================*/
-msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*))
-{
- msq_q_err_type rv;
- if( msg_q_data == NULL )
- {
- LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_HANDLE;
- }
- if( msg_obj == NULL )
- {
- LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_PARAMETER;
- }
-
- msg_q* p_msg_q = (msg_q*)msg_q_data;
-
- pthread_mutex_lock(&p_msg_q->list_mutex);
- LOC_LOGD("%s: Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj);
-
- if( p_msg_q->unblocked )
- {
- LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
- pthread_mutex_unlock(&p_msg_q->list_mutex);
- return eMSG_Q_UNAVAILABLE_RESOURCE;
- }
-
- rv = convert_linked_list_err_type(linked_list_add(p_msg_q->msg_list, msg_obj, dealloc));
-
- /* Show data is in the message queue. */
- pthread_cond_signal(&p_msg_q->list_cond);
-
- pthread_mutex_unlock(&p_msg_q->list_mutex);
-
- LOC_LOGD("%s: Finished Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj);
-
- return rv;
-}
-
-/*===========================================================================
-
- FUNCTION: msg_q_rcv
-
- ===========================================================================*/
-msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj)
-{
- msq_q_err_type rv;
- if( msg_q_data == NULL )
- {
- LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_HANDLE;
- }
-
- if( msg_obj == NULL )
- {
- LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_PARAMETER;
- }
-
- msg_q* p_msg_q = (msg_q*)msg_q_data;
-
- LOC_LOGD("%s: Waiting on message\n", __FUNCTION__);
-
- pthread_mutex_lock(&p_msg_q->list_mutex);
-
- if( p_msg_q->unblocked )
- {
- LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
- pthread_mutex_unlock(&p_msg_q->list_mutex);
- return eMSG_Q_UNAVAILABLE_RESOURCE;
- }
-
- /* Wait for data in the message queue */
- while( linked_list_empty(p_msg_q->msg_list) && !p_msg_q->unblocked )
- {
- pthread_cond_wait(&p_msg_q->list_cond, &p_msg_q->list_mutex);
- }
-
- rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj));
-
- pthread_mutex_unlock(&p_msg_q->list_mutex);
-
- LOC_LOGD("%s: Received message 0x%08X rv = %d\n", __FUNCTION__, *msg_obj, rv);
-
- return rv;
-}
-
-/*===========================================================================
-
- FUNCTION: msg_q_flush
-
- ===========================================================================*/
-msq_q_err_type msg_q_flush(void* msg_q_data)
-{
- msq_q_err_type rv;
- if ( msg_q_data == NULL )
- {
- LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_HANDLE;
- }
-
- msg_q* p_msg_q = (msg_q*)msg_q_data;
-
- LOC_LOGD("%s: Flushing Message Queue\n", __FUNCTION__);
-
- pthread_mutex_lock(&p_msg_q->list_mutex);
-
- /* Remove all elements from the list */
- rv = convert_linked_list_err_type(linked_list_flush(p_msg_q->msg_list));
-
- pthread_mutex_unlock(&p_msg_q->list_mutex);
-
- LOC_LOGD("%s: Message Queue flushed\n", __FUNCTION__);
-
- return rv;
-}
-
-/*===========================================================================
-
- FUNCTION: msg_q_unblock
-
- ===========================================================================*/
-msq_q_err_type msg_q_unblock(void* msg_q_data)
-{
- if ( msg_q_data == NULL )
- {
- LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
- return eMSG_Q_INVALID_HANDLE;
- }
-
- msg_q* p_msg_q = (msg_q*)msg_q_data;
- pthread_mutex_lock(&p_msg_q->list_mutex);
-
- if( p_msg_q->unblocked )
- {
- LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
- pthread_mutex_unlock(&p_msg_q->list_mutex);
- return eMSG_Q_UNAVAILABLE_RESOURCE;
- }
-
- LOC_LOGD("%s: Unblocking Message Queue\n", __FUNCTION__);
- /* Unblocking message queue */
- p_msg_q->unblocked = 1;
-
- /* Allow all the waiters to wake up */
- pthread_cond_broadcast(&p_msg_q->list_cond);
-
- pthread_mutex_unlock(&p_msg_q->list_mutex);
-
- LOC_LOGD("%s: Message Queue unblocked\n", __FUNCTION__);
-
- return eMSG_Q_SUCCESS;
-}
diff --git a/gps/utils/msg_q.h b/gps/utils/msg_q.h
deleted file mode 100644
index 453b8ce..0000000
--- a/gps/utils/msg_q.h
+++ /dev/null
@@ -1,207 +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.
- */
-
-#ifndef __MSG_Q_H__
-#define __MSG_Q_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include <stdlib.h>
-
-/** Linked List Return Codes */
-typedef enum
-{
- eMSG_Q_SUCCESS = 0,
- /**< Request was successful. */
- eMSG_Q_FAILURE_GENERAL = -1,
- /**< Failed because of a general failure. */
- eMSG_Q_INVALID_PARAMETER = -2,
- /**< Failed because the request contained invalid parameters. */
- eMSG_Q_INVALID_HANDLE = -3,
- /**< Failed because an invalid handle was specified. */
- eMSG_Q_UNAVAILABLE_RESOURCE = -4,
- /**< Failed because an there were not enough resources. */
- eMSG_Q_INSUFFICIENT_BUFFER = -5,
- /**< Failed because an the supplied buffer was too small. */
-}msq_q_err_type;
-
-/*===========================================================================
-FUNCTION msg_q_init
-
-DESCRIPTION
- Initializes internal structures for message queue.
-
- msg_q_data: pointer to an opaque Q handle to be returned; NULL if fails
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-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
- Releases internal structures for message queue.
-
- msg_q_data: State of message queue to be released.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-msq_q_err_type msg_q_destroy(void** msg_q_data);
-
-/*===========================================================================
-FUNCTION msg_q_snd
-
-DESCRIPTION
- Sends data to the message queue. The passed in data pointer
- is not modified or freed. Passed in msg_obj is expected to live throughout
- the use of the msg_q (i.e. data is not allocated internally)
-
- msg_q_data: Message Queue to add the element to.
- msgp: Pointer to data to add into message queue.
- dealloc: Function used to deallocate memory for this element. Pass NULL
- if you do not want data deallocated during a flush operation
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*));
-
-/*===========================================================================
-FUNCTION msg_q_rcv
-
-DESCRIPTION
- Retrieves data from the message queue. msg_obj is the oldest message received
- and pointer is simply removed from message queue.
-
- msg_q_data: Message Queue to copy data from into msgp.
- msg_obj: Pointer to space to copy msg_q contents to.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj);
-
-/*===========================================================================
-FUNCTION msg_q_flush
-
-DESCRIPTION
- Function removes all elements from the message queue.
-
- msg_q_data: Message Queue to remove elements from.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-msq_q_err_type msg_q_flush(void* msg_q_data);
-
-/*===========================================================================
-FUNCTION msg_q_unblock
-
-DESCRIPTION
- This function will stop use of the message queue. All waiters will wake up
- and likely receive nothing from the queue resulting in a negative return
- value. The message queue can no longer be used until it is destroyed
- and initialized again after calling this function.
-
- msg_q_data: Message queue to unblock.
-
-DEPENDENCIES
- N/A
-
-RETURN VALUE
- Look at error codes above.
-
-SIDE EFFECTS
- N/A
-
-===========================================================================*/
-msq_q_err_type msg_q_unblock(void* msg_q_data);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MSG_Q_H__ */