From caff30dc3147865452d0300a3a468343191714ef Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Wed, 27 Feb 2019 11:31:45 +0900 Subject: [PATCH] power: remove duplicated dbus methods Change-Id: Ib4b1b94559cf702a1f6823414a5379861146cb8e Signed-off-by: sanghyeok.oh --- conf/org.tizen.system.deviced.conf | 2 +- src/auto-test/power.c | 30 +++++++++++------------------- src/devicectl/devicectl.c | 2 +- src/libdeviced/deviced-noti.c | 8 ++++---- src/power/power-handler.c | 33 +++++---------------------------- 5 files changed, 22 insertions(+), 53 deletions(-) diff --git a/conf/org.tizen.system.deviced.conf b/conf/org.tizen.system.deviced.conf index f8c03e0..49877ee 100644 --- a/conf/org.tizen.system.deviced.conf +++ b/conf/org.tizen.system.deviced.conf @@ -33,7 +33,7 @@ privilege="http://tizen.org/privilege/display"/> - diff --git a/src/auto-test/power.c b/src/auto-test/power.c index 6f0eeef..a2c2a78 100644 --- a/src/auto-test/power.c +++ b/src/auto-test/power.c @@ -17,13 +17,12 @@ */ #include "test.h" -#define METHOD_REBOOT "reboot" -#define METHOD_REBOOTWITHOPTION "RebootWithOption" -#define METHOD_REBOOT2 "Reboot" +#define METHOD_POWEROFF "Poweroff" +#define METHOD_POWEROFF_WITH_OPTION "PoweroffWithOption" -#define METHOD_LOWPOWER_START "Start" -#define METHOD_LOWPOWER_STOP "Stop" -#define METHOD_LOWPOWER_GETSTATE "GetState" +#define METHOD_LOWPOWER_START "Start" +#define METHOD_LOWPOWER_STOP "Stop" +#define METHOD_LOWPOWER_GETSTATE "GetState" static bool set_reboot_method(const char *method, GVariant *param) { @@ -32,8 +31,8 @@ static bool set_reboot_method(const char *method, GVariant *param) bool ret = FALSE; msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_REBOOT, - DEVICED_INTERFACE_REBOOT, + DEVICED_PATH_POWEROFF, + DEVICED_INTERFACE_POWEROFF, method, param); if (!msg) { @@ -61,17 +60,12 @@ static bool set_reboot_method(const char *method, GVariant *param) static bool set_reboot(char *type) { - return set_reboot_method(METHOD_REBOOT, g_variant_new("(si)", type, 0)); + return set_reboot_method(METHOD_POWEROFF, g_variant_new("(s)", type)); } static bool set_reboot_with_option(char *type, char *option) { - return set_reboot_method(METHOD_REBOOTWITHOPTION, g_variant_new("(ss)", type, option)); -} - -static bool set_Reboot() -{ - return set_reboot_method(METHOD_REBOOT2, g_variant_new("(s)", "not_used")); + return set_reboot_method(METHOD_POWEROFF_WITH_OPTION, g_variant_new("(ss)", type, option)); } static bool request_lowpower_method(const char *method, GVariant *param) @@ -171,12 +165,10 @@ static int power_unit(int argc, char **argv) _I("start test"); lowpower_test_all(&success, &fail); _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); - } else if (0 == strcmp(argv[3], METHOD_REBOOT)) + } else if (0 == strcmp(argv[3], METHOD_POWEROFF)) set_reboot(argv[4]); - else if (0 == strcasecmp(argv[3], METHOD_REBOOTWITHOPTION)) + else if (0 == strcasecmp(argv[3], METHOD_POWEROFF_WITH_OPTION)) set_reboot_with_option(argv[4], argv[5]); - else if (0 == strcmp(argv[3], METHOD_REBOOT2)) - set_Reboot(); else if (0 == strcasecmp(argv[3], "lowpower")) { if (0 == strcasecmp(argv[4], METHOD_LOWPOWER_START)) set_lowpower_start(); diff --git a/src/devicectl/devicectl.c b/src/devicectl/devicectl.c index 4b820d5..04d5093 100644 --- a/src/devicectl/devicectl.c +++ b/src/devicectl/devicectl.c @@ -57,7 +57,7 @@ static const struct device { { DEVICE_PASS, "pass", DEVICED_PATH_PASS, DEVICED_INTERFACE_PASS }, { DEVICE_USB, "usb", DEVICED_PATH_USB, DEVICED_INTERFACE_USB }, { DEVICE_EXTCON, "extcon", DEVICED_PATH_EXTCON, DEVICED_INTERFACE_EXTCON }, - { DEVICE_POWER, "power", DEVICED_PATH_REBOOT, DEVICED_INTERFACE_REBOOT }, + { DEVICE_POWER, "power", DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF }, { DEVICE_USB_HOST_TEST, "usb-host-test", DEVICED_PATH_USB_HOST_TEST, DEVICED_INTERFACE_USB_HOST_TEST}, }; diff --git a/src/libdeviced/deviced-noti.c b/src/libdeviced/deviced-noti.c index 5741fe6..f02f5e8 100644 --- a/src/libdeviced/deviced-noti.c +++ b/src/libdeviced/deviced-noti.c @@ -114,10 +114,10 @@ static int dbus_power_handler(char* type) int val; msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, - DEVICED_PATH_REBOOT, - DEVICED_INTERFACE_REBOOT, - type, - g_variant_new("(si)", type, 0)); + DEVICED_PATH_POWEROFF, + DEVICED_INTERFACE_POWEROFF, + "Poweroff", + g_variant_new("(s)", type)); if (!msg) return -EBADMSG; diff --git a/src/power/power-handler.c b/src/power/power-handler.c index b4f3581..e07f18f 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -544,7 +544,7 @@ static GVariant *dbus_power_handler(GDBusConnection *conn, int ret; char *type_str; - g_variant_get(param, "(si)", &type_str, NULL); + g_variant_get(param, "(s)", &type_str); ret = check_sender_process(conn, sender); if (ret < 0) @@ -580,27 +580,6 @@ out: return g_variant_new("(i)", ret); } -static GVariant *request_reboot(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) -{ - char *str; - int ret; - - g_variant_get(param, "(s)", &str); - - ret = check_sender_process(conn, sender); - if (ret < 0) - goto out; - - _I("Poweroff PID(%d) requests reboot with command(%s).", ret, str); - ret = power_execute_pid(POWER_REBOOT, NULL); - -out: - g_free(str); - return g_variant_new("(i)", ret); -} - static GVariant *add_poweroff_time(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) @@ -689,10 +668,9 @@ out: } static const dbus_method_s dbus_methods[] = { - { POWER_REBOOT, "si", "i", dbus_power_handler }, - { "RebootWithOption", "ss", "i", dbus_power_option_handler }, + { "Poweroff", "s", "i", dbus_power_handler }, + { "PoweroffWithOption", "ss", "i", dbus_power_option_handler }, /* Public API device_power_reboot() calls this dbus method. */ - { "Reboot", "s", "i", request_reboot }, { "AddPoweroffWait", NULL, "i", add_poweroff_time }, { "RemovePoweroffWait", NULL, "i", remove_poweroff_time }, /* Add methods here */ @@ -700,7 +678,7 @@ static const dbus_method_s dbus_methods[] = { static const dbus_interface_u dbus_interface = { .oh = NULL, - .name = DEVICED_INTERFACE_REBOOT, + .name = DEVICED_INTERFACE_POWEROFF, .methods = dbus_methods, .nr_methods = ARRAY_SIZE(dbus_methods), }; @@ -773,7 +751,7 @@ static void power_init(void *data) int ret; /* init dbus interface */ - ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_REBOOT, &dbus_interface); + ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_POWEROFF, &dbus_interface); if (ret < 0) _E("Failed to init dbus method: %d", ret); @@ -784,7 +762,6 @@ static void power_init(void *data) add_poweroff_option(POWEROFF_TYPE_POWEROFF, NULL); add_poweroff_option(POWEROFF_TYPE_RESTART, NULL); add_poweroff_option(POWEROFF_TYPE_POPUP, NULL); - add_poweroff_option(POWEROFF_TYPE_RESTART, NULL); ret = config_parse(POWER_CONF_FILE, load_config, NULL); if (ret < 0) -- 2.7.4