diff options
author | Tao Bao | 2017-08-01 01:15:09 -0500 |
---|---|---|
committer | Tao Bao | 2017-08-03 16:52:06 -0500 |
commit | 937e884ca113a5e775a3cb37a3f9dbe2174d3376 (patch) | |
tree | 8ba30fb0ca4b4dea825db82574f69526e254d6ec | |
parent | af9f8b4d97af56b5abcb622aaecebce59179bc0b (diff) | |
download | platform-bootable-recovery-937e884ca113a5e775a3cb37a3f9dbe2174d3376.tar.gz platform-bootable-recovery-937e884ca113a5e775a3cb37a3f9dbe2174d3376.tar.xz platform-bootable-recovery-937e884ca113a5e775a3cb37a3f9dbe2174d3376.zip |
ui: Check for bootreason=recovery_ui.
Some wear bootloaders are passing bootreason=recovery_ui when booting
into recovery from fastboot, or via 'adb reboot recovery'. Allow turning
on text mode with a swipe for such a bootreason. Since we will turn on
text mode automatically for debuggable builds, this bootreason mainly
handles the case for user builds.
Note this change only applies to devices that allow touch screen inputs.
Bug: 36169090
Bug: 64307776
Test: Build and boot into user build recovery image. Toggle on text mode
with a swipe.
Change-Id: I55f19aed7b210352f8370de19935b4772cc12095
(cherry picked from commit 046aae29d9b0d2cdf24ad0567146991c3864c140)
-rw-r--r-- | ui.cpp | 20 | ||||
-rw-r--r-- | ui.h | 1 |
2 files changed, 21 insertions, 0 deletions
@@ -69,6 +69,7 @@ RecoveryUI::RecoveryUI() | |||
69 | has_down_key(false), | 69 | has_down_key(false), |
70 | has_touch_screen(false), | 70 | has_touch_screen(false), |
71 | touch_slot_(0), | 71 | touch_slot_(0), |
72 | is_bootreason_recovery_ui_(false), | ||
72 | screensaver_state_(ScreensaverState::DISABLED) { | 73 | screensaver_state_(ScreensaverState::DISABLED) { |
73 | pthread_mutex_init(&key_queue_mutex, nullptr); | 74 | pthread_mutex_init(&key_queue_mutex, nullptr); |
74 | pthread_cond_init(&key_queue_cond, nullptr); | 75 | pthread_cond_init(&key_queue_cond, nullptr); |
@@ -142,6 +143,19 @@ bool RecoveryUI::Init(const std::string& locale) { | |||
142 | 143 | ||
143 | if (touch_screen_allowed_) { | 144 | if (touch_screen_allowed_) { |
144 | ev_iterate_touch_inputs(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1)); | 145 | ev_iterate_touch_inputs(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1)); |
146 | |||
147 | // Parse /proc/cmdline to determine if it's booting into recovery with a bootreason of | ||
148 | // "recovery_ui". This specific reason is set by some (wear) bootloaders, to allow an easier way | ||
149 | // to turn on text mode. It will only be set if the recovery boot is triggered from fastboot, or | ||
150 | // with 'adb reboot recovery'. Note that this applies to all build variants. Otherwise the text | ||
151 | // mode will be turned on automatically on debuggable builds, even without a swipe. | ||
152 | std::string cmdline; | ||
153 | if (android::base::ReadFileToString("/proc/cmdline", &cmdline)) { | ||
154 | is_bootreason_recovery_ui_ = cmdline.find("bootreason=recovery_ui") != std::string::npos; | ||
155 | } else { | ||
156 | // Non-fatal, and won't affect Init() result. | ||
157 | PLOG(WARNING) << "Failed to read /proc/cmdline"; | ||
158 | } | ||
145 | } | 159 | } |
146 | 160 | ||
147 | if (!InitScreensaver()) { | 161 | if (!InitScreensaver()) { |
@@ -168,6 +182,12 @@ void RecoveryUI::OnTouchDetected(int dx, int dy) { | |||
168 | return; | 182 | return; |
169 | } | 183 | } |
170 | 184 | ||
185 | // Allow turning on text mode with any swipe, if bootloader has set a bootreason of recovery_ui. | ||
186 | if (is_bootreason_recovery_ui_ && !IsTextVisible()) { | ||
187 | ShowText(true); | ||
188 | return; | ||
189 | } | ||
190 | |||
171 | LOG(DEBUG) << "Swipe direction=" << direction; | 191 | LOG(DEBUG) << "Swipe direction=" << direction; |
172 | switch (direction) { | 192 | switch (direction) { |
173 | case SwipeDirection::UP: | 193 | case SwipeDirection::UP: |
@@ -170,6 +170,7 @@ class RecoveryUI { | |||
170 | int touch_start_Y_; | 170 | int touch_start_Y_; |
171 | bool touch_finger_down_; | 171 | bool touch_finger_down_; |
172 | bool touch_swiping_; | 172 | bool touch_swiping_; |
173 | bool is_bootreason_recovery_ui_; | ||
173 | 174 | ||
174 | struct key_timer_t { | 175 | struct key_timer_t { |
175 | RecoveryUI* ui; | 176 | RecoveryUI* ui; |