diff options
author | Tianjie Xu <xunchang@google.com> | 2019-07-10 19:46:27 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-07-10 19:46:27 +0200 |
commit | 33bb113af21edd00d15bbdf843c9cffe2d96ac90 (patch) | |
tree | b2b4793320304924b0b58257c1585a5c68e67b56 | |
parent | Merge "Create a fallback to install from fuse if mmap fails" (diff) | |
parent | Add a new key_pressed_mutex (diff) | |
download | android_bootable_recovery-33bb113af21edd00d15bbdf843c9cffe2d96ac90.tar android_bootable_recovery-33bb113af21edd00d15bbdf843c9cffe2d96ac90.tar.gz android_bootable_recovery-33bb113af21edd00d15bbdf843c9cffe2d96ac90.tar.bz2 android_bootable_recovery-33bb113af21edd00d15bbdf843c9cffe2d96ac90.tar.lz android_bootable_recovery-33bb113af21edd00d15bbdf843c9cffe2d96ac90.tar.xz android_bootable_recovery-33bb113af21edd00d15bbdf843c9cffe2d96ac90.tar.zst android_bootable_recovery-33bb113af21edd00d15bbdf843c9cffe2d96ac90.zip |
-rw-r--r-- | recovery_ui/include/recovery_ui/ui.h | 15 | ||||
-rw-r--r-- | recovery_ui/ui.cpp | 12 |
2 files changed, 15 insertions, 12 deletions
diff --git a/recovery_ui/include/recovery_ui/ui.h b/recovery_ui/include/recovery_ui/ui.h index d2ebad25b..a95f935e4 100644 --- a/recovery_ui/include/recovery_ui/ui.h +++ b/recovery_ui/include/recovery_ui/ui.h @@ -236,13 +236,16 @@ class RecoveryUI { 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 - bool key_long_press; // under key_queue_mutex - int key_down_count; // under key_queue_mutex - bool enable_reboot; // under key_queue_mutex - int rel_sum; + // key press events + std::mutex key_press_mutex; + char key_pressed[KEY_MAX + 1]; + int key_last_down; + bool key_long_press; + int key_down_count; + bool enable_reboot; + + int rel_sum; int consecutive_power_keys; bool has_power_key; diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp index 1f1cd18b1..98c654ddb 100644 --- a/recovery_ui/ui.cpp +++ b/recovery_ui/ui.cpp @@ -345,7 +345,7 @@ void RecoveryUI::ProcessKey(int key_code, int updown) { bool long_press = false; { - std::lock_guard<std::mutex> lg(key_queue_mutex); + std::lock_guard<std::mutex> lg(key_press_mutex); key_pressed[key_code] = updown; if (updown) { ++key_down_count; @@ -392,7 +392,7 @@ void RecoveryUI::TimeKey(int key_code, int count) { std::this_thread::sleep_for(750ms); // 750 ms == "long" bool long_press = false; { - std::lock_guard<std::mutex> lg(key_queue_mutex); + std::lock_guard<std::mutex> lg(key_press_mutex); if (key_last_down == key_code && key_down_count == count) { long_press = key_long_press = true; } @@ -517,13 +517,13 @@ bool RecoveryUI::IsUsbConnected() { } bool RecoveryUI::IsKeyPressed(int key) { - std::lock_guard<std::mutex> lg(key_queue_mutex); + std::lock_guard<std::mutex> lg(key_press_mutex); int pressed = key_pressed[key]; return pressed; } bool RecoveryUI::IsLongPress() { - std::lock_guard<std::mutex> lg(key_queue_mutex); + std::lock_guard<std::mutex> lg(key_press_mutex); bool result = key_long_press; return result; } @@ -547,7 +547,7 @@ void RecoveryUI::FlushKeys() { RecoveryUI::KeyAction RecoveryUI::CheckKey(int key, bool is_long_press) { { - std::lock_guard<std::mutex> lg(key_queue_mutex); + std::lock_guard<std::mutex> lg(key_press_mutex); key_long_press = false; } @@ -590,6 +590,6 @@ RecoveryUI::KeyAction RecoveryUI::CheckKey(int key, bool is_long_press) { void RecoveryUI::KeyLongPress(int) {} void RecoveryUI::SetEnableReboot(bool enabled) { - std::lock_guard<std::mutex> lg(key_queue_mutex); + std::lock_guard<std::mutex> lg(key_press_mutex); enable_reboot = enabled; } |