summaryrefslogtreecommitdiffstats
path: root/update_verifier
diff options
context:
space:
mode:
authorConnor O'Brien <connoro@google.com>2016-11-16 22:34:21 +0100
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-11-16 22:34:22 +0100
commita5f8c5dd59a527ef436022eff59e46f09dc50e27 (patch)
treefc7d39d65dc01c63dadc0775b44ae24b5b43f3ac /update_verifier
parentMerge "Use static_cast to cast pointers returned by malloc/calloc/realloc/mmap." am: 0bedc8e14c am: 0c15140dad am: b8c4ae9f80 (diff)
parentConvert update_verifier to boot HIDL HAL (diff)
downloadandroid_bootable_recovery-a5f8c5dd59a527ef436022eff59e46f09dc50e27.tar
android_bootable_recovery-a5f8c5dd59a527ef436022eff59e46f09dc50e27.tar.gz
android_bootable_recovery-a5f8c5dd59a527ef436022eff59e46f09dc50e27.tar.bz2
android_bootable_recovery-a5f8c5dd59a527ef436022eff59e46f09dc50e27.tar.lz
android_bootable_recovery-a5f8c5dd59a527ef436022eff59e46f09dc50e27.tar.xz
android_bootable_recovery-a5f8c5dd59a527ef436022eff59e46f09dc50e27.tar.zst
android_bootable_recovery-a5f8c5dd59a527ef436022eff59e46f09dc50e27.zip
Diffstat (limited to '')
-rw-r--r--update_verifier/Android.mk9
-rw-r--r--update_verifier/update_verifier.cpp31
2 files changed, 25 insertions, 15 deletions
diff --git a/update_verifier/Android.mk b/update_verifier/Android.mk
index 090db998b..5d118f873 100644
--- a/update_verifier/Android.mk
+++ b/update_verifier/Android.mk
@@ -20,7 +20,14 @@ LOCAL_CLANG := true
LOCAL_SRC_FILES := update_verifier.cpp
LOCAL_MODULE := update_verifier
-LOCAL_SHARED_LIBRARIES := libbase libcutils libhardware liblog
+LOCAL_SHARED_LIBRARIES := \
+ libbase \
+ libcutils \
+ libhardware \
+ liblog \
+ libutils \
+ libhidl \
+ android.hardware.boot@1.0
LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
LOCAL_CFLAGS := -Werror
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 <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
-#include <hardware/boot_control.h>
+#include <android/hardware/boot/1.0/IBootControl.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;
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<IBootControl> module = IBootControl::getService("bootctrl");
+ if (module == nullptr) {
LOG(ERROR) << "Error getting bootctrl module.";
return -1;
}
- boot_control_module_t* module = reinterpret_cast<boot_control_module_t*>(
- const_cast<hw_module_t*>(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<int32_t>(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.";