From 3c382cac7f9779ec74cfe2b84030740dd4e4edc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Thu, 26 Mar 2020 22:22:40 +0100
Subject: [PATCH] fp-device: Reset the finger status on complete

Devices should handle the finger status internally, but if they don't do it
we need to handle it on actions completion
---
 libfprint/fp-device.c  | 3 +++
 libfprint/fpi-device.c | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c
index c6fb7e3..0eb370e 100644
--- a/libfprint/fp-device.c
+++ b/libfprint/fp-device.c
@@ -85,6 +85,8 @@ fp_device_cancel_in_idle_cb (gpointer user_data)
 
   cls->cancel (self);
 
+  fpi_device_report_finger_status (self, FP_FINGER_STATUS_NONE);
+
   return G_SOURCE_REMOVE;
 }
 
@@ -635,6 +637,7 @@ fp_device_open (FpDevice           *device,
   priv->current_action = FPI_DEVICE_ACTION_OPEN;
   priv->current_task = g_steal_pointer (&task);
   maybe_cancel_on_cancelled (device, cancellable);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   FP_DEVICE_GET_CLASS (device)->open (device);
 }
diff --git a/libfprint/fpi-device.c b/libfprint/fpi-device.c
index d94ae67..3649304 100644
--- a/libfprint/fpi-device.c
+++ b/libfprint/fpi-device.c
@@ -787,6 +787,7 @@ fpi_device_probe_complete (FpDevice    *device,
   g_debug ("Device reported probe completion");
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (!error)
     {
@@ -829,6 +830,7 @@ fpi_device_open_complete (FpDevice *device, GError *error)
   g_debug ("Device reported open completion");
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (!error)
     {
@@ -862,6 +864,7 @@ fpi_device_close_complete (FpDevice *device, GError *error)
   g_debug ("Device reported close completion");
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   switch (priv->type)
     {
@@ -918,6 +921,7 @@ fpi_device_enroll_complete (FpDevice *device, FpPrint *print, GError *error)
   g_debug ("Device reported enroll completion");
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (!error)
     {
@@ -985,6 +989,7 @@ fpi_device_verify_complete (FpDevice *device,
   data = g_task_get_task_data (priv->current_task);
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (!error)
     {
@@ -1044,6 +1049,7 @@ fpi_device_identify_complete (FpDevice *device,
   data = g_task_get_task_data (priv->current_task);
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (!error)
     {
@@ -1100,6 +1106,7 @@ fpi_device_capture_complete (FpDevice *device,
   g_debug ("Device reported capture completion");
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (!error)
     {
@@ -1145,6 +1152,7 @@ fpi_device_delete_complete (FpDevice *device,
   g_debug ("Device reported deletion completion");
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (!error)
     fpi_device_return_task_in_idle (device, FP_DEVICE_TASK_RETURN_BOOL,
@@ -1179,6 +1187,7 @@ fpi_device_list_complete (FpDevice  *device,
   g_debug ("Device reported listing completion");
 
   clear_device_cancel_action (device);
+  fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE);
 
   if (prints && error)
     {