From fa554fed444b3823b3b2962a274de421ed186822 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Fri, 1 Apr 2022 14:17:10 -0700 Subject: Convert recovery to use AIDL bootcontrol HAL Test: th Bug; 227536004 Change-Id: I14c0c337c931d10c9b9865a1c15eaff8fedf191e --- update_verifier/update_verifier.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'update_verifier/update_verifier.cpp') diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp index 88fcfa502..ea47a65ca 100644 --- a/update_verifier/update_verifier.cpp +++ b/update_verifier/update_verifier.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -59,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -67,11 +67,6 @@ #include "care_map.pb.h" -using android::sp; -using android::hardware::boot::V1_0::IBootControl; -using android::hardware::boot::V1_0::BoolResult; -using android::hardware::boot::V1_0::CommandResult; - // TODO(xunchang) remove the prefix and use a default path instead. constexpr const char* kDefaultCareMapPrefix = "/data/ota_package/care_map"; @@ -92,7 +87,7 @@ UpdateVerifier::UpdateVerifier() // partition's integrity. std::map UpdateVerifier::FindDmPartitions() { static constexpr auto DM_PATH_PREFIX = "/sys/block/"; - dirent** namelist; + dirent** namelist = nullptr; int n = scandir(DM_PATH_PREFIX, &namelist, dm_name_filter, alphasort); if (n == -1) { PLOG(ERROR) << "Failed to scan dir " << DM_PATH_PREFIX; @@ -329,18 +324,21 @@ int update_verifier(int argc, char** argv) { LOG(INFO) << "Started with arg " << i << ": " << argv[i]; } - sp module = IBootControl::getService(); + const auto module = android::hal::BootControlClient::WaitForService(); if (module == nullptr) { LOG(ERROR) << "Error getting bootctrl module."; return reboot_device(); } - 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 == BoolResult::FALSE) { + uint32_t current_slot = module->GetCurrentSlot(); + const auto is_successful = module->IsSlotMarkedSuccessful(current_slot); + if (!is_successful.has_value()) { + LOG(INFO) << "Booting slot " << current_slot << " failed"; + } else { + LOG(INFO) << "Booting slot " << current_slot + << ": isSlotMarkedSuccessful=" << is_successful.value(); + } + if (is_successful.has_value() && !is_successful.value()) { // The current slot has not booted successfully. bool skip_verification = false; @@ -386,8 +384,7 @@ int update_verifier(int argc, char** argv) { } if (!supports_checkpoint) { - CommandResult cr; - module->markBootSuccessful([&cr](CommandResult result) { cr = result; }); + const auto cr = module->MarkBootSuccessful(); if (!cr.success) { LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg; return reboot_device(); -- cgit v1.2.3