battery: Add is_possible_to_notify_battery_full() 07/296407/3 accepted/tizen/8.0/unified/20231005.093832 accepted/tizen/unified/20230731.175246 tizen_8.0_m2_release
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 26 Jul 2023 10:53:09 +0000 (19:53 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 28 Jul 2023 02:28:32 +0000 (11:28 +0900)
is_possible_to_notify_battery_full() is used from deviced to decide whether to notify battery full or not.
This function is relocated from deviced plugin module to here.

Change-Id: I02f7d52f0b2d3b5df4b9372c3f136aab2bb36df2
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
CMakeLists.txt
packaging/system-plugin-backend-deviced-mobile.spec
src/battery/CMakeLists.txt [new file with mode: 0644]
src/battery/battery.c

index ef139bf2d809f4fc73dd4716c2cc9a35fe527857..7771931a0d2af470eb3ee6fd8e6151863d8097b8 100644 (file)
@@ -1,18 +1,8 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(system-plugin-backend-deviced-mobile C)
+PROJECT(${PLUGIN_BACKEND_NAME} C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
-SET(PKG_MODULES libsyscommon)
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(PKGS REQUIRED ${PKG_MODULES})
-FOREACH(FLAG ${PKGS_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${FLAG}")
-ENDFOREACH(FLAG)
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
 
-SET(SRCS src/battery/battery.c)
-
-ADD_LIBRARY(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS})
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${PLUGIN_LIB_DIR} COMPONENT RuntimeLibraries)
+ADD_SUBDIRECTORY(src/battery)
index 644c8d6d121e445aba26d51544e4c06754f8794a..ef908402b4dc693291a7582a9f3a6927ab61ce90 100644 (file)
@@ -12,18 +12,22 @@ Requires(postun): /sbin/ldconfig
 
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(libsyscommon)
+BuildRequires:  pkgconfig(libsyscommon-plugin-api-deviced)
+BuildRequires:  pkgconfig(dlog)
 
 %description
 System plugin backend for deviced mobile profile
 
+%define SYSTEM_PLUGIN_LIBDIR %{_libdir}/system/plugin
+
 %prep
 %setup -q
 cp %{SOURCE1} .
 
-%define SYSTEM_PLUGIN_LIBDIR %{_libdir}/system/plugin
-
 %build
-%cmake . -DPLUGIN_LIB_DIR=%{SYSTEM_PLUGIN_LIBDIR}
+%cmake . -DPLUGIN_BACKEND_NAME=%{name} \
+       -DPLUGIN_LIB_DIR=%{SYSTEM_PLUGIN_LIBDIR} \
+       -DPLUGIN_DEVICED_ENABLE_DLOG=1
 
 make %{?jobs:-j%jobs}
 
@@ -40,4 +44,4 @@ make %{?jobs:-j%jobs}
 %defattr(-,root,root,-)
 %manifest %{name}.manifest
 %license LICENSE.Apache-2.0
-%{SYSTEM_PLUGIN_LIBDIR}/*.so
+%{SYSTEM_PLUGIN_LIBDIR}/libplugin-backend-deviced-battery.so
diff --git a/src/battery/CMakeLists.txt b/src/battery/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e077bc5
--- /dev/null
@@ -0,0 +1,29 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(plugin-backend-deviced-battery C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+if (${PLUGIN_DEVICED_ENABLE_DLOG})
+       SET(PKG_MODULES
+               libsyscommon
+               libsyscommon-plugin-api-deviced)
+       ADD_DEFINITIONS("-DENABLE_DLOG")
+       ADD_DEFINITIONS("-DLOG_TAG=\"SYSTEM_PLUGIN_DEVICED_BATTERY\"")
+else()
+       SET(PKG_MODULES
+               libsyscommon
+               libsyscommon-plugin-api-deviced)
+endif()
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(PKGS REQUIRED ${PKG_MODULES})
+FOREACH(flag ${PKGS_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED battery.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${PLUGIN_LIB_DIR} COMPONENT RuntimeLibraries)
\ No newline at end of file
index 33b7da03731e08e3c9973a8cf0f35dd19a9cdd08..76f3566057f8513ab0dc93b709eef9e2d55f7b60 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <stdlib.h>
+#include <errno.h>
+
+#include <system/syscommon-plugin-common-interface.h>
+#include <system/syscommon-plugin-deviced-battery.h>
+#include <system/syscommon-plugin-deviced-battery-interface.h>
+
+#define EXPORT __attribute__ ((visibility("default")))
+
+static bool is_possible_to_notify_battery_full(void)
+{
+       return true;
+}
+
+static int deviced_plugin_battery_init(void **data)
+{
+       syscommon_plugin_backend_deviced_battery_funcs *funcs = NULL;
+
+       funcs = calloc(1, sizeof(*funcs));
+       if (!funcs)
+               return -ENOMEM;
+
+       funcs->is_possible_to_notify_battery_full = is_possible_to_notify_battery_full;
+
+       *data = (void *)funcs;
+
+       return 0;
+}
+
+static int deviced_plugin_battery_exit(void *data)
+{
+       free(data);
+       return 0;
+}
+
+syscommon_plugin_backend EXPORT system_plugin_backend_deviced_battery = {
+       .name = "deviced-battery",
+       .vendor = "Samsung",
+       .abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
+       .init = deviced_plugin_battery_init,
+       .exit = deviced_plugin_battery_exit,
+};
\ No newline at end of file