fp-image-device: Report finger status changes to the device
While the image device has its own finger status tracking, we use a simpler version as public data information, so let's just report the finger-on/off and when a finger is expected to the parent class. Verify that this happens as expected using the virtual-image class
This commit is contained in:
parent
3c382cac7f
commit
893ff9c033
2 changed files with 41 additions and 0 deletions
|
@ -140,6 +140,19 @@ fp_image_device_change_state (FpImageDevice *self, FpiImageDeviceState state)
|
|||
priv->state = state;
|
||||
g_object_notify (G_OBJECT (self), "fpi-image-device-state");
|
||||
g_signal_emit_by_name (self, "fpi-image-device-state-changed", priv->state);
|
||||
|
||||
if (state == FPI_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON)
|
||||
{
|
||||
fpi_device_report_finger_status_changes (FP_DEVICE (self),
|
||||
FP_FINGER_STATUS_NEEDED,
|
||||
FP_FINGER_STATUS_NONE);
|
||||
}
|
||||
else if (state == FPI_IMAGE_DEVICE_STATE_AWAIT_FINGER_OFF)
|
||||
{
|
||||
fpi_device_report_finger_status_changes (FP_DEVICE (self),
|
||||
FP_FINGER_STATUS_NONE,
|
||||
FP_FINGER_STATUS_NEEDED);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -395,6 +408,19 @@ fpi_image_device_report_finger_status (FpImageDevice *self,
|
|||
FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
|
||||
FpiDeviceAction action;
|
||||
|
||||
if (present)
|
||||
{
|
||||
fpi_device_report_finger_status_changes (device,
|
||||
FP_FINGER_STATUS_PRESENT,
|
||||
FP_FINGER_STATUS_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
fpi_device_report_finger_status_changes (device,
|
||||
FP_FINGER_STATUS_NONE,
|
||||
FP_FINGER_STATUS_PRESENT);
|
||||
}
|
||||
|
||||
if (priv->state == FPI_IMAGE_DEVICE_STATE_INACTIVE)
|
||||
{
|
||||
/* Do we really want to always ignore such reports? We could
|
||||
|
@ -684,6 +710,8 @@ fpi_image_device_open_complete (FpImageDevice *self, GError *error)
|
|||
priv->state = FPI_IMAGE_DEVICE_STATE_INACTIVE;
|
||||
g_object_notify (G_OBJECT (self), "fpi-image-device-state");
|
||||
|
||||
fpi_device_report_finger_status (FP_DEVICE (self), FP_FINGER_STATUS_NONE);
|
||||
|
||||
fpi_device_open_complete (FP_DEVICE (self), error);
|
||||
}
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ class VirtualImage(unittest.TestCase):
|
|||
def done_cb(dev, res):
|
||||
print("Enroll done")
|
||||
fp = dev.enroll_finish(res)
|
||||
self.assertEqual(self.dev.get_finger_status(), FPrint.FingerStatusFlags.NONE)
|
||||
self._enrolled = fp
|
||||
|
||||
template = FPrint.Print.new(self.dev)
|
||||
|
@ -182,6 +183,7 @@ class VirtualImage(unittest.TestCase):
|
|||
date = GLib.Date()
|
||||
date.set_dmy(*datetime.get_ymd()[::-1])
|
||||
template.props.enroll_date = date
|
||||
self.assertEqual(self.dev.get_finger_status(), FPrint.FingerStatusFlags.NONE)
|
||||
self.dev.enroll(template, None, progress_cb, tuple(), done_cb)
|
||||
|
||||
# Note: Assumes 5 enroll steps for this device!
|
||||
|
@ -192,25 +194,36 @@ class VirtualImage(unittest.TestCase):
|
|||
# Test the image-device path where the finger is removed after
|
||||
# the minutiae scan is completed.
|
||||
self.send_finger_automatic(False)
|
||||
self.assertEqual(self.dev.get_finger_status(), FPrint.FingerStatusFlags.NEEDED)
|
||||
self.send_finger_report(True)
|
||||
self.assertEqual(self.dev.get_finger_status(),
|
||||
FPrint.FingerStatusFlags.NEEDED | FPrint.FingerStatusFlags.PRESENT)
|
||||
self.send_image(image)
|
||||
while self._step < 2:
|
||||
ctx.iteration(True)
|
||||
self.send_finger_report(False)
|
||||
|
||||
self.assertEqual(self.dev.get_finger_status(), FPrint.FingerStatusFlags.NEEDED)
|
||||
|
||||
self.send_finger_automatic(True)
|
||||
self.send_image(image)
|
||||
while self._step < 3:
|
||||
ctx.iteration(True)
|
||||
|
||||
self.assertEqual(self.dev.get_finger_status(), FPrint.FingerStatusFlags.NEEDED)
|
||||
|
||||
self.send_image(image)
|
||||
while self._step < 4:
|
||||
ctx.iteration(True)
|
||||
|
||||
self.assertEqual(self.dev.get_finger_status(), FPrint.FingerStatusFlags.NEEDED)
|
||||
|
||||
self.send_image(image)
|
||||
while self._enrolled is None:
|
||||
ctx.iteration(True)
|
||||
|
||||
self.assertEqual(self.dev.get_finger_status(), FPrint.FingerStatusFlags.NONE)
|
||||
|
||||
return self._enrolled
|
||||
|
||||
def test_enroll_verify(self):
|
||||
|
|
Loading…
Reference in a new issue