blob: a1bdb965026ebf8e3e6eadbae8ef1efe6a5e1b3f [file] [log] [blame]
David Zeuthen6eddf262015-10-16 15:23:53 -04001//
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 Deymo39910dc2015-11-09 17:04:30 -080017#ifndef UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_
18#define UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_
David Zeuthen6eddf262015-10-16 15:23:53 -040019
Yifan Hongdaac7322019-11-07 10:48:26 -080020#include <memory>
David Zeuthen6eddf262015-10-16 15:23:53 -040021#include <string>
22
Alex Deymo39910dc2015-11-09 17:04:30 -080023#include "update_engine/common/boot_control_interface.h"
Yifan Hongdaac7322019-11-07 10:48:26 -080024#include "update_engine/common/dynamic_partition_control_interface.h"
David Zeuthen6eddf262015-10-16 15:23:53 -040025
26namespace 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 Jiang771f6482018-04-04 17:59:10 -070032// You are guaranteed that the implementation of GetNumSlots() method
David Zeuthen6eddf262015-10-16 15:23:53 -040033// always returns 0. This can be used to identify that this
34// implementation is in use.
35class BootControlStub : public BootControlInterface {
36 public:
Yifan Hongdaac7322019-11-07 10:48:26 -080037 BootControlStub();
David Zeuthen6eddf262015-10-16 15:23:53 -040038 ~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,
Tianjie51a5a392020-06-03 14:39:32 -070044 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,
David Zeuthen6eddf262015-10-16 15:23:53 -040049 BootControlInterface::Slot slot,
50 std::string* device) const override;
51 bool IsSlotBootable(BootControlInterface::Slot slot) const override;
52 bool MarkSlotUnbootable(BootControlInterface::Slot slot) override;
53 bool SetActiveBootSlot(BootControlInterface::Slot slot) override;
54 bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) override;
Yifan Hongf1415942020-02-24 18:34:49 -080055 bool IsSlotMarkedSuccessful(BootControlInterface::Slot slot) const override;
Yifan Hongdaac7322019-11-07 10:48:26 -080056 DynamicPartitionControlInterface* GetDynamicPartitionControl() override;
David Zeuthen6eddf262015-10-16 15:23:53 -040057
58 private:
Yifan Hongdaac7322019-11-07 10:48:26 -080059 std::unique_ptr<DynamicPartitionControlInterface> dynamic_partition_control_;
60
David Zeuthen6eddf262015-10-16 15:23:53 -040061 DISALLOW_COPY_AND_ASSIGN(BootControlStub);
62};
63
64} // namespace chromeos_update_engine
65
Alex Deymo39910dc2015-11-09 17:04:30 -080066#endif // UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_