DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor
FILES_MATCHING PATTERN "*.h"
)
+
+IF(${ENABLE_SYSTEM_SERVER})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/system-server-sensord.service
+ DESTINATION ${SYSTEM_SERVER_DIR}/conf)
+ENDIF()
+%define enable_system_server 0
+%define _system_server_dir %{_datadir}/united-service/system-server
+
Name: sensord
Summary: Sensor daemon
Version: 4.0.54
BuildRequires: pkgconfig(cynara-session)
BuildRequires: pkgconfig(hal-api-sensor)
BuildRequires: pkgconfig(hal-api-common)
+%if %{enable_system_server}
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(tizen-core)
+BuildRequires: pkgconfig(united-service)
+%endif
Provides: %{name}-profile_mobile = %{version}-%{release}
Provides: %{name}-profile_wearable = %{version}-%{release}
%build
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DCMAKE_HAL_LIBDIR_PREFIX=%{_hal_libdir}
+%cmake . \
+ -DMAJORVER=${MAJORVER} \
+ -DFULLVER=%{version} \
+ -DCMAKE_HAL_LIBDIR_PREFIX=%{_hal_libdir} \
+%if %{enable_system_server}
+ -DSYSTEM_SERVER_DIR=%{_system_server_dir} \
+%endif
+ -DENABLE_SYSTEM_SERVER=%{enable_system_server}
make %{?_smp_mflags}
%install
mkdir -p %{buildroot}%{_unitdir}
+%if "%{enable_system_server}" != "1"
install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}
install -m 0644 %SOURCE2 %{buildroot}%{_unitdir}
+%install_service multi-user.target.wants sensord.service
+%install_service sockets.target.wants sensord.socket
+%endif
mkdir -p %{buildroot}%{_sysconfdir}/sensord
install -m 644 conf/auto_rotation.conf %{buildroot}/etc/sensord/auto_rotation.conf
-%install_service multi-user.target.wants sensord.service
-%install_service sockets.target.wants sensord.socket
-
ln -s libsensor.so.%{version} %{buildroot}/%{_libdir}/libsensor.so.2
ln -s libsensor.so.%{version} %{buildroot}/%{_libdir}/libsensor.so.1
%{_libdir}/libsensord-shared.so
%{_libdir}/sensor/fusion/libsensor-fusion.so
%{_libdir}/sensor/physical/libsensor-physical.so
+%if %{enable_system_server}
+%{_system_server_dir}/mod/libsystem-server-sensord.so
+%{_system_server_dir}/conf/system-server-sensord.service
+%else
%{_bindir}/sensord
%{_unitdir}/sensord.service
%{_unitdir}/sensord.socket
%{_unitdir}/multi-user.target.wants/sensord.service
%{_unitdir}/sockets.target.wants/sensord.socket
+%endif
%config %{_sysconfdir}/sensord/auto_rotation.conf
%license LICENSE.APLv2
--- /dev/null
+[United-Service]
+Description=sensord plugin for system-server
+Name=system-server-sensord
+Type=notify
+Mode=normal
+Path=/usr/share/united-service/system-server/mod/libsystem-server-sensord.so
+Priority=1
SET(DEPENDENTS "glib-2.0 gio-2.0 dlog libsystemd cynara-client cynara-creds-socket cynara-session vconf hal-api-sensor hal-api-common")
+IF(${ENABLE_SYSTEM_SERVER})
+SET(DEPENDENTS "${DEPENDENTS} bundle tizen-core united-service")
+ENDIF()
+
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(SERVER_PKGS REQUIRED ${DEPENDENTS})
)
FILE(GLOB SERVER_SRCS *.cpp)
+
+IF(${ENABLE_SYSTEM_SERVER})
+ADD_LIBRARY("system-server-sensord" SHARED ${SENSOR_SRCS} ${SERVER_SRCS})
+TARGET_LINK_LIBRARIES("system-server-sensord" ${SERVER_PKGS_LDFLAGS} ${CMAKE_DL_LIBS} "sensord-shared")
+TARGET_LINK_LIBRARIES("system-server-sensord" PUBLIC "-lpthread -ldl")
+INSTALL(TARGETS "system-server-sensord" DESTINATION ${SYSTEM_SERVER_DIR}/mod COMPONENT RuntimeLibraries)
+ELSE()
+LIST(REMOVE_ITEM SERVER_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/system_server_sensord.cpp")
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})
+ENDIF()
--- /dev/null
+/*
+ * sensord
+ *
+ * Copyright (c) 2025 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 <service.h>
+#include <sensor_log.h>
+
+#include "sensord.h"
+
+static void system_server_create_callback(service_h service, void *user_data)
+{
+ _I("Create sensord for system-server");
+ sensord_init();
+}
+
+static void system_server_destroy_callback(service_h service, void *user_data)
+{
+ _I("Destroy sensord for system-server");
+ sensord_exit();
+}
+
+static void system_server_message_callback(service_h service,
+ const char *sender, bundle *envelope, void *user_data)
+{
+ _I("Message from sender(%s)", sender);
+}
+
+extern "C"
+int USD_MOD_INIT(const char *name)
+{
+ int ret = 0;
+ service_lifecycle_callback_s system_server_callback = {
+ .create = system_server_create_callback,
+ .destroy = system_server_destroy_callback,
+ .message = system_server_message_callback,
+ };
+
+ _I("Start sensord");
+
+ ret = service_register(name, &system_server_callback, NULL);
+ if (ret != SERVICE_ERROR_NONE) {
+ _E("Failed to create service: name(%s), ret(%d)", name, ret);
+ return ret;
+ }
+
+ return SERVICE_ERROR_NONE;
+}
+
+extern "C"
+void USD_MOD_SHUTDOWN(const char *name)
+{
+ _I("Shutdown sensord");
+
+ service_unregister(name);
+}