power: fix to deliver reboot parameter 16/108416/1 accepted/tizen/3.0/common/20170109.195441 accepted/tizen/3.0/ivi/20170105.231855 accepted/tizen/3.0/mobile/20170105.231802 accepted/tizen/3.0/tv/20170105.231820 accepted/tizen/3.0/wearable/20170105.231837 submit/tizen_3.0/20170105.022920
authortaeyoung <ty317.kim@samsung.com>
Wed, 4 Jan 2017 08:24:47 +0000 (17:24 +0900)
committertaeyoung <ty317.kim@samsung.com>
Wed, 4 Jan 2017 08:24:47 +0000 (17:24 +0900)
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 <ty317.kim@samsung.com>
src/power.c

index 1502a99..7e7cc30 100644 (file)
 #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