diff options
author | Connor O'Brien | 2016-11-21 14:47:33 -0600 |
---|---|---|
committer | Connor O'Brien | 2016-11-21 15:48:42 -0600 |
commit | ad43d2dd30c5f2d9b5749e944377f43f6ff07488 (patch) | |
tree | 4874b64c29bf80e88d3557f165eb7d3e1a49121b /update_verifier | |
parent | 1d77c93bcc446971d700ca42bfc14cde207c1795 (diff) | |
download | platform-bootable-recovery-ad43d2dd30c5f2d9b5749e944377f43f6ff07488.tar.gz platform-bootable-recovery-ad43d2dd30c5f2d9b5749e944377f43f6ff07488.tar.xz platform-bootable-recovery-ad43d2dd30c5f2d9b5749e944377f43f6ff07488.zip |
Switch update verifier to HIDL HAL
Test: UV logs show success in both binderized and passthrough modes.
Bug: 31864052
Change-Id: Ied67a52c458dba7fe600e0fe7eca84db1a9f2587
Signed-off-by: Connor O'Brien <connoro@google.com>
Diffstat (limited to 'update_verifier')
-rw-r--r-- | update_verifier/Android.mk | 5 | ||||
-rw-r--r-- | update_verifier/update_verifier.cpp | 31 |
2 files changed, 21 insertions, 15 deletions
diff --git a/update_verifier/Android.mk b/update_verifier/Android.mk index 8449c758..49d19b0e 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 | libhidlbase \ | ||
30 | android.hardware.boot@1.0 | ||
28 | 31 | ||
29 | LOCAL_CFLAGS := -Werror | 32 | LOCAL_CFLAGS := -Werror |
30 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. | 33 | LOCAL_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 | |||
50 | using android::sp; | ||
51 | using android::hardware::boot::V1_0::IBootControl; | ||
52 | using android::hardware::boot::V1_0::BoolResult; | ||
53 | using android::hardware::boot::V1_0::CommandResult; | ||
49 | 54 | ||
50 | constexpr auto CARE_MAP_FILE = "/data/ota_package/care_map.txt"; | 55 | constexpr auto CARE_MAP_FILE = "/data/ota_package/care_map.txt"; |
51 | constexpr int BLOCKSIZE = 4096; | 56 | constexpr 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."; |