To support unified system service, here is the changes.
deviced-unified-system-plugin rpm is newly added to install
libunified-system-service-deviced.so.
Service execution will be replaced as a library init/exit() way.
With this, unified-system-service can run system services as a thread simultaneously.
To avoid dbus rule conflict, a part of dbus conf rule is removed as
different config file 'org.tizen.system.deviced-unified-system-service.conf'.
This file will replace org.tizen.system.deviced.conf by the postscript
of plugin rpm when it is installed.
Change-Id: Ifda03117729dedaf818a0710b21460ca572e8bb9
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
########################################################
SET(CMAKE_VERBOSE_MAKEFILE OFF)
+SET(LIBRARY_NAME "unified-system-service-deviced")
IF("${ARCH}" STREQUAL "arm")
OPTION(USE_ARM "Use Arm" ON)
INSTALL(DIRECTORY DESTINATION ${MAKE_INSTALL_PREFIX}${DD_PLUGIN_PATH})
+ADD_LIBRARY(${LIBRARY_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${REQUIRED_PKGS_LDFLAGS} "-lrt -ldl -lm" deviced-common-private)
+INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
IF(POWER_MODULE STREQUAL on)
ADD_EXECUTABLE(deviced-shutdown src/power-shutdown/shutdown.c src/shared/common.c)
SET(deviced-shutdown_LDFLAGS ${REQUIRED_PKGS_LDFLAGS})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/conf/org.tizen.system.deviced.conf DESTINATION /etc/dbus-1/system.d)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/conf/org.tizen.system.deviced-unified-system-service.conf DESTINATION /etc/dbus-1/system.d)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/org.tizen.system.deviced.service DESTINATION /usr/share/dbus-1/system-services)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/deviced.service DESTINATION /usr/lib/systemd/system)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/usb-host-ffs-test-daemon.service DESTINATION /usr/lib/systemd/system)
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="org.tizen.system.deviced"/>
+ <allow send_destination="org.tizen.system.deviced"/>
+ <allow send_type="signal" send_path="/Org/Tizen/System/DeviceD/Display" send_interface="org.tizen.system.deviced.display"/>
+ <allow send_type="signal" send_path="/Org/Tizen/System/DeviceD/Time" send_interface="org.tizen.system.deviced.Time"/>
+ <allow send_type="signal" send_path="/Org/Tizen/System/DeviceD/Battery" send_interface="org.tizen.system.deviced.Battery"/>
+ </policy>
+
+ <policy user="service_fw">
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.BatteryMonitor" send_member="GetBMData"/>
+ </policy>
+
+ <policy user="system_fw">
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Battery" send_member="power_supply"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.ExtCon"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.display" send_member="AutoBrightnessChanged"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="udev"/>
+ </policy>
+
+ <policy user="security_fw">
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="getcontrol"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="control"/>
+ </policy>
+
+ <policy user="app_fw">
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Tzip"/>
+ </policy>
+
+ <policy group="users">
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Tzip"/>
+ </policy>
+
+ <policy context="default">
+ <deny own="org.tizen.system.deviced"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.freedesktop.DBus.Properties" send_member="GetAll"/>
+
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.display"
+ privilege="http://tizen.org/privilege/display"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Power"
+ privilege="http://tizen.org/privilege/power"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.PowerOff"
+ privilege="http://tizen.org/privilege/reboot"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Led"
+ privilege="http://tizen.org/privilege/led"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.ir"
+ privilege="http://tizen.org/privilege/use_ir"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Usbhost"
+ privilege="http://tizen.org/privilege/usb.host"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.touch"
+ privilege="http://tizen.org/privilege/internal/default/platform"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Csa"
+ privilege="http://tizen.org/privilege/internal/default/platform"/>
+
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.input"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Battery"/>
+ <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Battery" send_member="power_supply"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Battery" send_member="SetLowbatLevel"
+ privilege="http://tizen.org/privilege/systemsettings.admin"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Core"/>
+ <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.ExtCon"/>
+
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti"/>
+ <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="getcontrol"/>
+ <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="control"/>
+ <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="udev"/>
+
+ <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Tzip"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Usb"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.UsbHostTest"/>
+ <check send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.PmQos"
+ privilege="http://tizen.org/privilege/internal/default/platform"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.temperature"/>
+ <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Board"/>
+
+ <deny send_type="signal"
+ send_path="/Org/Tizen/System/DeviceD/Display"
+ send_interface="org.tizen.system.deviced.display"/>
+ <deny send_type="signal"
+ send_path="/Org/Tizen/System/DeviceD/Time"
+ send_interface="org.tizen.system.deviced.Time"/>
+ <deny send_type="signal"
+ send_path="/Org/Tizen/System/DeviceD/Battery"
+ send_interface="org.tizen.system.deviced.Battery"/>
+ </policy>
+</busconfig>
BuildRequires: pkgconfig(gtest)
BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(security-manager)
+BuildRequires: pkgconfig(hal-api-common)
Requires: %{name}-tools = %{version}-%{release}
%{?systemd_requires}
%description
Deviced
+%package unified-system-plugin
+Summary: unified-system plugin
+Requires: %{name} = %{version}-%{release}
+
+%description unified-system-plugin
+unified-system-service plugin
+
%package -n libdeviced
Summary: Deviced library
Group: Development/Libraries
mkdir -p %{_libdir}/deviced
mv %{_libdir}/tv-display.so %{_libdir}/deviced/display.so
+%post unified-system-plugin
+mv %{_sysconfdir}/dbus-1/system.d/org.tizen.system.deviced-unified-system-service.conf \
+ %{_sysconfdir}/dbus-1/system.d/org.tizen.system.deviced.conf
+
%files
%manifest %{name}.manifest
%license LICENSE.Apache-2.0
%{_prefix}/lib/systemd/deviced-shutdown
%{_sbindir}/deviced-request-shutdown
+%files unified-system-plugin
+%manifest %{name}.manifest
+%license LICENSE.Apache-2.0
+%{_libdir}/libunified-system-service-deviced.so
+%{_libdir}/libdeviced-common-private.so
+%dir %{plugindir}
+%if %{?sdb_prestart} == on
+%{_unitdir}/sdb-prestart.service
+%{_unitdir}/basic.target.wants/sdb-prestart.service
+%endif
+%config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.deviced-unified-system-service.conf
+%config %{_sysconfdir}/deviced/init.conf
+%config %{_sysconfdir}/deviced/display.conf
+%if %{?battery_module} == on
+%config %{_sysconfdir}/deviced/battery.conf
+%endif
+# usbhost_test
+%{_sysconfdir}/deviced/usb-host-test/test_gadget.gs
+%{_bindir}/usb-host-ffs-test-daemon
+%{_unitdir}/usb-host-ffs-test-daemon.service
+%{_unitdir}/usb-host-test.socket
+%{_sysconfdir}/deviced/usb-host-test/descs
+%{_sysconfdir}/deviced/usb-host-test/strs
+# dummy mtp-responder
+%{_sysconfdir}/mtp-responder-dummy/strs
+%{_sysconfdir}/mtp-responder-dummy/descs
+%{_unitdir}/mtp-responder-dummy.socket
+%{_unitdir}/mtp-responder-dummy.service
+
+# Assume power module is on (-DPOWER_MODULE=on)
+%{_unitdir}/deviced-request-shutdown@.service
+%{_unitdir}/systemd-reboot.service.d/deviced-request-shutdown-reboot.conf
+%{_unitdir}/systemd-poweroff.service.d/deviced-request-shutdown-poweroff.conf
+%{_unitdir}/systemd-halt.service.d/deviced-request-shutdown-halt.conf
+%{_unitdir}/systemd-exit.service.d/deviced-request-shutdown-exit.conf
+%{_prefix}/lib/systemd/deviced-shutdown
+%{_sbindir}/deviced-request-shutdown
+
%files -n libdeviced
%manifest deviced.manifest
%license LICENSE.Apache-2.0
#include <device/board-internal.h>
#include <argos.h>
+#include <unified-system-service-common.h>
+
#include "core.h"
#include "log.h"
#include "resource.h"
return G_SOURCE_CONTINUE;
}
-static int deviced_main(int argc, char **argv)
+static int deviced_early_init(void *data)
+{
+ writepid(PIDFILE_PATH);
+ return 0;
+}
+
+static int deviced_init(void *data)
{
int ret;
dbus_handle_h handle = NULL;
int retval;
CRITICAL_LOG("Initializing deviced.");
- mainloop = g_main_loop_new(NULL, FALSE);
ret = poweroff_check_revived();
if (is_poweroff_state(ret)) {
_E("aw_register failed.");
}
- /* g_main_loop */
CRITICAL_LOG("Starting deviced.");
- g_main_loop_run(mainloop);
- g_main_loop_unref(mainloop);
+ return 0;
+}
+
+static int deviced_exit(void *data)
+{
devices_exit(NULL);
resource_exit();
unload_plugins();
+ return 0;
+}
+
+static int deviced_main(int argc, char **argv)
+{
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ deviced_init(NULL);
+
+ g_main_loop_run(mainloop);
+ g_main_loop_unref(mainloop);
+
+ deviced_exit(NULL);
return 0;
}
int main(int argc, char **argv)
{
- writepid(PIDFILE_PATH);
+ deviced_early_init(NULL);
return deviced_main(argc, argv);
}
+
+__attribute__ ((visibility("default")))
+unified_system_service unified_system_service_deviced_data = {
+ .name = "unified-system-service-deviced",
+ .early_init = deviced_early_init,
+ .init = deviced_init,
+ .exit = deviced_exit,
+ .late_exit = NULL,
+};