Skip to content

Commit

Permalink
[fingerprint] Add support for debug led patterns
Browse files Browse the repository at this point in the history
There are no visible clues for fingerprint authentication being
possible / activated. This makes it difficult to differentiate between
situations where fingerprint scanner has not been activated and lower
lever functionality having problems with fingerprint acquisition.

To ease debugging, add led patterns for lighting up the led in yellow
color when fingerprint scanner is active and briefly turning the led
blue on fingerprint acquisition events.

These led patterns are not used by default, user must opt-in via:
  mcetool --enable-led-pattern=PatternScanningFingerprint
  mcetool --enable-led-pattern=PatternFingerprintAcquired

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Aug 15, 2018
1 parent cc88ef8 commit 7f395b6
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
10 changes: 10 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1551,6 +1551,16 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = G_STRINGIFY(false),
},
{
.key = MCE_SETTING_LED_PATH"/"MCE_LED_PATTERN_SCANNING_FINGERPRINT,
.type = "b",
.def = G_STRINGIFY(false),
},
{
.key = MCE_SETTING_LED_PATH"/"MCE_LED_PATTERN_FINGERPRINT_ACQUIRED,
.type = "b",
.def = G_STRINGIFY(false),
},
{
.key = MCE_SETTING_LED_SW_BREATH_ENABLED,
.type = "b",
Expand Down
6 changes: 6 additions & 0 deletions inifiles/debug-led.ini
Expand Up @@ -43,3 +43,9 @@ PatternKillingLipstick=12;5;0;100;100;ff00ff

# Touch input blocked after wakeup -> blue
PatternTouchInputBlocked=14;5;0;100;100;0000ff

# Fingerprint scanner active -> static yellow
PatternScanningFingerprint=11;1;0;0;0;ffff00

# Fingerprint acquired -> blue blip
PatternFingerprintAcquired=10;1;1;0;0;0000ff
6 changes: 6 additions & 0 deletions mce.h
Expand Up @@ -111,6 +111,12 @@
/** LED pattern used for communication events when battery is full */
#define MCE_LED_PATTERN_COMMUNICATION_EVENT_BATTERY_FULL "PatternCommunicationAndBatteryFull"

/** LED pattern used when fingerprint scanner is active */
#define MCE_LED_PATTERN_SCANNING_FINGERPRINT "PatternScanningFingerprint"

/** LED pattern used when fingerprint acquisition events are seen */
#define MCE_LED_PATTERN_FINGERPRINT_ACQUIRED "PatternFingerprintAcquired"

/** Persistent lock file for backups */
#define MCE_SETTINGS_LOCK_FILE_PATH G_STRINGIFY(MCE_RUN_DIR) "/restored"

Expand Down
101 changes: 101 additions & 0 deletions modules/fingerprint.c
Expand Up @@ -30,6 +30,17 @@
* Prototypes
* ========================================================================= */

/* ------------------------------------------------------------------------- *
* LED_CONTROL
* ------------------------------------------------------------------------- */

static void fingerprint_scanning_led_activate (bool activate);

static void fingerprint_acquired_led_activate (bool enable);
static gboolean fingerprint_acquired_led_timer_cb (gpointer aptr);
static void fingerprint_acquired_led_trigger (void);
static void fingerprint_acquired_led_cancel (void);

/* ------------------------------------------------------------------------- *
* STATE_MANAGEMENT
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -103,6 +114,81 @@ static fpstate_t fpstate = FPSTATE_UNSET;
/** Tracked fingerprint enroll status; assume not in progress */
static bool enroll_in_progress = false;

/* ========================================================================= *
* LED_CONTROL
* ========================================================================= */

/** Control led pattern for indicating fingerprint scanner status
*
* @param activate true to activate led, false to deactivate
*/
static void
fingerprint_scanning_led_activate(bool activate)
{
static bool activated = false;
if( activated != activate ) {
datapipe_exec_output_triggers((activated = activate) ?
&led_pattern_activate_pipe :
&led_pattern_deactivate_pipe,
MCE_LED_PATTERN_SCANNING_FINGERPRINT,
USE_INDATA);
}
}

/** Control led pattern for indicating fingerprint acquisition events
*
* @param activate true to activate led, false to deactivate
*/
static void
fingerprint_acquired_led_activate(bool activate)
{
static bool activated = false;
if( activated != activate ) {
datapipe_exec_output_triggers((activated = activate) ?
&led_pattern_activate_pipe :
&led_pattern_deactivate_pipe,
MCE_LED_PATTERN_FINGERPRINT_ACQUIRED,
USE_INDATA);
}
}

/** Timer id for: Stop fingerprint acquisition event led */
static guint fingerprint_acquired_led_timer_id = 0;

/** Timer callback for: Stop fingerprint acquisition event led */
static gboolean
fingerprint_acquired_led_timer_cb(gpointer aptr)
{
(void)aptr;
fingerprint_acquired_led_timer_id = 0;
fingerprint_acquired_led_activate(false);
return FALSE;
}

/** Briefly activate fingerprint acquisition event led
*/
static void
fingerprint_acquired_led_trigger(void)
{
if( fingerprint_acquired_led_timer_id )
g_source_remove(fingerprint_acquired_led_timer_id);
fingerprint_acquired_led_timer_id =
g_timeout_add(200, fingerprint_acquired_led_timer_cb, 0);
fingerprint_acquired_led_activate(true);
}

/** Dctivate fingerprint acquisition event led
*/
static void
fingerprint_acquired_led_cancel(void)
{
if( fingerprint_acquired_led_timer_id ) {
g_source_remove(fingerprint_acquired_led_timer_id),
fingerprint_acquired_led_timer_id = 0;
}
fingerprint_acquired_led_activate(false);
}

/* ========================================================================= *
* STATE_MANAGEMENT
* ========================================================================= */
Expand All @@ -127,6 +213,17 @@ fingerprint_update_fpstate(fpstate_t state)
datapipe_exec_full(&fpstate_pipe, GINT_TO_POINTER(fpstate),
USE_INDATA, CACHE_INDATA);

switch( fpstate ) {
case FPSTATE_ENROLLING:
case FPSTATE_IDENTIFYING:
case FPSTATE_VERIFYING:
fingerprint_scanning_led_activate(true);
break;
default:
fingerprint_scanning_led_activate(false);
break;
}

fingerprint_update_enroll_in_progress();

EXIT:
Expand Down Expand Up @@ -467,6 +564,8 @@ fingerprint_dbus_fpacquired_info_cb(DBusMessage *const msg)
break;
}

fingerprint_acquired_led_trigger();

EXIT:
dbus_error_free(&err);

Expand Down Expand Up @@ -624,5 +723,7 @@ g_module_unload(GModule *module)
fingerprint_datapipe_quit();
fingerprint_dbus_fpstate_query_cancel();

fingerprint_scanning_led_activate(false);
fingerprint_acquired_led_cancel();
return;
}
2 changes: 2 additions & 0 deletions tools/mcetool.c
Expand Up @@ -1890,6 +1890,8 @@ static const char * const led_patterns[] =
MCE_LED_PATTERN_KILLING_LIPSTICK,
MCE_LED_PATTERN_TOUCH_INPUT_BLOCKED,
MCE_LED_PATTERN_DISPLAY_DIMMED,
MCE_LED_PATTERN_SCANNING_FINGERPRINT,
MCE_LED_PATTERN_FINGERPRINT_ACQUIRED,
0
};

Expand Down

0 comments on commit 7f395b6

Please sign in to comment.