pass: Remove battery and ir modules
authorWook Song <wook16.song@samsung.com>
Fri, 18 Nov 2016 01:39:46 +0000 (10:39 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 16 Jan 2017 11:35:36 +0000 (20:35 +0900)
PASS does not require the battery and ir modules of deviced. The
src/battery and src/ir directories are deleted. In order to apply these
changes, CMakeLists.txt and packaging/pass.spec files are also modified.

Signed-off-by: Wook Song <wook16.song@samsung.com>
CMakeLists.txt
packaging/pass.spec
src/battery/battery-time.c [deleted file]
src/battery/battery.conf [deleted file]
src/battery/battery.h [deleted file]
src/battery/config.c [deleted file]
src/battery/config.h [deleted file]
src/battery/lowbat-handler.c [deleted file]
src/battery/power-supply.c [deleted file]
src/battery/power-supply.h [deleted file]
src/ir/ir.c [deleted file]

index e7235b0..de415b3 100644 (file)
@@ -80,11 +80,6 @@ SET(SRCS
        src/time/time-handler.c
 )
 
-IF(BATTERY_MODULE STREQUAL on)
-       ADD_SOURCE(src/battery BATTERY_SRCS)
-       SET(SRCS ${SRCS} ${BATTERY_SRCS})
-ENDIF()
-
 IF(BLOCK_MODULE STREQUAL on)
        ADD_SOURCE(src/block BLOCK_SRCS)
        SET(SRCS ${SRCS} ${BLOCK_SRCS})
@@ -141,11 +136,6 @@ IF(${USBHOST_MODULE} STREQUAL on)
        SET(SRCS ${SRCS} ${USBHOST_SRCS})
 ENDIF()
 
-IF(IR_MODULE STREQUAL on)
-       ADD_SOURCE(src/ir IR_SRCS)
-       SET(SRCS ${SRCS} ${IR_SRCS})
-ENDIF()
-
 IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on)
        ADD_SOURCE(src/usb-host-test USB_HOST_TEST_SRCS)
        SET(SRCS ${SRCS} ${USB_HOST_TEST_SRCS})
@@ -238,9 +228,6 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/deviced/ DESTINATION include/$
                PATTERN "*_doc.h" EXCLUDE
                PATTERN "*.h")
 
-IF(BATTERY_MODULE STREQUAL on)
-       INSTALL_CONF(src/battery battery)
-ENDIF()
 IF(BLOCK_MODULE STREQUAL on)
        INSTALL_CONF(src/block block)
        INSTALL_CONF(src/block storage)
index a872b5a..7c7fcf0 100644 (file)
@@ -8,14 +8,12 @@
 %define libdaemon_name lib%{daemon_name}
 
 # display, extcon, power, usb are always enable
-%define battery_module off
 %define block_module on
 %define TIZEN_FEATURE_BLOCK_SET_PERMISSION on
 %define block_tmpfs off
 %define display_module on
 %define extcon_module on
 %define haptic_module off
-%define ir_module off
 %define led_module off
 %define power_module on
 %define touchscreen_module off
@@ -31,9 +29,7 @@
 %define standard_mix off
 
 %if "%{?profile}" == "mobile"
-%define battery_module on
 %define haptic_module on
-%define ir_module on
 %define led_module on
 %define touchscreen_module on
 %define tzip_module on
@@ -41,7 +37,6 @@
 %define TIZEN_FEATURE_USBHOST_TEST on
 %endif
 %if "%{?profile}" == "wearable"
-%define battery_module on
 %define haptic_module on
 %define touchscreen_module on
 %define tzip_module on
@@ -188,7 +183,6 @@ Deviced library for device control (devel)
        -DDPMS=%{DPMS} \
        -DENGINEER_MODE=%{engineer_mode} \
        -DPROFILE=%{profile} \
-       -DBATTERY_MODULE=%{battery_module} \
        -DBLOCK_MODULE=%{block_module} \
        -DTIZEN_FEATURE_BLOCK_SET_PERMISSION=%{TIZEN_FEATURE_BLOCK_SET_PERMISSION} \
        -DBLOCK_TMPFS=%{block_tmpfs} \
@@ -196,7 +190,6 @@ Deviced library for device control (devel)
        -DEXTCON_MODULE=%{extcon_module} \
        -DHAPTIC_MODULE=%{haptic_module} \
        -DSTANDARD_MIX=%{standard_mix} \
-       -DIR_MODULE=%{ir_module} \
        -DLED_MODULE=%{led_module} \
        -DPOWER_MODULE=%{power_module} \
        -DSDB_PRESTART=%{sdb_prestart} \
@@ -274,9 +267,6 @@ systemctl daemon-reload
 %{_unitdir}/sockets.target.wants/%{daemon_name}.socket
 %{_unitdir}/%{daemon_name}.service
 %{_unitdir}/%{daemon_name}.socket
-%if %{?battery_module} == on
-%config %{_sysconfdir}/deviced/battery.conf
-%endif
 %if %{?block_module} == on
 %if %{?TIZEN_FEATURE_BLOCK_SET_PERMISSION} == on
 %{_bindir}/mmc-smack-label
diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c
deleted file mode 100644 (file)
index 125e658..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * 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 <Ecore.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <vconf.h>
-#include <device-node.h>
-
-#include "core/common.h"
-#include "core/devices.h"
-#include "core/log.h"
-#include "core/edbus-handler.h"
-#include "display/setting.h"
-#include "power-supply.h"
-
-#define CHARGING_STATE(x)      ((x) & CHRGR_FLAG)
-#define FULL_CAPACITY          (100)
-#define BATTERY_FULL_THRESHOLD (98)
-#define MAX_COUNT_UNCHARGING   (10)
-#define MAX_COUNT_CHARGING     (10)
-#define PRINT_ALL_BATT_NODE(x) /*print_all_batt_node(x)*/
-#define POLLING_TIME           (30)    /* seconds */
-
-#define SIGNAL_TIMETOFULL      "TimeToFull"
-#define SIGNAL_TIMETOEMPTY     "TimeToEmpty"
-
-enum state_b {
-       B_UNCHARGING = 0,
-       B_CHARGING = 1,
-       B_END = 2
-};
-
-struct Batt_node {
-       time_t clock;
-       int capacity;
-       struct Batt_node *preview;
-       struct Batt_node *next;
-};
-
-enum state_a {
-       A_TIMETOEMPTY = 0,
-       A_TIMETOFULL = 1,
-       A_END = 2
-};
-
-static Ecore_Timer *timeout_id;
-
-static struct Batt_node *batt_head[B_END];
-static struct Batt_node *batt_tail[B_END];
-static int MAX_VALUE_COUNT[B_END] = {MAX_COUNT_UNCHARGING, MAX_COUNT_CHARGING};
-static double avg_factor[B_END] = {-1.0, -1.0};
-static int old_capacity;
-static int charging_state;
-extern int system_wakeup_flag;
-static int time_to_full = -1;
-static int time_to_empty = -1;
-
-static int add_batt_node(enum state_b b_index, time_t clock, int capacity)
-{
-       struct Batt_node *node = NULL;
-
-       PRINT_ALL_BATT_NODE(b_index);
-
-       if (b_index < 0 || b_index >= B_END)
-               return -1;
-
-       node = (struct Batt_node *) malloc(sizeof(struct Batt_node));
-       if (node == NULL) {
-               _E("Not enough memory, add battery node fail!");
-               return -1;
-       }
-
-       node->clock = clock;
-       node->capacity = capacity;
-
-       if (batt_head[b_index] == NULL && batt_tail[b_index] == NULL) {
-               batt_head[b_index] = batt_tail[b_index] = node;
-               node->preview = NULL;
-               node->next = NULL;
-       } else {
-               node->next = batt_head[b_index];
-               node->preview = NULL;
-               batt_head[b_index]->preview = node;
-               batt_head[b_index] = node;
-       }
-       PRINT_ALL_BATT_NODE(b_index);
-       return 0;
-}
-
-static int reap_batt_node(enum state_b b_index, int max_count)
-{
-       struct Batt_node *node = NULL;
-       struct Batt_node *tmp = NULL;
-       int cnt = 0;
-
-       PRINT_ALL_BATT_NODE(b_index);
-
-       if (b_index < 0 || b_index >= B_END)
-               return -1;
-
-       if (max_count <= 0)
-               return -1;
-
-       node = batt_head[b_index];
-
-       while (node != NULL) {
-               if (cnt >= max_count) break;
-               cnt++;
-               node = node->next;
-       }
-
-       if (node != NULL && node != batt_tail[b_index]) {
-               batt_tail[b_index] = node;
-               node = node->next;
-               batt_tail[b_index]->next = NULL;
-               while (node != NULL) {
-                       tmp = node;
-                       node = node->next;
-                       free(tmp);
-               }
-       }
-       PRINT_ALL_BATT_NODE(b_index);
-       return 0;
-}
-
-static int del_all_batt_node(enum state_b b_index)
-{
-       struct Batt_node *node = NULL;
-
-       PRINT_ALL_BATT_NODE(b_index);
-
-       if (b_index < 0 || b_index >= B_END)
-               return -1;
-       if (batt_head[b_index] == NULL)
-               return 0;
-
-       while (batt_head[b_index] != NULL) {
-               node = batt_head[b_index];
-               batt_head[b_index] = batt_head[b_index]->next;
-               free(node);
-       }
-       batt_tail[b_index] = NULL;
-       PRINT_ALL_BATT_NODE(b_index);
-       return 0;
-}
-
-static float update_factor(enum state_b b_index)
-{
-       struct Batt_node *node = NULL;
-       double factor = 0.0;
-       double total_factor = 0.0;
-       int cnt = 0;
-       double timediff = 0.0;
-       double capadiff = 0.0;
-
-       if (b_index < 0 || b_index >= B_END)
-               return 0;
-
-       if (batt_head[b_index] == NULL || batt_head[b_index]->next == NULL)
-               return  avg_factor[b_index];
-
-       node = batt_head[b_index];
-       while (1) {
-               timediff = difftime(node->clock, node->next->clock);
-               capadiff = node->capacity - node->next->capacity;
-               if (capadiff < 0)
-                       capadiff *= (-1);
-               if (capadiff != 0)
-                       factor = timediff / capadiff;
-               total_factor += factor;
-
-               node = node->next;
-               cnt++;
-
-               /*_I("[%d] timediff(%lf) / capadiff(%lf) = factor(%lf)",
-                       cnt, timediff, capadiff, factor);*/
-               factor = 0.0;
-
-               if (node == NULL || node->next == NULL)
-                       break;
-               if (cnt >= MAX_VALUE_COUNT[b_index]) {
-                       reap_batt_node(b_index, MAX_VALUE_COUNT[b_index]);
-                       break;
-               }
-       }
-       total_factor /= (float)cnt;
-
-       return total_factor;
-}
-
-static void broadcast_battery_time(char *signal, int time)
-{
-       char *param[1];
-       char buf[10];
-
-       if (!signal)
-               return;
-
-       snprintf(buf, 10, "%d", time);
-       param[0] = buf;
-
-       broadcast_edbus_signal(DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
-           signal, "i", param);
-}
-
-static void update_time(enum state_a a_index, int seconds)
-{
-       if (a_index < 0 || a_index >= A_END)
-               return;
-
-       if (seconds <= 0)
-               return;
-
-       switch (a_index) {
-       case A_TIMETOFULL:
-               broadcast_battery_time(SIGNAL_TIMETOFULL, seconds);
-               time_to_full = seconds;
-               break;
-       case A_TIMETOEMPTY:
-               broadcast_battery_time(SIGNAL_TIMETOEMPTY, seconds);
-               time_to_empty = seconds;
-               break;
-       default:
-               break;
-       }
-}
-
-static int battinfo_calculation(void)
-{
-       time_t clock;
-       int capacity = 0;
-       int estimated_time = 0;
-       int tmp = 0;
-
-       capacity = battery.capacity;
-
-       if (capacity <= 0)
-               return -1;
-       if (capacity == old_capacity)
-               return 0;
-
-       old_capacity = capacity;
-
-       if (get_charging_status(&tmp) == 0)
-               charging_state = (tmp > 0 ? EINA_TRUE : EINA_FALSE);
-
-       clock = time(NULL);
-       if (charging_state == EINA_TRUE) {
-               del_all_batt_node(B_UNCHARGING);
-               if ((capacity * 100 / FULL_CAPACITY)
-                               >= BATTERY_FULL_THRESHOLD) {
-                       if (battery.charge_full == CHARGING_FULL) {
-                               del_all_batt_node(B_CHARGING);
-                               _I("battery fully charged!");
-                               update_time(A_TIMETOFULL, 0);
-                               return 0;
-                       }
-               }
-               if (batt_head[B_CHARGING] == NULL) {
-                       add_batt_node(B_CHARGING, clock, capacity);
-               } else {
-                       add_batt_node(B_CHARGING, clock, capacity);
-                       avg_factor[B_CHARGING] = update_factor(B_CHARGING);
-               }
-               estimated_time = (float)(FULL_CAPACITY - capacity) *
-                               avg_factor[B_CHARGING];
-               update_time(A_TIMETOFULL, estimated_time);
-       } else {
-               del_all_batt_node(B_CHARGING);
-               if (system_wakeup_flag == true) {
-                       del_all_batt_node(B_UNCHARGING);
-                       system_wakeup_flag = false;
-               }
-               if (batt_head[B_UNCHARGING] == NULL) {
-                       add_batt_node(B_UNCHARGING, clock, capacity);
-               } else {
-                       add_batt_node(B_UNCHARGING, clock, capacity);
-                       avg_factor[B_UNCHARGING] = update_factor(B_UNCHARGING);
-               }
-               estimated_time = (float)capacity * avg_factor[B_UNCHARGING];
-               update_time(A_TIMETOEMPTY, estimated_time);
-       }
-       return 0;
-}
-
-static Eina_Bool battinfo_cb(void *data)
-{
-       battinfo_calculation();
-       return ECORE_CALLBACK_RENEW;
-}
-
-static int start_battinfo_gathering(int timeout)
-{
-       _I("Start battery gathering!");
-
-       if (timeout <= 0) {
-               _E("invalid timeout value [%d]!", timeout);
-               return -1;
-       }
-
-       old_capacity = 0;
-       battinfo_calculation();
-
-       if (timeout > 0)        {
-               /* Using g_timer for gathering battery info */
-               timeout_id = ecore_timer_add(timeout,
-                       (Ecore_Task_Cb)battinfo_cb, NULL);
-       }
-
-       return 0;
-}
-
-static void end_battinfo_gathering(void)
-{
-       _I("End battery gathering!");
-
-       if (timeout_id) {
-               ecore_timer_del(timeout_id);
-               timeout_id = NULL;
-       }
-
-       del_all_batt_node(B_UNCHARGING);
-       del_all_batt_node(B_CHARGING);
-}
-
-static DBusMessage *dbus_get_timetofull(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int val;
-
-       val = time_to_full;
-
-       _D("get time %d", val);
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &val);
-       return reply;
-}
-
-static DBusMessage *dbus_get_timetoempty(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int val;
-
-       val = time_to_empty;
-
-       _D("get time %d", val);
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &val);
-       return reply;
-}
-
-static const struct edbus_method edbus_methods[] = {
-       { SIGNAL_TIMETOFULL,   NULL, "i", dbus_get_timetofull },
-       { SIGNAL_TIMETOEMPTY,  NULL, "i", dbus_get_timetoempty },
-       /* Add methods here */
-};
-
-static void battery_init(void *data)
-{
-       int ret;
-
-       /* init dbus interface */
-       ret = register_edbus_interface_and_method(DEVICED_PATH_BATTERY,
-                       DEVICED_INTERFACE_BATTERY,
-                       edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0)
-               _E("fail to init edbus interface and method(%d)", ret);
-
-       start_battinfo_gathering(POLLING_TIME);
-}
-
-static void battery_exit(void *data)
-{
-       end_battinfo_gathering();
-}
-
-static const struct device_ops battery_time_device_ops = {
-       .name     = "battery-time",
-       .init     = battery_init,
-       .exit     = battery_exit,
-};
-
-DEVICE_OPS_REGISTER(&battery_time_device_ops)
diff --git a/src/battery/battery.conf b/src/battery/battery.conf
deleted file mode 100644 (file)
index c882320..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[LOWBAT]
-#low battery level
-Normal=100
-Warning=15
-Critical=5
-PowerOff=1
-RealOff=0
-WarningMethod=warning
-CriticalMethod=critical
diff --git a/src/battery/battery.h b/src/battery/battery.h
deleted file mode 100644 (file)
index f1496bb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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 __BATTERY_H__
-#define __BATTERY_H__
-
-#define BATTERY_LEVEL_CHECK_FULL       95
-#define BATTERY_LEVEL_CHECK_HIGH       15
-#define BATTERY_LEVEL_CHECK_LOW                5
-#define BATTERY_LEVEL_CHECK_CRITICAL   1
-
-#define LOWBAT_OPT_WARNING             1
-#define LOWBAT_OPT_POWEROFF            2
-#define LOWBAT_OPT_CHARGEERR           3
-#define LOWBAT_OPT_CHECK               4
-
-#define METHOD_NAME_MAX                        32
-struct battery_config_info {
-       int normal;
-       int warning;
-       int critical;
-       int poweroff;
-       int realoff;
-};
-
-int battery_charge_err_low_act(void *data);
-int battery_charge_err_high_act(void *data);
-#endif /* __BATTERY_H__ */
diff --git a/src/battery/config.c b/src/battery/config.c
deleted file mode 100644 (file)
index 4dd42c1..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2014 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 <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdbool.h>
-#include <assert.h>
-
-#include "core/log.h"
-#include "core/common.h"
-#include "core/config-parser.h"
-#include "battery.h"
-#include "config.h"
-
-#define BAT_CONF_FILE  "/etc/deviced/battery.conf"
-
-static int load_config(struct parse_result *result, void *user_data)
-{
-       struct battery_config_info *info = user_data;
-       char *name;
-       char *value;
-
-       _D("%s,%s,%s", result->section, result->name, result->value);
-
-       if (!info)
-               return -EINVAL;
-
-       if (!MATCH(result->section, "LOWBAT"))
-               return -EINVAL;
-
-       name = result->name;
-       value = result->value;
-       if (MATCH(name, "Normal"))
-               info->normal = atoi(value);
-       else if (MATCH(name, "Warning"))
-               info->warning = atoi(value);
-       else if (MATCH(name, "Critical"))
-               info->critical = atoi(value);
-       else if (MATCH(name, "PowerOff"))
-               info->poweroff = atoi(value);
-       else if (MATCH(name, "RealOff"))
-               info->realoff = atoi(value);
-
-       return 0;
-}
-
-void battery_config_load(struct battery_config_info *info)
-{
-       int ret;
-
-       ret = config_parse(BAT_CONF_FILE, load_config, info);
-       if (ret < 0)
-               _E("Failed to load %s, %d Use default value!", BAT_CONF_FILE, ret);
-}
diff --git a/src/battery/config.h b/src/battery/config.h
deleted file mode 100644 (file)
index 77ca856..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2014 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 __BATTERY_CONFIG_H__
-#define __BATTERY_CONFIG_H__
-
-#define BATTERY_FULL     100
-#define BATTERY_NORMAL   BATTERY_FULL
-#define BATTERY_WARNING  15
-#define BATTERY_CRITICAL 5
-#define BATTERY_POWEROFF 1
-#define BATTERY_REALOFF  0
-
-void battery_config_load(struct battery_config_info *info);
-#endif /* __BATTERY_CONFIG_H__ */
diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c
deleted file mode 100644 (file)
index cad1bf7..0000000
+++ /dev/null
@@ -1,641 +0,0 @@
-/*
- * 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 <stdbool.h>
-#include <assert.h>
-#include <limits.h>
-#include <vconf.h>
-#include <fcntl.h>
-#include <bundle.h>
-#include <eventsystem.h>
-
-#include "battery.h"
-#include "config.h"
-#include "core/log.h"
-#include "core/launch.h"
-#include "core/devices.h"
-#include "core/device-notifier.h"
-#include "core/common.h"
-#include "core/list.h"
-#include "core/udev.h"
-#include "device-node.h"
-#include "display/setting.h"
-#include "display/poll.h"
-#include "core/edbus-handler.h"
-#include "power/power-handler.h"
-#include "apps/apps.h"
-#include "power-supply.h"
-
-#define CHARGE_POWERSAVE_FREQ_ACT      "charge_powersave_freq_act"
-#define CHARGE_RELEASE_FREQ_ACT                "charge_release_freq_act"
-
-#define POWER_OFF_CHECK_TIMER  (30)
-
-#define BATTERY_CHARGING       65535
-#define BATTERY_UNKNOWN                -1
-
-#define WARNING_LOW_BAT_ACT            "warning_low_bat_act"
-#define CRITICAL_LOW_BAT_ACT           "critical_low_bat_act"
-#define POWER_OFF_BAT_ACT              "power_off_bat_act"
-#define CHARGE_BAT_ACT                 "charge_bat_act"
-#define CHARGE_CHECK_ACT                       "charge_check_act"
-#define CHARGE_ERROR_ACT                       "charge_error_act"
-#define CHARGE_ERROR_LOW_ACT                   "charge_error_low_act"
-#define CHARGE_ERROR_HIGH_ACT                  "charge_error_high_act"
-#define CHARGE_ERROR_OVP_ACT                   "charge_error_ovp_act"
-#define WAITING_INTERVAL       10
-
-#define LOWBAT_CPU_CTRL_ID     "id6"
-#define LOWBAT_CPU_FREQ_RATE   (0.7)
-
-#define POWER_OFF_UNLOCK       0
-#define POWER_OFF_LOCK         1
-
-struct lowbat_process_entry {
-       int old;
-       int now;
-       int (*func) (void *data);
-};
-
-static int cur_bat_state = BATTERY_UNKNOWN;
-static int cur_bat_capacity = -1;
-
-static struct battery_config_info battery_info = {
-       .normal   = BATTERY_NORMAL,
-       .warning  = BATTERY_WARNING,
-       .critical = BATTERY_CRITICAL,
-       .poweroff = BATTERY_POWEROFF,
-       .realoff  = BATTERY_REALOFF,
-};
-
-static dd_list *lpe;
-static int scenario_count;
-static int power_off_lock = POWER_OFF_UNLOCK;
-static Ecore_Timer *power_off_timer;
-
-static int lowbat_popup(char *option);
-
-static int lowbat_initialized(void *data)
-{
-       static int status;
-
-       if (!data)
-               return status;
-
-       status = *(int *)data;
-       return status;
-}
-
-static int lowbat_scenario(int old, int now, void *data)
-{
-       dd_list *n;
-       struct lowbat_process_entry *scenario;
-       int found = 0;
-
-       if (old == now && battery.charge_now)
-               return found;
-       DD_LIST_FOREACH(lpe, n, scenario) {
-               if (old != scenario->old || now != scenario->now)
-                       continue;
-               if (!scenario->func)
-                       continue;
-               scenario->func(data);
-               found = 1;
-               break;
-       }
-       return found;
-}
-
-static int lowbat_add_scenario(int old, int now, int (*func)(void *data))
-{
-       struct lowbat_process_entry *scenario;
-
-       _I("%d %d, %x", old, now, func);
-
-       if (!func) {
-               _E("invalid func address!");
-               return -EINVAL;
-       }
-
-       scenario = malloc(sizeof(struct lowbat_process_entry));
-       if (!scenario) {
-               _E("Fail to malloc for notifier!");
-               return -ENOMEM;
-       }
-
-       scenario->old = old;
-       scenario->now = now;
-       scenario->func = func;
-
-       DD_LIST_APPEND(lpe, scenario);
-       scenario_count++;
-       return 0;
-}
-
-static void print_lowbat_state(unsigned int bat_percent)
-{
-#if 0
-       int i;
-       for (i = 0; i < BAT_MON_SAMPLES; i++)
-               _D("\t%d", recent_bat_percent[i]);
-#endif
-}
-
-static int power_execute(void *data)
-{
-       static const struct device_ops *ops;
-
-       FIND_DEVICE_INT(ops, POWER_OPS_NAME);
-
-       return ops->execute(data);
-}
-
-static int booting_done(void *data)
-{
-       static int done;
-       static int popup;
-
-       if (data == NULL) {
-               if (!done)
-                       popup = 1;
-               goto out;
-       }
-       done = *(int *)data;
-       if (!done)
-               goto out;
-       _I("booting done");
-       if (popup) {
-               popup = 0;
-               lowbat_popup(NULL);
-       }
-out:
-       return done;
-}
-
-static void power_off_pm_lock(void)
-{
-       if (power_off_lock == POWER_OFF_UNLOCK) {
-               pm_lock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, STAY_CUR_STATE, 0);
-               power_off_lock = POWER_OFF_LOCK;
-       }
-}
-
-static void power_off_pm_unlock(void)
-{
-       if (power_off_lock == POWER_OFF_LOCK) {
-               pm_unlock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, PM_SLEEP_MARGIN);
-               power_off_lock = POWER_OFF_UNLOCK;
-       }
-}
-
-static Eina_Bool power_off_cb(void *data)
-{
-       power_off_pm_unlock();
-       power_execute(POWER_POWEROFF);
-       return EINA_FALSE;
-}
-
-void power_off_timer_start(void)
-{
-       if (power_off_timer)
-               return;
-       _I("power off after %d", POWER_OFF_CHECK_TIMER);
-       power_off_pm_lock();
-       power_off_timer = ecore_timer_add(POWER_OFF_CHECK_TIMER,
-                               power_off_cb, NULL);
-       if (power_off_timer == NULL)
-               _E("fail to add battery init timer during booting");
-}
-
-void power_off_timer_stop(void)
-{
-       if (!power_off_timer)
-               return;
-       _I("cancel power off");
-       power_off_pm_unlock();
-       ecore_timer_del(power_off_timer);
-       power_off_timer = NULL;
-}
-
-static int lowbat_popup(char *option)
-{
-       static int launched_poweroff;
-       static int lowbat_popup_option;
-       int ret;
-       int r_disturb, s_disturb, r_block, s_block;
-       static char *value;
-
-       if (!option) {
-               if (!value)
-                       return -1;
-               else
-                       goto direct_launch;
-       }
-
-       if (strcmp(option, POWER_OFF_BAT_ACT))
-               launched_poweroff = 0;
-
-       if (!strcmp(option, CRITICAL_LOW_BAT_ACT)) {
-               value = "lowbattery_critical";
-               lowbat_popup_option = LOWBAT_OPT_CHECK;
-       } else if (!strcmp(option, WARNING_LOW_BAT_ACT)) {
-               value = "lowbattery_warning";
-               lowbat_popup_option = LOWBAT_OPT_WARNING;
-       } else if (!strcmp(option, POWER_OFF_BAT_ACT)) {
-               value = "poweroff";
-               lowbat_popup_option = LOWBAT_OPT_POWEROFF;
-       } else if (!strcmp(option, CHARGE_ERROR_ACT)) {
-               value = "chargeerr";
-               lowbat_popup_option = LOWBAT_OPT_CHARGEERR;
-       } else if (!strcmp(option, CHARGE_ERROR_LOW_ACT)) {
-               value = "chargeerrlow";
-               lowbat_popup_option = LOWBAT_OPT_CHARGEERR;
-       } else if (!strcmp(option, CHARGE_ERROR_HIGH_ACT)) {
-               value = "chargeerrhigh";
-               lowbat_popup_option = LOWBAT_OPT_CHARGEERR;
-       } else if (!strcmp(option, CHARGE_ERROR_OVP_ACT)) {
-               value = "chargeerrovp";
-               lowbat_popup_option = LOWBAT_OPT_CHARGEERR;
-       } else if (!strcmp(option, CHARGE_CHECK_ACT)) {
-               launched_poweroff = 0;
-               return 0;
-       } else
-               return -1;
-
-direct_launch:
-       _D("%s", value);
-       if (booting_done(NULL)) {
-
-               if (launched_poweroff == 1) {
-                       _I("will be foreced power off");
-                       power_execute(POWER_POWEROFF);
-                       return 0;
-               }
-
-               if (lowbat_popup_option == LOWBAT_OPT_POWEROFF)
-                       launched_poweroff = 1;
-
-               ret = launch_system_app(APP_DEFAULT,
-                               2, APP_KEY_TYPE, "remove_battery_popups");
-               if (ret < 0)
-                       _E("Failed to close all of battery popups");
-
-               r_disturb = vconf_get_int("memory/shealth/sleep/do_not_disturb", &s_disturb);
-               r_block = vconf_get_bool("db/setting/blockmode_wearable", &s_block);
-               if ((r_disturb != 0 && r_block != 0) ||
-                   (s_disturb == 0 && s_block == 0) ||
-                   lowbat_popup_option == LOWBAT_OPT_CHARGEERR)
-                       pm_change_internal(getpid(), LCD_NORMAL);
-               else
-                       _I("block LCD");
-
-               return launch_system_app(APP_DEFAULT,
-                               2, APP_KEY_TYPE, value);
-       } else {
-               _D("boot-animation running yet");
-       }
-
-       return 0;
-}
-
-static int battery_check_act(void *data)
-{
-       power_off_timer_stop();
-       lowbat_popup(CHARGE_CHECK_ACT);
-       return 0;
-}
-
-static int battery_warning_low_act(void *data)
-{
-       power_off_timer_stop();
-       lowbat_popup(WARNING_LOW_BAT_ACT);
-       return 0;
-}
-
-static int battery_critical_low_act(void *data)
-{
-       power_off_timer_stop();
-       lowbat_popup(CRITICAL_LOW_BAT_ACT);
-       return 0;
-}
-
-int battery_power_off_act(void *data)
-{
-       lowbat_popup(CRITICAL_LOW_BAT_ACT);
-       power_off_timer_start();
-       return 0;
-}
-
-int battery_charge_err_act(void *data)
-{
-       power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_ACT);
-       return 0;
-}
-
-int battery_charge_err_low_act(void *data)
-{
-       power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_LOW_ACT);
-       return 0;
-}
-
-int battery_charge_err_high_act(void *data)
-{
-       power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_HIGH_ACT);
-       return 0;
-}
-
-int battery_charge_err_ovp_act(void *data)
-{
-       power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_OVP_ACT);
-       return 0;
-}
-
-static void lowbat_scenario_init(void)
-{
-       lowbat_add_scenario(battery_info.normal, battery_info.warning, battery_warning_low_act);
-       lowbat_add_scenario(battery_info.normal, battery_info.critical, battery_critical_low_act);
-       lowbat_add_scenario(battery_info.normal, battery_info.poweroff, battery_critical_low_act);
-       lowbat_add_scenario(battery_info.normal, battery_info.realoff, battery_power_off_act);
-       lowbat_add_scenario(battery_info.warning, battery_info.warning, battery_warning_low_act);
-       lowbat_add_scenario(battery_info.warning, battery_info.critical, battery_critical_low_act);
-       lowbat_add_scenario(battery_info.warning, battery_info.poweroff, battery_critical_low_act);
-       lowbat_add_scenario(battery_info.warning, battery_info.realoff, battery_power_off_act);
-       lowbat_add_scenario(battery_info.critical, battery_info.critical, battery_critical_low_act);
-       lowbat_add_scenario(battery_info.critical, battery_info.realoff, battery_power_off_act);
-       lowbat_add_scenario(battery_info.poweroff, battery_info.poweroff, battery_critical_low_act);
-       lowbat_add_scenario(battery_info.poweroff, battery_info.realoff, battery_power_off_act);
-       lowbat_add_scenario(battery_info.realoff, battery_info.realoff, battery_power_off_act);
-       lowbat_add_scenario(battery_info.realoff, battery_info.normal, battery_check_act);
-       lowbat_add_scenario(battery_info.realoff, battery_info.warning, battery_check_act);
-       lowbat_add_scenario(battery_info.realoff, battery_info.critical, battery_check_act);
-       lowbat_add_scenario(battery_info.realoff, battery_info.poweroff, battery_check_act);
-       lowbat_add_scenario(battery_info.realoff, battery_info.realoff, battery_power_off_act);
-}
-
-static void battery_level_send_system_event(int bat_percent)
-{
-       bundle *b;
-       const char *str;
-       static const char *prev;
-
-       if (bat_percent > BATTERY_LEVEL_CHECK_FULL)
-               str = EVT_VAL_BATTERY_LEVEL_FULL;
-       else if (bat_percent > BATTERY_LEVEL_CHECK_HIGH)
-               str = EVT_VAL_BATTERY_LEVEL_HIGH;
-       else if (bat_percent > BATTERY_LEVEL_CHECK_LOW)
-               str = EVT_VAL_BATTERY_LEVEL_LOW;
-       else if (bat_percent > BATTERY_LEVEL_CHECK_CRITICAL)
-               str = EVT_VAL_BATTERY_LEVEL_CRITICAL;
-       else
-               str = EVT_VAL_BATTERY_LEVEL_EMPTY;
-
-       if (prev == str)
-               return;
-
-       prev = str;
-
-       _D("system_event(%s)", str);
-
-       b = bundle_create();
-       bundle_add_str(b, EVT_KEY_BATTERY_LEVEL_STATUS, str);
-       eventsystem_send_system_event(SYS_EVENT_BATTERY_LEVEL_STATUS, b);
-       bundle_free(b);
-}
-
-static void change_lowbat_level(int bat_percent)
-{
-       int prev, now;
-
-       if (cur_bat_capacity == bat_percent)
-               return;
-
-       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_LEVEL_STATUS, &prev) < 0) {
-               _E("vconf_get_int() failed");
-               return;
-       }
-
-       if (bat_percent > BATTERY_LEVEL_CHECK_FULL)
-               now = VCONFKEY_SYSMAN_BAT_LEVEL_FULL;
-       else if (bat_percent > BATTERY_LEVEL_CHECK_HIGH)
-               now = VCONFKEY_SYSMAN_BAT_LEVEL_HIGH;
-       else if (bat_percent > BATTERY_LEVEL_CHECK_LOW)
-               now = VCONFKEY_SYSMAN_BAT_LEVEL_LOW;
-       else if (bat_percent > BATTERY_LEVEL_CHECK_CRITICAL)
-               now = VCONFKEY_SYSMAN_BAT_LEVEL_CRITICAL;
-       else
-               now = VCONFKEY_SYSMAN_BAT_LEVEL_EMPTY;
-
-       if (prev != now)
-               vconf_set_int(VCONFKEY_SYSMAN_BATTERY_LEVEL_STATUS, now);
-}
-
-static int lowbat_process(int bat_percent, void *ad)
-{
-       static int online;
-       int new_bat_capacity;
-       int new_bat_state;
-       int vconf_state = -1;
-       int ret = 0;
-       int status = -1;
-       bool low_bat = false;
-       int result = 0;
-       int lock = -1;
-
-       new_bat_capacity = bat_percent;
-       if (new_bat_capacity < 0)
-               return -EINVAL;
-       change_lowbat_level(new_bat_capacity);
-       battery_level_send_system_event(new_bat_capacity);
-
-       if (new_bat_capacity != cur_bat_capacity) {
-               _D("[BAT_MON] cur = %d new = %d", cur_bat_capacity, new_bat_capacity);
-               if (vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, new_bat_capacity) == 0)
-                       cur_bat_capacity = new_bat_capacity;
-               power_supply_broadcast(CHARGE_CAPACITY_SIGNAL, new_bat_capacity);
-       }
-
-       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &vconf_state) < 0) {
-               _E("vconf_get_int() failed");
-               result = -EIO;
-               goto exit;
-       }
-
-       if (new_bat_capacity <= battery_info.realoff) {
-               if (battery.charge_now) {
-                       new_bat_state = battery_info.poweroff;
-                       if (vconf_state != VCONFKEY_SYSMAN_BAT_POWER_OFF)
-                               status = VCONFKEY_SYSMAN_BAT_POWER_OFF;
-               } else {
-                       new_bat_state = battery_info.realoff;
-                       if (vconf_state != VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF)
-                               status = VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF;
-               }
-       } else if (new_bat_capacity <= battery_info.poweroff) {
-               new_bat_state = battery_info.poweroff;
-               if (vconf_state != VCONFKEY_SYSMAN_BAT_POWER_OFF)
-                       status = VCONFKEY_SYSMAN_BAT_POWER_OFF;
-       } else if (new_bat_capacity <= battery_info.critical) {
-               new_bat_state = battery_info.critical;
-               if (vconf_state != VCONFKEY_SYSMAN_BAT_CRITICAL_LOW)
-                       status = VCONFKEY_SYSMAN_BAT_CRITICAL_LOW;
-       } else if (new_bat_capacity <= battery_info.warning) {
-               new_bat_state = battery_info.warning;
-               if (vconf_state != VCONFKEY_SYSMAN_BAT_WARNING_LOW)
-                       status = VCONFKEY_SYSMAN_BAT_WARNING_LOW;
-       } else {
-               new_bat_state = battery_info.normal;
-               if (new_bat_capacity == BATTERY_FULL) {
-                       if (battery.charge_full) {
-                               if (vconf_state != VCONFKEY_SYSMAN_BAT_FULL)
-                                       status = VCONFKEY_SYSMAN_BAT_FULL;
-                       } else {
-                               if (vconf_state != VCONFKEY_SYSMAN_BAT_NORMAL)
-                                       status = VCONFKEY_SYSMAN_BAT_NORMAL;
-                       }
-               } else {
-                       if (vconf_state != VCONFKEY_SYSMAN_BAT_NORMAL)
-                               status = VCONFKEY_SYSMAN_BAT_NORMAL;
-               }
-       }
-
-       if (status != -1) {
-               lock = pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0);
-               ret = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, status);
-               power_supply_broadcast(CHARGE_LEVEL_SIGNAL, status);
-               if (update_pm_setting)
-                       update_pm_setting(SETTING_LOW_BATT, status);
-       }
-
-       if (ret < 0) {
-               result = -EIO;
-               goto exit;
-       }
-
-       if (new_bat_capacity <= battery_info.warning)
-               low_bat = true;
-
-       device_notify(DEVICE_NOTIFIER_LOWBAT, (void *)low_bat);
-
-       if (battery.online == POWER_SUPPLY_TYPE_UNKNOWN)
-               goto exit;
-       if (cur_bat_state == new_bat_state &&
-           online == battery.online)
-               goto exit;
-       online = battery.online;
-       if (cur_bat_state == BATTERY_UNKNOWN)
-               cur_bat_state = battery_info.normal;
-       result = lowbat_scenario(cur_bat_state, new_bat_state, NULL);
-       if (result)
-               _I("cur %d, new %d(capacity %d)",
-               cur_bat_state, new_bat_state, bat_percent);
-       cur_bat_state = new_bat_state;
-exit:
-       if (lock == 0)
-               pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN);
-
-       return result;
-}
-
-static int check_lowbat_percent(int *pct)
-{
-       int bat_percent;
-
-       bat_percent = battery.capacity;
-       if (bat_percent < 0) {
-               _E("[BATMON] Cannot read battery gage. stop read fuel gage");
-               return -ENODEV;
-       }
-       if (bat_percent > 100)
-               bat_percent = 100;
-       change_lowbat_level(bat_percent);
-       battery_level_send_system_event(bat_percent);
-       *pct = bat_percent;
-       return 0;
-}
-
-static void lowbat_monitor(void *data)
-{
-       int bat_percent, r;
-
-       r = lowbat_initialized(NULL);
-       if (!r)
-               return;
-
-       if (data == NULL) {
-               r = check_lowbat_percent(&bat_percent);
-               if (r < 0)
-                       return;
-       } else
-               bat_percent = *(int *)data;
-       print_lowbat_state(bat_percent);
-       lowbat_process(bat_percent, NULL);
-}
-
-static int lowbat_monitor_init(void *data)
-{
-       int status = 1;
-
-       lowbat_initialized(&status);
-
-       /* it's called just this once. */
-       unregister_notifier(DEVICE_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init);
-
-       /* load battery configuration file */
-       battery_config_load(&battery_info);
-       _I("battery conf %d %d %d %d %d", battery_info.normal, battery_info.warning,
-               battery_info.critical, battery_info.poweroff, battery_info.realoff);
-
-       lowbat_scenario_init();
-       check_lowbat_percent(&battery.capacity);
-       lowbat_process(battery.capacity, NULL);
-       return 0;
-}
-
-static void lowbat_init(void *data)
-{
-       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-       register_notifier(DEVICE_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init);
-}
-
-static void lowbat_exit(void *data)
-{
-       int status = 0;
-
-       lowbat_initialized(&status);
-       unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-}
-
-static int lowbat_execute(void *data)
-{
-       lowbat_monitor(data);
-       return 0;
-}
-
-static const struct device_ops lowbat_device_ops = {
-       .name     = "lowbat",
-       .init     = lowbat_init,
-       .execute  = lowbat_execute,
-       .exit     = lowbat_exit,
-};
-
-DEVICE_OPS_REGISTER(&lowbat_device_ops)
diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c
deleted file mode 100644 (file)
index bd98f9a..0000000
+++ /dev/null
@@ -1,1292 +0,0 @@
-/*
- * 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 <stdbool.h>
-#include <vconf.h>
-#include <Ecore.h>
-#include <device-node.h>
-#include <bundle.h>
-#include <eventsystem.h>
-#include <hw/battery.h>
-
-#include "core/devices.h"
-#include "core/device-notifier.h"
-#include "core/udev.h"
-#include "core/log.h"
-#include "core/config-parser.h"
-#include "display/poll.h"
-#include "display/setting.h"
-#include "apps/apps.h"
-#include "power-supply.h"
-#include "battery.h"
-
-#define BATTERY_NAME        "battery"
-#define CHARGEFULL_NAME     "Full"
-#define CHARGENOW_NAME      "Charging"
-#define DISCHARGE_NAME      "Discharging"
-#define NOTCHARGE_NAME      "Not charging"
-#define OVERHEAT_NAME       "Overheat"
-#define TEMPCOLD_NAME       "Cold"
-#define OVERVOLT_NAME       "Over voltage"
-
-#define BUFF_MAX            255
-
-#define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse"
-#define SIGNAL_TEMP_GOOD          "TempGood"
-
-#define ABNORMAL_CHECK_TIMER_INTERVAL 60
-
-#define METHOD_FULL_NOTI_ON   "BatteryFullNotiOn"
-#define METHOD_FULL_NOTI_OFF  "BatteryFullNotiOff"
-#define METHOD_CHARGE_NOTI_ON "BatteryChargeNotiOn"
-
-#define RETRY_MAX 5
-#define BATTERY_CHECK_TIMER_INTERVAL (0.5)
-
-enum power_supply_init_type {
-       POWER_SUPPLY_NOT_READY   = 0,
-       POWER_SUPPLY_INITIALIZED = 1,
-};
-
-static void uevent_power_handler(struct udev_device *dev);
-static const struct uevent_handler uh = {
-       .subsystem   = POWER_SUBSYSTEM,
-       .uevent_func = uevent_power_handler,
-};
-
-struct battery_status battery;
-static int noti_id;
-static Ecore_Timer *power_timer;
-static Ecore_Timer *abnormal_timer;
-
-static int booting_done(void *data);
-
-static struct battery_device *battery_dev;
-
-static void lowbat_execute(void *data)
-{
-       static const struct device_ops *lowbat_ops;
-
-       FIND_DEVICE_VOID(lowbat_ops, "lowbat");
-       device_execute(lowbat_ops, data);
-}
-
-static void pm_check_and_change(int bInserted)
-{
-       static int old = -1;
-
-       if (old == bInserted)
-               return;
-       old = bInserted;
-       pm_change_internal(getpid(), LCD_NORMAL);
-}
-
-static int changed_battery_cf(enum present_type status)
-{
-       char *value;
-
-       if (status == PRESENT_ABNORMAL)
-               value = "battdisconnect";
-       else
-               value = "remove_battery_popups";
-
-       return launch_system_app(APP_DEFAULT,
-                       2, APP_KEY_TYPE, value);
-}
-
-static void abnormal_popup_timer_init(void)
-{
-       if (abnormal_timer == NULL)
-               return;
-       ecore_timer_del(abnormal_timer);
-       abnormal_timer = NULL;
-       _I("delete health timer");
-}
-
-static void health_status_broadcast(void)
-{
-       broadcast_edbus_signal(DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
-           SIGNAL_TEMP_GOOD, NULL, NULL);
-}
-
-
-static void health_timer_reset(void)
-{
-       abnormal_timer = NULL;
-}
-
-static Eina_Bool health_timer_cb(void *data)
-{
-       health_timer_reset();
-
-       if (battery.health == HEALTH_GOOD)
-               return EINA_FALSE;
-
-       _I("popup - Battery health status is not good");
-       device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)HEALTH_BAD);
-       pm_change_internal(getpid(), LCD_NORMAL);
-       pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
-       if (battery.temp == TEMP_LOW)
-               battery_charge_err_low_act(NULL);
-       else if (battery.temp == TEMP_HIGH)
-               battery_charge_err_high_act(NULL);
-       return EINA_FALSE;
-}
-
-static void abnormal_popup_edbus_signal_handler(void *data, DBusMessage *msg)
-{
-       if (battery.health == HEALTH_GOOD)
-               return;
-       _I("restart health timer");
-       abnormal_timer = ecore_timer_add(ABNORMAL_CHECK_TIMER_INTERVAL,
-                                               health_timer_cb, NULL);
-       if (abnormal_timer == NULL)
-               _E("Fail to add abnormal check timer");
-}
-
-static void full_noti_cb(void *data, DBusMessage *msg, DBusError *err)
-{
-       DBusError r_err;
-       int ret, id;
-
-       if (!msg)
-               return;
-
-       dbus_error_init(&r_err);
-       ret = dbus_message_get_args(msg, &r_err, DBUS_TYPE_INT32, &id, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message [%s:%s]", r_err.name, r_err.message);
-               dbus_error_free(&r_err);
-               return;
-       }
-
-       noti_id = id;
-       _D("Inserted battery full noti : %d", noti_id);
-}
-
-static int check_power_supply_noti(void)
-{
-#ifdef MICRO_DD
-       int r_disturb, s_disturb, r_block, s_block;
-       r_disturb = vconf_get_int("memory/shealth/sleep/do_not_disturb", &s_disturb);
-       r_block = vconf_get_bool("db/setting/blockmode_wearable", &s_block);
-       if ((r_disturb != 0 && r_block != 0) ||
-           (s_disturb == 0 && s_block == 0)) {
-           return 1;
-       }
-       return 0;
-#else
-       return 1;
-#endif
-}
-
-static int send_full_noti(enum charge_full_type state)
-{
-       int ret = 0;
-       int noti;
-       int retry;
-       char str_id[32];
-       char *arr[1];
-
-       noti = check_power_supply_noti();
-
-       if (!noti)
-               return noti;
-
-       switch (state) {
-       case CHARGING_FULL:
-               for (retry = RETRY_MAX; retry > 0; retry--) {
-                       ret = dbus_method_async_with_reply(POPUP_BUS_NAME,
-                                       POPUP_PATH_NOTI,
-                                       POPUP_INTERFACE_NOTI,
-                                       METHOD_FULL_NOTI_ON,
-                                       NULL, NULL, full_noti_cb, -1, NULL);
-                       if (ret == 0) {
-                               _D("Created battery full noti");
-                               return ret;
-                       }
-               }
-               _E("Failed to call dbus method (err: %d)", ret);
-       break;
-       case CHARGING_NOT_FULL:
-               if (noti_id <= 0)
-                       return -EPERM;
-               snprintf(str_id, sizeof(str_id), "%d", noti_id);
-               arr[0] = str_id;
-               for (retry = RETRY_MAX; retry > 0; retry--) {
-                       ret = dbus_method_async(POPUP_BUS_NAME,
-                                       POPUP_PATH_NOTI,
-                                       POPUP_INTERFACE_NOTI,
-                                       METHOD_FULL_NOTI_OFF,
-                                       "i", arr);
-                       if (ret == 0) {
-                               _D("Deleted battery full noti");
-                               noti_id = 0;
-                               return ret;
-                       }
-               }
-               _E("Failed to call dbus method (err: %d)", ret);
-       break;
-       }
-       return ret;
-}
-
-static int send_charge_noti(void)
-{
-       int ret = 0;
-       int retry;
-
-       for (retry = RETRY_MAX; retry > 0; retry--) {
-               ret = dbus_method_async(POPUP_BUS_NAME,
-                               POPUP_PATH_NOTI,
-                               POPUP_INTERFACE_NOTI,
-                               METHOD_CHARGE_NOTI_ON,
-                               NULL, NULL);
-               if (ret == 0) {
-                       _D("Created battery charge noti");
-                       return ret;
-               }
-       }
-       _E("Failed to call dbus method (err: %d)", ret);
-       return ret;
-}
-
-static void power_supply_noti(enum battery_noti_type type, enum battery_noti_status status)
-{
-       static int charger = CHARGER_DISCHARGING;
-       static int full = CHARGING_NOT_FULL;
-       int ret;
-
-       if (type == DEVICE_NOTI_BATT_CHARGE) {
-               if (status == DEVICE_NOTI_ON && charger == CHARGER_DISCHARGING) {
-                       send_charge_noti();
-                       charger = CHARGER_CHARGING;
-               } else if (status == DEVICE_NOTI_OFF && charger == CHARGER_CHARGING) {
-                       charger = CHARGER_DISCHARGING;
-               }
-       } else if (type == DEVICE_NOTI_BATT_FULL) {
-               if (status == DEVICE_NOTI_ON && full == CHARGING_NOT_FULL) {
-                       ret = send_full_noti(CHARGING_FULL);
-                       if (ret == 0)
-                               full = CHARGING_FULL;
-               } else if (status == DEVICE_NOTI_OFF && full == CHARGING_FULL) {
-                       ret = send_full_noti(CHARGING_NOT_FULL);
-                       if (ret == 0)
-                               full = CHARGING_NOT_FULL;
-               }
-       }
-}
-
-void power_supply_broadcast(char *sig, int status)
-{
-       static int old;
-       static char sig_old[32];
-       char *arr[1];
-       char str_status[32];
-
-       if (strcmp(sig_old, sig) == 0 && old == status)
-               return;
-
-       _D("%s %d", sig, status);
-
-       old = status;
-       snprintf(sig_old, sizeof(sig_old), "%s", sig);
-       snprintf(str_status, sizeof(str_status), "%d", status);
-       arr[0] = str_status;
-
-       broadcast_edbus_signal(DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
-                       sig, "i", arr);
-}
-
-static void noti_batt_full(void)
-{
-       static int bat_full_noti;
-       int noti;
-
-       if (!battery.charge_full && bat_full_noti == 1) {
-               power_supply_noti(DEVICE_NOTI_BATT_FULL, DEVICE_NOTI_OFF);
-               bat_full_noti = 0;
-               /* off the full charge state */
-               device_notify(DEVICE_NOTIFIER_FULLBAT, (void *)false);
-       }
-       if (battery.charge_full && bat_full_noti == 0) {
-               power_supply_noti(DEVICE_NOTI_BATT_FULL, DEVICE_NOTI_ON);
-               bat_full_noti = 1;
-               /* turn on LCD, if battery is full charged */
-               noti = check_power_supply_noti();
-               if (noti)
-                       pm_change_internal(INTERNAL_LOCK_BATTERY_FULL,
-                               LCD_NORMAL);
-               else
-                       _I("block LCD");
-               /* on the full charge state */
-               device_notify(DEVICE_NOTIFIER_FULLBAT, (void *)true);
-       }
-}
-
-static void check_power_supply(int state)
-{
-       pm_check_and_change(state);
-       if (update_pm_setting)
-               update_pm_setting(SETTING_CHARGING, state);
-}
-
-static void charger_state_send_system_event(int state)
-{
-       bundle *b;
-       const char *str;
-
-       switch (state) {
-       case CHARGE_STATUS_CHARGING:
-               str = EVT_VAL_BATTERY_CHARGER_CHARGING;
-               break;
-       case CHARGE_STATUS_FULL:
-       case CHARGE_STATUS_DISCHARGING:
-               str = EVT_VAL_BATTERY_CHARGER_DISCHARGING;
-               break;
-       case CHARGE_STATUS_CONNECTED:
-               str = EVT_VAL_BATTERY_CHARGER_CONNECTED;
-               break;
-       case CHARGE_STATUS_DISCONNECTED:
-               str = EVT_VAL_BATTERY_CHARGER_DISCONNECTED;
-               break;
-       default:
-               _E("invalid parameter(%d)", state);
-               return;
-       }
-
-       _D("system_event(%s)", str);
-
-       b = bundle_create();
-       bundle_add_str(b, EVT_KEY_BATTERY_CHARGER_STATUS, str);
-       eventsystem_send_system_event(SYS_EVENT_BATTERY_CHARGER_STATUS, b);
-       bundle_free(b);
-}
-
-static void update_present(enum battery_noti_status status)
-{
-       static int old = DEVICE_NOTI_OFF;
-       enum present_type present;
-
-       if (old == status)
-               return;
-       _I("charge %d present %d", battery.charge_now, battery.present);
-       old = status;
-       pm_change_internal(getpid(), LCD_NORMAL);
-       if (status == DEVICE_NOTI_ON) {
-               present = PRESENT_ABNORMAL;
-               device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)PRESENT_ABNORMAL);
-               pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
-       } else {
-               present = PRESENT_NORMAL;
-               device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)PRESENT_NORMAL);
-               pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
-       }
-       changed_battery_cf(present);
-}
-
-static void update_health(enum battery_noti_status status)
-{
-       static int old = DEVICE_NOTI_OFF;
-
-       if (old == status)
-               return;
-       _I("charge %d health %d", battery.charge_now, battery.health);
-       old = status;
-
-       pm_change_internal(getpid(), LCD_NORMAL);
-       if (status == DEVICE_NOTI_ON) {
-               _I("popup - Battery health status is not good");
-               device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)HEALTH_BAD);
-               pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
-               if (battery.temp == TEMP_LOW)
-                       battery_charge_err_low_act(NULL);
-               else if (battery.temp == TEMP_HIGH)
-                       battery_charge_err_high_act(NULL);
-       } else {
-               device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)HEALTH_GOOD);
-               pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
-               health_status_broadcast();
-               abnormal_popup_timer_init();
-       }
-}
-
-static void update_ovp(enum battery_noti_status status)
-{
-       static int old = DEVICE_NOTI_OFF;
-
-       if (old == status)
-               return;
-       _I("charge %d ovp %d", battery.charge_now, battery.ovp);
-       old = status;
-       pm_change_internal(getpid(), LCD_NORMAL);
-       if (status == DEVICE_NOTI_ON)
-               device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)OVP_ABNORMAL);
-       else
-               device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)OVP_NORMAL);
-}
-
-static void check_battery_status(void)
-{
-       static int old = DEVICE_CHANGE_NORMAL;
-       int status;
-
-       if (battery.charge_now == CHARGER_ABNORMAL &&
-           (battery.health == HEALTH_BAD || battery.present == PRESENT_ABNORMAL))
-               status = DEVICE_CHANGE_ABNORMAL;
-       else if (battery.ovp == OVP_ABNORMAL)
-               status = DEVICE_CHANGE_ABNORMAL;
-       else
-               status = DEVICE_CHANGE_NORMAL;
-       if (old == status)
-               return;
-       old = status;
-
-       if (battery.charge_now == CHARGER_ABNORMAL) {
-               if (battery.health == HEALTH_BAD) {
-                       update_health(DEVICE_NOTI_ON);
-                       return;
-               } else if (battery.present == PRESENT_ABNORMAL) {
-                       update_present(DEVICE_NOTI_ON);
-                       return;
-               }
-       }
-       if (battery.ovp == OVP_ABNORMAL) {
-               update_ovp(DEVICE_NOTI_ON);
-               return;
-       }
-
-       if (battery.charge_now != CHARGER_ABNORMAL &&
-           status == DEVICE_CHANGE_NORMAL) {
-               update_health(DEVICE_NOTI_OFF);
-               update_ovp(DEVICE_NOTI_OFF);
-               update_present(DEVICE_NOTI_OFF);
-       }
-}
-
-static void check_online(void)
-{
-       static int old_online;
-       static int old_charge_status;
-       int charge_status;
-
-       if (battery.charge_status == CHARGE_STATUS_FULL)
-               charge_status = CHARGE_STATUS_DISCHARGING;
-       else
-               charge_status = battery.charge_status;
-
-       if (battery.online > POWER_SUPPLY_TYPE_BATTERY &&
-           old_online == VCONFKEY_SYSMAN_CHARGER_DISCONNECTED) {
-               old_online = VCONFKEY_SYSMAN_CHARGER_CONNECTED;
-               vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS, old_online);
-               power_supply_broadcast(CHARGER_STATUS_SIGNAL, old_online);
-               check_power_supply(old_online);
-               charger_state_send_system_event(CHARGE_STATUS_CONNECTED);
-               if (charge_status != old_charge_status)
-                       charger_state_send_system_event(charge_status);
-
-       } else if (battery.online <= POWER_SUPPLY_TYPE_BATTERY &&
-           old_online == VCONFKEY_SYSMAN_CHARGER_CONNECTED) {
-               old_online = VCONFKEY_SYSMAN_CHARGER_DISCONNECTED;
-               vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS, old_online);
-               power_supply_broadcast(CHARGER_STATUS_SIGNAL, old_online);
-               check_power_supply(old_online);
-               if (charge_status != old_charge_status)
-                       charger_state_send_system_event(charge_status);
-               charger_state_send_system_event(CHARGE_STATUS_DISCONNECTED);
-
-       } else {
-               if (charge_status != old_charge_status)
-                       charger_state_send_system_event(charge_status);
-       }
-
-       old_charge_status = charge_status;
-}
-
-static void check_charge_status(const char *env_value)
-{
-       if (env_value == NULL)
-               return;
-
-       _D("Charge Status(%s)", env_value);
-
-       if (strncmp(env_value, CHARGEFULL_NAME,
-                               sizeof(CHARGEFULL_NAME)) == 0)
-               battery.charge_status = CHARGE_STATUS_FULL;
-       else if (strncmp(env_value, CHARGENOW_NAME,
-                               sizeof(CHARGENOW_NAME)) == 0)
-               battery.charge_status = CHARGE_STATUS_CHARGING;
-       else if (strncmp(env_value, DISCHARGE_NAME,
-                               sizeof(DISCHARGE_NAME)) == 0)
-               battery.charge_status = CHARGE_STATUS_DISCHARGING;
-       else if (strncmp(env_value, NOTCHARGE_NAME,
-                               sizeof(NOTCHARGE_NAME)) == 0)
-               battery.charge_status = CHARGE_STATUS_NOT_CHARGING;
-       else
-               battery.charge_status = CHARGE_STATUS_UNKNOWN;
-
-       if (battery.charge_status == CHARGE_STATUS_FULL) {
-               battery.charge_full = CHARGING_FULL;
-               battery.charge_now = CHARGER_DISCHARGING;
-       } else if (battery.charge_status == CHARGE_STATUS_CHARGING) {
-               battery.charge_full = CHARGING_NOT_FULL;
-               battery.charge_now = CHARGER_CHARGING;
-       } else if (battery.charge_status == CHARGE_STATUS_DISCHARGING) {
-               battery.charge_full = CHARGING_NOT_FULL;
-               battery.charge_now = CHARGER_DISCHARGING;
-       } else if (battery.charge_status == CHARGE_STATUS_NOT_CHARGING) {
-               battery.charge_full = CHARGING_NOT_FULL;
-               battery.charge_now = CHARGER_ABNORMAL;
-       } else {
-               battery.charge_full = CHARGING_NOT_FULL;
-               battery.charge_now = CHARGER_DISCHARGING;
-       }
-}
-
-static void check_health_status(const char *env_value)
-{
-       if (env_value == NULL) {
-               battery.health = HEALTH_GOOD;
-               battery.temp = TEMP_LOW;
-               battery.ovp = OVP_NORMAL;
-               return;
-       }
-       if (strncmp(env_value, OVERHEAT_NAME,
-                               sizeof(OVERHEAT_NAME)) == 0) {
-               battery.health = HEALTH_BAD;
-               battery.temp = TEMP_HIGH;
-               battery.ovp = OVP_NORMAL;
-       } else if (strncmp(env_value, TEMPCOLD_NAME,
-                               sizeof(TEMPCOLD_NAME)) == 0) {
-               battery.health = HEALTH_BAD;
-               battery.temp = TEMP_LOW;
-               battery.ovp = OVP_NORMAL;
-       } else if (strncmp(env_value, OVERVOLT_NAME,
-                               sizeof(OVERVOLT_NAME)) == 0) {
-               battery.health = HEALTH_GOOD;
-               battery.temp = TEMP_LOW;
-               battery.ovp = OVP_ABNORMAL;
-       } else {
-               battery.health = HEALTH_GOOD;
-               battery.temp = TEMP_LOW;
-               battery.ovp = OVP_NORMAL;
-       }
-}
-
-static void check_online_status(const char *env_value)
-{
-       if (env_value == NULL)
-               return;
-       battery.online = atoi(env_value);
-}
-
-static void check_present_status(const char *env_value)
-{
-       if (env_value == NULL) {
-               battery.present = PRESENT_NORMAL;
-               return;
-       }
-       battery.present = atoi(env_value);
-}
-
-static void check_capacity_status(const char *env_value)
-{
-       if (env_value == NULL)
-               return;
-       battery.capacity = atoi(env_value);
-}
-
-static void process_power_supply(void *data)
-{
-       static struct battery_status old;
-
-       if (old.charge_now != battery.charge_now || battery.charge_now == CHARGER_ABNORMAL) {
-               vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, battery.charge_now);
-               power_supply_broadcast(CHARGE_NOW_SIGNAL, battery.charge_now);
-       }
-
-       lowbat_execute(data);
-       check_online();
-       if (old.charge_full != battery.charge_full)
-               noti_batt_full();
-
-       old.capacity = battery.capacity;
-       old.online = battery.online;
-       old.charge_status = battery.charge_status;
-       old.charge_now = battery.charge_now;
-       old.charge_full = battery.charge_full;
-
-       check_battery_status();
-       device_notify(DEVICE_NOTIFIER_POWER_SUPPLY, NULL);
-       device_notify(DEVICE_NOTIFIER_BATTERY_CHARGING, &battery.charge_now);
-}
-
-static void uevent_power_handler(struct udev_device *dev)
-{
-       struct udev_list_entry *list_entry;
-       const char *env_name;
-       const char *env_value;
-       bool matched = false;
-       int ret;
-
-       udev_list_entry_foreach(list_entry,
-                       udev_device_get_properties_list_entry(dev)) {
-               env_name = udev_list_entry_get_name(list_entry);
-               if (!env_name)
-                       continue;
-
-               if (!strncmp(env_name, CHARGE_NAME, sizeof(CHARGE_NAME))) {
-                       env_value = udev_list_entry_get_value(list_entry);
-                       if (!env_value)
-                               continue;
-                       if (!strncmp(env_value, BATTERY_NAME,
-                                               sizeof(BATTERY_NAME))) {
-                               matched = true;
-                               break;
-                       }
-               }
-       }
-
-       if (!matched)
-               return;
-
-       env_value = udev_device_get_property_value(dev, CHARGE_STATUS);
-       check_charge_status(env_value);
-       env_value = udev_device_get_property_value(dev, CHARGE_ONLINE);
-       check_online_status(env_value);
-       env_value = udev_device_get_property_value(dev, CHARGE_HEALTH);
-       check_health_status(env_value);
-       env_value = udev_device_get_property_value(dev, CHARGE_PRESENT);
-       check_present_status(env_value);
-       env_value = udev_device_get_property_value(dev, CAPACITY);
-       check_capacity_status(env_value);
-
-       ret = booting_done(NULL);
-       if (ret) {
-               if (battery.online > POWER_SUPPLY_TYPE_BATTERY)
-                       power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_ON);
-               else
-                       power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_OFF);
-       }
-
-       process_power_supply(&battery.capacity);
-}
-
-static void battery_state(struct battery_info *info)
-{
-       if (!info)
-               return;
-
-       _I("%s(%s) %s(%d) Capa(%d) Hth(%s,%s) Pres(%d) OVP(%s) Curr(%d,%d)",
-                       info->status,
-                       battery.charge_now == CHARGER_CHARGING ? "Charging"
-                               : (battery.charge_now == CHARGER_DISCHARGING ? "Discharging" : "Abnormal"),
-                       info->power_source,
-                       info->online,
-                       info->capacity,
-                       info->health,
-                       battery.temp == TEMP_LOW ? "Low" : "High",
-                       info->present,
-                       battery.ovp == OVP_NORMAL ? "X" : "O",
-                       info->current_now,
-                       info->current_average);
-}
-
-static void battery_changed(struct battery_info *info, void *data)
-{
-       int ret;
-
-       if (!info)
-               return;
-
-       if (info->status) {
-               snprintf(battery.status_s, sizeof(battery.status_s),
-                               "%s", info->status);
-               check_charge_status(info->status);
-       } else
-               battery.status_s[0] = '\0';
-
-       if (info->health) {
-               snprintf(battery.health_s, sizeof(battery.health_s),
-                               "%s", info->health);
-               check_health_status(info->health);
-       } else
-               battery.health_s[0] = '\0';
-
-       if (info->power_source)
-               snprintf(battery.power_source_s, sizeof(battery.power_source_s),
-                               "%s", info->power_source);
-       else
-               battery.power_source_s[0] = '\0';
-
-       battery.online = info->online;
-       battery.present = info->present;
-       battery.capacity = info->capacity;
-       battery.current_now = info->current_now;
-       battery.current_average = info->current_average;
-
-       battery_state(info);
-
-       ret = booting_done(NULL);
-       if (ret) {
-               if (battery.online > POWER_SUPPLY_TYPE_BATTERY)
-                       power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_ON);
-               else
-                       power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_OFF);
-       }
-
-       process_power_supply(&battery.capacity);
-
-}
-
-static int lowbat_read(int *val)
-{
-       int r;
-
-       if (!val)
-               return -EINVAL;
-
-       r = sys_get_int("/sys/class/power_supply/battery/capacity", val);
-       if (r < 0)
-               return r;
-
-       return 0;
-}
-
-static void battery_get_capacity(struct battery_info *info, void *data)
-{
-       int *capa = data;
-
-       if (info && info->capacity >= 0)
-               *capa = info->capacity;
-}
-
-static void power_supply_status_init(void)
-{
-       static int charge_now = -1;
-       static int charge_full = -1;
-       static int capacity = -1;
-       int pct;
-       int r;
-
-       if (battery_dev && battery_dev->get_current_state) {
-               pct = -1;
-               r = battery_dev->get_current_state(battery_get_capacity, &pct);
-               if (r < 0 || pct < 0) {
-                       _E("Failed to get battery capacity (capa:%d, ret:%d)", pct, r);
-                       return;
-               }
-       } else {
-               r = lowbat_read(&pct);
-               if (r < 0) {
-                       _E("fail to read capacity data : %d", r);
-                       return;
-               }
-       }
-
-       battery.capacity = pct;
-       battery.health = HEALTH_GOOD;
-       battery.ovp = OVP_NORMAL;
-       battery.present = PRESENT_NORMAL;
-       battery.temp = TEMP_LOW;
-
-       if (charge_now == battery.charge_now &&
-           charge_full == battery.charge_full &&
-           capacity == battery.capacity)
-               return;
-
-       _I("charging %d full %d capacity %d", battery.charge_now, battery.charge_full, battery.capacity);
-
-       if (charge_now != battery.charge_now) {
-               vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, battery.charge_now);
-               power_supply_broadcast(CHARGE_NOW_SIGNAL, battery.charge_now);
-       }
-       if (capacity != battery.capacity) {
-               vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, battery.capacity);
-               power_supply_broadcast(CHARGE_CAPACITY_SIGNAL, battery.capacity);
-       }
-
-       charge_now = battery.charge_now;
-       charge_full = battery.charge_full;
-       capacity =  battery.capacity;
-}
-
-static Eina_Bool power_supply_update(void *data)
-{
-       power_supply_status_init();
-       return EINA_TRUE;
-}
-
-static void power_supply_timer_start(void)
-{
-       _D("battery init timer during booting");
-       power_timer = ecore_timer_add(BATTERY_CHECK_TIMER_INTERVAL,
-                               power_supply_update, NULL);
-       if (power_timer == NULL)
-               _E("fail to add battery init timer during booting");
-}
-
-static void power_supply_timer_stop(void)
-{
-       _D("battery init timer during booting");
-       if (!power_timer)
-               return;
-       ecore_timer_del(power_timer);
-       power_timer = NULL;
-}
-
-static DBusMessage *dbus_get_charger_status(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       if (vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS, &ret) < 0) {
-               _E("vconf_get_int() failed");
-               ret = -EIO;
-       }
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *dbus_get_charge_now(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = battery.charge_now;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *dbus_get_charge_level(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &ret) < 0) {
-               _E("vconf_get_int() failed");
-               ret = -EIO;
-       }
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *dbus_get_percent(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = battery.capacity;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *dbus_get_percent_raw(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = -ENOTSUP;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *dbus_is_full(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = battery.charge_full;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *dbus_get_health(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = battery.health;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *dbus_power_supply_handler(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusError err;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       pid_t pid;
-       int ret = 0;
-       int argc;
-       char *type_str;
-       char *argv[5];
-
-       dbus_error_init(&err);
-
-       if (!dbus_message_get_args(msg, &err,
-                   DBUS_TYPE_STRING, &type_str,
-                   DBUS_TYPE_INT32, &argc,
-                   DBUS_TYPE_STRING, &argv[0],
-                   DBUS_TYPE_STRING, &argv[1],
-                   DBUS_TYPE_STRING, &argv[2],
-                   DBUS_TYPE_STRING, &argv[3],
-                   DBUS_TYPE_STRING, &argv[4], DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (argc < 0) {
-               _E("message is invalid!");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       pid = get_edbus_sender_pid(msg);
-       if (kill(pid, 0) == -1) {
-               _E("%d process does not exist, dbus ignored!", pid);
-               ret = -ESRCH;
-               goto out;
-       }
-       check_capacity_status(argv[0]);
-       check_charge_status(argv[1]);
-       check_health_status(argv[2]);
-       check_online_status(argv[3]);
-       check_present_status(argv[4]);
-       _I("%d %d %d %d %d %d %d %d",
-               battery.capacity,
-               battery.charge_full,
-               battery.charge_now,
-               battery.health,
-               battery.online,
-               battery.ovp,
-               battery.present,
-               battery.temp);
-
-       if (battery.online > POWER_SUPPLY_TYPE_BATTERY)
-               power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_ON);
-       else
-               power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_OFF);
-
-       process_power_supply(&battery.capacity);
-out:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static void battery_get_info(struct battery_info *info, void *data)
-{
-       struct battery_info *bat = data;
-
-       if (!info || !bat)
-               return;
-
-       bat->status = strdup(info->status);
-       bat->health = strdup(info->health);
-       bat->power_source = strdup(info->power_source);
-       bat->online = info->online;
-       bat->present = info->present;
-       bat->capacity = info->capacity;
-       bat->current_now = info->current_now;
-       bat->current_average = info->current_average;
-}
-
-static DBusMessage *dbus_get_battery_info(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret, val;
-       const char *str;
-       struct battery_info info = { 0, };
-
-       if (battery_dev && battery_dev->get_current_state) {
-               ret = battery_dev->get_current_state(battery_get_info, &info);
-               if (ret < 0)
-                       _E("Failed to get battery info (%d)", ret);
-
-               battery_changed(&info, NULL);
-               free(info.status);
-               free(info.health);
-               free(info.power_source);
-       } else {
-               if (battery.charge_status == CHARGE_STATUS_FULL)
-                       str = CHARGEFULL_NAME;
-               else if (battery.charge_status == CHARGE_STATUS_CHARGING)
-                       str = CHARGENOW_NAME;
-               else if (battery.charge_status == CHARGE_STATUS_DISCHARGING)
-                       str = DISCHARGE_NAME;
-               else if (battery.charge_status == CHARGE_STATUS_NOT_CHARGING)
-                       str = NOTCHARGE_NAME;
-               else
-                       str = "Unknown";
-               snprintf(battery.status_s, sizeof(battery.status_s), "%s", str);
-
-               if (battery.health == HEALTH_GOOD) {
-                       if (battery.temp == TEMP_LOW && battery.ovp == OVP_ABNORMAL)
-                               str = OVERVOLT_NAME;
-                       else
-                               str = "Good";
-               } else { /* HEALTH_BAD */
-                       if (battery.temp == TEMP_HIGH)
-                               str = OVERHEAT_NAME;
-                       else /* TEMP_LOW */
-                               str = TEMPCOLD_NAME;
-               }
-               snprintf(battery.health_s, sizeof(battery.health_s), "%s", str);
-
-               if (vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS, &val) == 0 &&
-                       val != VCONFKEY_SYSMAN_USB_DISCONNECTED)
-                       str = POWER_SOURCE_USB;
-               else if (vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS, &val) == 0 &&
-                       val == VCONFKEY_SYSMAN_CHARGER_CONNECTED)
-                       str = POWER_SOURCE_AC;
-               else
-                       str = POWER_SOURCE_NONE;
-               snprintf(battery.power_source_s, sizeof(battery.power_source_s), "%s", str);
-
-               battery.current_now = -1; /* Not supported */
-               battery.current_average = -1; /* Not supported */
-               ret = 0;
-       }
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       str = battery.status_s;
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &str);
-       str = battery.health_s;
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &str);
-       str = battery.power_source_s;
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &str);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &(battery.online));
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &(battery.present));
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &(battery.capacity));
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &(battery.current_now));
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &(battery.current_average));
-       return reply;
-}
-
-static const struct edbus_method edbus_methods[] = {
-       { CHARGER_STATUS_SIGNAL,      NULL, "i", dbus_get_charger_status },
-       { CHARGE_NOW_SIGNAL,          NULL, "i", dbus_get_charge_now },
-       { CHARGE_LEVEL_SIGNAL,        NULL, "i", dbus_get_charge_level },
-       { CHARGE_CAPACITY_SIGNAL,     NULL, "i", dbus_get_percent },
-       { CHARGE_CAPACITY_LAW_SIGNAL, NULL, "i", dbus_get_percent_raw },
-       { CHARGE_FULL_SIGNAL,         NULL, "i", dbus_is_full },
-       { CHARGE_HEALTH_SIGNAL,       NULL, "i", dbus_get_health },
-       { POWER_SUBSYSTEM,       "sisssss", "i", dbus_power_supply_handler },
-       { "GetBatteryInfo",           NULL, "isssiiiii", dbus_get_battery_info },
-};
-
-static int booting_done(void *data)
-{
-       static int done;
-
-       if (data == NULL)
-               return done;
-       done = *(int *)data;
-       if (done == 0)
-               return done;
-
-       _I("booting done");
-
-       power_supply_timer_stop();
-
-       /* for simple noti change cb */
-       power_supply_status_init();
-       process_power_supply(NULL);
-
-       return done;
-}
-
-static int display_changed(void *data)
-{
-       if (battery.charge_now != CHARGER_ABNORMAL)
-               return 0;
-       if (battery.health != HEALTH_BAD && battery.present != PRESENT_ABNORMAL)
-               return 0;
-       pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
-       return 0;
-}
-
-static int load_uevent(struct parse_result *result, void *user_data)
-{
-       struct battery_status *info = user_data;
-
-       if (!info)
-               return -EINVAL;
-
-       if (MATCH(result->name, CHARGE_STATUS)) {
-               if (strstr(result->value, "Charging")) {
-                       info->charge_now = CHARGER_CHARGING;
-                       info->charge_full = CHARGING_NOT_FULL;
-               } else if (strstr(result->value, "Discharging")) {
-                       info->charge_now = CHARGER_DISCHARGING;
-                       info->charge_full = CHARGING_NOT_FULL;
-               } else if (strstr(result->value, "Full")) {
-                       info->charge_now = CHARGER_DISCHARGING;
-                       info->charge_full = CHARGING_FULL;
-               } else if (strstr(result->value, "Not charging")) {
-                       info->charge_now = CHARGER_ABNORMAL;
-                       info->charge_full = CHARGING_NOT_FULL;
-               }
-               snprintf(info->status_s, sizeof(info->status_s), "%s", result->value);
-       } else if (MATCH(result->name, CAPACITY))
-               info->capacity = atoi(result->value);
-       else if (MATCH(result->name, CHARGE_HEALTH))
-               snprintf(info->health_s, sizeof(info->health_s), "%s", result->value);
-       return 0;
-}
-
-static int power_supply_probe(void *data)
-{
-       struct hw_info *info;
-       int ret;
-
-       if (battery_dev)
-               return 0;
-
-       ret = hw_get_info(BATTERY_HARDWARE_DEVICE_ID,
-                       (const struct hw_info **)&info);
-
-       if (ret < 0) { /* There is no HAL for battery */
-               if (access(POWER_PATH, R_OK) == 0)
-                       return 0; /* Just power_supply uevent is used */
-               goto out;
-       }
-
-       if (!info->open) {
-               _E("Failed to open battery device; open(NULL)");
-               return -ENODEV;
-       }
-
-       ret = info->open(info, NULL, (struct hw_common**)&battery_dev);
-       if (ret < 0) {
-               _E("Failed to get battery device structure (%d)", ret);
-               return ret;
-       }
-
-       if (!battery_dev || !battery_dev->get_current_state) {
-               _E("get_current_state() is not supported by the Battery HAL");
-               return -ENODEV;
-       }
-
-       _I("battery device structure load success");
-       return 0;
-
-out:
-       /**
-        * Set battery vconf as -ENOTSUP
-        * These vconf key used by runtime-info and capi-system-device.
-        */
-       vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS, -ENOTSUP);
-       vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, -ENOTSUP);
-       vconf_set_int(VCONFKEY_SYSMAN_BATTERY_LEVEL_STATUS, -ENOTSUP);
-       _I("There is no battery device(%d)", ret);
-       return -ENODEV;
-}
-
-static void power_supply_init(void *data)
-{
-       int ret;
-
-       if (battery_dev) {
-               if (battery_dev->register_changed_event)
-                       battery_dev->register_changed_event(battery_changed, NULL);
-
-               if (battery_dev->get_current_state)
-                       battery_dev->get_current_state(battery_changed, NULL);
-       } else {
-               ret = config_parse(POWER_SUPPLY_UEVENT, load_uevent, &battery);
-               if (ret < 0)
-                       _E("Failed to load %s, %d Use default value!",
-                                       POWER_SUPPLY_UEVENT, ret);
-
-               /* register power subsystem */
-               register_kernel_uevent_control(&uh);
-       }
-
-       /* process check battery timer until booting done */
-       power_supply_timer_start();
-
-       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-       register_notifier(DEVICE_NOTIFIER_LCD, display_changed);
-
-       ret = register_edbus_interface_and_method(DEVICED_PATH_BATTERY,
-                       DEVICED_INTERFACE_BATTERY,
-                       edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0)
-               _E("fail to init edbus interface and method(%d)", ret);
-
-       ret = register_edbus_signal_handler(DEVICED_PATH_SYSNOTI,
-                       DEVICED_INTERFACE_SYSNOTI, SIGNAL_CHARGEERR_RESPONSE,
-                       abnormal_popup_edbus_signal_handler);
-       if (ret < 0)
-               _E("fail to init edbus signal(%d)", ret);
-}
-
-static void power_supply_exit(void *data)
-{
-       unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-       unregister_notifier(DEVICE_NOTIFIER_LCD, display_changed);
-
-       /* unregister power subsystem */
-       unregister_kernel_uevent_control(&uh);
-}
-
-static const struct device_ops power_supply_ops = {
-       .name     = "power_supply",
-       .probe    = power_supply_probe,
-       .init     = power_supply_init,
-       .exit     = power_supply_exit,
-};
-
-DEVICE_OPS_REGISTER(&power_supply_ops)
diff --git a/src/battery/power-supply.h b/src/battery/power-supply.h
deleted file mode 100644 (file)
index 24fb949..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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 __POWER_SUPPLY_H__
-#define __POWER_SUPPLY_H__
-
-enum device_change_type {
-       DEVICE_CHANGE_ABNORMAL  = 0,
-       DEVICE_CHANGE_NORMAL    = 1,
-};
-
-enum charge_status_type {
-       CHARGE_STATUS_UNKNOWN,
-       CHARGE_STATUS_DISCONNECTED,
-       CHARGE_STATUS_CONNECTED,
-       CHARGE_STATUS_CHARGING,
-       CHARGE_STATUS_DISCHARGING,
-       CHARGE_STATUS_NOT_CHARGING,
-       CHARGE_STATUS_FULL,
-};
-enum charge_full_type {
-       CHARGING_NOT_FULL       = 0,
-       CHARGING_FULL           = 1,
-};
-enum charge_now_type {
-       CHARGER_ABNORMAL        = -1,
-       CHARGER_DISCHARGING     = 0,
-       CHARGER_CHARGING        = 1,
-};
-enum health_type {
-       HEALTH_BAD              = 0,
-       HEALTH_GOOD             = 1,
-};
-
-enum temp_type {
-       TEMP_LOW                = 0,
-       TEMP_HIGH               = 1,
-};
-
-enum present_type {
-       PRESENT_ABNORMAL        = 0,
-       PRESENT_NORMAL          = 1,
-};
-
-enum ovp_type {
-       OVP_NORMAL              = 0,
-       OVP_ABNORMAL            = 1,
-};
-
-enum battery_noti_type {
-       DEVICE_NOTI_BATT_CHARGE = 0,
-       DEVICE_NOTI_BATT_LOW,
-       DEVICE_NOTI_BATT_FULL,
-       DEVICE_NOTI_MAX,
-};
-
-enum battery_noti_status {
-       DEVICE_NOTI_OFF = 0,
-       DEVICE_NOTI_ON  = 1,
-};
-
-struct battery_status {
-       int capacity;
-       int charge_status;
-       int charge_full;
-       int charge_now;
-       int health;
-       int present;
-       int online;
-       int temp;
-       int ovp;
-       int current_now;
-       int current_average;
-       char status_s[32];
-       char health_s[32];
-       char power_source_s[32];
-};
-
-extern struct battery_status battery;
-
-void power_supply_broadcast(char *sig, int status);
-
-#define CHARGER_STATUS_SIGNAL      "ChargerStatus"
-#define CHARGE_NOW_SIGNAL          "ChargeNow"
-#define CHARGE_LEVEL_SIGNAL        "BatteryStatusLow"
-#define CHARGE_CAPACITY_SIGNAL     "GetPercent"
-#define CHARGE_CAPACITY_LAW_SIGNAL "GetPercentRaw"
-#define CHARGE_HEALTH_SIGNAL       "GetHealth"
-#define CHARGE_FULL_SIGNAL         "IsFull"
-
-#endif /* __POWER_SUPPLY_H__ */
diff --git a/src/ir/ir.c b/src/ir/ir.c
deleted file mode 100644 (file)
index 0921781..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2014-2016 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 <assert.h>
-#include <stdbool.h>
-#include <hw/ir.h>
-#include "core/edbus-handler.h"
-#include "core/devices.h"
-#include "core/common.h"
-#include "core/log.h"
-
-static struct ir_device *ir_dev;
-
-static DBusMessage *edbus_ir_is_available(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       bool val;
-
-       if (!ir_dev) {
-               ret = -ENODEV;
-               goto exit;
-       }
-
-       if (!ir_dev->is_available) {
-               ret = -ENODEV;
-               goto exit;
-       }
-
-       ret = ir_dev->is_available(&val);
-       if (ret >= 0)
-               ret = val;
-
-exit:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_ir_transmit(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       int size;
-       int *freq_pattern;
-
-       if (!ir_dev) {
-               ret = -ENODEV;
-               goto exit;
-       }
-
-       if (!ir_dev->transmit) {
-               ret = -ENODEV;
-               goto exit;
-       }
-
-       if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &freq_pattern, &size,
-                               DBUS_TYPE_INVALID)) {
-               ret = -EINVAL;
-               goto exit;
-       }
-
-       _I("frequency : %d, pattern_size: %d", freq_pattern[0], size);
-
-       ret = ir_dev->transmit(freq_pattern, size);
-
-exit:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_set_ir_command(E_DBus_Object *obj, DBusMessage *msg)
-{
-       int ret = -ENOTSUP;
-
-       _E("The method is not supported. Use device_ir_transmit() of capi-system-device");
-
-       return make_reply_message(msg, ret);
-}
-
-static const struct edbus_method edbus_methods[] = {
-       { "IRIsAvailable", NULL, "i", edbus_ir_is_available},
-       { "TransmitIR", "ai", "i", edbus_ir_transmit},
-};
-
-static const struct edbus_method edbus_methods_legacy[] = {
-       { "SetIrCommand",      "s",   "i", edbus_set_ir_command },
-};
-
-static int ir_probe(void *data)
-{
-       struct hw_info *info;
-       int ret;
-
-       if (ir_dev)
-               return 0;
-
-       ret = hw_get_info(IR_HARDWARE_DEVICE_ID,
-                       (const struct hw_info **)&info);
-
-       if (ret < 0) {
-               _E("Fail to load ir(%d)", ret);
-               return -ENODEV;
-       }
-
-       if (!info->open) {
-               _E("Failed to open ir device; open(NULL)");
-               return -ENODEV;
-       }
-
-       ret = info->open(info, NULL, (struct hw_common**)&ir_dev);
-       if (ret < 0) {
-               _E("Failed to get ir device structure (%d)", ret);
-               return ret;
-       }
-
-       _I("ir device structure load success");
-       return 0;
-}
-
-static void ir_init(void *data)
-{
-       int ret;
-
-       ret = register_edbus_interface_and_method(DEVICED_PATH_IR,
-                       DEVICED_INTERFACE_IR,
-                       edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0)
-               _E("fail to init edbus interface and method(%d)", ret);
-
-       /* Legacy interfaces */
-       ret = register_edbus_interface_and_method(DEVICED_PATH_LED,
-                       DEVICED_INTERFACE_LED,
-                       edbus_methods_legacy, ARRAY_SIZE(edbus_methods_legacy));
-       if (ret < 0)
-               _E("fail to init edbus interfce and method(%d)", ret);
-}
-
-static void ir_exit(void *data)
-{
-       struct hw_info *info;
-
-       if (!ir_dev)
-               return;
-
-       info = ir_dev->common.info;
-       if (!info)
-               free(ir_dev);
-       else
-               info->close((struct hw_common *)ir_dev);
-
-       ir_dev = NULL;
-}
-
-static const struct device_ops ir_device_ops = {
-       .name     = "ir",
-       .probe    = ir_probe,
-       .init     = ir_init,
-       .exit     = ir_exit,
-};
-
-DEVICE_OPS_REGISTER(&ir_device_ops)