support led indicator func 60/14560/1
authorjy910.yun <jy910.yun@samsung.com>
Mon, 24 Jun 2013 12:50:35 +0000 (21:50 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Tue, 7 Jan 2014 15:18:59 +0000 (16:18 +0100)
libdeviced export led_set_mode, led_set_mode_with_color function.
system server controls real operation regarding led mode.

Change-Id: I2412fd4179230fceac49dfbcac4f4b47b2dde3a2
Signed-off-by: Krzysztof Sasiak <k.sasiak@samsung.com>
CMakeLists.txt
src/core/data.h
src/core/predefine.c
src/led/led.c [new file with mode: 0644]
src/led/led.h [new file with mode: 0644]
src/shared/led.c

index 4bf95c6..68c97a1 100755 (executable)
@@ -1,6 +1,11 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(system_server C)
 
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${PREFIX}/bin")
+SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}")
+SET(LIBDIR "\${prefix}/lib")
+
 # deviced
 SET(DEVICED_NAME deviced)
 SET(VERSION 0.1.0)
@@ -41,6 +46,9 @@ SET(SRCS ${SRCS}
        display/key-filter.c
        display/battery.c)
 
+SET(SRCS ${SRCS}
+       src/led/led.c)
+
 # libdeviced
 SET(DEVICED_SRCS
        src/shared/battery.c
index bc6ecb2..f686e55 100644 (file)
@@ -75,6 +75,8 @@ enum {
 #define PREDEF_CHECK_MMC               "checkmmc"
 #define PREDEF_CHECK_MMC_PROC  "checkmmcproc"
 
+#define PREDEF_LED             "led"
+
 #define PREDEF_SET_MAX_FREQUENCY       "set_max_frequency"     
 #define PREDEF_SET_MIN_FREQUENCY       "set_min_frequency"     
 #define PREDEF_RELEASE_MAX_FREQUENCY   "release_max_frequency" 
index addc991..e50045e 100644 (file)
@@ -41,6 +41,7 @@
 #include "core/data.h"
 #include "common.h"
 #include "display/poll.h"
+#include "led/led.h"
 
 #define CALL_EXEC_PATH                 PREFIX"/bin/call"
 #define LOWMEM_EXEC_PATH               PREFIX"/bin/lowmem-popup"
@@ -904,6 +905,9 @@ void ss_predefine_internal_init(void)
        ss_action_entry_add_internal(PREDEF_HAPTIC, haptic_def_predefine_action,
                                        NULL, NULL);
 
+       ss_action_entry_add_internal(PREDEF_LED,
+                                       led_def_predefine_action, NULL, NULL);
+
        if (vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void *)poweroff_control_cb, NULL) < 0) {
                _E("Vconf notify key chaneged failed: KEY(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
        }
diff --git a/src/led/led.c b/src/led/led.c
new file mode 100644 (file)
index 0000000..db482c2
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * deviced
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <errno.h>
+#include <assert.h>
+#include <device-node.h>
+
+#include "deviced/dd-led.h"
+#include "core/log.h"
+
+enum {
+       SET_BRT = 0,
+};
+
+static int set_brightness(int val)
+{
+       int r;
+
+       r = device_set_property(DEVICE_TYPE_LED, PROP_LED_BRIGHTNESS, val);
+       if (r < 0)
+               return r;
+
+       return 0;
+}
+
+int led_def_predefine_action(int argc, char **argv)
+{
+       int i;
+       int pid;
+       int prop;
+
+       _D("argc : %d", argc);
+       for (i = 0; i < argc; ++i)
+               _D("[%2d] %s", i, argv[i]);
+
+       if (argc > 4) {
+               _E("Invalid argument");
+               errno = EINVAL;
+               return -1;
+       }
+
+       pid = atoi(argv[0]);
+       prop = atoi(argv[1]);
+       _D("pid : %d, prop : %d", pid, prop);
+
+       switch(prop) {
+       case SET_BRT:
+               return set_brightness(atoi(argv[2]));
+       default:
+               break;
+       }
+
+       return -1;
+}
diff --git a/src/led/led.h b/src/led/led.h
new file mode 100644 (file)
index 0000000..4cd49b5
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * deviced
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __LED_H__
+#define __LED_H__
+
+int led_def_predefine_action(int argc, char **argv);
+
+#endif
index af70de2..4da1d7d 100644 (file)
@@ -6,7 +6,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 #include <device-node.h>
 
 #include "log.h"
+#include "dd-system.h"
 #include "dd-led.h"
 
+#define PREDEF_LED                     "led"
+
+enum {
+       SET_BRT = 0,
+};
+
 API int led_get_brightness(void)
 {
        int val;
@@ -50,11 +57,12 @@ API int led_get_max_brightness(void)
 
 API int led_set_brightness(int val)
 {
-       int r;
-
-       r = device_set_property(DEVICE_TYPE_LED, PROP_LED_BRIGHTNESS, val);
-       if (r < 0)
-               return r;
+       char buf_pid[32];
+       char buf_prop[32];
+       char buf_val[32];
 
-       return 0;
+       snprintf(buf_pid, sizeof(buf_pid), "%d", getpid());
+       snprintf(buf_prop, sizeof(buf_prop), "%d", SET_BRT);
+       snprintf(buf_val, sizeof(buf_val), "%d", val);
+       return system_call_predef_action(PREDEF_LED, 3, buf_pid, buf_prop, buf_val);
 }