Check vibration feature before the running 48/229348/1 accepted/tizen/5.5/unified/20200331.180320 submit/tizen_5.5/20200331.081954
authorYunmi Ha <yunmi.ha@samsung.com>
Tue, 31 Mar 2020 06:18:57 +0000 (15:18 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 31 Mar 2020 08:18:31 +0000 (08:18 +0000)
- If vibration feature is false, feedbackd will not be run.

Change-Id: I6c8234c5a93bb65167b01a7257d9e16ae0f4ac8c
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
(cherry picked from commit 979938abbaa6fe670fb714f5976dafe972bc545a)

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