update_engine: Merge remote-tracking branch 'cros/upstream' into cros/master
Done with:
git merge cros/upstream --commit -s recursive
- Added EC key support and its unittests.
- Resolved a conlict on error codes. Since Android versions are not
uploading any UMA metrics, I gave the priority to the Android version
Since they can't be changed.
- Changed the openssl functions to get1 version (from get0) version
because of a current issue with gale. Once the issue is resolved we
need to change them back.
- Some remaining styling issues fixed by clang-format
BUG=b:163153182
TEST=CQ passes
TEST=unittests
Change-Id: Ib95034422b92433ce26e28336bc4806b34910d38
diff --git a/common/fake_boot_control.h b/common/fake_boot_control.h
index 3d65075..98b93e6 100644
--- a/common/fake_boot_control.h
+++ b/common/fake_boot_control.h
@@ -18,12 +18,14 @@
#define UPDATE_ENGINE_COMMON_FAKE_BOOT_CONTROL_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include <base/time/time.h>
#include "update_engine/common/boot_control_interface.h"
+#include "update_engine/common/dynamic_partition_control_stub.h"
namespace chromeos_update_engine {
@@ -34,6 +36,8 @@
SetNumSlots(num_slots_);
// The current slot should be bootable.
is_bootable_[current_slot_] = true;
+
+ dynamic_partition_control_.reset(new DynamicPartitionControlStub());
}
// BootControlInterface overrides.
@@ -44,16 +48,27 @@
bool GetPartitionDevice(const std::string& partition_name,
BootControlInterface::Slot slot,
- std::string* device) const override {
+ bool not_in_payload,
+ std::string* device,
+ bool* is_dynamic) const override {
if (slot >= num_slots_)
return false;
auto part_it = devices_[slot].find(partition_name);
if (part_it == devices_[slot].end())
return false;
*device = part_it->second;
+ if (is_dynamic != nullptr) {
+ *is_dynamic = false;
+ }
return true;
}
+ bool GetPartitionDevice(const std::string& partition_name,
+ BootControlInterface::Slot slot,
+ std::string* device) const override {
+ return GetPartitionDevice(partition_name, slot, false, device, nullptr);
+ }
+
bool IsSlotBootable(BootControlInterface::Slot slot) const override {
return slot < num_slots_ && is_bootable_[slot];
}
@@ -70,22 +85,20 @@
bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) override {
// We run the callback directly from here to avoid having to setup a message
// loop in the test environment.
+ is_marked_successful_[GetCurrentSlot()] = true;
callback.Run(true);
return true;
}
- bool InitPartitionMetadata(Slot slot,
- const PartitionMetadata& partition_metadata,
- bool update_metadata) override {
- return true;
+ bool IsSlotMarkedSuccessful(Slot slot) const override {
+ return slot < num_slots_ && is_marked_successful_[slot];
}
- void Cleanup() override {}
-
// Setters
void SetNumSlots(unsigned int num_slots) {
num_slots_ = num_slots;
is_bootable_.resize(num_slots_, false);
+ is_marked_successful_.resize(num_slots_, false);
devices_.resize(num_slots_);
}
@@ -103,13 +116,20 @@
is_bootable_[slot] = bootable;
}
+ DynamicPartitionControlInterface* GetDynamicPartitionControl() override {
+ return dynamic_partition_control_.get();
+ }
+
private:
BootControlInterface::Slot num_slots_{2};
BootControlInterface::Slot current_slot_{0};
std::vector<bool> is_bootable_;
+ std::vector<bool> is_marked_successful_;
std::vector<std::map<std::string, std::string>> devices_;
+ std::unique_ptr<DynamicPartitionControlInterface> dynamic_partition_control_;
+
DISALLOW_COPY_AND_ASSIGN(FakeBootControl);
};