Loading cmds/statsd/src/StatsService.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -1210,20 +1210,22 @@ Status StatsService::sendBinaryPushStateChangedAtom(const android::String16& tra (long long)expId); } vector<uint8_t> buffer; buffer.resize(proto.size()); 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(&(buffer[pos]), iter.readBuffer(), toRead); std::memcpy(&(experimentIdsProtoBuffer[pos]), iter.readBuffer(), toRead); pos += toRead; iter.rp()->move(toRead); } LogEvent event(std::string(String8(trainName).string()), trainVersionCode, requiresStaging, rollbackEnabled, requiresLowLatencyMonitor, state, buffer, userId); std::string trainNameUtf8 = std::string(String8(trainName).string()); LogEvent event(trainNameUtf8, trainVersionCode, requiresStaging, rollbackEnabled, requiresLowLatencyMonitor, state, experimentIdsProtoBuffer, userId); mProcessor->OnLogEvent(&event); StorageManager::writeTrainInfo(trainVersionCode, buffer); StorageManager::writeTrainInfo(trainVersionCode, trainNameUtf8, state, experimentIdsProtoBuffer); return Status::ok(); } Loading cmds/statsd/src/atoms.proto +39 −2 Original line number Diff line number Diff line Loading @@ -3243,8 +3243,18 @@ message BinaryPushStateChanged { INSTALL_FAILURE = 6; INSTALL_CANCELLED = 7; INSTALLER_ROLLBACK_REQUESTED = 8; INSTALLER_ROLLBACK_SUCCESS = 9; INSTALLER_ROLLBACK_FAILURE = 10; INSTALLER_ROLLBACK_INITIATED = 9; INSTALLER_ROLLBACK_INITIATED_FAILURE = 10; INSTALLER_ROLLBACK_STAGED = 11; INSTALLER_ROLLBACK_STAGED_FAILURE = 12; INSTALLER_ROLLBACK_BOOT_TRIGGERED = 13; INSTALLER_ROLLBACK_BOOT_TRIGGERED_FAILURE = 14; INSTALLER_ROLLBACK_SUCCESS = 15; INSTALLER_ROLLBACK_FAILURE = 16; INSTALLER_ROLLBACK_CANCEL_STAGED_REMOVE_FROM_QUEUE = 17; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_INITIATED = 18; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_SUCCESS = 19; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_FAILURE = 20; } optional State state = 6; // Possible experiment ids for monitoring this push. Loading Loading @@ -5653,6 +5663,33 @@ message TrainInfo { optional int64 train_version_code = 1; optional TrainExperimentIds train_experiment_id = 2; optional string train_name = 3; enum Status { UNKNOWN = 0; INSTALL_REQUESTED = 1; INSTALL_STARTED = 2; INSTALL_STAGED_NOT_READY = 3; INSTALL_STAGED_READY = 4; INSTALL_SUCCESS = 5; INSTALL_FAILURE = 6; INSTALL_CANCELLED = 7; INSTALLER_ROLLBACK_REQUESTED = 8; INSTALLER_ROLLBACK_INITIATED = 9; INSTALLER_ROLLBACK_INITIATED_FAILURE = 10; INSTALLER_ROLLBACK_STAGED = 11; INSTALLER_ROLLBACK_STAGED_FAILURE = 12; INSTALLER_ROLLBACK_BOOT_TRIGGERED = 13; INSTALLER_ROLLBACK_BOOT_TRIGGERED_FAILURE = 14; INSTALLER_ROLLBACK_SUCCESS = 15; INSTALLER_ROLLBACK_FAILURE = 16; INSTALLER_ROLLBACK_CANCEL_STAGED_REMOVE_FROM_QUEUE = 17; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_INITIATED = 18; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_SUCCESS = 19; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_FAILURE = 20; } optional Status status = 4; } /** Loading cmds/statsd/src/logd/LogEvent.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -238,9 +238,12 @@ LogEvent::LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs, mLogdTimestampNs = wallClockTimestampNs; mElapsedTimestampNs = elapsedTimestampNs; mTagId = android::util::TRAIN_INFO; mValues.push_back( FieldValue(Field(mTagId, getSimpleField(1)), Value(trainInfo.trainVersionCode))); mValues.push_back(FieldValue(Field(mTagId, getSimpleField(2)), Value(trainInfo.experimentIds))); mValues.push_back(FieldValue(Field(mTagId, getSimpleField(3)), Value(trainInfo.trainName))); mValues.push_back(FieldValue(Field(mTagId, getSimpleField(4)), Value(trainInfo.status))); } LogEvent::LogEvent(int32_t tagId, int64_t timestampNs) : LogEvent(tagId, timestampNs, 0) {} Loading cmds/statsd/src/logd/LogEvent.h +2 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ struct AttributionNodeInternal { struct InstallTrainInfo { int64_t trainVersionCode; std::string trainName; int32_t status; std::vector<uint8_t> experimentIds; }; /** Loading cmds/statsd/src/storage/StorageManager.cpp +51 −4 Original line number Diff line number Diff line Loading @@ -95,8 +95,8 @@ void StorageManager::writeFile(const char* file, const void* buffer, int numByte close(fd); } bool StorageManager::writeTrainInfo(int64_t trainVersionCode, const std::vector<uint8_t>& experimentIds) { bool StorageManager::writeTrainInfo(int64_t trainVersionCode, const std::string& trainName, int32_t status, const std::vector<uint8_t>& experimentIds) { std::lock_guard<std::mutex> lock(sTrainInfoMutex); deleteAllFiles(TRAIN_INFO_DIR); Loading @@ -109,7 +109,34 @@ bool StorageManager::writeTrainInfo(int64_t trainVersionCode, return false; } size_t result = write(fd, experimentIds.data(), experimentIds.size()); size_t result; // Write # of bytes in trainName to file const size_t trainNameSize = trainName.size(); const size_t trainNameSizeByteCount = sizeof(trainNameSize); result = write(fd, (uint8_t*)&trainNameSize, trainNameSizeByteCount); if (result != trainNameSizeByteCount) { VLOG("Failed to write %s", file_name.c_str()); return false; } // Write trainName to file result = write(fd, trainName.c_str(), trainNameSize); if (result != trainNameSize) { VLOG("Failed to write %s", file_name.c_str()); return false; } // Write status to file const size_t statusByteCount = sizeof(status); result = write(fd, (uint8_t*)&status, statusByteCount); if (result != statusByteCount) { VLOG("Failed to write %s", file_name.c_str()); return false; } // Write experimentIds to file result = write(fd, experimentIds.data(), experimentIds.size()); if (result == experimentIds.size()) { VLOG("Successfully wrote %s", file_name.c_str()); } else { Loading Loading @@ -150,7 +177,27 @@ bool StorageManager::readTrainInfo(InstallTrainInfo& trainInfo) { string str; if (android::base::ReadFdToString(fd, &str)) { close(fd); std::copy(str.begin(), str.end(), std::back_inserter(trainInfo.experimentIds)); auto it = str.begin(); // Read # of bytes taken by trainName in the file size_t trainNameSize; const size_t trainNameSizeByteCount = sizeof(trainNameSize); std::copy_n(it, trainNameSizeByteCount, &trainNameSize); it += trainNameSizeByteCount; // Read trainName std::copy_n(it, trainNameSize, std::back_inserter(trainInfo.trainName)); it += trainNameSize; // Read status const size_t statusByteCount = sizeof(trainInfo.status); std::copy_n(it, statusByteCount, &trainInfo.status); it += statusByteCount; // Read experimentIds std::copy(it, str.end(), std::back_inserter(trainInfo.experimentIds)); VLOG("Read train info file successful: %s", fullPath.c_str()); return true; } Loading Loading
cmds/statsd/src/StatsService.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -1210,20 +1210,22 @@ Status StatsService::sendBinaryPushStateChangedAtom(const android::String16& tra (long long)expId); } vector<uint8_t> buffer; buffer.resize(proto.size()); 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(&(buffer[pos]), iter.readBuffer(), toRead); std::memcpy(&(experimentIdsProtoBuffer[pos]), iter.readBuffer(), toRead); pos += toRead; iter.rp()->move(toRead); } LogEvent event(std::string(String8(trainName).string()), trainVersionCode, requiresStaging, rollbackEnabled, requiresLowLatencyMonitor, state, buffer, userId); std::string trainNameUtf8 = std::string(String8(trainName).string()); LogEvent event(trainNameUtf8, trainVersionCode, requiresStaging, rollbackEnabled, requiresLowLatencyMonitor, state, experimentIdsProtoBuffer, userId); mProcessor->OnLogEvent(&event); StorageManager::writeTrainInfo(trainVersionCode, buffer); StorageManager::writeTrainInfo(trainVersionCode, trainNameUtf8, state, experimentIdsProtoBuffer); return Status::ok(); } Loading
cmds/statsd/src/atoms.proto +39 −2 Original line number Diff line number Diff line Loading @@ -3243,8 +3243,18 @@ message BinaryPushStateChanged { INSTALL_FAILURE = 6; INSTALL_CANCELLED = 7; INSTALLER_ROLLBACK_REQUESTED = 8; INSTALLER_ROLLBACK_SUCCESS = 9; INSTALLER_ROLLBACK_FAILURE = 10; INSTALLER_ROLLBACK_INITIATED = 9; INSTALLER_ROLLBACK_INITIATED_FAILURE = 10; INSTALLER_ROLLBACK_STAGED = 11; INSTALLER_ROLLBACK_STAGED_FAILURE = 12; INSTALLER_ROLLBACK_BOOT_TRIGGERED = 13; INSTALLER_ROLLBACK_BOOT_TRIGGERED_FAILURE = 14; INSTALLER_ROLLBACK_SUCCESS = 15; INSTALLER_ROLLBACK_FAILURE = 16; INSTALLER_ROLLBACK_CANCEL_STAGED_REMOVE_FROM_QUEUE = 17; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_INITIATED = 18; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_SUCCESS = 19; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_FAILURE = 20; } optional State state = 6; // Possible experiment ids for monitoring this push. Loading Loading @@ -5653,6 +5663,33 @@ message TrainInfo { optional int64 train_version_code = 1; optional TrainExperimentIds train_experiment_id = 2; optional string train_name = 3; enum Status { UNKNOWN = 0; INSTALL_REQUESTED = 1; INSTALL_STARTED = 2; INSTALL_STAGED_NOT_READY = 3; INSTALL_STAGED_READY = 4; INSTALL_SUCCESS = 5; INSTALL_FAILURE = 6; INSTALL_CANCELLED = 7; INSTALLER_ROLLBACK_REQUESTED = 8; INSTALLER_ROLLBACK_INITIATED = 9; INSTALLER_ROLLBACK_INITIATED_FAILURE = 10; INSTALLER_ROLLBACK_STAGED = 11; INSTALLER_ROLLBACK_STAGED_FAILURE = 12; INSTALLER_ROLLBACK_BOOT_TRIGGERED = 13; INSTALLER_ROLLBACK_BOOT_TRIGGERED_FAILURE = 14; INSTALLER_ROLLBACK_SUCCESS = 15; INSTALLER_ROLLBACK_FAILURE = 16; INSTALLER_ROLLBACK_CANCEL_STAGED_REMOVE_FROM_QUEUE = 17; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_INITIATED = 18; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_SUCCESS = 19; INSTALLER_ROLLBACK_CANCEL_STAGED_DELETE_SESSION_FAILURE = 20; } optional Status status = 4; } /** Loading
cmds/statsd/src/logd/LogEvent.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -238,9 +238,12 @@ LogEvent::LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs, mLogdTimestampNs = wallClockTimestampNs; mElapsedTimestampNs = elapsedTimestampNs; mTagId = android::util::TRAIN_INFO; mValues.push_back( FieldValue(Field(mTagId, getSimpleField(1)), Value(trainInfo.trainVersionCode))); mValues.push_back(FieldValue(Field(mTagId, getSimpleField(2)), Value(trainInfo.experimentIds))); mValues.push_back(FieldValue(Field(mTagId, getSimpleField(3)), Value(trainInfo.trainName))); mValues.push_back(FieldValue(Field(mTagId, getSimpleField(4)), Value(trainInfo.status))); } LogEvent::LogEvent(int32_t tagId, int64_t timestampNs) : LogEvent(tagId, timestampNs, 0) {} Loading
cmds/statsd/src/logd/LogEvent.h +2 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ struct AttributionNodeInternal { struct InstallTrainInfo { int64_t trainVersionCode; std::string trainName; int32_t status; std::vector<uint8_t> experimentIds; }; /** Loading
cmds/statsd/src/storage/StorageManager.cpp +51 −4 Original line number Diff line number Diff line Loading @@ -95,8 +95,8 @@ void StorageManager::writeFile(const char* file, const void* buffer, int numByte close(fd); } bool StorageManager::writeTrainInfo(int64_t trainVersionCode, const std::vector<uint8_t>& experimentIds) { bool StorageManager::writeTrainInfo(int64_t trainVersionCode, const std::string& trainName, int32_t status, const std::vector<uint8_t>& experimentIds) { std::lock_guard<std::mutex> lock(sTrainInfoMutex); deleteAllFiles(TRAIN_INFO_DIR); Loading @@ -109,7 +109,34 @@ bool StorageManager::writeTrainInfo(int64_t trainVersionCode, return false; } size_t result = write(fd, experimentIds.data(), experimentIds.size()); size_t result; // Write # of bytes in trainName to file const size_t trainNameSize = trainName.size(); const size_t trainNameSizeByteCount = sizeof(trainNameSize); result = write(fd, (uint8_t*)&trainNameSize, trainNameSizeByteCount); if (result != trainNameSizeByteCount) { VLOG("Failed to write %s", file_name.c_str()); return false; } // Write trainName to file result = write(fd, trainName.c_str(), trainNameSize); if (result != trainNameSize) { VLOG("Failed to write %s", file_name.c_str()); return false; } // Write status to file const size_t statusByteCount = sizeof(status); result = write(fd, (uint8_t*)&status, statusByteCount); if (result != statusByteCount) { VLOG("Failed to write %s", file_name.c_str()); return false; } // Write experimentIds to file result = write(fd, experimentIds.data(), experimentIds.size()); if (result == experimentIds.size()) { VLOG("Successfully wrote %s", file_name.c_str()); } else { Loading Loading @@ -150,7 +177,27 @@ bool StorageManager::readTrainInfo(InstallTrainInfo& trainInfo) { string str; if (android::base::ReadFdToString(fd, &str)) { close(fd); std::copy(str.begin(), str.end(), std::back_inserter(trainInfo.experimentIds)); auto it = str.begin(); // Read # of bytes taken by trainName in the file size_t trainNameSize; const size_t trainNameSizeByteCount = sizeof(trainNameSize); std::copy_n(it, trainNameSizeByteCount, &trainNameSize); it += trainNameSizeByteCount; // Read trainName std::copy_n(it, trainNameSize, std::back_inserter(trainInfo.trainName)); it += trainNameSize; // Read status const size_t statusByteCount = sizeof(trainInfo.status); std::copy_n(it, statusByteCount, &trainInfo.status); it += statusByteCount; // Read experimentIds std::copy(it, str.end(), std::back_inserter(trainInfo.experimentIds)); VLOG("Read train info file successful: %s", fullPath.c_str()); return true; } Loading