From 658304812b605e8f8cf224675078a92f4cd90756 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Wed, 4 Jan 2017 17:24:47 +0900 Subject: [PATCH] power: fix to deliver reboot parameter Previously, device_power_reboot() returns error if reboot parameter is NULL. Thus it is fixed by handling NULL input. Change-Id: Idcb6a5f4d0b41803cd6d60c4ec2be185675f0e83 Signed-off-by: taeyoung --- src/power.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/power.c b/src/power.c index 1502a99..7e7cc30 100644 --- a/src/power.c +++ b/src/power.c @@ -50,6 +50,10 @@ #define METHOD_UNLOCK_STATE "unlockstate" #define METHOD_CHANGE_STATE "changestate" #define METHOD_REBOOT "Reboot" +#define METHOD_REBOOT_WITH_OPTION "RebootWithOption" + +#define TYPE_REBOOT "reboot" +#define REBOOT_REASON_NONE "" #define STR_STAYCURSTATE "staycurstate" #define STR_GOTOSTATENOW "gotostatenow" @@ -466,17 +470,25 @@ int device_power_wakeup(bool dim) //LCOV_EXCL_START Not available to test(Reboot during TCT) int device_power_reboot(const char *reason) { - char *arr[1]; + char *arr[2]; + char *method, *sig; int ret; - if (!reason) - return DEVICE_ERROR_INVALID_PARAMETER; + if (reason) { + arr[0] = TYPE_REBOOT; + arr[1] = (char *)reason; + method = METHOD_REBOOT_WITH_OPTION; + sig = "ss"; + } else { + arr[0] = REBOOT_REASON_NONE; + method = METHOD_REBOOT; + sig = "s"; + } - arr[0] = (char *)reason; ret = dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, - METHOD_REBOOT, "s", arr); + method, sig, arr); return errno_to_device_error(ret); } //LCOV_EXCL_STOP -- 2.7.4