David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 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 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_ |
| 18 | #define UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_ |
David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 19 | |
Yifan Hong | daac732 | 2019-11-07 10:48:26 -0800 | [diff] [blame^] | 20 | #include <memory> |
David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 21 | #include <string> |
| 22 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 23 | #include "update_engine/common/boot_control_interface.h" |
Yifan Hong | daac732 | 2019-11-07 10:48:26 -0800 | [diff] [blame^] | 24 | #include "update_engine/common/dynamic_partition_control_interface.h" |
David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 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 | // |
Sen Jiang | 771f648 | 2018-04-04 17:59:10 -0700 | [diff] [blame] | 32 | // You are guaranteed that the implementation of GetNumSlots() method |
David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 33 | // always returns 0. This can be used to identify that this |
| 34 | // implementation is in use. |
| 35 | class BootControlStub : public BootControlInterface { |
| 36 | public: |
Yifan Hong | daac732 | 2019-11-07 10:48:26 -0800 | [diff] [blame^] | 37 | BootControlStub(); |
David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 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 | BootControlInterface::Slot slot, |
| 45 | std::string* device) const override; |
| 46 | bool IsSlotBootable(BootControlInterface::Slot slot) const override; |
| 47 | bool MarkSlotUnbootable(BootControlInterface::Slot slot) override; |
| 48 | bool SetActiveBootSlot(BootControlInterface::Slot slot) override; |
| 49 | bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) override; |
Yifan Hong | 13d41cb | 2019-09-16 13:18:22 -0700 | [diff] [blame] | 50 | bool PreparePartitionsForUpdate(Slot slot, |
| 51 | const DeltaArchiveManifest& manifest, |
| 52 | bool update_metadata) override; |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 53 | void Cleanup() override; |
Yifan Hong | daac732 | 2019-11-07 10:48:26 -0800 | [diff] [blame^] | 54 | DynamicPartitionControlInterface* GetDynamicPartitionControl() override; |
David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 55 | |
| 56 | private: |
Yifan Hong | daac732 | 2019-11-07 10:48:26 -0800 | [diff] [blame^] | 57 | std::unique_ptr<DynamicPartitionControlInterface> dynamic_partition_control_; |
| 58 | |
David Zeuthen | 6eddf26 | 2015-10-16 15:23:53 -0400 | [diff] [blame] | 59 | DISALLOW_COPY_AND_ASSIGN(BootControlStub); |
| 60 | }; |
| 61 | |
| 62 | } // namespace chromeos_update_engine |
| 63 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 64 | #endif // UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_ |