summaryrefslogtreecommitdiffstats
path: root/ui.h
diff options
context:
space:
mode:
authorJerry Zhang <zhangjerry@google.com>2018-07-31 01:25:32 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-07-31 01:25:32 +0200
commite32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd (patch)
treee90f35caed1adafb93032d344d316c523fb7ca77 /ui.h
parentMerge "minadbd: avoid overrriding services_to_fd." am: 6f1f2c811a am: 06ce8d32e6 (diff)
parentMerge "recovery: Add ability to interrupt UI" am: 561ee9362c (diff)
downloadandroid_bootable_recovery-e32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd.tar
android_bootable_recovery-e32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd.tar.gz
android_bootable_recovery-e32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd.tar.bz2
android_bootable_recovery-e32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd.tar.lz
android_bootable_recovery-e32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd.tar.xz
android_bootable_recovery-e32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd.tar.zst
android_bootable_recovery-e32cd9bc1a4c50d819b8c5e112c28b73c11a6ecd.zip
Diffstat (limited to 'ui.h')
-rw-r--r--ui.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/ui.h b/ui.h
index 32e28099e..a1e18cc10 100644
--- a/ui.h
+++ b/ui.h
@@ -51,6 +51,11 @@ class RecoveryUI {
IGNORE
};
+ enum class KeyError : int {
+ TIMED_OUT = -1,
+ INTERRUPTED = -2,
+ };
+
RecoveryUI();
virtual ~RecoveryUI();
@@ -99,9 +104,13 @@ class RecoveryUI {
// --- key handling ---
- // Waits for a key and return it. May return -1 after timeout.
+ // Waits for a key and return it. May return TIMED_OUT after timeout and
+ // KeyError::INTERRUPTED on a key interrupt.
virtual int WaitKey();
+ // Wakes up the UI if it is waiting on key input, causing WaitKey to return KeyError::INTERRUPTED.
+ virtual void InterruptKey();
+
virtual bool IsKeyPressed(int key);
virtual bool IsLongPress();
@@ -147,11 +156,22 @@ class RecoveryUI {
// device-specific action, even without that being listed in the menu. Caller needs to handle
// such a case accordingly (e.g. by calling Device::InvokeMenuItem() to process the action).
// Returns a non-negative value (the chosen item number or device-specific action code), or
- // static_cast<size_t>(-1) if timed out waiting for input.
+ // static_cast<size_t>(TIMED_OUT) if timed out waiting for input or
+ // static_cast<size_t>(ERR_KEY_INTERTUPT) if interrupted, such as by InterruptKey().
virtual size_t ShowMenu(const std::vector<std::string>& headers,
const std::vector<std::string>& items, size_t initial_selection,
bool menu_only, const std::function<int(int, bool)>& key_handler) = 0;
+ // Resets the key interrupt status.
+ void ResetKeyInterruptStatus() {
+ key_interrupted_ = false;
+ }
+
+ // Returns the key interrupt status.
+ bool IsKeyInterrupted() const {
+ return key_interrupted_;
+ }
+
protected:
void EnqueueKey(int key_code);
@@ -187,10 +207,11 @@ class RecoveryUI {
bool IsUsbConnected();
bool InitScreensaver();
-
+ void SetScreensaverState(ScreensaverState state);
// Key event input queue
std::mutex key_queue_mutex;
std::condition_variable key_queue_cond;
+ bool key_interrupted_;
int key_queue[256], key_queue_len;
char key_pressed[KEY_MAX + 1]; // under key_queue_mutex
int key_last_down; // under key_queue_mutex