backport a patch to fix activatable devices getting stuck in an update loop
Mario Limonciello
3 years ago
0 | From 3df7dd370888b49670e374f8c213f35430ad7b42 Mon Sep 17 00:00:00 2001 | |
1 | From: Mario Limonciello <mario.limonciello@dell.com> | |
2 | Date: Tue, 2 Mar 2021 19:53:31 -0600 | |
3 | Subject: [PATCH] libfwupdplugin: don't allow device updates while needing | |
4 | activation | |
5 | ||
6 | --- | |
7 | libfwupdplugin/fu-device.c | 7 +++++++ | |
8 | libfwupdplugin/fu-plugin.c | 6 ++++++ | |
9 | 2 files changed, 13 insertions(+) | |
10 | ||
11 | diff --git a/libfwupdplugin/fu-device.c b/libfwupdplugin/fu-device.c | |
12 | index 112246c0..c8a28246 100644 | |
13 | --- a/libfwupdplugin/fu-device.c | |
14 | +++ b/libfwupdplugin/fu-device.c | |
15 | @@ -2270,6 +2270,13 @@ fu_device_add_flag (FuDevice *self, FwupdDeviceFlags flag) | |
16 | if (flag & FWUPD_DEVICE_FLAG_INSTALL_ALL_RELEASES) | |
17 | flag |= FWUPD_DEVICE_FLAG_VERSION_CHECK_REQUIRED; | |
18 | fwupd_device_add_flag (FWUPD_DEVICE (self), flag); | |
19 | + | |
20 | + /* activatable devices shouldn't be allowed to update again until activated */ | |
21 | + /* don't let devices be updated until activated */ | |
22 | + if (flag & FWUPD_DEVICE_FLAG_NEEDS_ACTIVATION) { | |
23 | + fwupd_device_remove_flag (FWUPD_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); | |
24 | + fwupd_device_add_flag (FWUPD_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE_HIDDEN); | |
25 | + } | |
26 | } | |
27 | ||
28 | static void | |
29 | diff --git a/libfwupdplugin/fu-plugin.c b/libfwupdplugin/fu-plugin.c | |
30 | index 919a2996..3327de8c 100644 | |
31 | --- a/libfwupdplugin/fu-plugin.c | |
32 | +++ b/libfwupdplugin/fu-plugin.c | |
33 | @@ -2312,6 +2312,12 @@ fu_plugin_runner_activate (FuPlugin *self, FuDevice *device, GError **error) | |
34 | ||
35 | /* update with correct flags */ | |
36 | fu_device_remove_flag (device, FWUPD_DEVICE_FLAG_NEEDS_ACTIVATION); | |
37 | + | |
38 | + /* allow it to be updatable again */ | |
39 | + if (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE_HIDDEN)) { | |
40 | + fu_device_remove_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE_HIDDEN); | |
41 | + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE); | |
42 | + } | |
43 | fu_device_set_modified (device, (guint64) g_get_real_time () / G_USEC_PER_SEC); | |
44 | return TRUE; | |
45 | } | |
46 | -- | |
47 | 2.25.1 | |
48 |