summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2022-06-29 21:22:14 +0200
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-06-29 21:22:14 +0200
commit52e29ebb9b927237f6f23325642efb2953ccba73 (patch)
tree64d4ef6b1741ae763ac744b5d9e11d1959df3cfc
parentMerge "[MTE] Reset memtag message on factory reset." am: a2a93106b7 am: 1671d67b94 am: a5b5ca9fd1 am: e4fcd34c2c am: f149ab2e20 (diff)
parentMerge "Convert recovery to use AIDL bootcontrol HAL" am: ab532fdfc7 am: 819c91a522 am: 5a1e806401 am: 4d6b01ad17 (diff)
downloadandroid_bootable_recovery-52e29ebb9b927237f6f23325642efb2953ccba73.tar
android_bootable_recovery-52e29ebb9b927237f6f23325642efb2953ccba73.tar.gz
android_bootable_recovery-52e29ebb9b927237f6f23325642efb2953ccba73.tar.bz2
android_bootable_recovery-52e29ebb9b927237f6f23325642efb2953ccba73.tar.lz
android_bootable_recovery-52e29ebb9b927237f6f23325642efb2953ccba73.tar.xz
android_bootable_recovery-52e29ebb9b927237f6f23325642efb2953ccba73.tar.zst
android_bootable_recovery-52e29ebb9b927237f6f23325642efb2953ccba73.zip
-rw-r--r--Android.bp3
-rw-r--r--update_verifier/Android.bp4
-rw-r--r--update_verifier/update_verifier.cpp29
3 files changed, 19 insertions, 17 deletions
diff --git a/Android.bp b/Android.bp
index bd9570500..81de7779e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -94,6 +94,8 @@ cc_defaults {
shared_libs: [
"android.hardware.boot@1.0",
"android.hardware.boot@1.1",
+ "android.hardware.boot-V1-ndk",
+ "libboot_control_client",
"libbase",
"libbootloader_message",
"libcrypto",
@@ -158,6 +160,7 @@ cc_binary {
shared_libs: [
"android.hardware.health-V1-ndk", // from librecovery_utils
+ "android.hardware.boot-V1-ndk",
"librecovery_ui",
],
diff --git a/update_verifier/Android.bp b/update_verifier/Android.bp
index cb97bd1f7..3c4ec4a99 100644
--- a/update_verifier/Android.bp
+++ b/update_verifier/Android.bp
@@ -74,11 +74,12 @@ cc_library_static {
],
whole_static_libs: [
- "libsnapshot_snapuserd",
+ "libsnapshot_snapuserd",
],
shared_libs: [
"android.hardware.boot@1.0",
+ "libboot_control_client",
"libbase",
"libcutils",
"libbinder",
@@ -118,6 +119,7 @@ cc_binary {
"libprotobuf-cpp-lite",
"libbinder",
"libutils",
+ "libboot_control_client",
],
init_rc: [
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 <future>
#include <thread>
+#include <BootControlClient.h>
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -59,7 +60,6 @@
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
-#include <android/hardware/boot/1.0/IBootControl.h>
#include <android/os/IVold.h>
#include <binder/BinderService.h>
#include <binder/Status.h>
@@ -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<std::string, std::string> 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<IBootControl> 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<int32_t>(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();