Merge lp:~albaguirre/unity-system-compositor/fix-1343919 into lp:unity-system-compositor

Proposed by Alberto Aguirre
Status: Merged
Approved by: kevin gunn
Approved revision: 159
Merged at revision: 159
Proposed branch: lp:~albaguirre/unity-system-compositor/fix-1343919
Merge into: lp:unity-system-compositor
Diff against target: 71 lines (+22/-5)
2 files modified
src/powerd_mediator.cpp (+21/-5)
src/powerd_mediator.h (+1/-0)
To merge this branch: bzr merge lp:~albaguirre/unity-system-compositor/fix-1343919
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Unity System Compositor Development Team Pending
Review via email: mp+227645@code.launchpad.net

Commit message

Attempt to sync up sys state when powerd is already up (LP: #1343919)

Description of the change

Attempt to sync up sys state when powerd is already up (LP: #1343919)

powerd does not expose a system state query api - as a workaround the PowerdMediator constructor can issue a request for active state if the powerd interface is already up, but doesn't wait for the state change, it assumes it will be active at some point (if not already active).

There is a potential small race between powerd signaling the system to fully come out of suspend and turning the screen on so powering the screen may fail ((I have not seen this behavior so far however). In any case a press of the power key should bring the screen back up, as the powerd state and PowerdMediator will now be sync'd up.

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

Looks good and works well (tested on N4).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/powerd_mediator.cpp'
2--- src/powerd_mediator.cpp 2014-07-15 19:52:21 +0000
3+++ src/powerd_mediator.cpp 2014-07-21 22:19:19 +0000
4@@ -80,10 +80,6 @@
5 {
6 qDBusRegisterMetaType<BrightnessParams>();
7
8- if (powerd_interface->isValid())
9- {
10- init_brightness_params();
11- }
12 //Powerd interface may not be available right now or it may restart in the future
13 //watch for changes so brightness params get initialized to the most recent values.
14 connect(service_watcher.get(),
15@@ -96,6 +92,19 @@
16 "SysPowerStateChange",
17 this,
18 SLOT(powerd_state_changed(int)));
19+
20+ if (powerd_interface->isValid())
21+ {
22+ init_brightness_params();
23+ //If powerd is already up it may already be in the active state
24+ //and the SysPowerStateChange signal could have already been broadcasted
25+ //before we got a chance to register a listener for it.
26+ //We will assume that if the active request succeeds that the system state
27+ //will become active at some point in the future - this is only a workaround
28+ //for the lack of a system state query api in powerd
29+ if (disable_suspend_request())
30+ system_state = active;
31+ }
32 }
33
34 PowerdMediator::~PowerdMediator() = default;
35@@ -204,16 +213,23 @@
36
37 void PowerdMediator::disable_suspend()
38 {
39+ if (disable_suspend_request())
40+ wait_for_state(active);
41+}
42+
43+bool PowerdMediator::disable_suspend_request()
44+{
45 if (!acquired_sys_state)
46 {
47 QDBusReply<QString> reply = powerd_interface->call("requestSysState", "com.canonical.Unity.Screen", 1);
48 if (reply.isValid())
49 {
50 sys_state_cookie = reply.value();
51- wait_for_state(active);
52 acquired_sys_state = true;
53+ return true;
54 }
55 }
56+ return false;
57 }
58
59 void PowerdMediator::init_brightness_params()
60
61=== modified file 'src/powerd_mediator.h'
62--- src/powerd_mediator.h 2014-07-15 19:52:21 +0000
63+++ src/powerd_mediator.h 2014-07-21 22:19:19 +0000
64@@ -76,6 +76,7 @@
65 };
66 void change_backlight_state(BacklightState state);
67 void init_brightness_params();
68+ bool disable_suspend_request();
69 void wait_for_state(SystemState state);
70
71 int dim_brightness;

Subscribers

People subscribed via source and target branches