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 bool UpdateUsesUserSnapshots() override; 39 Return CreateUpdateSnapshots( 40 const chromeos_update_engine::DeltaArchiveManifest& manifest) override; 41 bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params, 42 std::string* snapshot_path) override; 43 std::unique_ptr<ICowWriter> OpenSnapshotWriter( 44 const android::fs_mgr::CreateLogicalPartitionParams& params, 45 std::optional<uint64_t> label) override; 46 bool UnmapUpdateSnapshot(const std::string& target_partition_name) override; 47 bool NeedSnapshotsInFirstStageMount() override; 48 bool CreateLogicalAndSnapshotPartitions( 49 const std::string& super_device, 50 const std::chrono::milliseconds& timeout_ms = {}) override; 51 bool HandleImminentDataWipe(const std::function<void()>& callback = {}) override; 52 bool FinishMergeInRecovery() override; 53 CreateResult RecoveryCreateSnapshotDevices() override; 54 CreateResult RecoveryCreateSnapshotDevices( 55 const std::unique_ptr<AutoDevice>& metadata_device) override; 56 bool Dump(std::ostream& os) override; 57 std::unique_ptr<AutoDevice> EnsureMetadataMounted() override; 58 ISnapshotMergeStats* GetSnapshotMergeStatsInstance() override; 59 bool MapAllSnapshots(const std::chrono::milliseconds& timeout_ms) override; 60 bool UnmapAllSnapshots() override; 61 std::string ReadSourceBuildFingerprint() override; 62 void SetMergeStatsFeatures(ISnapshotMergeStats* stats) override; 63 }; 64 65 } // namespace android::snapshot 66