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