diff -Nru upower-0.99.4/debian/changelog upower-0.99.4/debian/changelog --- upower-0.99.4/debian/changelog 2016-02-23 09:59:02.000000000 +0100 +++ upower-0.99.4/debian/changelog 2016-05-18 02:52:30.000000000 +0200 @@ -1,3 +1,12 @@ +upower (0.99.4-2ubuntu1) UNRELEASED; urgency=medium + + * debian/patches/0001-UpKbdBacklight-always-try-to-fetch-the-current-brigh.patch: + - Always return the current keyboard Brightness in GetBrightness also when + the keyboard doesn't notify any brightness change to userland + (Closes: #95457, LP: #1510344) + + -- Marco Trevisan (TreviƱo) Wed, 18 May 2016 02:50:11 +0200 + upower (0.99.4-2) xenial; urgency=high * Urgency high as this is a targetted fix for RC bug in testing. diff -Nru upower-0.99.4/debian/control upower-0.99.4/debian/control --- upower-0.99.4/debian/control 2016-02-23 09:59:02.000000000 +0100 +++ upower-0.99.4/debian/control 2016-05-18 02:52:45.000000000 +0200 @@ -1,7 +1,8 @@ Source: upower Section: admin Priority: optional -Maintainer: Utopia Maintenance Team +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Utopia Maintenance Team Uploaders: Michael Biebl , Martin Pitt , Build-Depends: autotools-dev, diff -Nru upower-0.99.4/debian/patches/0001-UpKbdBacklight-don-t-cache-the-brightness-level-alwa.patch upower-0.99.4/debian/patches/0001-UpKbdBacklight-don-t-cache-the-brightness-level-alwa.patch --- upower-0.99.4/debian/patches/0001-UpKbdBacklight-don-t-cache-the-brightness-level-alwa.patch 1970-01-01 01:00:00.000000000 +0100 +++ upower-0.99.4/debian/patches/0001-UpKbdBacklight-don-t-cache-the-brightness-level-alwa.patch 2016-05-24 14:38:59.000000000 +0200 @@ -0,0 +1,137 @@ +Description: Always read the current keyboard brightness level from sysnode +Author: Marco Trevisan +Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95457 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/upower/+bug/1510344 +Fowarded: yes +Applied-Upstream: https://cgit.freedesktop.org/upower/commit/?id=793642bfb + +From 793642bfb752494b97c3ef96eb60ae0ec573723b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= +Date: Fri, 20 May 2016 04:18:52 +0200 +Subject: UpKbdBacklight: don't cache the brightness level, always read it from + sysfs attrib + +When GetBrightness is called it's better to fetch the current value in the +sysfs attribute since many devices doesn't support the emission of brightness +changes to userland, and this could make settings daemons to handle +this value incorrectly. + +Add static up_kbd_backlight_brightness_read that is now called during +initialization too, it returns -1 on errors, and use it everywhere we need +to read or check the current brightness. + +https://bugs.freedesktop.org/show_bug.cgi?id=95457 + +diff --git a/src/up-kbd-backlight.c b/src/up-kbd-backlight.c +index cfa1dd3..ebd79dd 100644 +--- a/src/up-kbd-backlight.c ++++ b/src/up-kbd-backlight.c +@@ -43,13 +43,43 @@ static void up_kbd_backlight_finalize (GObject *object); + struct UpKbdBacklightPrivate + { + gint fd; +- gint brightness; + gint max_brightness; + }; + + G_DEFINE_TYPE (UpKbdBacklight, up_kbd_backlight, UP_TYPE_EXPORTED_KBD_BACKLIGHT_SKELETON) + + /** ++ * up_kbd_backlight_brightness_read: ++ **/ ++static gint ++up_kbd_backlight_brightness_read (UpKbdBacklight *kbd_backlight) ++{ ++ gchar buf[16]; ++ gchar *end = NULL; ++ ssize_t len; ++ gint64 brightness = -1; ++ ++ g_return_val_if_fail (kbd_backlight->priv->fd >= 0, brightness); ++ ++ lseek (kbd_backlight->priv->fd, 0, SEEK_SET); ++ len = read (kbd_backlight->priv->fd, buf, G_N_ELEMENTS (buf) - 1); ++ ++ if (len > 0) { ++ buf[len] = '\0'; ++ brightness = g_ascii_strtoll (buf, &end, 10); ++ ++ if (brightness < 0 || ++ brightness > kbd_backlight->priv->max_brightness || ++ end == buf || *end != '\0') { ++ brightness = -1; ++ g_warning ("failed to convert brightness: %s", buf); ++ } ++ } ++ ++ return brightness; ++} ++ ++/** + * up_kbd_backlight_brightness_write: + **/ + static gboolean +@@ -84,9 +114,8 @@ up_kbd_backlight_brightness_write (UpKbdBacklight *kbd_backlight, gint value) + } + + /* emit signal */ +- kbd_backlight->priv->brightness = value; + up_exported_kbd_backlight_emit_brightness_changed (UP_EXPORTED_KBD_BACKLIGHT (kbd_backlight), +- kbd_backlight->priv->brightness); ++ value); + + out: + g_free (text); +@@ -103,8 +132,19 @@ up_kbd_backlight_get_brightness (UpExportedKbdBacklight *skeleton, + GDBusMethodInvocation *invocation, + UpKbdBacklight *kbd_backlight) + { +- up_exported_kbd_backlight_complete_get_brightness (skeleton, invocation, +- kbd_backlight->priv->brightness); ++ gint brightness; ++ ++ brightness = up_kbd_backlight_brightness_read (kbd_backlight); ++ ++ if (brightness >= 0) { ++ up_exported_kbd_backlight_complete_get_brightness (skeleton, invocation, ++ brightness); ++ } else { ++ g_dbus_method_invocation_return_error (invocation, ++ UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, ++ "error reading brightness"); ++ } ++ + return TRUE; + } + +@@ -216,23 +256,12 @@ up_kbd_backlight_find (UpKbdBacklight *kbd_backlight) + goto out; + } + +- /* read brightness */ ++ /* open the brightness file for read and write operations */ + path_now = g_build_filename (dir_path, "brightness", NULL); +- ret = g_file_get_contents (path_now, &buf_now, NULL, &error); +- if (!ret) { +- g_warning ("failed to get brightness: %s", error->message); +- g_error_free (error); +- goto out; +- } +- kbd_backlight->priv->brightness = g_ascii_strtoull (buf_now, &end, 10); +- if (kbd_backlight->priv->brightness == 0 && end == buf_now) { +- g_warning ("failed to convert brightness: %s", buf_now); +- goto out; +- } +- +- /* open the file for writing */ + kbd_backlight->priv->fd = open (path_now, O_RDWR); +- if (kbd_backlight->priv->fd < 0) ++ ++ /* read brightness and check if it has an acceptable value */ ++ if (up_kbd_backlight_brightness_read (kbd_backlight) < 0) + goto out; + + /* success */ +-- +cgit v0.10.2 + diff -Nru upower-0.99.4/debian/patches/series upower-0.99.4/debian/patches/series --- upower-0.99.4/debian/patches/series 2016-02-23 09:59:02.000000000 +0100 +++ upower-0.99.4/debian/patches/series 2016-05-19 04:43:43.000000000 +0200 @@ -1 +1,2 @@ 0001-daemon-fix-get_critical_action.patch +0001-UpKbdBacklight-don-t-cache-the-brightness-level-alwa.patch diff -Nru upower-0.99.4/debian/tests/build upower-0.99.4/debian/tests/build --- upower-0.99.4/debian/tests/build 2016-02-23 09:59:02.000000000 +0100 +++ upower-0.99.4/debian/tests/build 1970-01-01 01:00:00.000000000 +0100 @@ -1,28 +0,0 @@ -#!/bin/sh -# autopkgtest check: Build and run a program against libupower-glib, to verify -# that the headers and pkg-config file are installed correctly -# (C) 2013 Canonical Ltd. -# Author: Martin Pitt - -set -e - -WORKDIR=$(mktemp -d) -trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM -cd $WORKDIR -cat < libupowertest.c -#include -#include - -int main() -{ - UpClient *client = up_client_new (); - g_assert_cmpint (strlen (up_client_get_daemon_version (client)), >, 4); - return 0; -} -EOF - -gcc -o libupowertest libupowertest.c `pkg-config --cflags --libs upower-glib` -Wall -Werror -echo "build: OK" -[ -x libupowertest ] -env G_DEBUG="fatal-warnings fatal-criticals" ./libupowertest -echo "run: OK"