aboutsummaryrefslogtreecommitdiffstats
path: root/verifier_test.cpp
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2011-10-31 09:34:15 -0700
committerDoug Zongker <dougz@android.com>2011-10-31 15:51:07 -0700
commitdaefc1d442fb421606680feb9aeb59c133f4c427 (patch)
tree71b64ebdd66540aca7a523c73a47626ca519d039 /verifier_test.cpp
parentb88aea8a89f9d3344022cdfe895397baac6c05e7 (diff)
downloadbootable_recovery-daefc1d442fb421606680feb9aeb59c133f4c427.zip
bootable_recovery-daefc1d442fb421606680feb9aeb59c133f4c427.tar.gz
bootable_recovery-daefc1d442fb421606680feb9aeb59c133f4c427.tar.bz2
C++ class for device-specific code
Replace the device-specific functions with a class. Move some of the key handling (for log visibility toggling and rebooting) into the UI class. Fix up the key handling so there is less crosstalk between the immediate keys and the queued keys (an increasing annoyance on button-limited devices). Change-Id: I698f6fd21c67a1e55429312a0484b6c393cad46f
Diffstat (limited to 'verifier_test.cpp')
-rw-r--r--verifier_test.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/verifier_test.cpp b/verifier_test.cpp
index 5b6c1f4..2448d8d 100644
--- a/verifier_test.cpp
+++ b/verifier_test.cpp
@@ -19,6 +19,7 @@
#include <stdarg.h>
#include "verifier.h"
+#include "ui.h"
// This is build/target/product/security/testkey.x509.pem after being
// dumped out by dumpkey.jar.
@@ -58,18 +59,41 @@ RSAPublicKey test_key =
367251975, 810756730, -1941182952, 1175080310 }
};
-void ui_print(const char* fmt, ...) {
- char buf[256];
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, 256, fmt, ap);
- va_end(ap);
+RecoveryUI* ui = NULL;
- fputs(buf, stderr);
-}
+// verifier expects to find a UI object; we provide one that does
+// nothing but print.
+class FakeUI : public RecoveryUI {
+ void Init() { }
+ void SetBackground(Icon icon) { }
-void ui_set_progress(float fraction) {
-}
+ void SetProgressType(ProgressType determinate) { }
+ void ShowProgress(float portion, float seconds) { }
+ void SetProgress(float fraction) { }
+
+ void ShowText(bool visible) { }
+ bool IsTextVisible() { return false; }
+ bool WasTextEverVisible() { return false; }
+ void Print(const char* fmt, ...) {
+ char buf[256];
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(buf, 256, fmt, ap);
+ va_end(ap);
+
+ fputs(buf, stderr);
+ }
+
+ int WaitKey() { return 0; }
+ bool IsKeyPressed(int key) { return false; }
+ void FlushKeys() { }
+ KeyAction CheckKey(int key) { return ENQUEUE; }
+
+ void StartMenu(const char* const * headers, const char* const * items,
+ int initial_selection) { }
+ int SelectMenu(int sel) { return 0; }
+ void EndMenu() { }
+};
int main(int argc, char **argv) {
if (argc != 2) {
@@ -77,6 +101,8 @@ int main(int argc, char **argv) {
return 2;
}
+ ui = new FakeUI();
+
int result = verify_file(argv[1], &test_key, 1);
if (result == VERIFY_SUCCESS) {
printf("SUCCESS\n");