diff options
author | Hui Liu <huliu@codeaurora.org> | 2021-08-18 18:53:58 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2021-08-20 00:46:27 -0700 |
commit | fe51fae4708b4c2eb4bc8ccae03be99a468a7cfa (patch) | |
tree | 65601676ac3173fceba8cff878eae0452749643f | |
parent | 9cc7717c320771b5997d17c04817568a4b100807 (diff) |
display: light: clear timer trigger before setting brightness
If set LED brightness to a none-zero value when it's
enabled with "timer" trigger, the "timer" trigger won't
be cleared automatically and the LED would be still in
working blink mode. To avoid this, clear "timer" trigger
before setting brightness values.
Change-Id: Ic7cf695330d3cb7421526c0e12d8be79de3c7821
-rw-r--r-- | liblight/lights.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/liblight/lights.c b/liblight/lights.c index f74fb542..eef85bd3 100644 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -177,6 +177,13 @@ static int set_rgb_led_brightness(enum rgb_led led, int brightness) { char file[48]; + snprintf(file, sizeof(file), "/sys/class/leds/%s/trigger", led_names[led]); + rc = write_str(file, "none"); + if (rc < 0) { + ALOGD("%s failed to set trigger to none\n", led_names[led]); + return rc; + } + snprintf(file, sizeof(file), "/sys/class/leds/%s/brightness", led_names[led]); return write_int(file, brightness); } |