standard: fix infinite vibration 65/222865/1 tizen_5.5_tv accepted/tizen/5.5/unified/20200121.165903 submit/tizen_5.5/20200121.093910
authorYunmi Ha <yunmi.ha@samsung.com>
Mon, 20 Jan 2020 10:07:33 +0000 (19:07 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 21 Jan 2020 03:00:08 +0000 (03:00 +0000)
- If feedbackd receives another vibration request
without stopping the previous vibration,
there's not way to stop the previous one, probably causing infinite vibration.

- So, feedbackd should override the previous effect id on a new request
to keep a single effect id.

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

src/haptic/standard.c

index af43425..d27139a 100644 (file)
@@ -73,6 +73,7 @@ static dd_list *ff_list;
 static dd_list *handle_list;
 static char ff_path[PATH_MAX];
 static int unique_number;
+static int current_effect_id = -1;
 
 static int stop_device(int device_handle);
 
@@ -253,10 +254,14 @@ static int ff_play(int fd, struct ff_effect *effect)
        }
 
        /* upload an effect */
-       if (ioctl(fd, EVIOCSFF, effect) == -1) {
-               _E("Failed to ioctl");
-               return -errno;
-       }
+       if (current_effect_id == -1) {
+               if (ioctl(fd, EVIOCSFF, effect) == -1) {
+                       _E("Failed to ioctl");
+                       return -errno;
+               }
+               current_effect_id = effect->id;
+       } else
+               effect->id = current_effect_id;
 
        /* play vibration*/
        play.type = EV_FF;
@@ -280,6 +285,12 @@ static int ff_stop(int fd, struct ff_effect *effect)
        if (fd < 0 || !effect)
                return -EINVAL;
 
+       if (effect->id == -1) {
+               if (current_effect_id == -1)
+                       return 0;
+               effect->id = current_effect_id;
+       }
+
        /* Stop vibration */
        stop.type = EV_FF;
        stop.code = effect->id;
@@ -294,6 +305,7 @@ static int ff_stop(int fd, struct ff_effect *effect)
 
        /* reset effect id */
        effect->id = -1;
+       current_effect_id = -1;
 
        return 0;
 }