Merge "fix cts error on x86 simulator" into pi-dev am: 9743fae2d9
am: b0828d55e5

Change-Id: Id25dc7960e984e99328fcbbdc729c29021677e3e
diff --git a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp
index 610faad..c020f9c 100644
--- a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp
+++ b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp
@@ -20,8 +20,8 @@
 #include <android/os/IStatsCompanionService.h>
 #include <cutils/log.h>
 #include <math.h>
+#include <stdint.h>
 #include <algorithm>
-#include <climits>
 #include "../StatsService.h"
 #include "../logd/LogEvent.h"
 #include "../stats_log_util.h"
@@ -46,6 +46,9 @@
 namespace os {
 namespace statsd {
 
+// Values smaller than this may require to update the alarm.
+const int64_t NO_ALARM_UPDATE = INT64_MAX;
+
 const std::map<int, PullAtomInfo> StatsPullerManagerImpl::kAllPullAtomInfo = {
         // wifi_bytes_transfer
         {android::util::WIFI_BYTES_TRANSFER,
@@ -170,7 +173,7 @@
         // temperature
         {android::util::TEMPERATURE, {{}, {}, 1, new ResourceThermalManagerPuller()}}};
 
-StatsPullerManagerImpl::StatsPullerManagerImpl() : mNextPullTimeNs(LONG_MAX) {
+StatsPullerManagerImpl::StatsPullerManagerImpl() : mNextPullTimeNs(NO_ALARM_UPDATE) {
 }
 
 bool StatsPullerManagerImpl::Pull(const int tagId, const int64_t timeNs,
@@ -197,7 +200,7 @@
 }
 
 void StatsPullerManagerImpl::updateAlarmLocked() {
-    if (mNextPullTimeNs == LONG_MAX) {
+    if (mNextPullTimeNs == NO_ALARM_UPDATE) {
         VLOG("No need to set alarms. Skipping");
         return;
     }
@@ -278,7 +281,7 @@
 void StatsPullerManagerImpl::OnAlarmFired(const int64_t currentTimeNs) {
     AutoMutex _l(mLock);
 
-    int64_t minNextPullTimeNs = LONG_MAX;
+    int64_t minNextPullTimeNs = NO_ALARM_UPDATE;
 
     vector<pair<int, vector<ReceiverInfo*>>> needToPull =
             vector<pair<int, vector<ReceiverInfo*>>>();
@@ -322,6 +325,8 @@
         }
     }
 
+    VLOG("mNextPullTimeNs: %lld updated to %lld", (long long)mNextPullTimeNs,
+         (long long)minNextPullTimeNs);
     mNextPullTimeNs = minNextPullTimeNs;
     updateAlarmLocked();
 }