summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Marshall <tdm@cyngn.com>2015-11-17 06:56:58 -0800
committerTom Marshall <tdm@cyngn.com>2015-11-25 15:34:35 -0800
commitf42bf40aa1526ff8d1a93717be40f40d975e798c (patch)
treee18738ecc5232dec93f36acc07a81d022964142e
parent3f092f7778ed608d454df4c3dc3b3f7cb4afde3b (diff)
downloadbootable_recovery-f42bf40aa1526ff8d1a93717be40f40d975e798c.zip
bootable_recovery-f42bf40aa1526ff8d1a93717be40f40d975e798c.tar.gz
bootable_recovery-f42bf40aa1526ff8d1a93717be40f40d975e798c.tar.bz2
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
-rw-r--r--recovery.cpp25
1 files changed, 25 insertions, 0 deletions
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" }
};