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 #include "update_engine/common/boot_control_stub.h"
18 #include "update_engine/common/dynamic_partition_control_stub.h"
19 
20 #include <base/logging.h>
21 
22 using std::string;
23 
24 namespace chromeos_update_engine {
25 
BootControlStub()26 BootControlStub::BootControlStub()
27     : dynamic_partition_control_(new DynamicPartitionControlStub()) {}
28 
GetNumSlots() const29 unsigned int BootControlStub::GetNumSlots() const {
30   return 0;
31 }
32 
GetCurrentSlot() const33 BootControlInterface::Slot BootControlStub::GetCurrentSlot() const {
34   LOG(ERROR) << __FUNCTION__ << " should never be called.";
35   return 0;
36 }
37 
GetPartitionDevice(const std::string & partition_name,BootControlInterface::Slot slot,bool not_in_payload,std::string * device,bool * is_dynamic) const38 bool BootControlStub::GetPartitionDevice(const std::string& partition_name,
39                                          BootControlInterface::Slot slot,
40                                          bool not_in_payload,
41                                          std::string* device,
42                                          bool* is_dynamic) const {
43   LOG(ERROR) << __FUNCTION__ << " should never be called.";
44   return false;
45 }
46 
GetPartitionDevice(const std::string & partition_name,uint32_t slot,uint32_t current_slot,bool not_in_payload) const47 std::optional<PartitionDevice> BootControlStub::GetPartitionDevice(
48     const std::string& partition_name,
49     uint32_t slot,
50     uint32_t current_slot,
51     bool not_in_payload) const {
52   LOG(ERROR) << __FUNCTION__ << " should never be called.";
53   return {};
54 }
55 
GetPartitionDevice(const string & partition_name,Slot slot,string * device) const56 bool BootControlStub::GetPartitionDevice(const string& partition_name,
57                                          Slot slot,
58                                          string* device) const {
59   LOG(ERROR) << __FUNCTION__ << " should never be called.";
60   return false;
61 }
62 
IsSlotBootable(Slot slot) const63 bool BootControlStub::IsSlotBootable(Slot slot) const {
64   LOG(ERROR) << __FUNCTION__ << " should never be called.";
65   return false;
66 }
67 
MarkSlotUnbootable(Slot slot)68 bool BootControlStub::MarkSlotUnbootable(Slot slot) {
69   LOG(ERROR) << __FUNCTION__ << " should never be called.";
70   return false;
71 }
72 
SetActiveBootSlot(Slot slot)73 bool BootControlStub::SetActiveBootSlot(Slot slot) {
74   LOG(ERROR) << __FUNCTION__ << " should never be called.";
75   return false;
76 }
77 
MarkBootSuccessfulAsync(base::Callback<void (bool)> callback)78 bool BootControlStub::MarkBootSuccessfulAsync(
79     base::Callback<void(bool)> callback) {
80   // This is expected to be called on update_engine startup.
81   return false;
82 }
83 
IsSlotMarkedSuccessful(Slot slot) const84 bool BootControlStub::IsSlotMarkedSuccessful(Slot slot) const {
85   LOG(ERROR) << __FUNCTION__ << " should never be called.";
86   return false;
87 }
88 
89 DynamicPartitionControlInterface*
GetDynamicPartitionControl()90 BootControlStub::GetDynamicPartitionControl() {
91   return dynamic_partition_control_.get();
92 }
93 
94 }  // namespace chromeos_update_engine
95