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

Commit 114a2c09 authored by David Anderson's avatar David Anderson Committed by Yifan Hong
Browse files

libsnapshot: Communicate compression status to update_engine.

Bug: 178732971
Test: manual with statsd_testdrive

Change-Id: If480e5ef1f6fcdde7ccf6f5060f12d021f75b9a1
parent d42b34cb
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ message SnapshotUpdateStatus {
    MergePhase merge_phase = 6;
}

// Next: 4
// Next: 5
message SnapshotMergeReport {
    // Status of the update after the merge attempts.
    UpdateState state = 1;
@@ -167,4 +167,7 @@ message SnapshotMergeReport {

    // Total size of all the COW images before the update.
    uint64 cow_file_size = 3;

    // Whether compression/dm-user was used for any snapshots.
    bool compression_enabled = 4;
}
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class MockSnapshotManager : public ISnapshotManager {
                (const std::function<bool()>& callback, const std::function<bool()>& before_cancel),
                (override));
    MOCK_METHOD(UpdateState, GetUpdateState, (double* progress), (override));
    MOCK_METHOD(bool, UpdateUsesCompression, (), (override));
    MOCK_METHOD(Return, CreateUpdateSnapshots,
                (const chromeos_update_engine::DeltaArchiveManifest& manifest), (override));
    MOCK_METHOD(bool, MapUpdateSnapshot,
+8 −0
Original line number Diff line number Diff line
@@ -170,6 +170,10 @@ class ISnapshotManager {
    //   Other: 0
    virtual UpdateState GetUpdateState(double* progress = nullptr) = 0;

    // Returns true if compression is enabled for the current update. This always returns false if
    // UpdateState is None, or no snapshots have been created.
    virtual bool UpdateUsesCompression() = 0;

    // Create necessary COW device / files for OTA clients. New logical partitions will be added to
    // group "cow" in target_metadata. Regions of partitions of current_metadata will be
    // "write-protected" and snapshotted.
@@ -326,6 +330,7 @@ class SnapshotManager final : public ISnapshotManager {
    UpdateState ProcessUpdateState(const std::function<bool()>& callback = {},
                                   const std::function<bool()>& before_cancel = {}) override;
    UpdateState GetUpdateState(double* progress = nullptr) override;
    bool UpdateUsesCompression() override;
    Return CreateUpdateSnapshots(const DeltaArchiveManifest& manifest) override;
    bool MapUpdateSnapshot(const CreateLogicalPartitionParams& params,
                           std::string* snapshot_path) override;
@@ -720,6 +725,9 @@ class SnapshotManager final : public ISnapshotManager {

    SnapuserdClient* snapuserd_client() const { return snapuserd_client_.get(); }

    // Helper of UpdateUsesCompression
    bool UpdateUsesCompression(LockedFile* lock);

    std::string gsid_dir_;
    std::string metadata_dir_;
    std::unique_ptr<IDeviceInfo> device_;
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class ISnapshotMergeStats {
    virtual ~ISnapshotMergeStats() = default;
    // Called when merge starts or resumes.
    virtual bool Start() = 0;
    virtual void set_state(android::snapshot::UpdateState state) = 0;
    virtual void set_state(android::snapshot::UpdateState state, bool using_compression) = 0;
    virtual void set_cow_file_size(uint64_t cow_file_size) = 0;
    virtual uint64_t cow_file_size() = 0;

@@ -51,7 +51,7 @@ class SnapshotMergeStats : public ISnapshotMergeStats {

    // ISnapshotMergeStats overrides
    bool Start() override;
    void set_state(android::snapshot::UpdateState state) override;
    void set_state(android::snapshot::UpdateState state, bool using_compression) override;
    void set_cow_file_size(uint64_t cow_file_size) override;
    uint64_t cow_file_size() override;
    std::unique_ptr<Result> Finish() override;
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class SnapshotManagerStub : public ISnapshotManager {
    UpdateState ProcessUpdateState(const std::function<bool()>& callback = {},
                                   const std::function<bool()>& before_cancel = {}) override;
    UpdateState GetUpdateState(double* progress = nullptr) override;
    bool UpdateUsesCompression() override;
    Return CreateUpdateSnapshots(
            const chromeos_update_engine::DeltaArchiveManifest& manifest) override;
    bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params,
Loading