aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui.cpp20
-rw-r--r--ui.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/ui.cpp b/ui.cpp
index eadcdd43..e80d7ed0 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -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:
diff --git a/ui.h b/ui.h
index 5cda7af0..3d9afece 100644
--- a/ui.h
+++ b/ui.h
@@ -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;