Allow first uid in attribution chain as primary field
Test: bit statsd_test:*
Bug: 142108433
Change-Id: I6a2f8e6198765d4205dac95e5f54666496b78808
diff --git a/cmds/statsd/src/state/StateTracker.cpp b/cmds/statsd/src/state/StateTracker.cpp
index ef59c92..3ad21e0 100644
--- a/cmds/statsd/src/state/StateTracker.cpp
+++ b/cmds/statsd/src/state/StateTracker.cpp
@@ -28,10 +28,14 @@
StateTracker::StateTracker(const int32_t atomId, const util::StateAtomFieldOptions& stateAtomInfo)
: mAtomId(atomId), mStateField(getSimpleMatcher(atomId, stateAtomInfo.exclusiveField)) {
// create matcher for each primary field
- // TODO(tsaichristine): b/142108433 handle when primary field is first uid in chain
- for (const auto& primary : stateAtomInfo.primaryFields) {
- Matcher matcher = getSimpleMatcher(atomId, primary);
- mPrimaryFields.push_back(matcher);
+ for (const auto& primaryField : stateAtomInfo.primaryFields) {
+ if (primaryField == util::FIRST_UID_IN_CHAIN) {
+ Matcher matcher = getFirstUidMatcher(atomId);
+ mPrimaryFields.push_back(matcher);
+ } else {
+ Matcher matcher = getSimpleMatcher(atomId, primaryField);
+ mPrimaryFields.push_back(matcher);
+ }
}
// TODO(tsaichristine): b/142108433 set default state, reset state, and nesting
diff --git a/cmds/statsd/src/state/StateTracker.h b/cmds/statsd/src/state/StateTracker.h
index 7453370..70f1627 100644
--- a/cmds/statsd/src/state/StateTracker.h
+++ b/cmds/statsd/src/state/StateTracker.h
@@ -72,7 +72,7 @@
int32_t mDefaultState = kStateUnknown;
- int32_t mResetState;
+ int32_t mResetState = kStateUnknown;
// Maps primary key to state value info
std::unordered_map<HashableDimensionKey, StateValueInfo> mStateMap;