mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
device: Support enrolling on devices with no identification support
This commit is contained in:
46
src/device.c
46
src/device.c
@ -306,8 +306,11 @@ on_nr_enroll_stages_changed (FprintDevice *rdev,
|
|||||||
FprintDBusDevice *dbus_dev = FPRINT_DBUS_DEVICE (rdev);
|
FprintDBusDevice *dbus_dev = FPRINT_DBUS_DEVICE (rdev);
|
||||||
gint nr_enroll_stages;
|
gint nr_enroll_stages;
|
||||||
|
|
||||||
|
nr_enroll_stages = fp_device_get_nr_enroll_stages (device);
|
||||||
|
|
||||||
/* One extra step for our internal identification. */
|
/* One extra step for our internal identification. */
|
||||||
nr_enroll_stages = fp_device_get_nr_enroll_stages (device) + 1;
|
if (fp_device_supports_identify (device))
|
||||||
|
nr_enroll_stages += 1;
|
||||||
|
|
||||||
g_debug ("Device %s enroll stages changed to %d",
|
g_debug ("Device %s enroll stages changed to %d",
|
||||||
fp_device_get_name (device),
|
fp_device_get_name (device),
|
||||||
@ -1829,6 +1832,21 @@ enroll_cb (FpDevice *dev, GAsyncResult *res, void *user_data)
|
|||||||
stoppable_action_completed (rdev);
|
stoppable_action_completed (rdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enroll_start (FprintDevice *rdev)
|
||||||
|
{
|
||||||
|
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
||||||
|
|
||||||
|
fp_device_enroll (priv->dev,
|
||||||
|
fprint_device_create_enroll_template (rdev, priv->enroll_data),
|
||||||
|
priv->current_cancellable,
|
||||||
|
enroll_progress_cb,
|
||||||
|
rdev,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback) enroll_cb,
|
||||||
|
rdev);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enroll_identify_cb (FpDevice *dev, GAsyncResult *res, void *user_data)
|
enroll_identify_cb (FpDevice *dev, GAsyncResult *res, void *user_data)
|
||||||
{
|
{
|
||||||
@ -1917,14 +1935,7 @@ enroll_identify_cb (FpDevice *dev, GAsyncResult *res, void *user_data)
|
|||||||
g_signal_emit (rdev, signals[SIGNAL_ENROLL_STATUS], 0, "enroll-stage-passed", FALSE);
|
g_signal_emit (rdev, signals[SIGNAL_ENROLL_STATUS], 0, "enroll-stage-passed", FALSE);
|
||||||
|
|
||||||
/* We are good and can start to enroll. */
|
/* We are good and can start to enroll. */
|
||||||
fp_device_enroll (priv->dev,
|
enroll_start (rdev);
|
||||||
fprint_device_create_enroll_template (rdev, priv->enroll_data),
|
|
||||||
priv->current_cancellable,
|
|
||||||
enroll_progress_cb,
|
|
||||||
rdev,
|
|
||||||
NULL,
|
|
||||||
(GAsyncReadyCallback) enroll_cb,
|
|
||||||
rdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1933,7 +1944,6 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
|
|||||||
const char *finger_name)
|
const char *finger_name)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(GPtrArray) all_prints = NULL;
|
|
||||||
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
|
||||||
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
||||||
FpFinger finger = finger_name_to_fp_finger (finger_name);
|
FpFinger finger = finger_name_to_fp_finger (finger_name);
|
||||||
@ -1964,6 +1974,10 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
|
|||||||
priv->enroll_data = finger;
|
priv->enroll_data = finger;
|
||||||
priv->current_action = ACTION_ENROLL;
|
priv->current_action = ACTION_ENROLL;
|
||||||
|
|
||||||
|
if (fp_device_supports_identify (priv->dev))
|
||||||
|
{
|
||||||
|
g_autoptr(GPtrArray) all_prints = load_all_prints (rdev);
|
||||||
|
|
||||||
/* We (now) have the policy that there must be no duplicate prints.
|
/* We (now) have the policy that there must be no duplicate prints.
|
||||||
* We need to do this for MoC devices, as their "identify" function
|
* We need to do this for MoC devices, as their "identify" function
|
||||||
* will generally just identify across all device stored prints.
|
* will generally just identify across all device stored prints.
|
||||||
@ -1971,7 +1985,6 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
|
|||||||
* to implement new features in the future (i.e. logging in/unlocking
|
* to implement new features in the future (i.e. logging in/unlocking
|
||||||
* the correct user without selecting it first).
|
* the correct user without selecting it first).
|
||||||
*/
|
*/
|
||||||
all_prints = load_all_prints (rdev);
|
|
||||||
fp_device_identify (priv->dev,
|
fp_device_identify (priv->dev,
|
||||||
all_prints,
|
all_prints,
|
||||||
priv->current_cancellable,
|
priv->current_cancellable,
|
||||||
@ -1980,6 +1993,17 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
|
|||||||
NULL,
|
NULL,
|
||||||
(GAsyncReadyCallback) enroll_identify_cb,
|
(GAsyncReadyCallback) enroll_identify_cb,
|
||||||
rdev);
|
rdev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We may still want to try to use verification to check for duplicates
|
||||||
|
* if only one fingerprint was previously enrolled, or add more verify
|
||||||
|
* stages up to a predefined limit */
|
||||||
|
g_warning ("Device %s does not support duplicate identification and so "
|
||||||
|
"fprintd duplicate detection won't work",
|
||||||
|
fp_device_get_name (priv->dev));
|
||||||
|
enroll_start (rdev);
|
||||||
|
}
|
||||||
|
|
||||||
fprint_dbus_device_complete_enroll_start (dbus_dev, invocation);
|
fprint_dbus_device_complete_enroll_start (dbus_dev, invocation);
|
||||||
|
|
||||||
|
|||||||
@ -567,6 +567,7 @@ class FPrintdVirtualImageDeviceBaseTests(FPrintdTest):
|
|||||||
socket_env = 'FP_VIRTUAL_IMAGE'
|
socket_env = 'FP_VIRTUAL_IMAGE'
|
||||||
device_driver = 'virtual_image'
|
device_driver = 'virtual_image'
|
||||||
driver_name = 'Virtual image device for debugging'
|
driver_name = 'Virtual image device for debugging'
|
||||||
|
has_identification = True
|
||||||
|
|
||||||
class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
||||||
|
|
||||||
@ -882,10 +883,12 @@ class FPrintdVirtualStorageDeviceBaseTest(FPrintdVirtualDeviceBaseTest):
|
|||||||
def _maybe_reduce_enroll_stages(self, stages=-1):
|
def _maybe_reduce_enroll_stages(self, stages=-1):
|
||||||
# Reduce the number of default enroll stages, we can go a bit faster
|
# Reduce the number of default enroll stages, we can go a bit faster
|
||||||
stages = stages if stages > 0 else self.enroll_stages
|
stages = stages if stages > 0 else self.enroll_stages
|
||||||
|
if self.has_identification:
|
||||||
stages += 1 # Adding the extra stage for duplicates-check
|
stages += 1 # Adding the extra stage for duplicates-check
|
||||||
if self.num_enroll_stages == stages:
|
if self.num_enroll_stages == stages:
|
||||||
return
|
return
|
||||||
self.send_command('SET_ENROLL_STAGES', stages - 1)
|
device_stages = stages -1 if self.has_identification else stages
|
||||||
|
self.send_command('SET_ENROLL_STAGES', device_stages)
|
||||||
while self.num_enroll_stages != stages:
|
while self.num_enroll_stages != stages:
|
||||||
ctx.iteration(True)
|
ctx.iteration(True)
|
||||||
self.assertIn({'num-enroll-stages': stages}, self._changed_properties)
|
self.assertIn({'num-enroll-stages': stages}, self._changed_properties)
|
||||||
@ -1004,10 +1007,8 @@ class FPrintdVirtualNoStorageDeviceBaseTest(FPrintdVirtualStorageDeviceBaseTest)
|
|||||||
socket_env = 'FP_VIRTUAL_DEVICE'
|
socket_env = 'FP_VIRTUAL_DEVICE'
|
||||||
device_driver = 'virtual_device'
|
device_driver = 'virtual_device'
|
||||||
driver_name = 'Virtual device for debugging'
|
driver_name = 'Virtual device for debugging'
|
||||||
|
has_identification = False
|
||||||
|
|
||||||
def enroll_image(self, img, device=None, finger='right-index-finger',
|
|
||||||
expected_result='enroll-completed', claim_user=None):
|
|
||||||
self.skipTest('Identification not supported, thus is the enrolling')
|
|
||||||
|
|
||||||
class FPrintdVirtualNoStorageDeviceTest(FPrintdVirtualNoStorageDeviceBaseTest):
|
class FPrintdVirtualNoStorageDeviceTest(FPrintdVirtualNoStorageDeviceBaseTest):
|
||||||
|
|
||||||
@ -2212,6 +2213,7 @@ class FPrintdVirtualDeviceEnrollTests(FPrintdVirtualDeviceBaseTest):
|
|||||||
self.assertEnrollError(FPrint.DeviceError.DATA_INVALID, 'enroll-unknown-error')
|
self.assertEnrollError(FPrint.DeviceError.DATA_INVALID, 'enroll-unknown-error')
|
||||||
|
|
||||||
def test_enroll_error_data_not_found(self):
|
def test_enroll_error_data_not_found(self):
|
||||||
|
if self.has_identification:
|
||||||
self.assertEnrollError(
|
self.assertEnrollError(
|
||||||
FPrint.DeviceError.DATA_NOT_FOUND, 'enroll-stage-passed')
|
FPrint.DeviceError.DATA_NOT_FOUND, 'enroll-stage-passed')
|
||||||
self.assertEnrollError(FPrint.DeviceError.DATA_NOT_FOUND, 'enroll-unknown-error')
|
self.assertEnrollError(FPrint.DeviceError.DATA_NOT_FOUND, 'enroll-unknown-error')
|
||||||
|
|||||||
Reference in New Issue
Block a user