summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDongmei Wang <dongme@codeaurora.org>2014-12-02 18:39:10 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2014-12-05 15:15:33 -0800
commit836bdc4386232b3a86d062f89f3093845d05cb29 (patch)
treeeca28ce187f928bfdaa7291bd7254d9f2c0cad76 /utils
parent42c543919b189a758445dc1fd59030e735ad30ec (diff)
downloadgps-836bdc4386232b3a86d062f89f3093845d05cb29.tar.gz
loc-pla: Create Platform Library Abstraction layer
Defined PLA functions to enable gps libraries to call platform-dependent library calls transparantly. Removed fake files and replaced the fake function with defined PLA functions. CRs-fixed: 605817 Change-Id: I677f658001329a10ef9b49bd963631a83fb4c85f
Diffstat (limited to 'utils')
-rw-r--r--utils/Makefile.am13
-rw-r--r--utils/linked_list.c5
-rw-r--r--utils/loc_cfg.cpp4
-rw-r--r--utils/loc_log.cpp60
-rw-r--r--utils/loc_target.cpp5
-rw-r--r--utils/loc_timer.h4
-rw-r--r--utils/log_util.h171
-rw-r--r--utils/msg_q.c5
8 files changed, 16 insertions, 251 deletions
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 0e7083e..5e71843 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -6,19 +6,15 @@ AM_CFLAGS = -Wundef \
-fno-short-enums \
-fpic \
-I./ \
- -I../platform_lib_abstractions
+ $(LOCPLA_CFLAGS)
libgps_utils_so_la_h_sources = \
- log_util.h \
msg_q.h \
linked_list.h \
loc_cfg.h \
loc_log.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_timer.h
libgps_utils_so_la_c_sources = \
linked_list.c \
@@ -26,8 +22,7 @@ libgps_utils_so_la_c_sources = \
loc_cfg.cpp \
loc_log.cpp \
loc_timer.c \
- loc_target.cpp \
- ../platform_lib_abstractions/platform_lib_time.cpp
+ loc_target.cpp
library_includedir = $(pkgincludedir)/utils
@@ -45,7 +40,7 @@ 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++ -llog
+libgps_utils_so_la_LIBADD = -lstdc++ -llog $(LOCPLA_LIBS)
#Create and Install libraries
lib_LTLIBRARIES = libgps_utils_so.la
diff --git a/utils/linked_list.c b/utils/linked_list.c
index 92617fe..1109acd 100644
--- a/utils/linked_list.c
+++ b/utils/linked_list.c
@@ -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
@@ -31,8 +31,7 @@
#include <string.h>
#define LOG_TAG "LocSvc_utils_ll"
-#include "log_util.h"
-#include "platform_lib_includes.h"
+#include <platform_lib_includes.h>
#include <stdlib.h>
#include <stdint.h>
diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp
index 037ffaf..8c76d1f 100644
--- a/utils/loc_cfg.cpp
+++ b/utils/loc_cfg.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -38,7 +38,7 @@
#include <unistd.h>
#include <time.h>
#include <loc_cfg.h>
-#include <log_util.h>
+#include <platform_lib_includes.h>
#if defined(USE_GLIB) && !defined(OFF_TARGET)
#include <glib.h>
#endif
diff --git a/utils/loc_log.cpp b/utils/loc_log.cpp
index 597b5b6..c64310e 100644
--- a/utils/loc_log.cpp
+++ b/utils/loc_log.cpp
@@ -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
@@ -34,11 +34,7 @@
#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"
+#include <platform_lib_includes.h>
#define BUFFER_SIZE 120
@@ -180,55 +176,3 @@ char *loc_get_time(char *time_string, unsigned long buf_size)
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/utils/loc_target.cpp b/utils/loc_target.cpp
index 5eff171..b5a6297 100644
--- a/utils/loc_target.cpp
+++ b/utils/loc_target.cpp
@@ -38,7 +38,6 @@
#include <cutils/properties.h>
#include "loc_target.h"
#include "loc_log.h"
-#include "log_util.h"
#include <platform_lib_includes.h>
#define APQ8064_ID_1 "109"
@@ -109,7 +108,7 @@ static bool is_qca1530(void)
for (i = 0; i < QCA1530_DETECT_TIMEOUT; ++i)
{
- ret = property_get(qca1530_property_name, buf, NULL);
+ ret = platform_lib_abstraction_property_get(qca1530_property_name, buf, NULL);
if (ret < 0)
{
LOC_LOGV( "qca1530: property %s is not accessible, ret=%d",
@@ -165,7 +164,7 @@ unsigned int loc_get_target(void)
goto detected;
}
- property_get("ro.baseband", baseband, "");
+ platform_lib_abstraction_property_get("ro.baseband", baseband, "");
if (!access(hw_platform, F_OK)) {
read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
} else {
diff --git a/utils/loc_timer.h b/utils/loc_timer.h
index 0034d27..5ca1586 100644
--- a/utils/loc_timer.h
+++ b/utils/loc_timer.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -34,7 +34,7 @@
extern "C" {
#endif /* __cplusplus */
#include<pthread.h>
-#include "log_util.h"
+#include <platform_lib_log_util.h>
/*
Return values:
diff --git a/utils/log_util.h b/utils/log_util.h
deleted file mode 100644
index 7fb0c78..0000000
--- a/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/utils/msg_q.c b/utils/msg_q.c
index f82d4c0..1555668 100644
--- a/utils/msg_q.c
+++ b/utils/msg_q.c
@@ -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
@@ -29,8 +29,7 @@
#include "msg_q.h"
#define LOG_TAG "LocSvc_utils_q"
-#include "log_util.h"
-#include "platform_lib_includes.h"
+#include <platform_lib_includes.h>
#include "linked_list.h"
#include <stdio.h>
#include <stdlib.h>