diff options
author | Dante Russo <drusso@codeaurora.org> | 2014-06-27 13:14:39 -0700 |
---|---|---|
committer | Vineeta Srivastava <vsrivastava@google.com> | 2014-07-08 16:46:17 -0700 |
commit | 8c61f8c1f1572ab769912264af3f31feb041fe79 (patch) | |
tree | ba884b1be1972a097332eca198dc083ba786dd8d /utils | |
parent | 4fe12bb6925e1372f441ec5a79c7c8f316ff06bd (diff) | |
download | android_hardware_qcom_gps-8c61f8c1f1572ab769912264af3f31feb041fe79.tar.gz android_hardware_qcom_gps-8c61f8c1f1572ab769912264af3f31feb041fe79.tar.bz2 android_hardware_qcom_gps-8c61f8c1f1572ab769912264af3f31feb041fe79.zip |
Merge branch 'KK.04.04.02.010.399' into l-pdk
Change-Id: I2452a378d4a4697cec2b023a0e9a9bf3e5f14924
Diffstat (limited to 'utils')
-rw-r--r-- | utils/Android.mk | 18 | ||||
-rw-r--r-- | utils/loc_cfg.cpp | 359 | ||||
-rw-r--r-- | utils/loc_cfg.h | 5 | ||||
-rw-r--r-- | utils/loc_log.cpp | 14 | ||||
-rw-r--r-- | utils/loc_misc_utils.cpp | 114 | ||||
-rw-r--r-- | utils/loc_misc_utils.h | 99 | ||||
-rw-r--r-- | utils/loc_target.cpp | 144 | ||||
-rw-r--r-- | utils/loc_target.h | 17 | ||||
-rw-r--r-- | utils/loc_timer.c | 173 | ||||
-rw-r--r-- | utils/loc_timer.h | 17 | ||||
-rw-r--r-- | utils/log_util.h | 42 |
11 files changed, 714 insertions, 288 deletions
diff --git a/utils/Android.mk b/utils/Android.mk index 18c7ccc..82c56f6 100644 --- a/utils/Android.mk +++ b/utils/Android.mk @@ -1,3 +1,6 @@ +ifeq (, $(filter aarch64 arm64, $(TARGET_ARCH))) +ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),) +ifneq ($(BUILD_TINY_ANDROID),true) #Compile this library only for builds with the latest modem image LOCAL_PATH := $(call my-dir) @@ -17,13 +20,17 @@ LOCAL_SRC_FILES += \ linked_list.c \ loc_target.cpp \ loc_timer.c \ - ../platform_lib_abstractions/elapsed_millis_since_boot.cpp - + ../platform_lib_abstractions/elapsed_millis_since_boot.cpp \ + loc_misc_utils.cpp LOCAL_CFLAGS += \ -fno-short-enums \ -D_ANDROID_ +ifeq ($(TARGET_BUILD_VARIANT),user) + LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER +endif + LOCAL_LDFLAGS += -Wl,--export-dynamic ## Includes @@ -41,8 +48,8 @@ LOCAL_COPY_HEADERS:= \ loc_timer.h \ ../platform_lib_abstractions/platform_lib_includes.h \ ../platform_lib_abstractions/platform_lib_time.h \ - ../platform_lib_abstractions/platform_lib_macros.h - + ../platform_lib_abstractions/platform_lib_macros.h \ + loc_misc_utils.h LOCAL_MODULE := libgps.utils @@ -52,3 +59,6 @@ LOCAL_PRELINK_MODULE := false LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES) include $(BUILD_SHARED_LIBRARY) +endif # not BUILD_TINY_ANDROID +endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE +endif # not aarch64 diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp index 73d1ca4..b8315ee 100644 --- a/utils/loc_cfg.cpp +++ b/utils/loc_cfg.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 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 @@ -39,6 +39,7 @@ #include <time.h> #include <loc_cfg.h> #include <log_util.h> +#include <loc_misc_utils.h> #ifdef USE_GLIB #include <glib.h> #endif @@ -57,16 +58,30 @@ static uint8_t TIMESTAMP = 0; /* Parameter spec table */ static loc_param_s_type loc_parameter_table[] = { - {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'}, - {"TIMESTAMP", &TIMESTAMP, NULL, 'n'}, + {"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'}, + {"TIMESTAMP", &TIMESTAMP, NULL, 'n'}, }; int loc_param_num = sizeof(loc_parameter_table) / sizeof(loc_param_s_type); +typedef struct loc_param_v_type +{ + char* param_name; + char* param_str_value; + int param_int_value; + double param_double_value; +}loc_param_v_type; + /*=========================================================================== -FUNCTION trim_space +FUNCTION loc_set_config_entry DESCRIPTION - Removes leading and trailing spaces of the string + Potentially sets a given configuration table entry based on the passed in + configuration value. This is done by using a string comparison of the + parameter names and those found in the configuration file. + +PARAMETERS: + config_entry: configuration entry in the table to possibly set + config_value: value to store in the entry if the parameter names match DEPENDENCIES N/A @@ -77,122 +92,177 @@ RETURN VALUE SIDE EFFECTS N/A ===========================================================================*/ -void trim_space(char *org_string) +int loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value) { - char *scan_ptr, *write_ptr; - char *first_nonspace = NULL, *last_nonspace = NULL; - - scan_ptr = write_ptr = org_string; - - while (*scan_ptr) - { - if ( !isspace(*scan_ptr) && first_nonspace == NULL) - { - first_nonspace = scan_ptr; - } - - if (first_nonspace != NULL) - { - *(write_ptr++) = *scan_ptr; - if ( !isspace(*scan_ptr)) - { - last_nonspace = write_ptr; - } - } - - scan_ptr++; - } - - if (last_nonspace) { *last_nonspace = '\0'; } + int ret=-1; + if(NULL == config_entry || NULL == config_value) + { + LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__); + return ret; + } + + if (strcmp(config_entry->param_name, config_value->param_name) == 0 && + config_entry->param_ptr) + { + switch (config_entry->param_type) + { + case 's': + if (strcmp(config_value->param_str_value, "NULL") == 0) + { + *((char*)config_entry->param_ptr) = '\0'; + } + else { + strlcpy((char*) config_entry->param_ptr, + config_value->param_str_value, + LOC_MAX_PARAM_STRING + 1); + } + /* Log INI values */ + LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr); + + if(NULL != config_entry->param_set) + { + *(config_entry->param_set) = 1; + } + ret = 0; + break; + case 'n': + *((int *)config_entry->param_ptr) = config_value->param_int_value; + /* Log INI values */ + LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value); + + if(NULL != config_entry->param_set) + { + *(config_entry->param_set) = 1; + } + ret = 0; + break; + case 'f': + *((double *)config_entry->param_ptr) = config_value->param_double_value; + /* Log INI values */ + LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value); + + if(NULL != config_entry->param_set) + { + *(config_entry->param_set) = 1; + } + ret = 0; + break; + default: + LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name); + } + } + return ret; } -typedef struct loc_param_v_type -{ - char* param_name; - - char* param_str_value; - int param_int_value; - double param_double_value; -}loc_param_v_type; - /*=========================================================================== -FUNCTION loc_set_config_entry +FUNCTION loc_read_conf_r (repetitive) DESCRIPTION - Potentially sets a given configuration table entry based on the passed in - configuration value. This is done by using a string comparison of the - parameter names and those found in the configuration file. + Reads the specified configuration file and sets defined values based on + the passed in configuration table. This table maps strings to values to + set along with the type of each of these values. + The difference between this and loc_read_conf is that this function returns + the file pointer position at the end of filling a config table. Also, it + reads a fixed number of parameters at a time which is equal to the length + of the configuration table. This functionality enables the caller to + repeatedly call the function to read data from the same file. PARAMETERS: - config_entry: configuration entry in the table to possibly set - config_value: value to store in the entry if the parameter names match + conf_fp : file pointer + config_table: table definition of strings to places to store information + table_length: length of the configuration table DEPENDENCIES N/A RETURN VALUE - None + 0: Table filled successfully + 1: No more parameters to read + -1: Error filling table SIDE EFFECTS N/A ===========================================================================*/ -void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value) +int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length) { - if(NULL == config_entry || NULL == config_value) - { - LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__); - return; - } - - if (strcmp(config_entry->param_name, config_value->param_name) == 0 && - config_entry->param_ptr) - { - switch (config_entry->param_type) - { - case 's': - if (strcmp(config_value->param_str_value, "NULL") == 0) - { - *((char*)config_entry->param_ptr) = '\0'; - } - else { - strlcpy((char*) config_entry->param_ptr, - config_value->param_str_value, - LOC_MAX_PARAM_STRING + 1); - } - /* Log INI values */ - LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr); - - if(NULL != config_entry->param_set) - { - *(config_entry->param_set) = 1; - } - break; - case 'n': - *((int *)config_entry->param_ptr) = config_value->param_int_value; - /* Log INI values */ - LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value); - - if(NULL != config_entry->param_set) - { - *(config_entry->param_set) = 1; - } - break; - case 'f': - *((double *)config_entry->param_ptr) = config_value->param_double_value; - /* Log INI values */ - LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value); - - if(NULL != config_entry->param_set) - { - *(config_entry->param_set) = 1; - } - break; - default: - LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name); - } - } + char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */ + char *lasts; + loc_param_v_type config_value; + uint32_t i; + int ret=0; + + unsigned int num_params=table_length; + if(conf_fp == NULL) { + LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__); + ret = -1; + goto err; + } + + /* Clear all validity bits */ + for(i = 0; NULL != config_table && i < table_length; i++) + { + if(NULL != config_table[i].param_set) + { + *(config_table[i].param_set) = 0; + } + } + LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params); + while(num_params) + { + if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) { + LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__); + break; + } + + memset(&config_value, 0, sizeof(config_value)); + + /* Separate variable and value */ + config_value.param_name = strtok_r(input_buf, "=", &lasts); + /* skip lines that do not contain "=" */ + if (config_value.param_name == NULL) continue; + config_value.param_str_value = strtok_r(NULL, "=", &lasts); + /* skip lines that do not contain two operands */ + if (config_value.param_str_value == NULL) continue; + + /* Trim leading and trailing spaces */ + loc_util_trim_space(config_value.param_name); + loc_util_trim_space(config_value.param_str_value); + + /* Parse numerical value */ + if ((strlen(config_value.param_str_value) >=3) && + (config_value.param_str_value[0] == '0') && + (tolower(config_value.param_str_value[1]) == 'x')) + { + /* hex */ + config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], + (char**) NULL, 16); + } + else { + config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */ + config_value.param_int_value = atoi(config_value.param_str_value); /* dec */ + } + + for(i = 0; NULL != config_table && i < table_length; i++) + { + if(!loc_set_config_entry(&config_table[i], &config_value)) { + num_params--; + } + } + } + +err: + return ret; } +typedef struct loc_param_v_type +{ + char* param_name; + + char* param_str_value; + int param_int_value; + double param_double_value; +}loc_param_v_type; + /*=========================================================================== FUNCTION loc_read_conf @@ -215,72 +285,25 @@ RETURN VALUE SIDE EFFECTS N/A ===========================================================================*/ -void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, uint32_t table_length) +void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, + uint32_t table_length) { - FILE *gps_conf_fp = NULL; - char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */ - char *lasts; - loc_param_v_type config_value; - uint32_t i; - - if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL) - { - LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name); - } - else - { - LOC_LOGW("%s: no %s file found", __FUNCTION__, conf_file_name); - loc_logger_init(DEBUG_LEVEL, TIMESTAMP); - return; /* no parameter file */ - } - - /* Clear all validity bits */ - for(i = 0; NULL != config_table && i < table_length; i++) - { - if(NULL != config_table[i].param_set) - { - *(config_table[i].param_set) = 0; - } - } - - while(fgets(input_buf, LOC_MAX_PARAM_LINE, gps_conf_fp) != NULL) - { - memset(&config_value, 0, sizeof(config_value)); - - /* Separate variable and value */ - config_value.param_name = strtok_r(input_buf, "=", &lasts); - if (config_value.param_name == NULL) continue; /* skip lines that do not contain "=" */ - config_value.param_str_value = strtok_r(NULL, "=", &lasts); - if (config_value.param_str_value == NULL) continue; /* skip lines that do not contain two operands */ - - /* Trim leading and trailing spaces */ - trim_space(config_value.param_name); - trim_space(config_value.param_str_value); - - /* Parse numerical value */ - if (config_value.param_str_value[0] == '0' && tolower(config_value.param_str_value[1]) == 'x') - { - /* hex */ - config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], (char**) NULL, 16); - } - else { - config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */ - config_value.param_int_value = atoi(config_value.param_str_value); /* dec */ - } - - for(i = 0; NULL != config_table && i < table_length; i++) - { - loc_set_config_entry(&config_table[i], &config_value); - } - - for(i = 0; i < loc_param_num; i++) - { - loc_set_config_entry(&loc_parameter_table[i], &config_value); - } - } - - fclose(gps_conf_fp); - - /* Initialize logging mechanism with parsed data */ - loc_logger_init(DEBUG_LEVEL, TIMESTAMP); + FILE *gps_conf_fp = NULL; + char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */ + char *lasts; + loc_param_v_type config_value; + uint32_t i; + + if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL) + { + LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name); + if(table_length && config_table) { + loc_read_conf_r(gps_conf_fp, config_table, table_length); + rewind(gps_conf_fp); + } + loc_read_conf_r(gps_conf_fp, loc_parameter_table, loc_param_num); + fclose(gps_conf_fp); + } + /* Initialize logging mechanism with parsed data */ + loc_logger_init(DEBUG_LEVEL, TIMESTAMP); } diff --git a/utils/loc_cfg.h b/utils/loc_cfg.h index df83338..268f4c2 100644 --- a/utils/loc_cfg.h +++ b/utils/loc_cfg.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 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 @@ -30,6 +30,7 @@ #ifndef LOC_CFG_H #define LOC_CFG_H +#include <stdio.h> #include <stdint.h> #define LOC_MAX_PARAM_NAME 48 @@ -75,7 +76,7 @@ extern "C" { extern void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, uint32_t table_length); - +extern int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length); #ifdef __cplusplus } #endif diff --git a/utils/loc_log.cpp b/utils/loc_log.cpp index f755d70..392966e 100644 --- a/utils/loc_log.cpp +++ b/utils/loc_log.cpp @@ -112,7 +112,7 @@ loc_name_val_s_type target_name[] = NAME_VAL(GNSS_MSM), NAME_VAL(GNSS_GSS), NAME_VAL(GNSS_MDM), - NAME_VAL(GNSS_GRIFFON), + NAME_VAL(GNSS_QCA1530), NAME_VAL(GNSS_UNKNOWN) }; @@ -134,18 +134,18 @@ RETURN VALUE const char *loc_get_target_name(unsigned int target) { int index = 0; - char ret[BUFFER_SIZE]; + static char ret[BUFFER_SIZE]; index = getTargetGnssType(target); if( index >= target_name_num || index < 0) index = target_name_num - 1; if( (target & HAS_SSC) == HAS_SSC ) { - sprintf(ret, " %s with SSC", + snprintf(ret, sizeof(ret), " %s with SSC", loc_get_name_from_val(target_name, target_name_num, (long)index) ); } else { - sprintf(ret, " %s without SSC", + snprintf(ret, sizeof(ret), " %s without SSC", loc_get_name_from_val(target_name, target_name_num, (long)index) ); } return ret; @@ -200,6 +200,12 @@ SIDE EFFECTS void loc_logger_init(unsigned long debug, unsigned long timestamp) { loc_logger.DEBUG_LEVEL = debug; +#ifdef TARGET_BUILD_VARIANT_USER + // force user builds to 2 or less + if (loc_logger.DEBUG_LEVEL > 2) { + loc_logger.DEBUG_LEVEL = 2; + } +#endif loc_logger.TIMESTAMP = timestamp; } diff --git a/utils/loc_misc_utils.cpp b/utils/loc_misc_utils.cpp new file mode 100644 index 0000000..7e96313 --- /dev/null +++ b/utils/loc_misc_utils.cpp @@ -0,0 +1,114 @@ +/* Copyright (c) 2014, 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 + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include <stdio.h> +#include <string.h> +#include <log_util.h> +#include <loc_misc_utils.h> +#include <ctype.h> + +#define LOG_NDDEBUG 0 +#define LOG_TAG "LocSvc_misc_utils" + +int loc_util_split_string(char *raw_string, char **split_strings_ptr, + int max_num_substrings, char delimiter) +{ + int raw_string_index=0; + int num_split_strings=0; + unsigned char end_string=0; + int raw_string_length=0; + + if(!raw_string || !split_strings_ptr) { + LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__); + num_split_strings = -1; + goto err; + } + LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string); + raw_string_length = strlen(raw_string) + 1; + split_strings_ptr[num_split_strings] = &raw_string[raw_string_index]; + for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) { + if(raw_string[raw_string_index] == '\0') + end_string=1; + if((raw_string[raw_string_index] == delimiter) || end_string) { + raw_string[raw_string_index] = '\0'; + LOC_LOGD("%s:%d]: split string: %s\n", + __func__, __LINE__, split_strings_ptr[num_split_strings]); + num_split_strings++; + if(((raw_string_index + 1) < raw_string_length) && + (num_split_strings < max_num_substrings)) { + split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1]; + } + else { + break; + } + } + if(end_string) + break; + } +err: + LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings); + return num_split_strings; +} + +void loc_util_trim_space(char *org_string) +{ + char *scan_ptr, *write_ptr; + char *first_nonspace = NULL, *last_nonspace = NULL; + + if(org_string == NULL) { + LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__); + goto err; + } + + scan_ptr = write_ptr = org_string; + + while (*scan_ptr) { + //Find the first non-space character + if ( !isspace(*scan_ptr) && first_nonspace == NULL) { + first_nonspace = scan_ptr; + } + //Once the first non-space character is found in the + //above check, keep shifting the characters to the left + //to replace the spaces + if (first_nonspace != NULL) { + *(write_ptr++) = *scan_ptr; + //Keep track of which was the last non-space character + //encountered + //last_nonspace will not be updated in the case where + //the string ends with spaces + if ( !isspace(*scan_ptr)) { + last_nonspace = write_ptr; + } + } + scan_ptr++; + } + //Add NULL terminator after the last non-space character + if (last_nonspace) { *last_nonspace = '\0'; } +err: + return; +} diff --git a/utils/loc_misc_utils.h b/utils/loc_misc_utils.h new file mode 100644 index 0000000..7d66d84 --- /dev/null +++ b/utils/loc_misc_utils.h @@ -0,0 +1,99 @@ +/* Copyright (c) 2014, 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 + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _LOC_MISC_UTILS_H_ +#define _LOC_MISC_UTILS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*=========================================================================== +FUNCTION loc_split_string + +DESCRIPTION: + This function is used to split a delimiter separated string into + sub-strings. This function does not allocate new memory to store the split + strings. Instead, it places '\0' in places of delimiters and assings the + starting address of the substring within the raw string as the string address + The input raw_string no longer remains to be a collection of sub-strings + after this function is executed. + Please make a copy of the input string before calling this function if + necessary + +PARAMETERS: + char *raw_string: is the original string with delimiter separated substrings + char **split_strings_ptr: is the arraw of pointers which will hold the addresses + of individual substrings + int max_num_substrings: is the maximum number of substrings that are expected + by the caller. The array of pointers in the above parameter + is usually this long + char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';' + +DEPENDENCIES + N/A + +RETURN VALUE + int Number of split strings + +SIDE EFFECTS + The input raw_string no longer remains a delimiter separated single string. + +EXAMPLE + delimiter = ' ' //space + raw_string = "hello new user" //delimiter is space ' ' + addresses = 0123456789abcd + split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello" + split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new" + split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user" + +===========================================================================*/ +int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings, + char delimiter); + +/*=========================================================================== +FUNCTION trim_space + +DESCRIPTION + Removes leading and trailing spaces of the string + +DEPENDENCIES + N/A + +RETURN VALUE + None + +SIDE EFFECTS + N/A +===========================================================================*/ +void loc_util_trim_space(char *org_string); +#ifdef __cplusplus +} +#endif + +#endif //_LOC_MISC_UTILS_H_ diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index 26df4cb..d46747a 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2014, 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,8 +56,14 @@ #define LENGTH(s) (sizeof(s) - 1) #define GPS_CHECK_NO_ERROR 0 #define GPS_CHECK_NO_GPS_HW 1 +/* When system server is started, it uses 20 seconds as ActivityManager + * timeout. After that it sends SIGSTOP signal to process. + */ +#define QCA1530_DETECT_TIMEOUT 15 +#define QCA1530_DETECT_PRESENT "yes" +#define QCA1530_DETECT_PROGRESS "detect" -static int gss_fd = 0; +static unsigned int gTarget = (unsigned int)-1; static int read_a_line(const char * file_path, char * line, int line_size) { @@ -81,29 +87,132 @@ static int read_a_line(const char * file_path, char * line, int line_size) return result; } -unsigned int get_target(void) +/*! + * \brief Checks if QCA1530 is avalable. + * + * Function verifies if qca1530 SoC is configured on the device. The test is + * based on property value. For 1530 scenario, the value shall be one of the + * following: "yes", "no", "detect". All other values are treated equally to + * "no". When the value is "detect" the system waits for SoC detection to + * finish before returning result. + * + * \retval true - QCA1530 is available. + * \retval false - QCA1530 is not available. + */ +static bool is_qca1530(void) +{ + static const char qca1530_property_name[] = "sys.qca1530"; + bool res = false; + int ret, i; + char buf[PROPERTY_VALUE_MAX]; + + memset(buf, 0, sizeof(buf)); + + for (i = 0; i < QCA1530_DETECT_TIMEOUT; ++i) + { + ret = property_get(qca1530_property_name, buf, NULL); + if (ret < 0) + { + LOC_LOGV( "qca1530: property %s is not accessible, ret=%d", + qca1530_property_name, + ret); + + break; + } + + LOC_LOGV( "qca1530: property %s is set to %s", + qca1530_property_name, + buf); + + if (!memcmp(buf, QCA1530_DETECT_PRESENT, + sizeof(QCA1530_DETECT_PRESENT))) + { + res = true; + break; + } + if (!memcmp(buf, QCA1530_DETECT_PROGRESS, + sizeof(QCA1530_DETECT_PROGRESS))) + { + LOC_LOGV("qca1530: SoC detection is in progress."); + sleep(1); + continue; + } + break; + } + + LOC_LOGD("qca1530: detected=%s", res ? "true" : "false"); + return res; +} + +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_target_baseband(char *baseband, int array_length) +{ + if(baseband && (array_length >= PROPERTY_VALUE_MAX)) { + property_get("ro.baseband", baseband, ""); + LOC_LOGD("%s:%d]: Baseband: %s\n", __func__, __LINE__, baseband); + } + else { + LOC_LOGE("%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\n", + __func__, __LINE__); + } +} + +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_platform_name(char *platform_name, int array_length) +{ + if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) { + property_get("ro.board.platform", platform_name, ""); + LOC_LOGD("%s:%d]: Target name: %s\n", __func__, __LINE__, platform_name); + } + else { + LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n", + __func__, __LINE__); + } +} + +unsigned int loc_get_target(void) { - unsigned int target = TARGET_DEFAULT; + if (gTarget != (unsigned int)-1) + return gTarget; - char hw_platform[] = "/sys/devices/system/soc/soc0/hw_platform"; - char id[] = "/sys/devices/system/soc/soc0/id"; - char mdm[] = "/dev/mdm"; // No such file or directory + static const char hw_platform[] = "/sys/devices/soc0/hw_platform"; + static const char id[] = "/sys/devices/soc0/soc_id"; + static const char hw_platform_dep[] = + "/sys/devices/system/soc/soc0/hw_platform"; + static const char id_dep[] = "/sys/devices/system/soc/soc0/id"; + static const char mdm[] = "/dev/mdm"; // No such file or directory char rd_hw_platform[LINE_LEN]; char rd_id[LINE_LEN]; char rd_mdm[LINE_LEN]; char baseband[LINE_LEN]; - property_get("ro.baseband", baseband, ""); - read_a_line(hw_platform, rd_hw_platform, LINE_LEN); - read_a_line( id, rd_id, LINE_LEN); + if (is_qca1530()) { + gTarget = TARGET_QCA1530; + goto detected; + } + + loc_get_target_baseband(baseband, sizeof(baseband)); + + if (!access(hw_platform, F_OK)) { + read_a_line(hw_platform, rd_hw_platform, LINE_LEN); + } else { + read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN); + } + if (!access(id, F_OK)) { + read_a_line(id, rd_id, LINE_LEN); + } else { + read_a_line(id_dep, rd_id, LINE_LEN); + } if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){ if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) ) - target = TARGET_MPQ; + gTarget = TARGET_MPQ; else - target = TARGET_APQ_SA; + gTarget = TARGET_APQ_SA; } else { if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID)) @@ -114,13 +223,18 @@ unsigned int get_target(void) && IS_STR_END(rd_hw_platform[LENGTH(STR_MTP)]))) { if (!read_a_line( mdm, rd_mdm, LINE_LEN)) - target = TARGET_MDM; + gTarget = TARGET_MDM; } else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) || (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) - target = TARGET_MSM_NO_SSC; + gTarget = TARGET_MSM_NO_SSC; + else + gTarget = TARGET_UNKNOWN; } - return target; + +detected: + LOC_LOGD("HAL: %s returned %d", __FUNCTION__, gTarget); + return gTarget; } diff --git a/utils/loc_target.h b/utils/loc_target.h index 12cff1d..9aa525f 100644 --- a/utils/loc_target.h +++ b/utils/loc_target.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2014, 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 @@ -34,6 +34,8 @@ #define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC) #define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC) #define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC) +#define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC) +#define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC) #define getTargetGnssType(target) (target>>1) #ifdef __cplusplus @@ -41,14 +43,23 @@ extern "C" { #endif -unsigned int get_target(void); +unsigned int loc_get_target(void); +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_target_baseband(char *baseband, int array_length); +/*The character array passed to this function should have length + of atleast PROPERTY_VALUE_MAX*/ +void loc_get_platform_name(char *platform_name, int array_length); + +/* Please remember to update 'target_name' in loc_log.cpp, + if do any changes to this enum. */ typedef enum { GNSS_NONE = 0, GNSS_MSM, GNSS_GSS, GNSS_MDM, - GNSS_GRIFFON, + GNSS_QCA1530, GNSS_UNKNOWN }GNSS_TARGET; diff --git a/utils/loc_timer.c b/utils/loc_timer.c index 13f7786..1e4008e 100644 --- a/utils/loc_timer.c +++ b/utils/loc_timer.c @@ -34,124 +34,153 @@ #include<time.h> #include<errno.h> -#define MAX_DELAY_RETRIES 3 +enum timer_state { + READY = 100, + WAITING, + DONE, + ABORT +}; typedef struct { loc_timer_callback callback_func; void *user_data; unsigned int time_msec; + pthread_cond_t timer_cond; + pthread_mutex_t timer_mutex; + enum timer_state state; }timer_data; static void *timer_thread(void *thread_data) { - int ret; - unsigned char retries=0; + int ret = -ETIMEDOUT; struct timespec ts; struct timeval tv; - timer_data t; - t.callback_func = ((timer_data *)thread_data)->callback_func; - t.user_data = ((timer_data *)thread_data)->user_data; - t.time_msec = ((timer_data *)thread_data)->time_msec; - pthread_cond_t timer_cond; - pthread_mutex_t timer_mutex; + timer_data* t = (timer_data*)thread_data; - LOC_LOGD("%s:%d]: Enter. Delay = %d\n", __func__, __LINE__, t.time_msec); - //Copied over all info into local variable. Do not need allocated struct - free(thread_data); + LOC_LOGD("%s:%d]: Enter. Delay = %d\n", __func__, __LINE__, t->time_msec); - if(pthread_cond_init(&timer_cond, NULL)) { - LOC_LOGE("%s:%d]: Pthread cond init failed\n", __func__, __LINE__); - ret = -1; - goto err; + gettimeofday(&tv, NULL); + clock_gettime(CLOCK_REALTIME, &ts); + if(t->time_msec >= 1000) { + ts.tv_sec += t->time_msec/1000; + t->time_msec = t->time_msec % 1000; } - if(pthread_mutex_init(&timer_mutex, NULL)) { - LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__); - ret = -1; - goto mutex_err; + if(t->time_msec) + ts.tv_nsec += t->time_msec * 1000000; + if(ts.tv_nsec > 999999999) { + LOC_LOGD("%s:%d]: Large nanosecs\n", __func__, __LINE__); + ts.tv_sec += 1; + ts.tv_nsec -= 1000000000; } - while(retries < MAX_DELAY_RETRIES) { - gettimeofday(&tv, NULL); - clock_gettime(CLOCK_REALTIME, &ts); - if(t.time_msec >= 1000) { - ts.tv_sec += t.time_msec/1000; - t.time_msec = t.time_msec % 1000; - } - if(t.time_msec) - ts.tv_nsec += t.time_msec * 1000000; - if(ts.tv_nsec > 999999999) { - LOC_LOGD("%s:%d]: Large nanosecs\n", __func__, __LINE__); - ts.tv_sec += 1; - ts.tv_nsec -= 1000000000; - } - LOC_LOGD("%s:%d]: ts.tv_sec:%d; ts.tv_nsec:%d\n", - __func__, __LINE__, (int)ts.tv_sec, (int)ts.tv_nsec); - LOC_LOGD("%s:%d]: Current time: %d sec; %d nsec\n", - __func__, __LINE__, (int)tv.tv_sec, (int)tv.tv_usec*1000); - pthread_mutex_lock(&(timer_mutex)); - ret = pthread_cond_timedwait(&timer_cond, &timer_mutex, &ts); - pthread_mutex_unlock(&(timer_mutex)); - if(ret != ETIMEDOUT) { - LOC_LOGE("%s:%d]: Call to pthread timedwait failed; ret=%d\n", - __func__, __LINE__,ret); - ret = -1; - retries++; - } - else { - ret = 0; - break; - } + LOC_LOGD("%s:%d]: ts.tv_sec:%d; ts.tv_nsec:%d\n" + "\t Current time: %d sec; %d nsec", + __func__, __LINE__, (int)ts.tv_sec, (int)ts.tv_nsec, + (int)tv.tv_sec, (int)tv.tv_usec*1000); + + pthread_mutex_lock(&(t->timer_mutex)); + if (READY == t->state) { + t->state = WAITING; + ret = pthread_cond_timedwait(&t->timer_cond, &t->timer_mutex, &ts); + t->state = DONE; } + pthread_mutex_unlock(&(t->timer_mutex)); - pthread_mutex_destroy(&timer_mutex); -mutex_err: - pthread_cond_destroy(&timer_cond); -err: - if(!ret) - t.callback_func(t.user_data, ret); + switch (ret) { + case ETIMEDOUT: + LOC_LOGV("%s:%d]: loc_timer timed out", __func__, __LINE__); + break; + case 0: + LOC_LOGV("%s:%d]: loc_timer stopped", __func__, __LINE__); + break; + case -ETIMEDOUT: + LOC_LOGV("%s:%d]: loc_timer cancelled", __func__, __LINE__); + break; + default: + LOC_LOGE("%s:%d]: Call to pthread timedwait failed; ret=%d\n", + __func__, __LINE__, ret); + break; + } + + pthread_mutex_destroy(&t->timer_mutex); + pthread_cond_destroy(&t->timer_cond); + + if(ETIMEDOUT == ret) + t->callback_func(t->user_data, ret); + + free(t); LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__); return NULL; } -int loc_timer_start(unsigned int msec, loc_timer_callback cb_func, - void* caller_data) +void* loc_timer_start(unsigned int msec, loc_timer_callback cb_func, + void* caller_data) { - int ret=0; timer_data *t=NULL; pthread_attr_t tattr; pthread_t id; LOC_LOGD("%s:%d]: Enter\n", __func__, __LINE__); if(cb_func == NULL || msec == 0) { LOC_LOGE("%s:%d]: Error: Wrong parameters\n", __func__, __LINE__); - ret = -1; - goto err; + goto _err; } t = (timer_data *)calloc(1, sizeof(timer_data)); if(t == NULL) { LOC_LOGE("%s:%d]: Could not allocate memory. Failing.\n", __func__, __LINE__); - ret = -1; - goto err; + goto _err; + } + + if(pthread_cond_init(&(t->timer_cond), NULL)) { + LOC_LOGE("%s:%d]: Pthread cond init failed\n", __func__, __LINE__); + goto t_err; + } + if(pthread_mutex_init(&(t->timer_mutex), NULL)) { + LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__); + goto cond_err; } t->callback_func = cb_func; t->user_data = caller_data; t->time_msec = msec; + t->state = READY; - pthread_attr_init(&tattr); + if (pthread_attr_init(&tattr)) { + LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__); + goto mutex_err; + } pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); + if(pthread_create(&(id), &tattr, timer_thread, (void *)t)) { LOC_LOGE("%s:%d]: Could not create thread\n", __func__, __LINE__); - ret = -1; goto attr_err; } - else { - LOC_LOGD("%s:%d]: Created thread with id: %d\n", - __func__, __LINE__, (int)id); - } + + LOC_LOGD("%s:%d]: Created thread with id: %d\n", + __func__, __LINE__, (int)id); + goto _err; attr_err: pthread_attr_destroy(&tattr); -err: +mutex_err: + pthread_mutex_destroy(&t->timer_mutex); +cond_err: + pthread_cond_destroy(&t->timer_cond); +t_err: + free(t); +_err: LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__); - return ret; + return t; +} + +void loc_timer_stop(void* handle) { + timer_data* t = (timer_data*)handle; + + if (NULL != t && (READY == t->state || WAITING == t->state)) { + pthread_mutex_lock(&(t->timer_mutex)); + if (READY == t->state || WAITING == t->state) { + pthread_cond_signal(&t->timer_cond); + t->state = ABORT; + } + pthread_mutex_unlock(&(t->timer_mutex)); + } } diff --git a/utils/loc_timer.h b/utils/loc_timer.h index 213da20..0034d27 100644 --- a/utils/loc_timer.h +++ b/utils/loc_timer.h @@ -43,10 +43,19 @@ extern "C" { */ typedef void(*loc_timer_callback)(void *user_data, int result); -//int loc_timer_start(loc_timer_client_data *p_thread); -int loc_timer_start(unsigned int delay_msec, - loc_timer_callback, - void* user_data); + +/* + Returns the handle, which can be used to stop the timer +*/ +void* loc_timer_start(unsigned int delay_msec, + loc_timer_callback, + void* user_data); + +/* + handle becomes invalid upon the return of the callback +*/ +void loc_timer_stop(void* handle); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/utils/log_util.h b/utils/log_util.h index 7fb0c78..8ff6b5a 100644 --- a/utils/log_util.h +++ b/utils/log_util.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014 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 @@ -96,37 +96,47 @@ extern char* get_timestamp(char* str, unsigned long buf_size); if that value remains unchanged, it means gps.conf did not provide a value and we default to the initial value to use Android's logging levels*/ +#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) + +#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) + #define LOC_LOGE(...) \ -if ((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \ -else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("W/"__VA_ARGS__); } +IF_LOC_LOGE { ALOGE("E/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("E/" __VA_ARGS__); } #define LOC_LOGW(...) \ -if ((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \ -else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/"__VA_ARGS__); } +IF_LOC_LOGW { ALOGE("W/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/" __VA_ARGS__); } #define LOC_LOGI(...) \ -if ((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("I/"__VA_ARGS__); } \ -else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/"__VA_ARGS__); } +IF_LOC_LOGI { ALOGE("I/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/" __VA_ARGS__); } #define LOC_LOGD(...) \ -if ((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("D/"__VA_ARGS__); } \ -else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/"__VA_ARGS__); } +IF_LOC_LOGD { ALOGE("D/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/" __VA_ARGS__); } #define LOC_LOGV(...) \ -if ((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("V/"__VA_ARGS__); } \ -else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/"__VA_ARGS__); } +IF_LOC_LOGV { ALOGE("V/" __VA_ARGS__); } \ +else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/" __VA_ARGS__); } #else /* DEBUG_DMN_LOC_API */ -#define LOC_LOGE(...) ALOGE("E/"__VA_ARGS__) +#define LOC_LOGE(...) ALOGE("E/" __VA_ARGS__) -#define LOC_LOGW(...) ALOGW("W/"__VA_ARGS__) +#define LOC_LOGW(...) ALOGW("W/" __VA_ARGS__) -#define LOC_LOGI(...) ALOGI("I/"__VA_ARGS__) +#define LOC_LOGI(...) ALOGI("I/" __VA_ARGS__) -#define LOC_LOGD(...) ALOGD("D/"__VA_ARGS__) +#define LOC_LOGD(...) ALOGD("D/" __VA_ARGS__) -#define LOC_LOGV(...) ALOGV("V/"__VA_ARGS__) +#define LOC_LOGV(...) ALOGV("V/" __VA_ARGS__) #endif /* DEBUG_DMN_LOC_API */ |