BootControl exposes DynamicPartitionControl.
Add BootControlInterface::GetDynamicPartitionControl, which
exposes the internal DynamicPartitionControlInterface object.
BootControlStub / FakeBootControl / BootControlChromeOS uses
DynamicPartitionControlStub (all functions succeeds).
BootControlAndroid uses DynamicPartitionControlAndroid.
GetPartitionDevice is exposed so that BootControlAndroid can use it.
Follow-up CLs delete duplicated PreparePartitionsForUpdate
and Cleanup from BootControlInterface so that BootControlAndroid remains
a thin wrapper of the HAL (+GetPartitionDevice, which exists before
dynamic partitions.)
Test: update_engine_unittests
Change-Id: Ifc2aa2ee8a63ef581c8ebc562ec158794ac51dfd
diff --git a/common/boot_control_interface.h b/common/boot_control_interface.h
index 9bf639a..2f8e9e3 100644
--- a/common/boot_control_interface.h
+++ b/common/boot_control_interface.h
@@ -25,6 +25,7 @@
#include <base/callback.h>
#include <base/macros.h>
+#include "update_engine/common/dynamic_partition_control_interface.h"
#include "update_engine/update_metadata.pb.h"
namespace chromeos_update_engine {
@@ -94,6 +95,9 @@
// Do necessary clean-up operations after the whole update.
virtual void Cleanup() = 0;
+ // Return the dynamic partition control interface.
+ virtual DynamicPartitionControlInterface* GetDynamicPartitionControl() = 0;
+
// Return a human-readable slot name used for logging.
static std::string SlotName(Slot slot) {
if (slot == kInvalidSlot)
diff --git a/common/boot_control_stub.cc b/common/boot_control_stub.cc
index b10e82f..6ae88f1 100644
--- a/common/boot_control_stub.cc
+++ b/common/boot_control_stub.cc
@@ -15,6 +15,7 @@
//
#include "update_engine/common/boot_control_stub.h"
+#include "update_engine/common/dynamic_partition_control_stub.h"
#include <base/logging.h>
@@ -22,6 +23,9 @@
namespace chromeos_update_engine {
+BootControlStub::BootControlStub()
+ : dynamic_partition_control_(new DynamicPartitionControlStub()) {}
+
unsigned int BootControlStub::GetNumSlots() const {
return 0;
}
@@ -69,4 +73,9 @@
LOG(ERROR) << __FUNCTION__ << " should never be called.";
}
+DynamicPartitionControlInterface*
+BootControlStub::GetDynamicPartitionControl() {
+ return dynamic_partition_control_.get();
+}
+
} // namespace chromeos_update_engine
diff --git a/common/boot_control_stub.h b/common/boot_control_stub.h
index f2973a2..3307813 100644
--- a/common/boot_control_stub.h
+++ b/common/boot_control_stub.h
@@ -17,9 +17,11 @@
#ifndef UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_
#define UPDATE_ENGINE_COMMON_BOOT_CONTROL_STUB_H_
+#include <memory>
#include <string>
#include "update_engine/common/boot_control_interface.h"
+#include "update_engine/common/dynamic_partition_control_interface.h"
namespace chromeos_update_engine {
@@ -32,7 +34,7 @@
// implementation is in use.
class BootControlStub : public BootControlInterface {
public:
- BootControlStub() = default;
+ BootControlStub();
~BootControlStub() = default;
// BootControlInterface overrides.
@@ -49,8 +51,11 @@
const DeltaArchiveManifest& manifest,
bool update_metadata) override;
void Cleanup() override;
+ DynamicPartitionControlInterface* GetDynamicPartitionControl() override;
private:
+ std::unique_ptr<DynamicPartitionControlInterface> dynamic_partition_control_;
+
DISALLOW_COPY_AND_ASSIGN(BootControlStub);
};
diff --git a/common/dynamic_partition_control_stub.cc b/common/dynamic_partition_control_stub.cc
new file mode 100644
index 0000000..86f75aa
--- /dev/null
+++ b/common/dynamic_partition_control_stub.cc
@@ -0,0 +1,49 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <stdint.h>
+
+#include <string>
+
+#include <base/logging.h>
+
+#include "update_engine/common/dynamic_partition_control_stub.h"
+
+namespace chromeos_update_engine {
+
+FeatureFlag DynamicPartitionControlStub::GetDynamicPartitionsFeatureFlag() {
+ return FeatureFlag(FeatureFlag::Value::NONE);
+}
+
+FeatureFlag DynamicPartitionControlStub::GetVirtualAbFeatureFlag() {
+ return FeatureFlag(FeatureFlag::Value::NONE);
+}
+
+void DynamicPartitionControlStub::Cleanup() {}
+
+bool DynamicPartitionControlStub::PreparePartitionsForUpdate(
+ uint32_t source_slot,
+ uint32_t target_slot,
+ const DeltaArchiveManifest& manifest,
+ bool update) {
+ return true;
+}
+
+bool DynamicPartitionControlStub::FinishUpdate() {
+ return true;
+}
+
+} // namespace chromeos_update_engine
diff --git a/common/dynamic_partition_control_stub.h b/common/dynamic_partition_control_stub.h
new file mode 100644
index 0000000..e7895de
--- /dev/null
+++ b/common/dynamic_partition_control_stub.h
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef UPDATE_ENGINE_COMMON_DYNAMIC_PARTITION_CONTROL_STUB_H_
+#define UPDATE_ENGINE_COMMON_DYNAMIC_PARTITION_CONTROL_STUB_H_
+
+#include <stdint.h>
+
+#include <string>
+
+#include "update_engine/common/dynamic_partition_control_interface.h"
+
+namespace chromeos_update_engine {
+
+class DynamicPartitionControlStub : public DynamicPartitionControlInterface {
+ public:
+ FeatureFlag GetDynamicPartitionsFeatureFlag() override;
+ FeatureFlag GetVirtualAbFeatureFlag() override;
+ void Cleanup() override;
+ bool PreparePartitionsForUpdate(uint32_t source_slot,
+ uint32_t target_slot,
+ const DeltaArchiveManifest& manifest,
+ bool update) override;
+
+ bool FinishUpdate() override;
+};
+
+} // namespace chromeos_update_engine
+
+#endif // UPDATE_ENGINE_COMMON_DYNAMIC_PARTITION_CONTROL_STUB_H_
diff --git a/common/fake_boot_control.h b/common/fake_boot_control.h
index 11810d1..1d6d979 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.
@@ -103,6 +107,10 @@
is_bootable_[slot] = bootable;
}
+ DynamicPartitionControlInterface* GetDynamicPartitionControl() {
+ return dynamic_partition_control_.get();
+ }
+
private:
BootControlInterface::Slot num_slots_{2};
BootControlInterface::Slot current_slot_{0};
@@ -110,6 +118,8 @@
std::vector<bool> is_bootable_;
std::vector<std::map<std::string, std::string>> devices_;
+ std::unique_ptr<DynamicPartitionControlInterface> dynamic_partition_control_;
+
DISALLOW_COPY_AND_ASSIGN(FakeBootControl);
};