diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c index 99399c6..8d508d3 100644 --- a/libfprint/fp-device.c +++ b/libfprint/fp-device.c @@ -986,6 +986,12 @@ fp_device_enroll (FpDevice *device, setup_task_cancellable (device); fpi_device_update_temp (device, TRUE); + if (priv->temp_current == FP_TEMPERATURE_HOT) + { + g_task_return_error (task, fpi_device_error_new (FP_DEVICE_ERROR_TOO_HOT)); + fpi_device_update_temp (device, FALSE); + return; + } data = g_new0 (FpEnrollData, 1); data->print = g_object_ref_sink (template_print); @@ -1081,6 +1087,12 @@ fp_device_verify (FpDevice *device, setup_task_cancellable (device); fpi_device_update_temp (device, TRUE); + if (priv->temp_current == FP_TEMPERATURE_HOT) + { + g_task_return_error (task, fpi_device_error_new (FP_DEVICE_ERROR_TOO_HOT)); + fpi_device_update_temp (device, FALSE); + return; + } data = g_new0 (FpMatchData, 1); data->enrolled_print = g_object_ref (enrolled_print); @@ -1202,6 +1214,12 @@ fp_device_identify (FpDevice *device, setup_task_cancellable (device); fpi_device_update_temp (device, TRUE); + if (priv->temp_current == FP_TEMPERATURE_HOT) + { + g_task_return_error (task, fpi_device_error_new (FP_DEVICE_ERROR_TOO_HOT)); + fpi_device_update_temp (device, FALSE); + return; + } data = g_new0 (FpMatchData, 1); /* We cannot store the gallery directly, because the ptr array may not own @@ -1321,6 +1339,12 @@ fp_device_capture (FpDevice *device, setup_task_cancellable (device); fpi_device_update_temp (device, TRUE); + if (priv->temp_current == FP_TEMPERATURE_HOT) + { + g_task_return_error (task, fpi_device_error_new (FP_DEVICE_ERROR_TOO_HOT)); + fpi_device_update_temp (device, FALSE); + return; + } priv->wait_for_finger = wait_for_finger; diff --git a/libfprint/fpi-device.c b/libfprint/fpi-device.c index 5704622..cfbd167 100644 --- a/libfprint/fpi-device.c +++ b/libfprint/fpi-device.c @@ -1806,6 +1806,21 @@ fpi_device_update_temp (FpDevice *device, gboolean is_active) if (priv->temp_current != old_temp) g_object_notify (G_OBJECT (device), "temperature"); + /* If the device is HOT, then do an internal cancellation of long running tasks. */ + if (priv->temp_current == FP_TEMPERATURE_HOT) + { + if (priv->current_action == FPI_DEVICE_ACTION_ENROLL || + priv->current_action == FPI_DEVICE_ACTION_VERIFY || + priv->current_action == FPI_DEVICE_ACTION_IDENTIFY || + priv->current_action == FPI_DEVICE_ACTION_CAPTURE) + { + if (!priv->current_cancellation_reason) + priv->current_cancellation_reason = fpi_device_error_new (FP_DEVICE_ERROR_TOO_HOT); + + g_cancellable_cancel (priv->current_cancellable); + } + } + g_clear_pointer (&priv->temp_timeout, g_source_destroy); if (next_threshold < 0)