input: Add SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin-backend 15/297415/4 accepted/tizen/unified/20230821.162249
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 18 Aug 2023 02:31:16 +0000 (11:31 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 18 Aug 2023 10:18:06 +0000 (19:18 +0900)
Add SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin-backend
for headless profile.

[Detailed description]
- package name :system-plugin-backend-deviced-headless-*.rpm
- files in package as following:
├── etc
│   └── deviced
│       ├── input.conf
│       └── power.conf
└── usr
    ├── bin
    │   └── rndis.sh
    ├── lib
    │   └── systemd
    │       └── system
    │           └── rndis.service
    ├── lib64
    │   └── system
    │       └── plugin
    │           └── libplugin-backend-deviced-input.so
    └── share
        └── licenses
            └── system-plugin-backend-deviced-headless
                └── LICENSE.Apache-2.0

Change-Id: If7f8d589e6b8693c2685d3a1d418b67111ca9a04
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt [new file with mode: 0644]
LICENSE.Apache-2.0 [new file with mode: 0644]
packaging/input.conf [new file with mode: 0644]
packaging/power.conf [new file with mode: 0644]
packaging/rndis.service [new file with mode: 0644]
packaging/rndis.sh [new file with mode: 0755]
packaging/system-plugin-backend-deviced-headless.manifest [new file with mode: 0644]
packaging/system-plugin-deviced-headless.spec [new file with mode: 0644]
src/deviced-input/CMakeLists.txt [new file with mode: 0644]
src/deviced-input/deviced-input.c [new file with mode: 0644]
src/deviced-input/input-config.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4553799
--- /dev/null
@@ -0,0 +1,13 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(${PLUGIN_BACKEND_NAME} C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
+
+ADD_SUBDIRECTORY(src/deviced-input)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/input.conf DESTINATION /etc/deviced)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/power.conf DESTINATION /etc/deviced)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/rndis.service DESTINATION /usr/lib/systemd/system)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/rndis.sh DESTINATION /usr/bin)
diff --git a/LICENSE.Apache-2.0 b/LICENSE.Apache-2.0
new file mode 100644 (file)
index 0000000..9fc6203
--- /dev/null
@@ -0,0 +1,204 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+
+
+
diff --git a/packaging/input.conf b/packaging/input.conf
new file mode 100644 (file)
index 0000000..1518e1c
--- /dev/null
@@ -0,0 +1,100 @@
+# [EventAction] - define event and corresponding action
+#  Name=string
+#   - define mnemonic for the event, and it is only used for logging
+#  Enum=integer
+#   - define an integer that represents the event. deviced uses this
+#     integer in broadcasting dbus signal.
+#  Keycode=integer
+#   - define keycode to filter key event
+#  DetectionRangeMsec=integer,integer
+#   - define time window in milisecond for filtering key event. -1 means no limit.
+#  TriggerType=level/edge
+#   - define event type
+#  ActionBroadcast=yes
+#   - Broadcast upon occuring an event, default no.
+#  ActionChangeState=current,next
+#   - define state transition action for the event.
+#  WakeLockDurationSec=
+#   - acquire wakelock for a specfied timeout
+
+#[EventAction]
+#Name=PWKEY_SHORT_EDGE
+#Enum=1000
+#Keycode=power
+#DetectionRangeMsec=0,2000
+#TriggerType=edge
+#ActionBroadcast=yes
+#WakeLockDurationSec=5
+
+#[EventAction]
+#Name=PWKEY_LONG_LEVEL
+#Enum=1001
+#Keycode=power
+#DetectionRangeMsec=2000,-1
+#TriggerType=level
+#ActionBroadcast=yes
+#WakeLockDurationSec=5
+
+#[EventAction]
+#Name=PWKEY_LONG_EDGE
+#Enum=1002
+#Keycode=power
+#DetectionRangeMsec=2000,7000
+#TriggerType=edge
+#ActionChangeState=normal,sleep
+#ActionChangeState=sleep,normal
+
+#[EventAction]
+#Name=PWKEY_LONGEST_LEVEL
+#Enum=1003
+#Keycode=power
+#DetectionRangeMsec=7000,-1
+#TriggerType=level
+#ActionBroadcast=yes
+#WakeLockDurationSec=5
+
+#[EventAction]
+#Name=PWKEY_LONGEST_EDGE_WO_CHARGER
+#Enum=1004
+#Keycode=power
+#DetectionRangeMsec=7000,-1
+#TriggerType=edge
+#ConditionVconf=memory/sysman/charger_status,int,0
+#ActionChangeState=normal,poweroff
+#ActionChangeState=sleep,normal
+
+#[EventAction]
+#Name=PWKEY_LONGEST_EDGE_W_CHARGER
+#Enum=1004
+#Keycode=power
+#DetectionRangeMsec=7000,-1
+#TriggerType=edge
+#ConditionVconf=memory/sysman/charger_status,int,1
+#ActionChangeState=normal,sleep
+#ActionChangeState=sleep,normal
+
+#[EventAction]
+#Name=BTKEY_SHORT_EDGE
+#Enum=1005
+#Keycode=bluetooth
+#DetectionRangeMsec=0,2000
+#TriggerType=edge
+#ActionBroadcast=yes
+#WakeLockDurationSec=5
+
+#[EventAction]
+#Name=BTKEY_LONG_LEVEL
+#Enum=1006
+#Keycode=bluetooth
+#DetectionRangeMsec=2000,-1
+#TriggerType=level
+#ActionBroadcast=yes
+#WakeLockDurationSec=5
+
+#[EventAction]
+#Name=BTKEY_LONG_EDGE
+#Enum=1007
+#Keycode=bluetooth
+#DetectionRangeMsec=2000,7000
+#TriggerType=edge
+#ActionBroadcast=yes
diff --git a/packaging/power.conf b/packaging/power.conf
new file mode 100644 (file)
index 0000000..0001706
--- /dev/null
@@ -0,0 +1,4 @@
+[PowerState]
+TimeoutSleepSupport=yes
+ChangeStateMaxWaitSecond=10
+PowerOffDelaySecond=0
diff --git a/packaging/rndis.service b/packaging/rndis.service
new file mode 100644 (file)
index 0000000..3072061
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=rndis service
+
+[Service]
+Type=oneshot
+User=network_fw
+Group=network_fw
+SmackProcessLabel=System
+ExecStart=/usr/bin/rndis.sh start
+ExecStop=/usr/bin/rndis.sh stop
+Capabilities=cap_net_admin=i
+SecureBits=keep-caps
+RemainAfterExit=yes
diff --git a/packaging/rndis.sh b/packaging/rndis.sh
new file mode 100755 (executable)
index 0000000..6a390e6
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+DEFAULT_IP_ADDR="192.168.129.3"
+
+#########################################################################################
+# TM1, TW2 : not configfs and have no ifname
+# TW3 : configfs and ifname value is "rndis0"
+# XU3 : configfs and ifname value is "usb0"
+if [ -e /sys/kernel/config/usb_gadget/hal-gadget/functions/rndis.default/ifname ]
+then
+       IFNAME=`cat /sys/kernel/config/usb_gadget/hal-gadget/functions/rndis.default/ifname`
+else
+       IFNAME="usb0"
+fi
+
+#########################################################################################
+VCONF=`vconftool get db/dnet/rndis_ip`
+if [ $? -ne 0 ]
+then
+       IP_ADDR=$DEFAULT_IP_ADDR
+else
+       IP_ADDR=`echo $VCONF | awk -F' ' '{print $4}'`
+fi
+
+#########################################################################################
+if [ x$1 == "xstart" ]
+then
+       echo "rndis network inteface =" $IFNAME
+       echo "rndis ip address =" $IP_ADDR
+
+       /sbin/ifconfig $IFNAME $IP_ADDR up
+else
+       /sbin/ifconfig $IFNAME down
+fi
diff --git a/packaging/system-plugin-backend-deviced-headless.manifest b/packaging/system-plugin-backend-deviced-headless.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/packaging/system-plugin-deviced-headless.spec b/packaging/system-plugin-deviced-headless.spec
new file mode 100644 (file)
index 0000000..996598b
--- /dev/null
@@ -0,0 +1,54 @@
+%define SYSTEM_PLUGIN_LIBDIR %{_libdir}/system/plugin
+
+Name:       system-plugin-backend-deviced-headless
+Summary:    System plugin backend for deviced and headless profile
+Version:    0.1.0
+Release:    0
+Group:      System/Libraries
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}.manifest
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(libsyscommon)
+BuildRequires:  pkgconfig(libsyscommon-plugin-api-deviced)
+BuildRequires:  pkgconfig(libinput)
+BuildRequires:  pkgconfig(libudev)
+BuildRequires:  pkgconfig(vconf)
+
+%description
+System plugin backend for deviced and headless profile
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%build
+%cmake . -DPLUGIN_BACKEND_NAME=%{name} \
+       -DPLUGIN_LIB_DIR=%{SYSTEM_PLUGIN_LIBDIR} \
+       -DPLUGIN_DEVICED_INPUT_ENABLE_DLOG=1
+
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%manifest %{name}.manifest
+%license LICENSE.Apache-2.0
+%{SYSTEM_PLUGIN_LIBDIR}/libplugin-backend-deviced-input.so
+%config %{_sysconfdir}/deviced/input.conf
+%config %{_sysconfdir}/deviced/power.conf
+%{_unitdir}/rndis.service
+%{_bindir}/rndis.sh
diff --git a/src/deviced-input/CMakeLists.txt b/src/deviced-input/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9fb133f
--- /dev/null
@@ -0,0 +1,28 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(plugin-backend-deviced-input C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(PKG_MODULES
+       libsyscommon
+       libsyscommon-plugin-api-deviced
+       libinput
+       libudev
+       vconf
+       glib-2.0)
+ADD_DEFINITIONS("-DENABLE_DLOG")
+ADD_DEFINITIONS("-DLOG_TAG=\"SYSTEM_PLUGIN_DEVICED_INPUT\"")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED deviced-input.c)
+MESSAGE("pkgs_LDFLAGS: ${pkgs_LDFLAGS}")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${PLUGIN_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/src/deviced-input/deviced-input.c b/src/deviced-input/deviced-input.c
new file mode 100644 (file)
index 0000000..1680205
--- /dev/null
@@ -0,0 +1,518 @@
+/**
+ * system-plugin-deviced-headless
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdlib.h>
+#include <glib.h>
+#include <assert.h>
+#include <stdbool.h>
+#include <time.h>
+#include <stdint.h>
+#include <libinput.h>
+#include <linux/input.h>
+#include <glib.h>
+
+#include <vconf.h>
+
+#include <libsyscommon/libgdbus.h>
+#include <libsyscommon/list.h>
+#include <libsyscommon/log.h>
+#include <libsyscommon/notifier.h>
+#include <libsyscommon/ini-parser.h>
+#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-common-interface.h>
+#include <system/syscommon-plugin-deviced-input.h>
+#include <system/syscommon-plugin-deviced-input-interface.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
+
+#define EXPORT __attribute__ ((visibility("default")))
+
+#define INPUT_CONF_PATH    "/etc/deviced/input.conf"
+
+enum input_trigger_type {
+       TRIGGER_TYPE_LEVEL, /* trigger event if a key is pressed for a duration */
+       TRIGGER_TYPE_EDGE,  /* trigger event if a key is released within a specific time interval */
+};
+
+struct input_condition_vconf {
+       char *keyname;
+       enum vconf_t type;
+       union {
+               int b;
+               int i;
+               double d;
+               char *s;
+       };
+};
+
+struct input_event_unit {
+       char *name;
+       int id;
+
+       /* which event to filter */
+       int keycode;
+       enum input_trigger_type type;
+       unsigned long interval[2];
+
+       /* level-trigger timer */
+       int timer;
+
+       /* condition for triggering action */
+       struct input_condition_vconf cv;
+
+       /* broadcast upon occuring the event */
+       int broadcast;
+
+       /* which action to do on receiving an event */
+       enum deviced_notifier notifier;
+       void *user_data;
+
+       /* hold wakelock for a duration on detecting the event */
+       int wakelock_duration;
+};
+
+struct input_config {
+       int keycode;
+       GList *event_list;     /* list of struct input_event_unit */
+
+       unsigned long start;   /* input incoming time in milisecond */
+};
+
+
+static syscommon_plugin_backend_deviced_input_funcs g_input_funcs;
+static GList *g_input_config_list;
+
+/***************************************************************************/
+struct input_config *find_input_config(int keycode)
+{
+       GList *elem;
+       struct input_config *ic;
+
+       SYS_G_LIST_FOREACH(g_input_config_list, elem, ic)
+               if (ic->keycode == keycode)
+                       return ic;
+
+       return NULL;
+}
+
+static void parse_keycode(struct input_event_unit *ieu, const char *keycode)
+{
+       if (MATCH(keycode, "power"))
+               ieu->keycode = KEY_POWER;
+       else if (MATCH(keycode, "bluetooth"))
+               ieu->keycode = KEY_BLUETOOTH;
+       /* add keycode list here */
+}
+
+static void parse_duration(struct input_event_unit *ieu, const char *duration)
+{
+       long start, end;
+       int retval;
+
+       retval = sscanf(duration, "%ld,%ld", &start, &end);
+       if (retval != 2) {
+               _E("Invalid duration format=%s", duration);
+               ieu->interval[0] = 0;
+               ieu->interval[1] = 0;
+               return;
+       }
+
+       if (end < 0)
+               end = ~0UL;
+
+       ieu->interval[0] = (unsigned long) start;
+       ieu->interval[1] = (unsigned long) end;
+}
+
+static void parse_trigger_type(struct input_event_unit *ieu, const char *type)
+{
+       if (MATCH(type, "edge")) {
+               ieu->type = TRIGGER_TYPE_EDGE;
+       } else if (MATCH(type, "level")) {
+               ieu->type = TRIGGER_TYPE_LEVEL;
+       } else {
+               _E("Invalid type=%s", type);
+               ieu->type = TRIGGER_TYPE_EDGE;
+       }
+
+}
+
+static void parse_condition_vconf(struct input_event_unit *ieu, const char *str)
+{
+       int retval;
+
+       char vconfkey[128] = { 0, };
+       char vconftype[16] = { 0, };
+       char vconfvalue[64] = { 0, };
+
+       retval = sscanf(str, "%127[^,],%15[^,],%63s", vconfkey, vconftype, vconfvalue);
+       if (retval != 3)
+               return;
+
+       _D("Condition vconf: key=%s, type=%s, value=%s", vconfkey, vconftype, vconfvalue);
+
+       if (!strncasecmp(vconftype, "bool", sizeof("bool"))) {
+               ieu->cv.type = VCONF_TYPE_BOOL;
+               sscanf(vconfvalue, "%d", &ieu->cv.b);
+       } else if (!strncasecmp(vconftype, "int", sizeof("int"))) {
+               ieu->cv.type = VCONF_TYPE_INT;
+               sscanf(vconfvalue, "%d", &ieu->cv.i);
+       } else if (!strncasecmp(vconftype, "double", sizeof("double"))) {
+               ieu->cv.type = VCONF_TYPE_DOUBLE;
+               sscanf(vconfvalue, "%lf", &ieu->cv.d);
+       } else if (!strncasecmp(vconftype, "string", sizeof("string"))) {
+               ieu->cv.type = VCONF_TYPE_STRING;
+               ieu->cv.s = strndup(vconfvalue, 128);
+       } else {
+               _E("Invalid condition vconf type");
+               return;
+       }
+
+       ieu->cv.keyname = strndup(vconfkey, 128);
+}
+
+static void add_action_transition_info(struct input_event_unit *ieu, char *curr, char *next)
+{
+       struct syscommon_plugin_deviced_power_trans_info *ti = NULL;
+       GList **action_list = (GList **) &(ieu->user_data);
+
+       ti = calloc(1, sizeof(struct syscommon_plugin_deviced_power_trans_info));
+       if (!ti)
+               return;
+
+       /* In configuration file, Enum= must be followed by Action=.
+        * Otherwise, ieu->id won't be defined at this point.*/
+       ti->reason = ieu->id;
+
+       ti->curr = syscommon_plugin_deviced_power_convert_to_power_state(curr);
+       ti->next = syscommon_plugin_deviced_power_convert_to_power_state(next);
+
+       SYS_G_LIST_APPEND(*action_list, ti);
+}
+
+static void parse_change_state(struct input_event_unit *ieu, const char *action)
+{
+       char curr[16] = { 0, };
+       char next[16] = { 0, };
+
+       if (sscanf(action, "%15[^,],%15s", curr, next) == 2) {
+               ieu->notifier = DEVICED_NOTIFIER_REQUEST_TRANSITION_STATE;
+               /* append transition info to ieu->user_data */
+               add_action_transition_info(ieu, curr, next);
+       } else {
+               _E("Invalid action=%s", action);
+       }
+}
+
+static void parse_event_action_property(gpointer data, gpointer user_data)
+{
+       struct section_property *prop = (struct section_property *) data;
+       struct input_event_unit *ieu = (struct input_event_unit *) user_data;
+
+       if (!prop || !ieu)
+               return;
+
+       _D("Key=%s, Value=%s", prop->key, prop->value);
+
+       if (MATCH(prop->key, "Name")) {
+               ieu->name = strndup(prop->value, 32);
+       } else if (MATCH(prop->key, "Enum")) {
+               sscanf(prop->value, "%d", &ieu->id);
+       } else if (MATCH(prop->key, "Keycode")) {
+               parse_keycode(ieu, prop->value);
+       } else if (MATCH(prop->key, "DetectionRangeMsec")) {
+               parse_duration(ieu, prop->value);
+       } else if (MATCH(prop->key, "TriggerType")) {
+               parse_trigger_type(ieu, prop->value);
+       } else if (MATCH(prop->key, "ConditionVconf")) {
+               parse_condition_vconf(ieu, prop->value);
+       } else if (MATCH(prop->key, "ActionChangeState")) {
+               parse_change_state(ieu, prop->value);
+       } else if (MATCH(prop->key, "ActionBroadcast")) {
+               ieu->broadcast = MATCH(prop->value, "yes");
+       } else if (MATCH(prop->key, "WakeLockDurationSec")) {
+               sscanf(prop->value, "%d", &ieu->wakelock_duration);
+       }
+}
+
+static int parse_event_action(const struct parse_result *result, void *data)
+{
+       struct input_config *ic;
+       struct input_event_unit *ieu;
+
+       if (!result || !result->props)
+               return 0;
+
+       if (!MATCH(result->section, "EventAction"))
+               return 0;
+
+       _D("Input section=%s", result->section);
+
+       ieu = calloc(1, sizeof(struct input_event_unit));
+       if (!ieu)
+               return 0;
+
+       g_list_foreach(result->props, parse_event_action_property, ieu);
+
+       ic = find_input_config(ieu->keycode);
+       if (!ic) {
+               ic = calloc(1, sizeof(struct input_config));
+               if (!ic)
+                       return -ENOMEM;
+               ic->keycode = ieu->keycode;
+               SYS_G_LIST_APPEND(g_input_config_list, ic);
+       }
+       SYS_G_LIST_APPEND(ic->event_list, ieu);
+
+       return 0;
+}
+
+int check_input_event_condition(const struct input_event_unit *ieu)
+{
+       char *keyname;
+       int retval, ret;
+       char buffer[256] = { 0, };
+
+       int b;
+       int i;
+       double d;
+       char *s;
+
+       if (!ieu)
+               return 0;
+
+       if (!ieu->cv.keyname)
+               return 1;
+
+       keyname = ieu->cv.keyname;
+
+       switch (ieu->cv.type) {
+       case VCONF_TYPE_BOOL:
+               retval = vconf_get_bool(keyname, &b);
+               if (retval < 0) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%d, current=%d", ieu->cv.b, b);
+               ret = (b == ieu->cv.b);
+               break;
+       case VCONF_TYPE_INT:
+               retval = vconf_get_int(keyname, &i);
+               if (retval < 0) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%d, current=%d", ieu->cv.i, i);
+               ret = (i == ieu->cv.i);
+               break;
+       case VCONF_TYPE_DOUBLE:
+               retval = vconf_get_dbl(keyname, &d);
+               if (retval < 0) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%lf, current=%lf", ieu->cv.d, d);
+               ret = (d == ieu->cv.d);
+               break;
+       case VCONF_TYPE_STRING:
+               s = vconf_get_str(keyname);
+               if (!s) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%s, current=%s", ieu->cv.s, s);
+               ret = (strncmp(s, ieu->cv.s, 128) == 0);
+               free(s);
+               break;
+       default:
+               return 0;
+       }
+
+       _D("Check condition vconf=%s(%s)", keyname, buffer);
+
+       return ret;
+}
+
+/***************************************************************************/
+static gboolean level_event_detected(gpointer data)
+{
+       struct input_event_unit *ieu = (struct input_event_unit *) data;
+
+       ieu->timer = 0;
+
+       _D("Detected level event=%s(%d), action=%d",
+                               ieu->name, ieu->id, ieu->notifier);
+
+       if (check_input_event_condition(ieu) == 0) {
+               _D("Skip triggering event=%s(%d), condition=%s isn't meet",
+                               ieu->name, ieu->id, ieu->cv.keyname);
+               return G_SOURCE_REMOVE;
+       }
+
+       if (ieu->broadcast)
+               gdbus_signal_emit(NULL, DEVICED_PATH_EVENT,
+                                       DEVICED_INTERFACE_EVENT,
+                                       DEVICED_SIGNAL_EVENT_ID,
+                                       g_variant_new("(i)", ieu->id));
+
+       if (ieu->wakelock_duration > 0)
+               syscommon_resman_set_resource_attr_uint64_2(
+                       SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+                       DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK,
+                       ieu->id, ieu->wakelock_duration);
+
+       if (ieu->notifier)
+               syscommon_notifier_emit_notify(ieu->notifier, ieu->user_data);
+
+       return G_SOURCE_REMOVE;
+}
+
+static void input_handler_edge_event_detected(struct input_event_unit *ieu)
+{
+       _D("Detected edge event=%s(%d), action=%d",
+                               ieu->name, ieu->id, ieu->notifier);
+
+       if (check_input_event_condition(ieu) == 0) {
+               _D("Skip triggering event=%s(%d), condition=%s isn't meet",
+                               ieu->name, ieu->id, ieu->cv.keyname);
+               return;
+       }
+
+       if (ieu->broadcast)
+               gdbus_signal_emit(NULL, DEVICED_PATH_EVENT,
+                                       DEVICED_INTERFACE_EVENT,
+                                       DEVICED_SIGNAL_EVENT_ID,
+                                       g_variant_new("(i)", ieu->id));
+
+       if (ieu->wakelock_duration > 0)
+               syscommon_resman_set_resource_attr_uint64_2(
+                       SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+                       DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK,
+                       ieu->id, ieu->wakelock_duration);
+
+       if (ieu->notifier)
+               syscommon_notifier_emit_notify(ieu->notifier, ieu->user_data);
+}
+
+static void input_handler_start_event_timer(struct input_config *ic)
+{
+       struct timespec ts;
+       struct input_event_unit *ieu;
+       GList *elem;
+
+       clock_gettime(CLOCK_MONOTONIC, &ts);
+       ic->start = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
+
+       /* set timer for level-trigger event */
+       SYS_G_LIST_FOREACH(ic->event_list, elem, ieu) {
+               if (ieu->type == TRIGGER_TYPE_LEVEL) {
+                       if (ieu->timer)
+                               g_source_remove(ieu->timer);
+                       ieu->timer = g_timeout_add(ieu->interval[0],
+                                               level_event_detected,
+                                               (gpointer) ieu);
+               }
+       }
+}
+
+static void input_handler_stop_event_timer(struct input_config *ic)
+{
+       struct timespec ts;
+       struct input_event_unit *ieu;
+       GList *elem;
+       unsigned long current;
+       unsigned long lapse;
+
+       if (ic->start == 0)
+               return;
+
+       clock_gettime(CLOCK_MONOTONIC, &ts);
+       current = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
+       lapse = current - ic->start;
+       ic->start = 0;
+
+       SYS_G_LIST_FOREACH(ic->event_list, elem, ieu) {
+               /* remove all level-trigger timer */
+               if (ieu->timer) {
+                       g_source_remove(ieu->timer);
+                       ieu->timer = 0;
+               }
+
+               /* detected edge-trigger event */
+               if (lapse >= ieu->interval[0]
+                               && lapse < ieu->interval[1]
+                               && ieu->type == TRIGGER_TYPE_EDGE)
+                       input_handler_edge_event_detected(ieu);
+       }
+}
+
+static void deviced_input_event_cb(struct timeval time, unsigned short type,
+                               unsigned short keycode, unsigned int keyvalue)
+{
+       struct input_config *ic;
+
+       if (type != EV_KEY)
+               return;
+
+       _D("Key input: code=%d, value=%d", keycode, keyvalue);
+
+       /* acquire tmplock on pressing key */
+       if (keyvalue == SYSCOMMON_DEVICED_INPUT_KEY_PRESSED)
+               syscommon_notifier_emit_notify(DEVICED_NOTIFIER_KEY_PRESS,
+                                       (void *)(intptr_t) keycode);
+
+       /* process all registered event to the keycode */
+       ic = find_input_config(keycode);
+       if (ic && keyvalue == SYSCOMMON_DEVICED_INPUT_KEY_PRESSED)
+               input_handler_start_event_timer(ic);
+       else if (ic && keyvalue == SYSCOMMON_DEVICED_INPUT_KEY_RELEASED)
+               input_handler_stop_event_timer(ic);
+
+       /* release tmplock on releasing key */
+       if (keyvalue == SYSCOMMON_DEVICED_INPUT_KEY_RELEASED)
+               syscommon_notifier_emit_notify(DEVICED_NOTIFIER_KEY_RELEASE,
+                                       (void *)(intptr_t) keycode);
+}
+
+static int deviced_input_init(void **data)
+{
+       *data = (void *)&g_input_funcs;
+
+       /* Parse /etc/deviced/input.conf */
+       syscommon_config_parse_by_section(INPUT_CONF_PATH, parse_event_action, NULL);
+
+       return 0;
+}
+
+static int deviced_input_exit(void *data)
+{
+       return 0;
+}
+
+static syscommon_plugin_backend_deviced_input_funcs g_input_funcs = {
+       .input_event_cb = deviced_input_event_cb,
+};
+
+syscommon_plugin_backend EXPORT system_plugin_backend_deviced_input_data = {
+       .name = "deviced-input",
+       .vendor = "Samsung",
+       .abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
+       .init = deviced_input_init,
+       .exit = deviced_input_exit,
+};
diff --git a/src/deviced-input/input-config.c b/src/deviced-input/input-config.c
new file mode 100644 (file)
index 0000000..d5ddf44
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2022 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 <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+#include <libsyscommon/ini-parser.h>
+#include <libsyscommon/list.h>
+#include <libsyscommon/log.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
+
+#include <linux/input.h>
+
+#include "input-config.h"
+
+#define INPUT_CONF_PATH    "/etc/deviced/input.conf"
+
+/* input config list */
+static GList *input_config_list;
+
+struct input_config *find_input_config(int keycode)
+{
+       GList *elem;
+       struct input_config *ic;
+
+       SYS_G_LIST_FOREACH(input_config_list, elem, ic)
+               if (ic->keycode == keycode)
+                       return ic;
+
+       return NULL;
+}
+
+static void parse_keycode(struct input_event_unit *ieu, const char *keycode)
+{
+       if (MATCH(keycode, "power"))
+               ieu->keycode = KEY_POWER;
+       else if (MATCH(keycode, "bluetooth"))
+               ieu->keycode = KEY_BLUETOOTH;
+       /* add keycode list here */
+}
+
+static void parse_duration(struct input_event_unit *ieu, const char *duration)
+{
+       long start, end;
+       int retval;
+
+       retval = sscanf(duration, "%ld,%ld", &start, &end);
+       if (retval != 2) {
+               _E("Invalid duration format=%s", duration);
+               ieu->interval[0] = 0;
+               ieu->interval[1] = 0;
+               return;
+       }
+
+       if (end < 0)
+               end = ~0UL;
+
+       ieu->interval[0] = (unsigned long) start;
+       ieu->interval[1] = (unsigned long) end;
+}
+
+static void parse_trigger_type(struct input_event_unit *ieu, const char *type)
+{
+       if (MATCH(type, "edge")) {
+               ieu->type = TRIGGER_TYPE_EDGE;
+       } else if (MATCH(type, "level")) {
+               ieu->type = TRIGGER_TYPE_LEVEL;
+       } else {
+               _E("Invalid type=%s", type);
+               ieu->type = TRIGGER_TYPE_EDGE;
+       }
+
+}
+
+static void parse_condition_vconf(struct input_event_unit *ieu, const char *str)
+{
+       int retval;
+
+       char vconfkey[128] = { 0, };
+       char vconftype[16] = { 0, };
+       char vconfvalue[64] = { 0, };
+
+       retval = sscanf(str, "%127[^,],%15[^,],%63s", vconfkey, vconftype, vconfvalue);
+       if (retval != 3)
+               return;
+
+       _D("Condition vconf: key=%s, type=%s, value=%s", vconfkey, vconftype, vconfvalue);
+
+       if (!strncasecmp(vconftype, "bool", sizeof("bool"))) {
+               ieu->cv.type = VCONF_TYPE_BOOL;
+               sscanf(vconfvalue, "%d", &ieu->cv.b);
+       } else if (!strncasecmp(vconftype, "int", sizeof("int"))) {
+               ieu->cv.type = VCONF_TYPE_INT;
+               sscanf(vconfvalue, "%d", &ieu->cv.i);
+       } else if (!strncasecmp(vconftype, "double", sizeof("double"))) {
+               ieu->cv.type = VCONF_TYPE_DOUBLE;
+               sscanf(vconfvalue, "%lf", &ieu->cv.d);
+       } else if (!strncasecmp(vconftype, "string", sizeof("string"))) {
+               ieu->cv.type = VCONF_TYPE_STRING;
+               ieu->cv.s = strndup(vconfvalue, 128);
+       } else {
+               _E("Invalid condition vconf type");
+               return;
+       }
+
+       ieu->cv.keyname = strndup(vconfkey, 128);
+}
+
+static void add_action_transition_info(struct input_event_unit *ieu, char *curr, char *next)
+{
+       struct syscommon_plugin_deviced_power_trans_info *ti = NULL;
+       GList **action_list = (GList **) &(ieu->user_data);
+
+       ti = calloc(1, sizeof(struct syscommon_plugin_deviced_power_trans_info));
+       if (!ti)
+               return;
+
+       /* In configuration file, Enum= must be followed by Action=.
+        * Otherwise, ieu->id won't be defined at this point.*/
+       ti->reason = ieu->id;
+
+       ti->curr = syscommon_plugin_deviced_power_convert_to_power_state(curr);
+       ti->next = syscommon_plugin_deviced_power_convert_to_power_state(next);
+
+       SYS_G_LIST_APPEND(*action_list, ti);
+}
+
+static void parse_change_state(struct input_event_unit *ieu, const char *action)
+{
+       char curr[16] = { 0, };
+       char next[16] = { 0, };
+
+       if (sscanf(action, "%15[^,],%15s", curr, next) == 2) {
+               ieu->notifier = DEVICED_NOTIFIER_REQUEST_TRANSITION_STATE;
+               /* append transition info to ieu->user_data */
+               add_action_transition_info(ieu, curr, next);
+       } else {
+               _E("Invalid action=%s", action);
+       }
+}
+
+static void parse_event_action_property(gpointer data, gpointer user_data)
+{
+       struct section_property *prop = (struct section_property *) data;
+       struct input_event_unit *ieu = (struct input_event_unit *) user_data;
+
+       if (!prop || !ieu)
+               return;
+
+       _D("Key=%s, Value=%s", prop->key, prop->value);
+
+       if (MATCH(prop->key, "Name")) {
+               ieu->name = strndup(prop->value, 32);
+       } else if (MATCH(prop->key, "Enum")) {
+               sscanf(prop->value, "%d", &ieu->id);
+       } else if (MATCH(prop->key, "Keycode")) {
+               parse_keycode(ieu, prop->value);
+       } else if (MATCH(prop->key, "DetectionRangeMsec")) {
+               parse_duration(ieu, prop->value);
+       } else if (MATCH(prop->key, "TriggerType")) {
+               parse_trigger_type(ieu, prop->value);
+       } else if (MATCH(prop->key, "ConditionVconf")) {
+               parse_condition_vconf(ieu, prop->value);
+       } else if (MATCH(prop->key, "ActionChangeState")) {
+               parse_change_state(ieu, prop->value);
+       } else if (MATCH(prop->key, "ActionBroadcast")) {
+               ieu->broadcast = MATCH(prop->value, "yes");
+       } else if (MATCH(prop->key, "WakeLockDurationSec")) {
+               sscanf(prop->value, "%d", &ieu->wakelock_duration);
+       }
+}
+
+static int parse_event_action(const struct parse_result *result, void *data)
+{
+       struct input_config *ic;
+       struct input_event_unit *ieu;
+
+       if (!result || !result->props)
+               return 0;
+
+       if (!MATCH(result->section, "EventAction"))
+               return 0;
+
+       _D("Input section=%s", result->section);
+
+       ieu = calloc(1, sizeof(struct input_event_unit));
+       if (!ieu)
+               return 0;
+
+       g_list_foreach(result->props, parse_event_action_property, ieu);
+
+       ic = find_input_config(ieu->keycode);
+       if (!ic) {
+               ic = calloc(1, sizeof(struct input_config));
+               if (!ic)
+                       return -ENOMEM;
+               ic->keycode = ieu->keycode;
+               SYS_G_LIST_APPEND(input_config_list, ic);
+       }
+       SYS_G_LIST_APPEND(ic->event_list, ieu);
+
+       return 0;
+}
+
+/* return 1 if the condition met, otherwise return 0 */
+int check_input_event_condition(const struct input_event_unit *ieu)
+{
+       char *keyname;
+       int retval, ret;
+       char buffer[256] = { 0, };
+
+       int b;
+       int i;
+       double d;
+       char *s;
+
+       if (!ieu)
+               return 0;
+
+       if (!ieu->cv.keyname)
+               return 1;
+
+       keyname = ieu->cv.keyname;
+
+       switch (ieu->cv.type) {
+       case VCONF_TYPE_BOOL:
+               retval = vconf_get_bool(keyname, &b);
+               if (retval < 0) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%d, current=%d", ieu->cv.b, b);
+               ret = (b == ieu->cv.b);
+               break;
+       case VCONF_TYPE_INT:
+               retval = vconf_get_int(keyname, &i);
+               if (retval < 0) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%d, current=%d", ieu->cv.i, i);
+               ret = (i == ieu->cv.i);
+               break;
+       case VCONF_TYPE_DOUBLE:
+               retval = vconf_get_dbl(keyname, &d);
+               if (retval < 0) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%lf, current=%lf", ieu->cv.d, d);
+               ret = (d == ieu->cv.d);
+               break;
+       case VCONF_TYPE_STRING:
+               s = vconf_get_str(keyname);
+               if (!s) {
+                       _E("Failed to get vconf=%s", keyname);
+                       return 0;
+               }
+               snprintf(buffer, sizeof(buffer), "expected=%s, current=%s", ieu->cv.s, s);
+               ret = (strncmp(s, ieu->cv.s, 128) == 0);
+               free(s);
+               break;
+       default:
+               return 0;
+       }
+
+       _D("Check condition vconf=%s(%s)", keyname, buffer);
+
+       return ret;
+}
+
+void init_input_config(void)
+{
+       syscommon_config_parse_by_section(INPUT_CONF_PATH, parse_event_action, NULL);
+}