device: Check for device overheating and abort when needed
Check if a device is too hot. If it is too hot already, refuse operation. If it becomes too hot while an operation is ongoing, then cancel the action and force a FP_DEVICE_ERROR_TOO_HOT return value.
This commit is contained in:
parent
da28731adc
commit
5b7c5e7c09
2 changed files with 39 additions and 0 deletions
|
@ -986,6 +986,12 @@ fp_device_enroll (FpDevice *device,
|
||||||
setup_task_cancellable (device);
|
setup_task_cancellable (device);
|
||||||
|
|
||||||
fpi_device_update_temp (device, TRUE);
|
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 = g_new0 (FpEnrollData, 1);
|
||||||
data->print = g_object_ref_sink (template_print);
|
data->print = g_object_ref_sink (template_print);
|
||||||
|
@ -1081,6 +1087,12 @@ fp_device_verify (FpDevice *device,
|
||||||
setup_task_cancellable (device);
|
setup_task_cancellable (device);
|
||||||
|
|
||||||
fpi_device_update_temp (device, TRUE);
|
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 = g_new0 (FpMatchData, 1);
|
||||||
data->enrolled_print = g_object_ref (enrolled_print);
|
data->enrolled_print = g_object_ref (enrolled_print);
|
||||||
|
@ -1202,6 +1214,12 @@ fp_device_identify (FpDevice *device,
|
||||||
setup_task_cancellable (device);
|
setup_task_cancellable (device);
|
||||||
|
|
||||||
fpi_device_update_temp (device, TRUE);
|
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 = g_new0 (FpMatchData, 1);
|
||||||
/* We cannot store the gallery directly, because the ptr array may not own
|
/* 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);
|
setup_task_cancellable (device);
|
||||||
|
|
||||||
fpi_device_update_temp (device, TRUE);
|
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;
|
priv->wait_for_finger = wait_for_finger;
|
||||||
|
|
||||||
|
|
|
@ -1806,6 +1806,21 @@ fpi_device_update_temp (FpDevice *device, gboolean is_active)
|
||||||
if (priv->temp_current != old_temp)
|
if (priv->temp_current != old_temp)
|
||||||
g_object_notify (G_OBJECT (device), "temperature");
|
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);
|
g_clear_pointer (&priv->temp_timeout, g_source_destroy);
|
||||||
|
|
||||||
if (next_threshold < 0)
|
if (next_threshold < 0)
|
||||||
|
|
Loading…
Reference in a new issue