1 // 2 // Copyright (C) 2015 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_ 18 #define UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_ 19 20 #include <memory> 21 #include <string> 22 23 #include "update_engine/common/boot_control_interface.h" 24 #include "update_engine/common/dynamic_partition_control_interface.h" 25 26 namespace chromeos_update_engine { 27 28 // An implementation of the BootControlInterface that does nothing, 29 // typically used when e.g. an underlying HAL implementation cannot be 30 // loaded or doesn't exist. 31 // 32 // You are guaranteed that the implementation of GetNumSlots() method 33 // always returns 0. This can be used to identify that this 34 // implementation is in use. 35 class BootControlStub : public BootControlInterface { 36 public: 37 BootControlStub(); 38 ~BootControlStub() = default; 39 40 // BootControlInterface overrides. 41 unsigned int GetNumSlots() const override; 42 BootControlInterface::Slot GetCurrentSlot() const override; 43 bool GetPartitionDevice(const std::string& partition_name, 44 Slot slot, 45 bool not_in_payload, 46 std::string* device, 47 bool* is_dynamic) const override; 48 bool GetPartitionDevice(const std::string& partition_name, 49 BootControlInterface::Slot slot, 50 std::string* device) const override; 51 std::optional<PartitionDevice> GetPartitionDevice( 52 const std::string& partition_name, 53 uint32_t slot, 54 uint32_t current_slot, 55 bool not_in_payload = false) const override; 56 bool IsSlotBootable(BootControlInterface::Slot slot) const override; 57 bool MarkSlotUnbootable(BootControlInterface::Slot slot) override; 58 bool SetActiveBootSlot(BootControlInterface::Slot slot) override; 59 bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) override; 60 bool IsSlotMarkedSuccessful(BootControlInterface::Slot slot) const override; 61 DynamicPartitionControlInterface* GetDynamicPartitionControl() override; 62 63 private: 64 std::unique_ptr<DynamicPartitionControlInterface> dynamic_partition_control_; 65 66 DISALLOW_COPY_AND_ASSIGN(BootControlStub); 67 }; 68 69 } // namespace chromeos_update_engine 70 71 #endif // UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_ 72