From 507d681c37d91c8f31d3f5150c2dbcfde6641560 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 16 Jan 2017 16:27:12 +0900 Subject: [PATCH] pass: Remove unused code and modify the prefix for pass The pass is developed based on deviced source. There are the specific features and codes for deviced. This patch removes the unused features and if there is the used feature for pass, this patch modifies the naming prefix for pass. Change-Id: Id078a9070e30b2a1ee87e374bbceaf731ebc7036 Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 49 ++- CREDITS | 10 +- packaging/libpass.manifest | 5 + packaging/pass.spec | 44 +-- src/apps/apps.c | 116 -------- src/apps/apps.h | 35 --- src/control/control.c | 227 -------------- src/core/boot.c | 8 +- src/core/boot.h | 10 +- src/core/common.c | 231 +-------------- src/core/common.h | 4 +- src/core/config-parser.c | 4 +- src/core/config-parser.h | 4 +- src/core/device-idler.c | 4 +- src/core/device-idler.h | 4 +- src/core/device-notifier.c | 4 +- src/core/device-notifier.h | 24 +- src/core/devices.c | 4 +- src/core/devices.h | 16 +- src/core/edbus-handler.c | 21 +- src/core/edbus-handler.h | 4 +- src/core/execute.c | 4 +- src/core/launch.c | 338 --------------------- src/core/launch.h | 32 -- src/core/list.h | 4 +- src/core/log.c | 4 +- src/core/log.h | 6 +- src/core/main.c | 12 +- src/core/sig-handler.c | 2 +- src/core/udev.c | 4 +- src/core/udev.h | 50 +--- src/deviced/dd-common.h | 39 --- src/deviced/dd-control.h | 103 ------- src/deviced/dd-deviced-managed.h | 65 ---- src/deviced/dd-deviced.h | 362 ----------------------- src/deviced/deviced_doc.h | 42 --- src/pass/pass-core.c | 12 +- src/pass/pass-core.h | 4 +- src/pass/pass-gov-radiation.c | 4 +- src/pass/pass-gov-step.c | 4 +- src/pass/pass-gov.h | 4 +- src/pass/pass-plugin.c | 4 +- src/pass/pass-plugin.h | 4 +- src/pass/pass-pmqos.c | 4 +- src/pass/pass-pmqos.h | 2 +- src/pass/pass-util.h | 4 +- src/pass/pass.c | 4 +- src/pass/pass.conf | 4 +- src/pass/pass.h | 4 +- src/pmqos/pmqos-parser.c | 2 +- src/pmqos/pmqos.c | 7 +- src/pmqos/pmqos.h | 4 +- src/proc/cpu-info.c | 155 ---------- src/proc/proc-handler.c | 217 -------------- src/shared/CMakeLists.txt | 1 - src/shared/common.h | 4 +- src/shared/dbus.c | 6 +- src/shared/dbus.h | 177 +---------- src/shared/deviced-internal.h | 38 --- src/shared/deviced-priv.h | 4 +- src/shared/deviced-systemd.h | 62 ---- src/shared/log-macro.h | 4 +- src/shared/log.h | 8 +- src/shared/{deviced-systemd.c => pass-systemd.c} | 76 ++--- src/shared/pass-systemd.h | 62 ++++ src/shared/score-defines.h | 4 +- 66 files changed, 244 insertions(+), 2540 deletions(-) create mode 100644 packaging/libpass.manifest delete mode 100755 src/apps/apps.c delete mode 100755 src/apps/apps.h delete mode 100644 src/control/control.c delete mode 100644 src/core/launch.c delete mode 100644 src/core/launch.h delete mode 100644 src/deviced/dd-common.h delete mode 100644 src/deviced/dd-control.h delete mode 100644 src/deviced/dd-deviced-managed.h delete mode 100644 src/deviced/dd-deviced.h delete mode 100644 src/deviced/deviced_doc.h delete mode 100644 src/proc/cpu-info.c delete mode 100644 src/proc/proc-handler.c delete mode 100644 src/shared/deviced-internal.h delete mode 100644 src/shared/deviced-systemd.h rename src/shared/{deviced-systemd.c => pass-systemd.c} (74%) create mode 100644 src/shared/pass-systemd.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f3eab29..dbaad06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ ELSEIF("${ARCH_BIT}" STREQUAL "64") ENDIF() ######################################################## -# Deviced Macros +# PASS Macros ######################################################## MACRO(ADD_SOURCE DIR OUT) @@ -45,13 +45,13 @@ MACRO(INSTALL_CONF DIR CONF) ENDIF() IF(DEFINED T_CONF) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${T_CONF} - DESTINATION /etc/deviced + DESTINATION /etc/pass RENAME ${CONF}.conf) ENDIF() ENDMACRO() ######################################################## -# Deviced CMakeLists.txt +# PASS CMakeLists.txt ######################################################## SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}/bin") @@ -61,38 +61,32 @@ SET(CONFDIR "/etc/${PROJECT_NAME}") SET(VERSION 0.1.0) SET(SRCS - src/apps/apps.c - src/control/control.c + src/pass/pass.c + src/pass/pass-core.c + src/pass/pass-gov-radiation.c + src/pass/pass-gov-step.c + src/pass/pass-parser.c + src/pass/pass-plugin.c + src/pass/pass-pmqos.c + src/pmqos/pmqos.c + src/pmqos/pmqos-parser.c + src/shared/pass-systemd.c src/core/common.c src/core/config-parser.c src/core/device-idler.c src/core/device-notifier.c src/core/devices.c src/core/edbus-handler.c - src/core/execute.c - src/core/launch.c src/core/log.c src/core/main.c src/core/sig-handler.c src/core/udev.c src/core/boot.c - src/proc/cpu-info.c - src/proc/proc-handler.c ) -IF(PASS_MODULE STREQUAL on) - ADD_SOURCE(src/pass PASS_SRCS) - SET(SRCS ${SRCS} ${PASS_SRCS}) -ENDIF() - -IF(PMQOS_MODULE STREQUAL on) - ADD_SOURCE(src/pmqos PMQOS_SRCS) - SET(SRCS ${SRCS} ${PMQOS_SRCS}) -ENDIF() - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/deviced) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/pass) SET(PKG_MODULES ecore @@ -107,7 +101,6 @@ SET(PKG_MODULES gio-2.0 eventsystem libtzplatform-config - hwcommon mount ) @@ -126,8 +119,8 @@ SET(CMAKE_EXE_LINKER_FLAGS "-pie") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") ADD_DEFINITIONS("-DLIBPATH=\"${LIB_INSTALL_DIR}\"") -ADD_DEFINITIONS("-DENABLE_DEVICED_DLOG") -ADD_DEFINITIONS("-DENABLE_LIBDEVICED_DLOG") +ADD_DEFINITIONS("-DENABLE_PASS_DLOG") +ADD_DEFINITIONS("-DENABLE_LIBPASS_DLOG") ADD_DEFINITIONS("-DENABLE_PM_LOG") IF(ENGINEER_MODE STREQUAL on) ADD_DEFINITIONS("-DENGINEER_MODE") @@ -151,16 +144,16 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl" "-lm" shared) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) -INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/deviced/ DESTINATION include/${PROJECT_NAME} +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*_doc.h" EXCLUDE PATTERN "*.h") INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${PROJECT_NAME}.conf DESTINATION /etc/dbus-1/system.d) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/pass.conf DESTINATION /etc/deviced) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/pass-cluster0.conf DESTINATION /etc/deviced) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/pass-cluster1.conf DESTINATION /etc/deviced) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pmqos/pmqos.conf DESTINATION /etc/deviced) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/pass.conf DESTINATION /etc/pass) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/pass-cluster0.conf DESTINATION /etc/pass) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/pass-cluster1.conf DESTINATION /etc/pass) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pmqos/pmqos.conf DESTINATION /etc/pass) CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) diff --git a/CREDITS b/CREDITS index c06cb19..d54df9c 100644 --- a/CREDITS +++ b/CREDITS @@ -1,4 +1,4 @@ -Thanks to the follow people for contributing to deviced by reporting +Thanks to the follow people for contributing to PASS by reporting bugs, providing fixes, providing information, providing resources or porting to new systems: @@ -6,10 +6,4 @@ The names are sorted alphabetically by last name. Names taken from sources and from version control system. ChanWoo Choi -Byung-Soo Kim -Taeyoung Kim -Gi-Yeol Ok -Kyungmin Park -SeungHun Pi -Juho Son -Jiyoung Yun +Wook Song diff --git a/packaging/libpass.manifest b/packaging/libpass.manifest new file mode 100644 index 0000000..97e8c31 --- /dev/null +++ b/packaging/libpass.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/pass.spec b/packaging/pass.spec index 4ba0766..ba24cf2 100644 --- a/packaging/pass.spec +++ b/packaging/pass.spec @@ -1,19 +1,6 @@ -#These options are DEACTIVATED by default. -%bcond_with x -%bcond_with wayland -%bcond_with emulator - %define _unpackaged_files_terminate_build 0 %define daemon_name pass -%define libdaemon_name lib%{daemon_name} - -# display, extcon, power, usb are always enable - -# Support two pattern combination vibration -%define standard_mix off -%define pass_module on -%define pmqos_module on %if "%{?profile}" == "mobile" %endif @@ -27,10 +14,10 @@ %endif Name: %{daemon_name} -Summary: PASS +Summary: Power Aware System Service Version: 0.0.1 Release: 1 -Group: System/Management +Group: System/Kernel License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest @@ -51,10 +38,6 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(eventsystem) BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(hwcommon) -#Requires: %{name}-tools = %{version}-%{release} -%{?systemd_requires} -Requires(post): /usr/bin/vconftool %description PASS (Power-Aware System Service) @@ -84,14 +67,6 @@ PASS systemd daemon. %define ARCH_BIT 64 %endif -%define DPMS none -%if %{with x} -%define DPMS x -%endif -%if %{with wayland} -%define DPMS wayland -%endif - %if 0%{?tizen_build_devel_mode} == 1 %define engineer_mode on %else @@ -103,12 +78,8 @@ PASS systemd daemon. -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DARCH=%{ARCH} \ -DARCH_BIT=%{ARCH_BIT} \ - -DDPMS=%{DPMS} \ -DENGINEER_MODE=%{engineer_mode} \ -DPROFILE=%{profile} \ - -DSTANDARD_MIX=%{standard_mix} \ - -DPASS_MODULE=%{pass_module} \ - -DPMQOS_MODULE=%{pmqos_module} \ #eol %build @@ -123,8 +94,6 @@ rm -rf %{buildroot} %install_service sockets.target.wants %{daemon_name}.socket %post -#memory type vconf key init -users_gid=$(getent group %{TZ_SYS_USER_GROUP} | cut -f3 -d':') systemctl daemon-reload if [ "$1" == "1" ]; then @@ -142,11 +111,10 @@ systemctl daemon-reload %files -n %{daemon_name} %manifest %{name}.manifest %license LICENSE -%config %{_sysconfdir}/dbus-1/system.d/%{daemon_name}.conf -%config %{_sysconfdir}/deviced/pass.conf -%config %{_sysconfdir}/deviced/pass-cluster0.conf -%config %{_sysconfdir}/deviced/pass-cluster1.conf -%config %{_sysconfdir}/deviced/pmqos.conf +%config %{_sysconfdir}/pass/pass.conf +%config %{_sysconfdir}/pass/pass-cluster0.conf +%config %{_sysconfdir}/pass/pass-cluster1.conf +%config %{_sysconfdir}/pass/pmqos.conf %{_bindir}/%{daemon_name} %{_unitdir}/multi-user.target.wants/%{daemon_name}.service %{_unitdir}/sockets.target.wants/%{daemon_name}.socket diff --git a/src/apps/apps.c b/src/apps/apps.c deleted file mode 100755 index 3e2433b..0000000 --- a/src/apps/apps.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. - * - * 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. - */ - -#include -#include "core/log.h" -#include "core/common.h" -#include "apps.h" -#include "core/edbus-handler.h" - -#define POPUP_METHOD "PopupLaunch" - -static const struct app_dbus_match { - const char *type; - const char *bus; - const char *path; - const char *iface; - const char *method; -} app_match[] = { - { APP_DEFAULT , POPUP_BUS_NAME, POPUP_PATH_SYSTEM , POPUP_INTERFACE_SYSTEM , POPUP_METHOD }, - { APP_POWERKEY, POPUP_BUS_NAME, POPUP_PATH_POWERKEY, POPUP_INTERFACE_POWERKEY, POPUP_METHOD }, -}; - -int launch_system_app(char *type, int num, ...) -{ - char *app_type; - va_list args; - int i, match, ret; - - if (type) - app_type = type; - else - app_type = APP_DEFAULT; - - match = -1; - for (i = 0 ; i < ARRAY_SIZE(app_match) ; i++) { - if (strncmp(app_type, app_match[i].type, strlen(app_type))) - continue; - match = i; - break; - } - if (match < 0) { - _E("Failed to find app matched (%s)", app_type); - return -EINVAL; - } - - va_start(args, num); - - ret = dbus_method_sync_pairs(app_match[match].bus, - app_match[match].path, - app_match[match].iface, - app_match[match].method, - num, args); - - va_end(args); - - return ret; -} - -int launch_message_post(char *type) -{ - char *param[1]; - - if (!type) - return -EINVAL; - - param[0] = type; - - return dbus_method_sync(POPUP_BUS_NAME, - POPUP_PATH_NOTI, - POPUP_INTERFACE_NOTI, - "MessagePostOn", - "s", param); -} - -int add_notification(char *type) -{ - if (!type) - return -EINVAL; - - return dbus_method_sync(POPUP_BUS_NAME, - POPUP_PATH_NOTI, - POPUP_INTERFACE_NOTI, - type, NULL, NULL); -} - -int remove_notification(char *type, int id) -{ - char *param[1]; - char id_str[16]; - - if (!type || id < 0) - return -EINVAL; - - snprintf(id_str, sizeof(id_str), "%d", id); - param[0] = id_str; - - return dbus_method_sync(POPUP_BUS_NAME, - POPUP_PATH_NOTI, - POPUP_INTERFACE_NOTI, - type, "i", param); -} diff --git a/src/apps/apps.h b/src/apps/apps.h deleted file mode 100755 index 2d7b35a..0000000 --- a/src/apps/apps.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. - * - * 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 __APPS_H__ -#define __APPS_H__ - - -#include "core/edbus-handler.h" -#include "core/common.h" - -#define APP_POWERKEY "powerkey" -#define APP_DEFAULT "system" -#define APP_KEY_TYPE "_SYSPOPUP_CONTENT_" - -int launch_system_app(char *type, int num, ...); -int launch_message_post(char *type); -int add_notification(char *type); -int remove_notification(char *type, int id); - -#endif /* __APPS_H__ */ diff --git a/src/control/control.c b/src/control/control.c deleted file mode 100644 index ffc09d2..0000000 --- a/src/control/control.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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. - */ - - -#include -#include -#include -#include -#include - -#include "core/log.h" -#include "core/common.h" -#include "core/devices.h" -#include "core/edbus-handler.h" - -#define CONTROL_HANDLER_NAME "control" -#define CONTROL_GETTER_NAME "getcontrol" - -static const struct control_device { - const int id; - const char *name; -} devices[] = { - /* Add id & ops to provide start/stop control */ - { DEVICE_CONTROL_MMC, "mmc" }, - { DEVICE_CONTROL_USBCLIENT, "usbclient" }, - { DEVICE_CONTROL_BLOCK, "block" }, -}; - -static int control_handler(int argc, char **argv) -{ - int i; - int pid; - int device; - bool enable; - int ret; - const struct device_ops *dev_ops = NULL; - - _I("argc : %d", argc); - for (i = 0; i < argc; ++i) - _I("[%2d] %s", i, argv[i]); - - if (argc > 5) { - _E("Invalid argument"); - errno = EINVAL; - return -1; - } - - pid = atoi(argv[0]); - device = atoi(argv[1]); - enable = atoi(argv[2]); - _I("pid : %d, device : %d, enable :%d", pid, device, enable); - - for (i = 0; i < ARRAY_SIZE(devices); i++) - if (devices[i].id == device) - break; - - if (i >= ARRAY_SIZE(devices)) - return -EINVAL; - FIND_DEVICE_INT(dev_ops, devices[i].name); - if (enable) - ret = device_start(dev_ops); - else - ret = device_stop(dev_ops); - - return ret; -} - -static int get_control_handler(int argc, char **argv) -{ - int i; - int pid; - int device; - const struct device_ops *dev_ops = NULL; - - _I("argc : %d", argc); - for (i = 0; i < argc; ++i) - _I("[%2d] %s", i, argv[i]); - - if (argc > 4) { - _E("Invalid argument"); - errno = EINVAL; - return -1; - } - - pid = atoi(argv[0]); - device = atoi(argv[1]); - _I("pid : %d, device : %d", pid, device); - - for (i = 0; i < ARRAY_SIZE(devices); i++) - if (devices[i].id == device) - break; - - if (i >= ARRAY_SIZE(devices)) - return -EINVAL; - - FIND_DEVICE_INT(dev_ops, devices[i].name); - - return device_get_status(dev_ops); -} - - -static DBusMessage *dbus_control_handler(E_DBus_Object *obj, DBusMessage *msg) -{ - DBusError err; - DBusMessageIter iter; - DBusMessage *reply; - pid_t pid; - int ret; - int argc; - char *type_str; - char *argv[3]; - - dbus_error_init(&err); - - if (!dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &type_str, - DBUS_TYPE_INT32, &argc, - DBUS_TYPE_STRING, &argv[0], - DBUS_TYPE_STRING, &argv[1], - DBUS_TYPE_STRING, &argv[2], DBUS_TYPE_INVALID)) { - _E("there is no message"); - ret = -EINVAL; - goto out; - } - - if (argc < 0) { - _E("message is invalid!"); - ret = -EINVAL; - goto out; - } - - pid = get_edbus_sender_pid(msg); - if (kill(pid, 0) == -1) { - _E("%d process does not exist, dbus ignored!", pid); - ret = -ESRCH; - goto out; - } - - ret = control_handler(argc, (char **)&argv); -out: - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); - - return reply; -} - -static DBusMessage *dbus_get_control_handler(E_DBus_Object *obj, DBusMessage *msg) -{ - DBusError err; - DBusMessageIter iter; - DBusMessage *reply; - pid_t pid; - int ret; - int argc; - char *type_str; - char *argv[2]; - - dbus_error_init(&err); - - if (!dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &type_str, - DBUS_TYPE_INT32, &argc, - DBUS_TYPE_STRING, &argv[0], - DBUS_TYPE_STRING, &argv[1], DBUS_TYPE_INVALID)) { - _E("there is no message"); - ret = -EINVAL; - goto out; - } - - if (argc < 0) { - _E("message is invalid!"); - ret = -EINVAL; - goto out; - } - - pid = get_edbus_sender_pid(msg); - if (kill(pid, 0) == -1) { - _E("%d process does not exist, dbus ignored!", pid); - ret = -ESRCH; - goto out; - } - - ret = get_control_handler(argc, (char **)&argv); -out: - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); - - return reply; -} - -static const struct edbus_method edbus_methods[] = { - { CONTROL_HANDLER_NAME, "sisss", "i", dbus_control_handler }, - { CONTROL_GETTER_NAME , "siss", "i", dbus_get_control_handler }, -}; - -static void control_init(void *data) -{ - int ret; - - ret = register_edbus_method(DEVICED_PATH_SYSNOTI, edbus_methods, ARRAY_SIZE(edbus_methods)); - if (ret < 0) - _E("fail to init edbus method(%d)", ret); -} - -static const struct device_ops control_device_ops = { - .name = "control", - .init = control_init, -}; - -DEVICE_OPS_REGISTER(&control_device_ops) diff --git a/src/core/boot.c b/src/core/boot.c index 9082fea..c1cbb61 100644 --- a/src/core/boot.c +++ b/src/core/boot.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ #include "core/device-notifier.h" #include "core/common.h" #include "core/edbus-handler.h" -#include "shared/deviced-systemd.h" +#include "shared/pass-systemd.h" #define SIGNAL_BOOTING_DONE "BootingDone" @@ -40,7 +40,7 @@ int booting_finished(void) int ret; size_t len; - ret = deviced_systemd_get_manager_property_as_string( + ret = pass_systemd_get_manager_property_as_string( SYSTEMD_DBUS_IFACE_MANAGER, SYSTEMD_DBUS_METHOD_SYSTEM_STATE, &state); diff --git a/src/core/boot.h b/src/core/boot.h index ff20fac..7562e76 100644 --- a/src/core/boot.h +++ b/src/core/boot.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -16,11 +16,11 @@ * limitations under the License. */ -#ifndef __DEVICED_BOOT_H__ -#define __DEVICED_BOOT_H__ +#ifndef __PASS_BOOT_H__ +#define __PASS_BOOT_H__ int booting_finished(void); void add_booting_done_handler(void *data); void remove_booting_done_handler(void *data); -#endif /* __DEVICED_BOOT_H__ */ +#endif /* __PASS_BOOT_H__ */ diff --git a/src/core/common.c b/src/core/common.c index 3cb598f..3d22461 100644 --- a/src/core/common.c +++ b/src/core/common.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -37,76 +37,7 @@ #include "log.h" #include "common.h" -#define PERMANENT_DIR "/tmp/permanent" -#define VIP_DIR "/tmp/vip" -#define BUFF_MAX 255 - -#define APP_ATTR_PATH "/proc/%d/attr/current" - -/** - * Opens "/proc/$pid/oom_score_adj" file for w/r; - * Return: FILE pointer or NULL - */ -FILE *open_proc_oom_score_adj_file(int pid, const char *mode) -{ - char buf[32]; - FILE *fp; - - snprintf(buf, sizeof(buf), "/proc/%d/oom_score_adj", pid); - fp = fopen(buf, mode); - return fp; -} - -int get_exec_pid(const char *execpath) -{ - DIR *dp; - struct dirent entry; - struct dirent *dentry; - int pid = -1, fd; - int ret; - int len; - char buf[PATH_MAX]; - char buf2[PATH_MAX]; - - dp = opendir("/proc"); - if (!dp) { - _E("FAIL: open /proc"); - return -1; - } - - len = strlen(execpath) + 1; - while (1) { - ret = readdir_r(dp, &entry, &dentry); - if (ret != 0 || dentry == NULL) - break; - - if (!isdigit(dentry->d_name[0])) - continue; - - pid = atoi(dentry->d_name); - - snprintf(buf, PATH_MAX, "/proc/%d/cmdline", pid); - fd = open(buf, O_RDONLY); - if (fd < 0) - continue; - ret = read(fd, buf2, PATH_MAX); - close(fd); - - if (ret < 0 || ret >= PATH_MAX) - continue; - - buf2[ret] = '\0'; - - if (!strncmp(buf2, execpath, len)) { - closedir(dp); - return pid; - } - } - - errno = ESRCH; - closedir(dp); - return -1; -} +#define BUFF_MAX 255 int get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size) { @@ -144,86 +75,6 @@ int get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size) return 0; } -int is_vip(int pid) -{ - if (pid < 1) - return -1; - - char buf[PATH_MAX]; - - snprintf(buf, PATH_MAX, "%s/%d", VIP_DIR, pid); - - if (access(buf, R_OK) == 0) - return 1; - else - return 0; -} - -static int remove_dir_internal(int fd) -{ - DIR *dir; - struct dirent entry; - struct dirent *de; - int subfd, ret = 0; - - dir = fdopendir(fd); - if (!dir) - return -1; - while (1) { - ret = readdir_r(dir, &entry, &de); - if (ret != 0 || de == NULL) - break; - if (de->d_type == DT_DIR) { - if (!strncmp(de->d_name, ".", 2) || !strncmp(de->d_name, "..", 3)) - continue; - subfd = openat(fd, de->d_name, O_RDONLY | O_DIRECTORY); - if (subfd < 0) { - _SE("Couldn't openat %s: %d\n", de->d_name, errno); - ret = -1; - continue; - } - if (remove_dir_internal(subfd)) - ret = -1; - - close(subfd); - if (unlinkat(fd, de->d_name, AT_REMOVEDIR) < 0) { - _SE("Couldn't unlinkat %s: %d\n", de->d_name, errno); - ret = -1; - } - } else { - if (unlinkat(fd, de->d_name, 0) < 0) { - _SE("Couldn't unlinkat %s: %d\n", de->d_name, errno); - ret = -1; - } - } - } - closedir(dir); - return ret; -} - -int remove_dir(const char *path, int del_dir) -{ - int fd, ret = 0; - - if (!path) - return -1; - fd = open(path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW); - if (fd < 0) { - _SE("Couldn't opendir %s: %d\n", path, errno); - return -errno; - } - ret = remove_dir_internal(fd); - close(fd); - - if (del_dir) { - if (rmdir(path)) { - _SE("Couldn't rmdir %s: %d\n", path, errno); - ret = -1; - } - } - return ret; -} - /* * Helper function * - Read from sysfs entry @@ -332,79 +183,3 @@ int sys_set_str(char *fname, char *val) return r; } - -int terminate_process(const char *partition, bool force) -{ - const char *argv[7] = {"/usr/bin/fuser", "-m", "-k", "-s", NULL, NULL, NULL}; - int argc; - - if (force) - argv[4] = "-SIGKILL"; - else - argv[4] = "-SIGTERM"; - argv[5] = partition; - argc = sizeof(argv) / sizeof(argv[0]); - return run_child(argc, argv); -} - -int mount_check(const char *path) -{ - int ret = false; - struct mntent *mnt; - const char *table = "/etc/mtab"; - FILE *fp; - int len; - - fp = setmntent(table, "r"); - if (!fp) - return ret; - - len = strlen(path) + 1; - while (1) { - mnt = getmntent(fp); - if (mnt == NULL) - break; - if (!strncmp(mnt->mnt_dir, path, len)) { - ret = true; - break; - } - } - endmntent(fp); - return ret; -} - -void print_time(const char *prefix) -{ - struct timeval tv; - struct tm tm; - struct tm *ret; - gettimeofday(&tv, NULL); - ret = localtime_r(&(tv.tv_sec), &tm); - if (ret) - _D("%s --> %d:%02d:%02d %d", - prefix, tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec); -} - -int get_privilege(pid_t pid, char *name, size_t len) -{ - char path[PATH_MAX]; - char attr[BUFF_MAX]; - size_t attr_len; - FILE *fp; - - snprintf(path, sizeof(path), APP_ATTR_PATH, pid); - - fp = fopen(path, "r"); - if (!fp) - return -errno; - - attr_len = fread(attr, 1, sizeof(attr) - 1, fp); - fclose(fp); - if (attr_len == 0) - return -ENOENT; - - attr[attr_len] = '\0'; - - snprintf(name, len, "%s", attr); - return 0; -} diff --git a/src/core/common.h b/src/core/common.h index c0096b8..86525cb 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/config-parser.c b/src/core/config-parser.c index 4018b88..3278efe 100644 --- a/src/core/config-parser.c +++ b/src/core/config-parser.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/config-parser.h b/src/core/config-parser.h index 7df70e6..66b72ec 100644 --- a/src/core/config-parser.h +++ b/src/core/config-parser.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/device-idler.c b/src/core/device-idler.c index e399bf2..79582a8 100644 --- a/src/core/device-idler.c +++ b/src/core/device-idler.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/device-idler.h b/src/core/device-idler.h index 411e4bb..c3efc03 100644 --- a/src/core/device-idler.h +++ b/src/core/device-idler.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2017 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. diff --git a/src/core/device-notifier.c b/src/core/device-notifier.c index ff066c0..e989c33 100644 --- a/src/core/device-notifier.c +++ b/src/core/device-notifier.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/device-notifier.h b/src/core/device-notifier.h index cef4cb7..4ac22bc 100644 --- a/src/core/device-notifier.h +++ b/src/core/device-notifier.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2017 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. @@ -22,26 +22,8 @@ enum device_notifier_type { DEVICE_NOTIFIER_BOOTING_DONE, - DEVICE_NOTIFIER_LCD, - DEVICE_NOTIFIER_TA, - DEVICE_NOTIFIER_LOWBAT, - DEVICE_NOTIFIER_FULLBAT, - DEVICE_NOTIFIER_TOUCH_HARDKEY, - DEVICE_NOTIFIER_PROCESS_TERMINATED, - DEVICE_NOTIFIER_POWER_SUPPLY, - DEVICE_NOTIFIER_BATTERY_HEALTH, - DEVICE_NOTIFIER_BATTERY_PRESENT, - DEVICE_NOTIFIER_BATTERY_OVP, - DEVICE_NOTIFIER_BATTERY_CHARGING, - DEVICE_NOTIFIER_DISPLAY_LOCK, - DEVICE_NOTIFIER_POWER_RESUME, - DEVICE_NOTIFIER_POWEROFF, - DEVICE_NOTIFIER_POWEROFF_HAPTIC, - DEVICE_NOTIFIER_PMQOS_OOM, DEVICE_NOTIFIER_PMQOS, - DEVICE_NOTIFIER_PROCESS_BACKGROUND, - DEVICE_NOTIFIER_PROCESS_FOREGROUND, - DEVICE_NOTIFIER_USB_TETHERING_MODE, + DEVICE_NOTIFIER_POWEROFF, DEVICE_NOTIFIER_MAX, }; diff --git a/src/core/devices.c b/src/core/devices.c index 3ff5a8d..837f656 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/devices.h b/src/core/devices.h index c49499a..d7b8d9a 100644 --- a/src/core/devices.h +++ b/src/core/devices.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -30,18 +30,6 @@ enum device_priority { enum device_flags { NORMAL_MODE = 0x00000001, - CORE_LOGIC_MODE = 0x00010000, - TOUCH_SCREEN_OFF_MODE = 0x00020000, - LCD_PANEL_OFF_MODE = 0x00040000, - LCD_PHASED_TRANSIT_MODE = 0x00080000, - LCD_ON_BY_GESTURE = 0x00100000, - LCD_ON_BY_POWER_KEY = 0x00200000, - LCD_ON_BY_EVENT = 0x00400000, - LCD_ON_BY_TOUCH = 0x00800000, - LCD_OFF_BY_POWER_KEY = 0x01000000, - LCD_OFF_BY_TIMEOUT = 0x02000000, - LCD_OFF_BY_EVENT = 0x04000000, - LCD_OFF_LATE_MODE = 0x08000000, }; struct device_ops { diff --git a/src/core/edbus-handler.c b/src/core/edbus-handler.c index aa36b5f..eec2461 100644 --- a/src/core/edbus-handler.c +++ b/src/core/edbus-handler.c @@ -1,5 +1,5 @@ /* - * deviced + * PASS * * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. * @@ -48,13 +48,7 @@ static struct edbus_object { E_DBus_Interface *iface; } edbus_objects[] = { { DEVICED_PATH_CORE , DEVICED_INTERFACE_CORE , NULL, NULL }, - { DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, NULL, NULL }, - { DEVICED_PATH_POWER , DEVICED_INTERFACE_POWER , NULL, NULL }, - { DEVICED_PATH_STORAGE, DEVICED_INTERFACE_STORAGE, NULL, NULL }, - { DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS, NULL, NULL }, - { DEVICED_PATH_KEY , DEVICED_INTERFACE_KEY , NULL, NULL }, { DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, NULL, NULL }, - { DEVICED_PATH_USB , DEVICED_INTERFACE_USB , NULL, NULL }, { DEVICED_PATH_PMQOS , DEVICED_INTERFACE_PMQOS , NULL, NULL }, /* Add new object & interface here*/ }; @@ -1055,19 +1049,6 @@ void edbus_init(void *data) retry++; } while (retry <= EDBUS_INIT_RETRY_COUNT); - retry = 0; - do { - edbus_request_name = e_dbus_request_name(edbus_conn_block, STORAGE_BUS_NAME, - DBUS_NAME_FLAG_REPLACE_EXISTING, request_name_cb, NULL); - if (edbus_request_name) - break; - if (retry == EDBUS_INIT_RETRY_COUNT) { - _E("fail to request edbus name"); - goto out3; - } - retry++; - } while (retry <= EDBUS_INIT_RETRY_COUNT); - for (i = 0; i < ARRAY_SIZE(edbus_objects); i++) { ret = register_edbus_interface(&edbus_objects[i]); if (ret < 0) { diff --git a/src/core/edbus-handler.h b/src/core/edbus-handler.h index 17eb956..13224af 100644 --- a/src/core/edbus-handler.h +++ b/src/core/edbus-handler.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/execute.c b/src/core/execute.c index 1996c4d..224ea58 100755 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/launch.c b/src/core/launch.c deleted file mode 100644 index f481357..0000000 --- a/src/core/launch.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "log.h" -#include "launch.h" -#include "common.h" - -#define MAX_ARGS 255 - -#define _S(str) ((str == NULL) ? "" : str) - -static int set_current_lang(void) -{ - char *lang; - int ret; - - lang = vconf_get_str(VCONFKEY_LANGSET); - if (lang == NULL) - return -1; - ret = setenv("LANG", lang, 1); - if (ret < 0) - return -1; - free(lang); - return 0; -} - - -static void prepare_exec(void) -{ - int i; - int maxfd; - - maxfd = getdtablesize(); - for (i = 3; i < maxfd; i++) - close(i); - - for (i = 0; i < _NSIG; i++) - signal(i, SIG_DFL); -} - -static int parse_cmd(const char *cmdline, char **argv, int max_args) -{ - const char *p; - char *buf, *bufp; - int nargs = 0; - int escape = 0, squote = 0, dquote = 0; - int bufsize; - - if (cmdline == NULL || cmdline[0] == '\0') - return -1; - bufsize = strlen(cmdline)+1; - bufp = buf = malloc(bufsize); - if (bufp == NULL || buf == NULL) - return -1; - memset(buf, 0, bufsize); - p = cmdline; - - while (*p) { - if (escape) { - *bufp++ = *p; - escape = 0; - } else { - switch (*p) { - case '\\': - escape = 1; - break; - case '"': - if (squote) - *bufp++ = *p; - else - dquote = !dquote; - break; - case '\'': - if (dquote) - *bufp++ = *p; - else - squote = !squote; - break; - case ' ': - if (!squote && !dquote) { - *bufp = '\0'; - if (nargs < max_args) - argv[nargs++] = strdup(buf); - bufp = buf; - break; - } - default: - *bufp++ = *p; - break; - } - } - p++; - } - - if (bufp != buf) { - *bufp = '\0'; - if (nargs < max_args) - argv[nargs++] = strdup(buf); - } - - argv[nargs++] = NULL; - - free(buf); - return nargs; -} - -int launch_app_with_nice(const char *file, char *const argv[], pid_t *pid, int _nice) -{ - int ret; - int _pid; - - if (file == NULL || access(file, X_OK) != 0) { - _E("launch app error: Invalid input"); - errno = EINVAL; - return -1; - } - - if (pid && (*pid > 0 && kill(*pid, 0) != -1)) - return *pid; - - _pid = fork(); - - if (_pid == -1) { - _E("fork error: %d", errno); - /* keep errno */ - return -1; - } - - if (_pid > 0) { /* parent */ - if (pid) - *pid = _pid; - return _pid; - } - - /* child */ - prepare_exec(); - - ret = nice(_nice); - - if (ret == -1 && errno != 0) - _E("nice error: %d", errno); - - ret = execvp(file, argv); - - /* If failed... */ - _E("exec. error: %s", errno); - return -2; -} - -int launch_app_cmd_with_nice(const char *cmdline, int _nice) -{ - int i; - int nargs; - int ret; - char *argv[MAX_ARGS + 1]; - - nargs = parse_cmd(cmdline, argv, MAX_ARGS + 1); - if (nargs == -1) { - _E("launch app error: Invalid input"); - errno = EINVAL; - return -1; - } - - ret = launch_app_with_nice(argv[0], argv, NULL, _nice); - - for (i = 0; i < nargs; i++) - free(argv[i]); - - return ret; -} - -int launch_app_cmd(const char *cmdline) -{ - return launch_app_cmd_with_nice(cmdline, 0); -} - -int launch_if_noexist(const char *execpath, const char *arg, ...) -{ - char *buf; - int pid; - int nice_value = 0; - int flag = 0; - int buf_size = -1; - va_list argptr; - - if (execpath == NULL) { - errno = EINVAL; - return -1; - } - pid = get_exec_pid(execpath); - if (pid > 0) - return pid; - - va_start(argptr, arg); - flag = va_arg(argptr, int); - - if (flag & LAUNCH_NICE) - nice_value = va_arg(argptr, int); - - va_end(argptr); - - set_current_lang(); - arg = _S(arg); - - buf_size = strlen(execpath) + strlen(arg) + 10; - buf = malloc(buf_size); - if (buf == NULL) { - /* Do something for not enought memory error */ - _E("Malloc failed"); - return -1; - } - - snprintf(buf, buf_size, "%s %s", execpath, arg); - pid = launch_app_cmd_with_nice(buf, nice_value); - if (pid == -2) - exit(EXIT_FAILURE); - free(buf); - - return pid; -} - -int launch_evenif_exist(const char *execpath, const char *arg, ...) -{ - char *buf; - int pid; - int nice_value = 0; - int flag = 0; - int buf_size = -1; - - va_list argptr; - - if (execpath == NULL) { - errno = EINVAL; - return -1; - } - - va_start(argptr, arg); - flag = va_arg(argptr, int); - - if (flag & LAUNCH_NICE) - nice_value = va_arg(argptr, int); - - va_end(argptr); - - set_current_lang(); - - arg = _S(arg); - - buf_size = strlen(execpath) + strlen(arg) + 10; - buf = malloc(buf_size); - if (buf == NULL) { - _E("Malloc failed"); - return -1; - } - - snprintf(buf, buf_size, "%s %s", execpath, arg); - pid = launch_app_cmd_with_nice(buf, nice_value); - if (pid == -2) - exit(EXIT_FAILURE); - free(buf); - - return pid; -} - -int launch_after_kill_if_exist(const char *execpath, const char *arg, ...) -{ - char *buf; - int pid; - int flag; - int buf_size; - int exist_pid; - va_list argptr; - int nice_value = 0; - - if (execpath == NULL) { - errno = EINVAL; - return -1; - } - - exist_pid = get_exec_pid(execpath); - if (exist_pid > 0) - kill(exist_pid, SIGTERM); - - va_start(argptr, arg); - flag = va_arg(argptr, int); - - if (flag & LAUNCH_NICE) - nice_value = va_arg(argptr, int); - - va_end(argptr); - - set_current_lang(); - - arg = _S(arg); - - buf_size = strlen(execpath) + strlen(arg) + 10; - buf = malloc(buf_size); - if (buf == NULL) { - /* Do something for not enought memory error */ - _E("Malloc Failed"); - return -1; - } - - snprintf(buf, buf_size, "%s %s", execpath, arg); - pid = launch_app_cmd_with_nice(buf, nice_value); - if (pid == -2) /* It means that the 'execvp' return -1 */ - exit(EXIT_FAILURE); - free(buf); - - return pid; - -} diff --git a/src/core/launch.h b/src/core/launch.h deleted file mode 100644 index 7c6d0dd..0000000 --- a/src/core/launch.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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 __LAUNCH_H__ -#define __LAUNCH_H__ - -#define LAUNCH_NICE 0x0002 - -int launch_if_noexist(const char *execpath, const char *arg, ...); -int launch_evenif_exist(const char *execpath, const char *arg, ...); -int launch_after_kill_if_exist(const char *execpath, const char *arg, ...); - -int launch_app_cmd(const char *cmdline); -int launch_app_cmd_with_nice(const char *cmdline, int _nice); - -#endif /* __LAUNCH_H__ */ diff --git a/src/core/list.h b/src/core/list.h index 9555737..c57452a 100644 --- a/src/core/list.h +++ b/src/core/list.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2017 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. diff --git a/src/core/log.c b/src/core/log.c index 86310cd..2a91d05 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/log.h b/src/core/log.h index f3c3bea..74b866a 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #ifndef __LOG_H__ #define __LOG_H__ -#ifdef ENABLE_DEVICED_DLOG +#ifdef ENABLE_PASS_DLOG #define ENABLE_DLOG #endif diff --git a/src/core/main.c b/src/core/main.c index c9de427..78e9680 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ #include "boot.h" #include "device-notifier.h" -#define PIDFILE_PATH "/var/run/.deviced.pid" +#define PIDFILE_PATH "/var/run/.pass.pid" static void writepid(char *pidpath) { @@ -49,12 +49,12 @@ static void sig_quit(int signo) static void sig_usr1(int signo) { - _D("received SIGUSR1 signal %d, deviced'll be finished!", signo); + _D("received SIGUSR1 signal %d, PASS'll be finished!", signo); ecore_main_loop_quit(); } -static int deviced_main(int argc, char **argv) +static int pass_main(int argc, char **argv) { int ret; @@ -81,5 +81,5 @@ int main(int argc, char **argv) { writepid(PIDFILE_PATH); ecore_init(); - return deviced_main(argc, argv); + return pass_main(argc, argv); } diff --git a/src/core/sig-handler.c b/src/core/sig-handler.c index 17b0dfc..9d31cc2 100644 --- a/src/core/sig-handler.c +++ b/src/core/sig-handler.c @@ -1,5 +1,5 @@ /* - * deviced + * PASS * * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. * diff --git a/src/core/udev.c b/src/core/udev.c index f11ea9b..71d72be 100644 --- a/src/core/udev.c +++ b/src/core/udev.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/core/udev.h b/src/core/udev.h index 494e905..66fc130 100644 --- a/src/core/udev.h +++ b/src/core/udev.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -29,52 +29,6 @@ #define UDEV_DEVPATH "DEVPATH" #define UDEV_DEVTYPE "DEVTYPE" -/* battery device */ -#define POWER_SUBSYSTEM "power_supply" -#define POWER_PATH "/sys/class/power_supply/battery" -#define POWER_SUPPLY_UEVENT POWER_PATH"/uevent" -#define CAPACITY "POWER_SUPPLY_CAPACITY" -#define CHARGE_HEALTH "POWER_SUPPLY_HEALTH" -#define CHARGE_PRESENT "POWER_SUPPLY_PRESENT" -#define CHARGE_NAME "POWER_SUPPLY_NAME" -#define CHARGE_STATUS "POWER_SUPPLY_STATUS" -#define CHARGE_ONLINE "POWER_SUPPLY_ONLINE" - -/* extcon */ -#define EXTCON_SUBSYSTEM "extcon" - -/* usb */ -#define USB_SUBSYSTEM "usb" -#define USB_INTERFACE_DEVTYPE "usb_interface" -#define USB_DEVICE_DEVTYPE "usb_device" - -/* block */ -#define BLOCK_SUBSYSTEM "block" -#define BLOCK_DEVTYPE_DISK "disk" -#define BLOCK_DEVTYPE_PARTITION "partition" - -/* power supply status */ -enum { - POWER_SUPPLY_STATUS_UNKNOWN = 0, - POWER_SUPPLY_STATUS_CHARGING, - POWER_SUPPLY_STATUS_DISCHARGING, - POWER_SUPPLY_STATUS_NOT_CHARGING, - POWER_SUPPLY_STATUS_FULL, -}; - -enum { - POWER_SUPPLY_TYPE_UNKNOWN = 0, - POWER_SUPPLY_TYPE_BATTERY, - POWER_SUPPLY_TYPE_UPS, - POWER_SUPPLY_TYPE_MAINS, - POWER_SUPPLY_TYPE_USB, -}; - -enum dock_type { - DOCK_NONE = 0, - DOCK_SOUND = 7, -}; - struct uevent_handler { char *subsystem; void (*uevent_func)(struct udev_device *dev); diff --git a/src/deviced/dd-common.h b/src/deviced/dd-common.h deleted file mode 100644 index fdfc2ac..0000000 --- a/src/deviced/dd-common.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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 __DD_COMMON_H__ -#define __DD_COMMON_H__ - -/** - * @file dd-common.h - * @ingroup CAPI_SYSTEM_DEVICED - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef DEPRECATED -#define DEPRECATED __attribute__((deprecated)) -#endif - -#ifdef __cplusplus -} -#endif -#endif /* __DD_COMMON_H__ */ diff --git a/src/deviced/dd-control.h b/src/deviced/dd-control.h deleted file mode 100644 index 120ed6c..0000000 --- a/src/deviced/dd-control.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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 __DD_CONTROL_H__ -#define __DD_CONTROL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * @file dd-control.h - * @defgroup CAPI_SYSTEM_DEVICED_CONTROL_MODULE Control - * @ingroup CAPI_SYSTEM_DEVICED - * @brief This file provides the API to enable/disable devices - * @section CAPI_SYSTEM_DEVICED_CONTROL_MODULE_HEADER Required Header - * \#include - */ - -/** - * @addtogroup CAPI_SYSTEM_DEVICED_CONTROL_MODULE - * @{ - */ - -/** - * @par Description - * Control Device type - */ -enum control_device_type { -/* Add device define here */ - DEVICE_CONTROL_MMC, - DEVICE_CONTROL_USBCLIENT, - DEVICE_CONTROL_BLOCK, - DEVICE_CONTROL_MAX, -}; - -/** - * @par Description: - * This API is used to enable/disable mmc device.\n - * @param[in] enable enable/disable mmc device - * @return 0 on success, -1 if failed - * @par Example - * @code - * ... - * if( deviced_mmc_control(1) < 0 ) - * printf("Enable mmc device failed\n"); - * ... - * @endcode - */ -int deviced_mmc_control(bool enable); - -/** - * @par Description: - * This API is used to enable/disable usb device.\n - * @param[in] enable enable/disable usb device - * @return 0 on success, -1 if failed - * @par Example - * @code - * ... - * if( deviced_usb_control(1) < 0 ) - * printf("Enable usb device failed\n"); - * ... - * @endcode - */ -int deviced_usb_control(bool enable); - -/* Only USB-manager will use the api */ -/** - * @par Description: - * @return - * @par Example - * @code - * @endcode - * @todo describe function - */ -int deviced_get_usb_control(void); - -/** - * @} // end of CAPI_SYSTEM_DEVICED_CONTROL_MODULE - */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/deviced/dd-deviced-managed.h b/src/deviced/dd-deviced-managed.h deleted file mode 100644 index ba0af77..0000000 --- a/src/deviced/dd-deviced-managed.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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 __DD_DEVICED_MANAGED_H__ -#define __DD_DEVICED_MANAGED_H__ - -#include -#include "dd-mmc.h" - -/** - * @file dd-deviced-managed.h - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup CAPI_SYSTEM_DEVICED - * @{ - */ - -/** - * @fn int deviced_get_pid(const char *execpath) - * @brief This API is used to get the pid of the process which has the specified execpath.\n - * Internally, this API searches /proc/{pid}/cmdline and compares the parameter execpath with 1st argument of cmdline. \n - * If there is no process that has same execpath in /proc/{pid}/cmdline, it will return -1. - * @param[in] execpath program path which you want to know whether it is run or not - * @return pid when the program is running, -1 if it is not. - */ -int deviced_get_pid(const char *execpath); - -/** - * @fn int deviced_set_datetime(time_t timet) - * @brief This API is used to set date time.\n - * Internally, this API call predefined action API. That is send a notify message. \n - * @param[in] timet type of time which you want to set. - * @return pid when the program is running, -1 if param is less than 0 or when failed set datetime. - */ -int deviced_set_datetime(time_t timet); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* __DD_DEVICED_MANAGED_H__ */ diff --git a/src/deviced/dd-deviced.h b/src/deviced/dd-deviced.h deleted file mode 100644 index be62a03..0000000 --- a/src/deviced/dd-deviced.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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 __DD_DEVICED__ -#define __DD_DEVICED__ - -#include -#include -#include -#include -#include "dd-deviced-managed.h" - -/** - * @file dd-deviced.h - * @defgroup CAPI_SYSTEM_DEVICED_UTIL_MODULE Util - * @ingroup CAPI_SYSTEM_DEVICED - * @section CAPI_SYSTEM_DEVICED_UTIL_MODULE_HEADER Required Header - * \#include - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup CAPI_SYSTEM_DEVICED_UTIL_MODULE - * @{ - */ - -/** - * @brief Policy for low memory - */ -enum mem_policy { - OOM_LIKELY, /**< For miscellaneous applications */ - OOM_IGNORE /**< For daemons */ -}; - -/* deviced_util */ - -/** - * @fn int deviced_get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size) - * @brief This API is used to get the file name of command line of the process from the proc fs. - * Caller process MUST allocate enough memory for the cmdline parameter. \n - * Its size should be assigned to cmdline_size. \n - * Internally it reads the 1st argument of /proc/{pid}/cmdline and copies it to cmdline. - * @param[in] pid pid of the process that you want to get the file name of command line - * @param[out] cmdline command line of the process that you want to get the file name
- * Callers should allocate memory to this parameter before calling this function. - * The allocated memory size must be large enough to store the file name. - * The result will include the terminating null byte('\0') at the end of the string. - * @param[in] cmdline_size - * @return 0 on success, negative value if failed.\n - * If the size of cmdline is smaller than the result, it will return -75 and \n - * errno will be set as EOVERFLOW. \n - * If the function cannot open /proc/%d/cmdline file then it will return -3 and \n - * errno will be set as ESRCH. - */ -int deviced_get_cmdline_name(pid_t pid, char *cmdline, - size_t cmdline_size); - -/** - * @fn int deviced_get_apppath(pid_t pid, char *app_path, size_t app_path_size) - * @brief This API is used to get the execution path of the process specified by the pid parameter.\n - * Caller process MUST allocate enough memory for the app_path parameter. \n - * Its size should be assigned to app_path_size. \n - * Internally it reads a link of /proc/{pid}/exe and copies the path to app_path. - * @param[in] pid pid of the process that you want to get the executed path - * @param[out] app_path the executed file path of the process
- * Callers should allocate memory to this parameter before calling this function. - * The allocated memory size must be large enough to store the executed file path. - * The result will include the terminating null byte('\0') at the end of the string. - * @param[in] app_path_size allocated memory size of char *app_path - * @return 0 on success, -1 if failed. \n - * If the size of app_path is smaller than the result, it will return -1 and \n - * errno will be set as EOVERFLOW. - */ -int deviced_get_apppath(pid_t pid, char *app_path, size_t app_path_size); - -/* sysconf */ - -/** - * @fn int deviced_conf_set_mempolicy(enum mem_policy mempol) - * @brief This API is used to set the policy of the current process when the phone has low available memory. - * @param[in] mempol oom adjust value which you want to set - * @return 0 on success, -1 if failed. - * @see deviced_conf_set_mempolicy_bypid() - * @retval -1 operation error - * @retval -EBADMSG - dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_conf_set_mempolicy(enum mem_policy mempol); - -/** - * @fn int deviced_conf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol) - * @brief This API is used to set the policy of the given process when the phone has low available memory. - * @param[in] pid process id which you want to set - * @param[in] mempol oom adjust value which you want to set - * @return 0 on success, -1 if failed. - * @retval -1 operation error - * @retval -EBADMSG - dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_conf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol); - -/** - * @fn int deviced_conf_set_permanent(void) - * @brief This API is used to set itself as a permanent process.\n - * If the permanent process is dead, system server will relaunch the process automatically. - * @return 0 on success, -1 if failed. - * @see deviced_conf_set_permanent_bypid() - * @par Example - * @code - * ... - * ret = deviced_conf_set_permanent(); - * if( ret < 0 ) - * printf("Fail to set a process as permanent\n"); - * ... - * @endcode - */ -int deviced_conf_set_permanent(void); - -/** - * @fn int deviced_conf_set_permanent_bypid(pid_t pid) - * @brief This API is used to set a given process as permanent.\n - * If the permanent process is dead, system server will relaunch the process automatically. - * @param[in] pid proces id - * @return 0 on success, -1 if failed. - * @see deviced_set_permanent() - * @par Example - * @code - * ... - * ret = deviced_conf_set_permanent_bypid(pid); - * if( ret < 0 ) - * printf("Fail to set a process(%d) as permanent\n",pid); - * ... - * @endcode - */ -int deviced_conf_set_permanent_bypid(pid_t pid); - -/** - * @fn int deviced_conf_set_vip(pid_t pid) - * @brief This API is used to set a process which has pid as Very Important Process(VIP) .\n - * If the VIP process is dead, restarter program will be run. \n - * Restarter program may kill almost processes and run rc.local scripts again. - * @param[in] pid process id to be vip - * @return 0 on success, -1 if failed. - * @see sysconf_is_vip - * @par Example - * @code - * ... - * ret = deviced_conf_set_vip(pid); - * if( ret < 0 ) - * printf("Fail to set a process(%d) as VIP\n",pid); - * ... - * @endcode - */ -int deviced_conf_set_vip(pid_t pid); - -/** - * @fn int deviced_conf_is_vip(pid_t pid) - * @brief This API is used to verify that process which has pid is Very Important Process(VIP) or not. - * @param[in] pid process id to be vip - * @return 1 if given process if vip process, otherwise 0 is returned. - * @see deviced_conf_set_vip - * @par Example - * @code - * ... - * ret = deviced_conf_is_vip(pid); - * if(ret) - * printf("process(%d) is Very Important Process\n",pid); - * ... - * @endcode - */ -int deviced_conf_is_vip(pid_t pid); - -/** - * @fn int deviced_set_timezone(char *tzpath_str) - * @brief This API sets system timezone. - * @param[in] tzpath_str path to timezone definition file - * @return 0 on success, negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_set_timezone(char *tzpath_str); - -/** - * @fn int deviced_call_predef_action(const char *type, int num, ...) - * @brief This API calls predefined systemd action. - * Internally it send message through SYSTEM_NOTI_SOCKET_PATH (/tmp/sn) UNIX socket to systemd. - * @param[in] type systemd action type name - * @param[in] num input parameters count. num cannot exceed SYSTEM_NOTI_MAXARG (16). - * @param[in] ... action input parameters. List of the parameters depends on action type. - * @return 0 on success, -1 if failed. - * If the action type is not set (is blank) or num > SYSTEM_NOTI_MAXARG it will return -1 - * and errno will be set as EINVAL. - */ -int deviced_call_predef_action(const char *type, int num, ...); - -/** - * @fn int deviced_change_flightmode(int mode) - * @brief This API call notifies about flight mode. - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_change_flightmode(int mode); - -/** - * @fn int deviced_inform_foregrd(void) - * @brief This API call notifies that current process is running in foreground. - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_inform_foregrd(void); - -/** - * @fn int deviced_inform_backgrd(void) - * @brief This API call notifies that current process is running in background. - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_inform_backgrd(void); - -/** - * @fn int deviced_inform_active(pid_t pid) - * @brief This API call notifies deviced daemon that given process (pid) is active. - * @param[in] pid process pid - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_inform_active(pid_t pid); - -/** - * @fn int deviced_inform_active(pid_t pid) - * @brief This API call notifies deviced daemon that given process (pid) is inactive. - * @param[in] pid process pid - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_inform_inactive(pid_t pid); - -/** - * @fn int deviced_request_poweroff(void) - * @brief This API call requests deviced daemon to launch "system poweroff popup". - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_request_poweroff(void); - -/** - * @fn deviced_request_entersleep(void) - * @brief This API call requests deviced daemon to enter system into sleep mode. - * @return 0 or positive value on success and negative value if failed. - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_request_entersleep(void); - -/** - * @fn int deviced_request_leavesleep(void) - * @brief This API calls requests deviced daemon to leave by system "sleep" mode and enter into "normal" mode. - * @return 0 or positive value on success and negative value if failed. - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_request_leavesleep(void); - -/** - * @fn int deviced_request_reboot(void) - * @brief This API call requests deviced daemon to initiate system reboot. - * @return 0 on success and negative value if failed. - * @retval -EBADMSG dbus error (in case of any error on the bus) - * @retval -EINVAL no mandatory parameters - * @retval -ESRCH incorrect sender process id - */ -int deviced_request_reboot(void); - -/** - * @fn int deviced_request_set_cpu_max_frequency(int val) - * @brief This API call requests deviced daemon to set maximum CPU frequency. - * @param[in] val maximum CPU frequency to be set. - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG - dbus error (in case of any error on the bus) - */ -int deviced_request_set_cpu_max_frequency(int val); - -/** - * @fn int deviced_request_set_cpu_min_frequency(int val) - * @brief This API call requests deviced daemon to set minimum CPU frequency. - * @param[in] val minimum CPU frequency to be set - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - */ -int deviced_request_set_cpu_min_frequency(int val); - -/** - * @fn int deviced_release_cpu_max_frequency(void) - * @brief This API call releases limit of maximum CPU frequency set by deviced_request_set_cpu_max_frequency() API. - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - */ -int deviced_release_cpu_max_frequency(void); - -/** - * @fn int deviced_release_cpu_min_frequency(void) - * @brief This API calls releases limit of minimum CPU frequency set by deviced_request_set_cpu_min_frequency() API. - * @return 0 or positive value on success and negative value if failed. - * @retval -1 operation error - * @retval -EBADMSG dbus error (in case of any error on the bus) - */ -int deviced_release_cpu_min_frequency(void); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* __DD_DEVICED__ */ diff --git a/src/deviced/deviced_doc.h b/src/deviced/deviced_doc.h deleted file mode 100644 index 6a478a3..0000000 --- a/src/deviced/deviced_doc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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_DEVICED_DOC_H__ -#define __TIZEN_SYSTEM_DEVICED_DOC_H__ - -/** - * @defgroup CAPI_SYSTEM_DEVICED deviced - * @brief The deviced APIs provide functions to control devices. - * @ingroup CAPI_SYSTEM_FRAMEWORK - * @section CAPI_SYSTEM_DEVICED_HEADER Required Header - * \#include - * - * @section CAPI_SYSTEM_SYSTEM_DEVICED_OVERVIEW Overview - * Provides access to a set of device like battery, display, haptic, LED, etc. - * The state of the device is changed or obtained by using APIs provided. - * - * - battery percentage, full charging state, etc. - * - brightness control, enhance mode setting, display lock/unlock, etc. - * - haptic play - * - service led control - * - other devices - * - */ - -#endif /* __TIZEN_SYSTEM_DEVICED_DOC_H__ */ diff --git a/src/pass/pass-core.c b/src/pass/pass-core.c index 34b143c..d1067be 100644 --- a/src/pass/pass-core.c +++ b/src/pass/pass-core.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -32,9 +32,9 @@ #define PASS_CPU_STATS_MAX_COUNT 20 /* - * FIXME: Current notifier of deviced didn't pass separate user_data parameter + * FIXME: Current notifier of PASS didn't pass separate user_data parameter * on callback function. So, PASS must need global pass_policy instance. This - * code must be modified after changing deviced's notifier feature. + * code must be modified after changing PASS's notifier feature. */ static struct pass_policy *policy_pmqos[PASS_CLUSTER_MAX]; static int num_policy_pmqos = 0; @@ -112,9 +112,9 @@ static int pass_notifier_init(struct pass_policy *policy) pass_notifier_booting_done); /* - * FIXME: Current notifier of deviced didn't pass separate user_data + * FIXME: Current notifier of PASS didn't pass separate user_data * parameter on callback function. So, PASS must need global pass_policy - * instance. This code must be modified after changing deviced's + * instance. This code must be modified after changing PASS's * notifier feature. */ policy_pmqos[num_policy_pmqos++] = policy; diff --git a/src/pass/pass-core.h b/src/pass/pass-core.h index 78defab..bbec558 100644 --- a/src/pass/pass-core.h +++ b/src/pass/pass-core.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass-gov-radiation.c b/src/pass/pass-gov-radiation.c index c403959..27b0b4a 100644 --- a/src/pass/pass-gov-radiation.c +++ b/src/pass/pass-gov-radiation.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware Systerm Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass-gov-step.c b/src/pass/pass-gov-step.c index 48d565e..e4e8686 100644 --- a/src/pass/pass-gov-step.c +++ b/src/pass/pass-gov-step.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass-gov.h b/src/pass/pass-gov.h index 6b1aee9..1caa07b 100644 --- a/src/pass/pass-gov.h +++ b/src/pass/pass-gov.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass-plugin.c b/src/pass/pass-plugin.c index 18c15be..6924213 100644 --- a/src/pass/pass-plugin.c +++ b/src/pass/pass-plugin.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass-plugin.h b/src/pass/pass-plugin.h index 629af7c..0c907bb 100644 --- a/src/pass/pass-plugin.h +++ b/src/pass/pass-plugin.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass-pmqos.c b/src/pass/pass-pmqos.c index 610251a..cb14eec 100644 --- a/src/pass/pass-pmqos.c +++ b/src/pass/pass-pmqos.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass-pmqos.h b/src/pass/pass-pmqos.h index a6991c1..6662bd3 100644 --- a/src/pass/pass-pmqos.h +++ b/src/pass/pass-pmqos.h @@ -1,5 +1,5 @@ /* - * deviced + * PASS (Power Aware System Service) * * Copyright (c) 2016 Samsung Electronics Co., Ltd. * diff --git a/src/pass/pass-util.h b/src/pass/pass-util.h index 918a284..bd23ecc 100644 --- a/src/pass/pass-util.h +++ b/src/pass/pass-util.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pass/pass.c b/src/pass/pass.c index 38d214d..7e50636 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -239,9 +239,9 @@ static void pass_init(void *data2) /* * Initialize pass cluster data by parsing pass.conf */ - ret = get_pass_cluster(&cluster, "/etc/deviced/pass.conf"); + ret = get_pass_cluster(&cluster, "/etc/pass/pass.conf"); if (ret < 0) { - _E("cannot parse /etc/deviced/pass.conf\n"); + _E("cannot parse /etc/pass/pass.conf\n"); return; } diff --git a/src/pass/pass.conf b/src/pass/pass.conf index 528500d..77ddd43 100644 --- a/src/pass/pass.conf +++ b/src/pass/pass.conf @@ -8,11 +8,11 @@ pass_num_cpu_clusters=2 [CpuCluster0] pass_cpu_cluster_id=0 pass_cpu_cluster_first_cpu=0 -pass_cpu_cluster_path_conf_file=/etc/deviced/pass-cluster0.conf +pass_cpu_cluster_path_conf_file=/etc/pass/pass-cluster0.conf pass_cpu_cluster_path_load_table=/sys/kernel/debug/cpufreq/cpu0/load_table [CpuCluster1] pass_cpu_cluster_id=1 pass_cpu_cluster_first_cpu=4 -pass_cpu_cluster_path_conf_file=/etc/deviced/pass-cluster1.conf +pass_cpu_cluster_path_conf_file=/etc/pass/pass-cluster1.conf pass_cpu_cluster_path_load_table=/sys/kernel/debug/cpufreq/cpu4/load_table diff --git a/src/pass/pass.h b/src/pass/pass.h index 072972b..631a5e4 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/pmqos/pmqos-parser.c b/src/pmqos/pmqos-parser.c index 563491a..f0baf8b 100644 --- a/src/pmqos/pmqos-parser.c +++ b/src/pmqos/pmqos-parser.c @@ -1,5 +1,5 @@ /* - * PASS + * PASS (Power Aware System Service) * * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. * diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 1fc091f..a1c5b3f 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -1,5 +1,5 @@ /* - * deviced + * PASS (Power Aware System Service) * * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. * @@ -33,7 +33,7 @@ #define DEFAULT_PMQOS_TIMER 3000 -#define PMQOS_CONF_PATH "/etc/deviced/pmqos.conf" +#define PMQOS_CONF_PATH "/etc/pass/pmqos.conf" #define MILLISECONDS(tv) ((tv.tv_sec)*1000 + (tv.tv_nsec)/1000000) #define DELTA(a, b) (MILLISECONDS(a) - MILLISECONDS(b)) @@ -427,7 +427,8 @@ static int booting_done(void *data) _I("booting done"); /* register edbus methods */ - ret = register_edbus_method(DEVICED_PATH_PMQOS, edbus_methods, ARRAY_SIZE(edbus_methods)); + ret = register_edbus_method(DEVICED_PATH_PMQOS, edbus_methods, + ARRAY_SIZE(edbus_methods)); if (ret < 0) _E("fail to init edbus method(%d)", ret); diff --git a/src/pmqos/pmqos.h b/src/pmqos/pmqos.h index 531847c..9de6b1d 100644 --- a/src/pmqos/pmqos.h +++ b/src/pmqos/pmqos.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/proc/cpu-info.c b/src/proc/cpu-info.c deleted file mode 100644 index 48795f1..0000000 --- a/src/proc/cpu-info.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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. - */ - - -#include - -#include "core/log.h" -#include "core/devices.h" -#include "core/edbus-handler.h" -#include "core/common.h" - -#define METHOD_GET_REVISION "GetRevision" -#define PATH_NAME "/proc/cpuinfo" -#define REVISION_NAME "Revision" -#define TOK_DELIMITER ":" -#define END_DELIMITER " \n" - -#define CONVERT_TYPE 10 -#define REVISION_SIZE 4 -#define FILE_BUFF_MAX 1024 -#define NOT_INITIALIZED (-1) - -static int read_from_file(const char *path, char *buf, size_t size) -{ - int fd; - size_t count; - - if (!path) - return -1; - - fd = open(path, O_RDONLY, 0); - if (fd == -1) { - _E("Could not open '%s'", path); - return -1; - } - - count = read(fd, buf, size); - - if ((int)count != -1 && count > 0) { - count = (count < size) ? count : size - 1; - while (count > 0 && buf[count - 1] == '\n') - count--; - buf[count] = '\0'; - } else { - buf[0] = '\0'; - } - - close(fd); - - return 0; -} - -static int get_revision(char *rev, int len) -{ - char buf[FILE_BUFF_MAX]; - char *tag; - char *start, *ptr; - char *saveptr; - long rev_num; - const int radix = 16; - - if (rev == NULL || len <= 0) { - _E("Invalid argument !\n"); - return -1; - } - - if (read_from_file(PATH_NAME, buf, FILE_BUFF_MAX) < 0) { - _E("fail to read %s\n", PATH_NAME); - return -1; - } - - tag = strstr(buf, REVISION_NAME); - if (tag == NULL) { - _E("cannot find Hardware in %s\n", PATH_NAME); - return -1; - } - - start = strstr(tag, TOK_DELIMITER); - if (start == NULL) { - _E("cannot find Hardware in %s\n", PATH_NAME); - return -1; - } - - start++; - ptr = strtok_r(start, END_DELIMITER, &saveptr); - if (!ptr) { - _E("fail to extract tokens"); - return -1; - } - ptr += strlen(ptr); - ptr -= 2; - - memset(rev, 0x00, REVISION_SIZE); - rev_num = strtol(ptr, NULL, radix); - snprintf(rev, len, "%ld", rev_num); - - return 0; -} - -static DBusMessage *dbus_revision_handler(E_DBus_Object *obj, DBusMessage *msg) -{ - DBusMessageIter iter; - DBusMessage *reply; - char rev[FILE_BUFF_MAX]; - char *ptr; - static int ret = NOT_INITIALIZED; - - if (ret != NOT_INITIALIZED) - goto out; - ret = get_revision(rev, sizeof(rev)); - if (ret == 0) - ret = strtol(rev, &ptr, CONVERT_TYPE); -out: - _D("rev : %d", ret); - - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); - return reply; -} - -static const struct edbus_method edbus_methods[] = { - { METHOD_GET_REVISION, NULL, "i", dbus_revision_handler }, -}; - -static void cpu_info_init(void *data) -{ - int ret; - - ret = register_edbus_method(DEVICED_PATH_SYSNOTI, edbus_methods, ARRAY_SIZE(edbus_methods)); - if (ret < 0) - _E("fail to init edbus method(%d)", ret); -} - -static const struct device_ops cpu_info_device_ops = { - .name = "cpu_info", - .init = cpu_info_init, -}; - -DEVICE_OPS_REGISTER(&cpu_info_device_ops) diff --git a/src/proc/proc-handler.c b/src/proc/proc-handler.c deleted file mode 100644 index 6d3f43c..0000000 --- a/src/proc/proc-handler.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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. - */ - - -#include -#include -//#include -//#include -//#include -//#include -//#include -#include -#include -//#include - -#include "core/log.h" -#include "core/common.h" -#include "core/devices.h" -#include "core/device-notifier.h" -#include "core/edbus-handler.h" -#include "shared/score-defines.h" - -#define OOMADJ_SET "oomadj_set" -#define OOM_PMQOS_TIME 2000 /* ms */ -#define SIGNAL_PROC_STATUS "ProcStatus" - -enum proc_status_type { - PROC_STATUS_LAUNCH, - PROC_STATUS_RESUME, - PROC_STATUS_TERMINATE, - PROC_STATUS_FOREGROUND, - PROC_STATUS_BACKGROUND, -}; - -static void memcg_move_group(int pid, int oom_score_adj) -{ - char buf[100]; - FILE *f; - int size; - char exe_name[PATH_MAX]; - - if (get_cmdline_name(pid, exe_name, PATH_MAX) != 0) { - _E("fail to get process name(%d)", pid); - return; - } - - _SD("memcg_move_group : %s, pid = %d", exe_name, pid); - if (oom_score_adj >= OOMADJ_BACKGRD_LOCKED) - snprintf(buf, sizeof(buf), "/sys/fs/cgroup/memory/background/cgroup.procs"); - else if (oom_score_adj >= OOMADJ_FOREGRD_LOCKED && oom_score_adj < OOMADJ_BACKGRD_LOCKED) - snprintf(buf, sizeof(buf), "/sys/fs/cgroup/memory/foreground/cgroup.procs"); - else - return; - - f = fopen(buf, "w"); - if (f == NULL) - return; - size = snprintf(buf, sizeof(buf), "%d", pid); - if (fwrite(buf, size, 1, f) != 1) - _E("fwrite cgroup tasks : %d", pid); - fclose(f); -} - -int set_oom_score_adj_action(int argc, char **argv) -{ - FILE *fp; - int pid = -1; - int new_oom_score_adj = 0; - - if (argc < 2) - return -1; - pid = atoi(argv[0]); - new_oom_score_adj = atoi(argv[1]); - if (pid < 0 || new_oom_score_adj <= -20) - return -1; - - _I("OOMADJ_SET : pid %d, new_oom_score_adj %d", pid, new_oom_score_adj); - - fp = open_proc_oom_score_adj_file(pid, "w"); - if (fp == NULL) - return -1; - if (new_oom_score_adj < OOMADJ_SU) - new_oom_score_adj = OOMADJ_SU; - fprintf(fp, "%d", new_oom_score_adj); - fclose(fp); - - memcg_move_group(pid, new_oom_score_adj); - return 0; -} - -static DBusMessage *dbus_oom_handler(E_DBus_Object *obj, DBusMessage *msg) -{ - DBusError err; - DBusMessageIter iter; - DBusMessage *reply; - pid_t pid; - int ret; - int argc; - char *type_str; - char *argv[2]; - - dbus_error_init(&err); - - if (!dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &type_str, - DBUS_TYPE_INT32, &argc, - DBUS_TYPE_STRING, &argv[0], - DBUS_TYPE_STRING, &argv[1], DBUS_TYPE_INVALID)) { - _E("there is no message"); - ret = -EINVAL; - goto out; - } - - if (argc < 0) { - _E("message is invalid!"); - ret = -EINVAL; - goto out; - } - - pid = get_edbus_sender_pid(msg); - if (kill(pid, 0) == -1) { - _E("%d process does not exist, dbus ignored!", pid); - ret = -ESRCH; - goto out; - } - - if (strncmp(type_str, OOMADJ_SET, strlen(OOMADJ_SET)) == 0) - ret = set_oom_score_adj_action(argc, (char **)&argv); - else - ret = -EINVAL; - -out: - reply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(reply, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); - - return reply; -} - -static void proc_signal_handler(void *data, DBusMessage *msg) -{ - DBusError err; - int ret, type; - pid_t pid; - - ret = dbus_message_is_signal(msg, RESOURCED_INTERFACE_PROCESS, - SIGNAL_PROC_STATUS); - if (!ret) { - _E("It's not active signal!"); - return; - } - - dbus_error_init(&err); - - if (dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &type, - DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID) == 0) { - _E("There's no arguments!"); - return; - } - - if (type == PROC_STATUS_BACKGROUND) - device_notify(DEVICE_NOTIFIER_PROCESS_BACKGROUND, &pid); - if (type == PROC_STATUS_FOREGROUND) - device_notify(DEVICE_NOTIFIER_PROCESS_FOREGROUND, &pid); -} - -static const struct edbus_method edbus_methods[] = { - { OOMADJ_SET, "siss", "i", dbus_oom_handler }, -}; - -static void proc_change_lowmemory(keynode_t *key, void *data) -{ - int state = 0; - - if (vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &state)) - return; - - if (state == VCONFKEY_SYSMAN_LOW_MEMORY_HARD_WARNING) - device_notify(DEVICE_NOTIFIER_PMQOS_OOM, (void *)OOM_PMQOS_TIME); -} - -static void process_init(void *data) -{ - int ret; - - register_edbus_signal_handler(RESOURCED_PATH_PROCESS, - RESOURCED_INTERFACE_PROCESS, SIGNAL_PROC_STATUS, proc_signal_handler); - - ret = register_edbus_method(DEVICED_PATH_PROCESS, edbus_methods, ARRAY_SIZE(edbus_methods)); - if (ret < 0) - _E("fail to init edbus method(%d)", ret); - - vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, - proc_change_lowmemory, NULL); -} - -static const struct device_ops process_device_ops = { - .name = "process", - .init = process_init, -}; - -DEVICE_OPS_REGISTER(&process_device_ops) diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index 5c6284f..2d331f8 100755 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(SHARED_SRCS dbus.c - deviced-systemd.c ) INCLUDE(FindPkgConfig) diff --git a/src/shared/common.h b/src/shared/common.h index 5a3ef23..73f12dd 100644 --- a/src/shared/common.h +++ b/src/shared/common.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2017 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. diff --git a/src/shared/dbus.c b/src/shared/dbus.c index e97d8d5..98b7907 100644 --- a/src/shared/dbus.c +++ b/src/shared/dbus.c @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -380,7 +380,7 @@ static void cb_pending(DBusPendingCall *pending, void *user_data) _E("no message : [%s:%s]", err.name, err.message); if (data->func) { - dbus_set_error(&err, "org.tizen.system.deviced.NoReply", + dbus_set_error(&err, "org.tizen.system.pass.NoReply", "There was no reply to this method call"); data->func(data->data, NULL, &err); dbus_error_free(&err); diff --git a/src/shared/dbus.h b/src/shared/dbus.h index 62bff11..975975e 100644 --- a/src/shared/dbus.h +++ b/src/shared/dbus.h @@ -1,5 +1,5 @@ /* - * deviced + * PASS * * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. * @@ -45,65 +45,16 @@ /* * Device daemon */ -#define DEVICED_BUS_NAME "org.tizen.system.pass" -#define DEVICED_OBJECT_PATH "/Org/Tizen/System/Pass" +#define DEVICED_BUS_NAME "org.tizen.system.deviced" +#define DEVICED_OBJECT_PATH "/Org/Tizen/System/Deviced" #define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME /* Core service: get/set device status operations about device */ #define DEVICED_PATH_CORE DEVICED_OBJECT_PATH"/Core" #define DEVICED_INTERFACE_CORE DEVICED_INTERFACE_NAME".core" -/* Display service: start/stop display(pm), get/set brightness operations about display */ -#define DEVICED_PATH_DISPLAY DEVICED_OBJECT_PATH"/Display" -#define DEVICED_INTERFACE_DISPLAY DEVICED_INTERFACE_NAME".display" -/* Pass service: start/stop pass operations about pass */ +/* PASS service: start/stop pass operations about pass */ #define DEVICED_PATH_PASS DEVICED_OBJECT_PATH"/Pass" #define DEVICED_INTERFACE_PASS DEVICED_INTERFACE_NAME".pass" -/* Hall service: get hall status operations about hall */ -#define DEVICED_PATH_HALL DEVICED_OBJECT_PATH"/Hall" -#define DEVICED_INTERFACE_HALL DEVICED_INTERFACE_NAME".hall" -/* Power service: set resetkey disable operations about power */ -#define DEVICED_PATH_POWER DEVICED_OBJECT_PATH"/Power" -#define DEVICED_INTERFACE_POWER DEVICED_INTERFACE_NAME".power" -/* Storage service: get storage size operatioins about storage */ -#define DEVICED_PATH_STORAGE DEVICED_OBJECT_PATH"/Storage" -#define DEVICED_INTERFACE_STORAGE DEVICED_INTERFACE_NAME".storage" -/* ODE service: request ode popup result operatioins about storage */ -#define DEVICED_PATH_ODE DEVICED_OBJECT_PATH"/Ode" -#define DEVICED_INTERFACE_ODE DEVICED_INTERFACE_NAME".ode" -/* Lowmem service: get critical low status operations about Lowmem */ -#define DEVICED_PATH_LOWMEM DEVICED_OBJECT_PATH"/Lowmem" -#define DEVICED_INTERFACE_LOWMEM DEVICED_INTERFACE_NAME".lowmem" -/* Poweroff service: get power off status operations about Poweroff */ -#define DEVICED_PATH_POWEROFF DEVICED_OBJECT_PATH"/PowerOff" -#define DEVICED_INTERFACE_POWEROFF DEVICED_INTERFACE_NAME".PowerOff" -/* Led service: play/stop led operations about led */ -#define DEVICED_PATH_LED DEVICED_OBJECT_PATH"/Led" -#define DEVICED_INTERFACE_LED DEVICED_INTERFACE_NAME".Led" -/* Block service: manage block device */ -#define STORAGE_BUS_NAME "org.tizen.system.storage" -#define STORAGE_OBJECT_PATH "/Org/Tizen/System/Storage" -#define STORAGE_INTERFACE_NAME STORAGE_BUS_NAME -#define DEVICED_PATH_BLOCK STORAGE_OBJECT_PATH"/Block" -#define DEVICED_PATH_BLOCK_MANAGER DEVICED_PATH_BLOCK"/Manager" -#define DEVICED_INTERFACE_BLOCK_MANAGER STORAGE_INTERFACE_NAME".BlockManager" -/* MMC service: mount/unmount/format mmc operations about mmc */ -#define DEVICED_PATH_MMC DEVICED_OBJECT_PATH"/Mmc" -#define DEVICED_INTERFACE_MMC DEVICED_INTERFACE_NAME".Mmc" -/* Process service: operations about process */ -#define DEVICED_PATH_PROCESS DEVICED_OBJECT_PATH"/Process" -#define DEVICED_INTERFACE_PROCESS DEVICED_INTERFACE_NAME".Process" -/* Key service: operations about key */ -#define DEVICED_PATH_KEY DEVICED_OBJECT_PATH"/Key" -#define DEVICED_INTERFACE_KEY DEVICED_INTERFACE_NAME".Key" -/* USB client service: change usb connection mode */ -#define DEVICED_PATH_USB DEVICED_OBJECT_PATH"/Usb" -#define DEVICED_INTERFACE_USB DEVICED_INTERFACE_NAME".Usb" -/* USB start/stop service: operations about usb start/stop */ -#define DEVICED_PATH_USB_CONTROL DEVICED_OBJECT_PATH"/UsbControl" -#define DEVICED_INTERFACE_USB_CONTROL DEVICED_INTERFACE_NAME".UsbControl" -/* USB host service: operations about usb start/stop */ -#define DEVICED_PATH_USBHOST DEVICED_OBJECT_PATH"/Usbhost" -#define DEVICED_INTERFACE_USBHOST DEVICED_INTERFACE_NAME".Usbhost" -/* Cpu service: operations about cpu */ + #define DEVICED_PATH_CPU DEVICED_OBJECT_PATH"/Cpu" #define DEVICED_INTERFACE_CPU DEVICED_INTERFACE_NAME".Cpu" /* PmQos service: operations about pmqos */ @@ -112,124 +63,6 @@ /* Sysnoti service */ #define DEVICED_PATH_SYSNOTI DEVICED_OBJECT_PATH"/SysNoti" #define DEVICED_INTERFACE_SYSNOTI DEVICED_INTERFACE_NAME".SysNoti" -/* ExtCon service */ -#define DEVICED_PATH_EXTCON DEVICED_OBJECT_PATH"/ExtCon" -#define DEVICED_INTERFACE_EXTCON DEVICED_INTERFACE_NAME".ExtCon" -/* Battery service */ -#define DEVICED_PATH_BATTERY DEVICED_OBJECT_PATH"/Battery" -#define DEVICED_INTERFACE_BATTERY DEVICED_INTERFACE_NAME".Battery" -/* Time service */ -#define DEVICED_PATH_TIME DEVICED_OBJECT_PATH"/Time" -#define DEVICED_INTERFACE_TIME DEVICED_INTERFACE_NAME".Time" -/* IR service */ -#define DEVICED_PATH_IR DEVICED_OBJECT_PATH"/Ir" -#define DEVICED_INTERFACE_IR DEVICED_INTERFACE_NAME".ir" -/* USB_HOST_TEST service */ -#define DEVICED_PATH_USB_HOST_TEST DEVICED_OBJECT_PATH"/UsbHostTest" -#define DEVICED_INTERFACE_USB_HOST_TEST DEVICED_INTERFACE_NAME".UsbHostTest" - -/* Apps service */ -#define DEVICED_PATH_APPS DEVICED_OBJECT_PATH"/Apps" -#define DEVICED_INTERFACE_APPS DEVICED_INTERFACE_NAME".Apps" - -/* GPIO service: status check about gpio */ -#define DEVICED_PATH_GPIO DEVICED_OBJECT_PATH"/Gpio" -#define DEVICED_INTERFACE_GPIO DEVICED_INTERFACE_NAME".Gpio" - -/* HDMICEC service: status check about gpio */ -#define DEVICED_PATH_HDMICEC DEVICED_OBJECT_PATH"/HdmiCec" -#define DEVICED_INTERFACE_HDMICEC DEVICED_INTERFACE_NAME".HdmiCec" - -/* Tzip service: Archive file system */ -#define DEVICED_PATH_TZIP DEVICED_OBJECT_PATH"/Tzip" -#define DEVICED_INTERFACE_TZIP DEVICED_INTERFACE_NAME".Tzip" - -/* - * Vibrator daemon - */ -#define VIBRATOR_BUS_NAME "org.tizen.system.vibrator" -#define VIBRATOR_OBJECT_PATH "/Org/Tizen/System/Vibrator" -#define VIBRATOR_INTERFACE_NAME VIBRATOR_BUS_NAME -/* Core service: get/set device status operations about device */ -#define VIBRATOR_PATH_CORE VIBRATOR_OBJECT_PATH"/Core" -#define VIBRATOR_INTERFACE_CORE VIBRATOR_INTERFACE_NAME".core" - -#define VIBRATOR_PATH_HAPTIC VIBRATOR_OBJECT_PATH"/Haptic" -#define VIBRATOR_INTERFACE_HAPTIC VIBRATOR_INTERFACE_NAME".haptic" - -/* - * Resource daemon - */ -#define RESOURCED_BUS_NAME "org.tizen.resourced" -#define RESOURCED_OBJECT_PATH "/Org/Tizen/ResourceD" -#define RESOURCED_INTERFACE_NAME RESOURCED_BUS_NAME - -#define RESOURCED_PATH_PROCESS RESOURCED_OBJECT_PATH"/Process" -#define RESOURCED_INTERFACE_PROCESS RESOURCED_INTERFACE_NAME".process" -#define RESOURCED_METHOD_ACTIVE "Active" - -/* - * Popup launcher - */ -#define POPUP_BUS_NAME "org.tizen.system.popup" -#define POPUP_OBJECT_PATH "/Org/Tizen/System/Popup" -#define POPUP_INTERFACE_NAME POPUP_BUS_NAME -/* LED */ -#define POPUP_PATH_LED POPUP_OBJECT_PATH"/Led" -#define POPUP_INTERFACE_LED POPUP_INTERFACE_NAME".Led" -/* Notification */ -#define POPUP_PATH_NOTI POPUP_OBJECT_PATH"/Noti" -#define POPUP_INTERFACE_NOTI POPUP_INTERFACE_NAME".Noti" -/* Power key longpress */ -#define POPUP_PATH_POWERKEY POPUP_OBJECT_PATH"/Powerkey" -#define POPUP_INTERFACE_POWERKEY POPUP_INTERFACE_NAME".Powerkey" -/* Low battery */ -#define POPUP_PATH_LOWBAT POPUP_OBJECT_PATH"/Lowbat" -#define POPUP_INTERFACE_LOWBAT POPUP_INTERFACE_NAME".Lowbat" -/* Low memory */ -#define POPUP_PATH_LOWMEM POPUP_OBJECT_PATH"/Lowmem" -#define POPUP_INTERFACE_LOWMEM POPUP_INTERFACE_NAME".Lowmem" -/* MMC */ -#define POPUP_PATH_MMC POPUP_OBJECT_PATH"/Mmc" -#define POPUP_INTERFACE_MMC POPUP_INTERFACE_NAME".Mmc" -/* USB */ -#define POPUP_PATH_USB POPUP_OBJECT_PATH"/Usb" -#define POPUP_INTERFACE_USB POPUP_INTERFACE_NAME".Usb" -/* USB otg */ -#define POPUP_PATH_USBOTG POPUP_OBJECT_PATH"/Usbotg" -#define POPUP_INTERFACE_USBOTG POPUP_INTERFACE_NAME".Usbotg" -/* USB host */ -#define POPUP_PATH_USBHOST POPUP_OBJECT_PATH"/Usbhost" -#define POPUP_INTERFACE_USBHOST POPUP_INTERFACE_NAME".Usbhost" -/* System */ -#define POPUP_PATH_SYSTEM POPUP_OBJECT_PATH"/System" -#define POPUP_INTERFACE_SYSTEM POPUP_INTERFACE_NAME".System" -/* Crash */ -#define POPUP_PATH_CRASH POPUP_OBJECT_PATH"/Crash" -#define POPUP_INTERFACE_CRASH POPUP_INTERFACE_NAME".Crash" -/* ODE */ -#define POPUP_PATH_ODE POPUP_OBJECT_PATH"/Ode" -#define POPUP_INTERFACE_ODE POPUP_INTERFACE_NAME".Ode" -/* Servant */ -#define POPUP_PATH_SERVANT POPUP_OBJECT_PATH"/Servant" -#define POPUP_IFACE_SERVANT POPUP_INTERFACE_NAME".Servant" - -#define POPUP_PATH_APP POPUP_OBJECT_PATH"/Apps" -#define POPUP_IFACE_APP POPUP_BUS_NAME".Apps" - -#define POPUP_METHOD_LAUNCH "PopupLaunch" -#define POPUP_METHOD_TERMINATE "AppTerminateByPid" -#define POPUP_KEY_CONTENT "_SYSPOPUP_CONTENT_" - -/* - * Crash daemon - */ -#define CRASHD_BUS_NAME "org.tizen.system.crashd" -#define CRASHD_OBJECT_PATH "/Org/Tizen/System/CrashD" -#define CRASHD_INTERFACE_NAME CRASHD_BUS_NAME - -#define CRASHD_PATH_CRASH CRASHD_OBJECT_PATH"/Crash" -#define CRASHD_INTERFACE_CRASH CRASHD_INTERFACE_NAME".Crash" struct dbus_byte { const unsigned char *data; diff --git a/src/shared/deviced-internal.h b/src/shared/deviced-internal.h deleted file mode 100644 index b26d67e..0000000 --- a/src/shared/deviced-internal.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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 ___DEVICED_INTERNAL___ -#define ___DEVICED_INTERNAL___ -#include -#include "dd-deviced.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* This file will be removed */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* ___DEVICED_INTERNAL___ */ diff --git a/src/shared/deviced-priv.h b/src/shared/deviced-priv.h index 0adb00f..6fab212 100644 --- a/src/shared/deviced-priv.h +++ b/src/shared/deviced-priv.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/shared/deviced-systemd.h b/src/shared/deviced-systemd.h deleted file mode 100644 index 4dabe0a..0000000 --- a/src/shared/deviced-systemd.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * 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 __DEVICED_SYSTEMD_H__ -#define __DEVICED_SYSTEMD_H__ - -#include -#include - -#define DBUS_IFACE_DBUS_PROPERTIES DBUS_SERVICE_DBUS ".Properties" - -#define SYSTEMD_DBUS_DEST "org.freedesktop.systemd1" -#define SYSTEMD_DBUS_IFACE_MANAGER SYSTEMD_DBUS_DEST ".Manager" -#define SYSTEMD_DBUS_IFACE_UNIT SYSTEMD_DBUS_DEST ".Unit" -#define SYSTEMD_DBUS_IFACE_SERVICE SYSTEMD_DBUS_DEST ".Service" -#define SYSTEMD_DBUS_IFACE_TARGET SYSTEMD_DBUS_DEST ".Target" - -#define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1" -#define SYSTEMD_DBUS_UNIT_PATH SYSTEMD_DBUS_PATH "/unit/" - -int deviced_systemd_start_unit(char *name); -int deviced_systemd_stop_unit(char *name); - -int deviced_systemd_get_manager_property(const char *iface, const char *property, GVariant **variant); -int deviced_systemd_get_unit_property(const char *unit, const char *property, GVariant **variant); -int deviced_systemd_get_service_property(const char* unit, const char* property, GVariant **variant); - -int deviced_systemd_get_manager_property_as_int32(const char *iface, const char *property, int *result); -int deviced_systemd_get_manager_property_as_uint32(const char *iface, const char *property, unsigned int *result); -int deviced_systemd_get_manager_property_as_int64(const char *iface, const char *property, long long *result); -int deviced_systemd_get_manager_property_as_uint64(const char *iface, const char *property, unsigned long long *result); -int deviced_systemd_get_manager_property_as_string(const char *iface, const char *property, char **result); -int deviced_systemd_get_unit_property_as_int32(const char *unit, const char *property, int *result); -int deviced_systemd_get_unit_property_as_uint32(const char *unit, const char *property, unsigned int *result); -int deviced_systemd_get_unit_property_as_int64(const char *unit, const char *property, long long *result); -int deviced_systemd_get_unit_property_as_uint64(const char *unit, const char *property, unsigned long long *result); -int deviced_systemd_get_unit_property_as_string(const char *unit, const char *property, char **result); -int deviced_systemd_get_service_property_as_int32(const char *unit, const char *property, int *result); -int deviced_systemd_get_service_property_as_uint32(const char *unit, const char *property, unsigned int *result); -int deviced_systemd_get_service_property_as_int64(const char *unit, const char *property, long long *result); -int deviced_systemd_get_service_property_as_uint64(const char *unit, const char *property, unsigned long long *result); -int deviced_systemd_get_service_property_as_string(const char *unit, const char *property, char **result); - -int deviced_systemd_instance_new_from_template(const char *template, const char *instance, const char **name); - -#endif diff --git a/src/shared/log-macro.h b/src/shared/log-macro.h index 407995e..ab42821 100644 --- a/src/shared/log-macro.h +++ b/src/shared/log-macro.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/src/shared/log.h b/src/shared/log.h index 29b6c85..5850d15 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ #ifndef __LOG_H__ #define __LOG_H__ -#ifdef ENABLE_LIBDEVICED_DLOG +#ifdef ENABLE_LIBPASS_DLOG #define ENABLE_DLOG #endif -#define LOG_TAG "DEVICED" +#define LOG_TAG "PASS" #include "shared/log-macro.h" #endif diff --git a/src/shared/deviced-systemd.c b/src/shared/pass-systemd.c similarity index 74% rename from src/shared/deviced-systemd.c rename to src/shared/pass-systemd.c index 8358256..e7f5f6f 100644 --- a/src/shared/deviced-systemd.c +++ b/src/shared/pass-systemd.c @@ -1,5 +1,5 @@ /* - * deviced + * PASS * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * @@ -28,7 +28,7 @@ #include "common.h" #include "dbus.h" -#include "deviced-systemd.h" +#include "pass-systemd.h" #include "core/log.h" @@ -52,7 +52,7 @@ typedef unsigned long long uint64; #define g_variant_get_function_string(v) g_variant_dup_string(v, NULL) -static int deviced_systemd_proxy_call_sync(const char *name, +static int pass_systemd_proxy_call_sync(const char *name, const char *path, const char *iface, const char *method, @@ -109,13 +109,13 @@ static int deviced_systemd_proxy_call_sync(const char *name, return 0; } -static int deviced_systemd_start_or_stop_unit(char *method, char *name) +static int pass_systemd_start_or_stop_unit(char *method, char *name) { int ret; GVariant *reply = NULL; _I("Starting: %s %s", method, name); - ret = deviced_systemd_proxy_call_sync(SYSTEMD_DBUS_DEST, + ret = pass_systemd_proxy_call_sync(SYSTEMD_DBUS_DEST, SYSTEMD_DBUS_PATH, SYSTEMD_DBUS_IFACE_MANAGER, method, @@ -141,21 +141,21 @@ finish: return ret; } -int deviced_systemd_start_unit(char *name) +int pass_systemd_start_unit(char *name) { assert(name); - return deviced_systemd_start_or_stop_unit("StartUnit", name); + return pass_systemd_start_or_stop_unit("StartUnit", name); } -int deviced_systemd_stop_unit(char *name) +int pass_systemd_stop_unit(char *name) { assert(name); - return deviced_systemd_start_or_stop_unit("StopUnit", name); + return pass_systemd_start_or_stop_unit("StopUnit", name); } -static char *deviced_systemd_get_unit_dbus_path(const char *unit) +static char *pass_systemd_get_unit_dbus_path(const char *unit) { char *path = NULL; int i; @@ -201,7 +201,7 @@ static char *deviced_systemd_get_unit_dbus_path(const char *unit) return path; } -static int deviced_systemd_get_property(const char *name, +static int pass_systemd_get_property(const char *name, const char *path, const char *iface, const char *method, @@ -216,7 +216,7 @@ static int deviced_systemd_get_property(const char *name, interface, property); - ret = deviced_systemd_proxy_call_sync(name, + ret = pass_systemd_proxy_call_sync(name, path, iface, method, @@ -226,14 +226,14 @@ static int deviced_systemd_get_property(const char *name, return ret; } -int deviced_systemd_get_manager_property(const char *iface, +int pass_systemd_get_manager_property(const char *iface, const char *property, GVariant **variant) { assert(iface); assert(property); - return deviced_systemd_get_property(SYSTEMD_DBUS_DEST, + return pass_systemd_get_property(SYSTEMD_DBUS_DEST, SYSTEMD_DBUS_PATH, DBUS_IFACE_DBUS_PROPERTIES, "Get", @@ -242,7 +242,7 @@ int deviced_systemd_get_manager_property(const char *iface, variant); } -int deviced_systemd_get_unit_property(const char *unit, +int pass_systemd_get_unit_property(const char *unit, const char *property, GVariant **variant) { @@ -252,9 +252,9 @@ int deviced_systemd_get_unit_property(const char *unit, assert(unit); assert(property); - escaped = deviced_systemd_get_unit_dbus_path(unit); + escaped = pass_systemd_get_unit_dbus_path(unit); - r = deviced_systemd_get_property(SYSTEMD_DBUS_DEST, + r = pass_systemd_get_property(SYSTEMD_DBUS_DEST, escaped, DBUS_IFACE_DBUS_PROPERTIES, "Get", @@ -265,7 +265,7 @@ int deviced_systemd_get_unit_property(const char *unit, return r; } -int deviced_systemd_get_service_property(const char *unit, +int pass_systemd_get_service_property(const char *unit, const char *property, GVariant **variant) { @@ -275,9 +275,9 @@ int deviced_systemd_get_service_property(const char *unit, assert(unit); assert(property); - escaped = deviced_systemd_get_unit_dbus_path(unit); + escaped = pass_systemd_get_unit_dbus_path(unit); - ret = deviced_systemd_get_property(SYSTEMD_DBUS_DEST, + ret = pass_systemd_get_property(SYSTEMD_DBUS_DEST, escaped, DBUS_IFACE_DBUS_PROPERTIES, "Get", @@ -289,7 +289,7 @@ int deviced_systemd_get_service_property(const char *unit, } #define DEFINE_SYSTEMD_GET_PROPERTY(iface, type, value) \ - int deviced_systemd_get_##iface##_property_as_##type( \ + int pass_systemd_get_##iface##_property_as_##type( \ const char *target, \ const char *property, \ value*result) \ @@ -299,7 +299,7 @@ int deviced_systemd_get_service_property(const char *unit, GVariant *inner; \ int r; \ \ - r = deviced_systemd_get_##iface##_property(target, \ + r = pass_systemd_get_##iface##_property(target, \ property, \ &var); \ if (r < 0) { \ @@ -325,38 +325,38 @@ int deviced_systemd_get_service_property(const char *unit, return 0; \ } -/* int deviced_systemd_get_manager_property_as_int32(const char *iface, const char *property, int *result); */ +/* int pass_systemd_get_manager_property_as_int32(const char *iface, const char *property, int *result); */ DEFINE_SYSTEMD_GET_PROPERTY(manager, int32, int) -/* int deviced_systemd_get_manager_property_as_uint32(const char *iface, const char *property, unsigned int *result); */ +/* int pass_systemd_get_manager_property_as_uint32(const char *iface, const char *property, unsigned int *result); */ DEFINE_SYSTEMD_GET_PROPERTY(manager, uint32, uint) -/* int deviced_systemd_get_manager_property_as_int64(const char *iface, const char *property, long long *result); */ +/* int pass_systemd_get_manager_property_as_int64(const char *iface, const char *property, long long *result); */ DEFINE_SYSTEMD_GET_PROPERTY(manager, int64, long long) -/* int deviced_systemd_get_manager_property_as_uint64(const char *iface, const char *property, unsigned long long *result); */ +/* int pass_systemd_get_manager_property_as_uint64(const char *iface, const char *property, unsigned long long *result); */ DEFINE_SYSTEMD_GET_PROPERTY(manager, uint64, unsigned long long) -/* int deviced_systemd_get_manager_property_as_string(const char *iface, const char *property, char **result); */ +/* int pass_systemd_get_manager_property_as_string(const char *iface, const char *property, char **result); */ DEFINE_SYSTEMD_GET_PROPERTY(manager, string, char*) -/* int deviced_systemd_get_unit_property_as_int32(const char *unit, const char *property, int *result); */ +/* int pass_systemd_get_unit_property_as_int32(const char *unit, const char *property, int *result); */ DEFINE_SYSTEMD_GET_PROPERTY(unit, int32, int) -/* int deviced_systemd_get_unit_property_as_uint32(const char *unit, const char *property, unsigned int *result); */ +/* int pass_systemd_get_unit_property_as_uint32(const char *unit, const char *property, unsigned int *result); */ DEFINE_SYSTEMD_GET_PROPERTY(unit, uint32, uint) -/* int deviced_systemd_get_unit_property_as_int64(const char *unit, const char *property, long long *result); */ +/* int pass_systemd_get_unit_property_as_int64(const char *unit, const char *property, long long *result); */ DEFINE_SYSTEMD_GET_PROPERTY(unit, int64, long long) -/* int deviced_systemd_get_unit_property_as_uint64(const char *unit, const char *property, unsigned long long *result); */ +/* int pass_systemd_get_unit_property_as_uint64(const char *unit, const char *property, unsigned long long *result); */ DEFINE_SYSTEMD_GET_PROPERTY(unit, uint64, unsigned long long) -/* int deviced_systemd_get_unit_property_as_string(const char *unit, const char *property, char **result); */ +/* int pass_systemd_get_unit_property_as_string(const char *unit, const char *property, char **result); */ DEFINE_SYSTEMD_GET_PROPERTY(unit, string, char*) -/* int deviced_systemd_get_service_property_as_int32(const char *unit, const char *property, int *result); */ +/* int pass_systemd_get_service_property_as_int32(const char *unit, const char *property, int *result); */ DEFINE_SYSTEMD_GET_PROPERTY(service, int32, int) -/* int deviced_systemd_get_service_property_as_uint32(const char *unit, const char *property, unsigned int *result); */ +/* int pass_systemd_get_service_property_as_uint32(const char *unit, const char *property, unsigned int *result); */ DEFINE_SYSTEMD_GET_PROPERTY(service, uint32, uint) -/* int deviced_systemd_get_service_property_as_int64(const char *unit, const char *property, long long *result); */ +/* int pass_systemd_get_service_property_as_int64(const char *unit, const char *property, long long *result); */ DEFINE_SYSTEMD_GET_PROPERTY(service, int64, long long) -/* int deviced_systemd_get_service_property_as_uint64(const char *unit, const char *property, unsigned long long *result); */ +/* int pass_systemd_get_service_property_as_uint64(const char *unit, const char *property, unsigned long long *result); */ DEFINE_SYSTEMD_GET_PROPERTY(service, uint64, unsigned long long) -/* int deviced_systemd_get_service_property_as_string(const char *unit, const char *property, char **result); */ +/* int pass_systemd_get_service_property_as_string(const char *unit, const char *property, char **result); */ DEFINE_SYSTEMD_GET_PROPERTY(service, string, char*) -int deviced_systemd_instance_new_from_template(const char *template, +int pass_systemd_instance_new_from_template(const char *template, const char *instance, const char **name) { diff --git a/src/shared/pass-systemd.h b/src/shared/pass-systemd.h new file mode 100644 index 0000000..4374df0 --- /dev/null +++ b/src/shared/pass-systemd.h @@ -0,0 +1,62 @@ +/* + * PASS + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * 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 __PASS_SYSTEMD_H__ +#define __PASS_SYSTEMD_H__ + +#include +#include + +#define DBUS_IFACE_DBUS_PROPERTIES DBUS_SERVICE_DBUS ".Properties" + +#define SYSTEMD_DBUS_DEST "org.freedesktop.systemd1" +#define SYSTEMD_DBUS_IFACE_MANAGER SYSTEMD_DBUS_DEST ".Manager" +#define SYSTEMD_DBUS_IFACE_UNIT SYSTEMD_DBUS_DEST ".Unit" +#define SYSTEMD_DBUS_IFACE_SERVICE SYSTEMD_DBUS_DEST ".Service" +#define SYSTEMD_DBUS_IFACE_TARGET SYSTEMD_DBUS_DEST ".Target" + +#define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1" +#define SYSTEMD_DBUS_UNIT_PATH SYSTEMD_DBUS_PATH "/unit/" + +int pass_systemd_start_unit(char *name); +int pass_systemd_stop_unit(char *name); + +int pass_systemd_get_manager_property(const char *iface, const char *property, GVariant **variant); +int pass_systemd_get_unit_property(const char *unit, const char *property, GVariant **variant); +int pass_systemd_get_service_property(const char* unit, const char* property, GVariant **variant); + +int pass_systemd_get_manager_property_as_int32(const char *iface, const char *property, int *result); +int pass_systemd_get_manager_property_as_uint32(const char *iface, const char *property, unsigned int *result); +int pass_systemd_get_manager_property_as_int64(const char *iface, const char *property, long long *result); +int pass_systemd_get_manager_property_as_uint64(const char *iface, const char *property, unsigned long long *result); +int pass_systemd_get_manager_property_as_string(const char *iface, const char *property, char **result); +int pass_systemd_get_unit_property_as_int32(const char *unit, const char *property, int *result); +int pass_systemd_get_unit_property_as_uint32(const char *unit, const char *property, unsigned int *result); +int pass_systemd_get_unit_property_as_int64(const char *unit, const char *property, long long *result); +int pass_systemd_get_unit_property_as_uint64(const char *unit, const char *property, unsigned long long *result); +int pass_systemd_get_unit_property_as_string(const char *unit, const char *property, char **result); +int pass_systemd_get_service_property_as_int32(const char *unit, const char *property, int *result); +int pass_systemd_get_service_property_as_uint32(const char *unit, const char *property, unsigned int *result); +int pass_systemd_get_service_property_as_int64(const char *unit, const char *property, long long *result); +int pass_systemd_get_service_property_as_uint64(const char *unit, const char *property, unsigned long long *result); +int pass_systemd_get_service_property_as_string(const char *unit, const char *property, char **result); + +int pass_systemd_instance_new_from_template(const char *template, const char *instance, const char **name); + +#endif diff --git a/src/shared/score-defines.h b/src/shared/score-defines.h index 44638e7..c3163f6 100644 --- a/src/shared/score-defines.h +++ b/src/shared/score-defines.h @@ -1,7 +1,7 @@ /* - * deviced + * PASS (Power Aware System Service) * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2017 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. -- 2.7.4