From 879053e9b3e1b4b2bf571811fe8deb8ebcb7edf5 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 14 Jan 2019 17:37:24 +0900 Subject: [PATCH] Vibrate when poweroff_type is POWER_OFF_DIRECT or POWER_OFF_RESTART Change-Id: Ia7f222768ffc6c3413a00f90e4d40e3302802450 Signed-off-by: pr.jung --- src/haptic/haptic.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/haptic/haptic.c b/src/haptic/haptic.c index 148d63f..4a60b85 100644 --- a/src/haptic/haptic.c +++ b/src/haptic/haptic.c @@ -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 @@ -63,6 +62,13 @@ #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; -- 2.7.4