Merge pull request #120 from baschi29/fprint_api_fix
Comply with fprint API when returning enrolled fingers
This commit is contained in:
commit
194c055445
4 changed files with 42 additions and 43 deletions
|
|
@ -27,7 +27,7 @@ from validitysensor.sensor import sensor, RebootException
|
||||||
from validitysensor.sid import sid_from_string
|
from validitysensor.sid import sid_from_string
|
||||||
from validitysensor.tls import tls
|
from validitysensor.tls import tls
|
||||||
from validitysensor.usb import usb
|
from validitysensor.usb import usb
|
||||||
from validitysensor.winbio_constants import finger_ids
|
from validitysensor.fingerprint_constants import finger_ids
|
||||||
|
|
||||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
|
|
@ -140,14 +140,8 @@ class Device(dbus.service.Object):
|
||||||
def EnrollStart(self, user, finger_name):
|
def EnrollStart(self, user, finger_name):
|
||||||
logging.debug('In EnrollStart %s for %s' % (finger_name, user))
|
logging.debug('In EnrollStart %s for %s' % (finger_name, user))
|
||||||
|
|
||||||
# left-ring-finger => LH
|
|
||||||
hand = 'LH' if finger_name[0] == 'l' else 'RH'
|
|
||||||
# left-ring-finger => RING_FINGER
|
|
||||||
generic_finger = '_'.join(finger_name.split('-')[1:]).upper()
|
|
||||||
winbio_name = 'WINBIO_ANSI_381_POS_' + hand + '_' + generic_finger
|
|
||||||
|
|
||||||
usr = self.user2identity(user)
|
usr = self.user2identity(user)
|
||||||
index = finger_ids.get(winbio_name, None)
|
index = finger_ids.get(finger_name, None)
|
||||||
|
|
||||||
def update_cb(rsp, e):
|
def update_cb(rsp, e):
|
||||||
if e is not None:
|
if e is not None:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from .flash import call_cleanups
|
||||||
from .sid import SidIdentity, sid_from_bytes
|
from .sid import SidIdentity, sid_from_bytes
|
||||||
from .tls import tls
|
from .tls import tls
|
||||||
from .util import assert_status
|
from .util import assert_status
|
||||||
from .winbio_constants import finger_names
|
from .fingerprint_constants import finger_names
|
||||||
|
|
||||||
|
|
||||||
class UserStorage:
|
class UserStorage:
|
||||||
|
|
|
||||||
39
validitysensor/fingerprint_constants.py
Normal file
39
validitysensor/fingerprint_constants.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# maps fingerprint names from the fprint api to corresponding indices
|
||||||
|
# for legacy reasons uses ANSI381 naming if no fprint name is specified - see https://github.com/uunicorn/python-validity/pull/23
|
||||||
|
|
||||||
|
finger_ids = {
|
||||||
|
# fprint https://fprint.freedesktop.org/fprintd-dev/Device.html#fingerprint-names
|
||||||
|
"right-thumb": 1,
|
||||||
|
"right-index-finger": 2,
|
||||||
|
"right-middle-finger": 3,
|
||||||
|
"right-ring-finger": 4,
|
||||||
|
"right-little-finger": 5,
|
||||||
|
"left-thumb": 6,
|
||||||
|
"left-index-finger": 7,
|
||||||
|
"left-middle-finger": 8,
|
||||||
|
"left-ring-finger": 9,
|
||||||
|
"left-little-finger": 10,
|
||||||
|
|
||||||
|
# ANSI381 https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L864-L878
|
||||||
|
"WINBIO_ANSI_381_POS_UNKNOWN": 0,
|
||||||
|
"WINBIO_ANSI_381_POS_RH_FOUR_FINGERS": 13,
|
||||||
|
"WINBIO_ANSI_381_POS_LH_FOUR_FINGERS": 14,
|
||||||
|
"WINBIO_ANSI_381_POS_TWO_THUMBS": 15,
|
||||||
|
|
||||||
|
# Microsoft specific extensions https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L920-L929
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_01": 0xf5,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_02": 0xf6,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_03": 0xf7,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_04": 0xf8,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_05": 0xf9,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_06": 0xfa,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_07": 0xfb,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_08": 0xfc,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_09": 0xfd,
|
||||||
|
"WINBIO_FINGER_UNSPECIFIED_POS_10": 0xfe
|
||||||
|
}
|
||||||
|
|
||||||
|
# Store the keys in the reverse order for faster lookups
|
||||||
|
finger_names = {}
|
||||||
|
for name, index in finger_ids.items():
|
||||||
|
finger_names[index] = name
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
finger_ids = {
|
|
||||||
# https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L864-L878
|
|
||||||
"WINBIO_ANSI_381_POS_UNKNOWN": 0,
|
|
||||||
"WINBIO_ANSI_381_POS_RH_THUMB": 1,
|
|
||||||
"WINBIO_ANSI_381_POS_RH_INDEX_FINGER": 2,
|
|
||||||
"WINBIO_ANSI_381_POS_RH_MIDDLE_FINGER": 3,
|
|
||||||
"WINBIO_ANSI_381_POS_RH_RING_FINGER": 4,
|
|
||||||
"WINBIO_ANSI_381_POS_RH_LITTLE_FINGER": 5,
|
|
||||||
"WINBIO_ANSI_381_POS_LH_THUMB": 6,
|
|
||||||
"WINBIO_ANSI_381_POS_LH_INDEX_FINGER": 7,
|
|
||||||
"WINBIO_ANSI_381_POS_LH_MIDDLE_FINGER": 8,
|
|
||||||
"WINBIO_ANSI_381_POS_LH_RING_FINGER": 9,
|
|
||||||
"WINBIO_ANSI_381_POS_LH_LITTLE_FINGER": 10,
|
|
||||||
"WINBIO_ANSI_381_POS_RH_FOUR_FINGERS": 13,
|
|
||||||
"WINBIO_ANSI_381_POS_LH_FOUR_FINGERS": 14,
|
|
||||||
"WINBIO_ANSI_381_POS_TWO_THUMBS": 15,
|
|
||||||
|
|
||||||
# https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L920-L929
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_01": 0xf5,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_02": 0xf6,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_03": 0xf7,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_04": 0xf8,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_05": 0xf9,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_06": 0xfa,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_07": 0xfb,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_08": 0xfc,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_09": 0xfd,
|
|
||||||
"WINBIO_FINGER_UNSPECIFIED_POS_10": 0xfe
|
|
||||||
}
|
|
||||||
|
|
||||||
# Store the keys in the reverse order for faster lookups
|
|
||||||
finger_names = {}
|
|
||||||
for name, index in finger_ids.items():
|
|
||||||
finger_names[index] = name
|
|
||||||
Loading…
Reference in a new issue