Vibrate when poweroff_type is POWER_OFF_DIRECT or POWER_OFF_RESTART 82/197582/8
authorpr.jung <pr.jung@samsung.com>
Mon, 14 Jan 2019 08:37:24 +0000 (17:37 +0900)
committerpr.jung <pr.jung@samsung.com>
Mon, 28 Jan 2019 06:52:30 +0000 (15:52 +0900)
Change-Id: Ia7f222768ffc6c3413a00f90e4d40e3302802450
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/haptic/haptic.c

index 148d63f..4a60b85 100644 (file)
@@ -41,7 +41,6 @@
 /* hardkey vibration variable */
 #define HARDKEY_VIB_ITERATION          1
 #define HARDKEY_VIB_FEEDBACK           3
-#define HARDKEY_VIB_PRIORITY           2
 #define HARDKEY_VIB_DURATION           30
 #define HAPTIC_FEEDBACK_STEP           20
 #define DEFAULT_FEEDBACK_LEVEL         3
 #define CHECK_VALID_OPS(ops, r)                ((ops) ? true : !(r = -ENODEV))
 #define RETRY_CNT      3
 
+enum poweroff_type {
+       POWER_OFF_NONE = 0,
+       POWER_OFF_POPUP,
+       POWER_OFF_DIRECT,
+       POWER_OFF_RESTART,
+};
+
 struct haptic_info {
        char *sender;
        dd_list *handle_list;
@@ -573,7 +579,7 @@ static void haptic_hardkey_changed_cb(GDBusConnection  *conn,
        }
 
        ret = h_ops->vibrate_monotone(g_handle, HARDKEY_VIB_DURATION,
-                       level*HAPTIC_FEEDBACK_STEP, HARDKEY_VIB_PRIORITY, &e_handle);
+                       level*HAPTIC_FEEDBACK_STEP, PRIORITY_HIGH, &e_handle);
        if (ret < 0)
                _E("fail to vibrate buffer : %d", ret);
 
@@ -588,9 +594,17 @@ static void haptic_poweroff_cb(GDBusConnection  *conn,
        GVariant         *param,
        gpointer          data)
 {
+       int type = POWER_OFF_NONE;
        int e_handle, ret;
        struct timespec time = {0,};
 
+       g_variant_get(param, "(i)", &type);
+
+       if (type != POWER_OFF_DIRECT && type != POWER_OFF_RESTART)
+               return;
+
+       _D("Poweroff: %d", type);
+
        if (!CHECK_VALID_OPS(h_ops, ret)) {
                ret = haptic_module_load();
                if (ret < 0)
@@ -601,8 +615,10 @@ static void haptic_poweroff_cb(GDBusConnection  *conn,
                haptic_internal_init();
 
        /* power off vibration */
+       _I("Handle %d dur %dms pri %d level %d",
+               g_handle, POWER_OFF_VIB_DURATION, PRIORITY_HIGH, POWER_VIB_FEEDBACK);
        ret = h_ops->vibrate_monotone(g_handle, POWER_OFF_VIB_DURATION,
-                       POWER_VIB_FEEDBACK, HARDKEY_VIB_PRIORITY, &e_handle);
+                       POWER_VIB_FEEDBACK, PRIORITY_HIGH, &e_handle);
        if (ret < 0) {
                _E("fail to vibrate_monotone : %d", ret);
                return;