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 37 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 */ 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 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 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 NAME_VAL( GPS_DELETE_ALMANAC_CORR ), 120 NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ), 121 NAME_VAL( GPS_DELETE_EPHEMERIS_GLO ), 122 NAME_VAL( GPS_DELETE_ALMANAC_GLO ), 123 NAME_VAL( GPS_DELETE_SVDIR_GLO ), 124 NAME_VAL( GPS_DELETE_SVSTEER_GLO ), 125 NAME_VAL( GPS_DELETE_ALMANAC_CORR_GLO ), 126 NAME_VAL( GPS_DELETE_TIME_GPS ), 127 NAME_VAL( GPS_DELETE_TIME_GLO ) 128 }; 129 static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type); 130 131 const char* loc_get_aiding_data_mask_names(GpsAidingData data) 132 { 133 return NULL; 134 } 135 136 137 static loc_name_val_s_type loc_eng_agps_types[] = 138 { 139 NAME_VAL( AGPS_TYPE_INVALID ), 140 NAME_VAL( AGPS_TYPE_ANY ), 141 NAME_VAL( AGPS_TYPE_SUPL ), 142 NAME_VAL( AGPS_TYPE_C2K ), 143 NAME_VAL( AGPS_TYPE_WWAN_ANY ) 144 }; 145 static int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type); 146 147 const char* loc_get_agps_type_name(AGpsType type) 148 { 149 return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type); 150 } 151 152 153 static loc_name_val_s_type loc_eng_ni_types[] = 154 { 155 NAME_VAL( GPS_NI_TYPE_VOICE ), 156 NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ), 157 NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ), 158 NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL ) 159 }; 160 static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type); 161 162 const char* loc_get_ni_type_name(GpsNiType type) 163 { 164 return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type); 165 } 166 167 168 static loc_name_val_s_type loc_eng_ni_responses[] = 169 { 170 NAME_VAL( GPS_NI_RESPONSE_ACCEPT ), 171 NAME_VAL( GPS_NI_RESPONSE_DENY ), 172 NAME_VAL( GPS_NI_RESPONSE_DENY ) 173 }; 174 static int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type); 175 176 const char* loc_get_ni_response_name(GpsUserResponseType response) 177 { 178 return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response); 179 } 180 181 182 static loc_name_val_s_type loc_eng_ni_encodings[] = 183 { 184 NAME_VAL( GPS_ENC_NONE ), 185 NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ), 186 NAME_VAL( GPS_ENC_SUPL_UTF8 ), 187 NAME_VAL( GPS_ENC_SUPL_UCS2 ), 188 NAME_VAL( GPS_ENC_UNKNOWN ) 189 }; 190 static int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type); 191 192 const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding) 193 { 194 return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding); 195 } 196 197 static loc_name_val_s_type loc_eng_agps_bears[] = 198 { 199 NAME_VAL( AGPS_APN_BEARER_INVALID ), 200 NAME_VAL( AGPS_APN_BEARER_IPV4 ), 201 NAME_VAL( AGPS_APN_BEARER_IPV6 ), 202 NAME_VAL( AGPS_APN_BEARER_IPV4V6 ) 203 }; 204 static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type); 205 206 const char* loc_get_agps_bear_name(AGpsBearerType bearer) 207 { 208 return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer); 209 } 210 211 static loc_name_val_s_type loc_eng_server_types[] = 212 { 213 NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ), 214 NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ), 215 NAME_VAL( LOC_AGPS_MPC_SERVER ), 216 NAME_VAL( LOC_AGPS_SUPL_SERVER ) 217 }; 218 static int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type); 219 220 const char* loc_get_server_type_name(LocServerType type) 221 { 222 return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type); 223 } 224 225 static loc_name_val_s_type loc_eng_position_sess_status_types[] = 226 { 227 NAME_VAL( LOC_SESS_SUCCESS ), 228 NAME_VAL( LOC_SESS_INTERMEDIATE ), 229 NAME_VAL( LOC_SESS_FAILURE ) 230 }; 231 static int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type); 232 233 const char* loc_get_position_sess_status_name(enum loc_sess_status status) 234 { 235 return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status); 236 } 237 238 static loc_name_val_s_type loc_eng_agps_status_names[] = 239 { 240 NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ), 241 NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ), 242 NAME_VAL( GPS_AGPS_DATA_CONNECTED ), 243 NAME_VAL( GPS_AGPS_DATA_CONN_DONE ), 244 NAME_VAL( GPS_AGPS_DATA_CONN_FAILED ) 245 }; 246 static int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type); 247 248 const char* loc_get_agps_status_name(AGpsStatusValue status) 249 { 250 return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status); 251 } 252