Merge lp:~mterry/unity8/lock-during-call into lp:unity8

Proposed by Michael Terry
Status: Work in progress
Proposed branch: lp:~mterry/unity8/lock-during-call
Merge into: lp:unity8
Diff against target: 191 lines (+76/-15)
7 files modified
Shell.qml (+2/-1)
debian/control (+1/-0)
plugins/Powerd/CMakeLists.txt (+9/-0)
plugins/Powerd/Powerd.cpp (+37/-13)
plugins/Powerd/Powerd.h (+15/-1)
tests/mocks/Powerd/Powerd.cpp (+5/-0)
tests/mocks/Powerd/Powerd.h (+7/-0)
To merge this branch: bzr merge lp:~mterry/unity8/lock-during-call
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Needs Information
Mirco Müller Pending
Review via email: mp+183964@code.launchpad.net

Commit message

Allow locking the screen during a phone call.

Description of the change

Allow locking the screen during a phone call.

In addition to checking the proximity sensor [1], we need to pass the phone call from the user session to the greeter.

[1] We want to ignore screen blanks that are proximity-related, since that's not actually a request for a lock.

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :

Mike you proposed this more than one year ago, is this still a "Work in Progress" or shall it be deleted?

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

It's still work in progress in the sense that it needs to be updated with latest code. But the bug is still open and valid. Just not high importance.

Unmerged revisions

280. By Michael Terry

Rough cut at listening to proximity events

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-09-02 11:24:59 +0000
3+++ Shell.qml 2013-09-04 19:37:06 +0000
4@@ -513,7 +513,8 @@
5 onDisplayPowerStateChange: {
6 // We ignore any display-off signals when the proximity sensor
7 // is active. This usually indicates something like a phone call.
8- if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
9+ var proximate = (flags & Powerd.UseProximity) && Powerd.nearProximity;
10+ if (status == Powerd.Off && !proximate) {
11 powerConnection.setFocused(false);
12 greeter.show();
13 } else if (status == Powerd.On) {
14
15=== modified file 'debian/control'
16--- debian/control 2013-09-03 23:38:15 +0000
17+++ debian/control 2013-09-04 19:37:06 +0000
18@@ -16,6 +16,7 @@
19 libnih-dev,
20 libnm-glib-dev,
21 libnm-util-dev,
22+ libplatform-api1-dev,
23 libpulse-dev,
24 libqmenumodel-dev (>= 0.2.7),
25 libqt5v8-5-private-dev,
26
27=== modified file 'plugins/Powerd/CMakeLists.txt'
28--- plugins/Powerd/CMakeLists.txt 2013-08-02 16:18:28 +0000
29+++ plugins/Powerd/CMakeLists.txt 2013-09-04 19:37:06 +0000
30@@ -8,6 +8,15 @@
31 )
32
33 qt5_use_modules(Powerd-qml DBus Qml)
34+pkg_check_modules(UA REQUIRED ubuntu-platform-api)
35+
36+include_directories(
37+ ${UA_INCLUDE_DIRS}
38+ )
39+
40+target_link_libraries(Powerd-qml
41+ ${UA_LDFLAGS}
42+ )
43
44 export_qmlfiles(Powerd Powerd)
45 export_qmlplugin(Powerd 0.1 Powerd TARGETS Powerd-qml)
46
47=== modified file 'plugins/Powerd/Powerd.cpp'
48--- plugins/Powerd/Powerd.cpp 2013-08-20 21:04:22 +0000
49+++ plugins/Powerd/Powerd.cpp 2013-09-04 19:37:06 +0000
50@@ -17,20 +17,44 @@
51 */
52
53 #include "Powerd.h"
54+#include <ubuntu/application/sensors/proximity.h>
55
56 Powerd::Powerd(QObject* parent)
57 : QObject(parent),
58- powerd(NULL)
59-{
60- powerd = new QDBusInterface("com.canonical.powerd",
61- "/com/canonical/powerd",
62- "com.canonical.powerd",
63- QDBusConnection::SM_BUSNAME(), this);
64-
65- powerd->connection().connect("com.canonical.powerd",
66- "/com/canonical/powerd",
67- "com.canonical.powerd",
68- "DisplayPowerStateChange",
69- this,
70- SIGNAL(displayPowerStateChange(int, unsigned int)));
71+ m_powerd(NULL),
72+ m_proximitySensor(ua_sensors_proximity_new()) // Note: seems no way to free...
73+{
74+ m_powerd = new QDBusInterface("com.canonical.powerd",
75+ "/com/canonical/powerd",
76+ "com.canonical.powerd",
77+ QDBusConnection::SM_BUSNAME(), this);
78+
79+ m_powerd->connection().connect("com.canonical.powerd",
80+ "/com/canonical/powerd",
81+ "com.canonical.powerd",
82+ "DisplayPowerStateChange",
83+ this,
84+ SIGNAL(displayPowerStateChange(int, unsigned int)));
85+
86+ if (m_proximitySensor) {
87+ ua_sensors_proximity_set_reading_cb(m_proximitySensor,
88+ onProximityEvent,
89+ this);
90+ }
91+}
92+
93+bool Powerd::getNearProximity()
94+{
95+ return m_nearProximity;
96+}
97+
98+void Powerd::onProximityEvent(UASProximityEvent *event, void *context)
99+{
100+ auto powerd = (Powerd*)context;
101+
102+ bool isNear = uas_proximity_event_get_distance(event) == U_PROXIMITY_NEAR;
103+ if (isNear != powerd->m_nearProximity) {
104+ powerd->m_nearProximity = isNear;
105+ Q_EMIT powerd->nearProximityChanged();
106+ }
107 }
108
109=== modified file 'plugins/Powerd/Powerd.h'
110--- plugins/Powerd/Powerd.h 2013-08-21 20:04:24 +0000
111+++ plugins/Powerd/Powerd.h 2013-09-04 19:37:06 +0000
112@@ -23,12 +23,19 @@
113 #include <QtCore/QObject>
114 #include <QtDBus/QDBusInterface>
115
116+typedef void UASProximityEvent;
117+typedef void UASensorsProximity;
118+
119 class Powerd: public QObject
120 {
121 Q_OBJECT
122 Q_ENUMS(Status)
123 Q_FLAGS(DisplayFlag DisplayFlags)
124
125+ Q_PROPERTY(bool nearProximity
126+ READ getNearProximity
127+ NOTIFY nearProximityChanged)
128+
129 public:
130 enum DisplayFlag {
131 UseProximity = 1, // Use proximity sensor to override screen state
132@@ -44,11 +51,18 @@
133
134 explicit Powerd(QObject *parent = 0);
135
136+ bool getNearProximity();
137+
138 Q_SIGNALS:
139 void displayPowerStateChange(int status, unsigned int flags);
140+ void nearProximityChanged();
141
142 private:
143- QDBusInterface *powerd;
144+ static void onProximityEvent(UASProximityEvent *event, void *context);
145+
146+ QDBusInterface *m_powerd;
147+ bool m_nearProximity;
148+ UASensorsProximity *m_proximitySensor;
149 };
150
151 #endif
152
153=== modified file 'tests/mocks/Powerd/Powerd.cpp'
154--- tests/mocks/Powerd/Powerd.cpp 2013-08-08 13:58:12 +0000
155+++ tests/mocks/Powerd/Powerd.cpp 2013-09-04 19:37:06 +0000
156@@ -22,3 +22,8 @@
157 : QObject(parent)
158 {
159 }
160+
161+bool Powerd::getNearProximity()
162+{
163+ return false;
164+}
165
166=== modified file 'tests/mocks/Powerd/Powerd.h'
167--- tests/mocks/Powerd/Powerd.h 2013-08-21 20:04:24 +0000
168+++ tests/mocks/Powerd/Powerd.h 2013-09-04 19:37:06 +0000
169@@ -27,6 +27,10 @@
170 Q_ENUMS(Status)
171 Q_FLAGS(DisplayFlag DisplayFlags)
172
173+ Q_PROPERTY(bool nearProximity
174+ READ getNearProximity
175+ NOTIFY nearProximityChanged)
176+
177 public:
178 enum DisplayFlag {
179 UseProximity = 1, // Use proximity sensor to override screen state
180@@ -42,8 +46,11 @@
181
182 explicit Powerd(QObject *parent = 0);
183
184+ bool getNearProximity();
185+
186 Q_SIGNALS:
187 void displayPowerStateChange(int status, unsigned int flags);
188+ void nearProximityChanged();
189 };
190
191 #endif

Subscribers

People subscribed via source and target branches