From b8a959b00fe57fc431034f9bea3c7b3380d4b6a5 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Fri, 14 Jun 2019 15:35:31 -0700 Subject: Add a new key_pressed_mutex The following variables in recovery ui were protected by key_queue_mutex. But the purpose of key_queue_mutex is to protect the key_queue, which will be changed after we already have a key code. So getting the key pressed should be orthogonal to the key queue. And adding a mutex will help to avoid deadlocks in b/135078366. Variables include: char key_pressed[KEY_MAX + 1]; int key_last_down; bool key_long_press; int key_down_count; bool enable_reboot; Bug: 135078366 Test: boot into recovery and press keys Change-Id: Ie2cfcf1f2fec49b53f8fac97aa9a2c60f15b84f9 --- recovery_ui/include/recovery_ui/ui.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'recovery_ui/include') diff --git a/recovery_ui/include/recovery_ui/ui.h b/recovery_ui/include/recovery_ui/ui.h index 797e2f0d5..0b29c29f1 100644 --- a/recovery_ui/include/recovery_ui/ui.h +++ b/recovery_ui/include/recovery_ui/ui.h @@ -230,18 +230,22 @@ class RecoveryUI { 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 - 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; int last_key; -- cgit v1.2.3