summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2020-11-05 21:34:50 -0800
committerLinux Build Service Account <lnxbuild@localhost>2020-11-05 21:34:50 -0800
commit32674e1fe36ab03ce210bbd32254516ff705d1e9 (patch)
tree1013293514a36ed0106c14b4ee69210fd4b76638
parent4d4e5f1e15b68290767dc41394160c5c37c9e557 (diff)
parent9a3b3ecd34f5bbfcaa7ec06c6741318f808fa54c (diff)
Merge 9a3b3ecd34f5bbfcaa7ec06c6741318f808fa54c on remote branch
Change-Id: Ia5fbf76a7c2e84013b877181cf810eb7277a7839
-rw-r--r--gnss/GnssAdapter.cpp40
-rw-r--r--gnss/GnssAdapter.h3
-rw-r--r--location/LocationDataTypes.h3
-rw-r--r--utils/loc_cfg.cpp1
-rw-r--r--utils/loc_log.cpp63
-rw-r--r--utils/log_util.h34
6 files changed, 112 insertions, 32 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index dc06da9..2c2e155 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -229,8 +229,7 @@ GnssAdapter::checkAndSetSPEToRunforNHz(TrackingOptions & out) {
void
GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation,
- const GpsLocationExtended& locationExtended,
- const LocPosTechMask techMask)
+ const GpsLocationExtended& locationExtended)
{
memset(&out, 0, sizeof(Location));
out.size = sizeof(Location);
@@ -272,39 +271,42 @@ GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation,
out.conformityIndex = locationExtended.conformityIndex;
}
out.timestamp = ulpLocation.gpsLocation.timestamp;
- if (LOC_POS_TECH_MASK_SATELLITE & techMask) {
+ if (LOC_POS_TECH_MASK_SATELLITE & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_GNSS_BIT;
}
- if (LOC_POS_TECH_MASK_CELLID & techMask) {
+ if (LOC_POS_TECH_MASK_CELLID & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_CELL_BIT;
}
- if (LOC_POS_TECH_MASK_WIFI & techMask) {
+ if (LOC_POS_TECH_MASK_WIFI & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_WIFI_BIT;
}
- if (LOC_POS_TECH_MASK_SENSORS & techMask) {
+ if (LOC_POS_TECH_MASK_SENSORS & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_SENSORS_BIT;
}
- if (LOC_POS_TECH_MASK_REFERENCE_LOCATION & techMask) {
+ if (LOC_POS_TECH_MASK_REFERENCE_LOCATION & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_REFERENCE_LOCATION_BIT;
}
- if (LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION & techMask) {
+ if (LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_INJECTED_COARSE_POSITION_BIT;
}
- if (LOC_POS_TECH_MASK_AFLT & techMask) {
+ if (LOC_POS_TECH_MASK_AFLT & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_AFLT_BIT;
}
- if (LOC_POS_TECH_MASK_HYBRID & techMask) {
+ if (LOC_POS_TECH_MASK_HYBRID & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_HYBRID_BIT;
}
- if (LOC_POS_TECH_MASK_PPE & techMask) {
+ if (LOC_POS_TECH_MASK_PPE & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_PPE_BIT;
}
- if (LOC_POS_TECH_MASK_VEH & techMask) {
+ if (LOC_POS_TECH_MASK_VEH & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_VEH_BIT;
}
- if (LOC_POS_TECH_MASK_VIS & techMask) {
+ if (LOC_POS_TECH_MASK_VIS & locationExtended.tech_mask) {
out.techMask |= LOCATION_TECHNOLOGY_VIS_BIT;
}
+ if (LOC_NAV_MASK_DGNSS_CORRECTION & locationExtended.navSolutionMask) {
+ out.techMask |= LOCATION_TECHNOLOGY_DGNSS_BIT;
+ }
if (LOC_GPS_LOCATION_HAS_SPOOF_MASK & ulpLocation.gpsLocation.flags) {
out.flags |= LOCATION_HAS_SPOOF_MASK;
@@ -3760,9 +3762,9 @@ GnssAdapter::needReportForGnssClient(const UlpLocation& ulpLocation,
bool
GnssAdapter::needReportForFlpClient(enum loc_sess_status status,
LocPosTechMask techMask) {
- if ((status == LOC_SESS_INTERMEDIATE) &&
- !(techMask & LOC_POS_TECH_MASK_SENSORS) &&
- (!getAllowFlpNetworkFixes())) {
+ if (((LOC_SESS_INTERMEDIATE == status) && !(techMask & LOC_POS_TECH_MASK_SENSORS) &&
+ (!getAllowFlpNetworkFixes())) ||
+ (LOC_SESS_FAILURE == status)) {
return false;
} else {
return true;
@@ -3826,7 +3828,7 @@ GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
if (reportToGnssClient || reportToFlpClient) {
GnssLocationInfoNotification locationInfo = {};
convertLocationInfo(locationInfo, locationExtended);
- convertLocation(locationInfo.location, ulpLocation, locationExtended, techMask);
+ convertLocation(locationInfo.location, ulpLocation, locationExtended);
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
if ((reportToFlpClient && isFlpClient(it->second)) ||
@@ -3937,8 +3939,7 @@ GnssAdapter::reportEnginePositions(unsigned int count,
convertLocationInfo(locationInfo[i], engLocation->locationExtended);
convertLocation(locationInfo[i].location,
engLocation->location,
- engLocation->locationExtended,
- engLocation->location.tech_mask);
+ engLocation->locationExtended);
}
}
@@ -4136,6 +4137,7 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
}
mGnssSvIdUsedInPosAvail = false;
+ mGnssMbSvIdUsedInPosAvail = false;
}
void
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index ddadb13..20064e6 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -266,8 +266,7 @@ class GnssAdapter : public LocAdapterBase {
/*==== CONVERSION ===================================================================*/
static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions);
static void convertLocation(Location& out, const UlpLocation& ulpLocation,
- const GpsLocationExtended& locationExtended,
- const LocPosTechMask techMask);
+ const GpsLocationExtended& locationExtended);
static void convertLocationInfo(GnssLocationInfoNotification& out,
const GpsLocationExtended& locationExtended);
static uint16_t getNumSvUsed(uint64_t svUsedIdsMask,
diff --git a/location/LocationDataTypes.h b/location/LocationDataTypes.h
index aa80479..9fc40af 100644
--- a/location/LocationDataTypes.h
+++ b/location/LocationDataTypes.h
@@ -93,7 +93,8 @@ typedef enum {
LOCATION_TECHNOLOGY_HYBRID_BIT = (1<<7), // HYBRID
LOCATION_TECHNOLOGY_PPE_BIT = (1<<8), // PPE
LOCATION_TECHNOLOGY_VEH_BIT = (1<<9), // using vehicular data
- LOCATION_TECHNOLOGY_VIS_BIT = (1<<10) // using visual data
+ LOCATION_TECHNOLOGY_VIS_BIT = (1<<10), // using visual data
+ LOCATION_TECHNOLOGY_DGNSS_BIT = (1<<11), // DGNSS
} LocationTechnologyBits;
typedef uint32_t LocationSpoofMask;
diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp
index 8aa1846..2a89966 100644
--- a/utils/loc_cfg.cpp
+++ b/utils/loc_cfg.cpp
@@ -453,6 +453,7 @@ void loc_read_conf_long(const char* conf_file_name, const loc_param_s_type* conf
/* Initialize logging mechanism with parsed data */
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
log_buffer_init(sLogBufferEnabled);
+ log_tag_level_map_init();
}
/*=============================================================================
diff --git a/utils/loc_log.cpp b/utils/loc_log.cpp
index 56ae116..2110683 100644
--- a/utils/loc_log.cpp
+++ b/utils/loc_log.cpp
@@ -38,8 +38,13 @@
#include "msg_q.h"
#include <loc_pla.h>
#include "LogBuffer.h"
-
+#include <unordered_map>
+#include <fstream>
+#include <algorithm>
+#include <string>
+#include <cctype>
#define BUFFER_SIZE 120
+#define LOG_TAG_LEVEL_CONF_FILE_PATH "/data/vendor/location/gps.prop"
// Logging Improvements
const char *loc_logger_boolStr[]={"False","True"};
@@ -59,6 +64,10 @@ const string gUnknownStr = "UNKNOWN";
/* Logging Mechanism */
loc_logger_s_type loc_logger;
+/* tag base logging control map*/
+static std::unordered_map<std::string, uint8_t> tag_level_map;
+static bool tag_map_inited = false;
+
/* returns the least signification bit that is set in the mask
Param
mask - bit mask.
@@ -219,3 +228,55 @@ void log_buffer_insert(char *str, unsigned long buf_size, int level)
string ss = str;
loc_util::LogBuffer::getInstance()->append(ss, level, elapsedTime);
}
+
+void log_tag_level_map_init()
+{
+ if (tag_map_inited) {
+ return;
+ }
+
+ std::string filename = LOG_TAG_LEVEL_CONF_FILE_PATH;
+
+ std::ifstream s(filename);
+ if (!s.is_open()) {
+ ALOGE("cannot open file:%s", LOG_TAG_LEVEL_CONF_FILE_PATH);
+ } else {
+ std::string line;
+ while (std::getline(s, line)) {
+ line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
+ int pos = line.find('=');
+ if (pos <= 0 || pos >= (line.size() - 1)) {
+ ALOGE("wrong format in gps.prop");
+ continue;
+ }
+ std::string tag = line.substr(0, pos);
+ std::string level = line.substr(pos+1, 1);
+ if (!std::isdigit(*(level.begin()))) {
+ ALOGE("wrong format in gps.prop");
+ continue;
+ }
+ tag_level_map[tag] = (uint8_t)std::stoul(level);
+ }
+ }
+ tag_map_inited = true;
+}
+
+int get_tag_log_level(const char* tag)
+{
+ if (!tag_map_inited) {
+ return -1;
+ }
+
+ // in case LOG_TAG isn't defined in a source file, use the global log level
+ if (tag == NULL) {
+ return loc_logger.DEBUG_LEVEL;
+ }
+ int log_level;
+ auto search = tag_level_map.find(std::string(tag));
+ if (tag_level_map.end() != search) {
+ log_level = search->second;
+ } else {
+ log_level = loc_logger.DEBUG_LEVEL;
+ }
+ return log_level;
+}
diff --git a/utils/log_util.h b/utils/log_util.h
index 78ed478..33aa6e2 100644
--- a/utils/log_util.h
+++ b/utils/log_util.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, 2020 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
@@ -32,7 +32,6 @@
#include <stdbool.h>
#include <loc_pla.h>
-
#if defined (USE_ANDROID_LOGGING) || defined (ANDROID)
// Android and LE targets with logcat support
#include <utils/Log.h>
@@ -160,10 +159,10 @@ inline void loc_logger_init(unsigned long debug, unsigned long timestamp)
inline void log_buffer_init(bool enabled) {
loc_logger.LOG_BUFFER_ENABLE = enabled;
}
-
+extern void log_tag_level_map_init();
+extern int get_tag_log_level(const char* tag);
extern char* get_timestamp(char* str, unsigned long buf_size);
extern void log_buffer_insert(char *str, unsigned long buf_size, int level);
-
/*=============================================================================
*
* LOGGING BUFFER MACROS
@@ -196,11 +195,28 @@ extern void log_buffer_insert(char *str, unsigned long buf_size, int level);
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))
+
+
+/* Tag based logging control MACROS */
+/* The logic is like this:
+ * 1, LOCAL_LOG_LEVEL is defined as a static variable in log_util.h,
+ * then all source files which includes log_util.h will have its own LOCAL_LOG_LEVEL variable;
+ * 2, For each source file,
+ * 2.1, First time when LOC_LOG* is invoked(its LOCAL_LOG_LEVEL == -1),
+ * Set the tag based log level according to the <tag, level> map;
+ * If this tag isn't found in map, set local debug level as global loc_logger.DEBUG_LEVEL;
+ * 2.2, If not the first time, use its LOCAL_LOG_LEVEL as the debug level of this tag.
+*/
+static int LOCAL_LOG_LEVEL = -1;
+#define IF_LOC_LOG(x) \
+ if (((LOCAL_LOG_LEVEL == -1 && (LOCAL_LOG_LEVEL = get_tag_log_level(LOG_TAG)) >= x) ||\
+ LOCAL_LOG_LEVEL >= x) && LOCAL_LOG_LEVEL <= 5)
+
+#define IF_LOC_LOGE IF_LOC_LOG(1)
+#define IF_LOC_LOGW IF_LOC_LOG(2)
+#define IF_LOC_LOGI IF_LOC_LOG(3)
+#define IF_LOC_LOGD IF_LOC_LOG(4)
+#define IF_LOC_LOGV IF_LOC_LOG(5)
#define LOC_LOGE(...) IF_LOC_LOGE { ALOGE(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 0, __VA_ARGS__);}
#define LOC_LOGW(...) IF_LOC_LOGW { ALOGW(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 1, __VA_ARGS__);}