Skip to content

Commit

Permalink
[fingerprint] Ignore powerkey during fingerprint enroll. Fixes JB#41217
Browse files Browse the repository at this point in the history
When enrolling fingerprints in devices where powerkey doubles as
fingerprint sensor (e.g. f5121 / Sony Xperia X), it easily happens
that the user presses the button all the way down - screen is blanked,
which then causes cancellation of the enroll operation and the user
must start all over again.

Track fingerprint service availability and state on D-Bus.

Ignore powerkey presses when enroll operation is in progress.

Interpret fingerprint acquisition notifications as user activity
during enroll, identify and verify operations - so that display
blanking timers get reset every time user places finger on the
sensor surface.

The code in fingerprint plugin is derived from usb mode tracking
plugin at modules/usbmode.c.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 1, 2018
1 parent 196c63e commit 2735b29
Show file tree
Hide file tree
Showing 10 changed files with 799 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .depend
Expand Up @@ -724,6 +724,22 @@ modules/filter-brightness-als.pic.o:\
modules/display.h\
modules/filter-brightness-als.h\

modules/fingerprint.o:\
modules/fingerprint.c\
builtin-gconf.h\
datapipe.h\
mce-dbus.h\
mce-log.h\
mce.h\

modules/fingerprint.pic.o:\
modules/fingerprint.c\
builtin-gconf.h\
datapipe.h\
mce-dbus.h\
mce-log.h\
mce.h\

modules/inactivity.o:\
modules/inactivity.c\
builtin-gconf.h\
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Expand Up @@ -150,6 +150,7 @@ TARGETS += mce
# Plugins to build
MODULES += $(MODULE_DIR)/radiostates.so
MODULES += $(MODULE_DIR)/filter-brightness-als.so
MODULES += $(MODULE_DIR)/fingerprint.so
MODULES += $(MODULE_DIR)/proximity.so
MODULES += $(MODULE_DIR)/keypad.so
MODULES += $(MODULE_DIR)/inactivity.so
Expand Down Expand Up @@ -587,6 +588,7 @@ NORMALIZE_USES_SPC =\
modules/doubletap.h\
modules/filter-brightness-als.c\
modules/filter-brightness-als.h\
modules/fingerprint.c\
modules/keypad.h\
modules/inactivity.c\
modules/memnotify.c\
Expand Down Expand Up @@ -666,7 +668,7 @@ endif
.SUFFIXES: .q .p

%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) $(MCE_CFLAGS)
%.p : %.q ; cproto -s < $< | sed -e 's/_Bool/bool/g'
%.p : %.q ; cproto -s < $< | sed -e 's/_Bool/bool/g' | prettyproto.py

clean::
$(RM) -f *.[qp] modules/*.[qp] tools/*.[qp]
Expand Down
50 changes: 50 additions & 0 deletions datapipe.c
Expand Up @@ -238,6 +238,15 @@ datapipe_struct music_playback_ongoing_pipe;
/** proximity blanking; read only */
datapipe_struct proximity_blanked_pipe;

/** fingerprint daemon availability; read only */
datapipe_struct fpd_service_state_pipe;

/** fingerprint daemon state; read only */
datapipe_struct fpstate_pipe;

/** fingerprint is enrolling; read only */
datapipe_struct enroll_in_progress_pipe;

/**
* Execute the input triggers of a datapipe
*
Expand Down Expand Up @@ -865,6 +874,12 @@ void mce_datapipe_init(void)
0, GINT_TO_POINTER(FALSE));
datapipe_init(&proximity_blanked_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(FALSE));
datapipe_init(&fpd_service_state_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(SERVICE_STATE_UNDEF));
datapipe_init(&fpstate_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(FPSTATE_UNSET));
datapipe_init(&enroll_in_progress_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(false));
}

/** Free all datapipes
Expand Down Expand Up @@ -937,6 +952,9 @@ void mce_datapipe_quit(void)
datapipe_free(&keypad_grab_wanted_pipe);
datapipe_free(&music_playback_ongoing_pipe);
datapipe_free(&proximity_blanked_pipe);
datapipe_free(&fpd_service_state_pipe);
datapipe_free(&fpstate_pipe);
datapipe_free(&enroll_in_progress_pipe);
}

/** Convert submode_t bitmap changes to human readable string
Expand Down Expand Up @@ -1527,6 +1545,38 @@ const char *key_state_repr(key_state_t state)
return repr;
}

/** Lookup table for fpstate_t <--> string */
static const mce_translation_t fpstate_lut[] =
{
{ FPSTATE_UNSET, "FPSTATE_UNSET" },
{ FPSTATE_ENUMERATING, "FPSTATE_ENUMERATING" },
{ FPSTATE_IDLE, "FPSTATE_IDLE" },
{ FPSTATE_ENROLLING, "FPSTATE_ENROLLING" },
{ FPSTATE_IDENTIFYING, "FPSTATE_IDENTIFYING" },
{ FPSTATE_REMOVING, "FPSTATE_REMOVING" },
{ FPSTATE_VERIFYING, "FPSTATE_VERIFYING" },
{ FPSTATE_ABORTING, "FPSTATE_ABORTING" },
{ FPSTATE_TERMINATING, "FPSTATE_TERMINATING" },
// sentinel
{ MCE_INVALID_TRANSLATION, 0 }
};

/** Parse fpd state from dbus string */
fpstate_t fpstate_parse(const char *name)
{
return mce_translate_string_to_int_with_default(fpstate_lut,
name,
FPSTATE_UNSET);
}

/** Translate fpd state to human readable form */
const char *fpstate_repr(fpstate_t state)
{
return mce_translate_int_to_string_with_default(fpstate_lut,
state,
"FPSTATE_UNKNOWN");
}

void datapipe_handlers_install(datapipe_handler_t *bindings)
{
if( !bindings )
Expand Down
3 changes: 3 additions & 0 deletions datapipe.h
Expand Up @@ -154,6 +154,9 @@ extern datapipe_struct keypad_grab_wanted_pipe;
extern datapipe_struct keypad_grab_active_pipe;
extern datapipe_struct music_playback_ongoing_pipe;
extern datapipe_struct proximity_blanked_pipe;
extern datapipe_struct fpd_service_state_pipe;
extern datapipe_struct fpstate_pipe;
extern datapipe_struct enroll_in_progress_pipe;

/* Data retrieval */

Expand Down
2 changes: 1 addition & 1 deletion inifiles/mce.ini
Expand Up @@ -16,7 +16,7 @@ ModulePath=/usr/lib/mce/modules
# to avoid unnecessary brightness fluctuations on mce startup
#
# Note: the name should not include the "lib"-prefix
Modules=radiostates;filter-brightness-als;display;keypad;led;battery-statefs;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;memnotify;usbmode;buttonbacklight
Modules=radiostates;filter-brightness-als;display;keypad;led;battery-statefs;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;memnotify;usbmode;buttonbacklight;fingerprint;

[KeyPad]

Expand Down
4 changes: 4 additions & 0 deletions mce-dbus.c
Expand Up @@ -1797,6 +1797,10 @@ static struct
.name = USB_MODED_DBUS_SERVICE,
.datapipe = &usbmoded_service_state_pipe,
},
{
.name = FINGERPRINT1_DBUS_SERVICE,
.datapipe = &fpd_service_state_pipe,
},
{
.name = "com.nokia.NonGraphicFeedback1.Backend",
.datapipe = &ngfd_service_state_pipe,
Expand Down
33 changes: 33 additions & 0 deletions mce-dbus.h
Expand Up @@ -120,6 +120,39 @@ void mce_dbus_exit(void);

void mce_dbus_send_config_notification(GConfEntry *entry);

/* ========================================================================= *
* FINGERPRINT_DAEMON_DBUS_SERVICE (API Version 1)
* ========================================================================= */

# define FINGERPRINT1_DBUS_SERVICE "org.sailfishos.fingerprint1"

# define FINGERPRINT1_DBUS_ROOT_OBJECT "/org/sailfishos/fingerprint1"

# define FINGERPRINT1_DBUS_INTERFACE "org.sailfishos.fingerprint1"

# define FINGERPRINT1_DBUS_REQ_ENROLL "Enroll"
# define FINGERPRINT1_DBUS_REQ_IDENTIFY "Identify"
# define FINGERPRINT1_DBUS_REQ_ABORT "Abort"
# define FINGERPRINT1_DBUS_REQ_GET_ALL "GetAll"
# define FINGERPRINT1_DBUS_REQ_REMOVE "Remove"
# define FINGERPRINT1_DBUS_REQ_VERIFY "Verify"
# define FINGERPRINT1_DBUS_REQ_GET_STATE "GetState"

# define FINGERPRINT1_DBUS_SIG_ADDED "Added"
# define FINGERPRINT1_DBUS_SIG_REMOVED "Removed"
# define FINGERPRINT1_DBUS_SIG_IDENTIFIED "Identified"
# define FINGERPRINT1_DBUS_SIG_ABORTED "Aborted"
# define FINGERPRINT1_DBUS_SIG_FAILED "Failed"
# define FINGERPRINT1_DBUS_SIG_VERIFIED "Verified"

# define FINGERPRINT1_DBUS_SIG_STATE_CHANGED "StateChanged"

# define FINGERPRINT1_DBUS_SIG_ERROR_INFO "ErrorInfo"

# define FINGERPRINT1_DBUS_SIG_ACQUISITION_INFO "AcquisitionInfo"

# define FINGERPRINT1_DBUS_SIG_ENROLL_PROGRESS "EnrollProgressChanged"

/** Placeholder for any basic dbus data type */
typedef union
{
Expand Down
17 changes: 17 additions & 0 deletions mce.h
Expand Up @@ -404,6 +404,23 @@ typedef enum {

const char *key_state_repr(key_state_t state);

/** Fingerprint daemon state */
typedef enum fpstate_t
{
FPSTATE_UNSET,
FPSTATE_ENUMERATING,
FPSTATE_IDLE,
FPSTATE_ENROLLING,
FPSTATE_IDENTIFYING,
FPSTATE_REMOVING,
FPSTATE_VERIFYING,
FPSTATE_ABORTING,
FPSTATE_TERMINATING,
} fpstate_t;

fpstate_t fpstate_parse(const char *name);
const char *fpstate_repr (fpstate_t state);

/* XXX: use HAL */

/** Does the device have a flicker key? */
Expand Down

0 comments on commit 2735b29

Please sign in to comment.