Merge lp:~mterry/unity8/display-proximity into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Michał Sawicz
Approved revision: 229
Merged at revision: 233
Proposed branch: lp:~mterry/unity8/display-proximity
Merge into: lp:unity8
Diff against target: 128 lines (+44/-11)
5 files modified
Shell.qml (+5/-3)
plugins/Powerd/Powerd.cpp (+2/-2)
plugins/Powerd/Powerd.h (+15/-1)
tests/mocks/Powerd/Powerd.h (+15/-2)
tests/qmltests/tst_Shell.qml (+7/-3)
To merge this branch: bzr merge lp:~mterry/unity8/display-proximity
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+181157@code.launchpad.net

Commit message

Listen to display-power-changed rather than system-power-changed signals when showing the greeter; ignore such signals when the proximity sensor is active

Description of the change

Listen to display-power-changed rather than system-power-changed signals when showing the greeter; ignore such signals when the proximity sensor is active.

We don't need to listen to power changes. The experience we really care about is whether the user sees the screen go black. That's when we want to turn on the greeter and unfocus apps. Plus, this gives us access to the flags that powerd sends with a display-power-changed signal that tell us whether the proximity sensors are enabled.

When proximity is on, we don't want to show the greeter. Because the user likely has the phone up to their ear for a call and want to resume what they were doing after pulling away from the ear.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~mterry/unity8/display-proximity updated
224. By Michael Terry

Update mock Powerd too

Revision history for this message
Michał Sawicz (saviq) wrote :

First of all - awesome! :)

Test needs fixing it seems (qmltestrunner.Shell::test_suspend: property showProgress Actual (): 0 Expected (): 1).

Can we have an enum for state... And actually, s/state/status/g so that we don't conflict with Item.state?

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

Ah, and I think we're missing Q_DECLARE_FLAGS() for completeness:

http://qt-project.org/doc/qt-5.0/qtcore/qobject.html#Q_FLAGS

review: Needs Information
lp:~mterry/unity8/display-proximity updated
225. By Michael Terry

And update suspend qmltest

Revision history for this message
Michael Terry (mterry) wrote :

Updated, thanks!

lp:~mterry/unity8/display-proximity updated
226. By Michael Terry

Add a Status enum

227. By Michael Terry

Use enums in test too

Revision history for this message
Michał Sawicz (saviq) wrote :

I get a failure in the test still:

FAIL! : qmltestrunner::Shell::test_suspend() property mainStageFocusedApplication
   Actual (): null
   Expected ():
   Loc: [/home/michal/dev/canonical/unity8/repo/tests/qmltests/tst_Shell.qml(139)]

The problem itself is fixed, though.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~mterry/unity8/display-proximity updated
228. By Michael Terry

Whoops, fix argument name to match the Qml plugin

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

The greeter does not come in on suspend now. It might be a powerd bug, but still problematic for us.

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

Humm... Did you ever see onDisplayPowerStateChange actually being called? I can't seem to, whether on power button, timeout suspend or proximity sensor...

Feels like we need an autopilot test for this...

Also, I seem to lose input to the phone app sometimes with this (not with trunk), I wonder what happens there...

review: Needs Information
Revision history for this message
Michael Terry (mterry) wrote :

For posterity: I mentioned on IRC that this is working for me, both the signal being called and input in phone app...

lp:~mterry/unity8/display-proximity updated
229. By Michael Terry

Fix indentation on Status enum

Revision history for this message
Michał Sawicz (saviq) wrote :

Yup, working now - not sure what was the issue. Input was not restarting phone-app between unity8 restarts.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Shell.qml'
2--- Shell.qml 2013-08-15 11:21:26 +0000
3+++ Shell.qml 2013-08-21 20:04:45 +0000
4@@ -497,11 +497,13 @@
5 }
6 }
7
8- onPowerStateChange: {
9- if (state == 0) { // suspend
10+ onDisplayPowerStateChange: {
11+ // We ignore any display-off signals when the proximity sensor
12+ // is active. This usually indicates something like a phone call.
13+ if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
14 powerConnection.setFocused(false);
15 greeter.show();
16- } else if (state == 1) { // active
17+ } else if (status == Powerd.On) {
18 powerConnection.setFocused(true);
19 }
20 }
21
22=== modified file 'plugins/Powerd/Powerd.cpp'
23--- plugins/Powerd/Powerd.cpp 2013-08-02 16:18:28 +0000
24+++ plugins/Powerd/Powerd.cpp 2013-08-21 20:04:45 +0000
25@@ -30,7 +30,7 @@
26 powerd->connection().connect("com.canonical.powerd",
27 "/com/canonical/powerd",
28 "com.canonical.powerd",
29- "SysPowerStateChange",
30+ "DisplayPowerStateChange",
31 this,
32- SIGNAL(powerStateChange(int)));
33+ SIGNAL(displayPowerStateChange(int, unsigned int)));
34 }
35
36=== modified file 'plugins/Powerd/Powerd.h'
37--- plugins/Powerd/Powerd.h 2013-08-02 16:18:28 +0000
38+++ plugins/Powerd/Powerd.h 2013-08-21 20:04:45 +0000
39@@ -26,12 +26,26 @@
40 class Powerd: public QObject
41 {
42 Q_OBJECT
43+ Q_ENUMS(Status)
44+ Q_FLAGS(DisplayFlag DisplayFlags)
45
46 public:
47+ enum DisplayFlag {
48+ UseProximity = 1, // Use proximity sensor to override screen state
49+ DisableAutoBrightness = 2, // Force autobrightness to be disabled
50+ Bright = 4, // Request the screen to stay bright
51+ };
52+ Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
53+
54+ enum Status {
55+ Off,
56+ On,
57+ };
58+
59 explicit Powerd(QObject *parent = 0);
60
61 Q_SIGNALS:
62- void powerStateChange(int state);
63+ void displayPowerStateChange(int status, unsigned int flags);
64
65 private:
66 QDBusInterface *powerd;
67
68=== modified file 'tests/mocks/Powerd/Powerd.h'
69--- tests/mocks/Powerd/Powerd.h 2013-08-09 14:35:36 +0000
70+++ tests/mocks/Powerd/Powerd.h 2013-08-21 20:04:45 +0000
71@@ -20,17 +20,30 @@
72 #define UNITY_MOCK_POWERD_H
73
74 #include <QtCore/QObject>
75-#include <QtDBus/QDBusInterface>
76
77 class Powerd: public QObject
78 {
79 Q_OBJECT
80+ Q_ENUMS(Status)
81+ Q_FLAGS(DisplayFlag DisplayFlags)
82
83 public:
84+ enum DisplayFlag {
85+ UseProximity = 1, // Use proximity sensor to override screen state
86+ DisableAutoBrightness = 2, // Force autobrightness to be disabled
87+ Bright = 4, // Request the screen to stay bright
88+ };
89+ Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
90+
91+ enum Status {
92+ Off,
93+ On,
94+ };
95+
96 explicit Powerd(QObject *parent = 0);
97
98 Q_SIGNALS:
99- void powerStateChange(int state);
100+ void displayPowerStateChange(int status, unsigned int flags);
101 };
102
103 #endif
104
105=== modified file 'tests/qmltests/tst_Shell.qml'
106--- tests/qmltests/tst_Shell.qml 2013-08-15 08:09:39 +0000
107+++ tests/qmltests/tst_Shell.qml 2013-08-21 20:04:45 +0000
108@@ -125,13 +125,17 @@
109 var mainApp = ApplicationManager.mainStageFocusedApplication;
110 tryCompareFunction(function() { return mainApp != null; }, true);
111
112- // Now suspend
113- Powerd.powerStateChange(0);
114+ // Try to suspend while proximity is engaged...
115+ Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
116+ tryCompare(greeter, "showProgress", 0);
117+
118+ // Now really suspend
119+ Powerd.displayPowerStateChange(Powerd.Off, 0);
120 tryCompare(greeter, "showProgress", 1);
121 tryCompare(ApplicationManager, "mainStageFocusedApplication", null);
122
123 // And wake up
124- Powerd.powerStateChange(1);
125+ Powerd.displayPowerStateChange(Powerd.On, 0);
126 tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
127 tryCompare(greeter, "showProgress", 1);
128 }

Subscribers

People subscribed via source and target branches