Commit graph

1084 commits

Author SHA1 Message Date
Benjamin Berg fe498c56c7 virtual-image: Fix race condition closing new connection
When a new connection came in we would close the old connection. This in
turn would trigger a receive error causing the *new* connection to be
closed from the error handler.

Fix this by simply cancelling any pending transfers when a new
connection comes in. Also change the error handling code to catch issues
like partial writes correctly.

This fixes an issue for the fprintd test where some tests were flaky.
2020-11-10 15:59:53 +01:00
Marco Trevisan (Treviño) 251ccef9ba fpi-device: Add debug information about the enrolled finger 2020-11-08 22:19:23 +01:00
Marco Trevisan (Treviño) 0c56e0de6d synaptics: Report finger status to libfprint
The inactivation in case would be set back by libfprint
2020-11-07 13:23:30 +00:00
Marco Trevisan (Treviño) 893ff9c033 fp-image-device: Report finger status changes to the device
While the image device has its own finger status tracking, we use a simpler
version as public data information, so let's just report the finger-on/off
and when a finger is expected to the parent class.

Verify that this happens as expected using the virtual-image class
2020-11-07 13:23:30 +00:00
Marco Trevisan (Treviño) 3c382cac7f fp-device: Reset the finger status on complete
Devices should handle the finger status internally, but if they don't do it
we need to handle it on actions completion
2020-11-07 13:23:30 +00:00
Marco Trevisan (Treviño) 42e4506b1b fp-device: Add finger-status property
It can be used by drivers to report the state of the finger on sensor
2020-11-07 13:23:30 +00:00
Benjamin Berg e5fa54e8e7 vfs301: Start capture only on state change to AWAIT_FINGER_ON
Start the capture when the state changes to AWAIT_FINGER_ON instead of
assuming that the device should always be active.

Closes: #320
2020-11-04 14:13:00 +01:00
Benjamin Berg d3076039d0 vfs301: Fix device pointer handling in callback
When porting the driver to the new libfprint 1.90.0 a mistake was made
where the device was not passed through user_data anymore but it was
still read from there. Stop using user_data in the callback to fix this.

See: #320
2020-11-04 14:13:00 +01:00
Benjamin Berg a748f4d30f elan: Simplify elan driver internal state machine
The elan driver always "deactivates" the device after a cpature run. We
can simplify the while internal state into a single "active" state and
rely on the image device driving this state machine correctly.

i.e.:
 * We start a callibrate/capture/deactivate when we go into the
   AWAIT_FINGER_ON state
 * We only store the fact that we are active and want to deactivate
 * We rely on the image device never going into the AWAIT_FINGER_ON
   state without first waiting for the finger to be off (which implies
   deactivation).
2020-11-04 14:13:00 +01:00
Benjamin Berg 3ee5536a13 image-device: Redefine internal states and valid transitions
This adds a number of new internal states to better capture what is
going on. Also added are checks that all transitions we make are in the
set of expected and valid transitions.

Only three drivers use the state_change notification. These drivers are
updated accordingly.
2020-11-04 14:13:00 +01:00
Benjamin Berg f56aacc7ef image-device: Remove cancelling boolean from private data
The boolean is just used to emit a warning for unexpected state
transitions. It is sufficient to pass it to the deactivate function
directly for that purpose.
2020-11-04 14:13:00 +01:00
Benjamin Berg 96fa0a96eb uru4000: Fix missing reference to image transfer
We might redo image transfers, but we only ever had one reference that
was implicitly removed after the transfer completed. Add a new reference
each time it is submitted and only free the last reference in the stop
handler.
2020-10-19 17:41:26 +02:00
Benjamin Berg 1754bd0204 synaptics: Always submit interrupt transfer without a timeout
For some reason we re-submitted the interrupt transfer with a timeout of
1s while the original submission was without a timeout. This looks like
typo, remove the timeout.
2020-10-19 17:14:24 +02:00
Benjamin Berg 90a1abf2f8 synaptics: Fix missing reference to interrupt transfer
When resubmitting the interrupt transfer we need to add a new reference
as the submit function will steal it again.
2020-10-19 17:13:58 +02:00
Benjamin Berg 59824d2122 synaptics: Remove useless code
There is never a fall through if error is not NULL.
2020-10-19 16:59:07 +02:00
Vincent Huang 31319d9c6f synaptics: add support to pid 0xF9, 0xFC, 0xC2 2020-10-15 12:25:34 +08:00
Vincent Huang e27b65c930 synaptics: add identify function 2020-10-14 18:48:09 +08:00
Benjamin Berg 44ef20d5ac aesx660: Use convenience API to allocate USB receive buffer
This also fixes a memory leak of the data as the g_free was missing and
none of the callback handlers free the data either.
2020-10-07 13:38:59 +02:00
Benjamin Berg 4719b30f16 aes1610: Use convenience API to allocate USB receive buffer 2020-10-07 13:38:59 +02:00
Benjamin Berg 7eb361087a drivers: Add access annotations to USB helpers
Mostly for completeness sake, doing this did not find any errors (but
might catch some issues with fixed buffer lengths).
2020-10-07 13:38:59 +02:00
Benjamin Berg 33d50e4e30 usb: Annotate access to USB buffers
Annotate the USB transfer creation functions with the correct buffer
access attribute. Note that we only annotate them as read_only as the
functions may be used for sending and receiving.

Hopefully this will catch buffer overflows in drivers in the future.
2020-10-07 13:22:18 +02:00
Benjamin Berg 994690cfa3 virtual-image: Only read socket when active
Doing this avoids race conditions in testing code where the code might
try to submit errors/images before the device has been activated. This
would then (sometimes) trigger assertions in the image driver code.
2020-10-07 09:44:49 +00:00
Benjamin Berg 52b2d10887 image-device: Delay task completion until device is deactivated
The earlier image device code tried to hide deactivation from the
surrounding library. However, this does not make any sense anymore with
the early reporting feature present.

This changes the operation to complete only once the device is
deactivated. Also changed that in most cases (except for cancellation)
we wait for the finger to be removed before deactivating the device.
2020-10-07 09:44:49 +00:00
Benjamin Berg 81e0f4dfe5 aes3k: Re-send some commands for each capture
The driver seems to have relied on the device to be fully
deactivated and activated again for each capture. This is not the case
during enroll, and as such in can cause issues.

Try fixing this by splitting out the last few commands send to the
device and assuming that this starts the capture.

Fixes: #306
2020-10-07 11:34:12 +02:00
Benjamin Berg c7cab77fc1 usb-transfer: Work around libgusb cancellation issue
We have plenty of code paths where a transfer may be cancelled before it
is submitted. Unfortunately, libgusb up to and including version 0.3.6
are not handling that case correctly (due to libusb ignoring
cancellation on transfers that are not yet submitted).

Work around this, but do so in a somewhat lazy fashion that is not
entirely race free.

Closes: #306
2020-10-01 00:19:35 +02:00
Benjamin Berg a63dcc96d5 virtual_image: Open a window for race conditions during open/close
Delay the open/close callbacks by 100ms so that we have a window of
opportunity for race conditions. This is needed to test certain
conditiosn in fprintd.
2020-09-29 12:02:19 +00:00
Benjamin Berg fab349f356 Remove trailing \n where they are not necessary
Adding a trailing \n to g_message, g_debug, g_warning and g_error is not
neccessary, as a newline will be added automatically by the logging
infrastructure.
2020-09-29 10:42:03 +02:00
Benjamin Berg 8c4ff253cb aes3k: Fix transfer error path and cancellable lifetime
The cancellable needs to be free'ed at deactivation. Also free it if we
run into a fatal error, which then in turn indicates that the device is
deactivated already.
2020-09-29 10:35:25 +02:00
Benjamin Berg 3ce6a15547 image-device: Don't deactivate if deactivation was already started
The test only prevent deactivation after it completed. Also guard
against trying to deactivate a second time.
2020-09-28 19:12:28 +02:00
Benjamin Berg bcce8876e2 aes3k: Fix cancellation logic of aes3k driver
The change_state function is called synchronously from the
image_captured callback. This means that deactivation of the device
happens during the img_cb function, causing the USB transfer to be
re-registered even though the device is already deactivating.

There are various ways to fix this, but it makes sense to directly bind
the cancellation to the deactivation. So create a cancellable that we
cancel at deactivation time, and make sure we always deactivate by going
through cancellation.

closes: #306
2020-09-14 11:23:38 +00:00
boger.wang f67f61c638 goodixmoc: Add identify function
this device support verify and identify both, actually call the same
interface.
2020-09-14 09:55:55 +00:00
boger.wang d5f7f4dfaa goodixmoc: Prevent incorrect firmware type running
only firmware type:APP can function well, if device flash in a factory
or test firmware, report a error tips user update firmware by fwupd
2020-09-14 09:55:55 +00:00
Benjamin Berg ce6961d165 image-device: Fix cancellation documentation
Image devices are simply deactivated suddenly. As such, the cancellation
logic of FpDevice is not really useful there, but the documentation was
apparently accidentally copied unmodified.
2020-09-07 12:12:34 +02:00
Benjamin Berg 5d0481b031 context: Lower severity of warning if USB fails to initialise
This is unlikely to happen in a real world scenario and currently breaks
running the CI test (not the umockdev based ones) while building the
flatpak. Lower the severity to avoid aborting because there is a
warning.
2020-09-03 09:41:11 +02:00
Benjamin Berg 596d22a449 context: Fix invalid accesses to GUsbContext if USB is missing
When USB cannot be initialised (inside the flatpak build environment),
then we would have invalid accesses to the NULL pointer. Fix those.
2020-09-03 09:41:11 +02:00
boger.wang eb2aaaaa20 drivers: add goodix moc sensor driver support 2020-09-01 16:39:06 +08:00
boger.wang e3c009c5b3 fp-device: add new type FpDeviceError FP_DEVICE_ERROR_DATA_DUPLICATE 2020-09-01 16:39:06 +08:00
Vincent Huang a4f7293f32 synaptics: retry get version command once when receiving non-success
status
2020-08-21 17:42:00 +08:00
Vincent Huang 8b64312f4b synaptics: support sensors pid 0xe9 & 0xdf 2020-07-31 09:47:35 +08:00
Marco Trevisan (Treviño) ed26976ac5 fpi-usb-transfer: Use the same values of libusb for transfer types 2020-06-16 22:50:47 +02:00
Marco Trevisan (Treviño) e4d292b595 fp-image-device: Properly include fp-device.h 2020-06-16 22:49:38 +02:00
Marco Trevisan (Treviño) c6b8430c72 fpi-print: Improve debug on print score 2020-06-16 22:49:18 +02:00
Marco Trevisan (Treviño) cbf1dcca29 fpi-image-device: Improve debugging messages 2020-06-16 22:48:51 +02:00
Marco Trevisan (Treviño) 7f7d099ba0 fpi-device: Don't double check for cancellable value
g_cancellable_is_cancelled already handles properly null values
2020-06-16 22:43:18 +02:00
Marco Trevisan (Treviño) b6f965c1d9 fpi-device: Use the current action string instead of value 2020-06-16 22:42:34 +02:00
Benjamin Berg 4af3e59174 uru4000: Always detect whether encryption is in use
This is based on the patch and observation from Bastien that some
URU4000B devices do not use encryption by default (it is a configuration
stored within the firmware). As such, it makes sense to always detect
whether encryption is in use by inspecting the image.

The encryption option would disable flipping of the image for the
URU400B device. Retain this behaviour for backward compatibility.
2020-06-05 15:53:53 +00:00
Benjamin Berg 24b1faffde upeksonly: Add a comment that multiple URBs are needed 2020-06-05 17:44:36 +02:00
Benjamin Berg 49983c8ee7 upeksonly: Fix memory leak of register data helper struct 2020-06-05 17:44:36 +02:00
Vasily Khoruzhick d276c3489e upeksonly: Fix register write value
The value was set after the transfer was submitting, causing the value
to always be zero.
2020-06-05 17:44:36 +02:00
Benjamin Berg 3f51e6dcb6 upeksonly: Pass required user data to write_regs_cb
The user data for write_regs_cb needs to be set to wrdata. This was
simply missing, add the appropriate argument.
2020-06-05 17:44:36 +02:00
Benjamin Berg b4dbbd667a upeksonly: Avoid reading beyond received packet boundary
The code would just read 4096 bytes from the packet, without checking
the size and neither setting short_is_error. It is not clear whether
packets from the device are always 4096 bytes or not. But the code
assume we always get a full line, so enforce that and use the actual
packet size otherwise.
2020-06-05 17:44:36 +02:00
Benjamin Berg 7d9245505f upeksonly: Remove callback support after killing transfers
This seems to have been unused even before the v2 port.
2020-06-05 17:44:36 +02:00
Benjamin Berg 570daf2321 upeksonly: Remove ABORT_SSM constant
This was not used. The old driver used this if creating a USB transfer
failed, however, we delay any such failures (which cannot really happen)
into the callback today, where the error is handled differently.
2020-06-05 15:40:17 +00:00
Benjamin Berg 60d0f84294 upeksonly: Fix creation of image transfers
The GPtrArray needs to be created at some point. Also, reference
counting was wrong as submitting the transfer sinks the ref, but we rely
on it surviving.

Note that we really should change this to only have one in-flight
transfer and starting a new one after it finishes.

Co-authored-by: Vasily Khoruzhick <anarsoul@gmail.com>
2020-06-05 15:40:17 +00:00
Benjamin Berg 6633025437 vfs301: Allow freeing of data by copying it
When sending static data, it would not be copied. The function that
sends it assumed that it should be free'ed though.

Fix this by simply always making a copy.
2020-06-05 15:17:42 +00:00
Benjamin Berg 40ed353666 elan: Only queue state changes once
The driver would warn about the fact that a state change is queued, but
still queue it a second time. This would result in deactivation to run
twice.

See: #216
2020-06-05 15:13:18 +00:00
Benjamin Berg 32bdd8d5c4 image: Fix reporting of retry on activation timeout
The image driver may still be deactivating when a new activation request
comes in. This is because of a hack to do early reporting, which is
technically not needed anymore.

Fix the immediate issue by properly reporting the retry case. The proper
fix is to only finish the previous operation after the device has been
deactivated.
2020-06-05 15:07:05 +00:00
Benjamin Berg 4b83f8bfd9 vfs0050: Accept zero bytes read instead of timeout for emulation
This allows us to replace non-emulateable timeout conditions into zero
byte replies in the recording.
2020-06-05 15:03:38 +00:00
Benjamin Berg b137807420 upekts: Fix error reporting during verify
We delayed the wrong error types for the early reporting mechanism.
2020-06-05 14:48:57 +00:00
Benjamin Berg 0936fc3597 upekts: Fix error handling in verify_stop_deinit_cb
The error memory management was incorrect possibly causing double free's
and critical warnings.
2020-06-05 14:48:57 +00:00
Benjamin Berg b7f436e8de upekts: Fix reading of fingerprint data for verification
the code tried to fetch the data from the device rather the print.
Obviously, this could never work.
2020-06-05 14:48:57 +00:00
Benjamin Berg f0abefa9fa device: Ensure enrolled print as an appropriate type set
The driver might forget to set the type of the print. Catch that error a
bit earlier rather than failing when the API user tries to load it from
disk again.
2020-06-05 14:48:57 +00:00
Benjamin Berg cecb01bcb9 upekts: Set the print type during enroll
The type of the print (RAW or NBIS) needs to be filled in by the driver.
For most drivers the image devices does this (NBIS), but the
corresponding call was missing in the upekts driver, rendering the
enrolled print unusable.
2020-06-05 14:48:57 +00:00
Benjamin Berg b95402bc72 upekts: Fix memory leak and remove unneeded copy
__handle_incoming_msg would copy the payload of the message into a newly
created buffer just to destroy it again immediately after calling the
callback. Just reference the correct address inside the original package
instead.

Also, in one case the extra buffer was leaked afterwards.
2020-06-05 14:48:57 +00:00
Benjamin Berg 484743f652 upekts: Assert correct packet length in __handle_incoming_msg
The surrounding code already checks this and reads the correct amount.
Add an assert to ensure we really never do an out of bounds read.
2020-06-05 14:48:57 +00:00
Benjamin Berg a5cfc1644f upekts: Fix 9 byte buffer overflow while reading extended data
The driver would correctly calculate the amount of extra space needed to
receive the whole packet. It would also request the correct number of
bytes for this transfer.

However, the reallocated buffer to hold this data was directly derived
from the expected payload size and did not include the overhead.

Make the code more explicit and get rid of the confusing
MAX_DATA_IN_READ_BUF define that hides details on buffer allocation
calculation from the code.
2020-06-05 14:48:57 +00:00
Benjamin Berg b3565b83e1 upekts: Only release USB interface on exit
The device is already beeing de-initialised from the verify/enroll
commands. Trying it again will result in a timeout error as it is not
responding properly at that point.
2020-06-05 14:48:57 +00:00
Benjamin Berg 8f46de0a60 upekts: Fix reference counting in do_enroll_stop
The print passed to do_enroll_stop does not need to be ref'ed in the
function.
2020-06-05 14:48:57 +00:00
Benjamin Berg b3c5fe4b82 upekts: Fix ownership transfer to fpi_device_enroll_complete
fpi_device_enroll_complete takes the ownership of the pointers. As such,
they need to be stolen from EnrollStopData.
2020-06-05 14:48:57 +00:00
Vasily Khoruzhick 4cf5f92a52 lib: re-add partial image flag
And activate perimeter points removal if this flag is set

This flag should be set for aes1610, aesx660, aes2501, aes2550
and upektc_img since these sensors may produce incomplete image.

Fixes: #142
2020-06-04 09:34:31 -07:00
Vasily Khoruzhick 297236b51a nbis: re-add step to remove perimeter points
This step helps to drop false minutiae for short sensors and
it was accidentally dropped during NBIS update. Re-add this step
and add a patch to update script to ensure that it's not dropped
during next update.

Fixes: 9fb789dc78 ("nbis: Update to NBIS 5.0.0")
2020-06-03 20:44:41 -07:00
Benjamin Berg e4f9935706 Uncrustify with newer version 2020-06-02 11:56:19 +00:00
Evgeny Gagauz 1b74813adf vfs0050: Stop capture after a timeout happens
If a transfer errors out then actual_length is negative. The only error
that is not caught is a timeout error, which should also result in the
SSM to move to the next state.
2020-05-13 09:51:23 +00:00
Benjamin Berg 07ff03970f libfprint: Fix a few issues with the documentation
This must have been broken all along. Get it into a better shape. Looks
like mostly cases of bad copy/paste.
2020-05-11 20:51:29 +02:00
Benjamin Berg a464f602ca nbis: Apply patch to fix scan-build warnings
Apply the newly added patch to the checkout.
2020-05-07 14:22:02 +00:00
Benjamin Berg ad17011e68 nbis: Add patch to fix warnings reported by scan-build
This patch basically only adds annotations. None of the errors can be
hit in practice.
2020-05-07 14:22:02 +00:00
Benjamin Berg 744a71ce08 vfs301: Assert hex string has 2 or more characters
Otherwise static analysis thinks we may end up allocating a 0 byte
output buffer.
2020-05-07 14:22:02 +00:00
Benjamin Berg 6e30a1ee45 print: Fix "possible leak" warning by moving initialization
For some reason static checkers report that the auto-free is not run if
the goto exists the loop. It seems to me like that should work fine, but
we can simply make the analysers happy by moving it.
2020-05-07 14:22:02 +00:00
Benjamin Berg 87c3b9c5ba upekts: Fix possible NULL pointer access
Reported by scan-build.
2020-05-07 14:22:02 +00:00
Benjamin Berg 9db89e00d0 elan: Downgrade g_message to debug severity
See: #211
2020-05-07 13:55:35 +00:00
Benjamin Berg 3ad65b9589 vfs5011: Prevent too small images
We need more than 1 line for assembling, but in general, we should
have a reasonable amount of lines. So use the width in the hope we'll
get an image that is about square at least.

Closes: #135
2020-05-07 13:55:35 +00:00
Benjamin Berg 48aa6d0252 upekts: Fix regression during initialisation
The driver has two helper functions to format a command. In one case,
the function was accidentally changed during the port to the new driver
APIs.

See https://bugzilla.redhat.com/show_bug.cgi?id=1832229
2020-05-07 09:55:13 +02:00
Michal Prívozník eefc954f91 context: Fix order of PID/VID in a debug message
When no driver is found for an USB device a debug message is
printed. However, it has PID and VID in wrong order - usually it
is Vendor ID which goes first. This is how 'lsusb' prints it.
Matching the order helps debugging.

Signed-off-by: Michal Privoznik <michal@privoznik.com>
2020-04-27 16:16:43 +02:00
Michal Prívozník 5bcf9ac008 print: Include "fpi-compact.h"
In the fpi_print_fill_from_user_id() GDate is defined using
g_autoptr(). However, this requires new enough GLib. For older
versions there's a definition provided locally in fpi-compact.h.
Include the file to fix build with older version of GLib.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 16:16:39 +02:00
Marco Trevisan (Treviño) bc3f622b2a context: Factorize duplicated code 2020-04-24 20:21:01 +02:00
Marco Trevisan (Treviño) 5de49b33e6 image-device: Terminate the current action with error on print failure
If we fail when setting the scanned image to a print, we'll have a fatal
error, in such case we can terminate the current action and deactivate the
device.
2020-04-24 20:09:56 +02:00
Marco Trevisan (Treviño) 81e198c034 image: Return an error if we got an empty or NULL minutiae array
In some cases nbim's get_minutiae returns no minutiae without providing an
error code, and if this happens we would crash in the task callback function
as we would try to deference the data->minutiae pointer.

Related to: #251
2020-04-24 20:09:56 +02:00
Marco Trevisan (Treviño) c0895a858d etes603: Return TOO_SHORT retry error for small images
If the image height is less than the sensor horizontal resolution, then
return a retry error rather than trying to submit the image for further
processing.

Related to: #251
2020-04-24 20:03:51 +02:00
Benjamin Berg 5d5995f201 image: Check for task success rather than just cancellation
The minutiae detection might fail and we must not copy any data at that
point. So check g_task_had_error to ensure that we only do so when the
task was successful.

Fixes: #251
2020-04-24 20:03:37 +02:00
Benjamin Berg f71045b743 synaptics: Use the FpPrint ID generation functionality
As the functionality is now part of the internal FpPrint API, it makes
sene to use it.
2020-04-20 16:43:52 +02:00
Benjamin Berg 0274d0783b print: Add helpers to generate a unique print ID containing metadata
It makes sense to include this functionality in the core library as more
than one driver will be using it soon.
2020-04-20 16:43:52 +02:00
Bastien Nocera 5c5a4f6907 upekts: Fix memory leak
Don't allocate a new finger print structure,
the fpi_device_get_enroll_data() just below will overwrite it.
2020-04-15 15:55:39 +02:00
Bastien Nocera 5b6f5c9aad synaptics: Don't pass always-NULL value
No need to pass "error" to this report function, it will always be NULL.
2020-04-15 15:55:39 +02:00
Bastien Nocera 579e01359b fp-print: Fix sign-compare warnings
libfprint/fp-print.c: In function ‘fp_print_equal’:
libfprint/fp-print.c:596:21: warning: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’} [-Wsign-compare]
  596 |       for (i = 0; i < self->prints->len; i++)
      |                     ^
libfprint/fp-print.c: In function ‘fp_print_serialize’:
libfprint/fp-print.c:667:21: warning: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’} [-Wsign-compare]
  667 |       for (i = 0; i < print->prints->len; i++)
      |                     ^
libfprint/fp-print.c: In function ‘fp_print_deserialize’:
libfprint/fp-print.c:823:21: warning: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘gsize’ {aka ‘long unsigned int’} [-Wsign-compare]
  823 |       for (i = 0; i < g_variant_n_children (prints); i++)
      |                     ^
2020-04-15 12:48:05 +02:00
Bastien Nocera cc887c1a37 libfprint: Fix typos 2020-04-14 13:51:02 +02:00
Bastien Nocera fdd2d6abf8 fprint-list: Fix typos in Copyright statements 2020-04-14 13:51:02 +02:00
Bastien Nocera a218a5efdd virtual-image: Fix typo 2020-04-14 13:51:01 +02:00
Bastien Nocera c6ae8e58a4 elan: Fix typo 2020-04-14 13:50:49 +02:00
Bastien Nocera 87c7894c28 synaptics: Fix typos 2020-04-14 13:47:48 +02:00
Laurent Bigonville 3d68cddfe7 Properly set the dependencies in the pkg-config file
The public API uses gio and gobject header, ensure that these are in the
list of Required pkg-config modules, otherwise they are added to
Required.private which is not OK.
2020-03-20 11:13:06 +00:00
Benjamin Berg 96fba323b9 meson: Fix linking issue of libfprint with newer gcc
It appears the order of linking is relevant in this case, change it to
fix some linking issues.

It may be that there are better solutions to this problem.
2020-03-20 12:05:14 +01:00
Bastien Nocera 90ccf9a0af vfs0050: Fix incorrect destructor for GError 2020-03-13 10:23:52 +01:00
Bastien Nocera 2581f1aa32 aes1610: Fix memory leak
Fix small memory leak when reading some data that's not going to be
processed.
2020-03-13 10:23:52 +01:00
Marco Trevisan (Treviño) 2ae8b74e60 meson: Add fpi-compat.h to the private headers 2020-02-27 06:03:21 +01:00
Marco Trevisan (Treviño) 355cae1bbd fp-device: Return error if trying to list a storage-less device
Devices with no storage don't allow listing prints, and if we try to do
that, we'd end up in trying to call a NULL function pointer, causing a crash

So always check if the device has storage before calling the list vfunc, and
if we fail, return an error.

Include an unit-test to verify this situation
2020-02-10 11:41:40 +01:00
Benjamin Berg e19a1a6550 meson: Create include directories in build tree
Without this we get warnings like the following:

  cc1: warning: .../_build/libfprint/nbis/libfprint-include: No such file or directory [-Wmissing-include-dirs]
2020-02-10 11:41:40 +01:00
Marco Trevisan (Treviño) 5faf8498d9 compat: Use new GDate autoptr and define if needed 2020-02-10 11:41:40 +01:00
Marco Trevisan (Treviño) cfbd5d27b7 comapt: Add FpDeviceClass compatibility autoptr and use it 2020-02-10 11:41:37 +01:00
Benjamin Berg 169ca1ba77 compat: Add compatibility defines for older GLib
We are already using a number of defines and autoptrs from newer GLib
releases. Add the appropriate compatibility defines rather than removing
the corresponding code.

Closes: #222
2020-02-10 11:40:40 +01:00
Marco Trevisan (Treviño) 2c9e252ca4 meson: Use versioned name for autosuspend udev rules
Given distros may have the previous value around, let's rename this too
2020-01-23 17:25:38 +01:00
Marco Trevisan (Treviño) 23fab3a20a Change SONAME and all the library paths to libfprint-2
To avoid conflicts with previous libfprint version and make sure that the
target version is the correct one (plus to allow parallel install in some
distros), let's use a versioned naming for the library keeping the abi
version in sync.

Fixes #223
2020-01-23 17:09:58 +01:00
Benjamin Berg 88461d53ec upekts: Fix use-after-free in an error condition
The callback function would continue processing even after having failed
the SSM already. This causes further invalid operations on the SSM.

This error was found using a coverity scan.
2020-01-21 14:19:33 +00:00
Marco Trevisan (Treviño) 3b47113122 synaptics: Immediately complete verification if finger removed
When quickly scanning a finger with the synaptic driver, it may wait forever
for finger removal even if this has already happened.

In fact we don't take care of the finger status when reporting the
verification.

To avoid this, add a function that delays the completion of the verification
until the finger removal if the finger is on sensor, otherwise it just
performs it.

Fixes #228
2020-01-20 18:24:16 +00:00
Marco Trevisan (Treviño) 7a7bec5a80 synaptics: Report a verify complete error on unexpected result
Also remove the unneeded verify report with match failure
2020-01-20 18:24:16 +00:00
Marco Trevisan (Treviño) 8be861b876 synaptics: Remove unneeded complete error/data parameters
Remove the never-used cmd_complete_data value and the repetition of
cmd_complete_error.

In fact now as per the fpi_device_verify_report() usage, we already pass
the match information to the device, such as the error and it will be
they will be used on completion if needed.

This allows to simplify cmd_ssm_done() as well.
2020-01-20 18:24:16 +00:00
Marco Trevisan (Treviño) 8893840ffa synaptics: Always report verify state early on non-match
In some cases we want to complete the verification after that the finger has
been removed, but we still need to promptly report the match state otherwise
fpi-device will complain about, and will eventually cause a match error
instead that reporting a non-match:

  synaptics: Finger is now on the sensor
  synaptics: Received message with 0 sequence number 0x91, ignoring!
  synaptics: interrupt transfer done
  synaptics: delaying match failure until after finger removal!
  synaptics: interrupt transfer done
  device: Driver reported successful verify complete but did not report the
          result earlier. Reporting error instead
  libfprint: Failed to verify print: An unspecified error occured!

Fixes #227
2020-01-20 18:24:16 +00:00
Marco Trevisan (Treviño) 4d6a7ec09d synaptics: Really check if a print is device database
Fix a typo causing the not-in-database print error to be fired, actually
checking the response result.
2020-01-20 18:24:16 +00:00
Marco Trevisan (Treviño) 027ac8d843 fpi-device: Only mark a device as closed if the operation succeeded
We may fail during the close phase, in such case the device should not be
marked as closed.
2020-01-17 19:03:33 +01:00
Marco Trevisan (Treviño) b3a4c2cf9a fpi-device: Improve logging and testing on report/complete 2020-01-17 19:03:33 +01:00
Marco Trevisan (Treviño) 0889ec20a8 fp-device: Remove confusing success parameter on FpMatchCb
This was added as alias to the error check, but given we're passing to the
callback both the error and the match itself, we can just avoid adding an
extra parameter that could be confusing (as may imply that the matching
happened).

Also clarify the documentation and ensure that the match value is properly
set in tests.
2020-01-16 20:24:42 +01:00
Benjamin Berg 05bc2e1c80 image-device: Avoid invalid state transition on cancellation
Fixes: #226
2020-01-15 14:57:51 +01:00
Benjamin Berg 54286c7603 image-device: Handle retry error propagation correctly
With the early reporting mechanism the retry error propagation needs to
be adjusted. Do the appropriate changes.
2020-01-13 17:58:41 +01:00
Benjamin Berg db14995c31 image-device: Set cancelling when errors are reported
Allow the AWAIT_FINGER_ON to deactivation state transition after errors
are reported.
2020-01-13 17:58:41 +01:00
Benjamin Berg 829fb9f873 device: Add early match reporting to sync API
This makes the sync/async APIs more similar again. It also simplifies
testing as otherwise we would need the async methods for some tests.
2020-01-13 14:37:39 +01:00
Benjamin Berg 4d5c34e11a 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.
2020-01-13 14:37:39 +01:00
Benjamin Berg 8292c449f7 device: Better define ownership passing for results
Some things were odd with regard to the ownership of passed objects. Try
to make things sane overall, in particular with the possible floating
FpPrint reference.
2020-01-13 13:45:05 +01:00
Benjamin Berg 3f3d4559b4 upekts: Remove unused argument from deinitsm_new 2020-01-09 10:45:54 +01:00
Benjamin Berg fcdf1a1ff1 device: Fix potential memory leak of progress_cb user data
The progress report user data free func was not assigned and therefore
never called. Add the missing assign, potentially fixing memory leaks
(mostly relevant for bindings).
2020-01-09 10:45:54 +01:00
Benjamin Berg c27a4faeca elan: Add umockdev based test
Unfortunately, the timeout handling cannot be simulated properly. This
also adds a workaround in the driver to not consider it a protocol error
if this happens.
2020-01-08 18:14:06 +01:00
Benjamin Berg 8992e559f8 image-device: Fix enroll continuation after retry error
Continuing an enroll was broken in case of a retry error. Explicitly add
code to wait for the finger to go OFF after a retry error, and ensure
that the enroll will continue once that has happened.
2020-01-08 18:14:06 +01:00
Benjamin Berg 6c6df626c8 image-device: Fix reading default values from the class
We cannot copy information from the class in the _init routine, instead,
this needs to be done in _constructed. Move the relevant code into a new
_constructed function to fix importing the bz3_threshold override from
drivers.

Fixes: #206
2020-01-08 18:14:06 +01:00
Benjamin Berg 0d604fa34e fpi-assembling: Fix offsets to be relative to the previous frame
The offset stored for a frame was not always relative to the previous
frame. This was the case for reverse movement, but for forwrad movement
the offset was the one to the next frame.

Make the offset handling consistent and alwasy store the offset to the
previous frame. Also update the frame assembling code to add the offset
before blitting the frame (i.e. making it relative to the previous frame
there too).

Note that fpi_assemble_lines already made the assumption that this was
the case as it forced the offset for the first frame to be zero. As
such, the code was inconsistent.

This could affect the AES drivers slightly as they use hardware reported
values which might not adhere to these assumptions.
2020-01-02 13:46:46 +01:00
Benjamin Berg d9bcf9b9cc fpi-assembling: Accept error of zero
Rather than discarding a zero error, check that the constraints are
sane. This way a perfect match is possible.
2020-01-02 13:46:46 +01:00
Marco Trevisan (Treviño) b8e558452a fp-print: Add FP_FINGER_IS_VALID
This is coming directly from fprintd, but being something generic is better
to have it insinde libfprint itself.
2019-12-19 14:20:00 +01:00
Marco Trevisan (Treviño) c5aedc9970 fp-print: Add aliases for First and Last finger in our order
We might want to iterate through the supported fingers values, to do that we
were hardcoding FP_FINGER_LEFT_THUMB and FP_FINGER_RIGHT_LITTLE as first and
last fingers.

Not that we'd ever get more fingers (unless some weird radiation would do
the job), but it's logically nicer to read than random hardcoded values.
2019-12-18 12:23:14 +00:00
Benjamin Berg 5b17eda011 Prefix internal properties/signals with fpi- and annotate them
We prefixed them with fp- which is not as obvious as fpi-. Also,
explicitly mark them as private and to be skipped in the GObject
Introspection annotatinos.

Warning: FPrint: (Signal)fp-image-device-state-changed: argument object: Unresolved type: 'FpiImageDeviceState'
2019-12-18 12:25:06 +01:00
Marco Trevisan (Treviño) bfc75de778 libfprint: Make sure we install fp-enums.h in the right folder
Since we were not explictly setting the install_dir, it was endind up in
$PREFIX/include by default, while we use our project name as subfolder.
2019-12-17 15:42:56 +01:00
Marco Trevisan (Treviño) f3f768e738 meson: Fix syntax for fpi_enums generation call 2019-12-17 15:42:32 +01:00
Marco Trevisan (Treviño) dbb26c5ade meson: Define enum dependency and ensure we generate them before using
Avoid setting the headers as sources everywhere, but instead use a dependency
to manage the headers creation in time
2019-12-17 14:38:20 +01:00
Marco Trevisan (Treviño) c8e1269f61 cleanup: Use FPI prefix for all the internal enum types 2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) 2158c5e2d1 cleanup: Use #pragma once everywhere
Remove legacy header guards, and use compiler newer features.
2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) 10945f8546 cleanup: Remove fp_internal.h and update drivers_api.h
Remove the uneeded internal API, as we can now include each header directly
if needed, while move the assembling stuff to the drivers API.
2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) 806ad10673 meson: Add fp-image-device to public headers 2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) 4562f9dae3 meson: Use soversion everywhere
Don't repeat the 2 version number hard-coding it, so we can easily track
updates
2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) c57defda92 meson: Use more meson's project_name()
Not that libfprint is long to write, but in case we'll ever change the
basename, we do it once.
2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) c806993cb9 meson: Don't install fpi-enums 2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) d255a91e97 meson: List deps in multiple lines, to have better diffs on changes 2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) 9ebb3fd231 meson: Parse all private headers
So we don't have to list each one in case we add new enums.
Also, as per previous commit we can reorder them alphabetically.
2019-12-17 14:38:19 +01:00
Marco Trevisan (Treviño) 68b5c5d98f fpi-ssm, fpi-usb-transfer: Use fwd-declarations to avoid headers dependencies
Don't make headers inclusions dependent on each others, given that FpiSsm
depends on FpiUsbTransfer and vice-versa, so fix the dependency cycle by
using forwarded declarations.
2019-12-17 14:38:19 +01:00
Benjamin Berg bfd68bbc01 meson: Add missing dependency on fp-enum.h for private library
The private library needs to indirectly include fp-enum.h. This
dependency was not listed anyway, resulting in a race condition during
the build process.
2019-12-16 11:42:51 +01:00
Benjamin Berg 9c806e60f4 elan: Do not leak converted frames
The elan driver converts frames into a different format. These frames
are only needed to assemable the image and should be free'ed afterwards.

Fixes: #213
2019-12-16 10:20:49 +00:00
Benjamin Berg 4948a85e97 synaptics: Use local variable rather than re-fetching usb device 2019-12-16 10:20:49 +00:00
Marco Trevisan (Treviño) 7e2db8e988 driver_ids.h: Remove the legacy ID file
This is not used anymore by drivers as they all use GType's, so remove it
and any (dead) reference to it.
2019-12-14 17:20:47 +01:00
Marco Trevisan (Treviño) 24d388f923 meson: Split single-line dependencies to reduce the diff on changes
Make it more readable and in case we add something else, it's easier to track
2019-12-14 17:20:47 +01:00
Marco Trevisan (Treviño) fe828d0bb2 fpi-ssm: Clear delayed actions for parent and child on subssm start
While timeout was already cleared for parent, we didn't properly delete the
cancellable.

Although we'd warn anyways when starting the SSM, is still better to clear
any delayed action also for the sub-SSM
2019-12-14 17:20:47 +01:00
Marco Trevisan (Treviño) cf5473a55c fpi-ssm: Make clear that the completed callback owns the error 2019-12-14 17:20:47 +01:00
Marco Trevisan (Treviño) 0471edbf10 fpi-ssm: Add debug message when a delayed state change is cancelled 2019-12-14 17:20:46 +01:00
Marco Trevisan (Treviño) 299a797423 fpi-ssm: Bug on wrong state passed to jump_to_state_delayed
While remove the checks that are already part of the common function
fpi_ssm_set_delayed_action_timeout().
2019-12-14 17:20:46 +01:00
Marco Trevisan (Treviño) c594863639 fpi-ssm: Define autoptr cleanup function 2019-12-14 17:20:46 +01:00
Marco Trevisan (Treviño) 3bb1840750 fpi-ssm: Use same argument names of header file
So we can mute a Gtk-doc parser warning
2019-12-14 17:20:46 +01:00
Marco Trevisan (Treviño) 98fa6efce3 fpi-device: Clarify ownership of parameters for progress call 2019-12-14 17:20:46 +01:00
Marco Trevisan (Treviño) c7b7f78273 fp-device: Call identify device class method on identification
Identify on device was broken because we were calling verify device method
on devices instead of the right one.

Thank you unit tests! :)
2019-12-14 17:20:46 +01:00
Marco Trevisan (Treviño) eeddd8c7bc fp-context, tools: Use auto-ptr to handle GTypeClass ownership
This also fixes a small leak we might have if reffing a type that was not a
virtual one.
2019-12-14 17:20:45 +01:00
Marco Trevisan (Treviño) 43a8c909bf fp-context: Use an env to define a whitelist of drivers to enable
This avoids that we pick unwanted drivers when running the tests in a
machine that has some supported device attached.
2019-12-14 17:20:45 +01:00
Marco Trevisan (Treviño) 09576e5209 fpi-context: Make fpi_get_driver_types to return an array
No need to create one all the times and the fill it with what we need.
2019-12-14 16:57:11 +01:00
Marco Trevisan (Treviño) 6f2b1f97da fprint: Move drivers to private internal library
This allows us to finally remove fpi_get_driver_types from the exported list
of symbols.
2019-12-12 19:03:57 +01:00
Marco Trevisan (Treviño) 5bed81025e meson: Use files to track the map file presence 2019-12-11 20:07:13 +01:00
Marco Trevisan (Treviño) d7100e41df fp-image, fp-print: Move private methods to own code units 2019-12-11 20:07:13 +01:00
Marco Trevisan (Treviño) ae7021e529 fp-image-device: Move fpi code into its own unit that can be compiled a part
In order to be able to test the private device code (used by drivers) we
need to have that split a part in a different .c file so that we can compile
it alone and link with it both the shared library and the test executables.

Redefine fp_image_device_get_instance_private for private usage, not to move
the private struct as part of FpDevice.
2019-12-11 20:07:12 +01:00
Marco Trevisan (Treviño) d9de941a47 fp-device: Move fpi code into its own unit that can be compiled a part
In order to be able to test the private device code (used by drivers) we
need to have that split a part in a different .c file so that we can compile
it alone and link with it both the shared library and the test executables.

Redefine fp_device_get_instance_private for private usage, not to move
the private struct as part of FpDevice.
2019-12-11 20:07:12 +01:00
Marco Trevisan (Treviño) 7114d97f25 libfprint: Introduce libfprint_private static library
Split the library into a private part with all the symbols that we can use
for unit-test all the fpi functions.
2019-12-10 20:19:55 +01:00
Marco Trevisan (Treviño) 92a5278a74 fp-device: Add a "open" property and method to check its state 2019-12-10 20:19:55 +01:00
Marco Trevisan (Treviño) ff0107fc0a fp-device: Use different pointers for device handlers
A Fp-device use an union to track the handle to the lower-level device, and
the value depends on the object type.

So in case of using a virtual device, the priv->usb_device location matches
the priv->virtual_env string location, and thus we'd end up unreffing a
string location as it was a GObject, while we'd leak the string.

To avoid such errors, instead of just checking the device type when we
finalize the device, let's just use different pointers to avoid other
possible clashes.
2019-12-10 19:20:21 +01:00
Vincent Huang 107fdfde32 synaptics: Fix problem after match is failed
This fixes the the problem that the sensor becomes unresponsive after
pressing the wrong fingerprint. We fix the problem by making sure that
the non-match report is delayed until the finger is removed. With this
we cannot run into the situation that the next match request fails
immediately as the finger is still present.

Fixes: #208
2019-12-10 09:38:54 +01:00
Benjamin Berg 6209b22e3b print: Fix match error propagation
The FPI_MATCH_ERROR constant was set to 0, however it is propagated to
the task completion using g_task_propagate_int. As g_task_propagate_int
will always return -1 on error, we either need to add an explicit -1
check or we just need to match the semantics.

Change the constant to -1, also rearange FP_MATCH_SUCCESS so that it
does not end up being 0.
2019-12-05 11:46:11 +00:00
Benjamin Berg 3e958ab7b4 virtual-image: Allow fine control over the finger state
Add commands to disable automatic finger reporting for images and to
send a specific finger report. This is useful to test more code paths
inside the image-device code.
2019-12-04 19:49:07 +00:00
Benjamin Berg a8a2a757ed virtual-image: Only print warnings for actual errors
No need to warn for lost connections (if we don't expect more data) or
cancellations.
2019-12-04 19:49:07 +00:00
Benjamin Berg 702255b182 image-device: Print warning for incorrect deactivation
Drivers may not handle deactivation properly when they are awaiting a
finger. This should be prevented by the internal FpImageDevice state
machine.
2019-12-04 19:49:07 +00:00
Marco Trevisan (Treviño) a64ac2296b vfs0051: Use named SSMs for usb async exchanges 2019-12-04 20:43:53 +01:00
Marco Trevisan (Treviño) a522e3fd6f fpi-ssm: Improve debugging of SSM using driver infos
Always mention the driver that is triggering it
2019-12-04 20:43:53 +01:00
Marco Trevisan (Treviño) 65828e0e56 fpi-ssm: Support named SSMs and use a fallback macro
Add fpi_ssm_new_full() that allows to pass a name to the state-machine
constructor, not to change all the drivers, provide a fpi_ssm_new() macro
that stringifies the nr_parameters value (usually an enum value) as the name
so that we can use it for better debugging.
2019-12-04 20:43:53 +01:00
Benjamin Berg 10c5bdade7 uru4000: Fix control transfer request type
During porting the request type was accidentally changed from VENDOR to
DEVICE. Change the type back to VENDOR.

See: #205
2019-12-04 18:00:02 +00:00
Benjamin Berg 8f21aa1b26 uru4000: Fix state change from IRQ handler
The IRQ handler will re-register itself automatically. However, if this
happens after the callback is called, then the check whether the IRQ
handler is running fails.

Re-start the IRQ handler before calling the callback. This way the state
changes happening from the callback will see the correct IRQ handler
registration state.

See: #205
2019-12-04 18:00:02 +00:00
Benjamin Berg 7b68344394 image-device: Prevent deactivation when waiting for finger
At the end of enroll, the image device would put the driver into the
AWAIT_FINGER_ON state and then deactivate the device afterwards. Doing
this adds additional complexity to drivers which would need to handle
both cancellation and normal deactivation from that state.

Only put the device into the AWAIT_FINGER_ON state when we know that
another enroll stage is needed. This avoids the critical state
transition simplifying the driver state machine.

Fixes: #203
Fixes: 689aff0232
2019-12-04 18:00:02 +00:00
Benjamin Berg dccb5b3ab2 elan: Fix internal state machine to ensure correct deactivation
During calibration, the internal state was stored as INACTIVE. This is
not true though, the device is actively running state machines.

Move the state update to the start of the operation, therefore ensuring
we don't deactivate without completing the SSM.

Note that this will prevent a crash, but the driver still does not
behave quite correctly when such a state change does happen. However,
this is just a safety measure as the state change should not happen in
the first place.

See: #203
2019-12-04 18:00:02 +00:00
Marco Trevisan (Treviño) b2e55308d6 meson: Move generated source to fpi- prefix and use more readable code
Instead of concatenating strings, use an array of strings and finally join
them using newline.
2019-12-04 18:52:20 +01:00
Marco Trevisan (Treviño) cacce50ef9 vfs0050: Use proper casting summing pointers first
Cast the pointers as what fpi usb transfer expects.
2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño) 5ab4d6c454 vfs5011: Cast gpointer data values to proper type to do math operations 2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño) 2b8c524928 cleanup: Use static functions for non-declared methods 2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño) 2f2ea65d32 fp-device: Remove unused timeout function and source data
These were probably added in previous iterations, but they are not uneeded
anymore as the GSource embeds already a callback function.

So make just this clearer in the dispatch function.
2019-12-04 18:52:18 +01:00
Marco Trevisan (Treviño) 35e9f19c0c nbis: Make the extern global bozworth 'y' variable as bz_y
Othewise this could create issues with other 'y' variable definitions
shadowing it.

Add a cocci file that performs the change automatically
2019-12-04 18:52:18 +01:00
Marco Trevisan (Treviño) 70a0d6f0fe nbis/log: Don't use old-style function declarations 2019-12-04 18:52:18 +01:00
Marco Trevisan (Treviño) 7ed9b0c2f9 cleanup: Don't make nbis depend on libfprint built-sources
Now that nbis is a static library it should be possible to compile it
without any fprint-built dependency, although since it included fp_internal
there was a compile-time dependency on the fp-enums that can be generated at
later times.

So:
 - Move nbis-helpers to nbis includes (and remove inclusion in fp_internal)
 - Move the Minutiae definitions inside a standalone fpi-minutiae header
 - Include fpi-minutiae.h in fp_internal.h
 - Include nbis-hepers.h and fpi-minutiae.h in nbis' lfs.h
 - Adapt missing definitions in libfprint
2019-12-04 18:50:46 +01:00
Marco Trevisan (Treviño) 6a090656b6 nbis: Add a global include file with all the definitions ignoring erros
The nbis headers are full of redundant declarations, we can't fix them all
now, so in the mean time let's use an header using pragma to ignore such
errors.

Add the error to nbis private include folder that should be used only by
headers of libfprint-nbis.
2019-12-04 18:44:39 +01:00
Marco Trevisan (Treviño) e1d181887f meson: Add the include directories to deps
So we don't have to repeat them everywhere.
2019-12-04 16:57:39 +01:00
Benjamin Berg e143f12e57 meson: Build nbis separately to allow changing flags
As nbis is an external source bundle, it does not necessarily make sense
to enable/fix all warnings to the extend we do for our own library code.

As such, separate the build process into multiple stages.
2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño) 7e70344b4a meson: Use add_project_arguments for common cflags
We were passing around the common cflags and setting them for each library
or executable, but this is just a repetition given we can just use
add_project_arguments for this.
2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño) 44af2173a8 fp-print: Clear the data not the description when setting the property 2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño) e7c7f368c9 drivers, examples: Don't use -Wno-pointer-sign and fix relative errors 2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño) a29586f398 fpi-usb: Use unsigned length for USB async transfers
Properly follow function signature using a temporary gsize variable address
to make the function use the same pointer type and avoid troubles at
deferencing it, while use automatic-casting to switch to signed one if
transfer succeeded.
2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño) 1e2f19ea3d fpi-ssm: Mark a fpi-ssm completed on delay 2019-12-03 18:28:48 +01:00
Marco Trevisan (Treviño) b0effae990 fpi-ssm: Bug on handler set to a NULL function
We would crash otherwise, while this is quite obvious there was no code
enforcing this.
2019-12-03 18:28:48 +01:00
Marco Trevisan (Treviño) ff67bf5a16 fpi-ssm: Make delayed actions cancellable
Add a GCancellable parameter to fpi_ssm_nex_state_delayed and
fpi_ssm_jump_to_state_delayed() so that it's possible to cancel an action
from the caller and in case the driver wants to cancel a delayed operation
when a device action has been cancelled.
2019-12-03 18:28:48 +01:00
Marco Trevisan (Treviño) bac6382f67 drivers: Use SSM delayed actions when possible 2019-12-03 17:31:22 +01:00
Marco Trevisan (Treviño) e12978f402 fpi-ssm: Clarify the ownership of error in fpi_ssm_mark_failed 2019-12-03 17:31:22 +01:00
Marco Trevisan (Treviño) 1ba95db379 drivers: Use fpi_ssm_next_state_delayed instead of custom callbacks
As per this fpi_ssm_next_state_timeout_cb can be removed
2019-12-03 17:31:22 +01:00
Marco Trevisan (Treviño) 7ec2df2405 fpi-ssm: Add possibility to jump to a state (or next one) with delay
This allows to have an automatic cleanup of the timeout source when the
the callback is reached and to avoid to do further state changes in the
middle.
2019-12-03 17:31:22 +01:00
Marco Trevisan (Treviño) 3ed73aa17c fpi-device: Make possible to set a DestroyNotify for timeout data
Since GSource data can be automatically cleaned up on source destruction, we
can mimic this for the devices timeout easily as well.

Add an extra parameter, and let's use this cocci file to adapt all the
drivers like magic:

	@@
	expression e1, e2, e3, e4;
	@@
	fpi_device_add_timeout (e1, e2, e3, e4
	+  , NULL
  	)
2019-12-03 17:31:22 +01:00
Marco Trevisan (Treviño) 0241617713 fpi-ssm: Also bug-on negative state value
Being an integer, anything could happen.
2019-12-03 17:31:22 +01:00
Marco Trevisan (Treviño) 20a52593eb vfs301: Use a transfer autopointer to cleanup it on sync submission
Partially revert commit a855c0cc7, since the driver uses a sync transfer
and in such case the caller still keeps the ownership.
2019-12-03 13:58:42 +00:00
Marco Trevisan (Treviño) 42db16364d synaptics: Close the usb device if reset failed
If reseting the device failed, we still need to close the usb device before
returning.
2019-12-03 13:58:42 +00:00
Marco Trevisan (Treviño) ee606ae49e synaptics: Use an autoptr to handle the FpiUsbTransfer sync transfers
When using fpi_usb_transfer_submit_sync we still need to unref the transfer
once done with it, so let's use an auto pointer so we free it also on
errors and early returns without having to handle this manually.
2019-12-03 13:58:42 +00:00
Benjamin Berg f9b2c7f9c3 virtual-image: Fix driver reading insufficient data
In rare occasions it could happen that the driver was reading
insufficient data. Fix this by using g_input_stream_read_all_async
which will ensure that incomplete data will not be misinterpreted.

This fixes rare test failures seen in fprintd.
2019-12-02 17:04:05 +01:00
Benjamin Berg 4115ae7ced Fix indentation issues using newer uncrustify
Seems like the older uncrustify versions did not find these indentation
issues. Fix them.

Old versions of uncrustify will leave things as is, so this is not a
problem if developers are using an old version of uncrustify.
2019-12-02 17:04:05 +01:00
Benjamin Berg 8cc0fd321f assembling: Use fixed point for image assembly
Using floating point causes architecture dependent results due to
accuracy/rounding differences. It is not hard to switch to fixed point,
and while this does cause quite different rounding errors, the
difference is small.

Fixes: #200
2019-11-28 20:41:45 +00:00
Marco Trevisan (Treviño) b9ff75c4e9 fp-print: Set the aligned_data as the data used by the cleanup function
g_variant_new_from_data() allows to destroy some other user_data passed as
parameter that might be different from the aligned_data itself.

But since in this case they match, pass it to be set as g_free parameter
or it won't be free'd.
2019-11-28 21:30:17 +01:00
Marco Trevisan (Treviño) db905a2048 fp-device: Use g_clear_error instead of check + free 2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) 712853d1e3 fp-device: Mark user data in FpEnrollProgress as transfer none
The data has its own DestroyNotify set, so while no generic DestroyNotify
exists for generic data, let's make it clear.
2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) c6298ede72 fp-device: Unref the print once we've notified the progress
When we notify the enroll progress with a print, this needs to be unreffed
once we're done, but this only was happening in case of error.

Since it's not up to the callback function to free it, let's do it at the
end of the function.

As per this, clarify the docs for FpEnrollProgress marking it as transfer
none.
2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) b1d99e7608 fp-device: Use an autopointer and steal the print when passed
Make it clearer that we're stealing the print when passing it away, instead
of just doing this silently.
2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) 5927a205e3 virtual-image: Also unref the object when closing a the stream
While a stream is closed when completely unreffed, the other way around
isn't true, so always unref the object.
2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) 8c05f3b78c fp-print: Unref print data and get static strings when deserializing 2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) 92db82e3d4 fp-print: Assert the prints aren't set when initialized 2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) f6f689f9cd fp-print: Unref the prints on finalize 2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) 5dc3edf07c fp-context: Run dispose on the usb context to deal with circular refs
Ensure that we dispose the USB context before unreffing it, so that it will
release any reference it has and destroy the internal libusb context.
2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) 71625ec1cf fp-device: Unref the usb device on finalize
Each device adds a ref to the underlying usb device, but it doesn't remove
the reference on finalization.

So clear the object to fix the leak
2019-11-27 21:40:44 +01:00
Marco Trevisan (Treviño) 9892eb1c03 fpi-ssm: Make clearer that data is unused in fpi_ssm_usb_transfer_cb 2019-11-27 21:02:20 +01:00
Marco Trevisan (Treviño) 587131a6bd drivers: Use more fpi_ssm_usb_transfer_cb when possible
Replace all the transfer callbacks where we just switch to the next state or
fail with fpi_ssm_usb_transfer_cb.
2019-11-27 21:02:20 +01:00
Marco Trevisan (Treviño) 65d0d5e3e0 fpi-ssm: Add a usb transfer callback with data as weak pointer
Allow to pass a double-pointer to be nullified as the transfer data in order
to mark it as NULL when the transfer is done.

This is useful if we're keeping the transfer around in order to check that
no one is currently running.
2019-11-27 21:02:19 +01:00
Marco Trevisan (Treviño) 2642fc6560 fpi-usb-transfer: Take ownership of the transfer when submitting it
When a transfer is completed, we automatically unref it since we can't
consider it valid anymore since this point.

Update the drivers not to free the transfer after submitting anymore.
2019-11-27 21:02:19 +01:00
Marco Trevisan (Treviño) a855c0cc79 fpi-ssm: Take ownership of the SSM when completing it
When a machine is completed, we automatically free it since we can't
consider it valid anymore since this point.

Update the drivers not to free the SSM on completion callback anymore.
2019-11-27 21:02:19 +01:00
Marco Trevisan (Treviño) 519b5acc91 synaptics: Initialize user_id autoptr to NULL 2019-11-27 18:54:21 +01:00
Marco Trevisan (Treviño) e812653acd synaptics: Use GDate getters to retrieve the DMY values
As per commit 201b5a961 we use g_date_copy() to copy the date, however the
GLib implementation is done assuming that the GDate getters are always used
as the copy function doesn't preserve the original format of the date
(whether is using julian days or dmy), and the synaptics driver access to
the dmy values directly, without using the getter that would recompute the
proper values.
Causing a read error of unset values.

So, to avoid this, just use the g_date_get_* getters to retrieve the day
month and year for for defining the print enroll id.
2019-11-27 18:54:21 +01:00
Marco Trevisan (Treviño) 1b23f0efe1 drivers: Use clearer messages using parameters 2019-11-26 12:18:57 +00:00
Marco Trevisan (Treviño) f6559ba8b1 fp-device: Support variadic arguments to error functions
Make possible to generate a formatted message when creating an error from
a device, without having save it first.
2019-11-26 12:18:57 +00:00
Marco Trevisan (Treviño) 15d218a112 fpi-log: Set fp_error as equal to g_critical 2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) 0a08a24896 fpi-ssm: Remove any reference to fpi_timeout_add()
This doesn't exist anymore, while fpi_device_add_timeout does exists.
2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) cca6d3b04b fp-image-device: Use a GObject signal to notify image state changed
This is more GObject-friendly and we have the automatic call of the vfunc if
one is set.
2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) be367988ae fp-image-device: Add private "fp-image-device-state" property
In this way drivers may get this without having to keep a copy of it
2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) ea4da08af0 fp-image-device: Reactivate in idle on deactivation completed
This is the same logic we apply to fp-device by default: any completed
action should trigger the subsequent one when it is finished.
So in case we want reactivate after a deactivation, let's do it in an idle,
after removing the current pending timeout.
2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) 60ad1ab9e3 fp-image-device: Clear the pending activation timeout on finalize 2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) 201b5a9614 fp-print: Use g_date_copy
As per previous commit we depend on glib 2.56, we can use this utility
function as well.
2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) 8b270141f3 image-device: Use g_clear_handle_id for timeouts
As per this depend on glib 2.56: it has been released almost 2 years ago,
I suppose we're fine with that.
2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) 099fa9f005 meson: Use preferred syntax everywhere
Meson files are normally using 4-spaces to indent and functions use first
parameter on the same line while others at next indentation level, not
following the parenthesis indentation.

So adapt libfprint to follow the meson standard.
2019-11-25 18:59:46 +01:00
Marco Trevisan (Treviño) d8efa336e5 fpi-ssm, fp-device: Add missing copyright 2019-11-25 18:59:46 +01:00
Benjamin Berg 9b48864c5b print: Ensure xyt struct is not leaked during deserialization
In the unlikely event of an error, the variable may have been leaked.
Fix this by using g_autoptr combined with a g_steal_pointer.
2019-11-25 18:46:14 +01:00
Benjamin Berg 14a41bdd48 print: Free temporary col variable
The variable was leaked during serialization. Free it.
2019-11-25 18:46:14 +01:00
Benjamin Berg 25bc89a4f5 image-device: Remove unused fpi_device_get_current_action call
There is a later call in the function which is sufficient. Simply remove
the first call.
2019-11-25 18:46:14 +01:00
Benjamin Berg 2f0824ab88 upeksonly: Add default clauses to switch statements
This effectively only annotates the code to make it clear that variables
set in the switch are always initialized.
2019-11-25 18:46:14 +01:00
Benjamin Berg 8ba6f4dad2 synaptics: Add an explicit assert on the response
The response must be non-NULL in the function. Add an explicit assert to
appease to static code analysis tools.
2019-11-25 18:46:14 +01:00