Compare commits

..

No commits in common. "master" and "v1.91.1" have entirely different histories.

9 changed files with 16 additions and 110 deletions

9
NEWS
View file

@ -1,12 +1,3 @@
Version 1.91.2
--------------
Released: 2026-04-01
- Feature: Skip the systemd inhibitor when performing CriticalPowerAction (!309)
- Feature: Introduce "Auto" CriticalPowerAction using systemd-logind Sleep() (!309)
- Fix: Test CanPowerOff() availability before calling PowerOff() (!311)
- Fix: Add charge limit support for systems providing only charge_control_end_threshold (!310, #342, #285)
Version 1.91.1 Version 1.91.1
-------------- --------------
Released: 2026-02-10 Released: 2026-02-10

View file

@ -104,11 +104,10 @@ ExpectBatteryRecalibration=false
# PowerOff # PowerOff
# Hibernate # Hibernate
# HybridSleep # HybridSleep
# Auto (The CriticalPowerAction will be determined by the system)
# Suspend (AllowRiskyCriticalPowerAction should be true to use this option but risky) # Suspend (AllowRiskyCriticalPowerAction should be true to use this option but risky)
# Ignore (AllowRiskyCriticalPowerAction should be true to use this option but risky) # Ignore (AllowRiskyCriticalPowerAction should be true to use this option but risky)
# #
# If Suspend isn't available or AllowRiskyCriticalPowerAction=false, HybridSleep will be used # If Suspend isn't available or AllowRiskyCriticalPowerAction=false, HybridSleep will be used
# If HybridSleep isn't available, Hibernate will be used # If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used # If Hibernate isn't available, PowerOff will be used
CriticalPowerAction=Auto CriticalPowerAction=HybridSleep

View file

@ -1,5 +1,5 @@
project('upower', 'c', project('upower', 'c',
version: '1.91.2', version: '1.91.1',
license: 'GPLv2+', license: 'GPLv2+',
default_options: [ default_options: [
'buildtype=debugoptimized', 'buildtype=debugoptimized',

View file

@ -1,9 +1,3 @@
install_data(
'org.freedesktop.upower.rules',
install_tag: 'runtime',
install_dir: join_paths(datadir, 'polkit-1', 'rules.d'),
)
if polkit.found() if polkit.found()
#newer polkit has the ITS rules included #newer polkit has the ITS rules included
if polkit.version().version_compare('>0.113') if polkit.version().version_compare('>0.113')

View file

@ -1,31 +0,0 @@
/*
* Copyright (C) 2026 Kate Hsuan <hpa@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.login1.power-off-ignore-inhibit" ||
action.id == "org.freedesktop.login1.reboot-ignore-inhibit" ||
action.id == "org.freedesktop.login1.halt-ignore-inhibit" ||
action.id == "org.freedesktop.login1.suspend-ignore-inhibit" ||
action.id == "org.freedesktop.login1.hibernate-ignore-inhibit") &&
subject.user == "root") {
return polkit.Result.YES;
}
});

View file

@ -4,8 +4,4 @@ SUBSYSTEM=="power_supply", ATTR{charge_control_start_threshold}!="", \
IMPORT{builtin}="hwdb 'battery:$kernel:$attr{model_name}:$attr{[dmi/id]modalias}'", \ IMPORT{builtin}="hwdb 'battery:$kernel:$attr{model_name}:$attr{[dmi/id]modalias}'", \
GOTO="battery_end" GOTO="battery_end"
SUBSYSTEM=="power_supply", ATTR{charge_control_end_threshold}!="", \
IMPORT{builtin}="hwdb 'battery:$kernel:$attr{model_name}:$attr{[dmi/id]modalias}'", \
GOTO="battery_end"
LABEL="battery_end" LABEL="battery_end"

View file

@ -2364,10 +2364,10 @@ class Tests(dbusmock.DBusTestCase):
with open(f"/sys/class/power_supply/{battery_name}/charge_types") as fp: with open(f"/sys/class/power_supply/{battery_name}/charge_types") as fp:
self.assertEqual(fp.read(), "Standard") self.assertEqual(fp.read(), "Standard")
# Battery 2 switches to "Standard" # Battery 2 switches to "Fast"
battery_name = bat2_up.split("_")[-1] battery_name = bat2_up.split("_")[-1]
with open(f"/sys/class/power_supply/{battery_name}/charge_types") as fp: with open(f"/sys/class/power_supply/{battery_name}/charge_types") as fp:
self.assertEqual(fp.read(), "Standard") self.assertEqual(fp.read(), "Fast")
def test_battery_charge_limit_multiple_batteries_get_charge_threshold_settings_supported( def test_battery_charge_limit_multiple_batteries_get_charge_threshold_settings_supported(
self, self,

View file

@ -566,15 +566,10 @@ up_backend_get_critical_action (UpBackend *backend)
const gchar *method; const gchar *method;
const gchar *can_method; const gchar *can_method;
} actions[] = { } actions[] = {
/*
* The fallback order is
* Suspend -> HybridSleep -> Hibernate -> PowerOff -> Sleep -> Ignore
*/
{ "Suspend", "CanSuspend" }, { "Suspend", "CanSuspend" },
{ "HybridSleep", "CanHybridSleep" }, { "HybridSleep", "CanHybridSleep" },
{ "Hibernate", "CanHibernate" }, { "Hibernate", "CanHibernate" },
{ "PowerOff", "CanPowerOff" }, { "PowerOff", NULL },
{ "Sleep", "CanSleep"},
{ "Ignore", NULL }, { "Ignore", NULL },
}; };
g_autofree gchar *action = NULL; g_autofree gchar *action = NULL;
@ -597,12 +592,6 @@ up_backend_get_critical_action (UpBackend *backend)
} }
} }
/* if "Auto", use "Sleep()" */
if (!g_strcmp0 (action, "Auto")) {
g_free (action);
action = g_strdup_printf ("Sleep");
}
if (action != NULL) { if (action != NULL) {
for (i = 0; i < G_N_ELEMENTS (actions); i++) for (i = 0; i < G_N_ELEMENTS (actions); i++)
if (g_str_equal (actions[i].method, action)) if (g_str_equal (actions[i].method, action))
@ -644,9 +633,6 @@ up_backend_get_critical_action (UpBackend *backend)
void void
up_backend_take_action (UpBackend *backend) up_backend_take_action (UpBackend *backend)
{ {
GVariant *res = NULL;
g_autoptr (GError) error = NULL;
g_autofree gchar *action = NULL;
const char *method; const char *method;
method = up_backend_get_critical_action (backend); method = up_backend_get_critical_action (backend);
@ -660,43 +646,14 @@ up_backend_take_action (UpBackend *backend)
return; return;
} }
if (!g_strcmp0 (method, "Sleep")) g_dbus_proxy_call (backend->priv->logind_proxy,
action = g_strdup ("Sleep"); method,
else g_variant_new ("(b)", FALSE),
action = g_strdup_printf ("%sWithFlags", method); G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
/* flag 16 is SD_LOGIND_SKIP_INHIBITORS */ NULL,
res = g_dbus_proxy_call_sync (backend->priv->logind_proxy, NULL,
action, NULL);
g_variant_new ("(t)", 16),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
/* if the new API doesn't work, use old one */
if (error != NULL) {
g_autofree gchar *action_old = NULL;
g_debug ("The new power action API doesn't work, using old one.");
if (!g_strcmp0 (method, "Sleep")) {
/* Sleep() is not available, so PowerOff instead */
g_debug ("Sleep() is not available, using PowerOff instead");
action_old = g_strdup ("PowerOff");
} else {
action_old = g_strdup (method);
}
g_dbus_proxy_call (backend->priv->logind_proxy,
action_old,
g_variant_new ("(b)", FALSE),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
NULL,
NULL);
}
if (res != NULL)
g_variant_unref (res);
} }
/** /**

View file

@ -302,12 +302,12 @@ up_device_battery_charge_find_available_charge_types_for_charging (UpDevice *dev
UpDeviceSupplyBattery *self = UP_DEVICE_SUPPLY_BATTERY (device); UpDeviceSupplyBattery *self = UP_DEVICE_SUPPLY_BATTERY (device);
UpDeviceSupplyBatteryChargeTypes charge_types = self->supported_charge_types; UpDeviceSupplyBatteryChargeTypes charge_types = self->supported_charge_types;
if (charge_types & UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_STANDARD)
return UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_STANDARD;
if (charge_types & UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_FAST) if (charge_types & UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_FAST)
return UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_FAST; return UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_FAST;
if (charge_types & UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_STANDARD)
return UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_STANDARD;
if (charge_types & UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_ADAPTIVE) if (charge_types & UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_ADAPTIVE)
return UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_ADAPTIVE; return UP_DEVICE_SUPPLY_BATTERY_CHARGE_TYPES_ADAPTIVE;