Skip to content
Permalink
Browse files
[fingerprint] Add support for debug led patterns
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 7f395b6131fd8f969265b72e1123b59e4eaace43
Showing with 125 additions and 0 deletions.
  1. +10 −0 builtin-gconf.c
  2. +6 −0 inifiles/debug-led.ini
  3. +6 −0 mce.h
  4. +101 −0 modules/fingerprint.c
  5. +2 −0 tools/mcetool.c
@@ -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",
@@ -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 mce.h
@@ -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"

@@ -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
* ------------------------------------------------------------------------- */
@@ -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
* ========================================================================= */
@@ -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:
@@ -467,6 +564,8 @@ fingerprint_dbus_fpacquired_info_cb(DBusMessage *const msg)
break;
}

fingerprint_acquired_led_trigger();

EXIT:
dbus_error_free(&err);

@@ -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;
}
@@ -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
};

0 comments on commit 7f395b6

Please sign in to comment.