mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-27 11:09:28 +00:00
Add a device problem for 'update-in-progress'
We already had this as an inhibit, but this was not translated client-side. We also need to propagate the problem to the bootloader device if the device replugs during firmware update.
This commit is contained in:
parent
3d56ac8a90
commit
5da8e1c760
@ -368,6 +368,8 @@ fwupd_device_problem_to_string(FwupdDeviceProblem device_problem)
|
|||||||
return "missing-license";
|
return "missing-license";
|
||||||
if (device_problem == FWUPD_DEVICE_PROBLEM_SYSTEM_INHIBIT)
|
if (device_problem == FWUPD_DEVICE_PROBLEM_SYSTEM_INHIBIT)
|
||||||
return "system-inhibit";
|
return "system-inhibit";
|
||||||
|
if (device_problem == FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS)
|
||||||
|
return "update-in-process";
|
||||||
if (device_problem == FWUPD_DEVICE_PROBLEM_UNKNOWN)
|
if (device_problem == FWUPD_DEVICE_PROBLEM_UNKNOWN)
|
||||||
return "unknown";
|
return "unknown";
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -406,6 +408,8 @@ fwupd_device_problem_from_string(const gchar *device_problem)
|
|||||||
return FWUPD_DEVICE_PROBLEM_MISSING_LICENSE;
|
return FWUPD_DEVICE_PROBLEM_MISSING_LICENSE;
|
||||||
if (g_strcmp0(device_problem, "system-inhibit") == 0)
|
if (g_strcmp0(device_problem, "system-inhibit") == 0)
|
||||||
return FWUPD_DEVICE_PROBLEM_SYSTEM_INHIBIT;
|
return FWUPD_DEVICE_PROBLEM_SYSTEM_INHIBIT;
|
||||||
|
if (g_strcmp0(device_problem, "update-in-process") == 0)
|
||||||
|
return FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS;
|
||||||
return FWUPD_DEVICE_PROBLEM_UNKNOWN;
|
return FWUPD_DEVICE_PROBLEM_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,6 +631,14 @@ typedef guint64 FwupdDeviceFlags;
|
|||||||
* Since 1.8.10
|
* Since 1.8.10
|
||||||
*/
|
*/
|
||||||
#define FWUPD_DEVICE_PROBLEM_SYSTEM_INHIBIT (1llu << 8)
|
#define FWUPD_DEVICE_PROBLEM_SYSTEM_INHIBIT (1llu << 8)
|
||||||
|
/**
|
||||||
|
* FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS:
|
||||||
|
*
|
||||||
|
* The device cannot be updated as it is already being updated.
|
||||||
|
*
|
||||||
|
* Since 1.8.11
|
||||||
|
*/
|
||||||
|
#define FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS (1llu << 9)
|
||||||
/**
|
/**
|
||||||
* FWUPD_DEVICE_PROBLEM_UNKNOWN:
|
* FWUPD_DEVICE_PROBLEM_UNKNOWN:
|
||||||
*
|
*
|
||||||
|
@ -164,7 +164,7 @@ fwupd_enums_func(void)
|
|||||||
g_assert_cmpstr(tmp, !=, NULL);
|
g_assert_cmpstr(tmp, !=, NULL);
|
||||||
g_assert_cmpint(fwupd_device_flag_from_string(tmp), ==, i);
|
g_assert_cmpint(fwupd_device_flag_from_string(tmp), ==, i);
|
||||||
}
|
}
|
||||||
for (guint64 i = 1; i <= FWUPD_DEVICE_PROBLEM_SYSTEM_INHIBIT; i *= 2) {
|
for (guint64 i = 1; i <= FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS; i *= 2) {
|
||||||
const gchar *tmp = fwupd_device_problem_to_string(i);
|
const gchar *tmp = fwupd_device_problem_to_string(i);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
g_warning("missing device problem 0x%x", (guint)i);
|
g_warning("missing device problem 0x%x", (guint)i);
|
||||||
|
@ -2926,6 +2926,8 @@ fu_device_problem_to_inhibit_reason(FuDevice *self, guint64 device_problem)
|
|||||||
return g_strdup("Device cannot be used while the lid is closed");
|
return g_strdup("Device cannot be used while the lid is closed");
|
||||||
if (device_problem == FWUPD_DEVICE_PROBLEM_IS_EMULATED)
|
if (device_problem == FWUPD_DEVICE_PROBLEM_IS_EMULATED)
|
||||||
return g_strdup("Device is emulated");
|
return g_strdup("Device is emulated");
|
||||||
|
if (device_problem == FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS)
|
||||||
|
return g_strdup("An update is in progress");
|
||||||
if (device_problem == FWUPD_DEVICE_PROBLEM_MISSING_LICENSE)
|
if (device_problem == FWUPD_DEVICE_PROBLEM_MISSING_LICENSE)
|
||||||
return g_strdup("Device does not have the necessary license installed");
|
return g_strdup("Device does not have the necessary license installed");
|
||||||
if (device_problem == FWUPD_DEVICE_PROBLEM_SYSTEM_POWER_TOO_LOW) {
|
if (device_problem == FWUPD_DEVICE_PROBLEM_SYSTEM_POWER_TOO_LOW) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "fu-device-list.h"
|
#include "fu-device-list.h"
|
||||||
#include "fu-device-private.h"
|
#include "fu-device-private.h"
|
||||||
|
#include "fu-engine.h"
|
||||||
#include "fu-mutex.h"
|
#include "fu-mutex.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -605,6 +606,16 @@ fu_device_list_clear_wait_for_replug(FuDeviceList *self, FuDeviceItem *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fu_device_incorporate_problem_update_in_progress(FuDevice *self, FuDevice *donor)
|
||||||
|
{
|
||||||
|
if (fu_device_has_inhibit(donor, "update-in-progress")) {
|
||||||
|
g_debug("moving inhibit update-in-progress to active device");
|
||||||
|
fu_device_add_problem(self, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS);
|
||||||
|
fu_device_remove_problem(donor, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fu_device_incorporate_update_state(FuDevice *self, FuDevice *donor)
|
fu_device_incorporate_update_state(FuDevice *self, FuDevice *donor)
|
||||||
{
|
{
|
||||||
@ -646,6 +657,9 @@ fu_device_list_replace(FuDeviceList *self, FuDeviceItem *item, FuDevice *device)
|
|||||||
fu_device_set_private_flags(device, private_flags);
|
fu_device_set_private_flags(device, private_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* copy inhibit */
|
||||||
|
fu_device_incorporate_problem_update_in_progress(item->device, device);
|
||||||
|
|
||||||
/* copy over the version strings if not set */
|
/* copy over the version strings if not set */
|
||||||
if (fu_device_get_version(item->device) != NULL && fu_device_get_version(device) == NULL) {
|
if (fu_device_get_version(item->device) != NULL && fu_device_get_version(device) == NULL) {
|
||||||
const gchar *version = fu_device_get_version(item->device);
|
const gchar *version = fu_device_get_version(item->device);
|
||||||
@ -744,6 +758,8 @@ fu_device_list_add(FuDeviceList *self, FuDevice *device)
|
|||||||
g_debug("found existing device %s", fu_device_get_id(device));
|
g_debug("found existing device %s", fu_device_get_id(device));
|
||||||
if (device != item->device) {
|
if (device != item->device) {
|
||||||
fu_device_uninhibit(item->device, "unconnected");
|
fu_device_uninhibit(item->device, "unconnected");
|
||||||
|
fu_device_incorporate_problem_update_in_progress(device,
|
||||||
|
item->device);
|
||||||
fu_device_incorporate_update_state(device, item->device);
|
fu_device_incorporate_update_state(device, item->device);
|
||||||
fu_device_list_item_set_device(item, device);
|
fu_device_list_item_set_device(item, device);
|
||||||
}
|
}
|
||||||
@ -757,6 +773,7 @@ fu_device_list_add(FuDeviceList *self, FuDevice *device)
|
|||||||
g_strcmp0(fu_device_get_id(device), fu_device_get_id(item->device_old)) == 0) {
|
g_strcmp0(fu_device_get_id(device), fu_device_get_id(item->device_old)) == 0) {
|
||||||
g_debug("found old device %s, swapping", fu_device_get_id(device));
|
g_debug("found old device %s, swapping", fu_device_get_id(device));
|
||||||
fu_device_uninhibit(item->device, "unconnected");
|
fu_device_uninhibit(item->device, "unconnected");
|
||||||
|
fu_device_incorporate_problem_update_in_progress(device, item->device);
|
||||||
fu_device_incorporate_update_state(device, item->device);
|
fu_device_incorporate_update_state(device, item->device);
|
||||||
g_set_object(&item->device_old, item->device);
|
g_set_object(&item->device_old, item->device);
|
||||||
fu_device_list_item_set_device(item, device);
|
fu_device_list_item_set_device(item, device);
|
||||||
|
@ -3138,7 +3138,7 @@ fu_engine_prepare(FuEngine *self,
|
|||||||
g_prefix_error(error, "failed to get device before update prepare: ");
|
g_prefix_error(error, "failed to get device before update prepare: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fu_device_inhibit(device, "update-in-progress", "An update is in progress");
|
fu_device_add_problem(device, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS);
|
||||||
|
|
||||||
if (!fu_engine_device_check_power(self, device, flags, error))
|
if (!fu_engine_device_check_power(self, device, flags, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3178,7 +3178,7 @@ fu_engine_cleanup(FuEngine *self,
|
|||||||
g_prefix_error(error, "failed to get device before update cleanup: ");
|
g_prefix_error(error, "failed to get device before update cleanup: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fu_device_uninhibit(device, "update-in-progress");
|
fu_device_remove_problem(device, FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS);
|
||||||
str = fu_device_to_string(device);
|
str = fu_device_to_string(device);
|
||||||
g_debug("cleanup -> %s", str);
|
g_debug("cleanup -> %s", str);
|
||||||
if (!fu_engine_device_cleanup(self, device, progress, flags, error))
|
if (!fu_engine_device_cleanup(self, device, progress, flags, error))
|
||||||
|
@ -1410,6 +1410,10 @@ fu_util_device_problem_to_string(FwupdClient *client, FwupdDevice *dev, FwupdDev
|
|||||||
/* TRANSLATORS: an application is preventing system updates */
|
/* TRANSLATORS: an application is preventing system updates */
|
||||||
return g_strdup(_("All devices are prevented from update by system inhibit"));
|
return g_strdup(_("All devices are prevented from update by system inhibit"));
|
||||||
}
|
}
|
||||||
|
if (problem == FWUPD_DEVICE_PROBLEM_UPDATE_IN_PROGRESS) {
|
||||||
|
/* TRANSLATORS: another application is updating the device already */
|
||||||
|
return g_strdup(_("An update is in progress"));
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user