From fa5d6c7bd10ba0d75463ccf4a706b6c5d89b919a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Wed, 24 Dec 2014 14:48:39 +0100 Subject: [PATCH 01/16] Fix bugs in managing the system group MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I274bcf8a0b310a264a1a4ea2fed814dbd8b2db10 Signed-off-by: José Bollo --- packaging/deviced.spec | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 25e6dc4..2f85dd6 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -239,7 +239,7 @@ rm -rf %{buildroot} %post #memory type vconf key init -users_gid=$(getent group $TZ_SYS_USER_GROUP | cut -f3 -d':') +users_gid=$(getent group %{TZ_SYS_USER_GROUP} | cut -f3 -d':') vconftool set -t int memory/sysman/usbhost_status -1 -i vconftool set -t int memory/sysman/mmc -1 -i @@ -259,23 +259,23 @@ vconftool set -t int memory/sysman/mmc_unmount -1 -i vconftool set -t int memory/sysman/mmc_format -1 -i vconftool set -t int memory/sysman/mmc_format_progress 0 -i vconftool set -t int memory/sysman/mmc_err_status 0 -i -vconftool set -t int memory/sysman/power_off 0 -g $users_gid -i -f +vconftool set -t int memory/sysman/power_off 0 -g "$users_gid" -i -f vconftool set -t int memory/sysman/battery_level_status -1 -i vconftool set -t string memory/private/sysman/added_storage_uevent "" -i -vconftool set -t string memory/private/sysman/removed_storage_uevent "" -g $users_gid -i +vconftool set -t string memory/private/sysman/removed_storage_uevent "" -g "$users_gid" -i vconftool set -t int memory/sysman/hdmi 0 -i vconftool set -t int memory/sysman/stime_changed 0 -i #db type vconf key init vconftool set -t int db/sysman/mmc_dev_changed 0 -i -vconftool set -t int memory/pm/state 0 -i -g $users_gid +vconftool set -t int memory/pm/state 0 -i -g "$users_gid" vconftool set -t int memory/pm/battery_timetofull -1 -i vconftool set -t int memory/pm/battery_timetoempty -1 -i -vconftool set -t int memory/pm/sip_status 0 -i -g $users_gid -vconftool set -t int memory/pm/custom_brightness_status 0 -i -g $users_gid +vconftool set -t int memory/pm/sip_status 0 -i -g "$users_gid" +vconftool set -t int memory/pm/custom_brightness_status 0 -i -g "$users_gid" vconftool set -t bool memory/pm/brt_changed_lpm 0 -i -vconftool set -t int memory/pm/current_brt 60 -i -g $users_gid +vconftool set -t int memory/pm/current_brt 60 -i -g "$users_gid" systemctl daemon-reload if [ "$1" == "1" ]; then -- 2.7.4 From 5627b7e736f3df34202e06a5f6572a97195e05f4 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Mon, 12 Jan 2015 18:00:29 +0900 Subject: [PATCH 02/16] deviced: Remove unused define "PROP_DISPLAY_MAX_BRIGHTNESS" The value is redefined btw libdevice-node and deviced. So I remove an unused define at deviced side. Signed-off-by: Jiyoung Yun Change-Id: I00d9fe78f9048694403a5e085926cf59746a3e13 --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c98310..93bd7f7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,6 @@ MESSAGE("FLAGS: ${CMAKE_C_FLAGS}") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") ADD_DEFINITIONS("-DLIBPATH=\"${LIB_INSTALL_DIR}\"") -ADD_DEFINITIONS("-DPROP_DISPLAY_MAX_BRIGHTNESS=1") ADD_DEFINITIONS("-DENABLE_KEY_FILTER") IF(X11_SUPPORT) ADD_DEFINITIONS("-DENABLE_X_LCD_ONOFF") -- 2.7.4 From 452ae559bfde482f5a9a2a4dc70d6d63961e55b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Mon, 12 Jan 2015 11:14:58 +0100 Subject: [PATCH 03/16] Fix a runtime dependency MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Making libdeviced requiring deviced has more meaning that deviced requiring itself ^_^ Change-Id: I0dedc4a466e6f0f295cd3bef96c868141c1f9674 Signed-off-by: José Bollo --- packaging/deviced.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 2f85dd6..0029d06 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -61,7 +61,6 @@ deviced %package deviced Summary: deviced daemon Group: main -Requires: %{name} = %{version}-%{release} %description deviced deviced daemon. @@ -69,6 +68,7 @@ deviced daemon. %package -n libdeviced Summary: Deviced library Group: Development/Libraries +Requires: %{name} = %{version}-%{release} %description -n libdeviced Deviced library for device control -- 2.7.4 From e2abc3873c1395314a85fa964e75993b746f1267 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Mon, 26 Jan 2015 19:32:41 +0900 Subject: [PATCH 04/16] deviced: Fixed wrong parameter on booting_done signal Change-Id: Idfa0f163eb67324494d04a0134c74954aa0ebe9f Signed-off-by: Jiyoung Yun --- src/power/power-handler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 1d2afcc..90d051a 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -292,6 +292,7 @@ static void booting_done_edbus_signal_handler(void *data, DBusMessage *msg) return; _I("signal booting done"); + done = TRUE; device_notify(DEVICE_NOTIFIER_BOOTING_DONE, &done); } -- 2.7.4 From 0e9560aa5bdc9767a15613d072490bbfcc923fae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lo=C3=AFc=20Plassart?= Date: Tue, 13 Jan 2015 10:48:15 +0100 Subject: [PATCH 05/16] Replace Syspopup by Notification MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Replace calls to various Syspopup programs by calls to the notification API. Change-Id: Icba61a3b9f590be0cbe7f3e9235de532fe8faa24 Author: Loïc Plassart Signed-off-by: Manuel Bachmann --- CMakeLists.txt | 1 + packaging/deviced.spec | 3 +- src/battery/lowbat-handler.c | 88 ++++++---------------------------------- src/battery/power-supply.c | 76 +++++----------------------------- src/core/common.c | 18 ++++++++ src/core/common.h | 1 + src/core/device-change-handler.c | 6 --- src/mmc/ext4.c | 21 +--------- src/mmc/mmc-handler.c | 22 +--------- src/mmc/mmc-handler.h | 4 -- src/power/power-handler.c | 22 ++-------- src/storage/storage.c | 29 +++---------- 12 files changed, 56 insertions(+), 235 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93bd7f7..d8db63f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,6 +133,7 @@ SET(PKG_MODULES sensor tapi libtzplatform-config + notification ) IF(X11_SUPPORT) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 0029d06..0b87fe3 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -15,7 +15,7 @@ %bcond_with vibrator Name: deviced -Summary: deviced +Summary: Deviced Version: 1.0.0 Release: 1 Group: Framework/system @@ -48,6 +48,7 @@ BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(notification) %{?systemd_requires} Requires(preun): /usr/bin/systemctl diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 48ae318..bb67d12 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -60,15 +60,6 @@ #define LOWBAT_CPU_CTRL_ID "id6" #define LOWBAT_CPU_FREQ_RATE (0.7) -#define LOWBAT_POPUP_NAME "lowbat-syspopup" -#define LOWBAT_EXEC_PATH PREFIX"/bin/lowbatt-popup" - -struct popup_data { - char *name; - char *key; - char *value; -}; - struct lowbat_process_entry { int old; int now; @@ -78,7 +69,6 @@ struct lowbat_process_entry { static int cur_bat_state = BATTERY_UNKNOWN; static int cur_bat_capacity = -1; -static int lowbat_popup_option = 0; static int lowbat_freq = -1; static struct battery_config_info battery_info = { .normal = BATTERY_NORMAL, @@ -166,80 +156,40 @@ static int power_execute(void) static int lowbat_popup(char *option) { - static int launched_poweroff = 0; - static const struct device_ops *apps = NULL; - struct popup_data *params; int ret, state=0; int r_disturb, s_disturb, r_block, s_block; + int lowbat_popup_option = -1; char *value; - pid_t pid; if (!option) return -1; - if (strcmp(option, POWER_OFF_BAT_ACT)) - launched_poweroff = 0; - if (!strcmp(option, CRITICAL_LOW_BAT_ACT)) { -#ifdef MICRO_DD - value = "lowbattery_critical"; -#else - value = "critical"; -#endif - lowbat_popup_option = LOWBAT_OPT_CHECK; + value = "Critical"; } else if (!strcmp(option, WARNING_LOW_BAT_ACT)) { -#ifdef MICRO_DD - value = "lowbattery_warning"; -#else - value = "warning"; -#endif - lowbat_popup_option = LOWBAT_OPT_WARNING; + value = "Warning"; } else if (!strcmp(option, POWER_OFF_BAT_ACT)) { - value = "poweroff"; - lowbat_popup_option = LOWBAT_OPT_POWEROFF; + value = "Poweroff"; } else if (!strcmp(option, CHARGE_ERROR_ACT)) { - value = "chargeerr"; + value = "Charger error"; lowbat_popup_option = LOWBAT_OPT_CHARGEERR; } else if (!strcmp(option, CHARGE_ERROR_LOW_ACT)) { - value = "chargeerrlow"; + value = "Charger low temperature error"; lowbat_popup_option = LOWBAT_OPT_CHARGEERR; } else if (!strcmp(option, CHARGE_ERROR_HIGH_ACT)) { - value = "chargeerrhigh"; + value = "Charger high temperature error"; lowbat_popup_option = LOWBAT_OPT_CHARGEERR; } else if (!strcmp(option, CHARGE_ERROR_OVP_ACT)) { - value = "chargeerrovp"; + value = "Charger ovp error"; lowbat_popup_option = LOWBAT_OPT_CHARGEERR; } else if (!strcmp(option, CHARGE_CHECK_ACT)) { - launched_poweroff = 0; return 0; } else return -1; + _D("%s", value); ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &state); if (state == 1 || ret != 0 || booting_done(NULL)) { - - if (launched_poweroff == 1) { - _I("will be foreced power off"); - power_execute(); - return 0; - } - - if (lowbat_popup_option == LOWBAT_OPT_POWEROFF) - launched_poweroff = 1; - - pid = get_exec_pid(LOWBAT_EXEC_PATH); - if (pid > 0) { - _I("pre launched %s destroy", LOWBAT_EXEC_PATH); - kill(pid, SIGTERM); - } - - FIND_DEVICE_INT(apps, "apps"); - - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); - return -1; - } 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) || @@ -248,12 +198,9 @@ static int lowbat_popup(char *option) pm_change_internal(getpid(), LCD_NORMAL); else _I("block LCD"); - params->name = LOWBAT_POPUP_NAME; - params->key = POPUP_KEY_CONTENT; - params->value = strdup(value); - apps->init((void *)params); - free(params->value); - free(params); + ret = manage_notification("Low battery", value); + if (ret == -1) + return -1; } else { _D("boot-animation running yet"); } @@ -311,17 +258,6 @@ int battery_charge_err_ovp_act(void *data) static int battery_charge_act(void *data) { -#ifdef NOUSE - int val; - char argstr[128]; - - /* instead of adding action to the queue, execute it right here */ - if (device_get_property(DEVTYPE_JACK, JACK_PROP_TA_ONLINE, &val) == 0 - && val == 1) { - snprintf(argstr, 128, "-t 4"); - launch_after_kill_if_exist(LOWBAT_EXEC_PATH, argstr); - } -#endif return 0; } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index c05072e..ffc5fbf 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -34,7 +34,6 @@ #include "power-supply.h" #define BUFF_MAX 255 -#define POPUP_KEY_CONTENT "_SYSPOPUP_CONTENT_" #define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" #define SIGNAL_TEMP_GOOD "TempGood" @@ -70,12 +69,6 @@ enum power_supply_init_type { POWER_SUPPLY_INITIALIZED = 1, }; -struct popup_data { - char *name; - char *key; - char *value; -}; - static struct uevent_handler uh = { .subsystem = POWER_SUBSYSTEM, .uevent_func = uevent_power_handler, @@ -102,8 +95,6 @@ static int check_lowbat_charge_device(int bInserted) int bat_state = -1; int ret = -1; char *value; - struct popup_data *params; - static const struct device_ops *apps = NULL; pm_check_and_change(bInserted); if (bInserted == 1) { @@ -117,24 +108,15 @@ static int check_lowbat_charge_device(int bInserted) if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) == 0) { if(bat_state < VCONFKEY_SYSMAN_BAT_NORMAL || bat_state == VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF) { - FIND_DEVICE_INT(apps, "apps"); if(bat_state == VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF) - value = "poweroff"; + value = "Poweroff"; else - value = "warning"; - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); + value = "Warning"; + _I("%s %s", "lowbat", value); + ret = manage_notification("Low battery", value); + if (ret == -1) return -1; - } - params->name = "lowbat-syspopup"; - params->key = POPUP_KEY_CONTENT; - params->value = value; - _I("%s %s %s(%x)", params->name, params->key, params->value, params); - if (apps->init) - apps->init((void *)params); - free(params); } } else { _E("failed to get vconf key"); @@ -148,26 +130,11 @@ static int check_lowbat_charge_device(int bInserted) static int changed_battery_cf(enum present_type status) { - struct popup_data *params; - static const struct device_ops *apps = NULL; - - FIND_DEVICE_INT(apps, "apps"); - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); - return -ENOMEM; - } - params->name = "lowbat-syspopup"; - params->key = POPUP_KEY_CONTENT; - params->value = "battdisconnect"; - if (apps->init == NULL || apps->exit == NULL) - goto out; - if (status == PRESENT_ABNORMAL) - apps->init((void *)params); - else - apps->exit((void *)params); -out: - free(params); + int ret; + ret = manage_notification("Battery disconnect", "Battery disconnect"); + if (ret < 0) + return -1; + return 0; } @@ -186,28 +153,6 @@ static void health_status_broadcast(void) SIGNAL_TEMP_GOOD, NULL, NULL); } -static int clean_health_popup(void) -{ - struct popup_data *params; - static const struct device_ops *apps = NULL; - - FIND_DEVICE_INT(apps, "apps"); - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); - return -ENOMEM; - } - params->name = "lowbat-syspopup"; - params->key = POPUP_KEY_CONTENT; - if (apps->exit) - apps->exit((void *)params); - health_status_broadcast(); -out: - free(params); - return 0; - -} - static void health_timer_reset(void) { abnormal_timer = NULL; @@ -477,7 +422,6 @@ static void update_health(enum battery_noti_status status) } else { vconf_set_int(SIOP_DISABLE, 0); pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); - clean_health_popup(); abnormal_popup_timer_init(); } } diff --git a/src/core/common.c b/src/core/common.c index b43835d..3ab0b19 100644 --- a/src/core/common.c +++ b/src/core/common.c @@ -34,6 +34,7 @@ #include #include #include "log.h" +#include #define PERMANENT_DIR "/tmp/permanent" #define VIP_DIR "/tmp/vip" @@ -358,3 +359,20 @@ void print_time(const char *prefix) _D("%s --> %d:%02d:%02d %d", prefix, tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec); } + +int manage_notification(char *title, char *content) +{ + notification_h noti; + + noti = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti == NULL) { + _E("fail to create %s notification (content:%s)", title, content); + return -1; + } + + notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, title, NULL, NOTIFICATION_TYPE_NONE); + notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, content, NULL, NOTIFICATION_TYPE_NONE); + notification_insert(noti, NULL); + notification_free(noti); + return 0; +} diff --git a/src/core/common.h b/src/core/common.h index 9754d14..9eb56be 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -139,6 +139,7 @@ int sys_set_int(char *fname, int val); int terminate_process(const char* partition, bool force); int mount_check(const char* path); void print_time(const char *prefix); +int manage_notification(char *title, char *content); #endif /* __CORE_COMMON_H__ */ diff --git a/src/core/device-change-handler.c b/src/core/device-change-handler.c index 7cc32d8..2ba0feb 100644 --- a/src/core/device-change-handler.c +++ b/src/core/device-change-handler.c @@ -132,12 +132,6 @@ struct ticker_data { int type; }; -struct popup_data { - char *name; - char *key; - char *value; -}; - struct siop_data { int siop; int rear; diff --git a/src/mmc/ext4.c b/src/mmc/ext4.c index 1ff73e6..1b3ccc1 100644 --- a/src/mmc/ext4.c +++ b/src/mmc/ext4.c @@ -35,12 +35,6 @@ #define FS_EXT4_SMACK_LABEL "/usr/bin/mmc-smack-label" -struct popup_data { - char *name; - char *key; - char *value; -}; - static const char *ext4_arg[] = { "/sbin/mkfs.ext4", NULL, NULL, @@ -121,24 +115,13 @@ static int check_smack_popup(void) { int ret = -1; int val = -1; - struct popup_data *params; - static const struct device_ops *apps = NULL; ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &val); if (val == 1 || ret != 0) { - FIND_DEVICE_INT(apps, "apps"); - - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); + ret = manage_notification("MMC", "Check smack"); + if (ret == -1) return -1; - } - params->name = MMC_POPUP_NAME; - params->key = MMC_POPUP_APP_KEY; - params->value = MMC_POPUP_SMACK_VALUE; - apps->init(params); - free(params); } return 0; diff --git a/src/mmc/mmc-handler.c b/src/mmc/mmc-handler.c index f35700a..84d20ef 100644 --- a/src/mmc/mmc-handler.c +++ b/src/mmc/mmc-handler.c @@ -92,12 +92,6 @@ struct mmc_data { char *devpath; }; -struct popup_data { - char *name; - char *key; - char *value; -}; - static dd_list *fs_head; static char *mmc_curpath; static bool smack = false; @@ -158,21 +152,7 @@ bool mmc_check_mounted(const char *mount_point) static void launch_syspopup(char *str) { - struct popup_data *params; - static const struct device_ops *apps = NULL; - - FIND_DEVICE_VOID(apps, "apps"); - - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); - return; - } - params->name = MMC_POPUP_NAME; - params->key = POPUP_KEY_CONTENT; - params->value = strdup(str); - apps->init((void *)params); - free(params); + manage_notification("MMC", str); } static int get_partition(const char *devpath, char *subpath) diff --git a/src/mmc/mmc-handler.h b/src/mmc/mmc-handler.h index 0dfa9c5..1a780fa 100644 --- a/src/mmc/mmc-handler.h +++ b/src/mmc/mmc-handler.h @@ -29,10 +29,6 @@ #define BUF_LEN 20 #define RETRY_COUNT 10 -#define MMC_POPUP_NAME "mmc-syspopup" -#define MMC_POPUP_APP_KEY "_APP_NAME_" -#define MMC_POPUP_SMACK_VALUE "checksmack" - enum mmc_fs_type { FS_TYPE_VFAT = 0, FS_TYPE_EXT4, diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 1d2afcc..4b56596 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -57,16 +57,10 @@ #define SIGNAL_POWEROFF_STATE "ChangeState" -#define POWEROFF_POPUP_NAME "poweroff-syspopup" #define UMOUNT_RW_PATH "/opt/usr" static void poweroff_control_cb(keynode_t *in_key, void *data); -struct popup_data { - char *name; - char *key; -}; - static struct timeval tv_start_poweroff; static int power_off = 0; @@ -166,20 +160,12 @@ static int poweroff(void) static int pwroff_popup(void) { - struct popup_data *params; - static const struct device_ops *apps = NULL; - int val; - - FIND_DEVICE_INT(apps, "apps"); + int ret; - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); + ret = manage_notification("Poweroff", "Poweroff"); + if (ret == -1) return -1; - } - params->name = POWEROFF_POPUP_NAME; - apps->init((void *)params); - free(params); + return 0; } diff --git a/src/storage/storage.c b/src/storage/storage.c index 1394b67..af89d5a 100755 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -74,12 +74,6 @@ enum memnoti_level { MEMNOTI_LEVEL_NORMAL, } ; -struct popup_data { - char *name; - char *key; - char *value; -}; - struct storage_config_info { double warning_level; double critical_level; @@ -133,8 +127,6 @@ static int memnoti_popup(enum memnoti_level level) int ret = -1; int val = -1; char *value = NULL; - struct popup_data *params; - static const struct device_ops *apps = NULL; if (level != MEMNOTI_LEVEL_WARNING && level != MEMNOTI_LEVEL_CRITICAL) { _E("level check error : %d",level); @@ -142,30 +134,19 @@ static int memnoti_popup(enum memnoti_level level) } if (level == MEMNOTI_LEVEL_WARNING) { - value = "warning"; + value = "Warning"; } else if (level == MEMNOTI_LEVEL_CRITICAL) { - value = "critical"; + value = "Critical"; } ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &val); if (val == 0 || ret != 0) - goto out; - - FIND_DEVICE_INT(apps, "apps"); + return 0; - params = malloc(sizeof(struct popup_data)); - if (params == NULL) { - _E("Malloc failed"); + ret = manage_notification("Low memory", value); + if (ret == -1) return -1; - } - params->name = LOWMEM_POPUP_NAME; - params->key = POPUP_KEY_MEMNOTI; - params->value = strdup(value); - apps->init((void *)params); - free(params); return 0; -out: - return -1; } static enum memnoti_level check_memnoti_level(double total, double avail) -- 2.7.4 From 9b5ffde8d4e160a6c56507ed81d472353f4b7145 Mon Sep 17 00:00:00 2001 From: Kibak Yoon Date: Tue, 3 Feb 2015 21:49:27 +0900 Subject: [PATCH 06/16] rename sensor.h to sensor_internal.h the header file for sensor internal API was changed to sensor_internal.h. Signed-off-by: Kibak Yoon Change-Id: If42f246a4733efd51cc7f066b7771fb52e7e0a8d --- src/display/auto-brightness.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/auto-brightness.c b/src/display/auto-brightness.c index 216b3e1..63b245e 100644 --- a/src/display/auto-brightness.c +++ b/src/display/auto-brightness.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include "util.h" -- 2.7.4 From 11b7499e9841cd1f37fc5340ace7d1ed95411986 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Wed, 4 Feb 2015 15:06:41 +0900 Subject: [PATCH 07/16] deviced: Support runtime deviced The available module has been determined by build configuration. Now deviced will support to judge what module is valid or avaliable at runtime. If there is no probe which is always true case or the probe succeed, deviced will activate the module at runtime. If not, we do not support any method call or operation of the module. Change-Id: I866c645a4ee193f5473bfc1909894f0e96ba8dc3 Signed-off-by: Jiyoung Yun --- src/core/devices.c | 5 +++++ src/core/devices.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/core/devices.c b/src/core/devices.c index de766f3..307d3a0 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -68,6 +68,11 @@ void devices_init(void *data) const struct device_ops *dev; DD_LIST_FOREACH(dev_head, elem, dev) { + if (dev->probe && dev->probe(data) != 0) { + _E("[%s] probe fail", dev->name); + continue; + } + _D("[%s] initialize", dev->name); if (dev->init) dev->init(data); diff --git a/src/core/devices.h b/src/core/devices.h index 262e629..04158ac 100644 --- a/src/core/devices.h +++ b/src/core/devices.h @@ -43,6 +43,7 @@ enum device_flags { struct device_ops { enum device_priority priority; char *name; + int (*probe) (void *data); void (*init) (void *data); void (*exit) (void *data); int (*start) (enum device_flags flags); -- 2.7.4 From d990889448c6a72e012ed93322ff9c5c1b66eed0 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Wed, 4 Feb 2015 15:26:51 +0900 Subject: [PATCH 08/16] deviced: Enable battery module and check whether it is available at runtime Some build issue is also fixed. Change-Id: I4b4d9be3a4ca10cbbe44eba412ae4546c182a0dd Signed-off-by: Jiyoung Yun --- CMakeLists.txt | 2 -- packaging/deviced.spec | 4 ---- src/battery/lowbat-handler.c | 51 +++++++++++++++++++++++++++++--------------- src/battery/power-supply.c | 13 +++++------ 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8db63f..7a6f018 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,14 +45,12 @@ SET(SRCS ${SRCS} src/gpio/buzzer.c) ENDIF(TIZEN_BUZZER) -IF(TIZEN_BATTERY) SET(SRCS ${SRCS} src/battery/battery-time.c src/battery/config.c src/battery/lowbat-handler.c src/battery/power-supply.c ) -ENDIF(TIZEN_BATTERY) IF(TIZEN_EXTCON) SET(SRCS ${SRCS} diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 0b87fe3..fc0397f 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -4,7 +4,6 @@ #These options are DEACTIVATED by default. %bcond_with x -%bcond_with battery %bcond_with buzzer %bcond_with camera_led %bcond_with extcon @@ -188,9 +187,6 @@ export CFLAGS+=" -DX11_SUPPORT" -DTZ_SYS_ETC=%TZ_SYS_ETC \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DARCH=%{ARCH} \ -%if %{with battery} - -DTIZEN_BATTERY:BOOL=ON \ -%endif %if %{with buzzer} -DTIZEN_BUZZER:BOOL=ON \ %endif diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index bb67d12..3cfaaa1 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -32,6 +32,7 @@ #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" @@ -154,6 +155,23 @@ static int power_execute(void) return ops->execute(INTERNAL_PWROFF); } +static int booting_done(void *data) +{ + static int done = 0; + + if (data == NULL) + goto out; + done = *(int*)data; + if (!done) + goto out; + _I("booting done"); + + power_supply_timer_stop(); + power_supply_init(NULL); +out: + return done; +} + static int lowbat_popup(char *option) { int ret, state=0; @@ -495,23 +513,6 @@ static int check_power_save_mode(void) return ret; } -static int booting_done(void *data) -{ - static int done = 0; - - if (data == NULL) - goto out; - done = *(int*)data; - if (!done) - goto out; - _I("booting done"); - - power_supply_timer_stop(); - power_supply_init(NULL); -out: - return done; -} - static int lowbat_monitor_init(void *data) { int status = 1; @@ -536,6 +537,21 @@ static int display_changed(void *data) return 0; } +static int lowbat_probe(void *data) +{ + /** + * find power-supply class. + * if there is no power-supply class, + * deviced does not activate a battery module. + */ + if (access(POWER_PATH, R_OK) != 0) { + _E("there is no power-supply class"); + return -ENODEV; + } + + return 0; +} + static void lowbat_init(void *data) { /* process check battery timer until booting done */ @@ -561,6 +577,7 @@ static void lowbat_exit(void *data) static const struct device_ops lowbat_device_ops = { .priority = DEVICE_PRIORITY_NORMAL, .name = "lowbat", + .probe = lowbat_probe, .init = lowbat_init, .exit = lowbat_exit, }; diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index ffc5fbf..8f25fc2 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -22,15 +22,15 @@ #include #include #include -#include "devices.h" -#include "device-handler.h" -#include "device-notifier.h" -#include "udev.h" -#include "log.h" +#include "core/devices.h" +#include "core/device-handler.h" +#include "core/device-notifier.h" +#include "core/udev.h" +#include "core/log.h" #include "display/poll.h" #include "display/setting.h" #include "proc/proc-handler.h" -#include "config-parser.h" +#include "core/config-parser.h" #include "power-supply.h" #define BUFF_MAX 255 @@ -69,6 +69,7 @@ enum power_supply_init_type { POWER_SUPPLY_INITIALIZED = 1, }; +static void uevent_power_handler(struct udev_device *dev); static struct uevent_handler uh = { .subsystem = POWER_SUBSYSTEM, .uevent_func = uevent_power_handler, -- 2.7.4 From 8a7b44698d5f6474aeefc9232e7729f1ca081a5c Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Wed, 4 Feb 2015 17:20:52 +0900 Subject: [PATCH 09/16] deviced: Do not use device-node in battery case deviced control battery module using power-supply class. So we do not need to use device-node to get battery information. Instead we can receive the changed event by using power-supply uevent. Change-Id: I4a94a8f35009c655c2a8ce760fe39e9426f557c2 Signed-off-by: Jiyoung Yun --- src/battery/lowbat-handler.c | 27 +-------------------------- src/battery/power-supply.c | 12 ++---------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 3cfaaa1..b7fead2 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -437,22 +437,11 @@ exit: return result; } -static int lowbat_read(void) -{ - int bat_percent, r; - - r = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY, &bat_percent); - if (r < 0) - return r; - - return bat_percent; -} - static int check_lowbat_percent(int *pct) { int bat_percent; - bat_percent = lowbat_read(); + bat_percent = battery.capacity; if (bat_percent < 0) { _E("[BATMON] Cannot read battery gage. stop read fuel gage"); return -ENODEV; @@ -482,20 +471,6 @@ void lowbat_monitor(void *data) lowbat_process(bat_percent, NULL); } -/* for debugging (request by kernel) */ -static int check_battery() -{ - int r; - int ret = -1; - - if (device_get_property(DEVICE_TYPE_POWER, PROP_POWER_PRESENT, &ret) < 0) { - _E("FAIL: device_get_property(): [BATMON] battery check : %d", ret); - } - _D("[BATMON] battery check : %d", ret); - - return ret; -} - static int check_power_save_mode(void) { int ret = 0; diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 8f25fc2..3128c0c 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -842,18 +842,10 @@ static DBusMessage *dbus_get_percent_raw(E_DBus_Object *obj, DBusMessage *msg) { DBusMessageIter iter; DBusMessage *reply; - int ret, val; - - ret = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY_RAW, &val); - if (ret < 0) - goto out; - - if (val > 10000) - val = 10000; + int ret; - ret = val; + ret = -ENOTSUP; -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); -- 2.7.4 From 0b90503f8dcf8f68e052a71da103bc5634d833eb Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Thu, 5 Feb 2015 15:42:16 +0900 Subject: [PATCH 10/16] deviced: Do not register dbus object in the case of deactive module If there is no power-supply class, deviced does not register battery dbus object. Change-Id: Idf6e390f5ffb3e622247d2c6d5727f5b498edd06 Signed-off-by: Jiyoung Yun --- src/battery/power-supply.c | 10 +++++-- src/core/edbus-handler.c | 71 ++++++++++++++++++++++++++++++++++++---------- src/core/edbus-handler.h | 9 ++++++ 3 files changed, 73 insertions(+), 17 deletions(-) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 3128c0c..2a78d08 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -953,13 +953,19 @@ static const struct edbus_method edbus_methods[] = { { POWER_SUBSYSTEM, "sisssss", "i", dbus_battery_handler }, }; +static struct edbus_object battery_obj = { + .path = DEVICED_PATH_BATTERY, + .interface = DEVICED_INTERFACE_BATTERY, +}; + int power_supply_init(void *data) { int ret; - ret = register_edbus_method(DEVICED_PATH_BATTERY, edbus_methods, ARRAY_SIZE(edbus_methods)); + ret = register_edbus_interface_with_method(&battery_obj, + edbus_methods, ARRAY_SIZE(edbus_methods)); if (ret < 0) - _E("fail to init edbus method(%d)", ret); + _E("fail to init edbus interface and method(%d)", ret); ret = register_edbus_signal_handler(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, SIGNAL_CHARGEERR_RESPONSE, diff --git a/src/core/edbus-handler.c b/src/core/edbus-handler.c index 75114f4..572dd42 100644 --- a/src/core/edbus-handler.c +++ b/src/core/edbus-handler.c @@ -18,6 +18,7 @@ #include +#include #include "core/log.h" #include "core/edbus-handler.h" #include "core/common.h" @@ -39,12 +40,7 @@ struct edbus_list{ E_DBus_Signal_Handler *handler; }; -static struct edbus_object { - const char *path; - const char *interface; - E_DBus_Object *obj; - E_DBus_Interface *iface; -} edbus_objects[] = { +static struct edbus_object edbus_objects[] = { { DEVICED_PATH_CORE , DEVICED_INTERFACE_CORE , NULL, NULL }, { DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, NULL, NULL }, { DEVICED_PATH_POWER , DEVICED_INTERFACE_POWER , NULL, NULL }, @@ -59,7 +55,6 @@ static struct edbus_object { { DEVICED_PATH_USB , DEVICED_INTERFACE_USB , NULL, NULL }, { DEVICED_PATH_USBHOST, DEVICED_INTERFACE_USBHOST, NULL, NULL }, { DEVICED_PATH_EXTCON , DEVICED_INTERFACE_EXTCON , NULL, NULL }, - { DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, NULL, NULL }, { DEVICED_PATH_GPIO, DEVICED_INTERFACE_GPIO, NULL, NULL}, { DEVICED_PATH_HDMICEC, DEVICED_INTERFACE_HDMICEC, NULL, NULL}, /* Add new object & interface here*/ @@ -456,18 +451,14 @@ static void unregister_edbus_watch_all(void) } } -int register_edbus_method(const char *path, const struct edbus_method *edbus_methods, int size) +static int register_method(E_DBus_Interface *iface, + const struct edbus_method *edbus_methods, int size) { - E_DBus_Interface *iface; int ret; int i; - iface = get_edbus_interface(path); - - if (!iface) { - _E("fail to get edbus interface!"); - return -ENODEV; - } + assert(iface); + assert(edbus_methods); for (i = 0; i < size; i++) { ret = e_dbus_interface_method_add(iface, @@ -484,6 +475,56 @@ int register_edbus_method(const char *path, const struct edbus_method *edbus_met return 0; } +int register_edbus_interface_with_method(struct edbus_object *object, + const struct edbus_method *edbus_methods, int size) +{ + int ret; + + if (!object || !edbus_methods || size < 1) { + _E("invalid parameter"); + return -EINVAL; + } + + ret = register_edbus_interface(object); + if (ret < 0) { + _E("fail to register %s interface(%d)", object->path, ret); + return ret; + } + + ret = register_method(object->iface, edbus_methods, size); + if (ret < 0) { + _E("fail to register %s method(%d)", object->path, ret); + return ret; + } + + return 0; +} + +int register_edbus_method(const char *path, const struct edbus_method *edbus_methods, int size) +{ + E_DBus_Interface *iface; + int ret; + + if (!path || !edbus_methods || size < 1) { + _E("invalid parameter"); + return -EINVAL; + } + + iface = get_edbus_interface(path); + if (!iface) { + _E("fail to get edbus interface!"); + return -ENODEV; + } + + ret = register_method(iface, edbus_methods, size); + if (ret < 0) { + _E("fail to register %s method(%d)", path, ret); + return ret; + } + + return 0; +} + static void request_name_cb(void *data, DBusMessage *msg, DBusError *error) { DBusError err; diff --git a/src/core/edbus-handler.h b/src/core/edbus-handler.h index c0e79ca..fa84818 100644 --- a/src/core/edbus-handler.h +++ b/src/core/edbus-handler.h @@ -23,6 +23,13 @@ #include #include "shared/dbus.h" +struct edbus_object { + const char *path; + const char *interface; + E_DBus_Object *obj; + E_DBus_Interface *iface; +}; + struct edbus_method { const char *member; const char *signature; @@ -43,6 +50,8 @@ struct watch { int (*func)(char *name, enum watch_id id); }; +int register_edbus_interface_with_method(struct edbus_object *object, + const struct edbus_method *edbus_methods, int size); int register_edbus_method(const char *path, const struct edbus_method *edbus_methods, int size); int register_edbus_signal_handler(const char *path, const char *interface, const char *name, E_DBus_Signal_Cb cb); -- 2.7.4 From 74d7482d9f5e479685abc82a28a531e13bc439d5 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Fri, 6 Feb 2015 11:47:05 +0900 Subject: [PATCH 11/16] deviced: Remove unnecessary initialization DEVICE_PRIORITY_NORMAL value is zero. And static structure value is initilized zero automatically. Do not need to reassign the same value. Change-Id: Ib03242ebbf246ee8fbfc0f099cd5808886cfb68a Signed-off-by: Jiyoung Yun --- src/apps/apps.c | 1 - src/battery/battery-time.c | 1 - src/battery/lowbat-handler.c | 1 - src/bs/bs.c | 1 - src/control/control.c | 1 - src/core/sig-handler.c | 1 - src/cpu/cpu-handler.c | 1 - src/earjack/earjack.c | 1 - src/gpio/gpio.c | 1 - src/haptic/haptic.c | 1 - src/led/ir.c | 1 - src/led/torch.c | 1 - src/mmc/mmc-handler.c | 1 - src/power/power-handler.c | 1 - src/proc/cpu-info.c | 1 - src/proc/pmon-handler.c | 1 - src/proc/proc-handler.c | 1 - src/storage/storage.c | 1 - src/ta/ta-handler.c | 1 - src/telephony/telephony.c | 1 - src/time/time-handler.c | 1 - 21 files changed, 21 deletions(-) diff --git a/src/apps/apps.c b/src/apps/apps.c index a4d1530..e3a897d 100644 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -85,7 +85,6 @@ static void apps_exit(void *data) } static const struct device_ops apps_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "apps", .init = apps_init, .exit = apps_exit, diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index 3759949..ee0f8af 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -463,7 +463,6 @@ static void battery_exit(void *data) } static const struct device_ops battery_time_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "battery-time", .init = battery_init, .exit = battery_exit, diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index b7fead2..8e19789 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -550,7 +550,6 @@ static void lowbat_exit(void *data) } static const struct device_ops lowbat_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "lowbat", .probe = lowbat_probe, .init = lowbat_init, diff --git a/src/bs/bs.c b/src/bs/bs.c index ae38ddb..590ba11 100644 --- a/src/bs/bs.c +++ b/src/bs/bs.c @@ -453,7 +453,6 @@ static void bs_init(void *data) } static const struct device_ops bs_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "bs", .init = bs_init, }; diff --git a/src/control/control.c b/src/control/control.c index 950d531..de37c47 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -221,7 +221,6 @@ static void control_init(void *data) } static const struct device_ops control_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "control", .init = control_init, }; diff --git a/src/core/sig-handler.c b/src/core/sig-handler.c index a04253c..e0bc74a 100644 --- a/src/core/sig-handler.c +++ b/src/core/sig-handler.c @@ -70,7 +70,6 @@ static void signal_init(void *data) } static const struct device_ops signal_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "signal", .init = signal_init, }; diff --git a/src/cpu/cpu-handler.c b/src/cpu/cpu-handler.c index 71d6d36..8724339 100644 --- a/src/cpu/cpu-handler.c +++ b/src/cpu/cpu-handler.c @@ -545,7 +545,6 @@ static void cpu_init(void *data) } static const struct device_ops cpu_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "cpu", .init = cpu_init, }; diff --git a/src/earjack/earjack.c b/src/earjack/earjack.c index bcc785e..c454745 100644 --- a/src/earjack/earjack.c +++ b/src/earjack/earjack.c @@ -131,7 +131,6 @@ static int earjack_execute(void *data) } static const struct device_ops earjack_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "earjack", .init = earjack_init, .status = earjack_get_status, diff --git a/src/gpio/gpio.c b/src/gpio/gpio.c index eea1751..0e15528 100644 --- a/src/gpio/gpio.c +++ b/src/gpio/gpio.c @@ -116,7 +116,6 @@ static void gpio_init(void *data) } const struct device_ops gpio_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "gpio", .init = gpio_init, }; diff --git a/src/haptic/haptic.c b/src/haptic/haptic.c index 2f0ff09..2884ac9 100644 --- a/src/haptic/haptic.c +++ b/src/haptic/haptic.c @@ -735,7 +735,6 @@ static int haptic_stop(void) } static const struct device_ops haptic_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "haptic", .init = haptic_init, .exit = haptic_exit, diff --git a/src/led/ir.c b/src/led/ir.c index 86f1767..af448ff 100644 --- a/src/led/ir.c +++ b/src/led/ir.c @@ -65,7 +65,6 @@ static void ir_init(void *data) } static const struct device_ops irled_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "irled", .init = ir_init, }; diff --git a/src/led/torch.c b/src/led/torch.c index ed734bb..f1cf6a3 100644 --- a/src/led/torch.c +++ b/src/led/torch.c @@ -112,7 +112,6 @@ static void torch_init(void *data) } static const struct device_ops torchled_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "torchled", .init = torch_init, }; diff --git a/src/mmc/mmc-handler.c b/src/mmc/mmc-handler.c index 84d20ef..7827e55 100644 --- a/src/mmc/mmc-handler.c +++ b/src/mmc/mmc-handler.c @@ -969,7 +969,6 @@ static int mmc_stop(enum device_flags flags) } const struct device_ops mmc_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "mmc", .init = mmc_init, .exit = mmc_exit, diff --git a/src/power/power-handler.c b/src/power/power-handler.c index efc36ad..9ae300e 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -541,7 +541,6 @@ static void power_init(void *data) } static const struct device_ops power_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = POWER_OPS_NAME, .init = power_init, .execute = power_execute, diff --git a/src/proc/cpu-info.c b/src/proc/cpu-info.c index 2c8e00e..ae69559 100644 --- a/src/proc/cpu-info.c +++ b/src/proc/cpu-info.c @@ -143,7 +143,6 @@ static void cpu_info_init(void *data) } static const struct device_ops cpu_info_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "cpu_info", .init = cpu_info_init, }; diff --git a/src/proc/pmon-handler.c b/src/proc/pmon-handler.c index 7f88d0f..6e993be 100644 --- a/src/proc/pmon-handler.c +++ b/src/proc/pmon-handler.c @@ -274,7 +274,6 @@ static void pmon_init(void *data) } static const struct device_ops pmon_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "pmon", .init = pmon_init, }; diff --git a/src/proc/proc-handler.c b/src/proc/proc-handler.c index 25bac1f..deeddba 100644 --- a/src/proc/proc-handler.c +++ b/src/proc/proc-handler.c @@ -787,7 +787,6 @@ static void process_init(void *data) } static const struct device_ops process_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = PROC_OPS_NAME, .init = process_init, .execute = process_execute, diff --git a/src/storage/storage.c b/src/storage/storage.c index af89d5a..87060be 100755 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -426,7 +426,6 @@ static void lowmem_exit(void *data) } static const struct device_ops lowmem_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "lowmem", .init = lowmem_init, .exit = lowmem_exit, diff --git a/src/ta/ta-handler.c b/src/ta/ta-handler.c index bfa7770..0345f27 100644 --- a/src/ta/ta-handler.c +++ b/src/ta/ta-handler.c @@ -69,7 +69,6 @@ static void ta_init(void *data) } static const struct device_ops ta_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "ta", .init = ta_init, }; diff --git a/src/telephony/telephony.c b/src/telephony/telephony.c index 4d75554..a01bb72 100644 --- a/src/telephony/telephony.c +++ b/src/telephony/telephony.c @@ -411,7 +411,6 @@ static void telephony_init(void *data) } static const struct device_ops tel_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "telephony", .init = telephony_init, .start = telephony_start, diff --git a/src/time/time-handler.c b/src/time/time-handler.c index 879c1a9..17d5888 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -376,7 +376,6 @@ static void time_init(void *data) } static const struct device_ops time_device_ops = { - .priority = DEVICE_PRIORITY_NORMAL, .name = "time", .init = time_init, }; -- 2.7.4 From 6baf202211e5e635b58be30669f351030ca604a5 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Fri, 6 Feb 2015 15:44:17 +0900 Subject: [PATCH 12/16] deviced: Fix library path under 64-bit architecture on pc file Change-Id: I2801f800b7251ae76daf634a2dd9906db77993d0 Signed-off-by: Jiyoung Yun --- deviced.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deviced.pc.in b/deviced.pc.in index 6ce4c9b..fe1f8f2 100644 --- a/deviced.pc.in +++ b/deviced.pc.in @@ -2,7 +2,7 @@ prefix=@PREFIX@ exec_prefix=@EXEC_PREFIX@ -libdir=/usr/lib +libdir=@LIB_INSTALL_DIR@ includedir=/usr/include/deviced Name: deviced -- 2.7.4 From e60f8942718b3db28b43e63488459e4fdecebe42 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Wed, 4 Feb 2015 17:46:53 +0900 Subject: [PATCH 13/16] extcon: add extcon uevent handler - The following is a example of extcon state in the uevent delivered when extcon devices are connected. USB=1 TA=0 FAST-CHARGER=0 SLOW-CHARGER=0 CHARGER-DOWNSTREAM=0 JIG-USB-ON=0 JIG-USB-OFF=0 JIG-UART-OFF=0 JIG-UART-ON=0 - extcon handler parses the extcon state information and notifies to the deviced modules related with the extcon devices. - 'struct extcon_ops' is used to register extcon devices. Change-Id: I612c4b38f527a0095c49b72958c595d72a99e56f Signed-off-by: taeyoung --- CMakeLists.txt | 1 + src/core/device-change-handler.c | 17 +++- src/core/udev.h | 3 + src/extcon/extcon.c | 212 +++++++++++++++++++++++++++++++++++++++ src/extcon/extcon.h | 46 +++++++++ 5 files changed, 276 insertions(+), 3 deletions(-) create mode 100755 src/extcon/extcon.c create mode 100755 src/extcon/extcon.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a6f018..88229eb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ SET(SRCS src/core/log.c src/core/main.c src/core/sig-handler.c + src/extcon/extcon.c src/gpio/gpio.c src/power/power-handler.c src/proc/cpu-info.c diff --git a/src/core/device-change-handler.c b/src/core/device-change-handler.c index 2ba0feb..74e9391 100644 --- a/src/core/device-change-handler.c +++ b/src/core/device-change-handler.c @@ -43,6 +43,7 @@ #include "devices.h" #include "display/setting.h" #include "display/core.h" +#include "extcon/extcon.h" #define PREDEF_DEVICE_CHANGED "device_changed" #define PREDEF_POWER_CHANGED POWER_SUBSYSTEM @@ -153,6 +154,7 @@ enum udev_subsystem_type { UDEV_INPUT, UDEV_PLATFORM, UDEV_SWITCH, + UDEV_EXTCON, }; static const struct udev_subsystem { @@ -160,9 +162,10 @@ static const struct udev_subsystem { const char *str; const char *devtype; } udev_subsystems[] = { - { UDEV_INPUT, INPUT_SUBSYSTEM, NULL }, - { UDEV_PLATFORM, PLATFORM_SUBSYSTEM, NULL }, - { UDEV_SWITCH, SWITCH_SUBSYSTEM, NULL }, + { UDEV_INPUT, INPUT_SUBSYSTEM, NULL }, + { UDEV_PLATFORM, PLATFORM_SUBSYSTEM, NULL }, + { UDEV_SWITCH, SWITCH_SUBSYSTEM, NULL }, + { UDEV_EXTCON, EXTCON_SUBSYSTEM, NULL }, }; static dd_list *udev_event_list; @@ -786,6 +789,14 @@ static Eina_Bool uevent_kernel_control_cb(void *data, Ecore_Fd_Handler *fd_handl break; changed_device(env_value, NULL); break; + case UDEV_EXTCON: + env_value = udev_device_get_property_value(dev, "STATE"); + if (!env_value) + break; + ret = extcon_update(env_value); + if (ret < 0) + _E("Failed to update extcon status"); + break; } out: diff --git a/src/core/udev.h b/src/core/udev.h index f477a9d..ab231b4 100644 --- a/src/core/udev.h +++ b/src/core/udev.h @@ -58,6 +58,9 @@ /* switch device */ #define SWITCH_SUBSYSTEM "switch" +/* extcon */ +#define EXTCON_SUBSYSTEM "extcon" + /* host device */ #define HOST_SUBSYSTEM "host_notify" diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c new file mode 100755 index 0000000..629c459 --- /dev/null +++ b/src/extcon/extcon.c @@ -0,0 +1,212 @@ +/* + * deviced + * + * Copyright (c) 2015 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 + +#include "core/log.h" +#include "core/list.h" +#include "core/common.h" +#include "core/devices.h" +#include "core/config-parser.h" +#include "core/device-notifier.h" +#include "extcon.h" + +#define EXTCON_PATH "/sys/class/extcon" + +#define BUF_MAX 256 + +static dd_list *extcon_list; + +void add_extcon(const struct extcon_ops *dev) +{ + DD_LIST_APPEND(extcon_list, dev); +} + +void remove_extcon(const struct extcon_ops *dev) +{ + DD_LIST_REMOVE(extcon_list, dev); +} + +static int extcon_changed(struct extcon_ops *dev, int status) +{ + if (!dev) + return -EINVAL; + + if (dev->status == status) + return 0; + + _I("Changed %s device : %d -> %d", dev->name, dev->status, status); + + dev->status = status; + device_notify(dev->noti, &status); + + return 0; +} + +static struct extcon_ops *find_extcon(const char *name) +{ + dd_list *l; + struct extcon_ops *dev; + + if (!name) + return NULL; + + DD_LIST_FOREACH(extcon_list, l, dev) { + if (!strcmp(dev->name, name)) + return dev; + } + + return NULL; +} + +int extcon_update(const char *value) +{ + char *s, *p; + char name[NAME_MAX]; + struct extcon_ops *dev; + + if (!value) + return -EINVAL; + + s = (char*)value; + while (s && *s != '\0') { + p = strchr(s, '='); + if (!p) + break; + memset(name, 0, sizeof(name)); + memcpy(name, s, p-s); + dev = find_extcon(name); + if (dev) + extcon_changed(dev, atoi(p+1)); + s = strchr(p, '\n'); + if (!s) + break; + s += 1; + } + + return 0; +} + +static int extcon_load_uevent(struct parse_result *result, void *user_data) +{ + struct extcon_ops *dev; + int val; + + if (!result) + return 0; + + if (!result->name || !result->value) + return 0; + + val = atoi(result->value); + dev = find_extcon(result->name); + if (dev) + extcon_changed(dev, val); + + return 0; +} + +static int get_extcon_uevent_state(char *state, unsigned int len) +{ + DIR *dir; + struct dirent *entry; + char node[BUF_MAX]; + int ret; + + if (!state) + return -EINVAL; + + dir = opendir(EXTCON_PATH); + if (!dir) { + ret = -errno; + _E("Cannot open dir (%s, errno:%d)", EXTCON_PATH, ret); + return ret; + } + + ret = -ENOENT; + while ((entry = readdir(dir))) { + if (entry->d_name[0] == '.') + continue; + snprintf(node, sizeof(node), "%s/%s/state", + EXTCON_PATH, entry->d_name); + _I("checking node (%s)", node); + if (access(node, F_OK) != 0) + continue; + + ret = 0; + break; + } + + if (dir) + closedir(dir); + + if (ret == 0) { + strncpy(state, node, len - 1); + state[len -1] = '\0'; + } + + return ret; +} + +static void extcon_init(void *data) +{ + int ret; + char state[256]; + dd_list *l; + struct extcon_ops *dev; + + if (!extcon_list) + return; + + DD_LIST_FOREACH(extcon_list, l, dev) { + _I("[extcon] init (%s)", dev->name); + if (dev->init) + dev->init(data); + } + + /* load extcon uevent */ + ret = get_extcon_uevent_state(state, sizeof(state)); + if (ret == 0) { + ret = config_parse(state, extcon_load_uevent, NULL); + if (ret < 0) + _E("Failed to load %s file : %d", EXTCON_PATH, ret); + } else { + _E("Failed to get extcon uevent state node"); + } +} + +static void extcon_exit(void *data) +{ + dd_list *l; + struct extcon_ops *dev; + + DD_LIST_FOREACH(extcon_list, l, dev) { + _I("[extcon] deinit (%s)", dev->name); + if (dev->exit) + dev->exit(data); + } +} + +const struct device_ops extcon_device_ops = { + .name = "extcon", + .init = extcon_init, + .exit = extcon_exit, +}; + +DEVICE_OPS_REGISTER(&extcon_device_ops) diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h new file mode 100755 index 0000000..9b2e699 --- /dev/null +++ b/src/extcon/extcon.h @@ -0,0 +1,46 @@ +/* + * deviced + * + * Copyright (c) 2015 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 __EXTCON_H__ +#define __EXTCON_H__ + +struct extcon_ops { + const char *name; + int status; + enum device_notifier_type noti; + void (*init)(void *data); + void (*exit)(void *data); +}; + +#define EXTCON_OPS_REGISTER(dev) \ +static void __CONSTRUCTOR__ extcon_init(void) \ +{ \ + add_extcon(dev); \ +} \ +static void __DESTRUCTOR__ extcon_exit(void) \ +{ \ + remove_extcon(dev); \ +} + +void add_extcon(const struct extcon_ops *dev); +void remove_extcon(const struct extcon_ops *dev); + +int extcon_update(const char *value); + +#endif /* __EXTCON_H__ */ -- 2.7.4 From bc0f549edbfbcf70a098f367d8998249b0bf09c6 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Wed, 4 Feb 2015 20:15:42 +0900 Subject: [PATCH 14/16] notifier: change the function name for unregistering device notification - There is a mismatching for the function name between the prototype and its implementation. Thus the name is changed correctly. unregister_notifier_del() -> unregister_notifier() Change-Id: I5387aae2837d457d0ad610e767e0979ea38a67e5 Signed-off-by: taeyoung --- src/core/device-notifier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/device-notifier.h b/src/core/device-notifier.h index 9e32fce..597217a 100644 --- a/src/core/device-notifier.h +++ b/src/core/device-notifier.h @@ -41,7 +41,7 @@ enum device_notifier_type { * This is for internal callback method. */ int register_notifier(enum device_notifier_type status, int (*func)(void *data)); -int unregister_notifier_del(enum device_notifier_type status, int (*func)(void *data)); +int unregister_notifier(enum device_notifier_type status, int (*func)(void *data)); void device_notify(enum device_notifier_type status, void *value); #endif /* __DEVICE_NOTIFIER_H__ */ -- 2.7.4 From 9e396ae38dea5a5c8b19db66785b79a6a0c1d195 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Wed, 4 Feb 2015 22:18:15 +0900 Subject: [PATCH 15/16] extcon: add function to get current device status - Each extcon device can have scenario in which they should get the current status of itself. Thus the getter function for current device status is added. Change-Id: I4898d5d9968ff95ee27d7c871cf65b13ca7fc559 Signed-off-by: taeyoung --- src/extcon/extcon.c | 14 ++++++++++++++ src/extcon/extcon.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c index 629c459..842c3c5 100755 --- a/src/extcon/extcon.c +++ b/src/extcon/extcon.c @@ -75,6 +75,20 @@ static struct extcon_ops *find_extcon(const char *name) return NULL; } +int extcon_get_status(const char *name) +{ + struct extcon_ops *dev; + + if (!name) + return -EINVAL; + + dev = find_extcon(name); + if (!dev) + return -ENOENT; + + return dev->status; +} + int extcon_update(const char *value) { char *s, *p; diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h index 9b2e699..f0b6ea1 100755 --- a/src/extcon/extcon.h +++ b/src/extcon/extcon.h @@ -42,5 +42,6 @@ void add_extcon(const struct extcon_ops *dev); void remove_extcon(const struct extcon_ops *dev); int extcon_update(const char *value); +int extcon_get_status(const char *name); #endif /* __EXTCON_H__ */ -- 2.7.4 From 357bd782f458f4ed8e22c8a1377db6672f588bf9 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Mon, 9 Feb 2015 15:59:19 +0900 Subject: [PATCH 16/16] extcon: change extcon object type from 'const' to normal - Extcon object contains status element and it can be updated by extcon status. Thus 'const' is removed for the extcon object Change-Id: I7a26af7ac8c878a145a4a68d77e9af2cc72607b1 Signed-off-by: taeyoung --- src/extcon/extcon.c | 4 ++-- src/extcon/extcon.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c index 842c3c5..cd2cc5f 100755 --- a/src/extcon/extcon.c +++ b/src/extcon/extcon.c @@ -33,12 +33,12 @@ static dd_list *extcon_list; -void add_extcon(const struct extcon_ops *dev) +void add_extcon(struct extcon_ops *dev) { DD_LIST_APPEND(extcon_list, dev); } -void remove_extcon(const struct extcon_ops *dev) +void remove_extcon(struct extcon_ops *dev) { DD_LIST_REMOVE(extcon_list, dev); } diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h index f0b6ea1..28fc8a1 100755 --- a/src/extcon/extcon.h +++ b/src/extcon/extcon.h @@ -38,8 +38,8 @@ static void __DESTRUCTOR__ extcon_exit(void) \ remove_extcon(dev); \ } -void add_extcon(const struct extcon_ops *dev); -void remove_extcon(const struct extcon_ops *dev); +void add_extcon(struct extcon_ops *dev); +void remove_extcon(struct extcon_ops *dev); int extcon_update(const char *value); int extcon_get_status(const char *name); -- 2.7.4