Merge lp:~afrantzis/powerd/fix-1489326-screen-flash-when-proximity-covered into lp:powerd

Proposed by Alexandros Frantzis on 2015-08-28
Status: Merged
Approved by: Alexandros Frantzis on 2015-09-01
Approved revision: 179
Merged at revision: 177
Proposed branch: lp:~afrantzis/powerd/fix-1489326-screen-flash-when-proximity-covered
Merge into: lp:powerd
Diff against target: 127 lines (+40/-8)
4 files modified
debian/changelog (+13/-0)
src/powerd-sensors.cpp (+20/-3)
src/powerd-sensors.h (+3/-1)
src/powerd.cpp (+4/-4)
To merge this branch: bzr merge lp:~afrantzis/powerd/fix-1489326-screen-flash-when-proximity-covered
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-09-01
Kevin DuBois (community) 2015-08-28 Approve on 2015-08-31
Review via email: mp+269523@code.launchpad.net

Commit message

Apply workaround for proximity sensors not sending initial state only for problematic sensors

Description of the change

Apply workaround for proximity sensors not sending initial state only for problematic sensors

Don't send the extra synthetic proximity FAR event (which is what turns on the screen momentarily), unless it is actually needed.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
178. By Alexandros Frantzis on 2015-08-31

Sync with lp:ubuntu/powerd

179. By Alexandros Frantzis on 2015-08-31

Update debian/changelog

Kevin DuBois (kdub) wrote :

seems reasonable as a fix... I guess powerd-sensors.cpp and powerd-sensors.h are shaping up to be more of a class than disjoint functions though.

review: Approve
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 'debian/changelog'
2--- debian/changelog 2015-07-30 05:15:59 +0000
3+++ debian/changelog 2015-08-31 13:54:42 +0000
4@@ -1,3 +1,16 @@
5+powerd (0.16+15.10.20150831-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ * Apply workaround for proximity sensors not sending initial
8+ state only for problematic sensors (LP: #1489326)
9+
10+ -- Alexandros Frantzis <alexandros.frantzis@canonical.com> Mon, 31 Aug 2015 16:41:34 +0300
11+
12+powerd (0.16+15.10.20150730-0ubuntu2~gcc5.1) wily; urgency=medium
13+
14+ * No-change test rebuild for g++5 ABI transition
15+
16+ -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 30 Jul 2015 21:36:06 +0000
17+
18 powerd (0.16+15.10.20150730-0ubuntu1) wily; urgency=medium
19
20 [ Alberto Aguirre ]
21
22=== modified file 'src/powerd-sensors.cpp'
23--- src/powerd-sensors.cpp 2015-07-29 23:48:24 +0000
24+++ src/powerd-sensors.cpp 2015-08-31 13:54:42 +0000
25@@ -22,15 +22,27 @@
26 #include "powerd-internal.h"
27 #include "powerd-sensors.h"
28 #include "log.h"
29+#include <atomic>
30
31 #include <ubuntu/application/sensors/light.h>
32 #include <ubuntu/application/sensors/proximity.h>
33
34 UASensorsProximity* prox_sensor;
35 UASensorsLight* light_sensor;
36+GMainLoop* main_loop = NULL;
37+std::atomic<bool> allow_synthetic{false};
38+
39+gboolean emit_synthetic_proximity_far(void *context)
40+{
41+ if (allow_synthetic)
42+ powerd_proximity_event(FALSE);
43+
44+ return FALSE;
45+}
46
47 void on_new_proximity_event(UASProximityEvent *event, void *context)
48 {
49+ allow_synthetic = false;
50 switch (uas_proximity_event_get_distance(event))
51 {
52 case U_PROXIMITY_NEAR:
53@@ -50,14 +62,18 @@
54 {
55 //FIXME: Some proximity sensors do not
56 //send an initial event when enabled and nothing is close
57- //Perhaps this should be called on a timeout instead
58- powerd_proximity_event(FALSE);
59+ //To work around this, we schedule a synthetic proximity
60+ //far event in case no event has been emitted 500ms
61+ //after enabling the proximity sensor
62+ allow_synthetic = true;
63+ g_timeout_add(500, emit_synthetic_proximity_far, NULL);
64
65 ua_sensors_proximity_enable(prox_sensor);
66 }
67
68 void powerd_sensors_proximity_disable(void)
69 {
70+ allow_synthetic = false;
71 ua_sensors_proximity_disable(prox_sensor);
72 }
73
74@@ -80,8 +96,9 @@
75 ua_sensors_light_disable(light_sensor);
76 }
77
78-void powerd_sensors_init(void)
79+void powerd_sensors_init(GMainLoop *ml)
80 {
81+ main_loop = ml;
82 prox_sensor = ua_sensors_proximity_new();
83 if (prox_sensor != NULL) {
84 ua_sensors_proximity_set_reading_cb(prox_sensor,
85
86=== modified file 'src/powerd-sensors.h'
87--- src/powerd-sensors.h 2013-05-29 21:06:00 +0000
88+++ src/powerd-sensors.h 2015-08-31 13:54:42 +0000
89@@ -22,7 +22,9 @@
90 #ifndef __POWERD_SENSORS_H__
91 #define __POWERD_SENSORS_H__
92
93-void powerd_sensors_init(void);
94+#include <glib.h>
95+
96+void powerd_sensors_init(GMainLoop* main_loop);
97 void powerd_sensors_proximity_enable(void);
98 void powerd_sensors_proximity_disable(void);
99
100
101=== modified file 'src/powerd.cpp'
102--- src/powerd.cpp 2015-07-20 14:53:30 +0000
103+++ src/powerd.cpp 2015-08-31 13:54:42 +0000
104@@ -444,6 +444,9 @@
105 (GBusNameVanishedCallback)unity_screen_name_vanished_cb,
106 NULL, NULL);
107
108+ main_loop = g_main_loop_new (NULL, FALSE);
109+ signal(SIGTERM, sigterm_quit);
110+
111 /* Init this first, data is used by other inits */
112 device_config_init();
113
114@@ -455,13 +458,10 @@
115 dbus_name_watch_init();
116 powerd_backlight_init();
117 powerd_autobrightness_init();
118- powerd_sensors_init();
119+ powerd_sensors_init(main_loop);
120 powerd_ps_init();
121 wakeup_init();
122
123- main_loop = g_main_loop_new (NULL, FALSE);
124- signal(SIGTERM, sigterm_quit);
125-
126 int err = hw_get_module(POWER_HARDWARE_MODULE_ID,
127 (hw_module_t const**)&_power_module);
128

Subscribers

People subscribed via source and target branches