From 1150b20f4eb31f1dbdf74914da95e6ec8da18d70 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 24 Dec 2020 13:08:55 +0900 Subject: [PATCH] Add internal api for power off Change-Id: I85be084f3b566c68ea44593a757bd664a08bbc3b Signed-off-by: lokilee73 --- include/power-internal.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/power.c | 13 +++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 include/power-internal.h diff --git a/include/power-internal.h b/include/power-internal.h new file mode 100644 index 0000000..294c765 --- /dev/null +++ b/include/power-internal.h @@ -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 diff --git a/src/power.c b/src/power.c index 0830c9a..2d62928 100644 --- a/src/power.c +++ b/src/power.c @@ -26,6 +26,7 @@ #include #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) -- 2.7.4