summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-07-10 23:23:14 +0200
committerandroid-build-merger <android-build-merger@google.com>2019-07-10 23:23:14 +0200
commit68594b11262fd3080f830c8008da1f555af2d7a3 (patch)
tree617e72f032e856c84670e0dc5a24ec9ecc2d4106
parentMerge "Create a fallback to install from fuse if mmap fails" am: 5f408dd48a am: 0c666e3d5d (diff)
parentMerge "Add a new key_pressed_mutex" am: 33bb113af2 (diff)
downloadandroid_bootable_recovery-68594b11262fd3080f830c8008da1f555af2d7a3.tar
android_bootable_recovery-68594b11262fd3080f830c8008da1f555af2d7a3.tar.gz
android_bootable_recovery-68594b11262fd3080f830c8008da1f555af2d7a3.tar.bz2
android_bootable_recovery-68594b11262fd3080f830c8008da1f555af2d7a3.tar.lz
android_bootable_recovery-68594b11262fd3080f830c8008da1f555af2d7a3.tar.xz
android_bootable_recovery-68594b11262fd3080f830c8008da1f555af2d7a3.tar.zst
android_bootable_recovery-68594b11262fd3080f830c8008da1f555af2d7a3.zip
-rw-r--r--recovery_ui/include/recovery_ui/ui.h15
-rw-r--r--recovery_ui/ui.cpp12
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;
}