device: Always report selected finger if there is only one

If the user specified "any" finger, then we would mirror this back even
if there is only one finger available. Change it so that we act as if
that finger was passed explicitly, meaning we use the "verify" method
and also send the signal for the selected finger accordingly.
This commit is contained in:
Benjamin Berg 2021-09-02 17:46:17 +02:00 committed by Benjamin Berg
parent 02468366b2
commit fc65055279
2 changed files with 14 additions and 6 deletions

View file

@ -1667,7 +1667,15 @@ fprint_device_verify_start (FprintDBusDevice *dbus_dev,
g_dbus_method_invocation_return_gerror (invocation, error);
return TRUE;
}
if (fp_device_has_feature (priv->dev, FP_DEVICE_FEATURE_IDENTIFY))
else if (gallery->len == 1)
{
FpPrint *fprint = g_ptr_array_index (gallery, 0);
/* If we only have a single finger, then do verify on that.
* This also means we report it back correctly to the user. */
finger = fp_print_get_finger (fprint);
}
else if (fp_device_has_feature (priv->dev, FP_DEVICE_FEATURE_IDENTIFY))
{
guint i;

View file

@ -2004,14 +2004,14 @@ class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest):
self.wait_for_result()
self.assertTrue(self._verify_stopped)
self.assertEqual(self._last_result, 'verify-match')
self.assertEqual(self._selected_finger, 'any')
self.assertEqual(self._selected_finger, 'left-thumb')
self.device.VerifyStop()
def test_verify_wrong_finger_no_match(self):
self.enroll_image('whorl', finger='right-thumb')
self.device.VerifyStart('(s)', 'right-toe')
self.send_image('tented_arch')
self.assertVerifyNoMatch(selected_finger='any')
self.assertVerifyNoMatch(selected_finger='right-thumb')
self.device.VerifyStop()
def test_verify_any_finger_match(self):
@ -2047,9 +2047,9 @@ class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest):
self.device.VerifyStart('(s)', 'any')
self.send_image(print)
if should_match:
self.assertVerifyMatch(selected_finger='any')
self.assertVerifyMatch()
else:
self.assertVerifyNoMatch(selected_finger='any')
self.assertVerifyNoMatch()
self.device.VerifyStop()
self.device.Release()
@ -3086,7 +3086,7 @@ class FPrindConcurrentPolkitRequestsTest(FPrintdVirtualStorageDeviceBaseTest):
self.device.Claim('(s)', '')
self.device.VerifyStart('(s)', 'any')
self.send_image('whorl')
self.assertVerifyMatch(selected_finger='any')
self.assertVerifyMatch(selected_finger='left-thumb')
self.device.VerifyStop()
self.device.Release()