Add unified-system-plugin package to support unified system service 87/323987/2
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 14 Apr 2025 10:10:07 +0000 (19:10 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Mon, 12 May 2025 05:33:59 +0000 (14:33 +0900)
To support the unified-system-service, a plugin is added:
    libunified-system-service-sensord.so
For this plugin, a new plugin sensor-unified-system-plugin is added.

Change-Id: Ife8f8fea4ebe94805f8d91894b2fc3aa9ef55f49
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
packaging/sensord.spec
src/server/CMakeLists.txt
src/server/main.cpp

index 87c5c3c8a781067b80b36e827e1b943d7f4413f4..f95f13d573c77fe9ac530be781fe3dc4772e7ec4 100644 (file)
@@ -63,6 +63,12 @@ Group:      System/Testing
 %description -n sensor-test
 Sensor functional testing
 
+%package -n sensor-unified-system-plugin
+Summary:    Package for unified-system-plugin plugin
+
+%description -n sensor-unified-system-plugin
+Package for unified-system-service plugin
+
 %isu_package
 
 %prep
@@ -149,6 +155,11 @@ rm -f %{_unitdir}/sockets.target.wants/sensord.socket
 %files -n sensor-test
 %{_bindir}/sensorctl
 
+%files -n sensor-unified-system-plugin
+%manifest packaging/sensord.manifest
+%{_libdir}/libunified-system-service-sensord.so
+%license LICENSE.APLv2
+
 
 # Dummy packages for Tizen 3.0.
 # When building other packages on Tizen 3.0, after building sensord first,
index 4b38e0598167177df840690d0229a09ac7d7688d..896d75c5035ccec41adc0e46b500bc306cec5ca0 100644 (file)
@@ -1,7 +1,18 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(sensord CXX)
 
-SET(DEPENDENTS "glib-2.0 gio-2.0 dlog libsystemd cynara-client cynara-creds-socket cynara-session vconf hal-api-sensor hal-api-common")
+SET(DEPENDENTS
+       glib-2.0
+       gio-2.0
+       dlog
+       libsystemd
+       cynara-client
+       cynara-creds-socket
+       cynara-session
+       vconf
+       hal-api-sensor
+       hal-api-common
+)
 
 INCLUDE(FindPkgConfig)
 PKG_CHECK_MODULES(SERVER_PKGS REQUIRED ${DEPENDENTS})
@@ -29,3 +40,8 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SENSOR_SRCS} ${SERVER_SRCS})
 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SERVER_PKGS_LDFLAGS} ${CMAKE_DL_LIBS} "sensord-shared")
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+SET(LIBRARY_NAME "unified-system-service-sensord")
+ADD_LIBRARY(${LIBRARY_NAME} SHARED ${SERVER_SRCS})
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${SERVER_PKGS_LDFLAGS} ${CMAKE_DL_LIBS} "sensord-shared")
+INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
index c4ec0488a0fad5fea0e60eef4e0b1bfc04dcc4e8..d69b184acea308ae9984abc9083782d9b5085c92 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <glib-unix.h>
 
+#include <unified-system-service-common.h>
 #include <sensor_log.h>
 #include "server.h"
 
@@ -37,16 +38,6 @@ static void handle_signal_std(int signum)
        raise(SIGTERM);
 }
 
-static gboolean handle_signal(gpointer data)
-{
-       long signum = (long) data;
-       _W("Received SIGNAL(%ld : %s)", signum, strsignal(signum));
-
-       server::stop();
-
-       return G_SOURCE_REMOVE;
-}
-
 static void on_new_failed(void)
 {
        static unsigned fail_count = 0;
@@ -59,6 +50,36 @@ static void on_new_failed(void)
        }
 }
 
+static int sensord_init(void *data)
+{
+       _I("start sensord");
+
+       std::set_new_handler(on_new_failed);
+
+       server::run();
+
+       return 0;
+}
+
+static int sensord_exit(void *data)
+{
+       server::stop();
+
+       _I("sensord stopped");
+
+       return 0;
+}
+
+static gboolean handle_signal(gpointer data)
+{
+       long signum = (long) data;
+       _W("Received SIGNAL(%ld : %s)", signum, strsignal(signum));
+
+       sensord_exit(NULL);
+
+       return G_SOURCE_REMOVE;
+}
+
 int main(int argc, char *argv[])
 {
        _I("Started");
@@ -74,11 +95,18 @@ int main(int argc, char *argv[])
        std::signal(SIGCHLD, SIG_IGN);
        std::signal(SIGPIPE, SIG_IGN);
 
-       std::set_new_handler(on_new_failed);
-
-       server::run();
+       sensord_init(NULL);
 
        _I("Stopped");
 
        return 0;
 }
+
+__attribute__((visibility("default")))
+unified_system_service unified_system_service_sensord_data = {
+       .name           = "unified-system-service-sensord-data",
+       .early_init     = NULL,
+       .init           = sensord_init,
+       .exit           = sensord_exit,
+       .late_exit      = NULL,
+};