Merge lp:~andreas-pokorny/powerd/blank-on-proximity-powerstate into lp:powerd
- blank-on-proximity-powerstate
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ricardo Salveti |
Approved revision: | 143 |
Merged at revision: | 143 |
Proposed branch: | lp:~andreas-pokorny/powerd/blank-on-proximity-powerstate |
Merge into: | lp:powerd |
Diff against target: |
514 lines (+148/-198) 9 files modified
CMakeLists.txt (+1/-0) cli/powerd-cli.c (+50/-0) data/com.canonical.powerd.xml (+8/-0) src/power-request.c (+2/-1) src/powerd-internal.h (+6/-0) src/powerd-object.c (+4/-29) src/powerd-proximity.cpp (+63/-0) src/powerd.cpp (+2/-168) src/powerd.h (+12/-0) |
To merge this branch: | bzr merge lp:~andreas-pokorny/powerd/blank-on-proximity-powerstate |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Salveti (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+235356@code.launchpad.net |
Commit message
Adds two dbus messages to control proximity sensor based blanking from other processes
Those messages are used by telepathy-ofono during a call to blank on proximity depending on the used audio outputs. Since now proximity handling is requested externally the builtin handling ofono voice calls is removed.
powerd-cli now supports a proximity command:
powerd-cli proximity on|off
Description of the change
This change deactivates the builtin proximity handling during calls, and lets an external requester deactivate and activate proximity using a new dbus methods.
PS Jenkins bot (ps-jenkins) wrote : | # |
Ricardo Salveti (rsalveti) wrote : | # |
The change looks fine, still need to test it though (together with https:/
Created silo 10 so we can have the packages available in the same PPA.
We just need to make sure telepathy-ofono is handling the same use cases as previously done by powerd.
Ricardo Salveti (rsalveti) wrote : | # |
Works fine as well.
- 144. By Andreas Pokorny
-
Trigger suspend on proximity events.
+ moved proximity handling to power-request.c
- 145. By Andreas Pokorny
-
Adds two new requets to enable and disable proximity based display blanking
instead of combining that behavior with a power state it is now a separate status. That way suspend logic remains unaffected by this.
Ricardo Salveti (rsalveti) wrote : | # |
As you added a new API, would it be possible to also change powerd-cli to support that?
- 146. By Andreas Pokorny
-
Adds an option to powerd-cli enable and disable proximty handling
this also fixes the missing dbus reponse.
Ricardo Salveti (rsalveti) wrote : | # |
Great, thanks!
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2014-08-18 21:33:32 +0000 | |||
3 | +++ CMakeLists.txt 2014-10-01 07:49:36 +0000 | |||
4 | @@ -53,6 +53,7 @@ | |||
5 | 53 | src/powerd-client.c | 53 | src/powerd-client.c |
6 | 54 | src/powerd-object.c | 54 | src/powerd-object.c |
7 | 55 | src/powerd-sensors.cpp | 55 | src/powerd-sensors.cpp |
8 | 56 | src/powerd-proximity.cpp | ||
9 | 56 | src/spline.c | 57 | src/spline.c |
10 | 57 | src/stats.c | 58 | src/stats.c |
11 | 58 | src/util.c | 59 | src/util.c |
12 | 59 | 60 | ||
13 | === modified file 'cli/powerd-cli.c' | |||
14 | --- cli/powerd-cli.c 2014-08-19 00:39:27 +0000 | |||
15 | +++ cli/powerd-cli.c 2014-10-01 07:49:36 +0000 | |||
16 | @@ -101,6 +101,32 @@ | |||
17 | 101 | } | 101 | } |
18 | 102 | 102 | ||
19 | 103 | gboolean | 103 | gboolean |
20 | 104 | requestProximityBlanking(gboolean enable) | ||
21 | 105 | { | ||
22 | 106 | GVariant *ret = NULL; | ||
23 | 107 | GError *error = NULL; | ||
24 | 108 | const char *method = enable ? | ||
25 | 109 | "enableProximityHandling": | ||
26 | 110 | "disableProximityHandling"; | ||
27 | 111 | |||
28 | 112 | ret = g_dbus_proxy_call_sync(powerd_proxy, | ||
29 | 113 | method, | ||
30 | 114 | g_variant_new("(s)", "powerd-cli"), | ||
31 | 115 | G_DBUS_CALL_FLAGS_NONE, | ||
32 | 116 | -1, | ||
33 | 117 | NULL, | ||
34 | 118 | &error); | ||
35 | 119 | if (ret == NULL) { | ||
36 | 120 | cli_warn("%s failed: %s", method, error->message); | ||
37 | 121 | g_error_free(error); | ||
38 | 122 | return FALSE; | ||
39 | 123 | } | ||
40 | 124 | |||
41 | 125 | g_variant_unref(ret); | ||
42 | 126 | return TRUE; | ||
43 | 127 | } | ||
44 | 128 | |||
45 | 129 | gboolean | ||
46 | 104 | requestSysState(const char *name, int state, | 130 | requestSysState(const char *name, int state, |
47 | 105 | powerd_cookie_t *cookie) | 131 | powerd_cookie_t *cookie) |
48 | 106 | { | 132 | { |
49 | @@ -691,6 +717,8 @@ | |||
50 | 691 | printf("client-test - test powerd registration / ack API.\n"); | 717 | printf("client-test - test powerd registration / ack API.\n"); |
51 | 692 | printf("display <on>\n"\ | 718 | printf("display <on>\n"\ |
52 | 693 | "\tMake the display stay on\n"); | 719 | "\tMake the display stay on\n"); |
53 | 720 | printf("proximity on|off\n"\ | ||
54 | 721 | "\tEnable disable proximity based screen blanking\n"); | ||
55 | 694 | printf("help\t- display this usage information.\n"); | 722 | printf("help\t- display this usage information.\n"); |
56 | 695 | printf("list\t- list outstanding requests.\n"); | 723 | printf("list\t- list outstanding requests.\n"); |
57 | 696 | printf("listen\t- listen for signals from powerd. This runs a\n"\ | 724 | printf("listen\t- listen for signals from powerd. This runs a\n"\ |
58 | @@ -732,6 +760,7 @@ | |||
59 | 732 | (strcmp(argv[1],"dbusnametest")) && | 760 | (strcmp(argv[1],"dbusnametest")) && |
60 | 733 | (strcmp(argv[1],"listen")) && | 761 | (strcmp(argv[1],"listen")) && |
61 | 734 | (strcmp(argv[1],"display")) && | 762 | (strcmp(argv[1],"display")) && |
62 | 763 | (strcmp(argv[1],"proximity")) && | ||
63 | 735 | (strcmp(argv[1],"help")) && | 764 | (strcmp(argv[1],"help")) && |
64 | 736 | (strcmp(argv[1],"clear-sys")) && | 765 | (strcmp(argv[1],"clear-sys")) && |
65 | 737 | (strcmp(argv[1],"client-test")) && | 766 | (strcmp(argv[1],"client-test")) && |
66 | @@ -821,6 +850,27 @@ | |||
67 | 821 | clearDisplayState(disp_cookie); | 850 | clearDisplayState(disp_cookie); |
68 | 822 | return 0; | 851 | return 0; |
69 | 823 | } | 852 | } |
70 | 853 | else if (!strcmp(argv[1],"proximity")) { | ||
71 | 854 | gboolean enable = TRUE; | ||
72 | 855 | if (argc != 3) { | ||
73 | 856 | fprintf(stderr,"proximity requires a parameter: 'on'|'off'\n"); | ||
74 | 857 | return -1; | ||
75 | 858 | } | ||
76 | 859 | if (!strcmp(argv[2],"on")) | ||
77 | 860 | enable = TRUE; | ||
78 | 861 | else if (!strcmp(argv[2],"off")) | ||
79 | 862 | enable = FALSE; | ||
80 | 863 | else { | ||
81 | 864 | fprintf(stderr,"proximity requires a parameter: 'on'|'off'\n"); | ||
82 | 865 | return -1; | ||
83 | 866 | } | ||
84 | 867 | |||
85 | 868 | if (requestProximityBlanking(enable) == FALSE) { | ||
86 | 869 | fprintf(stderr,"failed powerd proximity request\n"); | ||
87 | 870 | return -1; | ||
88 | 871 | } | ||
89 | 872 | return 0; | ||
90 | 873 | } | ||
91 | 824 | else if (!strncmp(argv[1],"clear",strlen("clear"))) { | 874 | else if (!strncmp(argv[1],"clear",strlen("clear"))) { |
92 | 825 | if (argc != 3) { | 875 | if (argc != 3) { |
93 | 826 | fprintf(stderr,"clear requires a cookie\n"); | 876 | fprintf(stderr,"clear requires a cookie\n"); |
94 | 827 | 877 | ||
95 | === modified file 'data/com.canonical.powerd.xml' | |||
96 | --- data/com.canonical.powerd.xml 2014-08-18 21:33:32 +0000 | |||
97 | +++ data/com.canonical.powerd.xml 2014-10-01 07:49:36 +0000 | |||
98 | @@ -20,6 +20,14 @@ | |||
99 | 20 | <arg type="s" name="cookie" direction="out" /> | 20 | <arg type="s" name="cookie" direction="out" /> |
100 | 21 | </method> | 21 | </method> |
101 | 22 | 22 | ||
102 | 23 | <method name="enableProximityHandling"> | ||
103 | 24 | <arg type="s" name="name" direction="in" /> | ||
104 | 25 | </method> | ||
105 | 26 | |||
106 | 27 | <method name="disableProximityHandling"> | ||
107 | 28 | <arg type="s" name="name" direction="in" /> | ||
108 | 29 | </method> | ||
109 | 30 | |||
110 | 23 | <method name="clearWakeup"> | 31 | <method name="clearWakeup"> |
111 | 24 | <arg type="s" name="cookie" direction="in" /> | 32 | <arg type="s" name="cookie" direction="in" /> |
112 | 25 | </method> | 33 | </method> |
113 | 26 | 34 | ||
114 | === modified file 'src/power-request.c' | |||
115 | --- src/power-request.c 2014-08-12 07:23:07 +0000 | |||
116 | +++ src/power-request.c 2014-10-01 07:49:36 +0000 | |||
117 | @@ -43,6 +43,7 @@ | |||
118 | 43 | const char *owner; | 43 | const char *owner; |
119 | 44 | uuid_t cookie; | 44 | uuid_t cookie; |
120 | 45 | enum SysPowerStates state; | 45 | enum SysPowerStates state; |
121 | 46 | int power_state_flags; | ||
122 | 46 | }; | 47 | }; |
123 | 47 | 48 | ||
124 | 48 | /* | 49 | /* |
125 | @@ -438,6 +439,7 @@ | |||
126 | 438 | if (ret) | 439 | if (ret) |
127 | 439 | powerd_warn("Failed to prepare for suspend: %d", ret); | 440 | powerd_warn("Failed to prepare for suspend: %d", ret); |
128 | 440 | } | 441 | } |
129 | 442 | |||
130 | 441 | ack_pending = powerd_client_transition_start(pending_system_state); | 443 | ack_pending = powerd_client_transition_start(pending_system_state); |
131 | 442 | powerd_sys_state_signal_emit(pending_system_state); | 444 | powerd_sys_state_signal_emit(pending_system_state); |
132 | 443 | 445 | ||
133 | @@ -523,7 +525,6 @@ | |||
134 | 523 | delayed_state_transition_process, | 525 | delayed_state_transition_process, |
135 | 524 | NULL); | 526 | NULL); |
136 | 525 | } | 527 | } |
137 | 526 | |||
138 | 527 | } | 528 | } |
139 | 528 | 529 | ||
140 | 529 | /* Must be called from main loop */ | 530 | /* Must be called from main loop */ |
141 | 530 | 531 | ||
142 | === modified file 'src/powerd-internal.h' | |||
143 | --- src/powerd-internal.h 2014-08-18 21:33:32 +0000 | |||
144 | +++ src/powerd-internal.h 2014-10-01 07:49:36 +0000 | |||
145 | @@ -97,6 +97,12 @@ | |||
146 | 97 | gboolean handle_clear_sys_state(PowerdSource *obj, | 97 | gboolean handle_clear_sys_state(PowerdSource *obj, |
147 | 98 | GDBusMethodInvocation *invocation, | 98 | GDBusMethodInvocation *invocation, |
148 | 99 | gchar *cookie); | 99 | gchar *cookie); |
149 | 100 | gboolean handle_enable_proximity_handling(PowerdSource *obj, | ||
150 | 101 | GDBusMethodInvocation *invocation, | ||
151 | 102 | const char *name); | ||
152 | 103 | gboolean handle_disable_proximity_handling(PowerdSource *obj, | ||
153 | 104 | GDBusMethodInvocation *invocation, | ||
154 | 105 | const char *name); | ||
155 | 100 | gboolean request_sys_state_internal(const char *name, int state, | 106 | gboolean request_sys_state_internal(const char *name, int state, |
156 | 101 | uuid_t *cookie, const char *owner); | 107 | uuid_t *cookie, const char *owner); |
157 | 102 | gboolean clear_sys_state_internal(uuid_t cookie); | 108 | gboolean clear_sys_state_internal(uuid_t cookie); |
158 | 103 | 109 | ||
159 | === modified file 'src/powerd-object.c' | |||
160 | --- src/powerd-object.c 2014-08-18 21:33:32 +0000 | |||
161 | +++ src/powerd-object.c 2014-10-01 07:49:36 +0000 | |||
162 | @@ -223,6 +223,10 @@ | |||
163 | 223 | G_CALLBACK(handle_clear_sys_state), powerd_source); | 223 | G_CALLBACK(handle_clear_sys_state), powerd_source); |
164 | 224 | g_signal_connect(oskel, "handle-list-sys-requests", | 224 | g_signal_connect(oskel, "handle-list-sys-requests", |
165 | 225 | G_CALLBACK(handle_list_sys_requests), powerd_source); | 225 | G_CALLBACK(handle_list_sys_requests), powerd_source); |
166 | 226 | g_signal_connect(oskel, "handle-enable-proximity-handling", | ||
167 | 227 | G_CALLBACK(handle_enable_proximity_handling), powerd_source); | ||
168 | 228 | g_signal_connect(oskel, "handle-disable-proximity-handling", | ||
169 | 229 | G_CALLBACK(handle_disable_proximity_handling), powerd_source); | ||
170 | 226 | 230 | ||
171 | 227 | g_signal_connect(oskel, "handle-register-client", | 231 | g_signal_connect(oskel, "handle-register-client", |
172 | 228 | G_CALLBACK(handle_register_client), powerd_source); | 232 | G_CALLBACK(handle_register_client), powerd_source); |
173 | @@ -343,35 +347,6 @@ | |||
174 | 343 | } | 347 | } |
175 | 344 | 348 | ||
176 | 345 | void | 349 | void |
177 | 346 | ofono_voicecall_proxy_connect_cb(GObject *source_object, | ||
178 | 347 | GAsyncResult *res, | ||
179 | 348 | gpointer user_data) | ||
180 | 349 | { | ||
181 | 350 | GError *error = NULL; | ||
182 | 351 | GDBusProxy *ofono_proxy; | ||
183 | 352 | struct call_data *call; | ||
184 | 353 | |||
185 | 354 | ofono_proxy = g_dbus_proxy_new_finish(res, &error); | ||
186 | 355 | if (error) { | ||
187 | 356 | powerd_warn("%s failed: %s", __func__, error->message); | ||
188 | 357 | g_error_free(error); | ||
189 | 358 | return; | ||
190 | 359 | } | ||
191 | 360 | |||
192 | 361 | call = user_data; | ||
193 | 362 | call->ofono_proxy = ofono_proxy; | ||
194 | 363 | |||
195 | 364 | /* Register for voicecall signals */ | ||
196 | 365 | g_signal_connect(ofono_proxy, "g-signal", | ||
197 | 366 | G_CALLBACK(on_ofono_voicecall_signal), NULL); | ||
198 | 367 | |||
199 | 368 | /* Get current voice call state */ | ||
200 | 369 | g_dbus_proxy_call(ofono_proxy, "GetProperties", NULL, | ||
201 | 370 | G_DBUS_CALL_FLAGS_NONE, -1, NULL, | ||
202 | 371 | ofono_voicecall_get_props_cb, NULL); | ||
203 | 372 | } | ||
204 | 373 | |||
205 | 374 | void | ||
206 | 375 | ofono_proxy_connect_cb(GObject *source_object, | 350 | ofono_proxy_connect_cb(GObject *source_object, |
207 | 376 | GAsyncResult *res, | 351 | GAsyncResult *res, |
208 | 377 | gpointer user_data) | 352 | gpointer user_data) |
209 | 378 | 353 | ||
210 | === added file 'src/powerd-proximity.cpp' | |||
211 | --- src/powerd-proximity.cpp 1970-01-01 00:00:00 +0000 | |||
212 | +++ src/powerd-proximity.cpp 2014-10-01 07:49:36 +0000 | |||
213 | @@ -0,0 +1,63 @@ | |||
214 | 1 | /* | ||
215 | 2 | * Copyright 2013 Canonical Ltd. | ||
216 | 3 | * | ||
217 | 4 | * This file is part of powerd. | ||
218 | 5 | * | ||
219 | 6 | * powerd is free software; you can redistribute it and/or modify | ||
220 | 7 | * it under the terms of the GNU General Public License as published by | ||
221 | 8 | * the Free Software Foundation; version 3. | ||
222 | 9 | * | ||
223 | 10 | * powerd is distributed in the hope that it will be useful, | ||
224 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
225 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
226 | 13 | * GNU General Public License for more details. | ||
227 | 14 | * | ||
228 | 15 | * You should have received a copy of the GNU General Public License | ||
229 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
230 | 17 | */ | ||
231 | 18 | |||
232 | 19 | |||
233 | 20 | #include "powerd-internal.h" | ||
234 | 21 | |||
235 | 22 | #include "libsuspend.h" | ||
236 | 23 | #include "powerd-dbus.h" | ||
237 | 24 | |||
238 | 25 | #include <unordered_set> | ||
239 | 26 | |||
240 | 27 | static std::unordered_set<std::string> active_proximity_users; | ||
241 | 28 | gboolean handle_enable_proximity_handling(PowerdSource *obj, | ||
242 | 29 | GDBusMethodInvocation *invocation, | ||
243 | 30 | const char *name) | ||
244 | 31 | { | ||
245 | 32 | if (active_proximity_users.empty()) | ||
246 | 33 | powerd_sensors_proximity_enable(); | ||
247 | 34 | active_proximity_users.insert(name); | ||
248 | 35 | |||
249 | 36 | g_dbus_method_invocation_return_value(invocation, NULL); | ||
250 | 37 | |||
251 | 38 | return TRUE; | ||
252 | 39 | } | ||
253 | 40 | |||
254 | 41 | |||
255 | 42 | gboolean handle_disable_proximity_handling(PowerdSource *obj, | ||
256 | 43 | GDBusMethodInvocation *invocation, | ||
257 | 44 | const char *name) | ||
258 | 45 | { | ||
259 | 46 | bool was_empty = active_proximity_users.empty(); | ||
260 | 47 | active_proximity_users.erase(name); | ||
261 | 48 | if (!was_empty && active_proximity_users.empty()) | ||
262 | 49 | powerd_sensors_proximity_disable(); | ||
263 | 50 | |||
264 | 51 | g_dbus_method_invocation_return_value(invocation, NULL); | ||
265 | 52 | |||
266 | 53 | return TRUE; | ||
267 | 54 | } | ||
268 | 55 | |||
269 | 56 | void powerd_proximity_event(gboolean near) | ||
270 | 57 | { | ||
271 | 58 | if (near) | ||
272 | 59 | turn_display_on(FALSE, UNITY_SCREEN_REASON_PROXIMITY); | ||
273 | 60 | else | ||
274 | 61 | turn_display_on(TRUE, UNITY_SCREEN_REASON_PROXIMITY); | ||
275 | 62 | } | ||
276 | 63 | |||
277 | 0 | 64 | ||
278 | === modified file 'src/powerd.cpp' | |||
279 | --- src/powerd.cpp 2014-08-19 20:22:10 +0000 | |||
280 | +++ src/powerd.cpp 2014-10-01 07:49:36 +0000 | |||
281 | @@ -92,31 +92,9 @@ | |||
282 | 92 | /* List with detected modems */ | 92 | /* List with detected modems */ |
283 | 93 | static GSList *g_modems = NULL; | 93 | static GSList *g_modems = NULL; |
284 | 94 | 94 | ||
285 | 95 | static void free_call_data(void *data) | ||
286 | 96 | { | ||
287 | 97 | struct call_data *call = (struct call_data *) data; | ||
288 | 98 | g_free(call->obj_name); | ||
289 | 99 | if (call->ofono_proxy) | ||
290 | 100 | g_object_unref(call->ofono_proxy); | ||
291 | 101 | } | ||
292 | 102 | |||
293 | 103 | static gint call_data_cmp(gconstpointer a, gconstpointer b) | ||
294 | 104 | { | ||
295 | 105 | const struct call_data *call = (const struct call_data *) a; | ||
296 | 106 | const char *call_name = (const char *) b; | ||
297 | 107 | |||
298 | 108 | return strcmp(call->obj_name, call_name); | ||
299 | 109 | } | ||
300 | 110 | |||
301 | 111 | static GDBusProxy *g_ofono_proxy; | 95 | static GDBusProxy *g_ofono_proxy; |
302 | 112 | static GDBusProxy *g_unity_proxy; | 96 | static GDBusProxy *g_unity_proxy; |
303 | 113 | 97 | ||
304 | 114 | /* List with existing calls */ | ||
305 | 115 | static GSList *g_calls = NULL; | ||
306 | 116 | |||
307 | 117 | /* Flag set when proximity sensor is on */ | ||
308 | 118 | static gboolean g_proximity_on = FALSE; | ||
309 | 119 | |||
310 | 120 | static struct power_module* _power_module; | 98 | static struct power_module* _power_module; |
311 | 121 | 99 | ||
312 | 122 | static void | 100 | static void |
313 | @@ -231,87 +209,6 @@ | |||
314 | 231 | g_variant_unref(result); | 209 | g_variant_unref(result); |
315 | 232 | } | 210 | } |
316 | 233 | 211 | ||
317 | 234 | static void notify_proximity_sensor(const char *call_state) | ||
318 | 235 | { | ||
319 | 236 | /* | ||
320 | 237 | * This function enables the proximity sensor in case the new state of the | ||
321 | 238 | * call is: | ||
322 | 239 | * | ||
323 | 240 | * Active - meaning, the call is in progress --> Proximity On | ||
324 | 241 | * Dialing - a signal made on outbound calls only which means that | ||
325 | 242 | * we have started to talk to the network, but the call has not | ||
326 | 243 | * been picked up. --> Proximity On (this signal is not | ||
327 | 244 | * sent on inbound calls) | ||
328 | 245 | * Note that the proximity sensor is not activated for "incoming" state | ||
329 | 246 | * For more details on states see voicecall-api.txt in the ofono source | ||
330 | 247 | */ | ||
331 | 248 | |||
332 | 249 | if (g_proximity_on) | ||
333 | 250 | return; | ||
334 | 251 | |||
335 | 252 | if (strcmp("active", call_state) == 0 | ||
336 | 253 | || strcmp("dialing", call_state) == 0) { | ||
337 | 254 | powerd_sensors_proximity_enable(); | ||
338 | 255 | g_proximity_on = TRUE; | ||
339 | 256 | } | ||
340 | 257 | } | ||
341 | 258 | |||
342 | 259 | static void deactivate_proximity_sensor(void) | ||
343 | 260 | { | ||
344 | 261 | if (!g_proximity_on) | ||
345 | 262 | return; | ||
346 | 263 | |||
347 | 264 | powerd_sensors_proximity_disable(); | ||
348 | 265 | g_proximity_on = FALSE; | ||
349 | 266 | } | ||
350 | 267 | |||
351 | 268 | |||
352 | 269 | void powerd_proximity_event(gboolean near) | ||
353 | 270 | { | ||
354 | 271 | if (near) | ||
355 | 272 | turn_display_on(FALSE, UNITY_SCREEN_REASON_PROXIMITY); | ||
356 | 273 | else | ||
357 | 274 | turn_display_on(TRUE, UNITY_SCREEN_REASON_PROXIMITY); | ||
358 | 275 | } | ||
359 | 276 | |||
360 | 277 | void | ||
361 | 278 | ofono_voicecall_get_props_cb(GObject *source_object, GAsyncResult *res, | ||
362 | 279 | gpointer user_data) | ||
363 | 280 | { | ||
364 | 281 | GDBusProxy *client = G_DBUS_PROXY(source_object); | ||
365 | 282 | GVariant *result; | ||
366 | 283 | GVariant *item; | ||
367 | 284 | GError *error = NULL; | ||
368 | 285 | GVariantIter *iter = NULL; | ||
369 | 286 | |||
370 | 287 | result = g_dbus_proxy_call_finish(client, res, &error); | ||
371 | 288 | if (result == NULL) { | ||
372 | 289 | powerd_warn("%s: call error", __func__); | ||
373 | 290 | return; | ||
374 | 291 | } | ||
375 | 292 | |||
376 | 293 | g_variant_get(result, "(a{sv})", &iter); | ||
377 | 294 | |||
378 | 295 | while ((item = g_variant_iter_next_value(iter))) { | ||
379 | 296 | GVariant *value = NULL; | ||
380 | 297 | const char *prop_name = NULL; | ||
381 | 298 | const char *call_state = NULL; | ||
382 | 299 | |||
383 | 300 | g_variant_get(item, "{&sv}", &prop_name, &value); | ||
384 | 301 | |||
385 | 302 | if (strcmp("State", prop_name) == 0) { | ||
386 | 303 | g_variant_get(value, "&s", &call_state); | ||
387 | 304 | notify_proximity_sensor(call_state); | ||
388 | 305 | powerd_info("GetProperties. Call State = %s", call_state); | ||
389 | 306 | } | ||
390 | 307 | |||
391 | 308 | g_variant_unref(value); | ||
392 | 309 | g_variant_unref(item); | ||
393 | 310 | } | ||
394 | 311 | |||
395 | 312 | g_variant_unref(result); | ||
396 | 313 | } | ||
397 | 314 | |||
398 | 315 | void on_ofono_manager_signal(GDBusProxy *proxy, gchar *sender_name, | 212 | void on_ofono_manager_signal(GDBusProxy *proxy, gchar *sender_name, |
399 | 316 | gchar *signal_name, GVariant *parameters, gpointer user_data) | 213 | gchar *signal_name, GVariant *parameters, gpointer user_data) |
400 | 317 | { | 214 | { |
401 | @@ -354,75 +251,13 @@ | |||
402 | 354 | GVariant *parameters, | 251 | GVariant *parameters, |
403 | 355 | gpointer user_data) | 252 | gpointer user_data) |
404 | 356 | { | 253 | { |
405 | 357 | GVariant *tmp; | ||
406 | 358 | |||
407 | 359 | if (!strcmp(signal_name, "CallAdded")) { | 254 | if (!strcmp(signal_name, "CallAdded")) { |
408 | 360 | struct call_data *call; | ||
409 | 361 | |||
410 | 362 | turn_display_on(TRUE, UNITY_SCREEN_REASON_NORMAL); | 255 | turn_display_on(TRUE, UNITY_SCREEN_REASON_NORMAL); |
411 | 363 | 256 | ||
431 | 364 | call = (struct call_data *) calloc(1, sizeof(*call)); | 257 | powerd_info("incoming call"); |
413 | 365 | tmp = g_variant_get_child_value(parameters, 0); | ||
414 | 366 | call->obj_name = g_variant_dup_string(tmp, NULL); | ||
415 | 367 | g_calls = g_slist_prepend(g_calls, call); | ||
416 | 368 | |||
417 | 369 | powerd_info("%s incoming call", call->obj_name); | ||
418 | 370 | |||
419 | 371 | /* Connect to voicecall interface */ | ||
420 | 372 | g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, | ||
421 | 373 | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, | ||
422 | 374 | NULL, | ||
423 | 375 | "org.ofono", | ||
424 | 376 | call->obj_name, | ||
425 | 377 | "org.ofono.VoiceCall", | ||
426 | 378 | NULL, | ||
427 | 379 | (GAsyncReadyCallback) ofono_voicecall_proxy_connect_cb, | ||
428 | 380 | call); | ||
429 | 381 | |||
430 | 382 | g_variant_unref(tmp); | ||
432 | 383 | 258 | ||
433 | 384 | } else if (!strcmp(signal_name, "CallRemoved")) { | 259 | } else if (!strcmp(signal_name, "CallRemoved")) { |
475 | 385 | const gchar *object_path; | 260 | powerd_info("call removed"); |
435 | 386 | GSList *node; | ||
436 | 387 | |||
437 | 388 | tmp = g_variant_get_child_value(parameters, 0); | ||
438 | 389 | object_path = g_variant_get_string(tmp, NULL); | ||
439 | 390 | node = g_slist_find_custom(g_calls, object_path, call_data_cmp); | ||
440 | 391 | if (node != NULL) { | ||
441 | 392 | free_call_data(node->data); | ||
442 | 393 | g_calls = g_slist_delete_link(g_calls, node); | ||
443 | 394 | powerd_info("%s call removed", object_path); | ||
444 | 395 | } | ||
445 | 396 | |||
446 | 397 | if (g_calls == NULL) | ||
447 | 398 | deactivate_proximity_sensor(); | ||
448 | 399 | |||
449 | 400 | g_variant_unref(tmp); | ||
450 | 401 | } | ||
451 | 402 | } | ||
452 | 403 | |||
453 | 404 | void | ||
454 | 405 | on_ofono_voicecall_signal (GDBusProxy *proxy, | ||
455 | 406 | gchar *sender_name, | ||
456 | 407 | gchar *signal_name, | ||
457 | 408 | GVariant *parameters, | ||
458 | 409 | gpointer user_data) | ||
459 | 410 | { | ||
460 | 411 | GVariant *value = NULL; | ||
461 | 412 | const char *prop_name = NULL; | ||
462 | 413 | const char *call_state = NULL; | ||
463 | 414 | |||
464 | 415 | if (!strcmp(signal_name, "PropertyChanged")) { | ||
465 | 416 | g_variant_get(parameters, "(&sv)", &prop_name, &value); | ||
466 | 417 | |||
467 | 418 | if (!strcmp(prop_name, "State")) { | ||
468 | 419 | g_variant_get(value, "&s", &call_state); | ||
469 | 420 | |||
470 | 421 | powerd_info("Call State = %s", call_state); | ||
471 | 422 | notify_proximity_sensor(call_state); | ||
472 | 423 | } | ||
473 | 424 | |||
474 | 425 | g_variant_unref(value); | ||
476 | 426 | } | 261 | } |
477 | 427 | } | 262 | } |
478 | 428 | 263 | ||
479 | @@ -608,7 +443,6 @@ | |||
480 | 608 | powerd_client_deinit(); | 443 | powerd_client_deinit(); |
481 | 609 | powerd_stats_deinit(); | 444 | powerd_stats_deinit(); |
482 | 610 | g_slist_free_full(g_modems, free_modem_data); | 445 | g_slist_free_full(g_modems, free_modem_data); |
483 | 611 | g_slist_free_full(g_calls, free_call_data); | ||
484 | 612 | if (g_ofono_proxy) | 446 | if (g_ofono_proxy) |
485 | 613 | g_object_unref(g_ofono_proxy); | 447 | g_object_unref(g_ofono_proxy); |
486 | 614 | if (g_unity_proxy) | 448 | if (g_unity_proxy) |
487 | 615 | 449 | ||
488 | === modified file 'src/powerd.h' | |||
489 | --- src/powerd.h 2014-05-21 03:17:03 +0000 | |||
490 | +++ src/powerd.h 2014-10-01 07:49:36 +0000 | |||
491 | @@ -30,11 +30,23 @@ | |||
492 | 30 | 30 | ||
493 | 31 | //The Active state will prevent system suspend | 31 | //The Active state will prevent system suspend |
494 | 32 | POWERD_SYS_STATE_ACTIVE, | 32 | POWERD_SYS_STATE_ACTIVE, |
495 | 33 | //Substate of Active with disabled proximity based blanking | ||
496 | 34 | POWERD_SYS_STATE_ACTIVE_BLANK_ON_PROXIMITY, | ||
497 | 33 | 35 | ||
498 | 34 | POWERD_NUM_POWER_STATES | 36 | POWERD_NUM_POWER_STATES |
499 | 35 | }; | 37 | }; |
500 | 36 | 38 | ||
501 | 37 | /* | 39 | /* |
502 | 40 | * Flags that can be applied to power states | ||
503 | 41 | * TODO Create dedicated power states instead? | ||
504 | 42 | */ | ||
505 | 43 | enum SysPowerStateFlags { | ||
506 | 44 | POWERD_POWER_STATE_FLAG_MASK = 0xFFFF0000, | ||
507 | 45 | // disables display blanking on proximity events | ||
508 | 46 | POWERD_DISABLE_PROXIMITY_SENSOR_BLANKING = 0x10000, | ||
509 | 47 | }; | ||
510 | 48 | |||
511 | 49 | /* | ||
512 | 38 | * Clients should treat this as an opaque type. Though this isn't really | 50 | * Clients should treat this as an opaque type. Though this isn't really |
513 | 39 | * possible until the client library is written. | 51 | * possible until the client library is written. |
514 | 40 | */ | 52 | */ |
PASSED: Continuous integration, rev:143 jenkins. qa.ubuntu. com/job/ powerd- ci/163/ jenkins. qa.ubuntu. com/job/ powerd- utopic- armhf-ci/ 15 jenkins. qa.ubuntu. com/job/ powerd- utopic- armhf-ci/ 15/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/powerd- ci/163/ rebuild
http://