Blame SOURCES/0093-image-device-Print-warning-for-incorrect-deactivatio.patch

d47ffe
From dfef13a3eb14ded653a0f1226eb5903e0b81b772 Mon Sep 17 00:00:00 2001
d47ffe
From: Benjamin Berg <bberg@redhat.com>
d47ffe
Date: Wed, 4 Dec 2019 19:54:07 +0100
d47ffe
Subject: [PATCH 093/181] image-device: Print warning for incorrect
d47ffe
 deactivation
d47ffe
d47ffe
Drivers may not handle deactivation properly when they are awaiting a
d47ffe
finger. This should be prevented by the internal FpImageDevice state
d47ffe
machine.
d47ffe
---
d47ffe
 libfprint/fp-image-device.c | 7 +++++++
d47ffe
 1 file changed, 7 insertions(+)
d47ffe
d47ffe
diff --git a/libfprint/fp-image-device.c b/libfprint/fp-image-device.c
d47ffe
index 26c3cb0..252f414 100644
d47ffe
--- a/libfprint/fp-image-device.c
d47ffe
+++ b/libfprint/fp-image-device.c
d47ffe
@@ -50,6 +50,7 @@ typedef struct
d47ffe
 {
d47ffe
   FpImageDeviceState state;
d47ffe
   gboolean           active;
d47ffe
+  gboolean           cancelling;
d47ffe
 
d47ffe
   gboolean           enroll_await_on_pending;
d47ffe
   gint               enroll_stage;
d47ffe
@@ -140,6 +141,9 @@ fp_image_device_deactivate (FpDevice *device)
d47ffe
       fp_dbg ("Already deactivated, ignoring request.");
d47ffe
       return;
d47ffe
     }
d47ffe
+  if (!priv->cancelling && priv->state == FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON)
d47ffe
+    g_warning ("Deactivating image device while waiting for finger, this should not happen.");
d47ffe
+
d47ffe
   priv->state = FP_IMAGE_DEVICE_STATE_INACTIVE;
d47ffe
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
d47ffe
 
d47ffe
@@ -203,6 +207,7 @@ static void
d47ffe
 fp_image_device_cancel_action (FpDevice *device)
d47ffe
 {
d47ffe
   FpImageDevice *self = FP_IMAGE_DEVICE (device);
d47ffe
+  FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
d47ffe
   FpDeviceAction action;
d47ffe
 
d47ffe
   action = fpi_device_get_current_action (device);
d47ffe
@@ -214,7 +219,9 @@ fp_image_device_cancel_action (FpDevice *device)
d47ffe
       action == FP_DEVICE_ACTION_IDENTIFY ||
d47ffe
       action == FP_DEVICE_ACTION_CAPTURE)
d47ffe
     {
d47ffe
+      priv->cancelling = TRUE;
d47ffe
       fp_image_device_deactivate (FP_DEVICE (self));
d47ffe
+      priv->cancelling = FALSE;
d47ffe
 
d47ffe
       /* XXX: Some nicer way of doing this would be good. */
d47ffe
       fpi_device_action_error (FP_DEVICE (self),
d47ffe
-- 
d47ffe
2.24.1
d47ffe