libfprint/tests/goodixmoc/custom.py

75 lines
1.7 KiB
Python
Raw Normal View History

2020-06-08 14:17:32 +00:00
#!/usr/bin/python3
import gi
gi.require_version('FPrint', '2.0')
from gi.repository import FPrint, GLib
ctx = GLib.main_context_default()
c = FPrint.Context()
c.enumerate()
devices = c.get_devices()
d = devices[0]
del devices
assert d.get_driver() == "goodixmoc"
d.open_sync()
template = FPrint.Print.new(d)
def enroll_progress(*args):
assert d.get_finger_status() == FPrint.FingerStatusFlags.NEEDED
2020-06-08 14:17:32 +00:00
print('enroll progress: ' + str(args))
def identify_done(dev, res):
global identified
identified = True
identify_match, identify_print = dev.identify_finish(res)
print('indentification_done: ', identify_match, identify_print)
assert identify_match.equal(identify_print)
# List, enroll, list, verify, identify, delete
2020-06-08 14:17:32 +00:00
print("enrolling")
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
2020-06-08 14:17:32 +00:00
p = d.enroll_sync(template, None, enroll_progress, None)
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
2020-06-08 14:17:32 +00:00
print("enroll done")
print("listing")
stored = d.list_prints_sync()
print("listing done")
assert len(stored) == 1
assert stored[0].equal(p)
print("verifying")
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
2020-06-08 14:17:32 +00:00
verify_res, verify_print = d.verify_sync(p)
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
2020-06-08 14:17:32 +00:00
print("verify done")
del p
2020-06-08 14:17:32 +00:00
assert verify_res == True
identified = False
deserialized_prints = []
for p in stored:
deserialized_prints.append(FPrint.Print.deserialize(p.serialize()))
assert deserialized_prints[-1].equal(p)
del stored
print('async identifying')
d.identify(deserialized_prints, callback=identify_done)
del deserialized_prints
while not identified:
ctx.iteration(True)
2020-06-08 14:17:32 +00:00
print("deleting")
d.delete_print_sync(p)
print("delete done")
2020-06-08 14:17:32 +00:00
d.close_sync()
del d
del c