Add internal api for power off 77/250377/4 accepted/tizen/unified/20201228.130118 submit/tizen/20201224.060832
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 24 Dec 2020 04:08:55 +0000 (13:08 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 24 Dec 2020 05:12:45 +0000 (14:12 +0900)
Change-Id: I85be084f3b566c68ea44593a757bd664a08bbc3b
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
include/power-internal.h [new file with mode: 0644]
src/power.c

diff --git a/include/power-internal.h b/include/power-internal.h
new file mode 100644 (file)
index 0000000..294c765
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2020 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_SYSTEM_POWER_INTERNAL_H__
+#define __TIZEN_SYSTEM_POWER_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @platform
+ * @brief Power off the device.
+ * @details It operates synchronously.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/reboot
+ * @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_poweroff(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 0830c9a..2d62928 100644 (file)
@@ -26,6 +26,7 @@
 #include <libsyscommon/dbus-system.h>
 
 #include "power.h"
+#include "power-internal.h"
 #include "display.h"
 #include "common.h"
 
@@ -50,6 +51,7 @@
 #define METHOD_POWEROFF             "PowerOff"
 #define METHOD_POWEROFF_WITH_OPTION "PowerOffWithOption"
 
+#define TYPE_POWEROFF           "poweroff"
 #define TYPE_REBOOT             "reboot"
 #define REBOOT_REASON_NONE      ""
 
@@ -536,6 +538,17 @@ int device_power_reboot(const char *reason)
                        method, param);
        return errno_to_device_error(ret);
 }
+
+int device_power_poweroff(void)
+{
+       int ret;
+
+       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
+                       DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF,
+                       METHOD_POWEROFF, g_variant_new("(s)", TYPE_POWEROFF));
+
+       return errno_to_device_error(ret);
+}
 //LCOV_EXCL_STOP
 
 static int power_load_config(struct parse_result *result, void *data)