From 9ae5a34d17b1134b0dd88457d3efe4745ee4e1fe Mon Sep 17 00:00:00 2001 From: "Arun Kumar K.R" Date: Wed, 23 Aug 2017 13:46:03 +0530 Subject: [PATCH] liblights: Enable button backlight conditionally Check for the existence of button backlight node before enabling that in the HAL. Change-Id: I66828d67dbabffdb694da55d4a3d12246fb7a66f Crs-fixed: 2093165 --- liblight/lights.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/liblight/lights.c b/liblight/lights.c index 3b5068cf..15db827b 100644 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -361,8 +361,14 @@ static int open_lights(const struct hw_module_t* module, char const* name, set_light = set_light_battery; else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) set_light = set_light_notifications; - else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) - set_light = set_light_buttons; + else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) { + if (!access(BUTTON_FILE, F_OK)) { + // enable light button when the file is present + set_light = set_light_buttons; + } else { + return -EINVAL; + } + } else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) set_light = set_light_attention; else