Skip to content

Commit

Permalink
ui: Check for bootreason=recovery_ui.
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Tao Bao committed Aug 3, 2017
1 parent af9f8b4 commit 937e884
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ RecoveryUI::RecoveryUI()
has_down_key(false),
has_touch_screen(false),
touch_slot_(0),
is_bootreason_recovery_ui_(false),
screensaver_state_(ScreensaverState::DISABLED) {
pthread_mutex_init(&key_queue_mutex, nullptr);
pthread_cond_init(&key_queue_cond, nullptr);
Expand Down Expand Up @@ -142,6 +143,19 @@ bool RecoveryUI::Init(const std::string& locale) {

if (touch_screen_allowed_) {
ev_iterate_touch_inputs(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1));

// Parse /proc/cmdline to determine if it's booting into recovery with a bootreason of
// "recovery_ui". This specific reason is set by some (wear) bootloaders, to allow an easier way
// to turn on text mode. It will only be set if the recovery boot is triggered from fastboot, or
// with 'adb reboot recovery'. Note that this applies to all build variants. Otherwise the text
// mode will be turned on automatically on debuggable builds, even without a swipe.
std::string cmdline;
if (android::base::ReadFileToString("/proc/cmdline", &cmdline)) {
is_bootreason_recovery_ui_ = cmdline.find("bootreason=recovery_ui") != std::string::npos;
} else {
// Non-fatal, and won't affect Init() result.
PLOG(WARNING) << "Failed to read /proc/cmdline";
}
}

if (!InitScreensaver()) {
Expand All @@ -168,6 +182,12 @@ void RecoveryUI::OnTouchDetected(int dx, int dy) {
return;
}

// Allow turning on text mode with any swipe, if bootloader has set a bootreason of recovery_ui.
if (is_bootreason_recovery_ui_ && !IsTextVisible()) {
ShowText(true);
return;
}

LOG(DEBUG) << "Swipe direction=" << direction;
switch (direction) {
case SwipeDirection::UP:
Expand Down
1 change: 1 addition & 0 deletions ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class RecoveryUI {
int touch_start_Y_;
bool touch_finger_down_;
bool touch_swiping_;
bool is_bootreason_recovery_ui_;

struct key_timer_t {
RecoveryUI* ui;
Expand Down

0 comments on commit 937e884

Please sign in to comment.