Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6983ad3f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Maintain existing train information"

parents 289cd11c bbe311c0
Loading
Loading
Loading
Loading
+36 −18
Original line number Diff line number Diff line
@@ -1198,19 +1198,26 @@ Status StatsService::sendBinaryPushStateChangedAtom(const android::String16& tra
    }
    // TODO: add verifier permission

    userid_t userId = multiuser_get_user_id(uid);
    bool readTrainInfoSuccess = false;
    InstallTrainInfo trainInfo;
    if (trainVersionCode == -1 || experimentIds.empty() || trainName.size() == 0) {
        readTrainInfoSuccess = StorageManager::readTrainInfo(trainInfo);
    }

    bool requiresStaging = options & IStatsManager::FLAG_REQUIRE_STAGING;
    bool rollbackEnabled = options & IStatsManager::FLAG_ROLLBACK_ENABLED;
    bool requiresLowLatencyMonitor = options & IStatsManager::FLAG_REQUIRE_LOW_LATENCY_MONITOR;
    if (trainVersionCode == -1 && readTrainInfoSuccess) {
        trainVersionCode = trainInfo.trainVersionCode;
    }

    vector<uint8_t> experimentIdsProtoBuffer;
    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);
        }

    vector<uint8_t> experimentIdsProtoBuffer;
        experimentIdsProtoBuffer.resize(proto.size());
        size_t pos = 0;
        auto iter = proto.data();
@@ -1220,8 +1227,19 @@ Status StatsService::sendBinaryPushStateChangedAtom(const android::String16& tra
            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);