diff options
-rw-r--r-- | gps/core/ContextBase.cpp | 21 | ||||
-rw-r--r-- | gps/core/ContextBase.h | 64 | ||||
-rw-r--r-- | gps/core/LocAdapterProxyBase.h | 6 | ||||
-rw-r--r-- | gps/core/gps_extended_c.h | 3 | ||||
-rw-r--r-- | gps/core/loc_core_log.cpp | 50 | ||||
-rw-r--r-- | gps/loc_api/Android.mk | 19 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/Android.mk (renamed from gps/libloc_api_50001/Android.mk) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/LocEngAdapter.cpp (renamed from gps/libloc_api_50001/LocEngAdapter.cpp) | 62 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/LocEngAdapter.h (renamed from gps/libloc_api_50001/LocEngAdapter.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/Makefile.am (renamed from gps/libloc_api_50001/Makefile.am) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/gps.c (renamed from gps/libloc_api_50001/gps.c) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc.cpp (renamed from gps/libloc_api_50001/loc.cpp) | 2 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc.h (renamed from gps/libloc_api_50001/loc.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng.cpp (renamed from gps/libloc_api_50001/loc_eng.cpp) | 29 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng.h (renamed from gps/libloc_api_50001/loc_eng.h) | 65 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_agps.cpp (renamed from gps/libloc_api_50001/loc_eng_agps.cpp) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_agps.h (renamed from gps/libloc_api_50001/loc_eng_agps.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp (renamed from gps/libloc_api_50001/loc_eng_dmn_conn.cpp) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_handler.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h (renamed from gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_log.cpp (renamed from gps/libloc_api_50001/loc_eng_log.cpp) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_log.h (renamed from gps/libloc_api_50001/loc_eng_log.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_msg.h (renamed from gps/libloc_api_50001/loc_eng_msg.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_ni.cpp (renamed from gps/libloc_api_50001/loc_eng_ni.cpp) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_ni.h (renamed from gps/libloc_api_50001/loc_eng_ni.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp (renamed from gps/libloc_api_50001/loc_eng_nmea.cpp) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_nmea.h (renamed from gps/libloc_api_50001/loc_eng_nmea.h) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp (renamed from gps/libloc_api_50001/loc_eng_xtra.cpp) | 0 | ||||
-rw-r--r-- | gps/loc_api/libloc_api_50001/loc_eng_xtra.h (renamed from gps/libloc_api_50001/loc_eng_xtra.h) | 0 | ||||
-rw-r--r-- | gps/utils/LocSharedLock.h | 7 | ||||
-rw-r--r-- | gps/utils/MsgTask.cpp | 2 | ||||
-rw-r--r-- | gps/utils/linked_list.c | 6 | ||||
-rw-r--r-- | gps/utils/loc_cfg.cpp | 16 | ||||
-rw-r--r-- | gps/utils/loc_cfg.h | 10 | ||||
-rw-r--r-- | gps/utils/loc_log.cpp | 22 | ||||
-rw-r--r-- | gps/utils/loc_log.h | 17 | ||||
-rw-r--r-- | gps/utils/msg_q.c | 8 |
44 files changed, 247 insertions, 162 deletions
diff --git a/gps/core/ContextBase.cpp b/gps/core/ContextBase.cpp index 9f6c4aa..971354d 100644 --- a/gps/core/ContextBase.cpp +++ b/gps/core/ContextBase.cpp @@ -40,6 +40,27 @@ namespace loc_core { +loc_gps_cfg_s_type ContextBase::mGps_conf {0}; +loc_sap_cfg_s_type ContextBase::mSap_conf {0}; + +uint32_t ContextBase::getCarrierCapabilities() { + #define carrierMSA (uint32_t)0x2 + #define carrierMSB (uint32_t)0x1 + #define gpsConfMSA (uint32_t)0x4 + #define gpsConfMSB (uint32_t)0x2 + uint32_t capabilities = mGps_conf.CAPABILITIES; + if ((mGps_conf.SUPL_MODE & carrierMSA) != carrierMSA) { + capabilities &= ~gpsConfMSA; + } + if ((mGps_conf.SUPL_MODE & carrierMSB) != carrierMSB) { + capabilities &= ~gpsConfMSB; + } + + LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x", + mGps_conf.CAPABILITIES, mGps_conf.SUPL_MODE, capabilities); + return capabilities; +} + LBSProxyBase* ContextBase::getLBSProxy(const char* libName) { LBSProxyBase* proxy = NULL; diff --git a/gps/core/ContextBase.h b/gps/core/ContextBase.h index fe0b860..bd9a19f 100644 --- a/gps/core/ContextBase.h +++ b/gps/core/ContextBase.h @@ -35,6 +35,64 @@ #include <LocApiBase.h> #include <LBSProxyBase.h> +#define MAX_XTRA_SERVER_URL_LENGTH 256 + +/* GPS.conf support */ +/* NOTE: the implementaiton of the parser casts number + fields to 32 bit. To ensure all 'n' fields working, + they must all be 32 bit fields. */ +typedef struct loc_gps_cfg_s +{ + uint32_t INTERMEDIATE_POS; + uint32_t ACCURACY_THRES; + uint32_t SUPL_VER; + uint32_t SUPL_MODE; + uint32_t CAPABILITIES; + uint32_t LPP_PROFILE; + uint32_t XTRA_VERSION_CHECK; + char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH]; + char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH]; + uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL; + uint32_t NMEA_PROVIDER; + uint32_t GPS_LOCK; + uint32_t A_GLONASS_POS_PROTOCOL_SELECT; + uint32_t AGPS_CERT_WRITABLE_MASK; +} loc_gps_cfg_s_type; + +/* NOTE: the implementaiton of the parser casts number + fields to 32 bit. To ensure all 'n' fields working, + they must all be 32 bit fields. */ +/* Meanwhile, *_valid fields are 8 bit fields, and 'f' + fields are double. Rigid as they are, it is the + the status quo, until the parsing mechanism is + change, that is. */ +typedef struct +{ + uint8_t GYRO_BIAS_RANDOM_WALK_VALID; + double GYRO_BIAS_RANDOM_WALK; + uint32_t SENSOR_ACCEL_BATCHES_PER_SEC; + uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH; + uint32_t SENSOR_GYRO_BATCHES_PER_SEC; + uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH; + uint32_t SENSOR_ACCEL_BATCHES_PER_SEC_HIGH; + uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH; + uint32_t SENSOR_GYRO_BATCHES_PER_SEC_HIGH; + uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH; + uint32_t SENSOR_CONTROL_MODE; + uint32_t SENSOR_USAGE; + uint32_t SENSOR_ALGORITHM_CONFIG_MASK; + uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double RATE_RANDOM_WALK_SPECTRAL_DENSITY; + uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID; + double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY; + uint32_t SENSOR_PROVIDER; +} loc_sap_cfg_s_type; + namespace loc_core { class LocAdapterBase; @@ -67,6 +125,12 @@ public: return mLBSProxy->getIzatDevId(); } inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } + + static loc_gps_cfg_s_type mGps_conf; + static loc_sap_cfg_s_type mSap_conf; + + static uint32_t getCarrierCapabilities(); + }; } // namespace loc_core diff --git a/gps/core/LocAdapterProxyBase.h b/gps/core/LocAdapterProxyBase.h index 1ddcca4..e1d0ccf 100644 --- a/gps/core/LocAdapterProxyBase.h +++ b/gps/core/LocAdapterProxyBase.h @@ -46,15 +46,15 @@ protected: inline virtual ~LocAdapterProxyBase() { delete mLocAdapterBase; } - ContextBase* getContext() const { - return mLocAdapterBase->getContext(); - } inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, loc_registration_mask_status isEnabled) { mLocAdapterBase->updateEvtMask(event,isEnabled); } public: + inline ContextBase* getContext() const { + return mLocAdapterBase->getContext(); + } inline virtual void handleEngineUpEvent() {}; inline virtual void handleEngineDownEvent() {}; inline virtual bool reportPosition(UlpLocation &location, diff --git a/gps/core/gps_extended_c.h b/gps/core/gps_extended_c.h index 27deb44..75ee17e 100644 --- a/gps/core/gps_extended_c.h +++ b/gps/core/gps_extended_c.h @@ -378,6 +378,7 @@ enum loc_api_adapter_event_index { LOC_API_ADAPTER_GDT_UPLOAD_END_REQ, // GDT upload end request LOC_API_ADAPTER_GNSS_MEASUREMENT, // GNSS Measurement report LOC_API_ADAPTER_REQUEST_TIMEZONE, // Timezone injection request + LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT, // Geofence dwell report LOC_API_ADAPTER_EVENT_MAX }; @@ -407,6 +408,7 @@ enum loc_api_adapter_event_index { #define LOC_API_ADAPTER_BIT_GDT_UPLOAD_END_REQ (1<<LOC_API_ADAPTER_GDT_UPLOAD_END_REQ) #define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT) #define LOC_API_ADAPTER_BIT_REQUEST_TIMEZONE (1<<LOC_API_ADAPTER_REQUEST_TIMEZONE) +#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_DWELL (1<<LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT) typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T; @@ -416,6 +418,7 @@ typedef enum loc_api_adapter_msg_to_check_supported { LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING, // DBT 2.0 LOC_API_ADAPTER_MESSAGE_ADAPTIVE_LOCATION_BATCHING, // Batching 1.5 LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING, // Batching 2.0 + LOC_API_ADAPTER_MESSAGE_UPDATE_TBF_ON_THE_FLY, // Updating Tracking TBF On The Fly LOC_API_ADAPTER_MESSAGE_MAX } LocCheckingMessagesID; diff --git a/gps/core/loc_core_log.cpp b/gps/core/loc_core_log.cpp index 216dd59..3ca6c0a 100644 --- a/gps/core/loc_core_log.cpp +++ b/gps/core/loc_core_log.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2015, 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 @@ -49,7 +49,7 @@ void LocPosMode::logv() const } /* GPS status names */ -static loc_name_val_s_type gps_status_name[] = +static const loc_name_val_s_type gps_status_name[] = { NAME_VAL( GPS_STATUS_NONE ), NAME_VAL( GPS_STATUS_SESSION_BEGIN ), @@ -57,7 +57,7 @@ static loc_name_val_s_type gps_status_name[] = NAME_VAL( GPS_STATUS_ENGINE_ON ), NAME_VAL( GPS_STATUS_ENGINE_OFF ), }; -static int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type); +static const int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type); /* Find Android GPS status name */ const char* loc_get_gps_status_name(GpsStatusValue gps_status) @@ -68,7 +68,7 @@ const char* loc_get_gps_status_name(GpsStatusValue gps_status) -static loc_name_val_s_type loc_eng_position_modes[] = +static const loc_name_val_s_type loc_eng_position_modes[] = { NAME_VAL( LOC_POSITION_MODE_STANDALONE ), NAME_VAL( LOC_POSITION_MODE_MS_BASED ), @@ -79,7 +79,7 @@ static loc_name_val_s_type loc_eng_position_modes[] = NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ), NAME_VAL( LOC_POSITION_MODE_RESERVED_5 ) }; -static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type); +static const int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type); const char* loc_get_position_mode_name(GpsPositionMode mode) { @@ -88,12 +88,12 @@ const char* loc_get_position_mode_name(GpsPositionMode mode) -static loc_name_val_s_type loc_eng_position_recurrences[] = +static const loc_name_val_s_type loc_eng_position_recurrences[] = { NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ), NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE ) }; -static int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type); +static const int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type); const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur) { @@ -102,7 +102,7 @@ const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur) -static loc_name_val_s_type loc_eng_aiding_data_bits[] = +static const loc_name_val_s_type loc_eng_aiding_data_bits[] = { NAME_VAL( GPS_DELETE_EPHEMERIS ), NAME_VAL( GPS_DELETE_ALMANAC ), @@ -118,7 +118,7 @@ static loc_name_val_s_type loc_eng_aiding_data_bits[] = NAME_VAL( GPS_DELETE_CELLDB_INFO ), NAME_VAL( GPS_DELETE_ALL) }; -static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type); +static const int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type); const char* loc_get_aiding_data_mask_names(GpsAidingData data) { @@ -126,7 +126,7 @@ const char* loc_get_aiding_data_mask_names(GpsAidingData data) } -static loc_name_val_s_type loc_eng_agps_types[] = +static const loc_name_val_s_type loc_eng_agps_types[] = { NAME_VAL( AGPS_TYPE_INVALID ), NAME_VAL( AGPS_TYPE_ANY ), @@ -134,7 +134,7 @@ static loc_name_val_s_type loc_eng_agps_types[] = NAME_VAL( AGPS_TYPE_C2K ), NAME_VAL( AGPS_TYPE_WWAN_ANY ) }; -static int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type); +static const int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type); const char* loc_get_agps_type_name(AGpsType type) { @@ -142,14 +142,14 @@ const char* loc_get_agps_type_name(AGpsType type) } -static loc_name_val_s_type loc_eng_ni_types[] = +static const loc_name_val_s_type loc_eng_ni_types[] = { NAME_VAL( GPS_NI_TYPE_VOICE ), NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ), NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ), NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL ) }; -static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type); +static const int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type); const char* loc_get_ni_type_name(GpsNiType type) { @@ -157,13 +157,13 @@ const char* loc_get_ni_type_name(GpsNiType type) } -static loc_name_val_s_type loc_eng_ni_responses[] = +static const loc_name_val_s_type loc_eng_ni_responses[] = { NAME_VAL( GPS_NI_RESPONSE_ACCEPT ), NAME_VAL( GPS_NI_RESPONSE_DENY ), NAME_VAL( GPS_NI_RESPONSE_DENY ) }; -static int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type); +static const int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type); const char* loc_get_ni_response_name(GpsUserResponseType response) { @@ -171,7 +171,7 @@ const char* loc_get_ni_response_name(GpsUserResponseType response) } -static loc_name_val_s_type loc_eng_ni_encodings[] = +static const loc_name_val_s_type loc_eng_ni_encodings[] = { NAME_VAL( GPS_ENC_NONE ), NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ), @@ -179,55 +179,55 @@ static loc_name_val_s_type loc_eng_ni_encodings[] = NAME_VAL( GPS_ENC_SUPL_UCS2 ), NAME_VAL( GPS_ENC_UNKNOWN ) }; -static int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type); +static const int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type); const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding) { return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding); } -static loc_name_val_s_type loc_eng_agps_bears[] = +static const loc_name_val_s_type loc_eng_agps_bears[] = { NAME_VAL( AGPS_APN_BEARER_INVALID ), NAME_VAL( AGPS_APN_BEARER_IPV4 ), NAME_VAL( AGPS_APN_BEARER_IPV6 ), NAME_VAL( AGPS_APN_BEARER_IPV4V6 ) }; -static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type); +static const int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type); const char* loc_get_agps_bear_name(AGpsBearerType bearer) { return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer); } -static loc_name_val_s_type loc_eng_server_types[] = +static const loc_name_val_s_type loc_eng_server_types[] = { NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ), NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ), NAME_VAL( LOC_AGPS_MPC_SERVER ), NAME_VAL( LOC_AGPS_SUPL_SERVER ) }; -static int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type); +static const int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type); const char* loc_get_server_type_name(LocServerType type) { return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type); } -static loc_name_val_s_type loc_eng_position_sess_status_types[] = +static const loc_name_val_s_type loc_eng_position_sess_status_types[] = { NAME_VAL( LOC_SESS_SUCCESS ), NAME_VAL( LOC_SESS_INTERMEDIATE ), NAME_VAL( LOC_SESS_FAILURE ) }; -static int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type); +static const int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type); const char* loc_get_position_sess_status_name(enum loc_sess_status status) { return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status); } -static loc_name_val_s_type loc_eng_agps_status_names[] = +static const loc_name_val_s_type loc_eng_agps_status_names[] = { NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ), NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ), @@ -235,7 +235,7 @@ static loc_name_val_s_type loc_eng_agps_status_names[] = NAME_VAL( GPS_AGPS_DATA_CONN_DONE ), NAME_VAL( GPS_AGPS_DATA_CONN_FAILED ) }; -static int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type); +static const int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type); const char* loc_get_agps_status_name(AGpsStatusValue status) { diff --git a/gps/loc_api/Android.mk b/gps/loc_api/Android.mk new file mode 100644 index 0000000..ca5347d --- /dev/null +++ b/gps/loc_api/Android.mk @@ -0,0 +1,19 @@ +# +# Copyright (C) 2016 The CyanogenMod Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH := $(call my-dir) + +include $(call all-subdir-makefiles,$(LOCAL_PATH)) diff --git a/gps/libloc_api_50001/Android.mk b/gps/loc_api/libloc_api_50001/Android.mk index 0c6d22d..0c6d22d 100644 --- a/gps/libloc_api_50001/Android.mk +++ b/gps/loc_api/libloc_api_50001/Android.mk diff --git a/gps/libloc_api_50001/LocEngAdapter.cpp b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp index bea21d9..e0f21ec 100644 --- a/gps/libloc_api_50001/LocEngAdapter.cpp +++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.cpp @@ -101,7 +101,6 @@ void LocEngAdapter::setXtraUserAgent() { char release[PROPERTY_VALUE_MAX]; char manufacture[PROPERTY_VALUE_MAX]; char model[PROPERTY_VALUE_MAX]; - char carrier[PROPERTY_VALUE_MAX]; char board[PROPERTY_VALUE_MAX]; char brand[PROPERTY_VALUE_MAX]; char chipsetsn[CHIPSET_SERIAL_NUMBER_MAX_LEN]; @@ -111,13 +110,18 @@ void LocEngAdapter::setXtraUserAgent() { property_get("ro.build.version.release", release, defVal); property_get("ro.product.manufacturer", manufacture, defVal); property_get("ro.product.model", model, defVal); - property_get("ro.carrier", carrier, defVal); property_get("ro.product.board", board, defVal); property_get("ro.product.brand", brand, defVal); getChipsetSerialNo(chipsetsn, sizeof(chipsetsn), defVal); - snprintf(userAgent, sizeof(userAgent), "A/%s/%s/%s/%s/%s/QCX3/s%u/-/%s/-/%s/-/-/-", - release, manufacture, model, board, carrier, + encodeInPlace(release, PROPERTY_VALUE_MAX); + encodeInPlace(manufacture, PROPERTY_VALUE_MAX); + encodeInPlace(model, PROPERTY_VALUE_MAX); + encodeInPlace(board, PROPERTY_VALUE_MAX); + encodeInPlace(brand, PROPERTY_VALUE_MAX); + + snprintf(userAgent, sizeof(userAgent), "A/%s/%s/%s/%s/-/QCX3/s%u/-/%s/-/%s/-/-/-", + release, manufacture, model, board, mContext->getIzatDevId(), chipsetsn, brand); for (int i = 0; i < sizeof(userAgent) && userAgent[i]; i++) { @@ -201,6 +205,56 @@ void LocEngAdapter::setXtraUserAgent() { return; } + /** + * encode the given string value such that all separator characters ('/','+','|','%') + * in the string are repaced by their corresponding encodings (%2F","%2B","%7C", "%25") + */ + static void encodeInPlace(char value[], const int size) { + char buffer[size]; + + struct ENCODE { + const char ch; + const char *code; + }; + + const ENCODE encodings[] = { {'/', "%2F"}, {'+', "%2B"}, {'|', "%7C",}, {'%', "%25"} }; + const int nencodings = (int)sizeof(encodings) / sizeof(encodings[0]); + + int inpos = 0, outpos = 0; + while(value[inpos] != '\0' && outpos < size - 1) { + // check if escaped character + int escchar = 0; + while(escchar < nencodings && encodings[escchar].ch != value[inpos]) { + escchar++; + } + + if (escchar == nencodings) { + // non escaped character + buffer[outpos++] = value[inpos++]; + continue; + } + + // escaped character + int codepos = 0; + #define NUM_CHARS_IN_CODE 3 + + if (outpos + NUM_CHARS_IN_CODE >= size) { + // skip last character if there is insufficient space + break; + } + + while(outpos < size - 1 && codepos < NUM_CHARS_IN_CODE) { + buffer[outpos++] = encodings[escchar].code[codepos++]; + } + inpos++; + } + + // copy to ouput + value[outpos] = '\0'; + while(--outpos >= 0) { + value[outpos] = buffer[outpos]; + } + } }; sendMsg(new LocSetXtraUserAgent(mContext)); diff --git a/gps/libloc_api_50001/LocEngAdapter.h b/gps/loc_api/libloc_api_50001/LocEngAdapter.h index a193e81..a193e81 100644 --- a/gps/libloc_api_50001/LocEngAdapter.h +++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.h diff --git a/gps/libloc_api_50001/Makefile.am b/gps/loc_api/libloc_api_50001/Makefile.am index 2374357..2374357 100644 --- a/gps/libloc_api_50001/Makefile.am +++ b/gps/loc_api/libloc_api_50001/Makefile.am diff --git a/gps/libloc_api_50001/gps.c b/gps/loc_api/libloc_api_50001/gps.c index 29f20f4..29f20f4 100644 --- a/gps/libloc_api_50001/gps.c +++ b/gps/loc_api/libloc_api_50001/gps.c diff --git a/gps/libloc_api_50001/loc.cpp b/gps/loc_api/libloc_api_50001/loc.cpp index 505fc94..d322a72 100644 --- a/gps/libloc_api_50001/loc.cpp +++ b/gps/loc_api/libloc_api_50001/loc.cpp @@ -314,7 +314,7 @@ static int loc_init(GpsCallbacks* callbacks) loc_afw_data.adapter->mSupportsPositionInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities(); loc_afw_data.adapter->mSupportsTimeInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities(); loc_afw_data.adapter->setGpsLockMsg(0); - loc_afw_data.adapter->requestUlp(getCarrierCapabilities()); + loc_afw_data.adapter->requestUlp(ContextBase::getCarrierCapabilities()); loc_afw_data.adapter->setXtraUserAgent(); if(retVal) { diff --git a/gps/libloc_api_50001/loc.h b/gps/loc_api/libloc_api_50001/loc.h index e56fdcf..e56fdcf 100644 --- a/gps/libloc_api_50001/loc.h +++ b/gps/loc_api/libloc_api_50001/loc.h diff --git a/gps/libloc_api_50001/loc_eng.cpp b/gps/loc_api/libloc_api_50001/loc_eng.cpp index 5d92e44..c06206b 100644 --- a/gps/libloc_api_50001/loc_eng.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2009-2015, 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 @@ -90,11 +90,9 @@ using namespace loc_core; boolean configAlreadyRead = false; unsigned int agpsStatus = 0; -loc_gps_cfg_s_type gps_conf; -loc_sap_cfg_s_type sap_conf; /* Parameter spec table */ -static loc_param_s_type gps_conf_table[] = +static const loc_param_s_type gps_conf_table[] = { {"GPS_LOCK", &gps_conf.GPS_LOCK, NULL, 'n'}, {"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'}, @@ -113,7 +111,7 @@ static loc_param_s_type gps_conf_table[] = {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'}, }; -static loc_param_s_type sap_conf_table[] = +static const loc_param_s_type sap_conf_table[] = { {"GYRO_BIAS_RANDOM_WALK", &sap_conf.GYRO_BIAS_RANDOM_WALK, &sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'}, {"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'}, @@ -500,7 +498,7 @@ struct LocEngSuplMode : public LocMsg { locallog(); } inline virtual void proc() const { - mUlp->setCapabilities(getCarrierCapabilities()); + mUlp->setCapabilities(ContextBase::getCarrierCapabilities()); } inline void locallog() const { } @@ -1684,24 +1682,6 @@ inline void LocEngReportGpsMeasurement::log() const { } #define INIT_CHECK(ctx, ret) STATE_CHECK(ctx, "instance not initialized", ret) -uint32_t getCarrierCapabilities() { - #define carrierMSA (uint32_t)0x2 - #define carrierMSB (uint32_t)0x1 - #define gpsConfMSA (uint32_t)0x4 - #define gpsConfMSB (uint32_t)0x2 - uint32_t capabilities = gps_conf.CAPABILITIES; - if ((gps_conf.SUPL_MODE & carrierMSA) != carrierMSA) { - capabilities &= ~gpsConfMSA; - } - if ((gps_conf.SUPL_MODE & carrierMSB) != carrierMSB) { - capabilities &= ~gpsConfMSB; - } - - LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x", - gps_conf.CAPABILITIES, gps_conf.SUPL_MODE, capabilities); - return capabilities; -} - /*=========================================================================== FUNCTION loc_eng_init @@ -2736,6 +2716,7 @@ void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data, gps_conf_tmp.SUPL_VER = gps_conf.SUPL_VER; gps_conf_tmp.LPP_PROFILE = gps_conf.LPP_PROFILE; gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT = gps_conf.A_GLONASS_POS_PROTOCOL_SELECT; + gps_conf_tmp.SUPL_MODE = gps_conf.SUPL_MODE; gps_conf_tmp.GPS_LOCK = gps_conf.GPS_LOCK; gps_conf = gps_conf_tmp; } diff --git a/gps/libloc_api_50001/loc_eng.h b/gps/loc_api/libloc_api_50001/loc_eng.h index a203e6b..6f90b23 100644 --- a/gps/libloc_api_50001/loc_eng.h +++ b/gps/loc_api/libloc_api_50001/loc_eng.h @@ -67,7 +67,8 @@ typedef unsigned char boolean; #define FAILURE FALSE #define INVALID_ATL_CONNECTION_HANDLE -1 -#define MAX_XTRA_SERVER_URL_LENGTH 256 +#define gps_conf ContextBase::mGps_conf +#define sap_conf ContextBase::mSap_conf enum loc_nmea_provider_e_type { NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA @@ -139,68 +140,6 @@ typedef struct loc_eng_data_s loc_ext_parser sv_ext_parser; } loc_eng_data_s_type; -/* GPS.conf support */ -/* NOTE: the implementaiton of the parser casts number - fields to 32 bit. To ensure all 'n' fields working, - they must all be 32 bit fields. */ -typedef struct loc_gps_cfg_s -{ - uint32_t INTERMEDIATE_POS; - uint32_t ACCURACY_THRES; - uint32_t SUPL_VER; - uint32_t SUPL_MODE; - uint32_t CAPABILITIES; - uint32_t LPP_PROFILE; - uint32_t XTRA_VERSION_CHECK; - char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH]; - char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH]; - char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH]; - uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL; - uint32_t NMEA_PROVIDER; - uint32_t GPS_LOCK; - uint32_t A_GLONASS_POS_PROTOCOL_SELECT; - uint32_t AGPS_CERT_WRITABLE_MASK; -} loc_gps_cfg_s_type; - -/* NOTE: the implementaiton of the parser casts number - fields to 32 bit. To ensure all 'n' fields working, - they must all be 32 bit fields. */ -/* Meanwhile, *_valid fields are 8 bit fields, and 'f' - fields are double. Rigid as they are, it is the - the status quo, until the parsing mechanism is - change, that is. */ -typedef struct -{ - uint8_t GYRO_BIAS_RANDOM_WALK_VALID; - double GYRO_BIAS_RANDOM_WALK; - uint32_t SENSOR_ACCEL_BATCHES_PER_SEC; - uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH; - uint32_t SENSOR_GYRO_BATCHES_PER_SEC; - uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH; - uint32_t SENSOR_ACCEL_BATCHES_PER_SEC_HIGH; - uint32_t SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH; - uint32_t SENSOR_GYRO_BATCHES_PER_SEC_HIGH; - uint32_t SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH; - uint32_t SENSOR_CONTROL_MODE; - uint32_t SENSOR_USAGE; - uint32_t SENSOR_ALGORITHM_CONFIG_MASK; - uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY; - uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY; - uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double RATE_RANDOM_WALK_SPECTRAL_DENSITY; - uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID; - double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY; - uint32_t SENSOR_PROVIDER; -} loc_sap_cfg_s_type; - -extern loc_gps_cfg_s_type gps_conf; -extern loc_sap_cfg_s_type sap_conf; - - -uint32_t getCarrierCapabilities(); - //loc_eng functions int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, diff --git a/gps/libloc_api_50001/loc_eng_agps.cpp b/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp index 5016b5c..5016b5c 100644 --- a/gps/libloc_api_50001/loc_eng_agps.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_agps.cpp diff --git a/gps/libloc_api_50001/loc_eng_agps.h b/gps/loc_api/libloc_api_50001/loc_eng_agps.h index 2d689ce..2d689ce 100644 --- a/gps/libloc_api_50001/loc_eng_agps.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_agps.h diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp index c257dff..c257dff 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h index 1d8c142..1d8c142 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c index a1076ff..a1076ff 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h index d685c87..d685c87 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c index dffcad0..dffcad0 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h index b2fa3a0..b2fa3a0 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp index edd53f2..edd53f2 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h index 1c0edd5..1c0edd5 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_handler.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c index 9fed9d4..9fed9d4 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c diff --git a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h index 89e598b..89e598b 100644 --- a/gps/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h diff --git a/gps/libloc_api_50001/loc_eng_log.cpp b/gps/loc_api/libloc_api_50001/loc_eng_log.cpp index 3a34167..3a34167 100644 --- a/gps/libloc_api_50001/loc_eng_log.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_log.cpp diff --git a/gps/libloc_api_50001/loc_eng_log.h b/gps/loc_api/libloc_api_50001/loc_eng_log.h index a68bd84..a68bd84 100644 --- a/gps/libloc_api_50001/loc_eng_log.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_log.h diff --git a/gps/libloc_api_50001/loc_eng_msg.h b/gps/loc_api/libloc_api_50001/loc_eng_msg.h index 9c7b9bc..9c7b9bc 100644 --- a/gps/libloc_api_50001/loc_eng_msg.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_msg.h diff --git a/gps/libloc_api_50001/loc_eng_ni.cpp b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp index 4597b98..4597b98 100644 --- a/gps/libloc_api_50001/loc_eng_ni.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_ni.cpp diff --git a/gps/libloc_api_50001/loc_eng_ni.h b/gps/loc_api/libloc_api_50001/loc_eng_ni.h index 068f5cd..068f5cd 100644 --- a/gps/libloc_api_50001/loc_eng_ni.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_ni.h diff --git a/gps/libloc_api_50001/loc_eng_nmea.cpp b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp index 126a97f..126a97f 100644 --- a/gps/libloc_api_50001/loc_eng_nmea.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp diff --git a/gps/libloc_api_50001/loc_eng_nmea.h b/gps/loc_api/libloc_api_50001/loc_eng_nmea.h index 066943a..066943a 100644 --- a/gps/libloc_api_50001/loc_eng_nmea.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_nmea.h diff --git a/gps/libloc_api_50001/loc_eng_xtra.cpp b/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp index 7bb8083..7bb8083 100644 --- a/gps/libloc_api_50001/loc_eng_xtra.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp diff --git a/gps/libloc_api_50001/loc_eng_xtra.h b/gps/loc_api/libloc_api_50001/loc_eng_xtra.h index 175f497..175f497 100644 --- a/gps/libloc_api_50001/loc_eng_xtra.h +++ b/gps/loc_api/libloc_api_50001/loc_eng_xtra.h diff --git a/gps/utils/LocSharedLock.h b/gps/utils/LocSharedLock.h index 6b9e27f..7fe6237 100644 --- a/gps/utils/LocSharedLock.h +++ b/gps/utils/LocSharedLock.h @@ -30,6 +30,7 @@ #define __LOC_SHARED_LOCK__ #include <stddef.h> +#include <cutils/atomic.h> #include <pthread.h> // This is a utility created for use cases such that there are more than @@ -39,16 +40,16 @@ // this share lock's share() method has to be called, so that the obj // can maintain an accurate client count. class LocSharedLock { - uint32_t mRef; + volatile int32_t mRef; pthread_mutex_t mMutex; inline ~LocSharedLock() { pthread_mutex_destroy(&mMutex); } public: // first client to create this LockSharedLock inline LocSharedLock() : mRef(1) { pthread_mutex_init(&mMutex, NULL); } // following client(s) are to *share()* this lock created by the first client - inline LocSharedLock* share() { mRef++; return this; } + inline LocSharedLock* share() { android_atomic_inc(&mRef); return this; } // whe a client no longer needs this shared lock, drop() shall be called. - inline void drop() { if (0 == --mRef) delete this; } + inline void drop() { if (1 == android_atomic_dec(&mRef)) delete this; } // locking the lock to enter critical section inline void lock() { pthread_mutex_lock(&mMutex); } // unlocking the lock to leave the critical section diff --git a/gps/utils/MsgTask.cpp b/gps/utils/MsgTask.cpp index fdb1102..6f9d0e9 100644 --- a/gps/utils/MsgTask.cpp +++ b/gps/utils/MsgTask.cpp @@ -83,7 +83,7 @@ void MsgTask::prerun() { } bool MsgTask::run() { - LOC_LOGD("MsgTask::loop() listening ...\n"); + LOC_LOGV("MsgTask::loop() listening ...\n"); LocMsg* msg; msq_q_err_type result = msg_q_rcv((void*)mQ, (void **)&msg); if (eMSG_Q_SUCCESS != result) { diff --git a/gps/utils/linked_list.c b/gps/utils/linked_list.c index 92617fe..2c91714 100644 --- a/gps/utils/linked_list.c +++ b/gps/utils/linked_list.c @@ -109,7 +109,7 @@ linked_list_err_type linked_list_destroy(void** list_data) ===========================================================================*/ linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*)) { - LOC_LOGD("%s: Adding to list data_obj = 0x%08X\n", __FUNCTION__, data_obj); + LOC_LOGV("%s: Adding to list data_obj = 0x%08X\n", __FUNCTION__, data_obj); if( list_data == NULL ) { LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); @@ -161,7 +161,7 @@ linked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dea ===========================================================================*/ linked_list_err_type linked_list_remove(void* list_data, void **data_obj) { - LOC_LOGD("%s: Removing from list\n", __FUNCTION__); + LOC_LOGV("%s: Removing from list\n", __FUNCTION__); if( list_data == NULL ) { LOC_LOGE("%s: Invalid list parameter!\n", __FUNCTION__); @@ -268,7 +268,7 @@ linked_list_err_type linked_list_search(void* list_data, void **data_p, bool (*equal)(void* data_0, void* data), void* data_0, bool rm_if_found) { - LOC_LOGD("%s: Search the list\n", __FUNCTION__); + LOC_LOGV("%s: Search the list\n", __FUNCTION__); if( list_data == NULL || NULL == equal ) { LOC_LOGE("%s: Invalid list parameter! list_data %p equal %p\n", diff --git a/gps/utils/loc_cfg.cpp b/gps/utils/loc_cfg.cpp index 5c33320..967d2f3 100644 --- a/gps/utils/loc_cfg.cpp +++ b/gps/utils/loc_cfg.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2015, 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 @@ -56,12 +56,12 @@ static uint32_t DEBUG_LEVEL = 0xff; static uint32_t TIMESTAMP = 0; /* Parameter spec table */ -static loc_param_s_type loc_param_table[] = +static const loc_param_s_type loc_param_table[] = { {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'}, {"TIMESTAMP", &TIMESTAMP, NULL, 'n'}, }; -int loc_param_num = sizeof(loc_param_table) / sizeof(loc_param_s_type); +static const int loc_param_num = sizeof(loc_param_table) / sizeof(loc_param_s_type); typedef struct loc_param_v_type { @@ -92,7 +92,7 @@ RETURN VALUE SIDE EFFECTS N/A ===========================================================================*/ -int loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value) +int loc_set_config_entry(const loc_param_s_type* config_entry, loc_param_v_type* config_value) { int ret=-1; if(NULL == config_entry || NULL == config_value) @@ -181,7 +181,7 @@ SIDE EFFECTS N/A ===========================================================================*/ int loc_fill_conf_item(char* input_buf, - loc_param_s_type* config_table, uint32_t table_length) + const loc_param_s_type* config_table, uint32_t table_length) { int ret = 0; @@ -258,7 +258,7 @@ RETURN VALUE SIDE EFFECTS N/A ===========================================================================*/ -int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length) +int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table, uint32_t table_length) { int ret=0; @@ -322,7 +322,7 @@ SIDE EFFECTS N/A ===========================================================================*/ int loc_update_conf(const char* conf_data, int32_t length, - loc_param_s_type* config_table, uint32_t table_length) + const loc_param_s_type* config_table, uint32_t table_length) { int ret = -1; @@ -377,7 +377,7 @@ RETURN VALUE SIDE EFFECTS N/A ===========================================================================*/ -void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, +void loc_read_conf(const char* conf_file_name, const loc_param_s_type* config_table, uint32_t table_length) { FILE *conf_fp = NULL; diff --git a/gps/utils/loc_cfg.h b/gps/utils/loc_cfg.h index ea4865b..9045e1d 100644 --- a/gps/utils/loc_cfg.h +++ b/gps/utils/loc_cfg.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2015, 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 @@ -54,7 +54,7 @@ *============================================================================*/ typedef struct { - char param_name[LOC_MAX_PARAM_NAME]; + const char *param_name; void *param_ptr; uint8_t *param_set; /* was this value set by config file? */ char param_type; /* 'n' for number, @@ -78,12 +78,12 @@ extern "C" { * *============================================================================*/ void loc_read_conf(const char* conf_file_name, - loc_param_s_type* config_table, + const loc_param_s_type* config_table, uint32_t table_length); -int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, +int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table, uint32_t table_length); int loc_update_conf(const char* conf_data, int32_t length, - loc_param_s_type* config_table, uint32_t table_length); + const loc_param_s_type* config_table, uint32_t table_length); #ifdef __cplusplus } #endif diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp index 5500dea..76f0c53 100644 --- a/gps/utils/loc_log.cpp +++ b/gps/utils/loc_log.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2012, 2015, 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 @@ -57,9 +57,9 @@ const char EXIT_ERROR_TAG[] = "Exiting with error"; loc_logger_s_type loc_logger; /* Get names from value */ -const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask) +const char* loc_get_name_from_mask(const loc_name_val_s_type table[], size_t table_size, long mask) { - int i; + size_t i; for (i = 0; i < table_size; i++) { if (table[i].val & (long) mask) @@ -71,9 +71,9 @@ const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, } /* Get names from value */ -const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value) +const char* loc_get_name_from_val(const loc_name_val_s_type table[], size_t table_size, long value) { - int i; + size_t i; for (i = 0; i < table_size; i++) { if (table[i].val == (long) value) @@ -84,7 +84,7 @@ const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, l return UNKNOWN_STR; } -static loc_name_val_s_type loc_msg_q_status[] = +static const loc_name_val_s_type loc_msg_q_status[] = { NAME_VAL( eMSG_Q_SUCCESS ), NAME_VAL( eMSG_Q_FAILURE_GENERAL ), @@ -93,7 +93,7 @@ static loc_name_val_s_type loc_msg_q_status[] = NAME_VAL( eMSG_Q_UNAVAILABLE_RESOURCE ), NAME_VAL( eMSG_Q_INSUFFICIENT_BUFFER ) }; -static int loc_msg_q_status_num = sizeof(loc_msg_q_status) / sizeof(loc_name_val_s_type); +static const size_t loc_msg_q_status_num = LOC_TABLE_SIZE(loc_msg_q_status); /* Find msg_q status name */ const char* loc_get_msg_q_status(int status) @@ -107,7 +107,7 @@ const char* log_succ_fail_string(int is_succ) } //Target names -loc_name_val_s_type target_name[] = +static const loc_name_val_s_type target_name[] = { NAME_VAL(GNSS_NONE), NAME_VAL(GNSS_MSM), @@ -118,7 +118,7 @@ loc_name_val_s_type target_name[] = NAME_VAL(GNSS_UNKNOWN) }; -static int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type); +static const size_t target_name_num = LOC_TABLE_SIZE(target_name); /*=========================================================================== @@ -139,7 +139,7 @@ const char *loc_get_target_name(unsigned int target) static char ret[BUFFER_SIZE]; index = getTargetGnssType(target); - if( index >= target_name_num || index < 0) + if( index < 0 || (unsigned)index >= target_name_num ) index = target_name_num - 1; if( (target & HAS_SSC) == HAS_SSC ) { @@ -168,7 +168,7 @@ RETURN VALUE The time string ===========================================================================*/ -char *loc_get_time(char *time_string, unsigned long buf_size) +char *loc_get_time(char *time_string, size_t buf_size) { struct timeval now; /* sec and usec */ struct tm now_tm; /* broken-down time */ diff --git a/gps/utils/loc_log.h b/gps/utils/loc_log.h index 82dc636..be492b1 100644 --- a/gps/utils/loc_log.h +++ b/gps/utils/loc_log.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2012, 2015 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 @@ -36,12 +36,13 @@ extern "C" #endif #include <ctype.h> +#include <stdlib.h> #include "loc_target.h" typedef struct { - char name[128]; - long val; + const char *name; + long val; } loc_name_val_s_type; #define NAME_VAL(x) {"" #x "", x } @@ -49,17 +50,19 @@ typedef struct #define UNKNOWN_STR "UNKNOWN" #define CHECK_MASK(type, value, mask_var, mask) \ - ((mask_var & mask) ? (type) value : (type) (-1)) + (((mask_var) & (mask)) ? (type) (value) : (type) (-1)) + +#define LOC_TABLE_SIZE(table) (sizeof(table)/sizeof((table)[0])) /* Get names from value */ -const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask); -const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value); +const char* loc_get_name_from_mask(const loc_name_val_s_type table[], size_t table_size, long mask); +const char* loc_get_name_from_val(const loc_name_val_s_type table[], size_t table_size, long value); const char* loc_get_msg_q_status(int status); const char* loc_get_target_name(unsigned int target); extern const char* log_succ_fail_string(int is_succ); -extern char *loc_get_time(char *time_string, unsigned long buf_size); +extern char *loc_get_time(char *time_string, size_t buf_size); #ifdef __cplusplus } diff --git a/gps/utils/msg_q.c b/gps/utils/msg_q.c index f82d4c0..5be8547 100644 --- a/gps/utils/msg_q.c +++ b/gps/utils/msg_q.c @@ -199,7 +199,7 @@ msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*) msg_q* p_msg_q = (msg_q*)msg_q_data; pthread_mutex_lock(&p_msg_q->list_mutex); - LOC_LOGD("%s: Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); + LOC_LOGV("%s: Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); if( p_msg_q->unblocked ) { @@ -215,7 +215,7 @@ msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*) pthread_mutex_unlock(&p_msg_q->list_mutex); - LOC_LOGD("%s: Finished Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); + LOC_LOGV("%s: Finished Sending message with handle = 0x%08X\n", __FUNCTION__, msg_obj); return rv; } @@ -242,7 +242,7 @@ msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj) msg_q* p_msg_q = (msg_q*)msg_q_data; - LOC_LOGD("%s: Waiting on message\n", __FUNCTION__); + LOC_LOGV("%s: Waiting on message\n", __FUNCTION__); pthread_mutex_lock(&p_msg_q->list_mutex); @@ -263,7 +263,7 @@ msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj) pthread_mutex_unlock(&p_msg_q->list_mutex); - LOC_LOGD("%s: Received message 0x%08X rv = %d\n", __FUNCTION__, *msg_obj, rv); + LOC_LOGV("%s: Received message 0x%08X rv = %d\n", __FUNCTION__, *msg_obj, rv); return rv; } |