diff --git a/Makefile.am b/Makefile.am index f374a5c5..3b4b595b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,8 +3,8 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = utils loc_api/libloc_api_50001 loc_api/loc_api_v02 +SUBDIRS = utils core loc_api pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = loc-api.pc +pkgconfig_DATA = loc-hal.pc EXTRA_DIST = $(pkgconfig_DATA) diff --git a/configure.ac b/configure.ac index dca18a19..4ef39eed 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -# configure.ac -- Autoconf script for gps loc_api +# configure.ac -- Autoconf script for gps loc_hal # # 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) +# Initialize the gps loc-hal package version 1.0.0 +AC_INIT([loc-hal],1.0.0) # Does not strictly follow GNU Coding standards AM_INIT_AUTOMAKE([foreign]) # Disables auto rebuilding of configure, Makefile.ins @@ -29,10 +29,22 @@ AC_PROG_MAKE_SET PKG_PROG_PKG_CONFIG # Checks for libraries. +PKG_CHECK_MODULES([QMI], [qmi]) +AC_SUBST([QMI_CFLAGS]) +AC_SUBST([QMI_LIBS]) + PKG_CHECK_MODULES([QMIF], [qmi-framework]) AC_SUBST([QMIF_CFLAGS]) AC_SUBST([QMIF_LIBS]) +PKG_CHECK_MODULES([DATA], [data]) +AC_SUBST([DATA_CFLAGS]) +AC_SUBST([DATA_LIBS]) + +PKG_CHECK_MODULES([LOCPLA], [loc-pla]) +AC_SUBST([LOCPLA_CFLAGS]) +AC_SUBST([LOCPLA_LIBS]) + AC_ARG_WITH([libhardware_includes], AC_HELP_STRING([--with-libhardware-includes=@<:@dir@:>@], [Specify the location of the libhardware headers]), @@ -77,9 +89,9 @@ 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 \ + core/Makefile \ + loc_api/Makefile \ + loc-hal.pc \ ]) AC_OUTPUT diff --git a/core/Android.mk b/core/Android.mk index c6d3128d..3650fbb3 100644 --- a/core/Android.mk +++ b/core/Android.mk @@ -20,7 +20,8 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ libgps.utils \ - libdl + libdl \ + libloc_pla LOCAL_SRC_FILES += \ LocApiBase.cpp \ @@ -35,7 +36,8 @@ LOCAL_CFLAGS += \ LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ - $(TARGET_OUT_HEADERS)/libflp + $(TARGET_OUT_HEADERS)/libflp \ + $(TARGET_OUT_HEADERS)/libloc_pla LOCAL_COPY_HEADERS_TO:= libloc_core/ LOCAL_COPY_HEADERS:= \ diff --git a/core/ContextBase.cpp b/core/ContextBase.cpp index 9f6c4aab..58dc8a78 100644 --- a/core/ContextBase.cpp +++ b/core/ContextBase.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include namespace loc_core { @@ -52,6 +52,10 @@ LBSProxyBase* ContextBase::getLBSProxy(const char* libName) proxy = (*getter)(); } } + else + { + LOC_LOGW("%s:%d]: FAILED TO LOAD libname: %s\n", __func__, __LINE__, libName); + } if (NULL == proxy) { proxy = new LBSProxyBase(); } diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp index 8fdb8cbb..e9bec95c 100644 --- a/core/LocAdapterBase.cpp +++ b/core/LocAdapterBase.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include namespace loc_core { diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index dcd35fec..45d16e90 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include namespace loc_core { diff --git a/core/LocApiBase.h b/core/LocApiBase.h index 713ca916..7b80f5f0 100644 --- a/core/LocApiBase.h +++ b/core/LocApiBase.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace loc_core { class ContextBase; diff --git a/core/LocDualContext.cpp b/core/LocDualContext.cpp index 578421cd..74b2903a 100644 --- a/core/LocDualContext.cpp +++ b/core/LocDualContext.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include namespace loc_core { @@ -59,7 +59,11 @@ ContextBase* LocDualContext::mBgContext = NULL; ContextBase* LocDualContext::mInjectContext = NULL; // the name must be shorter than 15 chars const char* LocDualContext::mLocationHalName = "Loc_hal_worker"; +#ifndef USE_GLIB const char* LocDualContext::mLBSLibName = "liblbs_core.so"; +#else +const char* LocDualContext::mLBSLibName = "liblbs_core.so.1"; +#endif pthread_mutex_t LocDualContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/core/Makefile.am b/core/Makefile.am new file mode 100644 index 00000000..341153ad --- /dev/null +++ b/core/Makefile.am @@ -0,0 +1,46 @@ +AM_CFLAGS = -I./ \ + -I../utils \ + $(LOCPLA_CFLAGS) \ + -I$(WORKSPACE)/gps-noship/flp \ + -D__func__=__PRETTY_FUNCTION__ \ + -fno-short-enums + +libloc_core_la_h_sources = \ + LocApiBase.h \ + LocAdapterBase.h \ + ContextBase.h \ + LocDualContext.h \ + LBSProxyBase.h \ + UlpProxyBase.h \ + gps_extended_c.h \ + gps_extended.h \ + loc_core_log.h \ + LocAdapterProxyBase.h + +libloc_core_la_c_sources = \ + LocApiBase.cpp \ + LocAdapterBase.cpp \ + ContextBase.cpp \ + LocDualContext.cpp \ + loc_core_log.cpp + +library_includedir = $(pkgincludedir)/core + +library_include_HEADERS = $(libloc_core_la_h_sources) + +libloc_core_la_SOURCES = $(libloc_core_la_c_sources) + +if USE_GLIB +libloc_core_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libloc_core_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_core_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_core_la_CFLAGS = $(AM_CFLAGS) +libloc_core_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 +libloc_core_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +endif + +libloc_core_la_LIBADD = -lstdc++ -ldl $(LOCPLA_LIBS) ../utils/libgps_utils_so.la + +#Create and Install libraries +lib_LTLIBRARIES = libloc_core.la diff --git a/core/UlpProxyBase.h b/core/UlpProxyBase.h index 50a43fd9..98d81ddf 100644 --- a/core/UlpProxyBase.h +++ b/core/UlpProxyBase.h @@ -31,7 +31,6 @@ #include #include "fused_location_extended.h" - namespace loc_core { class LocAdapterBase; diff --git a/core/gps_extended.h b/core/gps_extended.h index 88b0415b..b6d7a41b 100644 --- a/core/gps_extended.h +++ b/core/gps_extended.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2015, 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,11 +29,19 @@ #ifndef GPS_EXTENDED_H #define GPS_EXTENDED_H +#include +/** + * @file + * @brief C++ declarations for GPS types + */ + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#include +#if defined(USE_GLIB) || defined(OFF_TARGET) +#include +#endif struct LocPosMode { @@ -48,7 +56,8 @@ struct LocPosMode uint32_t gap, uint32_t accu, uint32_t time, const char* cred, const char* prov) : mode(m), recurrence(recr), - min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap), + min_interval(gap < GPS_MIN_POSSIBLE_FIX_INTERVAL_MS ? + GPS_MIN_POSSIBLE_FIX_INTERVAL_MS : gap), preferred_accuracy(accu), preferred_time(time) { memset(credentials, 0, sizeof(credentials)); memset(provider, 0, sizeof(provider)); @@ -63,7 +72,7 @@ struct LocPosMode inline LocPosMode() : mode(LOC_POSITION_MODE_MS_BASED), recurrence(GPS_POSITION_RECURRENCE_PERIODIC), - min_interval(MIN_POSSIBLE_FIX_INTERVAL), + min_interval(GPS_DEFAULT_FIX_INTERVAL_MS), preferred_accuracy(50), preferred_time(120000) { memset(credentials, 0, sizeof(credentials)); memset(provider, 0, sizeof(provider)); diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h index 9b73fd59..5bf11f30 100644 --- a/core/gps_extended_c.h +++ b/core/gps_extended_c.h @@ -29,16 +29,21 @@ #ifndef GPS_EXTENDED_C_H #define GPS_EXTENDED_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include #include #include +/** + * @file + * @brief C++ declarations for GPS types + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + /** Location has valid source information. */ #define LOCATION_HAS_SOURCE_INFO 0x0020 /** GpsLocation has valid "is indoor?" flag */ @@ -195,7 +200,24 @@ typedef enum loc_position_mode_type { } LocPositionMode; -#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */ +/** + * @brief Minimum allowed value for fix interval. + * + * This value is a sanity limit in GPS framework. The hardware has own internal + * limits that may not match this value + * + * @sa GPS_DEFAULT_FIX_INTERVAL_MS + */ + +#define GPS_MIN_POSSIBLE_FIX_INTERVAL_MS 100 +/** + * @brief Default value for fix interval. + * + * This value is used by default whenever appropriate. + * + * @sa GPS_MIN_POSSIBLE_FIX_INTERVAL_MS + */ +#define GPS_DEFAULT_FIX_INTERVAL_MS 1000 /** Flags to indicate which values are valid in a GpsLocationExtended. */ typedef uint16_t GpsLocationExtendedFlags; diff --git a/core/loc_core_log.cpp b/core/loc_core_log.cpp index 3ca6c0a5..4556fae3 100644 --- a/core/loc_core_log.cpp +++ b/core/loc_core_log.cpp @@ -31,8 +31,8 @@ #define LOG_TAG "LocSvc_core_log" #include -#include #include +#include void LocPosMode::logv() const { diff --git a/loc-api.pc.in b/loc-api.pc.in deleted file mode 100644 index 3b4f81bf..00000000 --- a/loc-api.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -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}/ -I${includedir}/loc-api diff --git a/loc-hal.pc.in b/loc-hal.pc.in new file mode 100644 index 00000000..36cd4e7d --- /dev/null +++ b/loc-hal.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: loc-hal +Description: QTI GPS Loc HAL +Version: @VERSION +Libs: -L${libdir} -lgps_utils_so -lloc_core -lloc_eng_so -lgps_default_so -lloc_ds_api -lloc_api_v02 +Cflags: -I${includedir} -I${includedir}/loc-hal/utils -I${includedir}/loc-hal/core -I${includedir}/loc-hal diff --git a/loc_api/Makefile.am b/loc_api/Makefile.am new file mode 100644 index 00000000..a5f529bd --- /dev/null +++ b/loc_api/Makefile.am @@ -0,0 +1,133 @@ +AM_CFLAGS = \ + -I./ \ + -I../core \ + -I./libloc_api_50001 \ + -I../utils \ + $(LOCPLA_CFLAGS) \ + -fno-short-enums \ + -D__func__=__PRETTY_FUNCTION__ \ + -DTARGET_USES_QCOM_BSP + +libloc_eng_so_la_h_sources = \ + loc_eng_dmn_conn_glue_msg.h \ + loc_eng_dmn_conn_glue_pipe.h \ + loc_eng_dmn_conn.h \ + loc_eng_dmn_conn_handler.h \ + loc_eng_dmn_conn_thread_helper.h + +libloc_eng_so_la_SOURCES = \ + libloc_api_50001/loc_eng.cpp \ + libloc_api_50001/loc_eng_agps.cpp \ + libloc_api_50001/loc_eng_xtra.cpp \ + libloc_api_50001/loc_eng_ni.cpp \ + libloc_api_50001/loc_eng_log.cpp \ + libloc_api_50001/loc_eng_nmea.cpp \ + libloc_api_50001/LocEngAdapter.cpp \ + libloc_api_50001/loc_eng_dmn_conn.cpp \ + libloc_api_50001/loc_eng_dmn_conn_handler.cpp \ + libloc_api_50001/loc_eng_dmn_conn_thread_helper.c \ + libloc_api_50001/loc_eng_dmn_conn_glue_msg.c \ + libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c + +libloc_eng_so_la_SOURCES += libloc_eng_so_la_h_sources + +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++ -ldl -llog $(LOCPLA_LIBS) ../utils/libgps_utils_so.la ../core/libloc_core.la + + +libgps_default_so_la_SOURCES = \ + libloc_api_50001/loc.cpp \ + libloc_api_50001/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++ -llog $(LOCPLA_LIBS) ../utils/libgps_utils_so.la ../core/libloc_core.la -ldl libloc_eng_so.la + + +libloc_ds_api_CFLAGS = \ + $(QMIF_CFLAGS) \ + $(QMI_CFLAGS) \ + $(DATA_CFLAGS) \ + -I$(WORKSPACE)/qcom-opensource/location/loc_api/ds_api + +libloc_ds_api_la_SOURCES = \ + $(WORKSPACE)/qcom-opensource/location/loc_api/ds_api/ds_client.c + +if USE_GLIB +libloc_ds_api_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_ds_api_CFLAGS) @GLIB_CFLAGS@ +libloc_ds_api_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_ds_api_la_LDFLAGS += -Wl,--export-dynamic +libloc_ds_api_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_ds_api_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_ds_api_la_CFLAGS = $(AM_CFLAGS) $(libloc_ds_api_CFLAGS) +libloc_ds_api_la_LDFLAGS = -lstdc++ -lpthread -Wl,--export-dynamic -shared -version-info 1:0:0 +libloc_ds_api_la_LDFLAGS += -Wl,--export-dynamic +libloc_ds_api_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) $(libloc_ds_api_CFLAGS) +endif + +libloc_ds_api_la_LIBADD = -lstdc++ $(QMIF_LIBS) -lqmiservices -ldsi_netctrl $(LOCPLA_LIBS) ../utils/libgps_utils_so.la +#libloc_ds_api_la_LIBADD = -lstdc++ $(QMIF_LIBS) -lqmiservices $(LOCPLA_LIBS) ../utils/libgps_utils_so.la + +libloc_api_v02_CFLAGS = \ + $(QMIF_CFLAGS) \ + -I$(WORKSPACE)/qcom-opensource/location/loc_api/ds_api \ + -I$(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02 + +libloc_api_v02_la_SOURCES = \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/LocApiV02.cpp \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_log.c \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_client.c \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_sync_req.c \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/location_service_v02.c + +if USE_GLIB +libloc_api_v02_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_api_v02_CFLAGS) @GLIB_CFLAGS@ +libloc_api_v02_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_api_v02_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(libloc_api_v02_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_api_v02_la_CFLAGS = $(AM_CFLAGS) $(libloc_api_v02_CFLAGS) +libloc_api_v02_la_LDFLAGS = -lstdc++ -lpthread -shared -version-info 1:0:0 +libloc_api_v02_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) $(libloc_api_v02_CFLAGS) +endif + +libloc_api_v02_la_CXXFLAGS = -std=c++0x +libloc_api_v02_la_LIBADD = -lstdc++ -lqmi_cci -lqmi_common_so $(QMIF_LIBS) $(LOCPLA_LIBS) ../core/libloc_core.la ../utils/libgps_utils_so.la libloc_ds_api.la + +library_include_HEADERS = \ + libloc_api_50001/LocEngAdapter.h \ + libloc_api_50001/loc.h \ + libloc_api_50001/loc_eng.h \ + libloc_api_50001/loc_eng_xtra.h \ + libloc_api_50001/loc_eng_ni.h \ + libloc_api_50001/loc_eng_agps.h \ + libloc_api_50001/loc_eng_msg.h \ + libloc_api_50001/loc_eng_log.h \ + $(WORKSPACE)/qcom-opensource/location/loc_api/ds_api/ds_client.h \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/location_service_v02.h \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_log.h \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_v02_client.h \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_api_sync_req.h \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/LocApiV02.h \ + $(WORKSPACE)/qcom-opensource/location/loc_api/loc_api_v02/loc_util_log.h + +library_includedir = $(pkgincludedir) + +#Create and Install libraries +lib_LTLIBRARIES = libloc_eng_so.la libgps_default_so.la libloc_ds_api.la libloc_api_v02.la diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp index c7447543..850bfb5f 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #ifdef USE_GLIB diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_log.c b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_log.c index 1c482325..eb685fdf 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_log.c +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_log.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 @@ -32,7 +32,6 @@ #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" diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_rpc_glue.c b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_rpc_glue.c index e0f400cf..8c12426b 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_rpc_glue.c +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_rpc_glue.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 @@ -62,7 +62,6 @@ #endif /* USE_GLIB */ /* Logging Improvement */ -#include "log_util.h" #include "platform_lib_includes.h" /*Maximum number of Modem init*/ #define RPC_TRY_NUM 10 diff --git a/loc_api/libloc_api_50001/Android.mk b/loc_api/libloc_api_50001/Android.mk index 62905e8c..cd4888d8 100644 --- a/loc_api/libloc_api_50001/Android.mk +++ b/loc_api/libloc_api_50001/Android.mk @@ -16,7 +16,8 @@ LOCAL_SHARED_LIBRARIES := \ libdl \ liblog \ libloc_core \ - libgps.utils + libgps.utils \ + libloc_pla LOCAL_SRC_FILES += \ loc_eng.cpp \ @@ -42,7 +43,8 @@ LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ $(TARGET_OUT_HEADERS)/libloc_core \ hardware/qcom/gps/loc_api/libloc_api_50001 \ - $(TARGET_OUT_HEADERS)/libflp + $(TARGET_OUT_HEADERS)/libflp \ + $(TARGET_OUT_HEADERS)/libloc_pla LOCAL_COPY_HEADERS_TO:= libloc_eng/ LOCAL_COPY_HEADERS:= \ @@ -75,7 +77,8 @@ LOCAL_SHARED_LIBRARIES := \ libloc_eng \ libloc_core \ libgps.utils \ - libdl + libdl \ + libloc_pla ifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false) endif @@ -96,7 +99,8 @@ endif LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ $(TARGET_OUT_HEADERS)/libloc_core \ - $(TARGET_OUT_HEADERS)/libflp + $(TARGET_OUT_HEADERS)/libflp \ + $(TARGET_OUT_HEADERS)/libloc_pla LOCAL_PRELINK_MODULE := false LOCAL_MODULE_RELATIVE_PATH := hw diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h index a193e818..72b780d1 100644 --- a/loc_api/libloc_api_50001/LocEngAdapter.h +++ b/loc_api/libloc_api_50001/LocEngAdapter.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/loc_api/libloc_api_50001/Makefile.am b/loc_api/libloc_api_50001/Makefile.am index 23743570..c7624272 100644 --- a/loc_api/libloc_api_50001/Makefile.am +++ b/loc_api/libloc_api_50001/Makefile.am @@ -1,76 +1,78 @@ -AM_CFLAGS = \ - -I../../utils \ - -I../../platform_lib_abstractions \ - -fno-short-enums \ - -DFEATURE_GNSS_BIT_API - -libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocEngAdapter.cpp - -if USE_GLIB -libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ -else -libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS) -libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 -libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) -endif -libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la - - -libloc_eng_so_la_SOURCES = \ - loc_eng.cpp \ - loc_eng_agps.cpp \ - loc_eng_xtra.cpp \ - loc_eng_ni.cpp \ - loc_eng_log.cpp \ - loc_eng_dmn_conn.cpp \ - loc_eng_dmn_conn_handler.cpp \ - loc_eng_dmn_conn_thread_helper.c \ - loc_eng_dmn_conn_glue_msg.c \ - loc_eng_dmn_conn_glue_pipe.c - - -if USE_GLIB -libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ -else -libloc_eng_so_la_CFLAGS = $(AM_CFLAGS) -libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 -libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) -endif - -libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la - - -libgps_default_so_la_SOURCES = \ - loc.cpp \ - gps.c - -if USE_GLIB -libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ -libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 -libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ -else -libgps_default_so_la_CFLAGS = $(AM_CFLAGS) -libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 -libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) -endif - -libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la - -library_include_HEADERS = \ - LocEngAdapter.h \ - loc.h \ - loc_eng.h \ - loc_eng_xtra.h \ - loc_eng_ni.h \ - loc_eng_agps.h \ - loc_eng_msg.h \ - loc_eng_log.h - -library_includedir = $(pkgincludedir)/libloc_api_50001 - -#Create and Install libraries -lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la +AM_CFLAGS = \ + -I../../utils \ + -I../../platform_lib_abstractions \ + -I$(WORKSPACE)/gps-noship/flp \ + -fno-short-enums \ + -D__func__=__PRETTY_FUNCTION__ \ + -DFEATURE_GNSS_BIT_API + +libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocEngAdapter.cpp + +if USE_GLIB +libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS) +libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 +libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +endif +libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la + + +libloc_eng_so_la_SOURCES = \ + loc_eng.cpp \ + loc_eng_agps.cpp \ + loc_eng_xtra.cpp \ + loc_eng_ni.cpp \ + loc_eng_log.cpp \ + loc_eng_dmn_conn.cpp \ + loc_eng_dmn_conn_handler.cpp \ + loc_eng_dmn_conn_thread_helper.c \ + loc_eng_dmn_conn_glue_msg.c \ + loc_eng_dmn_conn_glue_pipe.c + + +if USE_GLIB +libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_eng_so_la_CFLAGS = $(AM_CFLAGS) +libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 +libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +endif + +libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la + + +libgps_default_so_la_SOURCES = \ + loc.cpp \ + gps.c + +if USE_GLIB +libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libgps_default_so_la_CFLAGS = $(AM_CFLAGS) +libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 +libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +endif + +libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la + +library_include_HEADERS = \ + LocEngAdapter.h \ + loc.h \ + loc_eng.h \ + loc_eng_xtra.h \ + loc_eng_ni.h \ + loc_eng_agps.h \ + loc_eng_msg.h \ + loc_eng_log.h + +library_includedir = $(pkgincludedir)/libloc_api_50001 + +#Create and Install libraries +lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index 505fc940..7411dc5a 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include using namespace loc_core; @@ -192,17 +192,18 @@ SIDE EFFECTS N/A ===========================================================================*/ -const GpsInterface* gps_get_hardware_interface () +extern "C" const GpsInterface* gps_get_hardware_interface () { ENTRY_LOG_CALLFLOW(); const GpsInterface* ret_val; char propBuf[PROPERTY_VALUE_MAX]; + memset(propBuf, 0, sizeof(propBuf)); loc_eng_read_config(); // check to see if GPS should be disabled - property_get("gps.disable", propBuf, ""); + platform_lib_abstraction_property_get("gps.disable", propBuf, ""); if (propBuf[0] == '1') { LOC_LOGD("gps_get_interface returning NULL because gps.disable=1\n"); @@ -613,7 +614,7 @@ const void* loc_get_extension(const char* name) else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) { char baseband[PROPERTY_VALUE_MAX]; - property_get("ro.baseband", baseband, "msm"); + platform_lib_abstraction_property_get("ro.baseband", baseband, "msm"); if (strcmp(baseband, "csfb") == 0) { ret_val = &sLocEngAGpsRilInterface; diff --git a/loc_api/libloc_api_50001/loc.h b/loc_api/libloc_api_50001/loc.h index e56fdcf8..41b968c4 100644 --- a/loc_api/libloc_api_50001/loc.h +++ b/loc_api/libloc_api_50001/loc.h @@ -35,7 +35,6 @@ extern "C" { #endif /* __cplusplus */ #include -#include #include #include diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index d2fc5bc6..552e1d1c 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -47,19 +47,8 @@ #include #include -#include -#ifndef USE_GLIB -#include -#include -#endif /* USE_GLIB */ - -#ifdef USE_GLIB -#include -#include -#endif /* USE_GLIB */ #include - #include #include #include @@ -68,8 +57,7 @@ #include #include #include -#include "log_util.h" -#include "platform_lib_includes.h" +#include #include "loc_core_log.h" #include "loc_eng_log.h" @@ -2862,29 +2850,6 @@ 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_read_config diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h index b4f2564b..c0a5fbd3 100644 --- a/loc_api/libloc_api_50001/loc_eng.h +++ b/loc_api/libloc_api_50001/loc_eng.h @@ -54,7 +54,6 @@ typedef unsigned char boolean; #include #include #include -#include #include #include diff --git a/loc_api/libloc_api_50001/loc_eng_agps.cpp b/loc_api/libloc_api_50001/loc_eng_agps.cpp index 5016b5c4..43af70fe 100644 --- a/loc_api/libloc_api_50001/loc_eng_agps.cpp +++ b/loc_api/libloc_api_50001/loc_eng_agps.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 @@ -32,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/loc_api/libloc_api_50001/loc_eng_agps.h b/loc_api/libloc_api_50001/loc_eng_agps.h index 2d689cee..8b8f9f44 100644 --- a/loc_api/libloc_api_50001/loc_eng_agps.h +++ b/loc_api/libloc_api_50001/loc_eng_agps.h @@ -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 @@ -40,6 +40,10 @@ #include #include #include +#include +#if defined(USE_GLIB) && !defined(OFF_TARGET) +#include +#endif /* USE_GLIB */ // forward declaration class AgpsStateMachine; diff --git a/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp b/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp index c257dff4..5510fc5c 100644 --- a/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp +++ b/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2012,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 @@ -37,8 +37,7 @@ #include #include -#include "log_util.h" -#include "platform_lib_includes.h" +#include #include "loc_eng_dmn_conn_glue_msg.h" #include "loc_eng_dmn_conn_handler.h" #include "loc_eng_dmn_conn.h" diff --git a/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c b/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c index a1076ff9..e947fa1d 100644 --- a/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c +++ b/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.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 -#include "log_util.h" -#include "platform_lib_includes.h" +#include #include "loc_eng_dmn_conn_glue_msg.h" #include "loc_eng_dmn_conn_handler.h" diff --git a/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c b/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c index dffcad06..cbc4ea64 100644 --- a/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c +++ b/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.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 @@ -37,8 +37,7 @@ #include #include "loc_eng_dmn_conn_glue_pipe.h" -#include "log_util.h" -#include "platform_lib_includes.h" +#include /*=========================================================================== FUNCTION loc_eng_dmn_conn_glue_pipeget @@ -110,8 +109,10 @@ SIDE EFFECTS int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd) { close(fd); - if (pipe_name) unlink(pipe_name); - LOC_LOGD("fd = %d, %s\n", fd, pipe_name); + if (pipe_name != NULL) { + unlink(pipe_name); + LOC_LOGD("fd = %d, %s\n", fd, pipe_name); + } return 0; } diff --git a/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp index edd53f21..137f686b 100644 --- a/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp +++ b/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2012,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 #include -#include "log_util.h" -#include "platform_lib_includes.h" +#include #include "loc_eng_msg.h" #include "loc_eng_dmn_conn.h" #include "loc_eng_dmn_conn_handler.h" diff --git a/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c b/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c index 9fed9d42..b30f6d7a 100644 --- a/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c +++ b/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.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 @@ -28,8 +28,7 @@ */ #include -#include "log_util.h" -#include "platform_lib_includes.h" +#include #include "loc_eng_dmn_conn_thread_helper.h" /*=========================================================================== diff --git a/loc_api/libloc_api_50001/loc_eng_msg.h b/loc_api/libloc_api_50001/loc_eng_msg.h index 9c7b9bcd..3a1a86b9 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg.h +++ b/loc_api/libloc_api_50001/loc_eng_msg.h @@ -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 @@ -34,16 +34,16 @@ #include #include #include -#include #include #include #include #include +#include #ifndef SSID_BUF_SIZE #define SSID_BUF_SIZE (32+1) #endif -#ifdef USE_GLIB +#if defined(USE_GLIB) && !defined(OFF_TARGET) #include diff --git a/loc_api/libloc_api_50001/loc_eng_ni.cpp b/loc_api/libloc_api_50001/loc_eng_ni.cpp index 4597b983..a29784fc 100644 --- a/loc_api/libloc_api_50001/loc_eng_ni.cpp +++ b/loc_api/libloc_api_50001/loc_eng_ni.cpp @@ -43,8 +43,7 @@ #include -#include "log_util.h" -#include "platform_lib_includes.h" +#include using namespace loc_core; diff --git a/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/loc_api/libloc_api_50001/loc_eng_nmea.cpp index d60ecfc4..d5cbe9f0 100644 --- a/loc_api/libloc_api_50001/loc_eng_nmea.cpp +++ b/loc_api/libloc_api_50001/loc_eng_nmea.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012,2014 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -36,7 +36,7 @@ #include #include #include -#include "log_util.h" +#include /*=========================================================================== FUNCTION loc_eng_nmea_send diff --git a/loc_api/libloc_api_50001/loc_eng_xtra.cpp b/loc_api/libloc_api_50001/loc_eng_xtra.cpp index 7bb80839..9207564b 100644 --- a/loc_api/libloc_api_50001/loc_eng_xtra.cpp +++ b/loc_api/libloc_api_50001/loc_eng_xtra.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -32,8 +32,7 @@ #include #include -#include "log_util.h" -#include "platform_lib_includes.h" +#include using namespace loc_core; diff --git a/utils/Android.mk b/utils/Android.mk index 240d11fa..45f3c25a 100644 --- a/utils/Android.mk +++ b/utils/Android.mk @@ -6,11 +6,13 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) + ## Libs LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ - liblog + liblog \ + libloc_pla LOCAL_SRC_FILES += \ loc_log.cpp \ @@ -38,7 +40,7 @@ LOCAL_LDFLAGS += -Wl,--export-dynamic ## Includes LOCAL_C_INCLUDES:= \ - $(LOCAL_PATH)/platform_lib_abstractions + $(TARGET_OUT_HEADERS)/libloc_pla LOCAL_COPY_HEADERS_TO:= gps.utils/ LOCAL_COPY_HEADERS:= \ @@ -54,9 +56,6 @@ LOCAL_COPY_HEADERS:= \ loc_target.h \ loc_timer.h \ LocSharedLock.h \ - platform_lib_abstractions/platform_lib_includes.h \ - platform_lib_abstractions/platform_lib_time.h \ - platform_lib_abstractions/platform_lib_macros.h \ loc_misc_utils.h LOCAL_MODULE := libgps.utils @@ -66,5 +65,7 @@ LOCAL_MODULE_TAGS := optional LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) + +include $(addsuffix /Android.mk, $(addprefix $(LOCAL_PATH)/, platform_lib_abstractions)) endif # not BUILD_TINY_ANDROID endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/utils/LocTimer.h b/utils/LocTimer.h index c1468524..c6a63620 100644 --- a/utils/LocTimer.h +++ b/utils/LocTimer.h @@ -31,7 +31,7 @@ #define __LOC_TIMER_CPP_H__ #include -#include +#include // opaque class to provide service implementation. class LocTimerDelegate; diff --git a/utils/Makefile.am b/utils/Makefile.am index e5935f05..50f10078 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -5,22 +5,33 @@ AM_CFLAGS = -Wundef \ -fno-inline \ -fno-short-enums \ -fpic \ - -I../platform_lib_abstractions + -I./ \ + $(LOCPLA_CFLAGS) -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_h_sources = \ + msg_q.h \ + linked_list.h \ + loc_cfg.h \ + loc_log.h \ + loc_target.h \ + loc_timer.h \ + MsgTask.h \ + LocHeap.h \ + LocThread.h \ + LocTimer.h \ + loc_misc_utils.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 +libgps_utils_so_la_c_sources = \ + linked_list.c \ + msg_q.c \ + loc_cfg.cpp \ + loc_log.cpp \ + loc_target.cpp \ + LocHeap.cpp \ + LocTimer.cpp \ + LocThread.cpp \ + MsgTask.cpp \ + loc_misc_utils.cpp library_includedir = $(pkgincludedir)/utils @@ -38,7 +49,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++ -lcutils +libgps_utils_so_la_LIBADD = -lstdc++ -llog $(LOCPLA_LIBS) #Create and Install libraries lib_LTLIBRARIES = libgps_utils_so.la diff --git a/utils/MsgTask.cpp b/utils/MsgTask.cpp index 6f9d0e90..78a3fe00 100644 --- a/utils/MsgTask.cpp +++ b/utils/MsgTask.cpp @@ -29,12 +29,11 @@ #define LOG_NDDEBUG 0 #define LOG_TAG "LocSvc_MsgTask" -#include #include #include #include -#include #include +#include static void LocMsgDestroy(void* msg) { delete (LocMsg*)msg; @@ -79,7 +78,7 @@ void MsgTask::sendMsg(const LocMsg* msg) const { void MsgTask::prerun() { // make sure we do not run in background scheduling group - set_sched_policy(gettid(), SP_FOREGROUND); + platform_lib_abstraction_set_sched_policy(platform_lib_abstraction_gettid(), PLA_SP_FOREGROUND); } bool MsgTask::run() { diff --git a/utils/linked_list.c b/utils/linked_list.c index 2c91714b..acec5b1f 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 #define LOG_TAG "LocSvc_utils_ll" -#include "log_util.h" -#include "platform_lib_includes.h" +#include #include #include diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp index 967d2f30..926781a6 100644 --- a/utils/loc_cfg.cpp +++ b/utils/loc_cfg.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #ifdef USE_GLIB #include diff --git a/utils/loc_log.cpp b/utils/loc_log.cpp index 76f0c532..f6b54f91 100644 --- a/utils/loc_log.cpp +++ b/utils/loc_log.cpp @@ -34,11 +34,7 @@ #include #include "loc_log.h" #include "msg_q.h" -#ifdef USE_GLIB -#include -#endif /* USE_GLIB */ -#include "log_util.h" -#include "platform_lib_includes.h" +#include #define BUFFER_SIZE 120 diff --git a/utils/loc_misc_utils.cpp b/utils/loc_misc_utils.cpp index 7e96313f..dfe19a2d 100644 --- a/utils/loc_misc_utils.cpp +++ b/utils/loc_misc_utils.cpp @@ -28,7 +28,7 @@ */ #include #include -#include +#include #include #include diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index faaedf6c..30c040c7 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -38,7 +38,7 @@ #include #include "loc_target.h" #include "loc_log.h" -#include "log_util.h" +#include #define APQ8064_ID_1 "109" #define APQ8064_ID_2 "153" @@ -112,7 +112,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", diff --git a/utils/loc_timer.h b/utils/loc_timer.h index 2967858e..25fd1790 100644 --- a/utils/loc_timer.h +++ b/utils/loc_timer.h @@ -34,7 +34,7 @@ extern "C" { #endif /* __cplusplus */ #include - +#include /* user_data: client context pointer, passthrough. Originally received from calling client when loc_timer_start() is called. diff --git a/utils/msg_q.c b/utils/msg_q.c index 5be8547e..e412e781 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 #include "linked_list.h" #include #include diff --git a/utils/platform_lib_abstractions/Android.mk b/utils/platform_lib_abstractions/Android.mk new file mode 100644 index 00000000..b923a4c9 --- /dev/null +++ b/utils/platform_lib_abstractions/Android.mk @@ -0,0 +1,5 @@ +ifneq ($(BUILD_TINY_ANDROID),true) + +include $(call all-subdir-makefiles) + +endif diff --git a/utils/platform_lib_abstractions/loc_pla/Android.mk b/utils/platform_lib_abstractions/loc_pla/Android.mk new file mode 100644 index 00000000..b923a4c9 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/Android.mk @@ -0,0 +1,5 @@ +ifneq ($(BUILD_TINY_ANDROID),true) + +include $(call all-subdir-makefiles) + +endif diff --git a/utils/platform_lib_abstractions/loc_pla/Makefile.am b/utils/platform_lib_abstractions/loc_pla/Makefile.am new file mode 100644 index 00000000..8996763e --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/Makefile.am @@ -0,0 +1,10 @@ +# Makefile.am for gps loc-pla +# + +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = src + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = loc-pla.pc +EXTRA_DIST = $(pkgconfig_DATA) diff --git a/utils/platform_lib_abstractions/loc_pla/configure.ac b/utils/platform_lib_abstractions/loc_pla/configure.ac new file mode 100644 index 00000000..a8b892b5 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/configure.ac @@ -0,0 +1,61 @@ +# configure.ac -- Autoconf script for gps loc-pla +# +# 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-pla package version 1.0.0 +AC_INIT([loc-pla],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([include/platform_lib_includes.h]) +# 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([LOCSTUB], [loc-stub]) +AC_SUBST([LOCSTUB_CFLAGS]) +AC_SUBST([LOCSTUB_LIBS]) + +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 \ + src/Makefile \ + loc-pla.pc \ + ]) + +AC_OUTPUT diff --git a/utils/platform_lib_abstractions/loc_pla/include/platform_lib_android_runtime.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_android_runtime.h new file mode 100644 index 00000000..9a954f08 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_android_runtime.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PLATFORM_LIB_ANDROID_RUNTIME_H__ +#define __PLATFORM_LIB_ANDROID_RUNTIME_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +pthread_t platform_lib_abstraction_createJavaThread(const char* name, void (*start)(void *), void* arg); +#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION platform_lib_abstraction_createJavaThread + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /*__PLATFORM_LIB_ANDROID_RUNTIME_H__ */ diff --git a/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h new file mode 100644 index 00000000..9956937c --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PLATFORM_LIB_GETTID_H__ +#define __PLATFORM_LIB_GETTID_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif +pid_t platform_lib_abstraction_gettid(); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* __PLATFORM_LIB_GETTID_H__ */ diff --git a/utils/platform_lib_abstractions/platform_lib_includes.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h similarity index 81% rename from utils/platform_lib_abstractions/platform_lib_includes.h rename to utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h index 5858674f..47c37df8 100644 --- a/utils/platform_lib_abstractions/platform_lib_includes.h +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -26,10 +26,15 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _PLATFORM_LIB_INCLUDES_H_ -#define _PLATFORM_LIB_INCLUDES_H_ +#ifndef __PLATFORM_LIB_INCLUDES_H__ +#define __PLATFORM_LIB_INCLUDES_H__ -#include "platform_lib_time.h" +#include "platform_lib_android_runtime.h" +#include "platform_lib_gettid.h" +#include "platform_lib_log_util.h" #include "platform_lib_macros.h" +#include "platform_lib_property_service.h" +#include "platform_lib_sched_policy.h" +#include "platform_lib_time.h" -#endif +#endif /* __PLATFORM_LIB_INCLUDES_H__ */ diff --git a/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h new file mode 100644 index 00000000..205c9fff --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h @@ -0,0 +1,190 @@ +/* Copyright (c) 2011-2014 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PLATFORM_LIB_LOG_UTIL_H__ +#define __PLATFORM_LIB_LOG_UTIL_H__ + +#include "platform_lib_macros.h" + +#ifndef USE_GLIB +#include +#else + +#include +#include +#include +#include +#include +#include + +#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[]; +extern const char EXIT_ERROR_TAG[]; + +/*============================================================================= + * + * MODULE EXPORTED FUNCTIONS + * + *============================================================================*/ +void loc_logger_init(unsigned long debug, unsigned long timestamp); +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 IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define LOC_LOGE(...) \ +IF_LOC_LOGE { ALOGE("E/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("E/" __VA_ARGS__); } + +#define LOC_LOGW(...) \ +IF_LOC_LOGW { ALOGE("W/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/" __VA_ARGS__); } + +#define LOC_LOGI(...) \ +IF_LOC_LOGI { ALOGE("I/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/" __VA_ARGS__); } + +#define LOC_LOGD(...) \ +IF_LOC_LOGD { ALOGE("D/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/" __VA_ARGS__); } + +#define LOC_LOGV(...) \ +IF_LOC_LOGV { ALOGE("V/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/" __VA_ARGS__); } + +#else /* DEBUG_DMN_LOC_API */ + +#define LOC_LOGE(...) ALOGE("E/" __VA_ARGS__) + +#define LOC_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 LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, 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) +#define EXIT_LOG_WITH_ERROR(SPEC, VAL) \ + if (VAL != 0) { \ + LOG_E(EXIT_ERROR_TAG, __func__, SPEC, VAL); \ + } else { \ + 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 /* __PLATFORM_LIB_LOG_UTIL_H__ */ diff --git a/utils/platform_lib_abstractions/platform_lib_macros.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h similarity index 83% rename from utils/platform_lib_abstractions/platform_lib_macros.h rename to utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h index bc48dd99..c712122e 100644 --- a/utils/platform_lib_abstractions/platform_lib_macros.h +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -29,7 +29,22 @@ #ifndef __PLATFORM_LIB_MACROS_H__ #define __PLATFORM_LIB_MACROS_H__ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef USE_GLIB #include +#include +#include +#ifndef OFF_TARGET +#include +#define strlcat g_strlcat +#define strlcpy g_strlcpy +#else +#define strlcat strncat +#define strlcpy strncpy +#endif #define TS_PRINTF(format, x...) \ { \ @@ -43,39 +58,16 @@ fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec,##x); \ } - -#ifdef USE_GLIB - -#define strlcat g_strlcat -#define strlcpy g_strlcpy - #define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x) #define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x) #define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x) #define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x) #define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x) -#define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid)) - -#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread -#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot()) - - -#else - -#ifdef __cplusplus -extern "C" { -#endif -pid_t gettid(void); +#endif /* USE_GLIB */ #ifdef __cplusplus } -#endif +#endif /*__cplusplus */ -#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 +#endif /* __PLATFORM_LIB_MACROS_H__ */ diff --git a/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h new file mode 100644 index 00000000..ed2041f9 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PLATFORM_LIB_PROPERTY_SERVICE_H__ +#define __PLATFORM_LIB_PROPERTY_SERVICE_H__ + +#ifdef __cplusplus +extern "C" { +#endif +#ifndef PROPERTY_VALUE_MAX +#define PROPERTY_VALUE_MAX 92 +#endif +int platform_lib_abstraction_property_get(const char *key, char *value, const char *default_value); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __PLATFORM_LIB_PROPERTY_SERVICE_H__ */ diff --git a/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h new file mode 100644 index 00000000..d10f1513 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PLATFORM_LIB_SCHED_POLICY_H__ +#define __PLATFORM_LIB_SCHED_POLICY_H__ + +#ifdef __cplusplus +extern "C" { +#endif +typedef enum { + PLA_SP_BACKGROUND = 0, + PLA_SP_FOREGROUND = 1, +} PLASchedPolicy; + +int platform_lib_abstraction_set_sched_policy(int tid, PLASchedPolicy policy); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __PLATFORM_LIB_SCHED_POLICY_H__ */ + diff --git a/utils/platform_lib_abstractions/platform_lib_time.h b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h similarity index 86% rename from utils/platform_lib_abstractions/platform_lib_time.h rename to utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h index ce013afc..2905a74c 100644 --- a/utils/platform_lib_abstractions/platform_lib_time.h +++ b/utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -26,10 +26,10 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _PLATFORM_LIB_TIME_H_ -#define _PLATFORM_LIB_TIME_H_ +#ifndef __PLATFORM_LIB_TIME_H__ +#define __PLATFORM_LIB_TIME_H__ -int64_t systemTime(int clock); -int64_t elapsedMillisSinceBoot(); +#include +int64_t platform_lib_abstraction_elapsed_millis_since_boot(); -#endif +#endif /* __PLATFORM_LIB_TIME_H__ */ diff --git a/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in b/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in new file mode 100644 index 00000000..1aad2f47 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: loc-pla +Description: QTI GPS Location Platform Library Abstractions +Version: @VERSION@ +Libs: -L${libdir} -lloc_pla +Cflags: -I${includedir}/loc-pla diff --git a/utils/platform_lib_abstractions/loc_pla/src/Android.mk b/utils/platform_lib_abstractions/loc_pla/src/Android.mk new file mode 100644 index 00000000..7099f875 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/Android.mk @@ -0,0 +1,58 @@ +ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) +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 \ + libloc_stub + +LOCAL_SRC_FILES += \ + platform_lib_android_runtime.cpp \ + platform_lib_gettid.cpp \ + platform_lib_log_util.cpp \ + platform_lib_property_service.cpp \ + platform_lib_sched_policy.cpp \ + platform_lib_time.cpp + +LOCAL_CFLAGS += \ + -fno-short-enums \ + -D_ANDROID_ \ + -std=c++11 + + +LOCAL_LDFLAGS += -Wl,--export-dynamic + +## Includes +LOCAL_C_INCLUDES:= \ + $(LOCAL_PATH)/../include \ + $(TARGET_OUT_HEADERS)/libloc_stub + + +LOCAL_COPY_HEADERS_TO:= libloc_pla/ +LOCAL_COPY_HEADERS:= \ + ../include/platform_lib_android_runtime.h \ + ../include/platform_lib_gettid.h \ + ../include/platform_lib_includes.h \ + ../include/platform_lib_log_util.h \ + ../include/platform_lib_macros.h \ + ../include/platform_lib_property_service.h \ + ../include/platform_lib_sched_policy.h \ + ../include/platform_lib_time.h + +LOCAL_MODULE := libloc_pla +LOCAL_CLANG := false + +LOCAL_MODULE_TAGS := optional + +LOCAL_PRELINK_MODULE := false + +include $(BUILD_SHARED_LIBRARY) +endif # not BUILD_TINY_ANDROID +endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/utils/platform_lib_abstractions/loc_pla/src/Makefile.am b/utils/platform_lib_abstractions/loc_pla/src/Makefile.am new file mode 100644 index 00000000..6ee0be70 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/Makefile.am @@ -0,0 +1,41 @@ +AM_CFLAGS = \ + $(LOCSTUB_CFLAGS) \ + -I../include \ + -D__func__=__PRETTY_FUNCTION__ \ + -fno-short-enums + +h_sources = \ + ../include/platform_lib_android_runtime.h \ + ../include/platform_lib_gettid.h \ + ../include/platform_lib_includes.h \ + ../include/platform_lib_log_util.h \ + ../include/platform_lib_macros.h \ + ../include/platform_lib_property_service.h \ + ../include/platform_lib_sched_policy.h \ + ../include/platform_lib_time.h + +library_includedir = $(pkgincludedir) +library_include_HEADERS = $(h_sources) + +libloc_pla_la_SOURCES = \ + platform_lib_android_runtime.cpp \ + platform_lib_gettid.cpp \ + platform_lib_log_util.cpp \ + platform_lib_property_service.cpp \ + platform_lib_sched_policy.cpp \ + platform_lib_time.cpp + +if USE_GLIB +libloc_pla_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libloc_pla_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_pla_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_pla_la_CFLAGS = $(AM_CFLAGS) +libloc_pla_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 +libloc_pla_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +endif + +libloc_pla_la_LIBADD = -lstdc++ -ldl -llog $(LOCSTUB_LIBS) + +#Create and Install libraries +lib_LTLIBRARIES = libloc_pla.la diff --git a/utils/platform_lib_abstractions/loc_pla/src/platform_lib_android_runtime.cpp b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_android_runtime.cpp new file mode 100644 index 00000000..090af13b --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_android_runtime.cpp @@ -0,0 +1,40 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "platform_lib_android_runtime.h" + +#ifdef USE_GLIB +#include +#else +#include +#endif /* USE_GLIB */ + +pthread_t platform_lib_abstraction_createJavaThread(const char* name, void (*start)(void *), void* arg) +{ + return (pthread_t)android::AndroidRuntime::createJavaThread(name, start, arg); +} diff --git a/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp new file mode 100644 index 00000000..86863273 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp @@ -0,0 +1,40 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "platform_lib_gettid.h" + +#ifdef USE_GLIB +#include +#else +#include +#endif /* USE_GLIB */ + +pid_t platform_lib_abstraction_gettid() +{ + return gettid(); +} diff --git a/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp new file mode 100644 index 00000000..ef23201a --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp @@ -0,0 +1,42 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "platform_lib_log_util.h" + +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/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp new file mode 100644 index 00000000..1cc63abb --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp @@ -0,0 +1,39 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "platform_lib_property_service.h" + +#ifdef USE_GLIB +#include +#else +#include +#endif /* USE_GLIB */ + +int platform_lib_abstraction_property_get(const char *key, char *value, const char *default_value) +{ + return property_get(key, value, default_value); +} diff --git a/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp new file mode 100644 index 00000000..ba6b3505 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp @@ -0,0 +1,41 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "platform_lib_sched_policy.h" + +#ifdef USE_GLIB +#include +#else +#include +#endif /* USE_GLIB */ + +int platform_lib_abstraction_set_sched_policy(int tid, PLASchedPolicy policy) +{ + return set_sched_policy(tid, (SchedPolicy)policy); +} + diff --git a/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp new file mode 100644 index 00000000..dc7dff11 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp @@ -0,0 +1,47 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "platform_lib_time.h" + +#ifdef USE_GLIB +#include +#else +#include +#endif /* USE_GLIB */ + +int64_t platform_lib_abstraction_elapsed_millis_since_boot() +{ +#ifdef USE_GLIB + + return elapsedMillisSinceBoot(); + +#else + + return android::elapsedRealtime(); + +#endif +} diff --git a/utils/platform_lib_abstractions/loc_stub/Android.mk b/utils/platform_lib_abstractions/loc_stub/Android.mk new file mode 100644 index 00000000..b923a4c9 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/Android.mk @@ -0,0 +1,5 @@ +ifneq ($(BUILD_TINY_ANDROID),true) + +include $(call all-subdir-makefiles) + +endif diff --git a/utils/platform_lib_abstractions/loc_stub/Makefile.am b/utils/platform_lib_abstractions/loc_stub/Makefile.am new file mode 100644 index 00000000..d81e363a --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/Makefile.am @@ -0,0 +1,9 @@ +# Makefile.am for gps loc-stub + +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = src + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = loc-stub.pc +EXTRA_DIST = $(pkgconfig_DATA) diff --git a/utils/platform_lib_abstractions/loc_stub/configure.ac b/utils/platform_lib_abstractions/loc_stub/configure.ac new file mode 100644 index 00000000..8900f040 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/configure.ac @@ -0,0 +1,67 @@ +# configure.ac -- Autoconf script for gps loc-stub +# +# 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-stub package version 1.0.0 +AC_INIT([loc-stub],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([Makefile.am]) +# 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. +AC_ARG_WITH([hardware_include], + AC_HELP_STRING([--with-hardware-include=@<:@dir@:>@], + [Specify the location of the hardware headers]), + [hardware_incdir=$withval], + with_hardware_include=no) + +if test "x$with_hardware_include" != "xno"; then + CPPFLAGS="${CPPFLAGS} -I${hardware_incdir}" +fi + +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 \ + src/Makefile \ + loc-stub.pc + ]) + +AC_OUTPUT diff --git a/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h new file mode 100644 index 00000000..c8764eea --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LOC_STUB_ANDROID_RUNTIME_H__ +#define __LOC_STUB_ANDROID_RUNTIME_H__ + +#include + +namespace android { + +class AndroidRuntime +{ +public: + /** create a new thread that is visible from Java */ + static pthread_t createJavaThread(const char* name, void (*start)(void *), + void* arg); +}; + +} +#endif /* __LOC_STUB_ANDROID_RUNTIME_H__ */ diff --git a/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h new file mode 100644 index 00000000..677bc81a --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LOC_STUB_GETTID_H__ +#define __LOC_STUB_GETTID_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +pid_t gettid(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __LOC_STUB_GETTID_H__ */ diff --git a/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h new file mode 100644 index 00000000..3677cdf6 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h @@ -0,0 +1,42 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LOC_STUB_PROPERTY_SERVICE_H__ +#define __LOC_STUB_PROPERTY_SERVICE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +int property_get(const char *key, char *value, const char *default_value); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LOC_STUB_PROPERTY_SERVICE_H__ */ diff --git a/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h new file mode 100644 index 00000000..a42b117b --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h @@ -0,0 +1,64 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LOC_STUB_SCHED_POLICY_H__ +#define __LOC_STUB_SCHED_POLICY_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + SP_BACKGROUND = 0, + SP_FOREGROUND = 1, +} SchedPolicy; + +/*=========================================================================== +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 + +===========================================================================*/ +int set_sched_policy(int tid, SchedPolicy policy); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LOC_STUB_SCHED_POLICY_H__ */ + diff --git a/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h new file mode 100644 index 00000000..271e2ff4 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LOC_STUB_TIME_H__ +#define __LOC_STUB_TIME_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int64_t systemTime(int clock); +int64_t elapsedMillisSinceBoot(); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LOC_STUB_TIME_H__ */ diff --git a/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in b/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in new file mode 100644 index 00000000..c2ae764b --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: loc-stub +Description: QTI GPS Location Stub +Version: @VERSION +Libs: -L${libdir} -lloc_stub +Cflags: -I${includedir}/loc-stub diff --git a/utils/platform_lib_abstractions/loc_stub/src/Android.mk b/utils/platform_lib_abstractions/loc_stub/src/Android.mk new file mode 100644 index 00000000..2cf25b9e --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/src/Android.mk @@ -0,0 +1,52 @@ +ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) +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_stub_android_runtime.cpp \ + loc_stub_gettid.cpp \ + loc_stub_property_service.cpp \ + loc_stub_sched_policy.cpp \ + loc_stub_time.cpp + +LOCAL_CFLAGS += \ + -fno-short-enums \ + -D_ANDROID_ \ + -std=c++11 + + +LOCAL_LDFLAGS += -Wl,--export-dynamic + +## Includes +LOCAL_C_INCLUDES:= \ + $(LOCAL_PATH)/../include \ + + +LOCAL_COPY_HEADERS_TO:= libloc_stub/ +LOCAL_COPY_HEADERS:= \ + ../include/loc_stub_android_runtime.h \ + ../include/loc_stub_gettid.h \ + ../include/loc_stub_property_service.h \ + ../include/loc_stub_sched_policy.h \ + ../include/loc_stub_time.h + +LOCAL_MODULE := libloc_stub +LOCAL_CLANG := false + +LOCAL_MODULE_TAGS := optional + +LOCAL_PRELINK_MODULE := false + +include $(BUILD_SHARED_LIBRARY) +endif # not BUILD_TINY_ANDROID +endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE diff --git a/utils/platform_lib_abstractions/loc_stub/src/Makefile.am b/utils/platform_lib_abstractions/loc_stub/src/Makefile.am new file mode 100644 index 00000000..8bda7113 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/src/Makefile.am @@ -0,0 +1,40 @@ +AM_CFLAGS = \ + -I../include \ + -D__func__=__PRETTY_FUNCTION__ \ + -fno-short-enums + +libloc_stub_la_extra_h = \ + ../include/utils/Log.h + +libloc_stub_la_c_sources = \ + loc_stub_android_runtime.cpp \ + loc_stub_gettid.cpp \ + loc_stub_property_service.cpp \ + loc_stub_sched_policy.cpp \ + loc_stub_time.cpp + +libloc_stub_la_SOURCES = $(libloc_stub_la_c_sources) $(libloc_stub_la_extra_h) + +library_include_HEADERS = \ + ../include/loc_stub_android_runtime.h \ + ../include/loc_stub_gettid.h \ + ../include/loc_stub_property_service.h \ + ../include/loc_stub_sched_policy.h \ + ../include/loc_stub_time.h + +library_includedir = $(pkgincludedir) + +if USE_GLIB +libloc_stub_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ +libloc_stub_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 +libloc_stub_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@ +else +libloc_stub_la_CFLAGS = $(AM_CFLAGS) +libloc_stub_la_LDFLAGS = -lpthread -shared -version-info 1:0:0 +libloc_stub_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) +endif + +libloc_stub_la_LIBADD = -lstdc++ -ldl -llog + +#Create and Install libraries +lib_LTLIBRARIES = libloc_stub.la diff --git a/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp new file mode 100644 index 00000000..1db69b24 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp @@ -0,0 +1,41 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "loc_stub_android_runtime.h" + +namespace android { + +pthread_t AndroidRuntime::createJavaThread(const char* name, + void (*start)(void *), void* arg) +{ + pthread_t threadId = 0; + pthread_create(&threadId, NULL, (void *(*)(void*))start, arg); + return threadId; +} + +} diff --git a/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp new file mode 100644 index 00000000..55ef48a1 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp @@ -0,0 +1,37 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "loc_stub_gettid.h" +#include +#include + +// Required for off-target environment to compile properly +pid_t gettid(void) +{ + return syscall(SYS_gettid); +} diff --git a/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp new file mode 100644 index 00000000..f9d9e3ef --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp @@ -0,0 +1,42 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "loc_stub_property_service.h" +#include +#include + +int property_get(const char *key, char * value, const char *default_value) +{ + /* This will disable gps interface + value[0] = '1'; + */ + if (strcmp(key, "ro.baseband") == 0) { + memcpy(value, "msm", 4); + } + return 0; +} diff --git a/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp new file mode 100644 index 00000000..781be295 --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp @@ -0,0 +1,50 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "loc_stub_sched_policy.h" + +/*=========================================================================== +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 + +===========================================================================*/ +int set_sched_policy(int tid, SchedPolicy policy) +{ + return 0; +} diff --git a/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp new file mode 100644 index 00000000..82dc593f --- /dev/null +++ b/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp @@ -0,0 +1,46 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "loc_stub_time.h" +#include +#include + +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; +}