Merge "Fix puller callback with gauge/value metric" into qt-dev
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index 13eee5d..d6411a7 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -276,7 +276,8 @@
 }
 
 bool StatsPullerManager::PullerForMatcherExists(int tagId) const {
-    return kAllPullAtomInfo.find(tagId) != kAllPullAtomInfo.end();
+    // Vendor pulled atoms might be registered after we parse the config.
+    return isVendorPulledAtom(tagId) || kAllPullAtomInfo.find(tagId) != kAllPullAtomInfo.end();
 }
 
 void StatsPullerManager::updateAlarmLocked() {
@@ -449,9 +450,8 @@
         const sp<IStatsPullerCallback>& callback) {
     AutoMutex _l(mLock);
     // Platform pullers cannot be changed.
-    if (atomTag < StatsdStats::kMaxPlatformAtomTag) {
-        VLOG("RegisterPullerCallback: atom tag %d is less than min tag %d",
-                atomTag, StatsdStats::kMaxPlatformAtomTag);
+    if (!isVendorPulledAtom(atomTag)) {
+        VLOG("RegisterPullerCallback: atom tag %d is not vendor pulled", atomTag);
         return;
     }
     VLOG("RegisterPullerCallback: adding puller for tag %d", atomTag);
@@ -462,7 +462,7 @@
 void StatsPullerManager::UnregisterPullerCallback(int32_t atomTag) {
     AutoMutex _l(mLock);
     // Platform pullers cannot be changed.
-    if (atomTag < StatsdStats::kMaxPlatformAtomTag) {
+    if (!isVendorPulledAtom(atomTag)) {
         return;
     }
     StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/false);
diff --git a/cmds/statsd/src/guardrail/StatsdStats.h b/cmds/statsd/src/guardrail/StatsdStats.h
index 88ecccc..53f12ac 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.h
+++ b/cmds/statsd/src/guardrail/StatsdStats.h
@@ -160,6 +160,12 @@
     // Max platform atom tag number.
     static const int32_t kMaxPlatformAtomTag = 100000;
 
+    // Vendor pulled atom start id.
+    static const int32_t kVendorPulledAtomStartTag = 150000;
+
+    // Max accepted atom id.
+    static const int32_t kMaxAtomTag = 200000;
+
     static const int64_t kInt64Max = 0x7fffffffffffffffLL;
 
     /**
diff --git a/cmds/statsd/src/stats_log_util.h b/cmds/statsd/src/stats_log_util.h
index cdef874..2a18e22 100644
--- a/cmds/statsd/src/stats_log_util.h
+++ b/cmds/statsd/src/stats_log_util.h
@@ -96,6 +96,10 @@
     return atomId <= util::kMaxPushedAtomId && atomId > 1;
 }
 
+inline bool isVendorPulledAtom(int atomId) {
+    return atomId >= StatsdStats::kVendorPulledAtomStartTag && atomId < StatsdStats::kMaxAtomTag;
+}
+
 }  // namespace statsd
 }  // namespace os
 }  // namespace android