From cf33215b5030fc9d6708edbfd27332910d3322c8 Mon Sep 17 00:00:00 2001 From: Marius Gripsgard Date: Sun, 25 Mar 2018 22:15:43 +0200 Subject: Ignore batt_therm devices. Ported from UBports power indicator: commit 431114ed4f6d457822655ad57901e7e640f99bca Author: Marius Gripsgard Date: Sun Aug 13 00:08:05 2017 +0200 Ignore "batt_therm" devices (fixes: https://github.com/ubports/ubports-touch/issues/94) This ignores "batt_therm" devices since they do not provide correct values. "batt_therm" is only used for temperature of the battery and seems to appear as a "battery" device in upower Ported-by: Mike Gabriel --- src/device-provider-upower.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/device-provider-upower.c') diff --git a/src/device-provider-upower.c b/src/device-provider-upower.c index bfee80f..f9b5e18 100644 --- a/src/device-provider-upower.c +++ b/src/device-provider-upower.c @@ -229,6 +229,9 @@ static void refresh_device_soon (IndicatorPowerDeviceProviderUPower * self, const char * object_path) { + // Android: Ignore batt_therm devices since they give wrong values + if (g_str_has_suffix(object_path, "batt_therm")) + return; priv_t * p = get_priv(self); g_hash_table_add (p->queued_paths, g_strdup (object_path)); @@ -266,8 +269,11 @@ on_enumerate_devices_response(GObject * bus, ao = g_variant_get_child_value(v, 0); g_variant_iter_init(&iter, ao); path = NULL; - while(g_variant_iter_loop(&iter, "o", &path)) - refresh_device_soon (gself, path); + while(g_variant_iter_loop(&iter, "o", &path)) { + // Android: Ignore batt_therm devices since they give wrong values + if (!g_str_has_suffix(path, "batt_therm")) + refresh_device_soon (gself, path); + } g_variant_unref(ao); } @@ -284,6 +290,9 @@ on_device_properties_changed(GDBusConnection * connection G_GNUC_UNUSED, GVariant * parameters, gpointer gself) { + // Android: Ignore batt_therm devices since they give wrong values + if (g_str_has_suffix(object_path, "batt_therm")) + return; IndicatorPowerDeviceProviderUPower* self; priv_t* p; IndicatorPowerDevice* device; -- cgit v1.2.3