trivial: Add fu_device_has_problem() to be consistent and hide details

This commit is contained in:
Richard Hughes 2023-01-26 11:14:35 +00:00
parent 354122e83c
commit f3f951d3a7
4 changed files with 23 additions and 1 deletions

View File

@ -3069,6 +3069,25 @@ fu_device_remove_problem(FuDevice *self, FwupdDeviceProblem problem)
return fu_device_uninhibit(self, fwupd_device_problem_to_string(problem)); return fu_device_uninhibit(self, fwupd_device_problem_to_string(problem));
} }
/**
* fu_device_has_problem:
* @self: a #FuDevice
* @problem: a #FwupdDeviceProblem, e.g. %FWUPD_DEVICE_PROBLEM_SYSTEM_POWER_TOO_LOW
*
* Query if a device has a specific problem.
*
* Returns: %TRUE if the device has this problem
*
* Since: 1.8.11
**/
gboolean
fu_device_has_problem(FuDevice *self, FwupdDeviceProblem problem)
{
g_return_val_if_fail(FU_IS_DEVICE(self), FALSE);
g_return_val_if_fail(problem != FWUPD_DEVICE_PROBLEM_UNKNOWN, FALSE);
return fu_device_has_inhibit(self, fwupd_device_problem_to_string(problem));
}
/** /**
* fu_device_add_problem: * fu_device_add_problem:
* @self: a #FuDevice * @self: a #FuDevice

View File

@ -562,6 +562,8 @@ fu_device_add_problem(FuDevice *self, FwupdDeviceProblem problem);
void void
fu_device_remove_problem(FuDevice *self, FwupdDeviceProblem problem); fu_device_remove_problem(FuDevice *self, FwupdDeviceProblem problem);
gboolean gboolean
fu_device_has_problem(FuDevice *self, FwupdDeviceProblem problem);
gboolean
fu_device_has_inhibit(FuDevice *self, const gchar *inhibit_id); fu_device_has_inhibit(FuDevice *self, const gchar *inhibit_id);
const gchar * const gchar *
fu_device_get_physical_id(FuDevice *self); fu_device_get_physical_id(FuDevice *self);

View File

@ -1165,6 +1165,7 @@ LIBFWUPDPLUGIN_1.8.10 {
LIBFWUPDPLUGIN_1.8.11 { LIBFWUPDPLUGIN_1.8.11 {
global: global:
fu_device_has_problem;
fu_device_remove_backend_tag; fu_device_remove_backend_tag;
local: *; local: *;
} LIBFWUPDPLUGIN_1.8.10; } LIBFWUPDPLUGIN_1.8.10;

View File

@ -609,7 +609,7 @@ fu_device_list_clear_wait_for_replug(FuDeviceList *self, FuDeviceItem *item)
static void static void
fu_device_incorporate_problem_update_in_progress(FuDevice *self, FuDevice *donor) fu_device_incorporate_problem_update_in_progress(FuDevice *self, FuDevice *donor)
{ {
if (fu_device_has_inhibit(donor, "update-in-progress")) { if (fu_device_has_problem(donor, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS)) {
g_debug("moving inhibit update-in-progress to active device"); g_debug("moving inhibit update-in-progress to active device");
fu_device_add_problem(self, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS); fu_device_add_problem(self, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS);
fu_device_remove_problem(donor, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS); fu_device_remove_problem(donor, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS);