hardware/qcom/gps: Porting HAL and Loc API 2.0

- Wrote makefiles, config and other files
- Made code changes to minimize android dependencies

Change-Id: I350de6378684f5db81a36cc4c6d014c5a8189d4c
This commit is contained in:
Satheesh Jayakumar 2013-05-07 09:25:21 -07:00
parent 18875a4f8a
commit 0590a64deb
36 changed files with 633 additions and 21 deletions

10
Makefile.am Normal file
View file

@ -0,0 +1,10 @@
# Makefile.am - Automake script for gps loc_api
#
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = utils loc_api/libloc_api_50001 loc_api/loc_api_v02
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = loc-api.pc
EXTRA_DIST = $(pkgconfig_DATA)

85
configure.ac Normal file
View file

@ -0,0 +1,85 @@
# configure.ac -- Autoconf script for gps loc_api
#
# Process this file with autoconf to produce a configure script
# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the gps loc_api package version 1.0.0
AC_INIT([loc-api],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
# Disables auto rebuilding of configure, Makefile.ins
AM_MAINTAINER_MODE
# Verifies the --srcdir is correct by checking for the path
AC_CONFIG_SRCDIR([utils/loc_cfg.cpp])
# defines some macros variable to be included by source
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_MODULES([QMIF], [qmi-framework])
AC_SUBST([QMIF_CFLAGS])
AC_SUBST([QMIF_LIBS])
AC_ARG_WITH([libhardware_includes],
AC_HELP_STRING([--with-libhardware-includes=@<:@dir@:>@],
[Specify the location of the libhardware headers]),
[libhardware_incdir=$withval],
with_libhardware_includes=no)
if test "x$with_libhardware_includes" != "xno"; then
CPPFLAGS="${CPPFLAGS} -I${libhardware_incdir}"
fi
AC_ARG_WITH([core_includes],
AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
[Specify the location of the core headers]),
[core_incdir=$withval],
with_core_includes=no)
if test "x$with_core_includes" != "xno"; then
CPPFLAGS="${CPPFLAGS} -I${core_incdir}"
fi
AC_SUBST([CPPFLAGS])
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, building HLOS systems which use glib]))
if (test "x${with_glib}" = "xyes"); then
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GThread >= 2.16 is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GLib >= 2.16 is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
utils/Makefile \
loc_api/libloc_api_50001/Makefile \
loc_api/loc_api_v02/Makefile \
loc-api.pc \
])
AC_OUTPUT

10
loc-api.pc.in Normal file
View file

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: loc-api
Description: Qualcomm GPS Location API
Version: @VERSION@
Libs: -L${libdir} -lgps_utils_so -lloc_adapter_so -lloc_eng_so -lgps_default_so -lloc_api
Cflags: -I${includedir}/loc-api/libloc_api_50001 -I${includedir}/loc-api/utils -I${includedir}/

View file

@ -0,0 +1,46 @@
AM_CFLAGS = \
-I../../../utils \
-I../../../platform_lib_abstractions \
-I./rpc_inc \
-I../libloc_api-rpc-stub/inc \
-I../../libloc_api_50001 \
$(MSM7K_CFLAGS) \
-DUSE_QCOM_AUTO_RPC
requiredlibs = \
../../../utils/libgps_utils_so.la \
$(MSM7K_LIBS)
h_sources = \
rpc_inc/loc_api_rpc_glue.h \
rpc_inc/loc_api_fixup.h \
rpc_inc/loc_api_sync_call.h \
rpc_inc/loc_apicb_appinit.h \
c_sources = \
src/loc_api_rpc_glue.c \
src/loc_api_sync_call.c \
src/loc_apicb_appinit.c \
src/loc_api_fixup.c \
src/loc_api_log.c \
src/LocApiRpcAdapter.cpp \
library_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc
library_include_HEADERS = $(h_sources)
libloc_api_rpc_qc_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_rpc_qc_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_rpc_qc_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_rpc_qc_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_rpc_qc_la_CFLAGS = $(AM_CFLAGS)
libloc_api_rpc_qc_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_api_rpc_qc_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_rpc_qc_la_LIBADD = $(requiredlibs) -lstdc++
#Create and Install Libraries
lib_LTLIBRARIES = libloc_api_rpc_qc.la

View file

@ -48,8 +48,8 @@ typedef unsigned char boolean;
#define TRUE 1
#define FALSE 0
#include "rpc_inc/loc_api_fixup.h"
#include "rpc_inc/loc_api_sync_call.h"
#include "loc_api_fixup.h"
#include "loc_api_sync_call.h"
#include <rpc/clnt.h>
#ifdef __cplusplus

View file

@ -31,12 +31,20 @@
#include <unistd.h>
#include <math.h>
#ifndef USE_GLIB
#include <utils/SystemClock.h>
#endif /* USE_GLIB */
#include "LocApiRpcAdapter.h"
#include "loc_api_rpcgen_common_rpc.h"
#include "log_util.h"
#include "loc_log.h"
#include "loc_api_log.h"
#ifdef USE_GLIB
#include <glib.h>
#endif
#include "librpc.h"
#include "platform_lib_includes.h"
#define LOC_XTRA_INJECT_DEFAULT_TIMEOUT (3100)
#define XTRA_BLOCK_SIZE (3072)
@ -390,7 +398,7 @@ LocApiRpcAdapter::setTime(GpsUtcTime time, int64_t timeReference, int uncertaint
time_info_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.assistance_data_time;
time_info_ptr->time_utc = time;
time_info_ptr->time_utc += (int64_t)(android::elapsedRealtime() - timeReference);
time_info_ptr->time_utc += (int64_t)(ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION - timeReference);
time_info_ptr->uncertainty = uncertainty; // Uncertainty in ms
ioctl_data.disc = ioctl_type;

View file

@ -33,6 +33,7 @@
#include "loc_api_log.h"
#include "loc_log.h"
#include "log_util.h"
#include "platform_lib_includes.h"
#include "rpc/rpc.h"
#include "loc_api_fixup.h"

View file

@ -57,11 +57,13 @@
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
#define LOG_NDDEBUG 0
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
/* Logging Improvement */
#include "log_util.h"
#include "platform_lib_includes.h"
/*Maximum number of Modem init*/
#define RPC_TRY_NUM 10

View file

@ -40,7 +40,9 @@
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
// #define LOG_NDDEBUG 0
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
/***************************************************************************
* DATA FOR ASYNCHRONOUS RPC PROCESSING

View file

@ -0,0 +1,42 @@
AM_CFLAGS = \
-I../../../utils \
-I./inc \
$(MSM7K_CFLAGS)
requiredlibs = \
../../../utils/libgps_utils_so.la \
$(MSM7K_LIBS)
h_sources = \
inc/loc_api_rpcgen_rpc.h \
inc/loc_api_rpcgen_common_rpc.h \
inc/loc_api_rpcgen_cb_rpc.h \
inc/loc_apicb_appinit.h
c_sources = \
src/loc_api_rpcgen_cb_xdr.c \
src/loc_api_rpcgen_common_xdr.c \
src/loc_api_rpcgen_cb_svc.c \
src/loc_api_rpcgen_clnt.c \
src/loc_api_rpcgen_xdr.c
library_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-stub/inc
library_include_HEADERS = $(h_sources)
libloc_api_rpcgen_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_rpcgen_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_rpcgen_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_rpcgen_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_rpcgen_la_CFLAGS = $(AM_CFLAGS)
libloc_api_rpcgen_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_api_rpcgen_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_rpcgen_la_LIBADD = $(requiredlibs) -lstdc++
#Create and Install Libraries
lib_LTLIBRARIES = libloc_api_rpcgen.la

View file

@ -35,6 +35,7 @@
#include <loc_eng_log.h>
#include <log_util.h>
#include <loc_eng_msg.h>
#include "platform_lib_includes.h"
#define MAX_APN_LEN 100
#define MAX_URL_LEN 256

View file

@ -0,0 +1,79 @@
AM_CFLAGS = \
-I../../utils \
-I../../platform_lib_abstractions \
-I../ulp/inc \
-fno-short-enums \
-DFEATURE_GNSS_BIT_API
libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocApiAdapter.cpp
if USE_GLIB
libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS)
libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la
libloc_eng_so_la_SOURCES = \
loc_eng.cpp \
loc_eng_agps.cpp \
loc_eng_xtra.cpp \
loc_eng_ni.cpp \
loc_eng_log.cpp \
loc_eng_dmn_conn.cpp \
loc_eng_dmn_conn_handler.cpp \
loc_eng_dmn_conn_thread_helper.c \
loc_eng_dmn_conn_glue_msg.c \
loc_eng_dmn_conn_glue_pipe.c
if USE_GLIB
libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_eng_so_la_CFLAGS = $(AM_CFLAGS)
libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la
libgps_default_so_la_SOURCES = \
loc.cpp \
gps.c
if USE_GLIB
libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libgps_default_so_la_CFLAGS = $(AM_CFLAGS)
libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la
library_include_HEADERS = \
LocApiAdapter.h \
loc.h \
loc_eng.h \
loc_eng_xtra.h \
loc_eng_ni.h \
loc_eng_agps.h \
loc_eng_msg.h \
loc_eng_msg_id.h \
loc_eng_log.h \
../ulp/inc/ulp.h
library_includedir = $(pkgincludedir)/libloc_api_50001
#Create and Install libraries
lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la

View file

@ -47,8 +47,16 @@
#include "LocApiAdapter.h"
#include <cutils/sched_policy.h>
#ifndef USE_GLIB
#include <utils/SystemClock.h>
#include <utils/Log.h>
#endif /* USE_GLIB */
#ifdef USE_GLIB
#include <glib.h>
#include <sys/syscall.h>
#endif /* USE_GLIB */
#include <string.h>
#include <loc_eng.h>
@ -61,6 +69,7 @@
#include <msg_q.h>
#include <loc.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_log.h"
#define SUCCESS TRUE
@ -170,7 +179,7 @@ LocEngContext::LocEngContext(gps_create_thread threadCreator) :
counter(0)
{
LOC_LOGV("LocEngContext %d : %d pthread_id %ld\n",
getpid(), gettid(),
getpid(), GETTID_PLATFORM_LIB_ABSTRACTION,
deferred_action_thread);
}
@ -1418,6 +1427,29 @@ void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data)
EXIT_LOG(%s, VOID_RET);
}
#ifdef USE_GLIB
/*===========================================================================
FUNCTION set_sched_policy
DESCRIPTION
Local copy of this function which bypasses android set_sched_policy
DEPENDENCIES
None
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int set_sched_policy(int tid, SchedPolicy policy)
{
return 0;
}
#endif /* USE_GLIB */
/*===========================================================================
FUNCTION loc_eng_deferred_action_thread
@ -1442,7 +1474,7 @@ static void loc_eng_deferred_action_thread(void* arg)
LocEngContext* context = (LocEngContext*)arg;
// make sure we do not run in background scheduling group
set_sched_policy(gettid(), SP_FOREGROUND);
set_sched_policy(GETTID_PLATFORM_LIB_ABSTRACTION, SP_FOREGROUND);
while (1)
{

View file

@ -95,7 +95,7 @@ private:
};
// Module data
typedef struct
typedef struct loc_eng_data_s
{
LocApiAdapter *client_handle;
loc_location_cb_ext location_cb;

View file

@ -33,6 +33,7 @@
#include <loc_eng_agps.h>
#include <loc_eng_log.h>
#include <log_util.h>
#include "platform_lib_includes.h"
#include <loc_eng_dmn_conn_handler.h>
#include <loc_eng_dmn_conn.h>
#include<sys/time.h>

View file

@ -38,7 +38,7 @@
#include <sys/stat.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
#include "loc_eng_dmn_conn.h"

View file

@ -32,7 +32,7 @@
#include <linux/types.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"

View file

@ -38,7 +38,7 @@
#include "loc_eng_dmn_conn_glue_pipe.h"
#include "log_util.h"
#include "platform_lib_includes.h"
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipeget

View file

@ -32,6 +32,7 @@
#include <unistd.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_msg.h"
#include "loc_eng_dmn_conn.h"
#include "loc_eng_dmn_conn_handler.h"

View file

@ -29,6 +29,7 @@
#include <stdio.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_thread_helper.h"
/*===========================================================================

View file

@ -42,6 +42,12 @@
#ifndef SSID_BUF_SIZE
#define SSID_BUF_SIZE (32+1)
#endif
#ifdef USE_GLIB
#include <glib.h>
#endif /* USE_GLIB */
#include "platform_lib_includes.h"
#ifdef __cplusplus
extern "C" {

View file

@ -43,7 +43,7 @@
#include <loc_eng.h>
#include "log_util.h"
#include "platform_lib_includes.h"
/*=============================================================================
*
* DATA DECLARATION

View file

@ -33,7 +33,7 @@
#include <loc_eng.h>
#include <loc_eng_msg.h>
#include "log_util.h"
#include "platform_lib_includes.h"
/*===========================================================================
FUNCTION loc_eng_xtra_init

View file

@ -37,13 +37,17 @@
#include <stdbool.h>
#include <hardware/gps.h>
#ifndef USE_GLIB
#include <utils/SystemClock.h>
#endif /* USE_GLIB */
#include "LocApiV02Adapter.h"
#include "loc_api_v02_client.h"
#include "loc_api_v02_log.h"
#include "loc_api_sync_req.h"
#include "LocApiAdapter.h"
#include "loc_util_log.h"
#include "platform_lib_includes.h"
/* Default session id ; TBD needs incrementing for each */
#define LOC_API_V02_DEF_SESSION_ID (1)
@ -419,7 +423,7 @@ enum loc_api_adapter_err LocApiV02Adapter ::
inject_time_msg.timeUtc = time;
inject_time_msg.timeUtc += (int64_t)(android::elapsedRealtime() - timeReference);
inject_time_msg.timeUtc += (int64_t)(ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION - timeReference);
inject_time_msg.timeUnc = uncertainty;

View file

@ -0,0 +1,42 @@
AM_CFLAGS = \
${QMIF_CFLAGS} \
-I../../utils \
-I../../platform_lib_abstractions \
-I../libloc_api_50001
requiredlibs = \
${QMIF_LIBS} \
../libloc_api_50001/libloc_adapter_so.la \
../../utils/libgps_utils_so.la
h_sources = LocApiV02Adapter.h \
loc_util_log.h \
location_service_v02.h \
loc_api_sync_req.h \
loc_api_v02_client.h \
loc_api_v02_log.h
c_sources = LocApiV02Adapter.cpp \
loc_api_v02_log.c \
loc_api_v02_client.c \
loc_api_sync_req.c \
location_service_v02.c
library_includedir = $(pkgincludedir)
library_include_HEADERS = $(h_sources)
libloc_api_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_la_CFLAGS = $(AM_CFLAGS)
libloc_api_la_LDFLAGS = -shared -version-info 1:0:0
libloc_api_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_la_LIBADD = $(requiredlibs) -lstdc++
lib_LTLIBRARIES = libloc_api.la

View file

@ -36,7 +36,8 @@ extern "C"
#endif
#include <hardware/gps.h>
#include "loc_eng.h"
struct loc_eng_data_s;
/** Represents the standard ulp module interface. */
typedef struct {
@ -46,7 +47,7 @@ typedef struct {
/**
* Starts the libulp module. 0: success
*/
int (*init)(loc_eng_data_s_type &loc_eng_data);
int (*init)(struct loc_eng_data_s &loc_eng_data);
}ulpInterface;

View file

@ -0,0 +1,46 @@
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <sys/time.h>
#include "platform_lib_time.h"
int64_t systemTime(int clock)
{
struct timeval t;
t.tv_sec = t.tv_usec = 0;
gettimeofday(&t, NULL);
return t.tv_sec*1000000LL + t.tv_usec;
}
int64_t elapsedMillisSinceBoot()
{
int64_t t_us = systemTime(0);
return (int64_t) t_us / 1000LL;
}

View file

@ -0,0 +1,35 @@
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PLATFORM_LIB_INCLUDES_H_
#define _PLATFORM_LIB_INCLUDES_H_
#include "platform_lib_time.h"
#include "platform_lib_macros.h"
#endif

View file

@ -0,0 +1,57 @@
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PLATFORM_LIB_MACROS_H__
#define __PLATFORM_LIB_MACROS_H__
#ifdef USE_GLIB
#define strlcat g_strlcat
#define strlcpy g_strlcpy
#define ALOGE(format, x...) printf("E/%s (%d): " format "\n", LOG_TAG, getpid(), ##x)
#define ALOGW(format, x...) printf("W/%s (%d): " format "\n", LOG_TAG, getpid(), ##x)
#define ALOGI(format, x...) printf("I/%s (%d): " format "\n", LOG_TAG, getpid(), ##x)
#define ALOGD(format, x...) printf("D/%s (%d): " format "\n", LOG_TAG, getpid(), ##x)
#define ALOGV(format, x...) printf("V/%s (%d): " format "\n", LOG_TAG, getpid(), ##x)
#define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid))
#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread
#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot())
#else
#define GETTID_PLATFORM_LIB_ABSTRACTION (gettid())
#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION android::AndroidRuntime::createJavaThread
#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (android::elapsedRealtime())
#endif
#endif

View file

@ -0,0 +1,35 @@
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PLATFORM_LIB_TIME_H_
#define _PLATFORM_LIB_TIME_H_
int64_t systemTime(int clock);
int64_t elapsedMillisSinceBoot();
#endif

44
utils/Makefile.am Normal file
View file

@ -0,0 +1,44 @@
AM_CFLAGS = -Wundef \
-MD \
-Wno-trigraphs \
-g -O0 \
-fno-inline \
-fno-short-enums \
-fpic \
-I../platform_lib_abstractions
libgps_utils_so_la_h_sources = log_util.h \
msg_q.h \
linked_list.h \
loc_cfg.h \
loc_log.h \
../platform_lib_abstractions/platform_lib_includes.h \
../platform_lib_abstractions/platform_lib_time.h \
../platform_lib_abstractions/platform_lib_macros.h
libgps_utils_so_la_c_sources = linked_list.c \
msg_q.c \
loc_cfg.cpp \
loc_log.cpp \
../platform_lib_abstractions/elapsed_millis_since_boot.cpp
library_includedir = $(pkgincludedir)/utils
library_include_HEADERS = $(libgps_utils_so_la_h_sources)
libgps_utils_so_la_SOURCES = $(libgps_utils_so_la_c_sources)
if USE_GLIB
libgps_utils_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libgps_utils_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libgps_utils_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libgps_utils_so_la_CFLAGS = $(AM_CFLAGS)
libgps_utils_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libgps_utils_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libgps_utils_so_la_LIBADD = -lstdc++ -lcutils
#Create and Install libraries
lib_LTLIBRARIES = libgps_utils_so.la

View file

@ -32,7 +32,7 @@
#define LOG_TAG "LocSvc_utils_ll"
#include "log_util.h"
#include "platform_lib_includes.h"
#include <stdlib.h>
#include <stdint.h>

View file

@ -39,6 +39,10 @@
#include <time.h>
#include <loc_cfg.h>
#include <log_util.h>
#ifdef USE_GLIB
#include <glib.h>
#endif
#include "platform_lib_includes.h"
/*=============================================================================
*

View file

@ -34,8 +34,11 @@
#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"
// Logging Improvements
const char *loc_logger_boolStr[]={"False","True"};
const char VOID_RET[] = "None";

View file

@ -30,6 +30,23 @@
#ifndef __LOG_UTIL_H__
#define __LOG_UTIL_H__
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
#ifdef USE_GLIB
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#ifndef LOG_TAG
#define LOG_TAG "GPS_UTILS"
#endif // LOG_TAG
#endif /* USE_GLIB */
#ifdef __cplusplus
extern "C"
{
@ -72,9 +89,6 @@ extern const char ENTRY_TAG[];
extern void loc_logger_init(unsigned long debug, unsigned long timestamp);
extern char* get_timestamp(char* str, unsigned long buf_size);
#include <utils/Log.h>
#ifndef DEBUG_DMN_LOC_API
/* LOGGING MACROS */

View file

@ -30,7 +30,7 @@
#define LOG_TAG "LocSvc_utils_q"
#include "log_util.h"
#include "platform_lib_includes.h"
#include "linked_list.h"
#include <stdio.h>
#include <stdlib.h>