mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-23 10:28:13 +02:00
main: Obsolete "Inhibited" property and add Degraded
The PerformanceInhibited property was there to convey that the performance profile was unavailable, and that the daemon should switch to a lower profile to avoid using the performance profile. But it was difficult to communicate whether the daemon should switch back to the performance profile when the inhibition disappeared, or whether it should keep the same profile (the latter was what was implemented). There was also the problem that depending on the backend, the performance profile might be able to provide a behaviour that wouldn't match either of the unhampered performance profile, or the balanced profile, but somewhere in between. The PerformanceInhibited property is kept for compatibility reasons with the existing consumer, GNOME 40. It will be removed in the future and should not be relied on. Closes: #24
This commit is contained in:
parent
9ff59f0d1e
commit
99740ead2d
9 changed files with 96 additions and 105 deletions
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
OS components would typically use the "Profiles" property to construct
|
||||
their UI (2 or 3 profiles available), and monitor the "ActiveProfile"
|
||||
and the "PerformanceInhibited" properties to update that UI. The UI
|
||||
and the "PerformanceDegraded" properties to update that UI. The UI
|
||||
would try to set the "ActiveProfile" property if the user selected
|
||||
a different one.
|
||||
|
||||
|
|
@ -27,24 +27,29 @@
|
|||
<!--
|
||||
ActiveProfile:
|
||||
|
||||
The type of the currently active profile. It might change automatically
|
||||
if the "performance" profile was selected but it got inhibited, in which
|
||||
case the "PerformanceInhibited" property will reflect the reason.
|
||||
The type of the currently active profile.
|
||||
-->
|
||||
<property name="ActiveProfile" type="s" access="readwrite"/>
|
||||
|
||||
<!--
|
||||
PerformanceInhibited:
|
||||
|
||||
This will be set if the performance power profile is unavailable, with
|
||||
the value being used to identify the reason for unavailability. As new
|
||||
reasons can be added, it is recommended that front-ends show a generic
|
||||
This property is deprecated, and unused since version 0.9.
|
||||
-->
|
||||
<property name="PerformanceInhibited" type="s" access="read"/>
|
||||
|
||||
<!--
|
||||
PerformanceDegraded:
|
||||
|
||||
This will be set if the performance power profile is running in degraded
|
||||
mode, with the value being used to identify the reason for that degradation.
|
||||
As new reasons can be added, it is recommended that front-ends show a generic
|
||||
reason if they do not recognise the value. Possible values are:
|
||||
- "lap-detected" (the computer is sitting on the user's lap)
|
||||
- "high-operating-temperature" (the computer is close to overheating)
|
||||
- "" (the empty string, if not inhibited)
|
||||
- "" (the empty string, if not performance is not degraded)
|
||||
-->
|
||||
<property name="PerformanceInhibited" type="s" access="read"/>
|
||||
<property name="PerformanceDegraded" type="s" access="read"/>
|
||||
|
||||
<!--
|
||||
Profiles:
|
||||
|
|
|
|||
|
|
@ -68,9 +68,10 @@ typedef enum {
|
|||
PROP_INHIBITED = 1 << 1,
|
||||
PROP_PROFILES = 1 << 2,
|
||||
PROP_ACTIONS = 1 << 3,
|
||||
PROP_DEGRADED = 1 << 4,
|
||||
} PropertiesMask;
|
||||
|
||||
#define PROP_ALL (PROP_ACTIVE_PROFILE | PROP_INHIBITED | PROP_PROFILES | PROP_ACTIONS)
|
||||
#define PROP_ALL (PROP_ACTIVE_PROFILE | PROP_INHIBITED | PROP_PROFILES | PROP_ACTIONS | PROP_DEGRADED)
|
||||
|
||||
static const char *
|
||||
get_active_profile (PpdApp *data)
|
||||
|
|
@ -79,7 +80,7 @@ get_active_profile (PpdApp *data)
|
|||
}
|
||||
|
||||
static const char *
|
||||
get_performance_inhibited (PpdApp *data)
|
||||
get_performance_degraded (PpdApp *data)
|
||||
{
|
||||
const char *ret;
|
||||
PpdDriver *driver;
|
||||
|
|
@ -87,7 +88,7 @@ get_performance_inhibited (PpdApp *data)
|
|||
driver = GET_DRIVER(PPD_PROFILE_PERFORMANCE);
|
||||
if (!driver)
|
||||
return "";
|
||||
ret = ppd_driver_get_performance_inhibited (driver);
|
||||
ret = ppd_driver_get_performance_degraded (driver);
|
||||
g_assert (ret != NULL);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -158,7 +159,11 @@ send_dbus_event (PpdApp *data,
|
|||
}
|
||||
if (mask & PROP_INHIBITED) {
|
||||
g_variant_builder_add (&props_builder, "{sv}", "PerformanceInhibited",
|
||||
g_variant_new_string (get_performance_inhibited (data)));
|
||||
g_variant_new_string (""));
|
||||
}
|
||||
if (mask & PROP_DEGRADED) {
|
||||
g_variant_builder_add (&props_builder, "{sv}", "PerformanceDegraded",
|
||||
g_variant_new_string (get_performance_degraded (data)));
|
||||
}
|
||||
if (mask & PROP_PROFILES) {
|
||||
g_variant_builder_add (&props_builder, "{sv}", "Profiles",
|
||||
|
|
@ -245,13 +250,6 @@ set_active_profile (PpdApp *data,
|
|||
if (target_profile == data->active_profile)
|
||||
return TRUE;
|
||||
|
||||
if (target_profile == PPD_PROFILE_PERFORMANCE &&
|
||||
ppd_driver_is_performance_inhibited (GET_DRIVER (PPD_PROFILE_PERFORMANCE))) {
|
||||
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
|
||||
"Profile '%s' is inhibited", profile);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_debug ("Transitioning active profile from '%s' to '%s' by user request",
|
||||
ppd_profile_to_str (data->active_profile), profile);
|
||||
|
||||
|
|
@ -262,32 +260,27 @@ set_active_profile (PpdApp *data,
|
|||
}
|
||||
|
||||
static void
|
||||
driver_performance_inhibited_changed_cb (GObject *gobject,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
driver_performance_degraded_changed_cb (GObject *gobject,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
PpdApp *data = user_data;
|
||||
PpdDriver *driver = PPD_DRIVER (gobject);
|
||||
const char *prop_str = pspec->name;
|
||||
|
||||
if (g_strcmp0 (prop_str, "performance-inhibited") != 0) {
|
||||
if (g_strcmp0 (prop_str, "performance-degraded") != 0) {
|
||||
g_warning ("Ignoring '%s' property change on profile driver '%s'",
|
||||
prop_str, ppd_driver_get_driver_name (driver));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(ppd_driver_get_profiles (driver) & PPD_PROFILE_PERFORMANCE)) {
|
||||
g_warning ("Ignored 'performance-inhibited' change on non-performance driver '%s'",
|
||||
g_warning ("Ignored 'performance-degraded' change on non-performance driver '%s'",
|
||||
ppd_driver_get_driver_name (driver));
|
||||
return;
|
||||
}
|
||||
|
||||
send_dbus_event (data, PROP_INHIBITED);
|
||||
if (!ppd_driver_is_performance_inhibited (driver))
|
||||
return;
|
||||
|
||||
activate_target_profile (data, PPD_PROFILE_BALANCED, PPD_PROFILE_ACTIVATION_REASON_INHIBITION);
|
||||
send_dbus_event (data, PROP_ACTIVE_PROFILE);
|
||||
send_dbus_event (data, PROP_DEGRADED);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -324,11 +317,13 @@ handle_get_property (GDBusConnection *connection,
|
|||
if (g_strcmp0 (property_name, "ActiveProfile") == 0)
|
||||
return g_variant_new_string (get_active_profile (data));
|
||||
if (g_strcmp0 (property_name, "PerformanceInhibited") == 0)
|
||||
return g_variant_new_string (get_performance_inhibited (data));
|
||||
return g_variant_new_string ("");
|
||||
if (g_strcmp0 (property_name, "Profiles") == 0)
|
||||
return get_profiles_variant (data);
|
||||
if (g_strcmp0 (property_name, "Actions") == 0)
|
||||
return get_actions_variant (data);
|
||||
if (g_strcmp0 (property_name, "PerformanceDegraded") == 0)
|
||||
return g_variant_new_string (get_performance_degraded (data));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -477,8 +472,8 @@ start_profile_drivers (PpdApp *data)
|
|||
|
||||
data->driver = driver;
|
||||
|
||||
g_signal_connect (G_OBJECT (driver), "notify::performance-inhibited",
|
||||
G_CALLBACK (driver_performance_inhibited_changed_cb), data);
|
||||
g_signal_connect (G_OBJECT (driver), "notify::performance-degraded",
|
||||
G_CALLBACK (driver_performance_degraded_changed_cb), data);
|
||||
g_signal_connect (G_OBJECT (driver), "profile-changed",
|
||||
G_CALLBACK (driver_profile_changed_cb), data);
|
||||
} else if (PPD_IS_ACTION (object)) {
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ def get_profiles_property(prop):
|
|||
def _list():
|
||||
try:
|
||||
profiles = get_profiles_property('Profiles')
|
||||
reason = get_proxy().Get('(ss)', 'net.hadess.PowerProfiles', 'PerformanceInhibited')
|
||||
inhibited = (reason != '')
|
||||
reason = get_proxy().Get('(ss)', 'net.hadess.PowerProfiles', 'PerformanceDegraded')
|
||||
degraded = (reason != '')
|
||||
active = get_proxy().Get('(ss)', 'net.hadess.PowerProfiles', 'ActiveProfile')
|
||||
except:
|
||||
print("Couldn\'t get Profiles: ", sys.exc_info()[0])
|
||||
|
|
@ -114,7 +114,7 @@ def _list():
|
|||
print(('%s %s:') % ('*' if profile['Profile'] == active else ' ', profile['Profile']))
|
||||
print(' Driver: ', profile['Driver'])
|
||||
if profile['Profile'] == 'performance':
|
||||
print(' Inhibited: ', f'yes ({reason})' if inhibited else 'no')
|
||||
print(' Degraded: ', f'yes ({reason})' if degraded else 'no')
|
||||
index += 1
|
||||
|
||||
def main(): # pylint: disable=too-many-branches
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct _PpdDriverFake
|
|||
struct termios old_tio;
|
||||
GIOChannel *channel;
|
||||
guint watch_id;
|
||||
gboolean inhibited;
|
||||
gboolean degraded;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (PpdDriverFake, ppd_driver_fake, PPD_TYPE_DRIVER)
|
||||
|
|
@ -48,19 +48,19 @@ ppd_driver_fake_constructor (GType type,
|
|||
}
|
||||
|
||||
static void
|
||||
toggle_inhibition (PpdDriverFake *fake)
|
||||
toggle_degradation (PpdDriverFake *fake)
|
||||
{
|
||||
fake->inhibited = !fake->inhibited;
|
||||
fake->degraded = !fake->degraded;
|
||||
|
||||
g_object_set (G_OBJECT (fake),
|
||||
"performance-inhibited", fake->inhibited ? "lap-detected" : NULL,
|
||||
"performance-degraded", fake->degraded ? "lap-detected" : NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_usage (void)
|
||||
{
|
||||
g_print ("Valid keys are: i (toggle inhibition), r (restart drivers), q/x (quit)\n");
|
||||
g_print ("Valid keys are: d (toggle degradation), r (restart drivers), q/x (quit)\n");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -82,9 +82,9 @@ check_keyboard (GIOChannel *source,
|
|||
return TRUE;
|
||||
|
||||
switch (buf[0]) {
|
||||
case 'i':
|
||||
g_print ("Toggling inhibition\n");
|
||||
toggle_inhibition (fake);
|
||||
case 'd':
|
||||
g_print ("Toggling degradation\n");
|
||||
toggle_degradation (fake);
|
||||
break;
|
||||
case 'r':
|
||||
g_print ("Restarting profile drivers\n");
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ update_no_turbo (PpdDriverIntelPstate *pstate)
|
|||
turbo_disabled = TRUE;
|
||||
}
|
||||
|
||||
g_object_set (G_OBJECT (pstate), "performance-inhibited",
|
||||
g_object_set (G_OBJECT (pstate), "performance-degraded",
|
||||
turbo_disabled ? "high-operating-temperature" : NULL,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ update_dytc_lapmode_state (PpdDriverPlatformProfile *self)
|
|||
self->lapmode = new_lapmode;
|
||||
g_debug ("dytc_lapmode is now %s, so profile is %s",
|
||||
self->lapmode ? "on" : "off",
|
||||
self->lapmode ? "inhibited" : "uninhibited");
|
||||
self->lapmode ? "degraded" : "not degraded");
|
||||
g_object_set (G_OBJECT (self),
|
||||
"performance-inhibited", self->lapmode ? "lap-detected" : NULL,
|
||||
"performance-degraded", self->lapmode ? "lap-detected" : NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -225,13 +225,6 @@ ppd_driver_platform_profile_activate_profile (PpdDriver *drive
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (profile == PPD_PROFILE_PERFORMANCE &&
|
||||
self->lapmode) {
|
||||
g_debug ("Can't switch to performance mode, lapmode is detected");
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Mode is inhibited");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_signal_handler_block (G_OBJECT (self->acpi_platform_profile_mon), self->acpi_platform_profile_changed_id);
|
||||
platform_profile_path = ppd_utils_get_sysfs_path (ACPI_PLATFORM_PROFILE_PATH);
|
||||
if (!ppd_utils_write (platform_profile_path, profile_to_acpi_platform_profile_value (self, profile), error)) {
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@
|
|||
* `power-saver` profiles using placeholder
|
||||
*
|
||||
* When a driver implements the `performance` profile, it might set the
|
||||
* #PpdDriver:performance-inhibited property if the profile isn't available for any
|
||||
* reason, such as thermal limits being reached, or because a part of the
|
||||
* user's body is too close for safety, for example.
|
||||
* #PpdDriver:performance-degraded property if the profile isn't running to
|
||||
* its fullest performance for any reason, such as thermal limits being
|
||||
* reached, or because a part of the user's body is too close for safety,
|
||||
* for example.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
|
|
@ -43,14 +44,14 @@ typedef struct
|
|||
char *driver_name;
|
||||
PpdProfile profiles;
|
||||
gboolean selected;
|
||||
char *performance_inhibited;
|
||||
char *performance_degraded;
|
||||
} PpdDriverPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DRIVER_NAME,
|
||||
PROP_PROFILES,
|
||||
PROP_PERFORMANCE_INHIBITED
|
||||
PROP_PERFORMANCE_DEGRADED
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -81,9 +82,9 @@ ppd_driver_set_property (GObject *object,
|
|||
case PROP_PROFILES:
|
||||
priv->profiles = g_value_get_flags (value);
|
||||
break;
|
||||
case PROP_PERFORMANCE_INHIBITED:
|
||||
g_clear_pointer (&priv->performance_inhibited, g_free);
|
||||
priv->performance_inhibited = g_value_dup_string (value);
|
||||
case PROP_PERFORMANCE_DEGRADED:
|
||||
g_clear_pointer (&priv->performance_degraded, g_free);
|
||||
priv->performance_degraded = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
||||
|
|
@ -106,8 +107,8 @@ ppd_driver_get_property (GObject *object,
|
|||
case PROP_PROFILES:
|
||||
g_value_set_flags (value, priv->profiles);
|
||||
break;
|
||||
case PROP_PERFORMANCE_INHIBITED:
|
||||
g_value_set_string (value, priv->performance_inhibited);
|
||||
case PROP_PERFORMANCE_DEGRADED:
|
||||
g_value_set_string (value, priv->performance_degraded);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
||||
|
|
@ -121,7 +122,7 @@ ppd_driver_finalize (GObject *object)
|
|||
|
||||
priv = PPD_DRIVER_GET_PRIVATE (PPD_DRIVER (object));
|
||||
g_clear_pointer (&priv->driver_name, g_free);
|
||||
g_clear_pointer (&priv->performance_inhibited, g_free);
|
||||
g_clear_pointer (&priv->performance_degraded, g_free);
|
||||
|
||||
G_OBJECT_CLASS (ppd_driver_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -197,15 +198,15 @@ ppd_driver_class_init (PpdDriverClass *klass)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/**
|
||||
* PpdDriver:performance-inhibited:
|
||||
* PpdDriver:performance-degraded:
|
||||
*
|
||||
* If set to a non-%NULL value, the reason why the performance profile is unavailable.
|
||||
* The value must be one of the options listed in the D-Bus API reference.
|
||||
*/
|
||||
g_object_class_install_property (object_class, PROP_PERFORMANCE_INHIBITED,
|
||||
g_param_spec_string("performance-inhibited",
|
||||
"Performance Inhibited",
|
||||
"Why the performance profile is inhibited, if set",
|
||||
g_object_class_install_property (object_class, PROP_PERFORMANCE_DEGRADED,
|
||||
g_param_spec_string("performance-degraded",
|
||||
"Performance Degraded",
|
||||
"Why the performance profile is degraded, if set",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
|
@ -285,18 +286,18 @@ ppd_driver_get_selected (PpdDriver *driver)
|
|||
}
|
||||
|
||||
const char *
|
||||
ppd_driver_get_performance_inhibited (PpdDriver *driver)
|
||||
ppd_driver_get_performance_degraded (PpdDriver *driver)
|
||||
{
|
||||
PpdDriverPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (PPD_IS_DRIVER (driver), NULL);
|
||||
|
||||
priv = PPD_DRIVER_GET_PRIVATE (driver);
|
||||
return priv->performance_inhibited ? priv->performance_inhibited : "";
|
||||
return priv->performance_degraded ? priv->performance_degraded : "";
|
||||
}
|
||||
|
||||
gboolean
|
||||
ppd_driver_is_performance_inhibited (PpdDriver *driver)
|
||||
ppd_driver_is_performance_degraded (PpdDriver *driver)
|
||||
{
|
||||
PpdDriverPrivate *priv;
|
||||
|
||||
|
|
@ -304,7 +305,7 @@ ppd_driver_is_performance_inhibited (PpdDriver *driver)
|
|||
|
||||
priv = PPD_DRIVER_GET_PRIVATE (driver);
|
||||
|
||||
return (priv->performance_inhibited != NULL);
|
||||
return (priv->performance_degraded != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ gboolean ppd_driver_activate_profile (PpdDriver *driver,
|
|||
PpdProfile profile, PpdProfileActivationReason reason, GError **error);
|
||||
const char *ppd_driver_get_driver_name (PpdDriver *driver);
|
||||
PpdProfile ppd_driver_get_profiles (PpdDriver *driver);
|
||||
const char *ppd_driver_get_performance_inhibited (PpdDriver *driver);
|
||||
gboolean ppd_driver_is_performance_inhibited (PpdDriver *driver);
|
||||
const char *ppd_driver_get_performance_degraded (PpdDriver *driver);
|
||||
gboolean ppd_driver_is_performance_degraded (PpdDriver *driver);
|
||||
void ppd_driver_emit_profile_changed (PpdDriver *driver, PpdProfile profile);
|
||||
const char *ppd_profile_activation_reason_to_str (PpdProfileActivationReason reason);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ class Tests(dbusmock.DBusTestCase):
|
|||
|
||||
self.start_daemon()
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceInhibited'), '')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceDegraded'), '')
|
||||
|
||||
profiles = self.get_dbus_property('Profiles')
|
||||
self.assertEqual(len(profiles), 2)
|
||||
|
|
@ -279,8 +279,19 @@ class Tests(dbusmock.DBusTestCase):
|
|||
|
||||
self.stop_daemon()
|
||||
|
||||
def test_inhibited_transition(self):
|
||||
'''Test that transitions work as expected when inhibited'''
|
||||
def test_inhibited_property(self):
|
||||
'''Test that the inhibited property exists'''
|
||||
|
||||
self.create_dytc_device()
|
||||
self.create_platform_profile()
|
||||
self.start_daemon()
|
||||
|
||||
profiles = self.get_dbus_property('Profiles')
|
||||
self.assertEqual(len(profiles), 3)
|
||||
self.assertEqual(self.get_dbus_property('PerformanceInhibited'), '')
|
||||
|
||||
def test_degraded_transition(self):
|
||||
'''Test that transitions work as expected when degraded'''
|
||||
|
||||
self.create_dytc_device()
|
||||
self.create_platform_profile()
|
||||
|
|
@ -294,11 +305,11 @@ class Tests(dbusmock.DBusTestCase):
|
|||
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('performance'))
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
|
||||
|
||||
# Inhibit
|
||||
# Degraded
|
||||
self.testbed.set_attribute(self.tp_acpi, 'dytc_lapmode', '1\n')
|
||||
self.assertEventually(lambda: self.have_text_in_log('dytc_lapmode is now on'))
|
||||
self.assertEqual(self.get_dbus_property('PerformanceInhibited'), 'lap-detected')
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceDegraded'), 'lap-detected')
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
|
||||
|
||||
# Switch to non-performance
|
||||
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('power-saver'))
|
||||
|
|
@ -349,8 +360,8 @@ class Tests(dbusmock.DBusTestCase):
|
|||
no_turbo.write("1\n")
|
||||
|
||||
self.assertEventually(lambda: self.have_text_in_log('File monitor change happened for '))
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceInhibited'), 'high-operating-temperature')
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceDegraded'), 'high-operating-temperature')
|
||||
|
||||
self.stop_daemon()
|
||||
|
||||
|
|
@ -408,31 +419,17 @@ class Tests(dbusmock.DBusTestCase):
|
|||
self.assertEqual(profiles[2]['Profile'], 'performance')
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
|
||||
|
||||
# lapmode detected, but performance wasn't selected anyway
|
||||
# lapmode detected
|
||||
self.testbed.set_attribute(self.tp_acpi, 'dytc_lapmode', '1\n')
|
||||
self.assertEventually(lambda: self.get_dbus_property('PerformanceInhibited') == 'lap-detected')
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
|
||||
self.assertEventually(lambda: self.get_dbus_property('PerformanceDegraded') == 'lap-detected')
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
|
||||
|
||||
# Reset lapmode
|
||||
self.testbed.set_attribute(self.tp_acpi, 'dytc_lapmode', '0\n')
|
||||
self.assertEventually(lambda: self.get_dbus_property('PerformanceInhibited') == '')
|
||||
self.assertEventually(lambda: self.get_dbus_property('PerformanceDegraded') == '')
|
||||
|
||||
# Set performance mode
|
||||
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('performance'))
|
||||
# Performance mode didn't change
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
|
||||
self.assertEventually(lambda: self.read_sysfs_file("sys/firmware/acpi/platform_profile") == b'performance')
|
||||
|
||||
# And turn on lapmode
|
||||
self.testbed.set_attribute(self.tp_acpi, 'dytc_lapmode', '1\n')
|
||||
self.assertEventually(lambda: self.read_sysfs_file("sys/firmware/acpi/platform_profile") == b'balanced')
|
||||
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceInhibited'), 'lap-detected')
|
||||
|
||||
# Turn off lapmode, profile stays balanced
|
||||
self.testbed.set_attribute(self.tp_acpi, 'dytc_lapmode', '0\n')
|
||||
self.assertEventually(lambda: self.get_dbus_property('PerformanceInhibited') == '')
|
||||
self.assertEventually(lambda: self.read_sysfs_file("sys/firmware/acpi/platform_profile") == b'balanced')
|
||||
|
||||
# Switch to power-saver mode
|
||||
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('power-saver'))
|
||||
|
|
@ -511,7 +508,7 @@ class Tests(dbusmock.DBusTestCase):
|
|||
self.assertEqual(len(profiles), 3)
|
||||
# Was set in platform_profile before we loaded the drivers
|
||||
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceInhibited'), '')
|
||||
self.assertEqual(self.get_dbus_property('PerformanceDegraded'), '')
|
||||
|
||||
self.stop_daemon()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue