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

Commit f607e37f authored by Sandeep Dhavale's avatar Sandeep Dhavale Committed by Gerrit Code Review
Browse files

Merge "Print OTA merge progress state in logs"

parents 00bf9dcb 5bdb9dbb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -644,6 +644,7 @@ class SnapshotManager final : public ISnapshotManager {
    MergeFailureCode CheckMergeConsistency(LockedFile* lock, const std::string& name,
                                           const SnapshotStatus& update_status);

    auto UpdateStateToStr(enum UpdateState state);
    // Get status or table information about a device-mapper node with a single target.
    enum class TableQuery {
        Table,
+27 −3
Original line number Diff line number Diff line
@@ -988,6 +988,29 @@ bool SnapshotManager::IsSnapshotDevice(const std::string& dm_name, TargetInfo* t
    return true;
}

auto SnapshotManager::UpdateStateToStr(const enum UpdateState state) {
    switch (state) {
        case None:
            return "None";
        case Initiated:
            return "Initiated";
        case Unverified:
            return "Unverified";
        case Merging:
            return "Merging";
        case MergeNeedsReboot:
            return "MergeNeedsReboot";
        case MergeCompleted:
            return "MergeCompleted";
        case MergeFailed:
            return "MergeFailed";
        case Cancelled:
            return "Cancelled";
        default:
            return "Unknown";
    }
}

bool SnapshotManager::QuerySnapshotStatus(const std::string& dm_name, std::string* target_type,
                                          DmTargetSnapshot::Status* status) {
    DeviceMapper::TargetInfo target;
@@ -1016,7 +1039,7 @@ UpdateState SnapshotManager::ProcessUpdateState(const std::function<bool()>& cal
                                                const std::function<bool()>& before_cancel) {
    while (true) {
        auto result = CheckMergeState(before_cancel);
        LOG(INFO) << "ProcessUpdateState handling state: " << result.state;
        LOG(INFO) << "ProcessUpdateState handling state: " << UpdateStateToStr(result.state);

        if (result.state == UpdateState::MergeFailed) {
            AcknowledgeMergeFailure(result.failure_code);
@@ -1044,7 +1067,7 @@ auto SnapshotManager::CheckMergeState(const std::function<bool()>& before_cancel
    }

    auto result = CheckMergeState(lock.get(), before_cancel);
    LOG(INFO) << "CheckMergeState for snapshots returned: " << result.state;
    LOG(INFO) << "CheckMergeState for snapshots returned: " << UpdateStateToStr(result.state);

    if (result.state == UpdateState::MergeCompleted) {
        // Do this inside the same lock. Failures get acknowledged without the
@@ -1109,7 +1132,8 @@ auto SnapshotManager::CheckMergeState(LockedFile* lock, const std::function<bool
        }

        auto result = CheckTargetMergeState(lock, snapshot, update_status);
        LOG(INFO) << "CheckTargetMergeState for " << snapshot << " returned: " << result.state;
        LOG(INFO) << "CheckTargetMergeState for " << snapshot
                  << " returned: " << UpdateStateToStr(result.state);

        switch (result.state) {
            case UpdateState::MergeFailed: