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 19 namespace android::snapshot { 20 21 class SnapshotManagerStub : public ISnapshotManager { 22 public: 23 // Create a stubbed snapshot manager. All calls into the stub fails. 24 static std::unique_ptr<ISnapshotManager> New(); 25 26 // ISnapshotManager overrides. 27 bool BeginUpdate() override; 28 bool CancelUpdate() override; 29 bool FinishedSnapshotWrites(bool wipe) override; 30 bool InitiateMerge(uint64_t* cow_file_size = nullptr) override; 31 UpdateState ProcessUpdateState(const std::function<bool()>& callback = {}, 32 const std::function<bool()>& before_cancel = {}) override; 33 UpdateState GetUpdateState(double* progress = nullptr) override; 34 Return CreateUpdateSnapshots( 35 const chromeos_update_engine::DeltaArchiveManifest& manifest) override; 36 bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params, 37 std::string* snapshot_path) override; 38 bool UnmapUpdateSnapshot(const std::string& target_partition_name) override; 39 bool NeedSnapshotsInFirstStageMount() override; 40 bool CreateLogicalAndSnapshotPartitions( 41 const std::string& super_device, 42 const std::chrono::milliseconds& timeout_ms = {}) override; 43 bool HandleImminentDataWipe(const std::function<void()>& callback = {}) override; 44 bool FinishMergeInRecovery() override; 45 CreateResult RecoveryCreateSnapshotDevices() override; 46 CreateResult RecoveryCreateSnapshotDevices( 47 const std::unique_ptr<AutoDevice>& metadata_device) override; 48 bool Dump(std::ostream& os) override; 49 std::unique_ptr<AutoDevice> EnsureMetadataMounted() override; 50 ISnapshotMergeStats* GetSnapshotMergeStatsInstance() override; 51 }; 52 53 } // namespace android::snapshot 54