]> git.proxmox.com Git - fwupd.git/commitdiff
Use a heuristic to set ignore-system-power for all Lenovo batteries
authorRichard Hughes <richard@hughsie.com>
Thu, 16 Feb 2023 14:10:39 +0000 (14:10 +0000)
committerRichard Hughes <richard@hughsie.com>
Fri, 17 Feb 2023 14:00:43 +0000 (14:00 +0000)
src/fu-engine.c

index 534c9608721a760da31105300981ac85ed389ba8..b57b573de2a922409ce598d7e569130908cea392 100644 (file)
@@ -4512,6 +4512,23 @@ fu_engine_md_refresh_device_name_category(FuEngine *self, FuDevice *device, XbNo
                fu_device_remove_internal_flag(device,
                                               FU_DEVICE_INTERNAL_FLAG_MD_SET_NAME_CATEGORY);
        }
+
+       /* batteries updated using capsules should ignore the system power restriction */
+       if (g_strcmp0(fu_device_get_plugin(device), "uefi_capsule") == 0) {
+               gboolean is_battery = FALSE;
+               for (guint i = 0; i < cats->len; i++) {
+                       XbNode *n = g_ptr_array_index(cats, i);
+                       if (g_strcmp0(xb_node_get_text(n), "X-Battery") == 0) {
+                               is_battery = TRUE;
+                               break;
+                       }
+               }
+               if (is_battery) {
+                       g_debug("ignoring system power for %s battery", fu_device_get_id(device));
+                       fu_device_add_internal_flag(device,
+                                                   FU_DEVICE_INTERNAL_FLAG_IGNORE_SYSTEM_POWER);
+               }
+       }
 }
 
 static void