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

Commit 1acfc08e authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge "libsnapshot: Add more feature flags to SnapshotMergeReport."

parents 3c8a95e3 93faa18b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -235,4 +235,13 @@ message SnapshotMergeReport {

    // The source fingerprint at the time the OTA was downloaded.
    string source_build_fingerprint = 10;

    // Whether this update attempt uses userspace snapshots.
    bool userspace_snapshots_used = 11;

    // Whether this update attempt uses XOR compression.
    bool xor_compression_used = 12;

    // Whether this update attempt used io_uring.
    bool iouring_used = 13;
}
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ class MockSnapshotManager : public ISnapshotManager {
    MOCK_METHOD(std::unique_ptr<AutoDevice>, EnsureMetadataMounted, (), (override));
    MOCK_METHOD(ISnapshotMergeStats*, GetSnapshotMergeStatsInstance, (), (override));
    MOCK_METHOD(std::string, ReadSourceBuildFingerprint, (), (override));
    MOCK_METHOD(void, SetMergeStatsFeatures, (ISnapshotMergeStats*), (override));
};

}  // namespace android::snapshot
+2 −4
Original line number Diff line number Diff line
@@ -28,10 +28,7 @@ class MockSnapshotMergeStats final : public ISnapshotMergeStats {
    virtual ~MockSnapshotMergeStats() = default;
    // Called when merge starts or resumes.
    MOCK_METHOD(bool, Start, (), (override));
    MOCK_METHOD(void, set_state, (android::snapshot::UpdateState, bool), (override));
    MOCK_METHOD(void, set_cow_file_size, (uint64_t), ());
    MOCK_METHOD(void, set_total_cow_size_bytes, (uint64_t), (override));
    MOCK_METHOD(void, set_estimated_cow_size_bytes, (uint64_t), (override));
    MOCK_METHOD(void, set_state, (android::snapshot::UpdateState), (override));
    MOCK_METHOD(void, set_boot_complete_time_ms, (uint32_t), (override));
    MOCK_METHOD(void, set_boot_complete_to_merge_start_time_ms, (uint32_t), (override));
    MOCK_METHOD(void, set_merge_failure_code, (MergeFailureCode), (override));
@@ -45,6 +42,7 @@ class MockSnapshotMergeStats final : public ISnapshotMergeStats {
    MOCK_METHOD(MergeFailureCode, merge_failure_code, (), (override));
    MOCK_METHOD(std::unique_ptr<Result>, Finish, (), (override));
    MOCK_METHOD(bool, WriteState, (), (override));
    MOCK_METHOD(SnapshotMergeReport*, report, (), (override));

    using ISnapshotMergeStats::Result;
    // Return nullptr if any failure.
+4 −0
Original line number Diff line number Diff line
@@ -134,6 +134,9 @@ class ISnapshotManager {
    // may need to be merged before wiping.
    virtual bool FinishedSnapshotWrites(bool wipe) = 0;

    // Set feature flags on an ISnapshotMergeStats object.
    virtual void SetMergeStatsFeatures(ISnapshotMergeStats* stats) = 0;

    // Update an ISnapshotMergeStats object with statistics about COW usage.
    // This should be called before the merge begins as otherwise snapshots
    // may be deleted.
@@ -378,6 +381,7 @@ class SnapshotManager final : public ISnapshotManager {
    bool MapAllSnapshots(const std::chrono::milliseconds& timeout_ms = {}) override;
    bool UnmapAllSnapshots() override;
    std::string ReadSourceBuildFingerprint() override;
    void SetMergeStatsFeatures(ISnapshotMergeStats* stats) override;

    // We can't use WaitForFile during first-stage init, because ueventd is not
    // running and therefore will not automatically create symlinks. Instead,
+8 −8
Original line number Diff line number Diff line
@@ -28,10 +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, bool using_compression) = 0;
    virtual void set_cow_file_size(uint64_t cow_file_size) = 0;
    virtual void set_total_cow_size_bytes(uint64_t bytes) = 0;
    virtual void set_estimated_cow_size_bytes(uint64_t bytes) = 0;
    virtual void set_state(android::snapshot::UpdateState state) = 0;
    virtual void set_boot_complete_time_ms(uint32_t ms) = 0;
    virtual void set_boot_complete_to_merge_start_time_ms(uint32_t ms) = 0;
    virtual void set_merge_failure_code(MergeFailureCode code) = 0;
@@ -55,6 +52,9 @@ class ISnapshotMergeStats {
    // Return nullptr if any failure.
    virtual std::unique_ptr<Result> Finish() = 0;

    // Return the underlying implementation.
    virtual SnapshotMergeReport* report() = 0;

    // Write out the current state. This should be called when data might be lost that
    // cannot be recovered (eg the COW sizes).
    virtual bool WriteState() = 0;
@@ -67,11 +67,8 @@ class SnapshotMergeStats : public ISnapshotMergeStats {

    // ISnapshotMergeStats overrides
    bool Start() override;
    void set_state(android::snapshot::UpdateState state, bool using_compression) override;
    void set_cow_file_size(uint64_t cow_file_size) override;
    void set_state(android::snapshot::UpdateState state) override;
    uint64_t cow_file_size() override;
    void set_total_cow_size_bytes(uint64_t bytes) override;
    void set_estimated_cow_size_bytes(uint64_t bytes) override;
    uint64_t total_cow_size_bytes() override;
    uint64_t estimated_cow_size_bytes() override;
    void set_boot_complete_time_ms(uint32_t ms) override;
@@ -85,6 +82,9 @@ class SnapshotMergeStats : public ISnapshotMergeStats {
    std::unique_ptr<Result> Finish() override;
    bool WriteState() override;

    // Access the underlying report before it is finished.
    SnapshotMergeReport* report() override { return &report_; }

  private:
    bool ReadState();
    bool DeleteState();
Loading