1 /* Copyright (c) 2011-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
30 #define LOG_NDDEBUG 0
31 #define LOG_TAG "LocSvc_core_log"
32
33 #include <loc_log.h>
34 #include <log_util.h>
35 #include <loc_core_log.h>
36
logv() const37 void LocPosMode::logv() const
38 {
39 LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n "
40 "min interval: %d\n preferred accuracy: %d\n "
41 "preferred time: %d\n credentials: %s provider: %s",
42 loc_get_position_mode_name(mode),
43 loc_get_position_recurrence_name(recurrence),
44 min_interval,
45 preferred_accuracy,
46 preferred_time,
47 credentials,
48 provider);
49 }
50
51 /* GPS status names */
52 static loc_name_val_s_type gps_status_name[] =
53 {
54 NAME_VAL( GPS_STATUS_NONE ),
55 NAME_VAL( GPS_STATUS_SESSION_BEGIN ),
56 NAME_VAL( GPS_STATUS_SESSION_END ),
57 NAME_VAL( GPS_STATUS_ENGINE_ON ),
58 NAME_VAL( GPS_STATUS_ENGINE_OFF ),
59 };
60 static int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type);
61
62 /* Find Android GPS status name */
loc_get_gps_status_name(GpsStatusValue gps_status)63 const char* loc_get_gps_status_name(GpsStatusValue gps_status)
64 {
65 return loc_get_name_from_val(gps_status_name, gps_status_num,
66 (long) gps_status);
67 }
68
69
70
71 static loc_name_val_s_type loc_eng_position_modes[] =
72 {
73 NAME_VAL( LOC_POSITION_MODE_STANDALONE ),
74 NAME_VAL( LOC_POSITION_MODE_MS_BASED ),
75 NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ),
76 NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ),
77 NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ),
78 NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ),
79 NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ),
80 NAME_VAL( LOC_POSITION_MODE_RESERVED_5 )
81 };
82 static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
83
loc_get_position_mode_name(GpsPositionMode mode)84 const char* loc_get_position_mode_name(GpsPositionMode mode)
85 {
86 return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
87 }
88
89
90
91 static loc_name_val_s_type loc_eng_position_recurrences[] =
92 {
93 NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ),
94 NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE )
95 };
96 static int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);
97
loc_get_position_recurrence_name(GpsPositionRecurrence recur)98 const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur)
99 {
100 return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
101 }
102
103
104
105 static loc_name_val_s_type loc_eng_aiding_data_bits[] =
106 {
107 NAME_VAL( GPS_DELETE_EPHEMERIS ),
108 NAME_VAL( GPS_DELETE_ALMANAC ),
109 NAME_VAL( GPS_DELETE_POSITION ),
110 NAME_VAL( GPS_DELETE_TIME ),
111 NAME_VAL( GPS_DELETE_IONO ),
112 NAME_VAL( GPS_DELETE_UTC ),
113 NAME_VAL( GPS_DELETE_HEALTH ),
114 NAME_VAL( GPS_DELETE_SVDIR ),
115 NAME_VAL( GPS_DELETE_SVSTEER ),
116 NAME_VAL( GPS_DELETE_SADATA ),
117 NAME_VAL( GPS_DELETE_RTI ),
118 NAME_VAL( GPS_DELETE_CELLDB_INFO ),
119 #ifndef PDK_FEATURE_SET
120 NAME_VAL( GPS_DELETE_ALMANAC_CORR ),
121 NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
122 NAME_VAL( GLO_DELETE_EPHEMERIS ),
123 NAME_VAL( GLO_DELETE_ALMANAC ),
124 NAME_VAL( GLO_DELETE_SVDIR ),
125 NAME_VAL( GLO_DELETE_SVSTEER ),
126 NAME_VAL( GLO_DELETE_ALMANAC_CORR ),
127 NAME_VAL( GPS_DELETE_TIME_GPS ),
128 NAME_VAL( GLO_DELETE_TIME ),
129 NAME_VAL( BDS_DELETE_SVDIR ),
130 NAME_VAL( BDS_DELETE_SVSTEER ),
131 NAME_VAL( BDS_DELETE_TIME ),
132 NAME_VAL( BDS_DELETE_ALMANAC_CORR ),
133 NAME_VAL( BDS_DELETE_EPHEMERIS ),
134 NAME_VAL( BDS_DELETE_ALMANAC ),
135 #endif
136 NAME_VAL( GPS_DELETE_ALL)
137 };
138 static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
139
loc_get_aiding_data_mask_names(GpsAidingData data)140 const char* loc_get_aiding_data_mask_names(GpsAidingData data)
141 {
142 return NULL;
143 }
144
145
146 static loc_name_val_s_type loc_eng_agps_types[] =
147 {
148 NAME_VAL( AGPS_TYPE_INVALID ),
149 NAME_VAL( AGPS_TYPE_ANY ),
150 NAME_VAL( AGPS_TYPE_SUPL ),
151 NAME_VAL( AGPS_TYPE_C2K ),
152 NAME_VAL( AGPS_TYPE_WWAN_ANY )
153 };
154 static int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);
155
loc_get_agps_type_name(AGpsType type)156 const char* loc_get_agps_type_name(AGpsType type)
157 {
158 return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
159 }
160
161
162 static loc_name_val_s_type loc_eng_ni_types[] =
163 {
164 NAME_VAL( GPS_NI_TYPE_VOICE ),
165 NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
166 NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ),
167 NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL )
168 };
169 static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
170
loc_get_ni_type_name(GpsNiType type)171 const char* loc_get_ni_type_name(GpsNiType type)
172 {
173 return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
174 }
175
176
177 static loc_name_val_s_type loc_eng_ni_responses[] =
178 {
179 NAME_VAL( GPS_NI_RESPONSE_ACCEPT ),
180 NAME_VAL( GPS_NI_RESPONSE_DENY ),
181 NAME_VAL( GPS_NI_RESPONSE_DENY )
182 };
183 static int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);
184
loc_get_ni_response_name(GpsUserResponseType response)185 const char* loc_get_ni_response_name(GpsUserResponseType response)
186 {
187 return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
188 }
189
190
191 static loc_name_val_s_type loc_eng_ni_encodings[] =
192 {
193 NAME_VAL( GPS_ENC_NONE ),
194 NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ),
195 NAME_VAL( GPS_ENC_SUPL_UTF8 ),
196 NAME_VAL( GPS_ENC_SUPL_UCS2 ),
197 NAME_VAL( GPS_ENC_UNKNOWN )
198 };
199 static int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);
200
loc_get_ni_encoding_name(GpsNiEncodingType encoding)201 const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding)
202 {
203 return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
204 }
205
206 static loc_name_val_s_type loc_eng_agps_bears[] =
207 {
208 NAME_VAL( AGPS_APN_BEARER_INVALID ),
209 NAME_VAL( AGPS_APN_BEARER_IPV4 ),
210 NAME_VAL( AGPS_APN_BEARER_IPV6 ),
211 NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
212 };
213 static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);
214
loc_get_agps_bear_name(AGpsBearerType bearer)215 const char* loc_get_agps_bear_name(AGpsBearerType bearer)
216 {
217 return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer);
218 }
219
220 static loc_name_val_s_type loc_eng_server_types[] =
221 {
222 NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ),
223 NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ),
224 NAME_VAL( LOC_AGPS_MPC_SERVER ),
225 NAME_VAL( LOC_AGPS_SUPL_SERVER )
226 };
227 static int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type);
228
loc_get_server_type_name(LocServerType type)229 const char* loc_get_server_type_name(LocServerType type)
230 {
231 return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type);
232 }
233
234 static loc_name_val_s_type loc_eng_position_sess_status_types[] =
235 {
236 NAME_VAL( LOC_SESS_SUCCESS ),
237 NAME_VAL( LOC_SESS_INTERMEDIATE ),
238 NAME_VAL( LOC_SESS_FAILURE )
239 };
240 static int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type);
241
loc_get_position_sess_status_name(enum loc_sess_status status)242 const char* loc_get_position_sess_status_name(enum loc_sess_status status)
243 {
244 return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status);
245 }
246
247 static loc_name_val_s_type loc_eng_agps_status_names[] =
248 {
249 NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ),
250 NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ),
251 NAME_VAL( GPS_AGPS_DATA_CONNECTED ),
252 NAME_VAL( GPS_AGPS_DATA_CONN_DONE ),
253 NAME_VAL( GPS_AGPS_DATA_CONN_FAILED )
254 };
255 static int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type);
256
loc_get_agps_status_name(AGpsStatusValue status)257 const char* loc_get_agps_status_name(AGpsStatusValue status)
258 {
259 return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
260 }
261