diff options
Diffstat (limited to 'ui.cpp')
-rw-r--r-- | ui.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -49,6 +49,7 @@ RecoveryUI::RecoveryUI() : key_last_down(-1), key_long_press(false), key_down_count(0), + enable_reboot(true), consecutive_power_keys(0), consecutive_alternate_keys(0), last_key(-1) { @@ -64,12 +65,12 @@ void RecoveryUI::Init() { } -int RecoveryUI::input_callback(int fd, short revents, void* data) +int RecoveryUI::input_callback(int fd, uint32_t epevents, void* data) { struct input_event ev; int ret; - ret = ev_get_input(fd, revents, &ev); + ret = ev_get_input(fd, epevents, &ev); if (ret) return -1; @@ -117,6 +118,7 @@ int RecoveryUI::input_callback(int fd, short revents, void* data) void RecoveryUI::process_key(int key_code, int updown) { bool register_key = false; bool long_press = false; + bool reboot_enabled; pthread_mutex_lock(&key_queue_mutex); key_pressed[key_code] = updown; @@ -138,6 +140,7 @@ void RecoveryUI::process_key(int key_code, int updown) { } key_last_down = -1; } + reboot_enabled = enable_reboot; pthread_mutex_unlock(&key_queue_mutex); if (register_key) { @@ -151,7 +154,9 @@ void RecoveryUI::process_key(int key_code, int updown) { break; case RecoveryUI::REBOOT: - android_reboot(ANDROID_RB_RESTART, 0, 0); + if (reboot_enabled) { + android_reboot(ANDROID_RB_RESTART, 0, 0); + } break; case RecoveryUI::ENQUEUE: @@ -277,14 +282,20 @@ void RecoveryUI::FlushKeys() { // - Press power seven times in a row to reboot. // - Alternate vol-up and vol-down seven times to mount /system. RecoveryUI::KeyAction RecoveryUI::CheckKey(int key) { - if (IsKeyPressed(KEY_POWER) && key == KEY_VOLUMEUP) { + if ((IsKeyPressed(KEY_POWER) && key == KEY_VOLUMEUP) || key == KEY_HOME) { return TOGGLE; } if (key == KEY_POWER) { - ++consecutive_power_keys; - if (consecutive_power_keys >= 7) { - return REBOOT; + pthread_mutex_lock(&key_queue_mutex); + bool reboot_enabled = enable_reboot; + pthread_mutex_unlock(&key_queue_mutex); + + if (reboot_enabled) { + ++consecutive_power_keys; + if (consecutive_power_keys >= 7) { + return REBOOT; + } } } else { consecutive_power_keys = 0; @@ -312,3 +323,9 @@ void RecoveryUI::NextCheckKeyIsLong(bool is_long_press) { void RecoveryUI::KeyLongPress(int key) { } + +void RecoveryUI::SetEnableReboot(bool enabled) { + pthread_mutex_lock(&key_queue_mutex); + enable_reboot = enabled; + pthread_mutex_unlock(&key_queue_mutex); +} |