Fix UidMap proto output error. And fix a bug in MaxDurationTracker.

Bug: 76118312
Bug: 76145379

Test: adb shell cmd stats dump-report
      statsd_test
Change-Id: I9a987525df5b37fcefd5f28700bfa1c3952f6692
This commit is contained in:
Yao Chen
2018-03-21 17:21:23 -07:00
parent 86259365d4
commit 59cc0a2237
2 changed files with 5 additions and 3 deletions

View File

@@ -205,11 +205,12 @@ bool MaxDurationTracker::flushCurrentBucket(
bool hasPendingEvent =
false; // has either a kStarted or kPaused event across bucket boundaries
// meaning we need to carry them over to the new bucket.
for (auto it = mInfos.begin(); it != mInfos.end(); ++it) {
for (auto it = mInfos.begin(); it != mInfos.end();) {
if (it->second.state == DurationState::kStopped) {
// No need to keep buckets for events that were stopped before.
mInfos.erase(it);
it = mInfos.erase(it);
} else {
++it;
hasPendingEvent = true;
}
}

View File

@@ -365,7 +365,8 @@ void UidMap::appendUidMap(const int64_t& timestamp, const ConfigKey& key,
count++;
proto->write(FIELD_TYPE_INT64 | FIELD_ID_SNAPSHOT_TIMESTAMP,
(long long)record.timestampNs);
proto->write(FIELD_TYPE_MESSAGE | FIELD_ID_SNAPSHOT_PACKAGE_INFO, record.bytes.data());
proto->write(FIELD_TYPE_MESSAGE | FIELD_ID_SNAPSHOT_PACKAGE_INFO, record.bytes.data(),
record.bytes.size());
proto->end(snapshotsToken);
}
}