From f42bf40aa1526ff8d1a93717be40f40d975e798c Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Tue, 17 Nov 2015 06:56:58 -0800 Subject: recovery: turn on the backlight in recovery mode The backlight is not turned on by default in some devices. This leads to nothing displayed in recovery mode. Change-Id: Iae5b0440f79fdcb79e103744a242e12c96b02c00 --- recovery.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/recovery.cpp b/recovery.cpp index 9f45d9a..b8a53df 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -1116,6 +1116,28 @@ ui_print(const char* format, ...) { extern "C" int toybox_driver(int argc, char **argv); +static int write_file(const char *path, const char *value) +{ + int fd, ret, len; + + fd = open(path, O_WRONLY|O_CREAT, 0622); + if (fd < 0) + return -errno; + + len = strlen(value); + + do { + ret = write(fd, value, len); + } while (ret < 0 && errno == EINTR); + + close(fd); + if (ret < 0) { + return -errno; + } else { + return 0; + } +} + int main(int argc, char **argv) { // If this binary is started with the single argument "--adbd", @@ -1235,6 +1257,9 @@ main(int argc, char **argv) { ui->SetBackground(RecoveryUI::NONE); if (show_text) ui->ShowText(true); + /*enable the backlight*/ + write_file("/sys/class/leds/lcd-backlight/brightness", "128"); + struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "/file_contexts" } }; -- cgit v1.1