aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor O'Brien2016-11-08 20:58:44 -0600
committerConnor O'Brien2016-11-16 13:07:24 -0600
commitf50593c447faf8415615b5dea2666d7f0f24a0fb (patch)
treee4af5fe7f8671f5e21d2e27941a09a03a37c249e /update_verifier
parentb76960c9845ba0e2f4dbfabe9dc747e752b8049e (diff)
downloadplatform-bootable-recovery-f50593c447faf8415615b5dea2666d7f0f24a0fb.tar.gz
platform-bootable-recovery-f50593c447faf8415615b5dea2666d7f0f24a0fb.tar.xz
platform-bootable-recovery-f50593c447faf8415615b5dea2666d7f0f24a0fb.zip
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 <connoro@google.com>
Diffstat (limited to 'update_verifier')
-rw-r--r--update_verifier/Android.mk5
-rw-r--r--update_verifier/update_verifier.cpp31
2 files changed, 21 insertions, 15 deletions
diff --git a/update_verifier/Android.mk b/update_verifier/Android.mk
index 8449c758..2c79d74b 100644
--- a/update_verifier/Android.mk
+++ b/update_verifier/Android.mk
@@ -24,7 +24,10 @@ LOCAL_SHARED_LIBRARIES := \
24 libbase \ 24 libbase \
25 libcutils \ 25 libcutils \
26 libhardware \ 26 libhardware \
27 liblog 27 liblog \
28 libutils \
29 libhidl \
30 android.hardware.boot@1.0
28 31
29LOCAL_CFLAGS := -Werror 32LOCAL_CFLAGS := -Werror
30LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. 33LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index 93ac605b..e97a3adb 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -45,7 +45,12 @@
45#include <android-base/strings.h> 45#include <android-base/strings.h>
46#include <android-base/unique_fd.h> 46#include <android-base/unique_fd.h>
47#include <cutils/properties.h> 47#include <cutils/properties.h>
48#include <hardware/boot_control.h> 48#include <android/hardware/boot/1.0/IBootControl.h>
49
50using android::sp;
51using android::hardware::boot::V1_0::IBootControl;
52using android::hardware::boot::V1_0::BoolResult;
53using android::hardware::boot::V1_0::CommandResult;
49 54
50constexpr auto CARE_MAP_FILE = "/data/ota_package/care_map.txt"; 55constexpr auto CARE_MAP_FILE = "/data/ota_package/care_map.txt";
51constexpr int BLOCKSIZE = 4096; 56constexpr int BLOCKSIZE = 4096;
@@ -142,21 +147,18 @@ int main(int argc, char** argv) {
142 LOG(INFO) << "Started with arg " << i << ": " << argv[i]; 147 LOG(INFO) << "Started with arg " << i << ": " << argv[i];
143 } 148 }
144 149
145 const hw_module_t* hw_module; 150 sp<IBootControl> module = IBootControl::getService("bootctrl");
146 if (hw_get_module("bootctrl", &hw_module) != 0) { 151 if (module == nullptr) {
147 LOG(ERROR) << "Error getting bootctrl module."; 152 LOG(ERROR) << "Error getting bootctrl module.";
148 return -1; 153 return -1;
149 } 154 }
150 155
151 boot_control_module_t* module = reinterpret_cast<boot_control_module_t*>( 156 uint32_t current_slot = module->getCurrentSlot();
152 const_cast<hw_module_t*>(hw_module)); 157 BoolResult is_successful = module->isSlotMarkedSuccessful(current_slot);
153 module->init(module); 158 LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful="
154 159 << static_cast<int32_t>(is_successful);
155 unsigned current_slot = module->getCurrentSlot(module);
156 int is_successful= module->isSlotMarkedSuccessful(module, current_slot);
157 LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful=" << is_successful;
158 160
159 if (is_successful == 0) { 161 if (is_successful == BoolResult::FALSE) {
160 // The current slot has not booted successfully. 162 // The current slot has not booted successfully.
161 char verity_mode[PROPERTY_VALUE_MAX]; 163 char verity_mode[PROPERTY_VALUE_MAX];
162 if (property_get("ro.boot.veritymode", verity_mode, "") == -1) { 164 if (property_get("ro.boot.veritymode", verity_mode, "") == -1) {
@@ -175,9 +177,10 @@ int main(int argc, char** argv) {
175 return -1; 177 return -1;
176 } 178 }
177 179
178 int ret = module->markBootSuccessful(module); 180 CommandResult cr;
179 if (ret != 0) { 181 module->markBootSuccessful([&cr](CommandResult result) { cr = result; });
180 LOG(ERROR) << "Error marking booted successfully: " << strerror(-ret); 182 if (!cr.success) {
183 LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg;
181 return -1; 184 return -1;
182 } 185 }
183 LOG(INFO) << "Marked slot " << current_slot << " as booted successfully."; 186 LOG(INFO) << "Marked slot " << current_slot << " as booted successfully.";