capi-system-device: Add reboot API 57/39757/1
authorJiyoung Yun <jy910.yun@samsung.com>
Fri, 22 May 2015 04:35:21 +0000 (13:35 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Fri, 22 May 2015 04:35:21 +0000 (13:35 +0900)
Reboot api request to deviced with command string.
It only valids with reboot privilege.

Change-Id: I3fcf252ad64b1256c9787f04f2fbda7470d281b8
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
include/power.h
src/dbus.h
src/power.c

index 7e1f9a3..a461188 100755 (executable)
@@ -124,6 +124,28 @@ int device_power_release_lock(power_lock_e type);
 int device_power_wakeup(bool dim);
 
 /**
+ * @platform
+ * @brief Reboots the device.
+ * @details Will not return if the reboot is successful. \n
+ *          It operates asynchronously.
+ *
+ * @since_tizen 2.3.1
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/reboot
+ *
+ * @param[in] reason Pass to the platform and kernel to request special reboot reason, or null.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #DEVICE_ERROR_NONE               Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #DEVICE_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #DEVICE_ERROR_OPERATION_FAILED   Operation failed
+ */
+int device_power_reboot(const char *reason);
+
+/**
  * @}
  */
 
index 1e3fead..0beac19 100644 (file)
 #define DEVICED_PATH_LED                    DEVICED_OBJECT_PATH"/Led"
 #define DEVICED_INTERFACE_LED               DEVICED_INTERFACE_NAME".Led"
 
+/* Power service: request to reboot */
+#define DEVICED_PATH_POWER                  DEVICED_OBJECT_PATH"/Power"
+#define DEVICED_INTERFACE_POWER             DEVICED_INTERFACE_NAME".power"
+
 int dbus_method_sync(const char *dest, const char *path,
                const char *interface, const char *method,
                const char *sig, char *param[]);
index 8fc1831..b7a0f37 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@
 #define METHOD_LOCK_STATE       "lockstate"
 #define METHOD_UNLOCK_STATE     "unlockstate"
 #define METHOD_CHANGE_STATE     "changestate"
+#define METHOD_REBOOT           "Reboot"
 
 #define STR_STAYCURSTATE "staycurstate"
 #define STR_GOTOSTATENOW "gotostatenow"
@@ -215,3 +216,19 @@ int device_power_wakeup(bool dim)
 
        return device_display_change_state(DISPLAY_STATE_NORMAL);
 }
+
+int device_power_reboot(const char *reason)
+{
+       char *arr[1];
+       int ret;
+
+       if (!reason)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
+       arr[0] = (char *)reason;
+       ret = dbus_method_sync(DEVICED_BUS_NAME,
+                       DEVICED_PATH_POWER,
+                       DEVICED_INTERFACE_POWER,
+                       METHOD_REBOOT, "s", arr);
+       return errno_to_device_error(ret);
+}