Check vibration feature before the running 16/229316/2 accepted/tizen/unified/20200406.133214 submit/tizen/20200402.112144
authorYunmi Ha <yunmi.ha@samsung.com>
Tue, 31 Mar 2020 06:18:57 +0000 (15:18 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Tue, 31 Mar 2020 08:03:34 +0000 (17:03 +0900)
- If vibration feature is false, feedbackd will not be run.

Change-Id: I6c8234c5a93bb65167b01a7257d9e16ae0f4ac8c
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
src/core/main.c
systemd/feedbackd.service

index 03d1169..be0d5db 100644 (file)
 
 #include <stdio.h>
 #include <fcntl.h>
-#include <sys/reboot.h>
 #include <glib.h>
-#include <libsyscommon/dbus-system.h>
+#include <sys/reboot.h>
+
+#include <system_info.h>
 #include <systemd/sd-daemon.h>
+#include <libsyscommon/dbus-system.h>
 
 #include "core/log.h"
 #include "core/common.h"
 #include "haptic/haptic.h"
 
+#define VIBRATION_FEATURE              "http://tizen.org/feature/feedback.vibration"
+
 static GMainLoop *mainloop = NULL;
 
 static void sig_quit(int signo)
@@ -55,6 +59,13 @@ int main(int argc, char **argv)
 {
        int ret;
        dbus_handle_h handle = NULL;
+       bool haptic_avail = false;
+
+       ret = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
+       if ((ret < 0) || !haptic_avail) {
+               _I("Vibration feature is not supported.");
+               return 0;
+       }
 
        mainloop = g_main_loop_new(NULL, FALSE);
 
@@ -65,6 +76,7 @@ int main(int argc, char **argv)
        ret = haptic_probe();
        if (ret != 0) {
                _E("'Haptic' probe fail.");
+               g_main_loop_unref(mainloop);
                return ret;
        }
        haptic_init();
index 50399c5..7b381da 100644 (file)
@@ -5,7 +5,7 @@ Description=System Vibrator Daemon
 Type=notify
 SmackProcessLabel=System
 ExecStart=/usr/bin/feedbackd
-Restart=always
+Restart=on-failure
 RestartSec=0
 KillSignal=SIGUSR1
 CapabilityBoundingSet=~CAP_MAC_ADMIN