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

Commit 5bdb9dbb authored by Sandeep Dhavale's avatar Sandeep Dhavale
Browse files

Print OTA merge progress state in logs

Currently OTA merge process prints enum values in logs in numerical
form. This patch changes the log messages from numerical enums to
more friendly names.

Test: Manual OTA

===========Logs==========
CheckTargetMergeState for vendor_dlkm_b returned: Merging
ProcessUpdateState handling state: Merging
CheckTargetMergeState for product_b returned: Merging
CheckTargetMergeState for vendor_dlkm_b returned: MergeCompleted
ProcessUpdateState handling state: Merging
CheckTargetMergeState for product_b returned: MergeCompleted
ProcessUpdateState handling state: MergeCompleted

Bug: 234518211
Change-Id: If690d3ea86e6fe37e8b3e4bd52e87b70ae92495c
parent 932e069f
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: