summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2015-04-07 19:01:17 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2015-04-13 14:26:39 +0900
commitde374774f959e24b01545b11341542a2e70ae624 (patch)
treec55df834a1d50e7f24bee13e8369726e8f56fb4b
parentd32f876fdb862f41700a06581cdcc6f67a8cd98a (diff)
downloaddeviced-de374774f959e24b01545b11341542a2e70ae624.tar.gz
deviced-de374774f959e24b01545b11341542a2e70ae624.tar.bz2
deviced-de374774f959e24b01545b11341542a2e70ae624.zip
power: Do not use vconf key to control poweroff operation
Before changing, deviced can be turn off the target by vconf key. Now all poweroff case of the dependent on vconf key are removed. And removed unsupported recovery, fota codes. Change-Id: Ia01a4e1f898ecb3451c81d226521a4864712dd6c Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
-rw-r--r--src/battery/lowbat-handler.c4
-rw-r--r--src/display/core.c9
-rw-r--r--src/power/power-handler.c176
-rw-r--r--src/power/power-handler.h17
-rw-r--r--src/telephony/telephony.c19
5 files changed, 75 insertions, 150 deletions
diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c
index cd7df779..e95e175f 100644
--- a/src/battery/lowbat-handler.c
+++ b/src/battery/lowbat-handler.c
@@ -151,7 +151,7 @@ static int power_execute(void)
FIND_DEVICE_INT(ops, POWER_OPS_NAME);
- return ops->execute(INTERNAL_PWROFF);
+ return ops->execute(POWER_POWEROFF);
}
static int booting_done(void *data)
@@ -244,7 +244,7 @@ static int battery_critical_low_act(void *data)
int battery_power_off_act(void *data)
{
- vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, VCONFKEY_SYSMAN_POWER_OFF_DIRECT);
+ power_execute();
return 0;
}
diff --git a/src/display/core.c b/src/display/core.c
index b56a2fff..1618e010 100644
--- a/src/display/core.c
+++ b/src/display/core.c
@@ -51,6 +51,7 @@
#include "core/edbus-handler.h"
#include "core/config-parser.h"
#include "extcon/extcon.h"
+#include "power/power-handler.h"
#include "dd-display.h"
#define PM_STATE_LOG_FILE "/var/log/pm_state.log"
@@ -1918,12 +1919,12 @@ static int update_setting(int key_idx, int val)
break;
case SETTING_POWEROFF:
switch (val) {
- case VCONFKEY_SYSMAN_POWER_OFF_NONE:
- case VCONFKEY_SYSMAN_POWER_OFF_POPUP:
+ case POWER_OFF_NONE:
+ case POWER_OFF_POPUP:
pm_status_flag &= ~PWROFF_FLAG;
break;
- case VCONFKEY_SYSMAN_POWER_OFF_DIRECT:
- case VCONFKEY_SYSMAN_POWER_OFF_RESTART:
+ case POWER_OFF_DIRECT:
+ case POWER_OFF_RESTART:
pm_status_flag |= PWROFF_FLAG;
break;
}
diff --git a/src/power/power-handler.c b/src/power/power-handler.c
index a208851e..3bda4c9d 100644
--- a/src/power/power-handler.c
+++ b/src/power/power-handler.c
@@ -36,6 +36,7 @@
#include "core/log.h"
#include "core/launch.h"
#include "core/device-notifier.h"
+#include "core/device-idler.h"
#include "core/common.h"
#include "core/devices.h"
#include "proc/proc-handler.h"
@@ -48,23 +49,20 @@
#define SIGNAL_NAME_POWEROFF_POPUP "poweroffpopup"
#define SIGNAL_BOOTING_DONE "BootingDone"
-#define POWEROFF_NOTI_NAME "power_off_start"
#define POWEROFF_DURATION 2
#define MAX_RETRY 2
-#define SYSTEMD_STOP_POWER_OFF 4
-
#define SIGNAL_POWEROFF_STATE "ChangeState"
#define UMOUNT_RW_PATH "/opt/usr"
-static void poweroff_control_cb(keynode_t *in_key, void *data);
-
static struct timeval tv_start_poweroff;
static int power_off = 0;
static const struct device_ops *telephony = NULL;
+static int power_execute(void *data);
+
static void telephony_init(void)
{
FIND_DEVICE_VOID(telephony, "telephony");
@@ -90,25 +88,6 @@ static int telephony_exit(void *data)
return ret;
}
-static int systemd_manager_object(const char *opt, char **param)
-{
- return dbus_method_async("org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- opt,
- "ss", param);
-}
-
-static int systemd_manager_object_start_unit(char **param)
-{
- return systemd_manager_object("StartUnit", param);
-}
-
-static int systemd_manager_object_stop_unit(char **param)
-{
- return systemd_manager_object("StopUnit", param);
-}
-
static void poweroff_start_animation(void)
{
char params[128];
@@ -151,7 +130,6 @@ static int poweroff(void)
retry_count++;
continue;
}
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void*)poweroff_control_cb);
return 0;
}
return -1;
@@ -168,7 +146,7 @@ static int pwroff_popup(void)
return 0;
}
-static int power_reboot(int type)
+static int power_reboot(void)
{
int ret;
@@ -184,40 +162,14 @@ static int power_reboot(int type)
gettimeofday(&tv_start_poweroff, NULL);
- if (type == SYSTEMD_STOP_POWER_RESTART_RECOVERY)
- ret = telephony_exit(POWER_RECOVERY);
- else if (type == SYSTEMD_STOP_POWER_RESTART_FOTA)
- ret = telephony_exit(POWER_FOTA);
- else
- ret = telephony_exit(POWER_REBOOT);
-
+ ret = telephony_exit(POWER_REBOOT);
if (ret < 0) {
- restart_ap(type);
+ restart_ap(NULL);
return 0;
}
return ret;
}
-static int power_execute(void *data)
-{
- int ret = 0;
-
- if (strncmp(POWER_POWEROFF, (char *)data, POWER_POWEROFF_LEN) == 0)
- ret = poweroff();
- else if (strncmp(PWROFF_POPUP, (char *)data, PWROFF_POPUP_LEN) == 0)
- ret = pwroff_popup();
- else if (strncmp(POWER_REBOOT, (char *)data, POWER_REBOOT_LEN) == 0)
- ret = power_reboot(VCONFKEY_SYSMAN_POWER_OFF_RESTART);
- else if (strncmp(POWER_RECOVERY, (char *)data, POWER_RECOVERY_LEN) == 0)
- ret = power_reboot(SYSTEMD_STOP_POWER_RESTART_RECOVERY);
- else if (strncmp(POWER_FOTA, (char *)data, POWER_FOTA_LEN) == 0)
- ret = power_reboot(SYSTEMD_STOP_POWER_RESTART_FOTA);
- else if (strncmp(INTERNAL_PWROFF, (char *)data, INTERNAL_PWROFF_LEN) == 0)
- ret = previous_poweroff();
-
- return ret;
-}
-
static void poweroff_popup_edbus_signal_handler(void *data, DBusMessage *msg)
{
DBusError err;
@@ -236,19 +188,7 @@ static void poweroff_popup_edbus_signal_handler(void *data, DBusMessage *msg)
return;
}
- if (!strncmp(str, PWROFF_POPUP, PWROFF_POPUP_LEN))
- val = VCONFKEY_SYSMAN_POWER_OFF_POPUP;
- else if (!strncmp(str, POWER_POWEROFF, POWER_POWEROFF_LEN))
- val = SYSTEMD_STOP_POWER_OFF;
- else if (!strncmp(str, POWER_REBOOT, POWER_REBOOT_LEN))
- val = SYSTEMD_STOP_POWER_RESTART;
- else if (!strncmp(str, POWER_FOTA, POWER_FOTA_LEN))
- val = SYSTEMD_STOP_POWER_RESTART_FOTA;
- if (val == 0) {
- _E("not supported message : %s", str);
- return;
- }
- vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, val);
+ power_execute(str);
}
static int booting_done(void *data)
@@ -307,52 +247,71 @@ static void poweroff_stop_systemd_service(void)
umount2("/sys/fs/cgroup", MNT_FORCE |MNT_DETACH);
}
-static void poweroff_control_cb(keynode_t *in_key, void *data)
+static int poweroff_idler_cb(void *data)
{
- int val;
+ enum poweroff_type val = (int)data;
int ret;
int recovery;
telephony_start();
- if (vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) != 0)
- return;
+ pm_lock_internal(INTERNAL_LOCK_POWEROFF, LCD_OFF, STAY_CUR_STATE, 0);
+ poweroff_stop_systemd_service();
- recovery = val;
-
- if (val == SYSTEMD_STOP_POWER_OFF ||
- val == SYSTEMD_STOP_POWER_RESTART ||
- val == SYSTEMD_STOP_POWER_RESTART_RECOVERY ||
- val == SYSTEMD_STOP_POWER_RESTART_FOTA) {
- pm_lock_internal(INTERNAL_LOCK_POWEROFF, LCD_OFF, STAY_CUR_STATE, 0);
- poweroff_stop_systemd_service();
- if (val == SYSTEMD_STOP_POWER_OFF)
- val = VCONFKEY_SYSMAN_POWER_OFF_DIRECT;
- else
- val = VCONFKEY_SYSMAN_POWER_OFF_RESTART;
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void*)poweroff_control_cb);
- vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, val);
+ if (val == POWER_OFF_DIRECT || val == POWER_OFF_RESTART) {
+ poweroff_send_broadcast(val);
+ device_notify(DEVICE_NOTIFIER_POWEROFF, &val);
}
- if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART)
- poweroff_send_broadcast(val);
+ /* TODO for notify. will be removed asap. */
+ vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, val);
switch (val) {
- case VCONFKEY_SYSMAN_POWER_OFF_DIRECT:
- device_notify(DEVICE_NOTIFIER_POWEROFF, &val);
+ case POWER_OFF_DIRECT:
poweroff();
break;
- case VCONFKEY_SYSMAN_POWER_OFF_POPUP:
+ case POWER_OFF_POPUP:
pwroff_popup();
break;
- case VCONFKEY_SYSMAN_POWER_OFF_RESTART:
- device_notify(DEVICE_NOTIFIER_POWEROFF, &val);
- power_reboot(recovery);
+ case POWER_OFF_RESTART:
+ power_reboot();
break;
}
if (update_pm_setting)
update_pm_setting(SETTING_POWEROFF, val);
+
+ return 0;
+}
+
+static int power_execute(void *data)
+{
+ int ret;
+ int val;
+
+ if (!data) {
+ _E("Invalid parameter : data(NULL)");
+ return -EINVAL;
+ }
+
+ if (strncmp(POWER_POWEROFF, (char *)data, POWER_POWEROFF_LEN) == 0)
+ val = POWER_OFF_DIRECT;
+ else if (strncmp(PWROFF_POPUP, (char *)data, PWROFF_POPUP_LEN) == 0)
+ val = POWER_OFF_POPUP;
+ else if (strncmp(POWER_REBOOT, (char *)data, POWER_REBOOT_LEN) == 0)
+ val = POWER_OFF_RESTART;
+ else {
+ _E("Invalid parameter : data(%s)", (char *)data);
+ return -EINVAL;
+ }
+
+ ret = add_idle_request(poweroff_idler_cb, (int*)val);
+ if (ret < 0) {
+ _E("fail to add poweroff idle request : %d", ret);
+ return ret;
+ }
+
+ return 0;
}
/* umount usr data partition */
@@ -407,7 +366,6 @@ static void powerdown(void)
}
/* if this fails, that's OK */
telephony_stop();
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void*)poweroff_control_cb);
power_off = 1;
sync();
@@ -434,16 +392,6 @@ static void powerdown(void)
#endif
}
-static void restart_by_mode(int mode)
-{
- if (mode == SYSTEMD_STOP_POWER_RESTART_RECOVERY)
- launch_evenif_exist("/usr/sbin/reboot", "recovery");
- else if (mode == SYSTEMD_STOP_POWER_RESTART_FOTA)
- launch_evenif_exist("/usr/sbin/reboot", "fota");
- else
- reboot(RB_AUTOBOOT);
-}
-
static DBusMessage *dbus_power_handler(E_DBus_Object *obj, DBusMessage *msg)
{
DBusError err;
@@ -477,14 +425,7 @@ static DBusMessage *dbus_power_handler(E_DBus_Object *obj, DBusMessage *msg)
goto out;
}
- telephony_start();
-
- if(!strncmp(type_str, POWER_REBOOT, POWER_REBOOT_LEN))
- ret = power_reboot(VCONFKEY_SYSMAN_POWER_OFF_RESTART);
- else if(!strncmp(type_str, POWER_RECOVERY, POWER_RECOVERY_LEN))
- ret = power_reboot(SYSTEMD_STOP_POWER_RESTART_RECOVERY);
- else if(!strncmp(type_str, PWROFF_POPUP, PWROFF_POPUP_LEN))
- ret = pwroff_popup();
+ ret = power_execute(type_str);
out:
reply = dbus_message_new_method_return(msg);
@@ -501,16 +442,15 @@ void powerdown_ap(void *data)
reboot(RB_POWER_OFF);
}
-void restart_ap(int data)
+void restart_ap(void *data)
{
- _I("Restart %d", data);
+ _I("Restart");
powerdown();
- restart_by_mode(data);
+ reboot(RB_AUTOBOOT);
}
static const struct edbus_method edbus_methods[] = {
{ POWER_REBOOT, "si", "i", dbus_power_handler },
- { POWER_RECOVERY, "si", "i", dbus_power_handler },
{ PWROFF_POPUP, "si", "i", dbus_power_handler },
/* Add methods here */
};
@@ -525,10 +465,6 @@ static void power_init(void *data)
if (ret < 0)
_E("fail to init edbus method(%d)", ret);
- if (vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (void *)poweroff_control_cb, NULL) < 0) {
- _E("Vconf notify key chaneged failed: KEY(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
- }
-
register_edbus_signal_handler(DEVICED_OBJECT_PATH, DEVICED_INTERFACE_NAME,
SIGNAL_NAME_POWEROFF_POPUP,
poweroff_popup_edbus_signal_handler);
diff --git a/src/power/power-handler.h b/src/power/power-handler.h
index 322c30bc..cb7af7ac 100644
--- a/src/power/power-handler.h
+++ b/src/power/power-handler.h
@@ -25,21 +25,18 @@
#define POWER_POWEROFF_LEN 8
#define POWER_REBOOT "reboot"
#define POWER_REBOOT_LEN 6
-#define POWER_RECOVERY "reboot-recovery"
-#define POWER_RECOVERY_LEN 15
-#define POWER_FOTA "fota"
-#define POWER_FOTA_LEN 4
#define PWROFF_POPUP "pwroff-popup"
#define PWROFF_POPUP_LEN 12
-#define INTERNAL_PWROFF "internal"
-#define INTERNAL_PWROFF_LEN 8
-#define SYSTEMD_STOP_POWER_RESTART 5
-#define SYSTEMD_STOP_POWER_RESTART_RECOVERY 6
-#define SYSTEMD_STOP_POWER_RESTART_FOTA 7
+enum poweroff_type {
+ POWER_OFF_NONE = 0,
+ POWER_OFF_POPUP,
+ POWER_OFF_DIRECT,
+ POWER_OFF_RESTART,
+};
#ifndef SYSTEMD_SHUTDOWN
-void restart_ap(int data);
+void restart_ap(void *data);
void powerdown_ap(void *data);
#endif
diff --git a/src/telephony/telephony.c b/src/telephony/telephony.c
index a01bb72c..464fae14 100644
--- a/src/telephony/telephony.c
+++ b/src/telephony/telephony.c
@@ -43,7 +43,6 @@
static TapiHandle *tapi_handle = NULL;
static Ecore_Timer *poweroff_timer_id = NULL;
-static int reboot_opt;
static Eina_Bool telephony_powerdown_ap_internal(void *data)
{
@@ -57,7 +56,7 @@ static void telephony_powerdown_ap(TapiHandle *handle, const char *noti_id, void
static void telephony_restart_ap(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- restart_ap(reboot_opt);
+ restart_ap(data);
}
static Eina_Bool telephony_restart_ap_by_force(void *data)
@@ -152,37 +151,29 @@ static void telephony_exit(void *data)
return;
}
- if (strncmp(data, POWER_REBOOT, POWER_REBOOT_LEN) &&
- strncmp(data, POWER_RECOVERY, POWER_RECOVERY_LEN) &&
- strncmp(data, POWER_FOTA, POWER_FOTA_LEN)) {
+ if (strncmp(data, POWER_REBOOT, POWER_REBOOT_LEN)) {
_E("Fail %s", data);
return;
}
_I("Option: %s", data);
- if (!strncmp(data, POWER_RECOVERY, POWER_RECOVERY_LEN))
- reboot_opt = SYSTEMD_STOP_POWER_RESTART_RECOVERY;
- else if (!strncmp(data, POWER_REBOOT, POWER_REBOOT_LEN))
- reboot_opt = SYSTEMD_STOP_POWER_RESTART;
- else if (!strncmp(data, POWER_FOTA, POWER_FOTA_LEN))
- reboot_opt = SYSTEMD_STOP_POWER_RESTART_FOTA;
ret = tel_register_noti_event(tapi_handle, TAPI_NOTI_MODEM_POWER,
telephony_restart_ap, NULL);
if (ret != TAPI_API_SUCCESS) {
_E("tel_register_event is not subscribed. error %d", ret);
- telephony_restart_ap_by_force((void *)POWER_RESTART);
+ telephony_restart_ap_by_force(NULL);
return;
}
ret = tel_process_power_command(tapi_handle, TAPI_PHONE_POWER_OFF,
powerdown_res_cb, NULL);
if (ret != TAPI_API_SUCCESS) {
_E("tel_process_power_command() error %d", ret);
- telephony_restart_ap_by_force((void *)reboot_opt);
+ telephony_restart_ap_by_force(NULL);
return;
}
poweroff_timer_id = ecore_timer_add(15,telephony_restart_ap_by_force,
- (void *)reboot_opt);
+ NULL);
}
static void telephony_flight_mode_on(TapiHandle *handle, int result, void *data, void *user_data)