Remove support for --ignore-power by frontends

This functionality broke a number of releases ago as part of
implementing device inhibition and was just noticed now.

Instead of fixing it, the preference seems to be to remove the
functionality as it exists today as inhibitions can happen for
a number of reasons.

To still allow people to override these power warnings (such as during
development) add a new daemon configuration item that can be used.

Fixes: #3778
This commit is contained in:
Mario Limonciello 2021-09-21 11:50:28 -05:00 committed by Mario Limonciello
parent 907a60573d
commit 6ebccf1e1e
11 changed files with 40 additions and 34 deletions

View File

@ -58,7 +58,6 @@ _fwupdmgr_opts=(
'--filter'
'--disable-ssl-strict'
'--ipfs'
'--ignore-power'
'--json'
)

View File

@ -58,7 +58,6 @@ _fwupdtool_opts=(
'--no-safety-check'
'--ignore-checksum'
'--ignore-vid-pid'
'--ignore-power'
)
_show_filters()

View File

@ -42,3 +42,7 @@ BlockedFirmware=
#
# If unset or no schemes are listed, the default will be: file,https,http,ipfs
UriSchemes=
# Ignore power levels of devices when running updates
IgnorePower=false

View File

@ -9,6 +9,7 @@
* Remove `fwupd_release_get_uri()` and `fwupd_release_set_uri()`
* Rename `fwupd_client_install_release2_async()` to `fwupd_client_install_release_async()`
* Remove fwupd_device_set_protocol() and fwupd_device_get_protocol()
* Remove deprecated install flag `FWUPD_INSTALL_FLAG_IGNORE_POWER`
## Migration from Version 0.9.x

View File

@ -743,6 +743,7 @@ typedef guint64 FwupdPluginFlags;
* @FWUPD_INSTALL_FLAG_IGNORE_CHECKSUM: Ignore firmware CRCs and checksums
* @FWUPD_INSTALL_FLAG_IGNORE_VID_PID: Ignore firmware vendor and project checks
* @FWUPD_INSTALL_FLAG_IGNORE_POWER: Ignore requirement of external power source
*(Deprecated since 1.7.0)
* @FWUPD_INSTALL_FLAG_NO_SEARCH: Do not use heuristics when parsing the image
*
* Flags to set when performing the firmware update or install.

View File

@ -34,6 +34,7 @@ struct _FuConfig {
gchar *config_file;
gboolean update_motd;
gboolean enumerate_all_devices;
gboolean ignore_power;
};
G_DEFINE_TYPE(FuConfig, fu_config, G_TYPE_OBJECT)
@ -58,6 +59,7 @@ fu_config_reload(FuConfig *self, GError **error)
g_autofree gchar *domains = NULL;
g_autoptr(GKeyFile) keyfile = g_key_file_new();
g_autoptr(GError) error_update_motd = NULL;
g_autoptr(GError) error_ignore_power = NULL;
g_autoptr(GError) error_enumerate_all = NULL;
if (g_file_test(self->config_file, G_FILE_TEST_EXISTS)) {
@ -184,6 +186,14 @@ fu_config_reload(FuConfig *self, GError **error)
self->enumerate_all_devices = TRUE;
}
/* whether to ignore power levels for updates */
self->ignore_power =
g_key_file_get_boolean(keyfile, "fwupd", "IgnorePower", &error_ignore_power);
if (!self->ignore_power && error_ignore_power != NULL) {
g_debug("failed to read IgnorePower key: %s", error_ignore_power->message);
self->ignore_power = FALSE;
}
return TRUE;
}
@ -306,6 +316,13 @@ fu_config_get_update_motd(FuConfig *self)
return self->update_motd;
}
gboolean
fu_config_get_ignore_power(FuConfig *self)
{
g_return_val_if_fail(FU_IS_CONFIG(self), FALSE);
return self->ignore_power;
}
gboolean
fu_config_get_enumerate_all_devices(FuConfig *self)
{

View File

@ -38,3 +38,5 @@ gboolean
fu_config_get_update_motd(FuConfig *self);
gboolean
fu_config_get_enumerate_all_devices(FuConfig *self);
gboolean
fu_config_get_ignore_power(FuConfig *self);

View File

@ -281,6 +281,9 @@ fu_engine_watch_device(FuEngine *self, FuDevice *device)
static void
fu_engine_ensure_device_battery_inhibit(FuEngine *self, FuDevice *device)
{
if (fu_config_get_ignore_power(self->config))
return;
if (fu_device_has_flag(device, FWUPD_DEVICE_FLAG_REQUIRE_AC) &&
(fu_context_get_battery_state(self->ctx) == FU_BATTERY_STATE_DISCHARGING ||
fu_context_get_battery_state(self->ctx) == FU_BATTERY_STATE_EMPTY)) {
@ -2811,7 +2814,15 @@ fu_engine_device_check_power(FuEngine *self,
FwupdInstallFlags flags,
GError **error)
{
if (flags & FWUPD_INSTALL_FLAG_IGNORE_POWER)
if (flags & FWUPD_INSTALL_FLAG_IGNORE_POWER) {
g_autofree gchar *configdir = fu_common_get_path(FU_PATH_KIND_SYSCONFDIR_PKG);
g_autofree gchar *configfile = g_build_filename(configdir, "daemon.conf", NULL);
g_warning("Ignoring deprecated flag provided by client "
"'FWUPD_INSTALL_FLAG_IGNORE_POWER'. To ignore power levels, modify %s",
configfile);
}
if (fu_config_get_ignore_power(self->config))
return TRUE;
/* not charging */

View File

@ -1570,10 +1570,8 @@ fu_main_daemon_method_call(GDBusConnection *connection,
g_variant_get_boolean(prop_value) == TRUE)
helper->flags |= FWUPD_INSTALL_FLAG_ALLOW_BRANCH_SWITCH;
if (g_strcmp0(prop_key, "force") == 0 &&
g_variant_get_boolean(prop_value) == TRUE) {
g_variant_get_boolean(prop_value) == TRUE)
helper->flags |= FWUPD_INSTALL_FLAG_FORCE;
helper->flags |= FWUPD_INSTALL_FLAG_IGNORE_POWER;
}
if (g_strcmp0(prop_key, "ignore-power") == 0 &&
g_variant_get_boolean(prop_value) == TRUE)
helper->flags |= FWUPD_INSTALL_FLAG_IGNORE_POWER;

View File

@ -2907,7 +2907,6 @@ main(int argc, char *argv[])
gboolean ret;
gboolean version = FALSE;
gboolean ignore_checksum = FALSE;
gboolean ignore_power = FALSE;
gboolean ignore_vid_pid = FALSE;
gboolean interactive = isatty(fileno(stdout)) != 0;
g_auto(GStrv) plugin_glob = NULL;
@ -2973,14 +2972,6 @@ main(int argc, char *argv[])
/* TRANSLATORS: command line option */
_("Ignore firmware hardware mismatch failures"),
NULL},
{"ignore-power",
'\0',
0,
G_OPTION_ARG_NONE,
&ignore_power,
/* TRANSLATORS: command line option */
_("Ignore requirement of external power source"),
NULL},
{"no-reboot-check",
'\0',
0,
@ -3449,16 +3440,12 @@ main(int argc, char *argv[])
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_OLDER;
if (allow_branch_switch)
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_BRANCH_SWITCH;
if (force) {
if (force)
priv->flags |= FWUPD_INSTALL_FLAG_FORCE;
priv->flags |= FWUPD_INSTALL_FLAG_IGNORE_POWER;
}
if (ignore_checksum)
priv->flags |= FWUPD_INSTALL_FLAG_IGNORE_CHECKSUM;
if (ignore_vid_pid)
priv->flags |= FWUPD_INSTALL_FLAG_IGNORE_VID_PID;
if (ignore_power)
priv->flags |= FWUPD_INSTALL_FLAG_IGNORE_POWER;
/* load engine */
priv->engine = fu_engine_new(FU_APP_FLAGS_NO_IDLE_SOURCES);

View File

@ -3338,7 +3338,6 @@ main(int argc, char *argv[])
gboolean allow_older = FALSE;
gboolean allow_reinstall = FALSE;
gboolean enable_ipfs = FALSE;
gboolean ignore_power = FALSE;
gboolean is_interactive = TRUE;
gboolean no_history = FALSE;
gboolean offline = FALSE;
@ -3512,14 +3511,6 @@ main(int argc, char *argv[])
_("Filter with a set of device flags using a ~ prefix to "
"exclude, e.g. 'internal,~needs-reboot'"),
NULL},
{"ignore-power",
'\0',
0,
G_OPTION_ARG_NONE,
&ignore_power,
/* TRANSLATORS: command line option */
_("Ignore requirement of external power source"),
NULL},
{"json",
'\0',
0,
@ -3879,14 +3870,10 @@ main(int argc, char *argv[])
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_OLDER;
if (allow_branch_switch)
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_BRANCH_SWITCH;
if (force) {
if (force)
priv->flags |= FWUPD_INSTALL_FLAG_FORCE;
priv->flags |= FWUPD_INSTALL_FLAG_IGNORE_POWER;
}
if (no_history)
priv->flags |= FWUPD_INSTALL_FLAG_NO_HISTORY;
if (ignore_power)
priv->flags |= FWUPD_INSTALL_FLAG_IGNORE_POWER;
/* use IPFS for metadata and firmware *only* if specified */
if (enable_ipfs)