1 /* Copyright (c) 2014, The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are
5  * met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above
9  *       copyright notice, this list of conditions and the following
10  *       disclaimer in the documentation and/or other materials provided
11  *       with the distribution.
12  *     * Neither the name of The Linux Foundation nor the names of its
13  *       contributors may be used to endorse or promote products derived
14  *       from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __LOC_PLA__
30 #define __LOC_PLA__
31 
32 #ifdef __cplusplus
33 #ifndef FEATURE_EXTERNAL_AP
34 #include <utils/SystemClock.h>
35 #endif /* FEATURE_EXTERNAL_AP */
36 #include <inttypes.h>
37 #include <sys/time.h>
38 #include <time.h>
39 
uptimeMillis()40 inline int64_t uptimeMillis()
41 {
42     struct timespec ts;
43     int64_t time_ms = 0;
44     clock_gettime(CLOCK_BOOTTIME, &ts);
45     time_ms += (ts.tv_sec * 1000000000LL);
46     time_ms += ts.tv_nsec + 500000LL;
47     return time_ms / 1000000LL;
48 }
49 
50 extern "C" {
51 #endif
52 
53 #ifndef FEATURE_EXTERNAL_AP
54 #include <cutils/properties.h>
55 #include <cutils/sched_policy.h>
56 #endif /* FEATURE_EXTERNAL_AP */
57 #include <pthread.h>
58 #include <sys/time.h>
59 #include <sys/types.h>
60 #include <string.h>
61 #include <stdlib.h>
62 #ifndef OFF_TARGET
63 #include <glib.h>
64 #define strlcat g_strlcat
65 #define strlcpy g_strlcpy
66 #else
67 #define strlcat strncat
68 #define strlcpy strncpy
69 #endif
70 
71 #define UID_GPS (1021)
72 #define GID_GPS (1021)
73 #define UID_LOCCLIENT (4021)
74 #define GID_LOCCLIENT (4021)
75 
76 #define LOC_PATH_GPS_CONF_STR      "/etc/gps.conf"
77 #define LOC_PATH_IZAT_CONF_STR     "/etc/izat.conf"
78 #define LOC_PATH_FLP_CONF_STR      "/etc/flp.conf"
79 #define LOC_PATH_LOWI_CONF_STR     "/etc/lowi.conf"
80 #define LOC_PATH_SAP_CONF_STR      "/etc/sap.conf"
81 #define LOC_PATH_APDR_CONF_STR     "/etc/apdr.conf"
82 #define LOC_PATH_XTWIFI_CONF_STR   "/etc/xtwifi.conf"
83 #define LOC_PATH_QUIPC_CONF_STR    "/etc/quipc.conf"
84 
85 #ifdef FEATURE_EXTERNAL_AP
86 #define PROPERTY_VALUE_MAX 92
87 
property_get(const char * key,char * value,const char * default_value)88 inline int property_get(const char* key, char* value, const char* default_value)
89 {
90     strlcpy(value, default_value, PROPERTY_VALUE_MAX - 1);
91     return strlen(value);
92 }
93 #endif /* FEATURE_EXTERNAL_AP */
94 
95 #ifdef __cplusplus
96 }
97 #endif /*__cplusplus */
98 
99 #endif /* __LOC_PLA__ */
100