Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tianjie Xu | 8f39730 | 2018-08-20 13:40:47 -0700 | [diff] [blame] | 17 | #include "recovery_ui/ui.h" |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 18 | |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 19 | #include <errno.h> |
| 20 | #include <fcntl.h> |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <string.h> |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 24 | #include <sys/time.h> |
| 25 | #include <sys/types.h> |
| 26 | #include <time.h> |
| 27 | #include <unistd.h> |
| 28 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 29 | #include <chrono> |
Tao Bao | 9468fc0 | 2017-03-17 00:57:37 -0700 | [diff] [blame] | 30 | #include <functional> |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 31 | #include <string> |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 32 | #include <thread> |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 33 | |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 34 | #include <android-base/file.h> |
| 35 | #include <android-base/logging.h> |
| 36 | #include <android-base/parseint.h> |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 37 | #include <android-base/properties.h> |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 38 | #include <android-base/strings.h> |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 39 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 40 | #include "minui/minui.h" |
Tao Bao | 2c52639 | 2018-05-03 23:01:13 -0700 | [diff] [blame] | 41 | #include "otautil/sysutil.h" |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 42 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 43 | using namespace std::chrono_literals; |
| 44 | |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 45 | constexpr int UI_WAIT_KEY_TIMEOUT_SEC = 120; |
| 46 | constexpr const char* BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/brightness"; |
| 47 | constexpr const char* MAX_BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/max_brightness"; |
| 48 | constexpr const char* BRIGHTNESS_FILE_SDM = "/sys/class/backlight/panel0-backlight/brightness"; |
| 49 | constexpr const char* MAX_BRIGHTNESS_FILE_SDM = |
katao | c35c1b0 | 2017-12-08 11:02:43 +0800 | [diff] [blame] | 50 | "/sys/class/backlight/panel0-backlight/max_brightness"; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 51 | |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 52 | constexpr int kDefaultTouchLowThreshold = 50; |
| 53 | constexpr int kDefaultTouchHighThreshold = 90; |
| 54 | |
Elliott Hughes | ec28340 | 2015-04-10 10:01:53 -0700 | [diff] [blame] | 55 | RecoveryUI::RecoveryUI() |
Tao Bao | efb49ad | 2017-01-31 23:03:10 -0800 | [diff] [blame] | 56 | : brightness_normal_(50), |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 57 | brightness_dimmed_(25), |
katao | c35c1b0 | 2017-12-08 11:02:43 +0800 | [diff] [blame] | 58 | brightness_file_(BRIGHTNESS_FILE), |
| 59 | max_brightness_file_(MAX_BRIGHTNESS_FILE), |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 60 | touch_screen_allowed_(false), |
David Anderson | 983e2d5 | 2019-01-02 11:35:38 -0800 | [diff] [blame] | 61 | fastbootd_logo_enabled_(false), |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 62 | touch_low_threshold_(android::base::GetIntProperty("ro.recovery.ui.touch_low_threshold", |
| 63 | kDefaultTouchLowThreshold)), |
| 64 | touch_high_threshold_(android::base::GetIntProperty("ro.recovery.ui.touch_high_threshold", |
| 65 | kDefaultTouchHighThreshold)), |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 66 | key_interrupted_(false), |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 67 | key_queue_len(0), |
| 68 | key_last_down(-1), |
| 69 | key_long_press(false), |
| 70 | key_down_count(0), |
| 71 | enable_reboot(true), |
| 72 | consecutive_power_keys(0), |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 73 | has_power_key(false), |
| 74 | has_up_key(false), |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 75 | has_down_key(false), |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 76 | has_touch_screen(false), |
| 77 | touch_slot_(0), |
Tao Bao | 046aae2 | 2017-07-31 23:15:09 -0700 | [diff] [blame] | 78 | is_bootreason_recovery_ui_(false), |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 79 | screensaver_state_(ScreensaverState::DISABLED) { |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 80 | memset(key_pressed, 0, sizeof(key_pressed)); |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 83 | RecoveryUI::~RecoveryUI() { |
| 84 | ev_exit(); |
| 85 | input_thread_stopped_ = true; |
Tao Bao | 94371fd | 2018-06-06 07:38:54 -0700 | [diff] [blame] | 86 | if (input_thread_.joinable()) { |
| 87 | input_thread_.join(); |
| 88 | } |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Elliott Hughes | 642aaa7 | 2015-04-10 12:47:46 -0700 | [diff] [blame] | 91 | void RecoveryUI::OnKeyDetected(int key_code) { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 92 | if (key_code == KEY_POWER) { |
| 93 | has_power_key = true; |
| 94 | } else if (key_code == KEY_DOWN || key_code == KEY_VOLUMEDOWN) { |
| 95 | has_down_key = true; |
| 96 | } else if (key_code == KEY_UP || key_code == KEY_VOLUMEUP) { |
| 97 | has_up_key = true; |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 98 | } else if (key_code == ABS_MT_POSITION_X || key_code == ABS_MT_POSITION_Y) { |
| 99 | has_touch_screen = true; |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 100 | } |
Elliott Hughes | 642aaa7 | 2015-04-10 12:47:46 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 103 | bool RecoveryUI::InitScreensaver() { |
| 104 | // Disabled. |
| 105 | if (brightness_normal_ == 0 || brightness_dimmed_ > brightness_normal_) { |
| 106 | return false; |
| 107 | } |
katao | c35c1b0 | 2017-12-08 11:02:43 +0800 | [diff] [blame] | 108 | if (access(brightness_file_.c_str(), R_OK | W_OK)) { |
| 109 | brightness_file_ = BRIGHTNESS_FILE_SDM; |
| 110 | } |
| 111 | if (access(max_brightness_file_.c_str(), R_OK)) { |
| 112 | max_brightness_file_ = MAX_BRIGHTNESS_FILE_SDM; |
| 113 | } |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 114 | // Set the initial brightness level based on the max brightness. Note that reading the initial |
| 115 | // value from BRIGHTNESS_FILE doesn't give the actual brightness value (bullhead, sailfish), so |
| 116 | // we don't have a good way to query the default value. |
| 117 | std::string content; |
katao | c35c1b0 | 2017-12-08 11:02:43 +0800 | [diff] [blame] | 118 | if (!android::base::ReadFileToString(max_brightness_file_, &content)) { |
Tao Bao | 8eec373 | 2017-01-31 21:24:16 -0800 | [diff] [blame] | 119 | PLOG(WARNING) << "Failed to read max brightness"; |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 120 | return false; |
| 121 | } |
| 122 | |
| 123 | unsigned int max_value; |
| 124 | if (!android::base::ParseUint(android::base::Trim(content), &max_value)) { |
| 125 | LOG(WARNING) << "Failed to parse max brightness: " << content; |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | brightness_normal_value_ = max_value * brightness_normal_ / 100.0; |
| 130 | brightness_dimmed_value_ = max_value * brightness_dimmed_ / 100.0; |
| 131 | if (!android::base::WriteStringToFile(std::to_string(brightness_normal_value_), |
katao | c35c1b0 | 2017-12-08 11:02:43 +0800 | [diff] [blame] | 132 | brightness_file_)) { |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 133 | PLOG(WARNING) << "Failed to set brightness"; |
| 134 | return false; |
| 135 | } |
| 136 | |
| 137 | LOG(INFO) << "Brightness: " << brightness_normal_value_ << " (" << brightness_normal_ << "%)"; |
| 138 | screensaver_state_ = ScreensaverState::NORMAL; |
| 139 | return true; |
| 140 | } |
| 141 | |
Tao Bao | efb49ad | 2017-01-31 23:03:10 -0800 | [diff] [blame] | 142 | bool RecoveryUI::Init(const std::string& /* locale */) { |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 143 | ev_init(std::bind(&RecoveryUI::OnInputEvent, this, std::placeholders::_1, std::placeholders::_2), |
| 144 | touch_screen_allowed_); |
Elliott Hughes | 985022a | 2015-04-13 13:04:32 -0700 | [diff] [blame] | 145 | |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 146 | ev_iterate_available_keys(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1)); |
| 147 | |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 148 | if (touch_screen_allowed_) { |
| 149 | ev_iterate_touch_inputs(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1)); |
Tao Bao | 046aae2 | 2017-07-31 23:15:09 -0700 | [diff] [blame] | 150 | |
| 151 | // Parse /proc/cmdline to determine if it's booting into recovery with a bootreason of |
| 152 | // "recovery_ui". This specific reason is set by some (wear) bootloaders, to allow an easier way |
| 153 | // to turn on text mode. It will only be set if the recovery boot is triggered from fastboot, or |
| 154 | // with 'adb reboot recovery'. Note that this applies to all build variants. Otherwise the text |
| 155 | // mode will be turned on automatically on debuggable builds, even without a swipe. |
| 156 | std::string cmdline; |
| 157 | if (android::base::ReadFileToString("/proc/cmdline", &cmdline)) { |
| 158 | is_bootreason_recovery_ui_ = cmdline.find("bootreason=recovery_ui") != std::string::npos; |
| 159 | } else { |
| 160 | // Non-fatal, and won't affect Init() result. |
| 161 | PLOG(WARNING) << "Failed to read /proc/cmdline"; |
| 162 | } |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 165 | if (!InitScreensaver()) { |
| 166 | LOG(INFO) << "Screensaver disabled"; |
| 167 | } |
| 168 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 169 | // Create a separate thread that handles input events. |
| 170 | input_thread_ = std::thread([this]() { |
| 171 | while (!this->input_thread_stopped_) { |
| 172 | if (!ev_wait(500)) { |
| 173 | ev_dispatch(); |
| 174 | } |
| 175 | } |
| 176 | }); |
| 177 | |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 178 | return true; |
Elliott Hughes | 985022a | 2015-04-13 13:04:32 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 181 | void RecoveryUI::OnTouchDetected(int dx, int dy) { |
| 182 | enum SwipeDirection { UP, DOWN, RIGHT, LEFT } direction; |
| 183 | |
| 184 | // We only consider a valid swipe if: |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 185 | // - the delta along one axis is below touch_low_threshold_; |
| 186 | // - and the delta along the other axis is beyond touch_high_threshold_. |
| 187 | if (abs(dy) < touch_low_threshold_ && abs(dx) > touch_high_threshold_) { |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 188 | direction = dx < 0 ? SwipeDirection::LEFT : SwipeDirection::RIGHT; |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 189 | } else if (abs(dx) < touch_low_threshold_ && abs(dy) > touch_high_threshold_) { |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 190 | direction = dy < 0 ? SwipeDirection::UP : SwipeDirection::DOWN; |
| 191 | } else { |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 192 | LOG(DEBUG) << "Ignored " << dx << " " << dy << " (low: " << touch_low_threshold_ |
| 193 | << ", high: " << touch_high_threshold_ << ")"; |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 194 | return; |
| 195 | } |
| 196 | |
Tao Bao | 046aae2 | 2017-07-31 23:15:09 -0700 | [diff] [blame] | 197 | // Allow turning on text mode with any swipe, if bootloader has set a bootreason of recovery_ui. |
| 198 | if (is_bootreason_recovery_ui_ && !IsTextVisible()) { |
| 199 | ShowText(true); |
| 200 | return; |
| 201 | } |
| 202 | |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 203 | LOG(DEBUG) << "Swipe direction=" << direction; |
| 204 | switch (direction) { |
| 205 | case SwipeDirection::UP: |
| 206 | ProcessKey(KEY_UP, 1); // press up key |
| 207 | ProcessKey(KEY_UP, 0); // and release it |
| 208 | break; |
| 209 | |
| 210 | case SwipeDirection::DOWN: |
| 211 | ProcessKey(KEY_DOWN, 1); // press down key |
| 212 | ProcessKey(KEY_DOWN, 0); // and release it |
| 213 | break; |
| 214 | |
| 215 | case SwipeDirection::LEFT: |
| 216 | case SwipeDirection::RIGHT: |
| 217 | ProcessKey(KEY_POWER, 1); // press power key |
| 218 | ProcessKey(KEY_POWER, 0); // and release it |
| 219 | break; |
| 220 | }; |
| 221 | } |
| 222 | |
Elliott Hughes | 985022a | 2015-04-13 13:04:32 -0700 | [diff] [blame] | 223 | int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 224 | struct input_event ev; |
| 225 | if (ev_get_input(fd, epevents, &ev) == -1) { |
| 226 | return -1; |
| 227 | } |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 228 | |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 229 | // Touch inputs handling. |
| 230 | // |
| 231 | // We handle the touch inputs by tracking the position changes between initial contacting and |
| 232 | // upon lifting. touch_start_X/Y record the initial positions, with touch_finger_down set. Upon |
| 233 | // detecting the lift, we unset touch_finger_down and detect a swipe based on position changes. |
| 234 | // |
| 235 | // Per the doc Multi-touch Protocol at below, there are two protocols. |
| 236 | // https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt |
| 237 | // |
| 238 | // The main difference between the stateless type A protocol and the stateful type B slot protocol |
| 239 | // lies in the usage of identifiable contacts to reduce the amount of data sent to userspace. The |
| 240 | // slot protocol (i.e. type B) sends ABS_MT_TRACKING_ID with a unique id on initial contact, and |
| 241 | // sends ABS_MT_TRACKING_ID -1 upon lifting the contact. Protocol A doesn't send |
| 242 | // ABS_MT_TRACKING_ID -1 on lifting, but the driver may additionally report BTN_TOUCH event. |
| 243 | // |
| 244 | // For protocol A, we rely on BTN_TOUCH to recognize lifting, while for protocol B we look for |
| 245 | // ABS_MT_TRACKING_ID being -1. |
| 246 | // |
| 247 | // Touch input events will only be available if touch_screen_allowed_ is set. |
| 248 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 249 | if (ev.type == EV_SYN) { |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 250 | if (touch_screen_allowed_ && ev.code == SYN_REPORT) { |
| 251 | // There might be multiple SYN_REPORT events. We should only detect a swipe after lifting the |
| 252 | // contact. |
| 253 | if (touch_finger_down_ && !touch_swiping_) { |
| 254 | touch_start_X_ = touch_X_; |
| 255 | touch_start_Y_ = touch_Y_; |
| 256 | touch_swiping_ = true; |
| 257 | } else if (!touch_finger_down_ && touch_swiping_) { |
| 258 | touch_swiping_ = false; |
| 259 | OnTouchDetected(touch_X_ - touch_start_X_, touch_Y_ - touch_start_Y_); |
| 260 | } |
| 261 | } |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 262 | return 0; |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | if (ev.type == EV_REL) { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 266 | if (ev.code == REL_Y) { |
| 267 | // accumulate the up or down motion reported by |
| 268 | // the trackball. When it exceeds a threshold |
| 269 | // (positive or negative), fake an up/down |
| 270 | // key event. |
| 271 | rel_sum += ev.value; |
| 272 | if (rel_sum > 3) { |
| 273 | ProcessKey(KEY_DOWN, 1); // press down key |
| 274 | ProcessKey(KEY_DOWN, 0); // and release it |
| 275 | rel_sum = 0; |
| 276 | } else if (rel_sum < -3) { |
| 277 | ProcessKey(KEY_UP, 1); // press up key |
| 278 | ProcessKey(KEY_UP, 0); // and release it |
| 279 | rel_sum = 0; |
| 280 | } |
| 281 | } |
| 282 | } else { |
| 283 | rel_sum = 0; |
| 284 | } |
| 285 | |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 286 | if (touch_screen_allowed_ && ev.type == EV_ABS) { |
| 287 | if (ev.code == ABS_MT_SLOT) { |
| 288 | touch_slot_ = ev.value; |
| 289 | } |
| 290 | // Ignore other fingers. |
| 291 | if (touch_slot_ > 0) return 0; |
| 292 | |
| 293 | switch (ev.code) { |
| 294 | case ABS_MT_POSITION_X: |
| 295 | touch_X_ = ev.value; |
| 296 | touch_finger_down_ = true; |
| 297 | break; |
| 298 | |
| 299 | case ABS_MT_POSITION_Y: |
| 300 | touch_Y_ = ev.value; |
| 301 | touch_finger_down_ = true; |
| 302 | break; |
| 303 | |
| 304 | case ABS_MT_TRACKING_ID: |
| 305 | // Protocol B: -1 marks lifting the contact. |
| 306 | if (ev.value < 0) touch_finger_down_ = false; |
| 307 | break; |
| 308 | } |
| 309 | return 0; |
| 310 | } |
| 311 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 312 | if (ev.type == EV_KEY && ev.code <= KEY_MAX) { |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 313 | if (touch_screen_allowed_) { |
| 314 | if (ev.code == BTN_TOUCH) { |
| 315 | // A BTN_TOUCH with value 1 indicates the start of contact (protocol A), with 0 means |
| 316 | // lifting the contact. |
| 317 | touch_finger_down_ = (ev.value == 1); |
| 318 | } |
| 319 | |
| 320 | // Intentionally ignore BTN_TOUCH and BTN_TOOL_FINGER, which would otherwise trigger |
| 321 | // additional scrolling (because in ScreenRecoveryUI::ShowFile(), we consider keys other than |
| 322 | // KEY_POWER and KEY_UP as KEY_DOWN). |
| 323 | if (ev.code == BTN_TOUCH || ev.code == BTN_TOOL_FINGER) { |
| 324 | return 0; |
| 325 | } |
| 326 | } |
| 327 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 328 | ProcessKey(ev.code, ev.value); |
| 329 | } |
| 330 | |
| 331 | return 0; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 334 | // Processes a key-up or -down event. A key is "registered" when it is pressed and then released, |
| 335 | // with no other keypresses or releases in between. Registered keys are passed to CheckKey() to |
| 336 | // see if it should trigger a visibility toggle, an immediate reboot, or be queued to be processed |
| 337 | // next time the foreground thread wants a key (eg, for the menu). |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 338 | // |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 339 | // We also keep track of which keys are currently down so that CheckKey() can call IsKeyPressed() |
| 340 | // to see what other keys are held when a key is registered. |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 341 | // |
| 342 | // updown == 1 for key down events; 0 for key up events |
Elliott Hughes | 985022a | 2015-04-13 13:04:32 -0700 | [diff] [blame] | 343 | void RecoveryUI::ProcessKey(int key_code, int updown) { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 344 | bool register_key = false; |
| 345 | bool long_press = false; |
Doug Zongker | bb01d0c | 2012-12-17 10:52:58 -0800 | [diff] [blame] | 346 | |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 347 | { |
Tianjie Xu | b8a959b | 2019-06-14 15:35:31 -0700 | [diff] [blame] | 348 | std::lock_guard<std::mutex> lg(key_press_mutex); |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 349 | key_pressed[key_code] = updown; |
| 350 | if (updown) { |
| 351 | ++key_down_count; |
| 352 | key_last_down = key_code; |
| 353 | key_long_press = false; |
| 354 | std::thread time_key_thread(&RecoveryUI::TimeKey, this, key_code, key_down_count); |
| 355 | time_key_thread.detach(); |
| 356 | } else { |
| 357 | if (key_last_down == key_code) { |
| 358 | long_press = key_long_press; |
| 359 | register_key = true; |
| 360 | } |
| 361 | key_last_down = -1; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 362 | } |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 363 | } |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 364 | |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 365 | bool reboot_enabled = enable_reboot; |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 366 | if (register_key) { |
| 367 | switch (CheckKey(key_code, long_press)) { |
| 368 | case RecoveryUI::IGNORE: |
| 369 | break; |
Doug Zongker | 48b5b07 | 2012-01-18 13:46:26 -0800 | [diff] [blame] | 370 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 371 | case RecoveryUI::TOGGLE: |
| 372 | ShowText(!IsTextVisible()); |
| 373 | break; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 374 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 375 | case RecoveryUI::REBOOT: |
| 376 | if (reboot_enabled) { |
Mark Salyzyn | 488cc05 | 2019-05-20 10:36:16 -0700 | [diff] [blame] | 377 | Reboot("userrequested,recovery,ui"); |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 378 | while (true) { |
| 379 | pause(); |
| 380 | } |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 381 | } |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 382 | break; |
| 383 | |
| 384 | case RecoveryUI::ENQUEUE: |
| 385 | EnqueueKey(key_code); |
| 386 | break; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 387 | } |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 388 | } |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 391 | void RecoveryUI::TimeKey(int key_code, int count) { |
| 392 | std::this_thread::sleep_for(750ms); // 750 ms == "long" |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 393 | bool long_press = false; |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 394 | { |
Tianjie Xu | b8a959b | 2019-06-14 15:35:31 -0700 | [diff] [blame] | 395 | std::lock_guard<std::mutex> lg(key_press_mutex); |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 396 | if (key_last_down == key_code && key_down_count == count) { |
| 397 | long_press = key_long_press = true; |
| 398 | } |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 399 | } |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 400 | if (long_press) KeyLongPress(key_code); |
Doug Zongker | c0441d1 | 2013-07-31 11:28:24 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Doug Zongker | bb01d0c | 2012-12-17 10:52:58 -0800 | [diff] [blame] | 403 | void RecoveryUI::EnqueueKey(int key_code) { |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 404 | std::lock_guard<std::mutex> lg(key_queue_mutex); |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 405 | const int queue_max = sizeof(key_queue) / sizeof(key_queue[0]); |
| 406 | if (key_queue_len < queue_max) { |
| 407 | key_queue[key_queue_len++] = key_code; |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 408 | key_queue_cond.notify_one(); |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 409 | } |
Doug Zongker | bb01d0c | 2012-12-17 10:52:58 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 412 | void RecoveryUI::SetScreensaverState(ScreensaverState state) { |
| 413 | switch (state) { |
| 414 | case ScreensaverState::NORMAL: |
| 415 | if (android::base::WriteStringToFile(std::to_string(brightness_normal_value_), |
| 416 | brightness_file_)) { |
| 417 | screensaver_state_ = ScreensaverState::NORMAL; |
| 418 | LOG(INFO) << "Brightness: " << brightness_normal_value_ << " (" << brightness_normal_ |
| 419 | << "%)"; |
| 420 | } else { |
Zhang, GaofengX | 852d9fe | 2019-06-11 11:16:30 +0800 | [diff] [blame] | 421 | LOG(WARNING) << "Unable to set brightness to normal"; |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 422 | } |
| 423 | break; |
| 424 | case ScreensaverState::DIMMED: |
| 425 | if (android::base::WriteStringToFile(std::to_string(brightness_dimmed_value_), |
| 426 | brightness_file_)) { |
| 427 | LOG(INFO) << "Brightness: " << brightness_dimmed_value_ << " (" << brightness_dimmed_ |
| 428 | << "%)"; |
| 429 | screensaver_state_ = ScreensaverState::DIMMED; |
| 430 | } else { |
Zhang, GaofengX | 852d9fe | 2019-06-11 11:16:30 +0800 | [diff] [blame] | 431 | LOG(WARNING) << "Unable to set brightness to dim"; |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 432 | } |
| 433 | break; |
| 434 | case ScreensaverState::OFF: |
| 435 | if (android::base::WriteStringToFile("0", brightness_file_)) { |
| 436 | LOG(INFO) << "Brightness: 0 (off)"; |
| 437 | screensaver_state_ = ScreensaverState::OFF; |
| 438 | } else { |
Zhang, GaofengX | 852d9fe | 2019-06-11 11:16:30 +0800 | [diff] [blame] | 439 | LOG(WARNING) << "Unable to set brightness to off"; |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 440 | } |
| 441 | break; |
| 442 | default: |
| 443 | LOG(ERROR) << "Invalid screensaver state"; |
| 444 | } |
| 445 | } |
| 446 | |
Elliott Hughes | ec28340 | 2015-04-10 10:01:53 -0700 | [diff] [blame] | 447 | int RecoveryUI::WaitKey() { |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 448 | std::unique_lock<std::mutex> lk(key_queue_mutex); |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 449 | |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 450 | // Check for a saved key queue interruption. |
| 451 | if (key_interrupted_) { |
| 452 | SetScreensaverState(ScreensaverState::NORMAL); |
| 453 | return static_cast<int>(KeyError::INTERRUPTED); |
| 454 | } |
| 455 | |
Tao Bao | 53be332 | 2018-08-16 11:48:50 -0700 | [diff] [blame] | 456 | // Time out after UI_WAIT_KEY_TIMEOUT_SEC, unless a USB cable is plugged in. |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 457 | do { |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 458 | bool rc = key_queue_cond.wait_for(lk, std::chrono::seconds(UI_WAIT_KEY_TIMEOUT_SEC), [this] { |
| 459 | return this->key_queue_len != 0 || key_interrupted_; |
| 460 | }); |
| 461 | if (key_interrupted_) { |
| 462 | SetScreensaverState(ScreensaverState::NORMAL); |
| 463 | return static_cast<int>(KeyError::INTERRUPTED); |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 464 | } |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 465 | if (screensaver_state_ != ScreensaverState::DISABLED) { |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 466 | if (!rc) { |
Tao Bao | 53be332 | 2018-08-16 11:48:50 -0700 | [diff] [blame] | 467 | // Must be after a timeout. Lower the brightness level: NORMAL -> DIMMED; DIMMED -> OFF. |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 468 | if (screensaver_state_ == ScreensaverState::NORMAL) { |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 469 | SetScreensaverState(ScreensaverState::DIMMED); |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 470 | } else if (screensaver_state_ == ScreensaverState::DIMMED) { |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 471 | SetScreensaverState(ScreensaverState::OFF); |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 472 | } |
Tao Bao | 53be332 | 2018-08-16 11:48:50 -0700 | [diff] [blame] | 473 | } else if (screensaver_state_ != ScreensaverState::NORMAL) { |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 474 | // Drop the first key if it's changing from OFF to NORMAL. |
| 475 | if (screensaver_state_ == ScreensaverState::OFF) { |
| 476 | if (key_queue_len > 0) { |
| 477 | memcpy(&key_queue[0], &key_queue[1], sizeof(int) * --key_queue_len); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | // Reset the brightness to normal. |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 482 | SetScreensaverState(ScreensaverState::NORMAL); |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 483 | } |
| 484 | } |
| 485 | } while (IsUsbConnected() && key_queue_len == 0); |
| 486 | |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 487 | int key = static_cast<int>(KeyError::TIMED_OUT); |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 488 | if (key_queue_len > 0) { |
| 489 | key = key_queue[0]; |
| 490 | memcpy(&key_queue[0], &key_queue[1], sizeof(int) * --key_queue_len); |
| 491 | } |
Tao Bao | 6278bdf | 2017-01-16 17:38:18 -0800 | [diff] [blame] | 492 | return key; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Jerry Zhang | b76af93 | 2018-05-22 12:08:35 -0700 | [diff] [blame] | 495 | void RecoveryUI::InterruptKey() { |
| 496 | { |
| 497 | std::lock_guard<std::mutex> lg(key_queue_mutex); |
| 498 | key_interrupted_ = true; |
| 499 | } |
| 500 | key_queue_cond.notify_one(); |
| 501 | } |
| 502 | |
Elliott Hughes | 985022a | 2015-04-13 13:04:32 -0700 | [diff] [blame] | 503 | bool RecoveryUI::IsUsbConnected() { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 504 | int fd = open("/sys/class/android_usb/android0/state", O_RDONLY); |
| 505 | if (fd < 0) { |
| 506 | printf("failed to open /sys/class/android_usb/android0/state: %s\n", strerror(errno)); |
| 507 | return 0; |
| 508 | } |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 509 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 510 | char buf; |
| 511 | // USB is connected if android_usb state is CONNECTED or CONFIGURED. |
| 512 | int connected = (TEMP_FAILURE_RETRY(read(fd, &buf, 1)) == 1) && (buf == 'C'); |
| 513 | if (close(fd) < 0) { |
| 514 | printf("failed to close /sys/class/android_usb/android0/state: %s\n", strerror(errno)); |
| 515 | } |
| 516 | return connected; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 517 | } |
| 518 | |
Elliott Hughes | ec28340 | 2015-04-10 10:01:53 -0700 | [diff] [blame] | 519 | bool RecoveryUI::IsKeyPressed(int key) { |
Tianjie Xu | b8a959b | 2019-06-14 15:35:31 -0700 | [diff] [blame] | 520 | std::lock_guard<std::mutex> lg(key_press_mutex); |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 521 | int pressed = key_pressed[key]; |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 522 | return pressed; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Elliott Hughes | 642aaa7 | 2015-04-10 12:47:46 -0700 | [diff] [blame] | 525 | bool RecoveryUI::IsLongPress() { |
Tianjie Xu | b8a959b | 2019-06-14 15:35:31 -0700 | [diff] [blame] | 526 | std::lock_guard<std::mutex> lg(key_press_mutex); |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 527 | bool result = key_long_press; |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 528 | return result; |
Elliott Hughes | 642aaa7 | 2015-04-10 12:47:46 -0700 | [diff] [blame] | 529 | } |
| 530 | |
Elliott Hughes | 4af215b | 2015-04-10 15:00:34 -0700 | [diff] [blame] | 531 | bool RecoveryUI::HasThreeButtons() { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 532 | return has_power_key && has_up_key && has_down_key; |
Elliott Hughes | 4af215b | 2015-04-10 15:00:34 -0700 | [diff] [blame] | 533 | } |
| 534 | |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 535 | bool RecoveryUI::HasPowerKey() const { |
| 536 | return has_power_key; |
| 537 | } |
| 538 | |
| 539 | bool RecoveryUI::HasTouchScreen() const { |
| 540 | return has_touch_screen; |
| 541 | } |
| 542 | |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 543 | void RecoveryUI::FlushKeys() { |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 544 | std::lock_guard<std::mutex> lg(key_queue_mutex); |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 545 | key_queue_len = 0; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Elliott Hughes | 642aaa7 | 2015-04-10 12:47:46 -0700 | [diff] [blame] | 548 | RecoveryUI::KeyAction RecoveryUI::CheckKey(int key, bool is_long_press) { |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 549 | { |
Tianjie Xu | b8a959b | 2019-06-14 15:35:31 -0700 | [diff] [blame] | 550 | std::lock_guard<std::mutex> lg(key_press_mutex); |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 551 | key_long_press = false; |
| 552 | } |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 553 | |
| 554 | // If we have power and volume up keys, that chord is the signal to toggle the text display. |
Tao Bao | 5f8dd99 | 2017-07-28 00:05:40 -0700 | [diff] [blame] | 555 | if (HasThreeButtons() || (HasPowerKey() && HasTouchScreen() && touch_screen_allowed_)) { |
| 556 | if ((key == KEY_VOLUMEUP || key == KEY_UP) && IsKeyPressed(KEY_POWER)) { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 557 | return TOGGLE; |
| 558 | } |
| 559 | } else { |
| 560 | // Otherwise long press of any button toggles to the text display, |
| 561 | // and there's no way to toggle back (but that's pretty useless anyway). |
| 562 | if (is_long_press && !IsTextVisible()) { |
| 563 | return TOGGLE; |
| 564 | } |
| 565 | |
| 566 | // Also, for button-limited devices, a long press is translated to KEY_ENTER. |
| 567 | if (is_long_press && IsTextVisible()) { |
| 568 | EnqueueKey(KEY_ENTER); |
| 569 | return IGNORE; |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | // Press power seven times in a row to reboot. |
| 574 | if (key == KEY_POWER) { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 575 | bool reboot_enabled = enable_reboot; |
Elliott Hughes | 642aaa7 | 2015-04-10 12:47:46 -0700 | [diff] [blame] | 576 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 577 | if (reboot_enabled) { |
| 578 | ++consecutive_power_keys; |
| 579 | if (consecutive_power_keys >= 7) { |
| 580 | return REBOOT; |
| 581 | } |
Doug Zongker | 9e805d6 | 2013-09-04 13:44:38 -0700 | [diff] [blame] | 582 | } |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 583 | } else { |
| 584 | consecutive_power_keys = 0; |
| 585 | } |
Doug Zongker | 9e805d6 | 2013-09-04 13:44:38 -0700 | [diff] [blame] | 586 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 587 | return (IsTextVisible() || screensaver_state_ == ScreensaverState::OFF) ? ENQUEUE : IGNORE; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 588 | } |
Doug Zongker | bb01d0c | 2012-12-17 10:52:58 -0800 | [diff] [blame] | 589 | |
Tianjie Xu | 8f39730 | 2018-08-20 13:40:47 -0700 | [diff] [blame] | 590 | void RecoveryUI::KeyLongPress(int) {} |
Doug Zongker | c704e06 | 2014-05-23 08:40:35 -0700 | [diff] [blame] | 591 | |
| 592 | void RecoveryUI::SetEnableReboot(bool enabled) { |
Tianjie Xu | b8a959b | 2019-06-14 15:35:31 -0700 | [diff] [blame] | 593 | std::lock_guard<std::mutex> lg(key_press_mutex); |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 594 | enable_reboot = enabled; |
Doug Zongker | c704e06 | 2014-05-23 08:40:35 -0700 | [diff] [blame] | 595 | } |