Merge lp:~ricmm/powerd/add-sensors-proximity-call into lp:powerd

Proposed by Ricardo Mendoza
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 26
Merged at revision: 25
Proposed branch: lp:~ricmm/powerd/add-sensors-proximity-call
Merge into: lp:powerd
Diff against target: 172 lines (+101/-1)
5 files modified
CMakeLists.txt (+3/-0)
debian/control (+2/-1)
src/powerd-sensors.cpp (+63/-0)
src/powerd-sensors.h (+29/-0)
src/powerd.cpp (+4/-0)
To merge this branch: bzr merge lp:~ricmm/powerd/add-sensors-proximity-call
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ricardo Salveti (community) Approve
Michael Frey (community) Approve
Review via email: mp+166390@code.launchpad.net

Commit message

  * Provide initial sensors control
  * Turn screen off when in call and proximity = NEAR

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:25
http://jenkins.qa.ubuntu.com/job/powerd-ci/36/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/powerd-raring-armhf-ci/36/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/powerd-ci/36/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Frey (mfrey) wrote :

tested, works great.

review: Approve
26. By Ricardo Mendoza

Add platform-api dep

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:26
http://jenkins.qa.ubuntu.com/job/powerd-ci/40/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/powerd-raring-armhf-ci/40/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/powerd-ci/40/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Working fine, as expected.

Needs newer platform-api for it to build.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-05-25 01:24:31 +0000
3+++ CMakeLists.txt 2013-05-30 01:44:23 +0000
4@@ -28,6 +28,7 @@
5 src/display.c
6 src/powerd-object.c
7 src/power-request.c
8+ src/powerd-sensors.cpp
9 src/${GDBUS_NAME}.c
10 )
11
12@@ -79,6 +80,8 @@
13 ${GUDEV_LIBRARIES}
14 ${GIO_LIBRARIES}
15 ${GIO-UNIX_LIBRARIES}
16+ ${PHABLET_LIBRARIES}
17+ "-lubuntu_application_api"
18 )
19
20 install(
21
22=== modified file 'debian/control'
23--- debian/control 2013-05-20 15:46:01 +0000
24+++ debian/control 2013-05-30 01:44:23 +0000
25@@ -8,7 +8,8 @@
26 libgudev-1.0-dev,
27 libhybris-dev,
28 libgles2-mesa-dev,
29- python
30+ python,
31+ libplatform-api1-dev
32 Standards-Version: 3.9.3
33 Vcs-Bzr: lp:powerd
34
35
36=== added file 'src/powerd-sensors.cpp'
37--- src/powerd-sensors.cpp 1970-01-01 00:00:00 +0000
38+++ src/powerd-sensors.cpp 2013-05-30 01:44:23 +0000
39@@ -0,0 +1,63 @@
40+/*
41+ * Copyright 2013 Canonical Ltd.
42+ *
43+ * Authors:
44+ * Ricardo Mendoza: ricardo.mendoza@canonical.com
45+ *
46+ * This file is part of powerd.
47+ *
48+ * powerd is free software; you can redistribute it and/or modify
49+ * it under the terms of the GNU General Public License as published by
50+ * the Free Software Foundation; version 3.
51+ *
52+ * powerd is distributed in the hope that it will be useful,
53+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
54+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55+ * GNU General Public License for more details.
56+ *
57+ * You should have received a copy of the GNU General Public License
58+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
59+ */
60+
61+#include "powerd-internal.h"
62+#include "powerd-sensors.h"
63+
64+#include <ubuntu/application/sensors/proximity.h>
65+
66+UASensorsProximity* prox_sensor;
67+
68+void on_new_proximity_event(UASProximityEvent *event, void *context)
69+{
70+ switch (uas_proximity_event_get_distance(event))
71+ {
72+ case U_PROXIMITY_NEAR:
73+ {
74+ powerd_set_display_state(POWERD_DISPLAY_OFF);
75+ break;
76+ }
77+ case U_PROXIMITY_FAR:
78+ {
79+ powerd_set_display_state(POWERD_DISPLAY_ON);
80+ break;
81+ }
82+ }
83+}
84+
85+void powerd_sensors_proximity_enable(void)
86+{
87+ ua_sensors_proximity_enable(prox_sensor);
88+}
89+
90+void powerd_sensors_proximity_disable(void)
91+{
92+ ua_sensors_proximity_disable(prox_sensor);
93+}
94+
95+void powerd_sensors_init(void)
96+{
97+ prox_sensor = ua_sensors_proximity_new();
98+
99+ ua_sensors_proximity_set_reading_cb(prox_sensor,
100+ on_new_proximity_event,
101+ NULL);
102+}
103
104=== added file 'src/powerd-sensors.h'
105--- src/powerd-sensors.h 1970-01-01 00:00:00 +0000
106+++ src/powerd-sensors.h 2013-05-30 01:44:23 +0000
107@@ -0,0 +1,29 @@
108+/*
109+ * Copyright 2013 Canonical Ltd.
110+ *
111+ * Authors:
112+ * Ricardo Mendoza: ricardo.mendoza@canonical.com
113+ *
114+ * This file is part of powerd.
115+ *
116+ * powerd is free software; you can redistribute it and/or modify
117+ * it under the terms of the GNU General Public License as published by
118+ * the Free Software Foundation; version 3.
119+ *
120+ * powerd is distributed in the hope that it will be useful,
121+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
122+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
123+ * GNU General Public License for more details.
124+ *
125+ * You should have received a copy of the GNU General Public License
126+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
127+ */
128+
129+#ifndef __POWERD_SENSORS_H__
130+#define __POWERD_SENSORS_H__
131+
132+void powerd_sensors_init(void);
133+void powerd_sensors_proximity_enable(void);
134+void powerd_sensors_proximity_disable(void);
135+
136+#endif /* __POWERD_SENSORS_H */
137
138=== modified file 'src/powerd.cpp'
139--- src/powerd.cpp 2013-05-25 01:24:31 +0000
140+++ src/powerd.cpp 2013-05-30 01:44:23 +0000
141@@ -38,6 +38,7 @@
142 #include "powerd-internal.h"
143 #include "powerd-object.h"
144 #include "powerd-dbus.h"
145+#include "powerd-sensors.h"
146
147 #include <hybris/input/input_stack_compatibility_layer.h>
148 #include <hybris/input/input_stack_compatibility_layer_codes_key.h>
149@@ -203,6 +204,7 @@
150 g_warning("Request for active state failed");
151 }
152 powerd_set_display_state(POWERD_DISPLAY_ON);
153+ powerd_sensors_proximity_enable();
154 }
155 else if (!strcmp(signal_name, "CallRemoved")) {
156 g_debug("Call over, dropping active state request");
157@@ -210,6 +212,7 @@
158 if (!ret)
159 g_warning("Internal system state request cookie invalid: %d\n",
160 ofono_call_request_cookie);
161+ powerd_sensors_proximity_disable();
162 }
163 }
164
165@@ -259,6 +262,7 @@
166 libsuspend_init(0);
167 power_request_init();
168 powerd_display_init();
169+ powerd_sensors_init();
170
171 main_loop = g_main_loop_new (NULL, FALSE);
172 signal(SIGTERM, sigterm_quit);

Subscribers

People subscribed via source and target branches