Loading fs_mgr/libsnapshot/android/snapshot/snapshot.proto +9 −0 Original line number Diff line number Diff line Loading @@ -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; } fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot_merge_stats.h +2 −4 Original line number Diff line number Diff line Loading @@ -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)); Loading @@ -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. Loading fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +4 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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, Loading fs_mgr/libsnapshot/include/libsnapshot/snapshot_stats.h +8 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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 Loading
fs_mgr/libsnapshot/android/snapshot/snapshot.proto +9 −0 Original line number Diff line number Diff line Loading @@ -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; }
fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot.h +1 −0 Original line number Diff line number Diff line Loading @@ -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
fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot_merge_stats.h +2 −4 Original line number Diff line number Diff line Loading @@ -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)); Loading @@ -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. Loading
fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +4 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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, Loading
fs_mgr/libsnapshot/include/libsnapshot/snapshot_stats.h +8 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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