1 // Copyright (C) 2020 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <libsnapshot/snapshot.h> 18 #include <payload_consumer/file_descriptor.h> 19 20 namespace android::snapshot { 21 22 class SnapshotManagerStub : public ISnapshotManager { 23 public: 24 // Create a stubbed snapshot manager. All calls into the stub fails. 25 static std::unique_ptr<ISnapshotManager> New(); 26 27 // ISnapshotManager overrides. 28 bool BeginUpdate() override; 29 bool CancelUpdate() override; 30 bool FinishedSnapshotWrites(bool wipe) override; 31 void UpdateCowStats(ISnapshotMergeStats* stats) override; 32 MergeFailureCode ReadMergeFailureCode() override; 33 bool InitiateMerge() override; 34 UpdateState ProcessUpdateState(const std::function<bool()>& callback = {}, 35 const std::function<bool()>& before_cancel = {}) override; 36 UpdateState GetUpdateState(double* progress = nullptr) override; 37 bool UpdateUsesCompression() override; 38 Return CreateUpdateSnapshots( 39 const chromeos_update_engine::DeltaArchiveManifest& manifest) override; 40 bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params, 41 std::string* snapshot_path) override; 42 std::unique_ptr<ISnapshotWriter> OpenSnapshotWriter( 43 const android::fs_mgr::CreateLogicalPartitionParams& params, 44 const std::optional<std::string>& source_device) override; 45 bool UnmapUpdateSnapshot(const std::string& target_partition_name) override; 46 bool NeedSnapshotsInFirstStageMount() override; 47 bool CreateLogicalAndSnapshotPartitions( 48 const std::string& super_device, 49 const std::chrono::milliseconds& timeout_ms = {}) override; 50 bool HandleImminentDataWipe(const std::function<void()>& callback = {}) override; 51 bool FinishMergeInRecovery() override; 52 CreateResult RecoveryCreateSnapshotDevices() override; 53 CreateResult RecoveryCreateSnapshotDevices( 54 const std::unique_ptr<AutoDevice>& metadata_device) override; 55 bool Dump(std::ostream& os) override; 56 std::unique_ptr<AutoDevice> EnsureMetadataMounted() override; 57 ISnapshotMergeStats* GetSnapshotMergeStatsInstance() override; 58 bool MapAllSnapshots(const std::chrono::milliseconds& timeout_ms) override; 59 bool UnmapAllSnapshots() override; 60 std::string ReadSourceBuildFingerprint() override; 61 }; 62 63 } // namespace android::snapshot 64