summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-07-31 05:02:02 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-07-31 05:02:02 +0200
commit6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a (patch)
treee90f35caed1adafb93032d344d316c523fb7ca77 /screen_ui.cpp
parentSnap for 4919674 from 40e5596aa7020fe65b3e14336c61d5e096a1f6b2 to qt-release (diff)
parentMerge "recovery: Add ability to interrupt UI" am: 561ee9362c am: 3528139409 am: 9e9ef363fb (diff)
downloadandroid_bootable_recovery-6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a.tar
android_bootable_recovery-6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a.tar.gz
android_bootable_recovery-6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a.tar.bz2
android_bootable_recovery-6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a.tar.lz
android_bootable_recovery-6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a.tar.xz
android_bootable_recovery-6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a.tar.zst
android_bootable_recovery-6e0d3d7bfbc4dcaeb1e999fd76a48eabd327274a.zip
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index f9c4a06c1..c14f29d49 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -417,6 +417,7 @@ void ScreenRecoveryUI::CheckBackgroundTextImages() {
FlushKeys();
while (true) {
int key = WaitKey();
+ if (key == static_cast<int>(KeyError::INTERRUPTED)) break;
if (key == KEY_POWER || key == KEY_ENTER) {
break;
} else if (key == KEY_UP || key == KEY_VOLUMEUP) {
@@ -925,6 +926,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
while (show_prompt) {
show_prompt = false;
int key = WaitKey();
+ if (key == static_cast<int>(KeyError::INTERRUPTED)) return;
if (key == KEY_POWER || key == KEY_ENTER) {
return;
} else if (key == KEY_UP || key == KEY_VOLUMEUP) {
@@ -1017,19 +1019,26 @@ size_t ScreenRecoveryUI::ShowMenu(const std::vector<std::string>& headers,
// Throw away keys pressed previously, so user doesn't accidentally trigger menu items.
FlushKeys();
+ // If there is a key interrupt in progress, return KeyError::INTERRUPTED without starting the
+ // menu.
+ if (IsKeyInterrupted()) return static_cast<size_t>(KeyError::INTERRUPTED);
+
StartMenu(headers, items, initial_selection);
int selected = initial_selection;
int chosen_item = -1;
while (chosen_item < 0) {
int key = WaitKey();
- if (key == -1) { // WaitKey() timed out.
+ if (key == static_cast<int>(KeyError::INTERRUPTED)) { // WaitKey() was interrupted.
+ return static_cast<size_t>(KeyError::INTERRUPTED);
+ }
+ if (key == static_cast<int>(KeyError::TIMED_OUT)) { // WaitKey() timed out.
if (WasTextEverVisible()) {
continue;
} else {
LOG(INFO) << "Timed out waiting for key input; rebooting.";
EndMenu();
- return static_cast<size_t>(-1);
+ return static_cast<size_t>(KeyError::TIMED_OUT);
}
}