aboutsummaryrefslogtreecommitdiffstats
path: root/ui.cpp
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2014-05-23 08:40:35 -0700
committerDoug Zongker <dougz@android.com>2014-05-23 08:52:31 -0700
commitc704e06ce596bd0a6de66b10b108aee95535468a (patch)
tree3005b89333b7500aaa78e0867e377eac2f0280ab /ui.cpp
parentffb557d351776bed40818fa77afaa743d9e34a34 (diff)
downloadbootable_recovery-c704e06ce596bd0a6de66b10b108aee95535468a.zip
bootable_recovery-c704e06ce596bd0a6de66b10b108aee95535468a.tar.gz
bootable_recovery-c704e06ce596bd0a6de66b10b108aee95535468a.tar.bz2
disable async reboot during package installation
The default recovery UI will reboot the device when the power key is pressed 7 times in a row, regardless of what recovery is doing. Disable this feature during package installation, to minimize the chance of corrupting the device due to a mid-install reboot. (Debug packages can explicitly request that the feature be reenabled.) Change-Id: I20f3ec240ecd344615d452005ff26d8dd7775acf
Diffstat (limited to 'ui.cpp')
-rw-r--r--ui.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/ui.cpp b/ui.cpp
index 091012f..9844253 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -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) {
@@ -116,6 +117,7 @@ int RecoveryUI::input_callback(int fd, uint32_t epevents, 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;
@@ -137,6 +139,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) {
@@ -150,7 +153,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:
@@ -281,9 +286,15 @@ RecoveryUI::KeyAction RecoveryUI::CheckKey(int key) {
}
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;
@@ -311,3 +322,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);
+}