summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jonathan Nguyen <jtnguyen@google.com> 2019-03-14 20:44:52 -0700
committer Tej Singh <singhtejinder@google.com> 2019-03-15 00:26:32 -0700
commitbbe311c0e56957cf2ae9cda634ee6907220859bd (patch)
tree0cd9bf77d363bb047979f8efbb7c05dd9ac7fd69
parenta3e9de112196e86bbafd36d70983fa7981f39295 (diff)
Maintain existing train information
When sendBinaryPushStateChangedAtom is called with empty train name/version/experiment ids, populate the empty fields from the trainInfo previously stored on disk if possible. If no train info is on disk (or read fails), the empty fields are passed through. Test: gts in ag/6731864 Test: testdrive 10051 with partially/completely missing train info Bug: 128640419 Change-Id: Iea3c2db5c11d07f0b42b41aec7b2d7913a99ca03
-rw-r--r--cmds/statsd/src/StatsService.cpp54
1 files changed, 36 insertions, 18 deletions
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 1526d6609fa0..f78ae38aabd8 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -1198,30 +1198,48 @@ Status StatsService::sendBinaryPushStateChangedAtom(const android::String16& tra
}
// TODO: add verifier permission
- userid_t userId = multiuser_get_user_id(uid);
-
- bool requiresStaging = options & IStatsManager::FLAG_REQUIRE_STAGING;
- bool rollbackEnabled = options & IStatsManager::FLAG_ROLLBACK_ENABLED;
- bool requiresLowLatencyMonitor = options & IStatsManager::FLAG_REQUIRE_LOW_LATENCY_MONITOR;
+ bool readTrainInfoSuccess = false;
+ InstallTrainInfo trainInfo;
+ if (trainVersionCode == -1 || experimentIds.empty() || trainName.size() == 0) {
+ readTrainInfoSuccess = StorageManager::readTrainInfo(trainInfo);
+ }
- ProtoOutputStream proto;
- for (const auto& expId : experimentIds) {
- proto.write(FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED | FIELD_ID_EXPERIMENT_ID,
- (long long)expId);
+ if (trainVersionCode == -1 && readTrainInfoSuccess) {
+ trainVersionCode = trainInfo.trainVersionCode;
}
vector<uint8_t> experimentIdsProtoBuffer;
- experimentIdsProtoBuffer.resize(proto.size());
- size_t pos = 0;
- auto iter = proto.data();
- while (iter.readBuffer() != NULL) {
- size_t toRead = iter.currentToRead();
- std::memcpy(&(experimentIdsProtoBuffer[pos]), iter.readBuffer(), toRead);
- pos += toRead;
- iter.rp()->move(toRead);
+ if (readTrainInfoSuccess && experimentIds.empty()) {
+ experimentIdsProtoBuffer = trainInfo.experimentIds;
+ } else {
+ ProtoOutputStream proto;
+ for (const auto& expId : experimentIds) {
+ proto.write(FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED | FIELD_ID_EXPERIMENT_ID,
+ (long long)expId);
+ }
+
+ experimentIdsProtoBuffer.resize(proto.size());
+ size_t pos = 0;
+ auto iter = proto.data();
+ while (iter.readBuffer() != NULL) {
+ size_t toRead = iter.currentToRead();
+ std::memcpy(&(experimentIdsProtoBuffer[pos]), iter.readBuffer(), toRead);
+ pos += toRead;
+ iter.rp()->move(toRead);
+ }
+ }
+
+ std::string trainNameUtf8;
+ if (readTrainInfoSuccess && trainName.size() == 0) {
+ trainNameUtf8 = trainInfo.trainName;
+ } else {
+ trainNameUtf8 = std::string(String8(trainName).string());
}
- std::string trainNameUtf8 = std::string(String8(trainName).string());
+ userid_t userId = multiuser_get_user_id(uid);
+ bool requiresStaging = options & IStatsManager::FLAG_REQUIRE_STAGING;
+ bool rollbackEnabled = options & IStatsManager::FLAG_ROLLBACK_ENABLED;
+ bool requiresLowLatencyMonitor = options & IStatsManager::FLAG_REQUIRE_LOW_LATENCY_MONITOR;
LogEvent event(trainNameUtf8, trainVersionCode, requiresStaging, rollbackEnabled,
requiresLowLatencyMonitor, state, experimentIdsProtoBuffer, userId);
mProcessor->OnLogEvent(&event);