From: Yunhee Seo Date: Fri, 31 May 2024 08:11:26 +0000 (+0900) Subject: plugin: Remove battery module from mobile plugin X-Git-Tag: accepted/tizen/8.0/unified/20240618.013352~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a8ae95742568d264382a50f1a38a32e166ac6a5;p=platform%2Fcore%2Fsystem%2Fdeviced.git plugin: Remove battery module from mobile plugin The existing deviced plugin battery module was highly dependent on the battery inside the deviced(core) and used the function, data structures directly, which effectively faded the meaning of the plugin. By completely moving the code to mobile profile plugin backend git and removing the build dependency, it became possible to delete the corresponding plugin's battery module. Since there is no need for the remaining code to exist in the deviced git anymore, battery module in mobile plugin is deleted. Change-Id: I1b1d98ecc9434dd0891c8a9ebead870b2a9e3d4e Signed-off-by: Yunhee Seo --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b3ae7c4..4d11ffe4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,6 @@ ADD_SUBDIRECTORY(plugins/mobile/display) ADD_SUBDIRECTORY(plugins/wearable/display) ADD_SUBDIRECTORY(plugins/tv/display) IF(BATTERY_MODULE STREQUAL on) - ADD_SUBDIRECTORY(plugins/mobile/battery) ADD_SUBDIRECTORY(plugins/wearable/battery) ENDIF() ADD_SUBDIRECTORY(isu) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 022887c5..4044af66 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -232,9 +232,6 @@ mv %{_sysconfdir}/deviced/display-profile-mobile.conf %{_sysconfdir}/deviced/dis mv %{_sysconfdir}/deviced/power-profile-mobile.conf %{_sysconfdir}/deviced/power.conf mkdir -p %{_libdir}/deviced mv %{_libdir}/mobile-display.so %{_libdir}/deviced/display.so -%if %{?battery_module} == on -mv %{_libdir}/mobile-battery.so %{_libdir}/deviced/battery.so -%endif %post plugin-profile-wearable mv %{_sysconfdir}/deviced/display-profile-wearable.conf %{_sysconfdir}/deviced/display.conf @@ -339,9 +336,6 @@ mv %{_libdir}/tv-display.so %{_libdir}/deviced/display.so %config %{_sysconfdir}/deviced/display-profile-mobile.conf %config %{_sysconfdir}/deviced/power-profile-mobile.conf %{_libdir}/mobile-display.so -%if %{?battery_module} == on -%{_libdir}/mobile-battery.so -%endif %{_unitdir}/rndis.service %{_bindir}/rndis.sh diff --git a/plugins/mobile/battery/CMakeLists.txt b/plugins/mobile/battery/CMakeLists.txt deleted file mode 100644 index 778ab93b..00000000 --- a/plugins/mobile/battery/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(mobile-battery C) - -FILE(GLOB ALL_SRCS "*.c") -SET(SRCS ${ALL_SRCS}) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/battery) - -INCLUDE(FindPkgConfig) -pkg_check_modules(libpkgs REQUIRED - dlog - glib-2.0 - gio-2.0 - gio-unix-2.0 - libinput) - -FOREACH(flag ${libpkgs_CFLAGS}) - SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}") -ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") - -ADD_DEFINITIONS("-DENABLE_DLOG") - -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS} deviced-common-private) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME mobile-battery) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c deleted file mode 100644 index 578d65a8..00000000 --- a/plugins/mobile/battery/battery-notification.c +++ /dev/null @@ -1,173 +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 "battery.h" -#include "battery-parser.h" -#include "power-supply.h" -#include "lowbat-handler.h" -#include "battery-ops.h" -#include "core.h" -#include "display-lock.h" -#include "display-ops.h" -#include "display-state-transition.h" -#include "poll.h" -#include "shared/eventsystem.h" -#include "shared/plugin.h" -#include "shared/device-notifier.h" -#include "shared/apps.h" - -#define REMOVE_POPUP "remove_battery_popups" - -static struct display_plugin *disp_plgn; -static guint abnormal_timer; - -static void health_timer_reset(void) -{ - abnormal_timer = 0; -} - -static gboolean health_timer_cb(void *data) -{ - int ret = 0; - enum syscommon_deviced_battery_health_type battery_health; - char *battery_health_s = NULL; - bool battery_do_not_disturb = false; - - health_timer_reset(); - - ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_BATTERY), - DEVICED_BATTERY_ATTR_INT_STATUS_HEALTH, (int32_t *) &battery_health); - if (ret < 0) { - _E("Failed to get battery health status."); - return G_SOURCE_REMOVE; - } - - if (battery_health != SYSCOMMON_DEVICED_BATTERY_HEALTH_LOW && battery_health != SYSCOMMON_DEVICED_BATTERY_HEALTH_HIGH) - return G_SOURCE_REMOVE; - - battery_health_s = calloc(1, SYSCOMMON_RESMAN_BUFF_MAX); - if (battery_health_s) { - battery_health_s[SYSCOMMON_RESMAN_BUFF_MAX - 1] = '\0'; - ret = syscommon_resman_get_resource_attr_string(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_BATTERY), - DEVICED_BATTERY_ATTR_STRING_STATUS_HEALTH, battery_health_s); - if (ret == 0) { - CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery_health_s); - } - free(battery_health_s); - } - - syscommon_notifier_emit_notify(DEVICED_NOTIFIER_BATTERY_HEALTH, (void *)&battery_health); - ret = syscommon_resman_get_resource_attr_bool(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_BATTERY), - DEVICED_BATTERY_ATTR_BOOL_DO_NOT_DISTURB, &battery_do_not_disturb); - if (ret == 0 && !battery_do_not_disturb) - syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY), - DEVICED_DISPLAY_ATTR_TUPLE2_CURRENT_STATE_WITH_OPTION, DEVICED_EVENT_MISC_POPUP, SYSCOMMON_DEVICED_DISPLAY_STATE_DIM); - - syscommon_resman_set_resource_attr_uint64_3(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY), - DEVICED_DISPLAY_ATTR_TUPLE3_UNLOCK_WITH_OPTION, DEVICED_EVENT_MISC_POPUP, - SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, DEVICED_DISPLAY_LOCK_SLEEP_MARGIN); - - syscommon_resman_set_resource_attr_uint64_4(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY), - DEVICED_DISPLAY_ATTR_TUPLE4_LOCK_WITH_OPTION, DEVICED_EVENT_MISC_POPUP, - SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, DEVICED_DISPLAY_STATE_STAY_CUR_STATE, 0); - - if (battery_health == SYSCOMMON_DEVICED_BATTERY_HEALTH_LOW) { - syscommon_resman_set_resource_attr_uint64_4(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY), - DEVICED_DISPLAY_ATTR_TUPLE4_LOCK_WITH_OPTION, DEVICED_EVENT_BATTERY_HEALTH_OVERCOOL, - SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, DEVICED_DISPLAY_STATE_STAY_CUR_STATE, 60000); - syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_BATTERY), - DEVICED_BATTERY_ATTR_INT_LOW_BATTERY_POPUP, SYSCOMMON_DEVICED_BATTERY_OPT_ERR_TEMP_LOW); - } else if (battery_health == SYSCOMMON_DEVICED_BATTERY_HEALTH_HIGH) { - syscommon_resman_set_resource_attr_uint64_4(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY), - DEVICED_DISPLAY_ATTR_TUPLE4_LOCK_WITH_OPTION, DEVICED_EVENT_BATTERY_HEALTH_OVERHEAT, - SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, DEVICED_DISPLAY_STATE_STAY_CUR_STATE, 60000); - syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_BATTERY), - DEVICED_BATTERY_ATTR_INT_LOW_BATTERY_POPUP, SYSCOMMON_DEVICED_BATTERY_OPT_ERR_TEMP_HIGH); - } - - return G_SOURCE_REMOVE; -} - -static void abnormal_popup_dbus_signal_handler(GDBusConnection *conn, - const gchar *sender, - const gchar *path, - const gchar *iface, - const gchar *name, - GVariant *param, - gpointer user_data) - -{ - int ret = 0; - enum syscommon_deviced_battery_health_type battery_health; - - ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_BATTERY), - DEVICED_BATTERY_ATTR_INT_STATUS_HEALTH, (int32_t *) &battery_health); - if (ret < 0) { - _E("Failed to get battery health status."); - return; - } - - if (battery_health == SYSCOMMON_DEVICED_BATTERY_HEALTH_GOOD) - return; - - _I("Restart health timer."); - abnormal_timer = g_timeout_add_seconds(DEVICED_BATTERY_ABNORMAL_CHECK_TIMER_INTERVAL, - health_timer_cb, NULL); - if (abnormal_timer == 0) - _E("Failed to add abnormal check timer."); -} - -static void battery_notification_init(void *data) -{ - struct battery_plugin *plugin = (struct battery_plugin *)data; - int ret; - - if (!plugin) - return; - - _D("Add plugins for battery notification."); - - ret = gdbus_signal_subscribe(NULL, DEVICED_PATH_SYSNOTI, - DEVICED_INTERFACE_SYSNOTI, SIGNAL_CHARGEERR_RESPONSE, abnormal_popup_dbus_signal_handler, NULL, NULL); - if (ret <= 0) - _E("Failed to init dbus signal: %d", ret); -} - -static const struct battery_ops battery_notification_ops = { - .name = "battery_notification", - .init = battery_notification_init, -}; - -BATTERY_OPS_REGISTER(&battery_notification_ops) - -static void __CONSTRUCTOR__ initialize(void) -{ - disp_plgn = get_var_display_plugin(); - if (!disp_plgn) - _E("Failed to get display plugin variable."); -}