From 5e535014dd7961fbf812abeaa27f3339775031f1 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 16 Mar 2017 17:37:38 -0700 Subject: Drop the dependency on 'ui' in verify_file(). verify_file() has a dependency on the global variable of 'ui' for posting the verification progress, which requires the users of libverifier to provide a UI instance. This CL adds an optional argument to verify_file() so that it can post the progress through the provided callback function. As a result, we can drop the MockUI class in verifier_test.cpp. Test: recovery_component_test passes. Test: verify_file() posts progress update when installing an OTA. Change-Id: I8b87d0f0d99777ea755d33d6dbbe2b6d44243bf1 --- verifier.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'verifier.h') diff --git a/verifier.h b/verifier.h index 58083fe14..067dab554 100644 --- a/verifier.h +++ b/verifier.h @@ -17,6 +17,7 @@ #ifndef _RECOVERY_VERIFIER_H #define _RECOVERY_VERIFIER_H +#include #include #include @@ -58,13 +59,14 @@ struct Certificate { std::unique_ptr ec; }; -/* addr and length define a an update package file that has been - * loaded (or mmap'ed, or whatever) into memory. Verify that the file - * is signed and the signature matches one of the given keys. Return - * one of the constants below. +/* + * 'addr' and 'length' define an update package file that has been loaded (or mmap'ed, or + * whatever) into memory. Verifies that the file is signed and the signature matches one of the + * given keys. It optionally accepts a callback function for posting the progress to. Returns one + * of the constants of VERIFY_SUCCESS and VERIFY_FAILURE. */ -int verify_file(unsigned char* addr, size_t length, - const std::vector& keys); +int verify_file(unsigned char* addr, size_t length, const std::vector& keys, + const std::function& set_progress = nullptr); bool load_keys(const char* filename, std::vector& certs); -- cgit v1.2.3