########################################################
SET(CMAKE_VERBOSE_MAKEFILE OFF)
+SET(LIBRARY_NAME "hal-backend-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}/hal 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})
BuildRequires: pkgconfig(gtest)
BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(security-manager)
+BuildRequires: pkgconfig(hal-api-common)
Requires: %{name}-tools = %{version}-%{release}
%{?systemd_requires}
%{_sysconfdir}/mtp-responder-dummy/descs
%{_unitdir}/mtp-responder-dummy.socket
%{_unitdir}/mtp-responder-dummy.service
+%{_libdir}/hal/libhal-backend-service-deviced.so
# Assume power module is on (-DPOWER_MODULE=on)
%{_unitdir}/deviced-request-shutdown@.service
#include <device/board-internal.h>
#include <argos.h>
+#include <hal/hal-common.h>
+
#include "core.h"
#include "log.h"
#include "resource.h"
writepid(PIDFILE_PATH);
return deviced_main(argc, argv);
}
+
+
+static int deviced_init (void *data)
+{
+ int ret;
+ dbus_handle_h handle = NULL;
+ guint timer;
+ char bootmode[32] = "normal";
+ int retval;
+
+ writepid(PIDFILE_PATH);
+
+ CRITICAL_LOG("Initializing deviced.");
+ //mainloop = g_main_loop_new(NULL, FALSE);
+
+ ret = poweroff_check_revived();
+ if (is_poweroff_state(ret)) {
+ /* Restarted: deviced was terminated
+ * in middle of reboot/poweroff - resume procedure
+ */
+ poweroff_request_shutdown(ret);
+ return 0;
+ }
+
+ handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
+ if (!handle)
+ _E("Failed to get dbus connection.");
+
+ load_plugins();
+
+ retval = device_board_get_boot_mode(bootmode, sizeof(bootmode));
+ if (retval < 0)
+ _W("Cannot get boot mode, ret(%d)", retval);
+
+ if (retval == 0) {
+ ret = power_boot_load_silent_boot();
+ if (ret < 0)
+ _W("Cannot set silent_boot, ret(%d)", ret);
+ }
+
+ CRITICAL_LOG("bootmode=%s", bootmode);
+
+ resource_init();
+ devices_init(NULL);
+
+ ret = gdbus_request_name(handle, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL);
+ if (ret <= 0) {
+ _E("Failed to request bus name.");
+ gdbus_check_name_owner(NULL, DEVICED_BUS_NAME);
+ }
+
+ g_unix_signal_add(SIGTERM, handle_sigterm, (gpointer) SIGTERM);
+ g_unix_signal_add(SIGUSR1, handle_sigusr1, (gpointer) SIGUSR1);
+
+ timer = g_timeout_add_seconds_full(G_PRIORITY_HIGH, WATCHDOG_REFRESH_TIME, watchdog_cb, NULL, NULL);
+ if (timer) {
+ ret = aw_register(WATCHDOG_TIMEOUT);
+ if (ret < 0)
+ _E("aw_register failed.");
+ }
+
+ /* g_main_loop */
+ CRITICAL_LOG("Starting deviced.");
+ //g_main_loop_run(mainloop);
+ //g_main_loop_unref(mainloop);
+
+ devices_exit(NULL);
+ resource_exit();
+
+ unload_plugins();
+
+ return 0;
+}
+
+static int deviced_exit(void *data)
+{
+ return 0;
+}
+
+hal_backend_service hal_backend_service_deviced_data = {
+ .module = HAL_MODULE_DEVICED,
+ .name = "hal-backend-service-deviced",
+ .early_init = NULL,
+ .init = deviced_init,
+ .exit = deviced_exit,
+ .late_exit = NULL,
+};
[Unit]
Description=System device daemon
+Requires=local-fs.target tizen-system-env.service systemd-tmpfiles-setup.service wait-mount@opt-usr.service dbus.socket
+After=wait-mount@opt-usr.service dbus.service local-fs.target tizen-system-env.service systemd-tmpfiles-setup.service
# Caution: never uncomment belwo "Wants=" and "After=" entries.
# Just information, deviced internally wait for /run/.wm_ready
Type=notify
SmackProcessLabel=System::Privileged
Environment=XDG_RUNTIME_DIR=/run
-ExecStart=/usr/bin/deviced
-Restart=on-failure
+EnvironmentFile=/run/xdg-root-env
+ExecStart=/usr/bin/hal/hal-backend-service storaged deviced
+Restart=always
RestartSec=0
KillSignal=SIGUSR1
+MemoryMax=20M
[Install]
WantedBy=multi-user.target