From e1762474ce2c297448d070161d53e3b13d15f6e8 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 23 Mar 2019 18:04:55 +0000 Subject: [PATCH] Do not schedule an update on battery power if it requires AC power This stops us scheduling an update that has FWUPD_DEVICE_FLAG_REQUIRE_AC when on battery power, as we don't show messages when in the offline updates mode. Of course, we still check for AC when we reboot, but the common case is where we reboot into the offline mode just after we schedule the update without changing the hardware configuration. --- src/fu-engine.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fu-engine.c b/src/fu-engine.c index 188be5cac..78eb0da9f 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -1467,10 +1467,17 @@ fu_engine_install (FuEngine *self, return FALSE; } - /* schedule this for the next reboot if not in system-update.target */ + /* schedule this for the next reboot if not in system-update.target, + * but first check if allowed on battery power */ if ((self->app_flags & FU_APP_FLAGS_IS_OFFLINE) == 0 && - (flags & FWUPD_INSTALL_FLAG_OFFLINE) > 0) + (flags & FWUPD_INSTALL_FLAG_OFFLINE) > 0) { + plugin = fu_plugin_list_find_by_name (self->plugin_list, "upower", NULL); + if (plugin != NULL) { + if (!fu_plugin_runner_update_prepare (plugin, flags, device, error)) + return FALSE; + } return fu_plugin_runner_schedule_update (plugin, device, blob_cab, error); + } /* install firmware blob */ version_orig = g_strdup (fu_device_get_version (device));