Commit 64e71c69 authored by spiiroin's avatar spiiroin

[fingerprint] Use gesture actions for fingerprint wake up. Fixes JB#47437

Originally fingerprint wake up was modeled to:
- wake up display like double tap does
- exit from lockscreen when device is not locked, or
- indicate need to unlock when device is locked
i.e. behave as if double power key press were made.

This however means that fingerprint wake up never ends up showing
lockscreen where things like date and time would be visible.

Switch from handling fingerprint wake up as something explicit into
treating it as just another gesture with configurable actions.

Add "tkunlock2" gesture action, which behaves like "tkunlock" when
device is unlocked and does nothing when device is locked.

After which users can tweak fingerprint behavior with mcetool.

mcetool --set-touchscreen-gesture-actions=fpwakeup,unblank,tkunlock

  The default behavior.

mcetool --set-touchscreen-gesture-actions=fpwakeup,unblank,tkunlock2

  Exits from lockscreen only if device is not locked.

mcetool --set-touchscreen-gesture-actions=fpwakeup,unblank

  Just wakes up display, leaving lockscreen status as it is.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 2b5a8281
......@@ -1380,6 +1380,7 @@ tools/mcetool.o:\
tools/mcetool.c\
builtin-gconf.h\
datapipe.h\
evdev.h\
event-input.h\
mce-command-line.h\
mce-dbus.h\
......@@ -1401,6 +1402,7 @@ tools/mcetool.pic.o:\
tools/mcetool.c\
builtin-gconf.h\
datapipe.h\
evdev.h\
event-input.h\
mce-command-line.h\
mce-dbus.h\
......
......@@ -1757,6 +1757,51 @@ static const setting_t gconf_defaults[] =
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE10,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE11,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE11,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE12,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE12,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE13,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE13,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE14,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE14,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE15,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE15,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE16,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE16,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE17,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE17,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE18,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE18,
},
{
.key = MCE_SETTING_POWERKEY_ACTIONS_GESTURE19,
.type = "s",
.def = MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE19,
},
{
.key = MCE_SETTING_POWERKEY_DBUS_ACTION1,
.type = "s",
......
......@@ -37,13 +37,15 @@ extern "C" {
* mce to always mean doubletap.
*/
typedef enum {
/* Values */
/* Values 0-15 reserved for touchscreen gestures */
GESTURE_SWIPE_FROM_LEFT = 0,
GESTURE_SWIPE_FROM_RIGHT = 1,
GESTURE_SWIPE_FROM_TOP = 2,
GESTURE_SWIPE_FROM_BOTTOM = 3,
GESTURE_DOUBLETAP = 4, /* To conform with value used in
* Nokia N9 kernel driver */
GESTURE_FPWAKEUP = 16,
/* Modifiers */
GESTURE_SYNTHESIZED = (1<<8),
} gesture_t;
......
......@@ -2647,12 +2647,6 @@ fpwakeup_trigger(void)
datapipe_exec_full(&ngfd_event_request_pipe,
"unlock_device");
/* Make sure we unblank / exit from lpm */
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
/* Exit from lockscreen */
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF);
/* Deactivate type=6 led patterns (e.g. sms/email notifications)
* by signaling "true user activity" via synthetized gesture
* input event. (The event type ought not matter, but using
......@@ -2663,9 +2657,13 @@ fpwakeup_trigger(void)
const struct input_event ev = {
.type = EV_MSC,
.code = MSC_GESTURE,
.value = GESTURE_DOUBLETAP | GESTURE_SYNTHESIZED,
.value = GESTURE_FPWAKEUP | GESTURE_SYNTHESIZED,
};
datapipe_exec_full(&user_activity_event_pipe, &ev);
/* Forward to powerkey.c for configurable action handling */
const struct input_event *evp = &ev;
datapipe_exec_full(&keypress_event_pipe, &evp);
}
}
......
......@@ -162,6 +162,7 @@ static void pwrkey_action_tklock (void);
static void pwrkey_action_blank (void);
static void pwrkey_action_unblank (void);
static void pwrkey_action_tkunlock (void);
static void pwrkey_action_tkunlock2(void);
static void pwrkey_action_devlock (void);
static void pwrkey_action_dbus1 (void);
static void pwrkey_action_dbus2 (void);
......@@ -300,6 +301,15 @@ static const char * const pwrkey_actions_gesture_key[POWERKEY_ACTIONS_GESTURE_CO
MCE_SETTING_POWERKEY_ACTIONS_GESTURE8,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE9,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE10,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE11,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE12,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE13,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE14,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE15,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE16,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE17,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE18,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE19,
};
/** Array of default values for configurable touchscreen gestures */
......@@ -316,6 +326,15 @@ static const char * const pwrkey_actions_gesture_val[POWERKEY_ACTIONS_GESTURE_CO
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE8,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE9,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE10,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE11,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE12,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE13,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE14,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE15,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE16,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE17,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE18,
MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE19,
};
/** Array of current values for configurable touchscreen gestures */
......@@ -574,6 +593,7 @@ static void pwrkey_setting_quit (void);
static void pwrkey_datapipe_keypress_event_cb(gconstpointer const data);
static void pwrkey_datapipe_ngfd_service_state_cb(gconstpointer data);
static void pwrkey_datapipe_system_state_cb(gconstpointer data);
static void pwrkey_datapipe_devicelock_state_cb(gconstpointer data);
static void pwrkey_datapipe_display_state_curr_cb(gconstpointer data);
static void pwrkey_datapipe_display_state_next_cb(gconstpointer data);
static void pwrkey_datapipe_lid_sensor_filtered_cb(gconstpointer data);
......@@ -664,6 +684,9 @@ static bool pwrkey_delete_flagfile(const char *path)
/** System state; is undefined at bootup, can't assume anything */
static system_state_t system_state = MCE_SYSTEM_STATE_UNDEF;
/** Cached devicelock_state ; assume unknown */
static devicelock_state_t devicelock_state = DEVICELOCK_STATE_UNDEFINED;
/** Current display state; undefined initially, can't assume anything */
static display_state_t display_state_curr = MCE_DISPLAY_UNDEF;
......@@ -844,6 +867,18 @@ EXIT:
return;
}
static void
pwrkey_action_tkunlock2(void)
{
if( devicelock_state != DEVICELOCK_STATE_UNLOCKED ) {
mce_log(LL_DEBUG, "devicelock_state=%s; rejecting 'tkunlock2' action",
devicelock_state_repr(devicelock_state));
}
else {
pwrkey_action_tkunlock();
}
}
static void
pwrkey_action_blank(void)
{
......@@ -1033,6 +1068,10 @@ static const pwrkey_bitconf_t pwrkey_action_lut[] =
.name = "unblank",
.func = pwrkey_action_unblank,
},
{
.name = "tkunlock2",
.func = pwrkey_action_tkunlock2,
},
{
.name = "tkunlock",
.func = pwrkey_action_tkunlock,
......@@ -2918,6 +2957,27 @@ EXIT:
return;
}
/** Notification callback for devicelock_state_pipe
*
* @param data devicelock_state_t value as void pointer
*/
static void
pwrkey_datapipe_devicelock_state_cb(gconstpointer data)
{
devicelock_state_t prev = devicelock_state;
devicelock_state = GPOINTER_TO_INT(data);
if( devicelock_state == prev )
goto EXIT;
mce_log(LL_DEBUG, "devicelock_state = %s -> %s",
devicelock_state_repr(prev),
devicelock_state_repr(devicelock_state));
EXIT:
return;
}
/** Handle display state change notifications
*
* @param data display state (as void pointer)
......@@ -3257,6 +3317,10 @@ static datapipe_handler_t pwrkey_datapipe_handlers[] =
.datapipe = &system_state_pipe,
.output_cb = pwrkey_datapipe_system_state_cb,
},
{
.datapipe = &devicelock_state_pipe,
.output_cb = pwrkey_datapipe_devicelock_state_cb,
},
{
.datapipe = &display_state_curr_pipe,
.output_cb = pwrkey_datapipe_display_state_curr_cb,
......
......@@ -129,7 +129,7 @@ typedef enum
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE3 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE4 MCE_SETTING_POWERKEY_PATH "/actions_gesture4"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE4 "unblank"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE4 "unblank" // GESTURE_DOUBLETAP
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE5 MCE_SETTING_POWERKEY_PATH "/actions_gesture5"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE5 "unblank"
......@@ -149,8 +149,35 @@ typedef enum
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE10 MCE_SETTING_POWERKEY_PATH "/actions_gesture10"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE10 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE11 MCE_SETTING_POWERKEY_PATH "/actions_gesture11"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE11 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE12 MCE_SETTING_POWERKEY_PATH "/actions_gesture12"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE12 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE13 MCE_SETTING_POWERKEY_PATH "/actions_gesture13"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE13 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE14 MCE_SETTING_POWERKEY_PATH "/actions_gesture14"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE14 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE15 MCE_SETTING_POWERKEY_PATH "/actions_gesture15"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE15 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE16 MCE_SETTING_POWERKEY_PATH "/actions_gesture16"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE16 "unblank,tkunlock" // GESTURE_FPWAKEUP
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE17 MCE_SETTING_POWERKEY_PATH "/actions_gesture17"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE17 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE18 MCE_SETTING_POWERKEY_PATH "/actions_gesture18"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE18 "unblank"
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE19 MCE_SETTING_POWERKEY_PATH "/actions_gesture19"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE19 "unblank"
/** Number of configurable touchscreen gestures */
# define POWERKEY_ACTIONS_GESTURE_COUNT 11
# define POWERKEY_ACTIONS_GESTURE_COUNT 20
/** What to send when dbus action N is taken*/
# define MCE_SETTING_POWERKEY_DBUS_ACTION1 MCE_SETTING_POWERKEY_PATH "/dbus_action1"
......
......@@ -32,6 +32,7 @@
#include "../tklock.h"
#include "../powerkey.h"
#include "../event-input.h"
#include "../evdev.h"
#include "../modules/display.h"
#include "../modules/doubletap.h"
#include "../modules/inactivity.h"
......@@ -1846,6 +1847,14 @@ static const char *rlookup(const symbol_t *stab, int val)
}
}
/** Lookup table for gesture events
*/
static const symbol_t gesture_values[] = {
{ "doubletap", GESTURE_DOUBLETAP },
{ "fpwakeup", GESTURE_FPWAKEUP },
{ NULL, -1 }
};
/** Lookup table for autosuspend policies
*
* @note These must match the hardcoded values in mce itself.
......@@ -4838,6 +4847,7 @@ static bool xmce_is_powerkey_action(const char *name)
"vibrate",
"unblank",
"tkunlock",
"tkunlock2",
"dbus1",
"dbus2",
"dbus3",
......@@ -4946,7 +4956,7 @@ static bool xmce_set_powerkey_actions_while_display_on_long(const char *args)
return true;
}
static const char * const gesture_actions_key[] =
static const char * const gesture_actions_key[POWERKEY_ACTIONS_GESTURE_COUNT] =
{
MCE_SETTING_POWERKEY_ACTIONS_GESTURE0,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE1,
......@@ -4959,6 +4969,15 @@ static const char * const gesture_actions_key[] =
MCE_SETTING_POWERKEY_ACTIONS_GESTURE8,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE9,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE10,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE11,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE12,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE13,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE14,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE15,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE16,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE17,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE18,
MCE_SETTING_POWERKEY_ACTIONS_GESTURE19,
};
/** Set actions to perform on touchscreen gestures
......@@ -4967,10 +4986,13 @@ static bool xmce_set_touchscreen_gesture_action(const char *args)
{
char *work = strdup(args);
char *conf = work;
char *gesture = mcetool_parse_token(&conf);
size_t id = xmce_parse_integer(mcetool_parse_token(&conf));
int id = lookup(gesture_values, gesture);
if( id < 0 )
id = xmce_parse_integer(gesture);
if( id >= G_N_ELEMENTS(gesture_actions_key) ) {
if( id < 0 || id >= (int)G_N_ELEMENTS(gesture_actions_key) ) {
fprintf(stderr, "invalid gesture id: '%s'\n", work);
return false;
}
......@@ -5015,8 +5037,12 @@ static void xmce_get_powerkey_action_masks(void)
printf("Touchscreen gestures:\n");
for( size_t id = 0; id < G_N_ELEMENTS(gesture_actions_key); ++id) {
char temp[32];
snprintf(temp, sizeof temp, "gesture%zu", id);
xmce_get_powerkey_action_mask(gesture_actions_key[id], temp);
const char *gesture = rlookup(gesture_values, (int)id);
if( !gesture ) {
snprintf(temp, sizeof temp, "gesture%zu", id);
gesture = temp;
}
xmce_get_powerkey_action_mask(gesture_actions_key[id], gesture);
}
}
......@@ -6986,22 +7012,23 @@ static const mce_opt_t options[] =
"set actions to execute on single power key press from display on state\n"
"\n"
"Valid actions are:\n"
" blank - turn display off\n"
" tklock - lock ui\n"
" devlock - lock device\n"
" shutdown - power off device\n"
" vibrate - play vibrate event via ngfd\n"
" unblank - turn display on\n"
" tkunlock - unlock ui\n"
" dbus1 - send dbus signal or make method call\n"
" dbus2 - send dbus signal or make method call\n"
" dbus3 - send dbus signal or make method call\n"
" blank - turn display off\n"
" tklock - lock ui\n"
" devlock - lock device\n"
" shutdown - power off device\n"
" vibrate - play vibrate event via ngfd\n"
" unblank - turn display on\n"
" tkunlock - unlock ui / prompt devicelock code\n"
" tkunlock2 - unlock ui if device is not locked\n"
" dbus1 - send dbus signal or make method call\n"
" dbus2 - send dbus signal or make method call\n"
" dbus3 - send dbus signal or make method call\n"
" ...\n"
" dbus10 - send dbus signal or make method call\n"
" nop - dummy operation, for differentiating otherwise\n"
" identical single/double press actions (mce does not\n"
" wait for double presses double press actions are\n"
" the same as for a single press)\n"
" dbus10 - send dbus signal or make method call\n"
" nop - dummy operation, for differentiating otherwise\n"
" identical single/double press actions (mce does not\n"
" wait for double presses double press actions are\n"
" the same as for a single press)\n"
"\n"
"Comma separated list of actions can be used.\n"
},
......@@ -7053,14 +7080,14 @@ static const mce_opt_t options[] =
{
.name = "set-touchscreen-gesture-actions",
.with_arg = xmce_set_touchscreen_gesture_action,
.values = "gesture_id,actions",
.values = "gesture_id|doubletap|fpwakeup,actions",
.usage =
"set actions to execute on touchscreen gestures\n"
"\n"
"Gesture id is a number in 0...10 range. The values are hw specific,\n"
"but 4 can be assumed to mean doubletap.\n"
"Gesture id is a number in 0...19 range. The values are hw specific,\n"
"but 4 can be assumed to mean doubletap and 16 fingerprint wakeup.\n"
"\n"
"Actions are as with --set-display-on-single-powerkey-press-actions\n"
"Actions are as with --set-display-on-single-powerkey-press-actions.\n"
},
{
.name = "set-powerkey-dbus-action",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment