Introduce an early reporting mechanism for verify and match

It is a good idea to report match results early, to e.g. log in a user
immediately even if more device interaction is needed. Add new _full
variants for the verify/identify functions, with a corresponding
callback. Also move driver result reporting into new
fpi_device_{identify,verify}_report functions and remove the reporting
from the fpi_device_{identify,verify}_complete calls.

Basic updates to code is done in places. Only the upekts driver is
actually modified from a behaviour point of view. The image driver code
should be restructured quite a bit to split the reporting and only
report completion after device deactivation. This should simplifiy the
code quite a bit again.
This commit is contained in:
Benjamin Berg
2019-12-24 01:01:04 +01:00
parent 8292c449f7
commit 4d5c34e11a
13 changed files with 385 additions and 102 deletions

View File

@@ -95,8 +95,16 @@ fpi_device_fake_verify (FpDevice *device)
fpi_device_get_verify_data (device, &print);
fake_dev->last_called_function = fpi_device_fake_verify;
fpi_device_verify_complete (device, fake_dev->ret_result, print,
fake_dev->ret_error);
if (!fake_dev->ret_error || fake_dev->ret_error->domain == FP_DEVICE_RETRY)
{
fpi_device_verify_report (device, fake_dev->ret_result, print, fake_dev->ret_error);
fpi_device_verify_complete (device, NULL);
}
else
{
fpi_device_verify_complete (device, fake_dev->ret_error);
}
}
static void
@@ -128,8 +136,15 @@ fpi_device_fake_identify (FpDevice *device)
}
fake_dev->last_called_function = fpi_device_fake_identify;
fpi_device_identify_complete (device, match, fake_dev->ret_print,
fake_dev->ret_error);
if (!fake_dev->ret_error || fake_dev->ret_error->domain == FP_DEVICE_RETRY)
{
fpi_device_identify_report (device, match, fake_dev->ret_print, fake_dev->ret_error);
fpi_device_identify_complete (device, NULL);
}
else
{
fpi_device_identify_complete (device, fake_dev->ret_error);
}
}
static void

View File

@@ -1166,12 +1166,12 @@ test_driver_complete_actions_errors (void)
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"*assertion*current_action*failed");
fpi_device_verify_complete (device, FPI_MATCH_FAIL, NULL, NULL);
fpi_device_verify_complete (device, NULL);
g_test_assert_expected_messages ();
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"*assertion*current_action*failed");
fpi_device_identify_complete (device, NULL, NULL, NULL);
fpi_device_identify_complete (device, NULL);
g_test_assert_expected_messages ();
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,

View File

@@ -220,7 +220,7 @@ class VirtualImage(unittest.TestCase):
self._verify_match = None
self._verify_fp = None
self.dev.verify(fp_whorl, None, verify_cb)
self.dev.verify(fp_whorl, callback=verify_cb)
self.send_image('whorl')
while self._verify_match is None:
ctx.iteration(True)
@@ -228,7 +228,7 @@ class VirtualImage(unittest.TestCase):
self._verify_match = None
self._verify_fp = None
self.dev.verify(fp_whorl, None, verify_cb)
self.dev.verify(fp_whorl, callback=verify_cb)
self.send_image('tented_arch')
while self._verify_match is None:
ctx.iteration(True)
@@ -250,14 +250,14 @@ class VirtualImage(unittest.TestCase):
self._identify_match, self._identify_fp = self.dev.identify_finish(res)
self._identify_fp = None
self.dev.identify([fp_whorl, fp_tented_arch], None, identify_cb)
self.dev.identify([fp_whorl, fp_tented_arch], callback=identify_cb)
self.send_image('tented_arch')
while self._identify_fp is None:
ctx.iteration(True)
assert(self._identify_match is fp_tented_arch)
self._identify_fp = None
self.dev.identify([fp_whorl, fp_tented_arch], None, identify_cb)
self.dev.identify([fp_whorl, fp_tented_arch], callback=identify_cb)
self.send_image('whorl')
while self._identify_fp is None:
ctx.iteration(True)
@@ -290,7 +290,7 @@ class VirtualImage(unittest.TestCase):
self._verify_match = None
self._verify_fp = None
self.dev.verify(fp_whorl_new, None, verify_cb)
self.dev.verify(fp_whorl_new, callback=verify_cb)
self.send_image('whorl')
while self._verify_match is None:
ctx.iteration(True)
@@ -298,7 +298,7 @@ class VirtualImage(unittest.TestCase):
self._verify_match = None
self._verify_fp = None
self.dev.verify(fp_whorl_new, None, verify_cb)
self.dev.verify(fp_whorl_new, callback=verify_cb)
self.send_image('tented_arch')
while self._verify_match is None:
ctx.iteration(True)