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

Commit 19b6f5f4 authored by Yifan Hong's avatar Yifan Hong
Browse files

libsnapshot: Only EnsureImageManager when it is needed.

In functions / code paths where images_ is not used,
don't call EnsureImageManager.

Test: libsnapshot_test
Test: sideload on retrofit
Bug: 140749209
Change-Id: I36635e43b8c2e1c22524f8f4685a216d74c71ad7
parent 9a3ebd2d
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -342,7 +342,6 @@ bool SnapshotManager::MapSnapshot(LockedFile* lock, const std::string& name,
                                  const std::chrono::milliseconds& timeout_ms,
                                  std::string* dev_path) {
    CHECK(lock);
    if (!EnsureImageManager()) return false;

    SnapshotStatus status;
    if (!ReadSnapshotStatus(lock, name, &status)) {
@@ -1428,7 +1427,6 @@ bool SnapshotManager::MapCowDevices(LockedFile* lock, const CreateLogicalPartiti
                                    const SnapshotStatus& snapshot_status,
                                    AutoDeviceList* created_devices, std::string* cow_name) {
    CHECK(lock);
    if (!EnsureImageManager()) return false;
    CHECK(snapshot_status.cow_partition_size() + snapshot_status.cow_file_size() > 0);
    auto begin = std::chrono::steady_clock::now();

@@ -1440,6 +1438,7 @@ bool SnapshotManager::MapCowDevices(LockedFile* lock, const CreateLogicalPartiti

    // Map COW image if necessary.
    if (snapshot_status.cow_file_size() > 0) {
        if (!EnsureImageManager()) return false;
        auto remaining_time = GetRemainingTime(params.timeout_ms, begin);
        if (remaining_time.count() < 0) return false;