exynos4210: lights: add missing brightness check cm-10.1-M2 cm-10.1-M3
authorcodeworkx <codeworkx@cyanogenmod.org>
Sat, 2 Mar 2013 18:23:50 +0000 (18:23 +0000)
committercodeworkx <codeworkx@cyanogenmod.org>
Sat, 2 Mar 2013 18:23:50 +0000 (18:23 +0000)
Change-Id: I7d307fbfe7581bfa76e7f4f6ce50f759683bf9dc

exynos4/exynos4210/liblights/lights.c

index fe1e83f05184e1a9731f3ec6385ca2a736cdba7f..2d22b7cdc8aa2550b8bfebfadf61b0bfa55e66f0 100644 (file)
@@ -254,14 +254,19 @@ set_light_buttons(struct light_device_t* dev,
 #ifdef EXYNOS4210_TABLET
     return 0;
 #else
+    int err = 0;
+    int brightness = rgb_to_brightness(state);
 
     load_settings();
 
-    int err = 0;
-
     pthread_mutex_lock(&g_lock);
-    ALOGD("set_light_button on=%d\n", g_enable_touchlight ? 1 : 0);
-    err = write_int(BUTTON_FILE, g_enable_touchlight ? 1 : 0);
+    if (brightness > 0) {
+        ALOGD("set_light_buttons on=%d\n", g_enable_touchlight ? 1 : 0);
+        err = write_int(BUTTON_FILE, g_enable_touchlight ? 1 : 0);
+    } else {
+        ALOGD("set_light_buttons off\n");
+        err = write_int(BUTTON_FILE, 0);
+    }
     pthread_mutex_unlock(&g_lock);
 
     return err;