BootControlAndroid: Implement using libhardware.
This simply calls into the a boot_control HAL implementation loaded with
libhardware. I've tested it with the implementation located in
system/extras/boot_control_copy.
The only non-trivial routine here is GetPartitionDevice() which I've
hand-tested on a device using the following snippet of code:
string names[] = {"boot", "system", "nope_enoent"};
for (string name : names) {
for (int slot = 0; slot <= 2; slot++) {
string device;
if (!GetPartitionDevice(name, slot, &device))
device = "NOTHERE";
LOG(INFO) << "slot:" << slot << " part:" << name << " -> " << device;
}
}
Change-Id: I1280325bd7cd4cf1cc9a33ef13c2f46f215da6e6
diff --git a/boot_control_android.h b/boot_control_android.h
index 21c5878..2e218a0 100644
--- a/boot_control_android.h
+++ b/boot_control_android.h
@@ -19,9 +19,10 @@
#include <string>
-#include <gtest/gtest_prod.h> // for FRIEND_TEST
+#include <hardware/boot_control.h>
+#include <hardware/hardware.h>
-#include "update_engine/boot_control_interface.h"
+#include "update_engine/boot_control.h"
namespace chromeos_update_engine {
@@ -32,6 +33,10 @@
BootControlAndroid() = default;
~BootControlAndroid() = default;
+ // Load boot_control HAL implementation using libhardware and
+ // initializes it. Returns false if an error occurred.
+ bool Init();
+
// BootControlInterface overrides.
unsigned int GetNumSlots() const override;
BootControlInterface::Slot GetCurrentSlot() const override;
@@ -42,6 +47,10 @@
bool MarkSlotUnbootable(BootControlInterface::Slot slot) override;
private:
+ // NOTE: There is no way to release/unload HAL implementations so
+ // this is essentially leaked on object destruction.
+ boot_control_module_t* module_;
+
DISALLOW_COPY_AND_ASSIGN(BootControlAndroid);
};