diff options
| author | 2019-03-15 18:22:15 +0000 | |
|---|---|---|
| committer | 2019-03-15 18:22:15 +0000 | |
| commit | 6983ad3f17566a44d36886affb5e877e7e4ae34c (patch) | |
| tree | 733b01c6773c0e6f0ba9a098847066f16ac8c79f | |
| parent | 289cd11cc4f538e80414b2b7ff580ea4e058e74a (diff) | |
| parent | bbe311c0e56957cf2ae9cda634ee6907220859bd (diff) | |
Merge "Maintain existing train information"
| -rw-r--r-- | cmds/statsd/src/StatsService.cpp | 54 |
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); |