From f50593c447faf8415615b5dea2666d7f0f24a0fb Mon Sep 17 00:00:00 2001 From: Connor O'Brien Date: Tue, 8 Nov 2016 18:58:44 -0800 Subject: Convert update_verifier to boot HIDL HAL Test: Flashed device and confirmed update_verifier runs successfully Change-Id: I5bce4ece1e3ba98f57299c9cf469a5e2a5226ff2 Merged-In: I5bce4ece1e3ba98f57299c9cf469a5e2a5226ff2 Signed-off-by: Connor O'Brien --- update_verifier/Android.mk | 5 ++++- update_verifier/update_verifier.cpp | 31 +++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'update_verifier') diff --git a/update_verifier/Android.mk b/update_verifier/Android.mk index 8449c758d..2c79d74b9 100644 --- a/update_verifier/Android.mk +++ b/update_verifier/Android.mk @@ -24,7 +24,10 @@ LOCAL_SHARED_LIBRARIES := \ libbase \ libcutils \ libhardware \ - liblog + liblog \ + libutils \ + libhidl \ + android.hardware.boot@1.0 LOCAL_CFLAGS := -Werror LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp index 93ac605b1..e97a3adba 100644 --- a/update_verifier/update_verifier.cpp +++ b/update_verifier/update_verifier.cpp @@ -45,7 +45,12 @@ #include #include #include -#include +#include + +using android::sp; +using android::hardware::boot::V1_0::IBootControl; +using android::hardware::boot::V1_0::BoolResult; +using android::hardware::boot::V1_0::CommandResult; constexpr auto CARE_MAP_FILE = "/data/ota_package/care_map.txt"; constexpr int BLOCKSIZE = 4096; @@ -142,21 +147,18 @@ int main(int argc, char** argv) { LOG(INFO) << "Started with arg " << i << ": " << argv[i]; } - const hw_module_t* hw_module; - if (hw_get_module("bootctrl", &hw_module) != 0) { + sp module = IBootControl::getService("bootctrl"); + if (module == nullptr) { LOG(ERROR) << "Error getting bootctrl module."; return -1; } - boot_control_module_t* module = reinterpret_cast( - const_cast(hw_module)); - module->init(module); - - unsigned current_slot = module->getCurrentSlot(module); - int is_successful= module->isSlotMarkedSuccessful(module, current_slot); - LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful=" << is_successful; + uint32_t current_slot = module->getCurrentSlot(); + BoolResult is_successful = module->isSlotMarkedSuccessful(current_slot); + LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful=" + << static_cast(is_successful); - if (is_successful == 0) { + if (is_successful == BoolResult::FALSE) { // The current slot has not booted successfully. char verity_mode[PROPERTY_VALUE_MAX]; if (property_get("ro.boot.veritymode", verity_mode, "") == -1) { @@ -175,9 +177,10 @@ int main(int argc, char** argv) { return -1; } - int ret = module->markBootSuccessful(module); - if (ret != 0) { - LOG(ERROR) << "Error marking booted successfully: " << strerror(-ret); + CommandResult cr; + module->markBootSuccessful([&cr](CommandResult result) { cr = result; }); + if (!cr.success) { + LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg; return -1; } LOG(INFO) << "Marked slot " << current_slot << " as booted successfully."; -- cgit v1.2.3