Merge lp:~afrantzis/unity-system-compositor/fix-1461476-display-off-ubuntu into lp:unity-system-compositor/ubuntu

Proposed by Alexandros Frantzis
Status: Merged
Merged at revision: 205
Proposed branch: lp:~afrantzis/unity-system-compositor/fix-1461476-display-off-ubuntu
Merge into: lp:unity-system-compositor/ubuntu
Diff against target: 80 lines (+37/-3)
2 files modified
src/unity_screen_service.cpp (+11/-3)
tests/integration-tests/test_unity_screen_service.cpp (+26/-0)
To merge this branch: bzr merge lp:~afrantzis/unity-system-compositor/fix-1461476-display-off-ubuntu
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity System Compositor Development Team Pending
Review via email: mp+264128@code.launchpad.net

Commit message

Don't restart the inactivity timers when receiving invalid dbus calls or uninteresting dbus events

Previously, invalid dbus calls (e.g., trying to remove a non-existent keepDisplayOn request), or uninteresting dbus events (e.g., being informed about disconnections of dbus clients that hadn't issued any keepDisplayOn requests), would restart the inactivity timers, effectively increasing the delay until display dimming and poweroff.

Description of the change

Don't restart the inactivity timers when receiving invalid dbus calls or uninteresting dbus events

Previously, invalid dbus calls (e.g., trying to remove a non-existent keepDisplayOn request), or uninteresting dbus events (e.g., being informed about disconnections of dbus clients that hadn't issued any keepDisplayOn requests), would restart the inactivity timers, effectively increasing the delay until display dimming and poweroff.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity_screen_service.cpp'
2--- src/unity_screen_service.cpp 2015-03-18 13:06:10 +0000
3+++ src/unity_screen_service.cpp 2015-07-08 11:44:41 +0000
4@@ -305,6 +305,8 @@
5 {
6 std::lock_guard<std::mutex> lock{keep_display_on_mutex};
7
8+ bool id_removed{false};
9+
10 auto range = keep_display_on_ids.equal_range(sender);
11 for (auto iter = range.first;
12 iter != range.second;
13@@ -313,11 +315,12 @@
14 if (iter->second == id)
15 {
16 keep_display_on_ids.erase(iter);
17+ id_removed = true;
18 break;
19 }
20 }
21
22- if (keep_display_on_ids.empty())
23+ if (id_removed && keep_display_on_ids.empty())
24 screen->keep_display_on(false);
25 }
26
27@@ -329,9 +332,14 @@
28 if (new_owner.empty() && old_owner == name)
29 {
30 std::lock_guard<std::mutex> lock{keep_display_on_mutex};
31- keep_display_on_ids.erase(name);
32- if (keep_display_on_ids.empty())
33+ // If the disconnected client had issued keepDisplayOn requests
34+ // and after removing them there are now no more requests left,
35+ // tell the screen we don't need to keep the display on.
36+ if (keep_display_on_ids.erase(name) > 0 &&
37+ keep_display_on_ids.empty())
38+ {
39 screen->keep_display_on(false);
40+ }
41 }
42 }
43
44
45=== modified file 'tests/integration-tests/test_unity_screen_service.cpp'
46--- tests/integration-tests/test_unity_screen_service.cpp 2015-03-18 13:06:10 +0000
47+++ tests/integration-tests/test_unity_screen_service.cpp 2015-07-08 11:44:41 +0000
48@@ -365,6 +365,32 @@
49 EXPECT_TRUE(request_processed.woken());
50 }
51
52+TEST_F(AUnityScreenService, ignores_invalid_display_on_removal_request)
53+{
54+ ut::WaitCondition request_processed;
55+
56+ int32_t const invalid_id{-1};
57+ EXPECT_CALL(*mock_screen, keep_display_on(false)).Times(0);
58+
59+ client.request_remove_display_on_request(invalid_id);
60+ client.disconnect();
61+
62+ // Allow some time for dbus calls to reach UnityScreenService
63+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
64+}
65+
66+TEST_F(AUnityScreenService, ignores_disconnects_from_clients_without_display_on_request)
67+{
68+ ut::WaitCondition request_processed;
69+
70+ EXPECT_CALL(*mock_screen, keep_display_on(false)).Times(0);
71+
72+ client.disconnect();
73+
74+ // Allow some time for disconnect notification to reach UnityScreenService
75+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
76+}
77+
78 TEST_F(AUnityScreenService, emits_power_state_change_signal)
79 {
80 using namespace testing;

Subscribers

People subscribed via source and target branches