From 143a49ecd8a5063ba7e1b935d40f384e80b9bd50 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Fri, 22 May 2015 13:35:21 +0900 Subject: [PATCH] capi-system-device: Add reboot API Reboot api request to deviced with command string. It only valids with reboot privilege. Change-Id: I3fcf252ad64b1256c9787f04f2fbda7470d281b8 Signed-off-by: Jiyoung Yun --- include/power.h | 22 ++++++++++++++++++++++ src/dbus.h | 4 ++++ src/power.c | 19 ++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/include/power.h b/include/power.h index 7e1f9a3..a461188 100755 --- a/include/power.h +++ b/include/power.h @@ -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); + +/** * @} */ diff --git a/src/dbus.h b/src/dbus.h index 1e3fead..0beac19 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -42,6 +42,10 @@ #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[]); diff --git a/src/power.c b/src/power.c index 8fc1831..b7a0f37 100644 --- a/src/power.c +++ b/src/power.c @@ -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); +} -- 2.7.4