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

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
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
Kevin DuBois (community) Approve
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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
178. By Alexandros Frantzis

Sync with lp:ubuntu/powerd

179. By Alexandros Frantzis

Update debian/changelog

Revision history for this message
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
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
=== modified file 'debian/changelog'
--- debian/changelog 2015-07-30 05:15:59 +0000
+++ debian/changelog 2015-08-31 13:54:42 +0000
@@ -1,3 +1,16 @@
1powerd (0.16+15.10.20150831-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Apply workaround for proximity sensors not sending initial
4 state only for problematic sensors (LP: #1489326)
5
6 -- Alexandros Frantzis <alexandros.frantzis@canonical.com> Mon, 31 Aug 2015 16:41:34 +0300
7
8powerd (0.16+15.10.20150730-0ubuntu2~gcc5.1) wily; urgency=medium
9
10 * No-change test rebuild for g++5 ABI transition
11
12 -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 30 Jul 2015 21:36:06 +0000
13
1powerd (0.16+15.10.20150730-0ubuntu1) wily; urgency=medium14powerd (0.16+15.10.20150730-0ubuntu1) wily; urgency=medium
215
3 [ Alberto Aguirre ]16 [ Alberto Aguirre ]
417
=== modified file 'src/powerd-sensors.cpp'
--- src/powerd-sensors.cpp 2015-07-29 23:48:24 +0000
+++ src/powerd-sensors.cpp 2015-08-31 13:54:42 +0000
@@ -22,15 +22,27 @@
22#include "powerd-internal.h"22#include "powerd-internal.h"
23#include "powerd-sensors.h"23#include "powerd-sensors.h"
24#include "log.h"24#include "log.h"
25#include <atomic>
2526
26#include <ubuntu/application/sensors/light.h>27#include <ubuntu/application/sensors/light.h>
27#include <ubuntu/application/sensors/proximity.h>28#include <ubuntu/application/sensors/proximity.h>
2829
29UASensorsProximity* prox_sensor;30UASensorsProximity* prox_sensor;
30UASensorsLight* light_sensor;31UASensorsLight* light_sensor;
32GMainLoop* main_loop = NULL;
33std::atomic<bool> allow_synthetic{false};
34
35gboolean emit_synthetic_proximity_far(void *context)
36{
37 if (allow_synthetic)
38 powerd_proximity_event(FALSE);
39
40 return FALSE;
41}
3142
32void on_new_proximity_event(UASProximityEvent *event, void *context)43void on_new_proximity_event(UASProximityEvent *event, void *context)
33{44{
45 allow_synthetic = false;
34 switch (uas_proximity_event_get_distance(event))46 switch (uas_proximity_event_get_distance(event))
35 {47 {
36 case U_PROXIMITY_NEAR:48 case U_PROXIMITY_NEAR:
@@ -50,14 +62,18 @@
50{62{
51 //FIXME: Some proximity sensors do not63 //FIXME: Some proximity sensors do not
52 //send an initial event when enabled and nothing is close64 //send an initial event when enabled and nothing is close
53 //Perhaps this should be called on a timeout instead65 //To work around this, we schedule a synthetic proximity
54 powerd_proximity_event(FALSE);66 //far event in case no event has been emitted 500ms
67 //after enabling the proximity sensor
68 allow_synthetic = true;
69 g_timeout_add(500, emit_synthetic_proximity_far, NULL);
5570
56 ua_sensors_proximity_enable(prox_sensor);71 ua_sensors_proximity_enable(prox_sensor);
57}72}
5873
59void powerd_sensors_proximity_disable(void)74void powerd_sensors_proximity_disable(void)
60{75{
76 allow_synthetic = false;
61 ua_sensors_proximity_disable(prox_sensor);77 ua_sensors_proximity_disable(prox_sensor);
62}78}
6379
@@ -80,8 +96,9 @@
80 ua_sensors_light_disable(light_sensor);96 ua_sensors_light_disable(light_sensor);
81}97}
8298
83void powerd_sensors_init(void)99void powerd_sensors_init(GMainLoop *ml)
84{100{
101 main_loop = ml;
85 prox_sensor = ua_sensors_proximity_new();102 prox_sensor = ua_sensors_proximity_new();
86 if (prox_sensor != NULL) {103 if (prox_sensor != NULL) {
87 ua_sensors_proximity_set_reading_cb(prox_sensor,104 ua_sensors_proximity_set_reading_cb(prox_sensor,
88105
=== modified file 'src/powerd-sensors.h'
--- src/powerd-sensors.h 2013-05-29 21:06:00 +0000
+++ src/powerd-sensors.h 2015-08-31 13:54:42 +0000
@@ -22,7 +22,9 @@
22#ifndef __POWERD_SENSORS_H__22#ifndef __POWERD_SENSORS_H__
23#define __POWERD_SENSORS_H__23#define __POWERD_SENSORS_H__
2424
25void powerd_sensors_init(void);25#include <glib.h>
26
27void powerd_sensors_init(GMainLoop* main_loop);
26void powerd_sensors_proximity_enable(void);28void powerd_sensors_proximity_enable(void);
27void powerd_sensors_proximity_disable(void);29void powerd_sensors_proximity_disable(void);
2830
2931
=== modified file 'src/powerd.cpp'
--- src/powerd.cpp 2015-07-20 14:53:30 +0000
+++ src/powerd.cpp 2015-08-31 13:54:42 +0000
@@ -444,6 +444,9 @@
444 (GBusNameVanishedCallback)unity_screen_name_vanished_cb,444 (GBusNameVanishedCallback)unity_screen_name_vanished_cb,
445 NULL, NULL);445 NULL, NULL);
446446
447 main_loop = g_main_loop_new (NULL, FALSE);
448 signal(SIGTERM, sigterm_quit);
449
447 /* Init this first, data is used by other inits */450 /* Init this first, data is used by other inits */
448 device_config_init();451 device_config_init();
449452
@@ -455,13 +458,10 @@
455 dbus_name_watch_init();458 dbus_name_watch_init();
456 powerd_backlight_init();459 powerd_backlight_init();
457 powerd_autobrightness_init();460 powerd_autobrightness_init();
458 powerd_sensors_init();461 powerd_sensors_init(main_loop);
459 powerd_ps_init();462 powerd_ps_init();
460 wakeup_init();463 wakeup_init();
461464
462 main_loop = g_main_loop_new (NULL, FALSE);
463 signal(SIGTERM, sigterm_quit);
464
465 int err = hw_get_module(POWER_HARDWARE_MODULE_ID,465 int err = hw_get_module(POWER_HARDWARE_MODULE_ID,
466 (hw_module_t const**)&_power_module);466 (hw_module_t const**)&_power_module);
467467

Subscribers

People subscribed via source and target branches