Avoid processing log event when there is no uid field.
Test: all statsd unit test passed
Change-Id: Id434d86586950a485b30a244f3c030e8202c1c6d
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp
index 7a7a2f6..0eaefb7 100644
--- a/cmds/statsd/src/StatsLogProcessor.cpp
+++ b/cmds/statsd/src/StatsLogProcessor.cpp
@@ -92,10 +92,20 @@
void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const {
std::vector<Field> uidFields;
- findFields(
- event->getFieldValueMap(),
- buildAttributionUidFieldMatcher(event->GetTagId(), Position::ANY),
- &uidFields);
+ if (android::util::kAtomsWithAttributionChain.find(event->GetTagId()) !=
+ android::util::kAtomsWithAttributionChain.end()) {
+ findFields(
+ event->getFieldValueMap(),
+ buildAttributionUidFieldMatcher(event->GetTagId(), Position::ANY),
+ &uidFields);
+ } else if (android::util::kAtomsWithUidField.find(event->GetTagId()) !=
+ android::util::kAtomsWithUidField.end()) {
+ findFields(
+ event->getFieldValueMap(),
+ buildSimpleAtomFieldMatcher(event->GetTagId(), 1 /* uid is always the 1st field. */),
+ &uidFields);
+ }
+
for (size_t i = 0; i < uidFields.size(); ++i) {
DimensionsValue* value = event->findFieldValueOrNull(uidFields[i]);
if (value != nullptr && value->value_case() == DimensionsValue::ValueCase::kValueInt) {