aboutsummaryrefslogtreecommitdiff
path: root/gps/utils
diff options
context:
space:
mode:
authorBruno Martins <bgcngm@gmail.com>2016-11-16 23:40:24 +0000
committerdavidevinavil <davidevinavil@gmail.com>2017-01-21 18:27:40 +0100
commitdb17d990d994300016c7e88cecad7de81f5e79e5 (patch)
tree8c1ec061f63ef1271b03bccc22fe945e6f6b6000 /gps/utils
parentb6b44db0293d2e81356ae8f35c2583f6129ea62c (diff)
z2_plus: Update GPS stack
* Tag LA.UM.5.5.r1-00100-8x96.0 Change-Id: I18cd979799001ccbaae6d08d07f907689ac5a00a
Diffstat (limited to 'gps/utils')
-rw-r--r--gps/utils/Android.mk16
-rw-r--r--gps/utils/LocThread.cpp4
-rw-r--r--gps/utils/LocTimer.cpp7
-rw-r--r--gps/utils/LocTimer.h2
-rw-r--r--gps/utils/Makefile.am45
-rw-r--r--gps/utils/MsgTask.cpp5
-rw-r--r--gps/utils/linked_list.c5
-rw-r--r--gps/utils/loc_cfg.cpp2
-rw-r--r--gps/utils/loc_log.cpp6
-rw-r--r--gps/utils/loc_misc_utils.cpp2
-rw-r--r--gps/utils/loc_target.cpp44
-rw-r--r--gps/utils/loc_target.h6
-rw-r--r--gps/utils/loc_timer.h2
-rw-r--r--gps/utils/log_util.h6
-rw-r--r--gps/utils/msg_q.c5
-rw-r--r--gps/utils/platform_lib_abstractions/Android.mk5
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/Android.mk5
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/Makefile.am10
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/configure.ac61
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_android_runtime.h45
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h41
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h40
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h196
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h (renamed from gps/utils/platform_lib_abstractions/platform_lib_macros.h)46
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h44
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h46
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h (renamed from gps/utils/platform_lib_abstractions/platform_lib_includes.h)12
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in10
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/Android.mk55
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/Makefile.am41
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_android_runtime.cpp40
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp40
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp42
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp39
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp41
-rw-r--r--gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp47
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/Android.mk5
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/Makefile.am9
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/configure.ac67
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h45
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h44
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h42
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h64
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h (renamed from gps/utils/platform_lib_abstractions/platform_lib_time.h)18
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in10
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/src/Android.mk49
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/src/Makefile.am40
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp41
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp37
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp42
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp50
-rw-r--r--gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp46
52 files changed, 1580 insertions, 92 deletions
diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk
index 103e524..ef1b7a2 100644
--- a/gps/utils/Android.mk
+++ b/gps/utils/Android.mk
@@ -5,11 +5,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 \
@@ -24,10 +26,10 @@ LOCAL_SRC_FILES += \
MsgTask.cpp \
loc_misc_utils.cpp
+# Flag -std=c++11 is not accepted by compiler when LOCAL_CLANG is set to true
LOCAL_CFLAGS += \
-fno-short-enums \
- -D_ANDROID_ \
- -std=c++11
+ -D_ANDROID_
ifeq ($(TARGET_BUILD_VARIANT),user)
LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
@@ -37,7 +39,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:= \
@@ -53,17 +55,15 @@ 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
-LOCAL_CLANG := false
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
diff --git a/gps/utils/LocThread.cpp b/gps/utils/LocThread.cpp
index 19bf101..685841e 100644
--- a/gps/utils/LocThread.cpp
+++ b/gps/utils/LocThread.cpp
@@ -29,6 +29,7 @@
#include <LocThread.h>
#include <string.h>
#include <pthread.h>
+#include <platform_lib_macros.h>
class LocThreadDelegate {
LocRunnable* mRunnable;
@@ -84,7 +85,8 @@ LocThreadDelegate::LocThreadDelegate(LocThread::tCreate creator,
if (mThandle) {
// set thread name
char lname[16];
- int len = sizeof(lname) - 1;
+ int len = (sizeof(lname)>sizeof(threadName)) ?
+ (sizeof(threadName) -1):(sizeof(lname) - 1);
memcpy(lname, threadName, len);
lname[len] = 0;
// set the thread name here
diff --git a/gps/utils/LocTimer.cpp b/gps/utils/LocTimer.cpp
index 70904b2..4de6b40 100644
--- a/gps/utils/LocTimer.cpp
+++ b/gps/utils/LocTimer.cpp
@@ -505,8 +505,13 @@ int LocTimerDelegate::ranks(LocRankable& rankable) {
LocTimerDelegate* timer = (LocTimerDelegate*)(&rankable);
if (timer) {
// larger time ranks lower!!!
- // IOW, if input obj has bigger tv_sec, this obj outRanks higher
+ // IOW, if input obj has bigger tv_sec/tv_nsec, this obj outRanks higher
rank = timer->mFutureTime.tv_sec - mFutureTime.tv_sec;
+ if(0 == rank)
+ {
+ //rank against tv_nsec for msec accuracy
+ rank = (int)(timer->mFutureTime.tv_nsec - mFutureTime.tv_nsec);
+ }
}
return rank;
}
diff --git a/gps/utils/LocTimer.h b/gps/utils/LocTimer.h
index c146852..c6a6362 100644
--- a/gps/utils/LocTimer.h
+++ b/gps/utils/LocTimer.h
@@ -31,7 +31,7 @@
#define __LOC_TIMER_CPP_H__
#include <stddef.h>
-#include <log_util.h>
+#include <platform_lib_includes.h>
// opaque class to provide service implementation.
class LocTimerDelegate;
diff --git a/gps/utils/Makefile.am b/gps/utils/Makefile.am
index e5935f0..50f1007 100644
--- a/gps/utils/Makefile.am
+++ b/gps/utils/Makefile.am
@@ -5,22 +5,33 @@ AM_CFLAGS = -Wundef \
-fno-inline \
-fno-short-enums \
-fpic \
- -I../platform_lib_abstractions
-
-libgps_utils_so_la_h_sources = log_util.h \
- msg_q.h \
- linked_list.h \
- loc_cfg.h \
- loc_log.h \
- ../platform_lib_abstractions/platform_lib_includes.h \
- ../platform_lib_abstractions/platform_lib_time.h \
- ../platform_lib_abstractions/platform_lib_macros.h
-
-libgps_utils_so_la_c_sources = linked_list.c \
- msg_q.c \
- loc_cfg.cpp \
- loc_log.cpp \
- ../platform_lib_abstractions/elapsed_millis_since_boot.cpp
+ -I./ \
+ $(LOCPLA_CFLAGS)
+
+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 \
+ 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/gps/utils/MsgTask.cpp b/gps/utils/MsgTask.cpp
index 6f9d0e9..78a3fe0 100644
--- a/gps/utils/MsgTask.cpp
+++ b/gps/utils/MsgTask.cpp
@@ -29,12 +29,11 @@
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_MsgTask"
-#include <cutils/sched_policy.h>
#include <unistd.h>
#include <MsgTask.h>
#include <msg_q.h>
-#include <log_util.h>
#include <loc_log.h>
+#include <platform_lib_includes.h>
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/gps/utils/linked_list.c b/gps/utils/linked_list.c
index 2c91714..acec5b1 100644
--- a/gps/utils/linked_list.c
+++ b/gps/utils/linked_list.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,8 +31,7 @@
#include <string.h>
#define LOG_TAG "LocSvc_utils_ll"
-#include "log_util.h"
-#include "platform_lib_includes.h"
+#include <platform_lib_includes.h>
#include <stdlib.h>
#include <stdint.h>
diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp
index 967d2f3..926781a 100644
--- a/gps/utils/loc_cfg.cpp
+++ b/gps/utils/loc_cfg.cpp
@@ -38,7 +38,7 @@
#include <unistd.h>
#include <time.h>
#include <loc_cfg.h>
-#include <log_util.h>
+#include <platform_lib_includes.h>
#include <loc_misc_utils.h>
#ifdef USE_GLIB
#include <glib.h>
diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp
index 76f0c53..f6b54f9 100644
--- a/gps/utils/loc_log.cpp
+++ b/gps/utils/loc_log.cpp
@@ -34,11 +34,7 @@
#include <sys/time.h>
#include "loc_log.h"
#include "msg_q.h"
-#ifdef USE_GLIB
-#include <time.h>
-#endif /* USE_GLIB */
-#include "log_util.h"
-#include "platform_lib_includes.h"
+#include <platform_lib_includes.h>
#define BUFFER_SIZE 120
diff --git a/gps/utils/loc_misc_utils.cpp b/gps/utils/loc_misc_utils.cpp
index 7e96313..dfe19a2 100644
--- a/gps/utils/loc_misc_utils.cpp
+++ b/gps/utils/loc_misc_utils.cpp
@@ -28,7 +28,7 @@
*/
#include <stdio.h>
#include <string.h>
-#include <log_util.h>
+#include <platform_lib_log_util.h>
#include <loc_misc_utils.h>
#include <ctype.h>
diff --git a/gps/utils/loc_target.cpp b/gps/utils/loc_target.cpp
index faaedf6..2da2fea 100644
--- a/gps/utils/loc_target.cpp
+++ b/gps/utils/loc_target.cpp
@@ -38,7 +38,7 @@
#include <cutils/properties.h>
#include "loc_target.h"
#include "loc_log.h"
-#include "log_util.h"
+#include <platform_lib_includes.h>
#define APQ8064_ID_1 "109"
#define APQ8064_ID_2 "153"
@@ -49,11 +49,12 @@
#define APQ8074_ID_1 "184"
#define LINE_LEN 100
-#define STR_LIQUID "Liquid"
-#define STR_SURF "Surf"
-#define STR_MTP "MTP"
-#define STR_APQ "apq"
-#define STR_AUTO "auto"
+#define STR_LIQUID "Liquid"
+#define STR_SURF "Surf"
+#define STR_MTP "MTP"
+#define STR_APQ "apq"
+#define STR_APQ_NO_WGR "baseband_apq_nowgr"
+#define STR_AUTO "auto"
#define IS_STR_END(c) ((c) == '\0' || (c) == '\n' || (c) == '\r')
#define LENGTH(s) (sizeof(s) - 1)
#define GPS_CHECK_NO_ERROR 0
@@ -112,7 +113,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",
@@ -174,6 +175,20 @@ void loc_get_platform_name(char *platform_name, int array_length)
}
}
+/*The character array passed to this function should have length
+ of atleast PROPERTY_VALUE_MAX*/
+void loc_get_auto_platform_name(char *platform_name, int array_length)
+{
+ if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) {
+ property_get("ro.hardware.type", platform_name, "");
+ LOC_LOGD("%s:%d]: Autoplatform name: %s\n", __func__, __LINE__, platform_name);
+ }
+ else {
+ LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n",
+ __func__, __LINE__);
+ }
+}
+
unsigned int loc_get_target(void)
{
if (gTarget != (unsigned int)-1)
@@ -190,6 +205,7 @@ unsigned int loc_get_target(void)
char rd_id[LINE_LEN];
char rd_mdm[LINE_LEN];
char baseband[LINE_LEN];
+ char rd_auto_platform[LINE_LEN];
if (is_qca1530()) {
gTarget = TARGET_QCA1530;
@@ -208,16 +224,26 @@ unsigned int loc_get_target(void)
} else {
read_a_line(id_dep, rd_id, LINE_LEN);
}
- if( !memcmp(baseband, STR_AUTO, LENGTH(STR_AUTO)) )
+
+ /*check automotive platform*/
+ loc_get_auto_platform_name(rd_auto_platform, sizeof(rd_auto_platform));
+ if( !memcmp(rd_auto_platform, STR_AUTO, LENGTH(STR_AUTO)) )
{
gTarget = TARGET_AUTO;
goto detected;
}
+
+ if( !memcmp(baseband, STR_APQ_NO_WGR, LENGTH(STR_APQ_NO_WGR)) ){
+
+ gTarget = TARGET_NO_GNSS;
+ goto detected;
+ }
+
if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){
if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1))
&& IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) )
- gTarget = TARGET_MPQ;
+ gTarget = TARGET_NO_GNSS;
else
gTarget = TARGET_APQ_SA;
}
diff --git a/gps/utils/loc_target.h b/gps/utils/loc_target.h
index 3bb3b5e..69395db 100644
--- a/gps/utils/loc_target.h
+++ b/gps/utils/loc_target.h
@@ -32,7 +32,7 @@
#define TARGET_DEFAULT TARGET_SET(GNSS_MSM, HAS_SSC)
#define TARGET_MDM TARGET_SET(GNSS_MDM, HAS_SSC)
#define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC)
-#define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC)
+#define TARGET_NO_GNSS TARGET_SET(GNSS_NONE, NO_SSC)
#define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC)
#define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC)
#define TARGET_AUTO TARGET_SET(GNSS_AUTO, NO_SSC)
@@ -52,6 +52,10 @@ void loc_get_target_baseband(char *baseband, int array_length);
/*The character array passed to this function should have length
of atleast PROPERTY_VALUE_MAX*/
void loc_get_platform_name(char *platform_name, int array_length);
+/*The character array passed to this function should have length
+ of atleast PROPERTY_VALUE_MAX*/
+void loc_get_auto_platform_name(char *platform_name, int array_length);
+
/*Reads the property ro.lean to identify if this is a lean target
Returns:
0 if not a lean and mean target
diff --git a/gps/utils/loc_timer.h b/gps/utils/loc_timer.h
index 2967858..25fd179 100644
--- a/gps/utils/loc_timer.h
+++ b/gps/utils/loc_timer.h
@@ -34,7 +34,7 @@
extern "C" {
#endif /* __cplusplus */
#include <stddef.h>
-
+#include <platform_lib_includes.h>
/*
user_data: client context pointer, passthrough. Originally received
from calling client when loc_timer_start() is called.
diff --git a/gps/utils/log_util.h b/gps/utils/log_util.h
index ffd5ca9..d27c800 100644
--- a/gps/utils/log_util.h
+++ b/gps/utils/log_util.h
@@ -159,6 +159,12 @@ else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/" __VA_ARGS__); }
} \
} while(0)
+#define LOC_LOG_HEAD(tag,fmt) "%s:%d][" tag "] " fmt "\n"
+#define LOC_LOGv(tag,fmt,...) LOC_LOGV(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+#define LOC_LOGw(tag,fmt,...) LOC_LOGW(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+#define LOC_LOGd(tag,fmt,...) LOC_LOGD(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+#define LOC_LOGe(tag,fmt,...) LOC_LOGE(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+
#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)
diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c
index 5be8547..e412e78 100644
--- a/gps/utils/msg_q.c
+++ b/gps/utils/msg_q.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,8 +29,7 @@
#include "msg_q.h"
#define LOG_TAG "LocSvc_utils_q"
-#include "log_util.h"
-#include "platform_lib_includes.h"
+#include <platform_lib_includes.h>
#include "linked_list.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/gps/utils/platform_lib_abstractions/Android.mk b/gps/utils/platform_lib_abstractions/Android.mk
new file mode 100644
index 0000000..b923a4c
--- /dev/null
+++ b/gps/utils/platform_lib_abstractions/Android.mk
@@ -0,0 +1,5 @@
+ifneq ($(BUILD_TINY_ANDROID),true)
+
+include $(call all-subdir-makefiles)
+
+endif
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/Android.mk b/gps/utils/platform_lib_abstractions/loc_pla/Android.mk
new file mode 100644
index 0000000..b923a4c
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_pla/Makefile.am b/gps/utils/platform_lib_abstractions/loc_pla/Makefile.am
new file mode 100644
index 0000000..8996763
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_pla/configure.ac b/gps/utils/platform_lib_abstractions/loc_pla/configure.ac
new file mode 100644
index 0000000..a8b892b
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_android_runtime.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_android_runtime.h
new file mode 100644
index 0000000..9a954f0
--- /dev/null
+++ b/gps/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 <pthread.h>
+
+#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/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_gettid.h
new file mode 100644
index 0000000..9956937
--- /dev/null
+++ b/gps/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 <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+pid_t platform_lib_abstraction_gettid();
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __PLATFORM_LIB_GETTID_H__ */
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h
new file mode 100644
index 0000000..47c37df
--- /dev/null
+++ b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_includes.h
@@ -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.
+ */
+
+#ifndef __PLATFORM_LIB_INCLUDES_H__
+#define __PLATFORM_LIB_INCLUDES_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 /* __PLATFORM_LIB_INCLUDES_H__ */
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h
new file mode 100644
index 0000000..5989c64
--- /dev/null
+++ b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_log_util.h
@@ -0,0 +1,196 @@
+/* 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 <log_util.h>
+#else
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+
+#ifndef LOG_TAG
+#define LOG_TAG "GPS_UTILS"
+#endif /* LOG_TAG */
+
+#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 LOC_LOG_HEAD(tag,fmt) "%s:%d][" tag "] " fmt "\n"
+#define LOC_LOGv(tag,fmt,...) LOC_LOGV(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+#define LOC_LOGw(tag,fmt,...) LOC_LOGW(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+#define LOC_LOGd(tag,fmt,...) LOC_LOGD(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+#define LOC_LOGe(tag,fmt,...) LOC_LOGE(LOC_LOG_HEAD(tag,fmt), __func__, __LINE__, ##__VA_ARGS__)
+
+#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 /* USE_GLIB */
+
+#endif /* __PLATFORM_LIB_LOG_UTIL_H__ */
diff --git a/gps/utils/platform_lib_abstractions/platform_lib_macros.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_macros.h
index bc48dd9..c712122 100644
--- a/gps/utils/platform_lib_abstractions/platform_lib_macros.h
+++ b/gps/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 <sys/time.h>
+#include <string.h>
+#include <stdlib.h>
+#ifndef OFF_TARGET
+#include <glib.h>
+#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
-
-#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 /*__cplusplus */
-#endif
-
-#endif
+#endif /* __PLATFORM_LIB_MACROS_H__ */
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_property_service.h
new file mode 100644
index 0000000..ed2041f
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_sched_policy.h
new file mode 100644
index 0000000..d10f151
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/platform_lib_includes.h b/gps/utils/platform_lib_abstractions/loc_pla/include/platform_lib_time.h
index 5858674..2905a74 100644
--- a/gps/utils/platform_lib_abstractions/platform_lib_includes.h
+++ b/gps/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_INCLUDES_H_
-#define _PLATFORM_LIB_INCLUDES_H_
+#ifndef __PLATFORM_LIB_TIME_H__
+#define __PLATFORM_LIB_TIME_H__
-#include "platform_lib_time.h"
-#include "platform_lib_macros.h"
+#include <stdint.h>
+int64_t platform_lib_abstraction_elapsed_millis_since_boot();
-#endif
+#endif /* __PLATFORM_LIB_TIME_H__ */
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in b/gps/utils/platform_lib_abstractions/loc_pla/loc-pla.pc.in
new file mode 100644
index 0000000..1aad2f4
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_pla/src/Android.mk b/gps/utils/platform_lib_abstractions/loc_pla/src/Android.mk
new file mode 100644
index 0000000..0363d59
--- /dev/null
+++ b/gps/utils/platform_lib_abstractions/loc_pla/src/Android.mk
@@ -0,0 +1,55 @@
+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)/gps.utils \
+ $(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_MODULE_TAGS := optional
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+endif # not BUILD_TINY_ANDROID
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/Makefile.am b/gps/utils/platform_lib_abstractions/loc_pla/src/Makefile.am
new file mode 100644
index 0000000..6ee0be7
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_android_runtime.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_android_runtime.cpp
new file mode 100644
index 0000000..090af13
--- /dev/null
+++ b/gps/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 <loc_stub_android_runtime.h>
+#else
+#include <android_runtime/AndroidRuntime.h>
+#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/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_gettid.cpp
new file mode 100644
index 0000000..8686327
--- /dev/null
+++ b/gps/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 <loc_stub_gettid.h>
+#else
+#include <unistd.h>
+#endif /* USE_GLIB */
+
+pid_t platform_lib_abstraction_gettid()
+{
+ return gettid();
+}
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_log_util.cpp
new file mode 100644
index 0000000..ef23201
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_property_service.cpp
new file mode 100644
index 0000000..1cc63ab
--- /dev/null
+++ b/gps/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 <loc_stub_property_service.h>
+#else
+#include <cutils/properties.h>
+#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/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_sched_policy.cpp
new file mode 100644
index 0000000..ba6b350
--- /dev/null
+++ b/gps/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 <loc_stub_sched_policy.h>
+#else
+#include <cutils/sched_policy.h>
+#endif /* USE_GLIB */
+
+int platform_lib_abstraction_set_sched_policy(int tid, PLASchedPolicy policy)
+{
+ return set_sched_policy(tid, (SchedPolicy)policy);
+}
+
diff --git a/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp b/gps/utils/platform_lib_abstractions/loc_pla/src/platform_lib_time.cpp
new file mode 100644
index 0000000..dc7dff1
--- /dev/null
+++ b/gps/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 <loc_stub_time.h>
+#else
+#include <utils/SystemClock.h>
+#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/gps/utils/platform_lib_abstractions/loc_stub/Android.mk b/gps/utils/platform_lib_abstractions/loc_stub/Android.mk
new file mode 100644
index 0000000..b923a4c
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/Makefile.am b/gps/utils/platform_lib_abstractions/loc_stub/Makefile.am
new file mode 100644
index 0000000..d81e363
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/configure.ac b/gps/utils/platform_lib_abstractions/loc_stub/configure.ac
new file mode 100644
index 0000000..8900f04
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_android_runtime.h
new file mode 100644
index 0000000..c8764ee
--- /dev/null
+++ b/gps/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 <pthread.h>
+
+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/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_gettid.h
new file mode 100644
index 0000000..677bc81
--- /dev/null
+++ b/gps/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 <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+pid_t gettid(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LOC_STUB_GETTID_H__ */
diff --git a/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_property_service.h
new file mode 100644
index 0000000..3677cdf
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_sched_policy.h
new file mode 100644
index 0000000..a42b117
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/platform_lib_time.h b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_time.h
index ce013af..271e2ff 100644
--- a/gps/utils/platform_lib_abstractions/platform_lib_time.h
+++ b/gps/utils/platform_lib_abstractions/loc_stub/include/loc_stub_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,20 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _PLATFORM_LIB_TIME_H_
-#define _PLATFORM_LIB_TIME_H_
+#ifndef __LOC_STUB_TIME_H__
+#define __LOC_STUB_TIME_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
int64_t systemTime(int clock);
int64_t elapsedMillisSinceBoot();
-#endif
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LOC_STUB_TIME_H__ */
diff --git a/gps/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in b/gps/utils/platform_lib_abstractions/loc_stub/loc-stub.pc.in
new file mode 100644
index 0000000..c2ae764
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/src/Android.mk b/gps/utils/platform_lib_abstractions/loc_stub/src/Android.mk
new file mode 100644
index 0000000..65fe021
--- /dev/null
+++ b/gps/utils/platform_lib_abstractions/loc_stub/src/Android.mk
@@ -0,0 +1,49 @@
+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_MODULE_TAGS := optional
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+endif # not BUILD_TINY_ANDROID
diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/Makefile.am b/gps/utils/platform_lib_abstractions/loc_stub/src/Makefile.am
new file mode 100644
index 0000000..8bda711
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_android_runtime.cpp
new file mode 100644
index 0000000..1db69b2
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_gettid.cpp
new file mode 100644
index 0000000..55ef48a
--- /dev/null
+++ b/gps/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 <sys/syscall.h>
+#include <unistd.h>
+
+// Required for off-target environment to compile properly
+pid_t gettid(void)
+{
+ return syscall(SYS_gettid);
+}
diff --git a/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_property_service.cpp
new file mode 100644
index 0000000..f9d9e3e
--- /dev/null
+++ b/gps/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 <stdio.h>
+#include <string.h>
+
+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/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_sched_policy.cpp
new file mode 100644
index 0000000..781be29
--- /dev/null
+++ b/gps/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/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp b/gps/utils/platform_lib_abstractions/loc_stub/src/loc_stub_time.cpp
new file mode 100644
index 0000000..82dc593
--- /dev/null
+++ b/gps/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 <stdlib.h>
+#include <sys/time.h>
+
+int64_t systemTime(int clock)
+{
+ struct timeval t;
+ t.tv_sec = t.tv_usec = 0;
+ gettimeofday(&t, NULL);
+ return t.tv_sec*1000000LL + t.tv_usec;
+}
+
+
+int64_t elapsedMillisSinceBoot()
+{
+ int64_t t_us = systemTime(0);
+ return (int64_t) t_us / 1000LL;
+}