Merge lp:~alfonsosanchezbeato/powerd/ofono-fixes into lp:powerd

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 117
Merged at revision: 121
Proposed branch: lp:~alfonsosanchezbeato/powerd/ofono-fixes
Merge into: lp:powerd
Diff against target: 586 lines (+370/-94)
4 files modified
src/display.c (+1/-1)
src/powerd-internal.h (+20/-2)
src/powerd-object.c (+60/-6)
src/powerd.cpp (+289/-85)
To merge this branch: bzr merge lp:~alfonsosanchezbeato/powerd/ofono-fixes
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Review via email: mp+212119@code.launchpad.net

Commit message

* Add support for multiple ofono modems (LP#1295085)
* Handle simultaneous voice calls (LP#1191033)
* Listen to ofono USSD signals

Description of the change

* Add support for multiple ofono modems (LP#1295085)
* Handle simultaneous voice calls (LP#1191033)
* Listen to ofono USSD signals

To post a comment you must log in.
Revision history for this message
Tony Espy (awe) wrote :

The overall changes look good to me.

That said, I've discussed with rsalveti and he said he'd claim the review, so I'll leave it to him to approve.

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

254 + /* Activate proximity sensor if no previously existing call */
255 + if (g_calls == NULL)
256 + if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
257 + powerd_warn("Request to use proximity sensor failed");

If you check the previous logic to enable/disable the proximity sensor, you'll see that it was only enabled when the call was in the active state, and not when the call was added in the ofono level. As a side effect, the proximity sensor is now enabled even before the call is active (the user accepts the call), which is a regression.

Please do a similar check, as we only want the proximity sensor to be enable when we have at least one active call in place.

review: Needs Fixing
115. By Alfonso Sanchez-Beato

Do not activate proximity sensor when calls are in "incoming" state

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

New commit takes state of the call into consideration for activating the proximity sensor. However, I have changed the logic a bit: previously, the sensor was activated when calls moved to either "alerting" or "active" states. Now I do it when the call reaches "dialing" or "active" state.

The rationale is as follows. Taking into account that the usual sequence of states of the calls is (not all transitions are considered):

Outgoing: dialing -> alerting -> active -> disconnected

Incoming: incoming -> active -> disconnected

then I think that it makes sense to activate the sensor when the state of an outgoing call is "dialing" instead of waiting for it to be "alerting", as most people once they press the call button they move their phone near to their ear immediately (while we are still dialing) so they can hear the other party ringing (move to alerting).

So the change makes sure the proximity sensor is off only when the state is "incoming": the user is supposed to be looking at the screen at that moment to decide whether to accept the call or not. We can discuss this further if you thing there is some problem with this.

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

> New commit takes state of the call into consideration for activating the
> proximity sensor. However, I have changed the logic a bit: previously, the
> sensor was activated when calls moved to either "alerting" or "active" states.
> Now I do it when the call reaches "dialing" or "active" state.
>
> The rationale is as follows. Taking into account that the usual sequence of
> states of the calls is (not all transitions are considered):
>
> Outgoing: dialing -> alerting -> active -> disconnected
>
> Incoming: incoming -> active -> disconnected
>
> then I think that it makes sense to activate the sensor when the state of an
> outgoing call is "dialing" instead of waiting for it to be "alerting", as most
> people once they press the call button they move their phone near to their ear
> immediately (while we are still dialing) so they can hear the other party
> ringing (move to alerting).
>
> So the change makes sure the proximity sensor is off only when the state is
> "incoming": the user is supposed to be looking at the screen at that moment to
> decide whether to accept the call or not. We can discuss this further if you
> thing there is some problem with this.

Makes sense, and it now behaves similarly as done in android.

Just a minor comment:
235 +ofono_get_modems_cb(GObject *source_object,
236 + GAsyncResult *res,
237 + gpointer user_data)
238 +{
239 + GDBusProxy *client = G_DBUS_PROXY(source_object);

Indentation here is different from the rest of the file, please change it to be similar to the rest.

Building and testing.

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

Tested and worked fine, can approve once the minor changes I asked in the previous comment are in place.

We already have a powerd landing slot in progress, once that lands, we can queue this MR.

116. By Alfonso Sanchez-Beato

Correct powerd.cpp indentations

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Indentations fixed. Just too used to ofono coding style...

How could I collapse the three commits of this MR, as can be done with "git rebase -i"?

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

> Indentations fixed. Just too used to ofono coding style...

Thanks!

> How could I collapse the three commits of this MR, as can be done with "git
> rebase -i"?

Don't worry about that, they will not show by default when checking the logs from the main branch. I wouldn't worry about rebase with bzr, as that's kind of a pita to do. Git is indeed *way* easier when rebasing commits.

Revision history for this message
Ricardo Salveti (rsalveti) :
review: Approve
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Actually, would you mind merging trunk back before I can land this MR?

117. By Alfonso Sanchez-Beato

Merge from main branch

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Trunk merged back.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/display.c'
--- src/display.c 2014-01-14 03:14:22 +0000
+++ src/display.c 2014-03-28 08:00:57 +0000
@@ -153,7 +153,7 @@
153 current_state = state;153 current_state = state;
154}154}
155155
156gboolean display_set_power_mode(int display, char *power_mode)156gboolean display_set_power_mode(int display, const char *power_mode)
157{157{
158 GError *error = NULL;158 GError *error = NULL;
159 GDBusProxy *unity_proxy = NULL;159 GDBusProxy *unity_proxy = NULL;
160160
=== modified file 'src/powerd-internal.h'
--- src/powerd-internal.h 2014-01-14 03:14:22 +0000
+++ src/powerd-internal.h 2014-03-28 08:00:57 +0000
@@ -51,6 +51,12 @@
51 uint ref_count;51 uint ref_count;
52};52};
5353
54/* Used to track call state */
55struct call_data {
56 char *obj_name;
57 GDBusProxy *ofono_proxy;
58};
59
54void powerd_shutdown(void);60void powerd_shutdown(void);
55void powerd_exit(int exit_code);61void powerd_exit(int exit_code);
56void powerd_hal_signal_activity(void);62void powerd_hal_signal_activity(void);
@@ -80,7 +86,7 @@
80/* Display functions */86/* Display functions */
81void powerd_brightness_set_value(gint value);87void powerd_brightness_set_value(gint value);
82gboolean powerd_display_enabled(void);88gboolean powerd_display_enabled(void);
83gboolean display_set_power_mode(int display, char *powerd_mode);89gboolean display_set_power_mode(int display, const char *powerd_mode);
84void powerd_set_display_state(struct powerd_display_request *req);90void powerd_set_display_state(struct powerd_display_request *req);
85int powerd_display_init(void);91int powerd_display_init(void);
86void powerd_proximity_event(gboolean near);92void powerd_proximity_event(gboolean near);
@@ -153,16 +159,28 @@
153 gpointer user_data);159 gpointer user_data);
154void powerd_name_vanished_cb(GDBusConnection *connection, const gchar *name,160void powerd_name_vanished_cb(GDBusConnection *connection, const gchar *name,
155 gpointer user_data);161 gpointer user_data);
162void ofono_get_modems_cb(GObject *source_object, GAsyncResult *res,
163 gpointer user_data);
164void ofono_voicecall_get_props_cb(GObject *source_object, GAsyncResult *res,
165 gpointer user_data);
156166
157/* dbus signal handlers */167/* dbus signal handlers */
168void on_ofono_manager_signal(GDBusProxy *proxy, gchar *sender_name,
169 gchar *signal_name, GVariant *parameters, gpointer user_data);
170void on_ofono_voicecall_signal(GDBusProxy *proxy, gchar *sender_name,
171 gchar *signal_name, GVariant *parameters, gpointer user_data);
158void on_ofono_voicecallmanager_signal(GDBusProxy *proxy, gchar *sender_name,172void on_ofono_voicecallmanager_signal(GDBusProxy *proxy, gchar *sender_name,
159 gchar *signal_name, GVariant *parameters, gpointer user_data);173 gchar *signal_name, GVariant *parameters, gpointer user_data);
160void on_ofono_messagemanager_signal(GDBusProxy *proxy, gchar *sender_name,174void on_ofono_messagemanager_signal(GDBusProxy *proxy, gchar *sender_name,
161 gchar *signal_name, GVariant *parameters, gpointer user_data);175 gchar *signal_name, GVariant *parameters, gpointer user_data);
162void on_ofono_voicecall_signal(GDBusProxy *proxy, gchar *sender_name,176void on_ofono_ussd_signal(GDBusProxy *proxy, gchar *sender_name,
163 gchar *signal_name, GVariant *parameters, gpointer user_data);177 gchar *signal_name, GVariant *parameters, gpointer user_data);
164178
165/* dbus proxy async setup */179/* dbus proxy async setup */
180void ofono_manager_proxy_connect_cb(GObject *source_object, GAsyncResult *res,
181 gpointer user_data);
182void ofono_voicecall_proxy_connect_cb(GObject *source_object, GAsyncResult *res,
183 gpointer user_data);
166void ofono_proxy_connect_cb(GObject *source_object, GAsyncResult *res,184void ofono_proxy_connect_cb(GObject *source_object, GAsyncResult *res,
167 gpointer user_data);185 gpointer user_data);
168186
169187
=== modified file 'src/powerd-object.c'
--- src/powerd-object.c 2013-09-12 14:23:02 +0000
+++ src/powerd-object.c 2014-03-28 08:00:57 +0000
@@ -259,6 +259,60 @@
259}259}
260260
261void261void
262ofono_manager_proxy_connect_cb(GObject *source_object,
263 GAsyncResult *res,
264 gpointer user_data)
265{
266 GError *error = NULL;
267 GDBusProxy *ofono_proxy;
268
269 ofono_proxy = g_dbus_proxy_new_finish(res, &error);
270 if (error) {
271 powerd_warn("%s failed: %s", __func__, error->message);
272 g_error_free(error);
273 return;
274 }
275
276 /* Register for insertion and removal of modems */
277 g_signal_connect(ofono_proxy, "g-signal",
278 G_CALLBACK(on_ofono_manager_signal), NULL);
279
280 /* Get current modems */
281 g_dbus_proxy_call(ofono_proxy, "GetModems", NULL,
282 G_DBUS_CALL_FLAGS_NONE, -1, NULL,
283 ofono_get_modems_cb, NULL);
284}
285
286void
287ofono_voicecall_proxy_connect_cb(GObject *source_object,
288 GAsyncResult *res,
289 gpointer user_data)
290{
291 GError *error = NULL;
292 GDBusProxy *ofono_proxy;
293 struct call_data *call;
294
295 ofono_proxy = g_dbus_proxy_new_finish(res, &error);
296 if (error) {
297 powerd_warn("%s failed: %s", __func__, error->message);
298 g_error_free(error);
299 return;
300 }
301
302 call = user_data;
303 call->ofono_proxy = ofono_proxy;
304
305 /* Register for voicecall signals */
306 g_signal_connect(ofono_proxy, "g-signal",
307 G_CALLBACK(on_ofono_voicecall_signal), NULL);
308
309 /* Get current voice call state */
310 g_dbus_proxy_call(ofono_proxy, "GetProperties", NULL,
311 G_DBUS_CALL_FLAGS_NONE, -1, NULL,
312 ofono_voicecall_get_props_cb, NULL);
313}
314
315void
262ofono_proxy_connect_cb(GObject *source_object,316ofono_proxy_connect_cb(GObject *source_object,
263 GAsyncResult *res,317 GAsyncResult *res,
264 gpointer user_data)318 gpointer user_data)
@@ -275,18 +329,18 @@
275 else {329 else {
276 interface_name = g_dbus_proxy_get_interface_name(ofono_proxy);330 interface_name = g_dbus_proxy_get_interface_name(ofono_proxy);
277 powerd_debug("ofono_proxy_connect_cb: proxy is %s", interface_name);331 powerd_debug("ofono_proxy_connect_cb: proxy is %s", interface_name);
278 if (!strcmp(interface_name,"org.ofono.VoiceCall")) {332 if (!strcmp(interface_name, "org.ofono.VoiceCallManager")) {
279 g_signal_connect(ofono_proxy, "g-signal",
280 G_CALLBACK (on_ofono_voicecall_signal), NULL);
281 }
282 else if (!strcmp(interface_name,"org.ofono.VoiceCallManager")) {
283 g_signal_connect(ofono_proxy, "g-signal",333 g_signal_connect(ofono_proxy, "g-signal",
284 G_CALLBACK (on_ofono_voicecallmanager_signal), NULL);334 G_CALLBACK (on_ofono_voicecallmanager_signal), NULL);
285 }335 }
286 else if (!strcmp(interface_name,"org.ofono.MessageManager")) {336 else if (!strcmp(interface_name, "org.ofono.MessageManager")) {
287 g_signal_connect(ofono_proxy, "g-signal",337 g_signal_connect(ofono_proxy, "g-signal",
288 G_CALLBACK (on_ofono_messagemanager_signal), NULL);338 G_CALLBACK (on_ofono_messagemanager_signal), NULL);
289 }339 }
340 else if (!strcmp(interface_name, "org.ofono.SupplementaryServices")) {
341 g_signal_connect(ofono_proxy, "g-signal",
342 G_CALLBACK (on_ofono_ussd_signal), NULL);
343 }
290 else {344 else {
291 powerd_warn("unknown interface name for this proxy, ignoring");345 powerd_warn("unknown interface name for this proxy, ignoring");
292 }346 }
293347
=== modified file 'src/powerd.cpp'
--- src/powerd.cpp 2014-03-27 21:00:43 +0000
+++ src/powerd.cpp 2014-03-28 08:00:57 +0000
@@ -125,6 +125,31 @@
125 POWERD_DISPLAY_FLAG_BRIGHT /* flags */125 POWERD_DISPLAY_FLAG_BRIGHT /* flags */
126};126};
127127
128/* List with detected modems */
129static GSList *g_modems = NULL;
130
131static void free_call_data(void *data)
132{
133 struct call_data *call = (struct call_data *) data;
134 g_free(call->obj_name);
135 if (call->ofono_proxy)
136 g_object_unref(call->ofono_proxy);
137}
138
139static gint call_data_cmp(gconstpointer a, gconstpointer b)
140{
141 const struct call_data *call = (const struct call_data *) a;
142 const char *call_name = (const char *) b;
143
144 return strcmp(call->obj_name, call_name);
145}
146
147/* List with existing calls */
148static GSList *g_calls = NULL;
149
150/* Flag set when proximity sensor is on */
151static gboolean g_proximity_on = FALSE;
152
128gboolean activity_monitor(gpointer data);153gboolean activity_monitor(gpointer data);
129void update_screen_state(int state);154void update_screen_state(int state);
130155
@@ -294,6 +319,184 @@
294 powerd_reset_activity_timer(1);319 powerd_reset_activity_timer(1);
295}320}
296321
322static void watch_modem(const char *modem)
323{
324 /* for incoming SMS signals */
325 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
326 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
327 NULL,
328 "org.ofono",
329 modem,
330 "org.ofono.MessageManager",
331 NULL,
332 (GAsyncReadyCallback)ofono_proxy_connect_cb,
333 NULL);
334
335 /* for incoming calls Added/Removed signals */
336 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
337 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
338 NULL,
339 "org.ofono",
340 modem,
341 "org.ofono.VoiceCallManager",
342 NULL,
343 (GAsyncReadyCallback)ofono_proxy_connect_cb,
344 NULL);
345
346 /* for USSD notifications/network requests */
347 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
348 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
349 NULL,
350 "org.ofono",
351 modem,
352 "org.ofono.SupplementaryServices",
353 NULL,
354 (GAsyncReadyCallback)ofono_proxy_connect_cb,
355 NULL);
356}
357
358void
359ofono_get_modems_cb(GObject *source_object,
360 GAsyncResult *res,
361 gpointer user_data)
362{
363 GDBusProxy *client = G_DBUS_PROXY(source_object);
364 GVariant *result;
365 GVariant *item;
366 GError *error = NULL;
367 GVariantIter *iter;
368
369 result = g_dbus_proxy_call_finish(client, res, &error);
370 if (result == NULL) {
371 powerd_warn("%s: call error", __func__);
372 return;
373 }
374
375 g_variant_get(result, "(a(oa{sv}))", &iter);
376 while ((item = g_variant_iter_next_value(iter))) {
377 const char *obj_path;
378
379 g_variant_get_child(item, 0, "&o", &obj_path);
380
381 if (g_slist_find_custom(g_modems, obj_path, (GCompareFunc) strcmp)
382 == NULL) {
383 powerd_debug("active ofono modem %s", obj_path);
384 g_modems = g_slist_prepend(g_modems, g_strdup(obj_path));
385 watch_modem(obj_path);
386 }
387
388 g_variant_unref(item);
389 }
390
391 g_variant_unref(result);
392}
393
394static void notify_proximity_sensor(const char *call_state)
395{
396 /*
397 * This function enables the proximity sensor in case the new state of the
398 * call is:
399 *
400 * Active - meaning, the call is in progress --> Proximity On
401 * Dialing - a signal made on outbound calls only which means that
402 * we have started to talk to the network, but the call has not
403 * been picked up. --> Proximity On (this signal is not
404 * sent on inbound calls)
405 * Note that the proximity sensor is not activated for "incoming" state
406 * For more details on states see voicecall-api.txt in the ofono source
407 */
408
409 if (g_proximity_on)
410 return;
411
412 if (strcmp("active", call_state) == 0
413 || strcmp("dialing", call_state) == 0) {
414 if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
415 powerd_warn("Request to use proximity sensor failed");
416 g_proximity_on = TRUE;
417 }
418}
419
420static void deactivate_proximity_sensor(void)
421{
422 if (!g_proximity_on)
423 return;
424
425 powerd_remove_display_request(prox_sensor_req.cookie);
426 g_proximity_on = FALSE;
427}
428
429void
430ofono_voicecall_get_props_cb(GObject *source_object, GAsyncResult *res,
431 gpointer user_data)
432{
433 GDBusProxy *client = G_DBUS_PROXY(source_object);
434 GVariant *result;
435 GVariant *item;
436 GError *error = NULL;
437 GVariantIter *iter = NULL;
438
439 result = g_dbus_proxy_call_finish(client, res, &error);
440 if (result == NULL) {
441 powerd_warn("%s: call error", __func__);
442 return;
443 }
444
445 g_variant_get(result, "(a{sv})", &iter);
446
447 while ((item = g_variant_iter_next_value(iter))) {
448 GVariant *value = NULL;
449 const char *prop_name = NULL;
450 const char *call_state = NULL;
451
452 g_variant_get(item, "{&sv}", &prop_name, &value);
453
454 if (strcmp("State", prop_name) == 0) {
455 g_variant_get(value, "&s", &call_state);
456 notify_proximity_sensor(call_state);
457 powerd_info("GetProperties. Call State = %s", call_state);
458 }
459
460 g_variant_unref(value);
461 g_variant_unref(item);
462 }
463
464 g_variant_unref(result);
465}
466
467void on_ofono_manager_signal(GDBusProxy *proxy, gchar *sender_name,
468 gchar *signal_name, GVariant *parameters, gpointer user_data)
469{
470 const gchar *object_path;
471 GVariant *tmp;
472 char *modem;
473 GSList *node;
474
475 tmp = g_variant_get_child_value(parameters, 0);
476
477 object_path = g_variant_get_string(tmp, NULL);
478 node = g_slist_find_custom(g_modems, object_path, (GCompareFunc) strcmp);
479
480 if (strcmp("ModemAdded", signal_name) == 0) {
481 /* Add if not already in list */
482 if (node == NULL) {
483 powerd_debug("watching ofono modem %s", object_path);
484 modem = g_strdup(object_path);
485 g_modems = g_slist_prepend(g_modems, modem);
486 watch_modem(modem);
487 }
488 } else if(strcmp("ModemRemoved", signal_name) == 0) {
489 /* Remove if found in list */
490 if (node != NULL) {
491 powerd_debug("stop watch on ofono modem %s", object_path);
492 g_free(g_modems->data);
493 g_modems = g_slist_delete_link(g_modems, node);
494 }
495 }
496
497 g_variant_unref(tmp);
498}
499
297void500void
298on_ofono_voicecallmanager_signal (GDBusProxy *proxy,501on_ofono_voicecallmanager_signal (GDBusProxy *proxy,
299 gchar *sender_name,502 gchar *sender_name,
@@ -301,12 +504,76 @@
301 GVariant *parameters,504 GVariant *parameters,
302 gpointer user_data)505 gpointer user_data)
303{506{
304 powerd_debug("we get signal from %s: %s", sender_name, signal_name);507 GVariant *tmp;
305 /* from org.ofono.VoiceCallManager - a call was added */508
306 if (!strcmp(signal_name, "CallAdded")) {509 if (!strcmp(signal_name, "CallAdded")) {
307 powerd_debug("Waking up the device - Incoming Call");510 struct call_data *call;
511
308 powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);512 powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
309 powerd_reset_activity_timer(1);513 powerd_reset_activity_timer(1);
514
515 call = (struct call_data *) calloc(1, sizeof(*call));
516 tmp = g_variant_get_child_value(parameters, 0);
517 call->obj_name = g_variant_dup_string(tmp, NULL);
518 g_calls = g_slist_prepend(g_calls, call);
519
520 powerd_info("%s incoming call", call->obj_name);
521
522 /* Connect to voicecall interface */
523 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
524 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
525 NULL,
526 "org.ofono",
527 call->obj_name,
528 "org.ofono.VoiceCall",
529 NULL,
530 (GAsyncReadyCallback) ofono_voicecall_proxy_connect_cb,
531 call);
532
533 g_variant_unref(tmp);
534
535 } else if (!strcmp(signal_name, "CallRemoved")) {
536 const gchar *object_path;
537 GSList *node;
538
539 tmp = g_variant_get_child_value(parameters, 0);
540 object_path = g_variant_get_string(tmp, NULL);
541 node = g_slist_find_custom(g_calls, object_path, call_data_cmp);
542 if (node != NULL) {
543 free_call_data(node->data);
544 g_calls = g_slist_delete_link(g_calls, node);
545 powerd_info("%s call removed", object_path);
546 }
547
548 if (g_calls == NULL)
549 deactivate_proximity_sensor();
550
551 g_variant_unref(tmp);
552 }
553}
554
555void
556on_ofono_voicecall_signal (GDBusProxy *proxy,
557 gchar *sender_name,
558 gchar *signal_name,
559 GVariant *parameters,
560 gpointer user_data)
561{
562 GVariant *value = NULL;
563 const char *prop_name = NULL;
564 const char *call_state = NULL;
565
566 if (!strcmp(signal_name, "PropertyChanged")) {
567 g_variant_get(parameters, "(&sv)", &prop_name, &value);
568
569 if (!strcmp(prop_name, "State")) {
570 g_variant_get(value, "&s", &call_state);
571
572 powerd_info("Call State = %s", call_state);
573 notify_proximity_sensor(call_state);
574 }
575
576 g_variant_unref(value);
310 }577 }
311}578}
312579
@@ -327,63 +594,19 @@
327 }594 }
328}595}
329596
330void597void on_ofono_ussd_signal(GDBusProxy *proxy,
331on_ofono_voicecall_signal (GDBusProxy *proxy,
332 gchar *sender_name,598 gchar *sender_name,
333 gchar *signal_name,599 gchar *signal_name,
334 GVariant *parameters,600 GVariant *parameters,
335 gpointer user_data)601 gpointer user_data)
336{602{
337 GVariant *value = NULL;
338 const char *prop_name;
339 const char *prop_value;
340 static gboolean alerted = FALSE;
341
342 powerd_debug("we get signal from %s: %s", sender_name, signal_name);603 powerd_debug("we get signal from %s: %s", sender_name, signal_name);
343604 /* from org.ofono.MessageManager */
344 /* This function enables and disables the proximity sensor based605 if ((!strcmp(signal_name, "NotificationReceived")) ||
345 * on the state of the call.606 (!strcmp(signal_name, "RequestReceived"))) {
346 *607 powerd_debug("Waking up the device - Incoming USSD");
347 * Active - meaning, the call is in progress --> Proximity On608 powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
348 * Alerting - a signal made on outbound calls only which means that609 powerd_reset_activity_timer(1);
349 * the phone is ringing on the other side, but has not
350 * been picked up. --> Proximity On (this signal is not
351 * sent on inbound calls)
352 * Disconnected - the call is over. --> Proximity Off.
353 *
354 * For more details on states see voicecall-api.txt in the ofono source
355 */
356
357 /* Note: As of June 13, 2013, the phone cannot successfully
358 * accept a call while another call is in progress. When this is fixed
359 * the code below will need to be rewritten to handle multiple
360 * active/disconnected signals. LP: #1191033 (mfisch) */
361
362 if (!strcmp(signal_name, "PropertyChanged")) {
363 g_variant_get(parameters, "(&sv)", &prop_name, &value);
364 if (!strcmp(prop_name,"State")) {
365 g_variant_get(value, "&s", &prop_value);
366 powerd_debug("Call State = %s", prop_value);
367 if (!strcmp(prop_value,"active")) {
368 if (!alerted) {
369 //call is active, enable sensor
370 if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
371 powerd_warn("Request to use proximity sensor failed");
372 }
373 }
374 if (!strcmp(prop_value,"alerting")) {
375 alerted = TRUE;
376 //call is altering, enable sensor
377 if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
378 powerd_warn("Request to use proximity sensor failed");
379 }
380 else if (!strcmp(prop_value,"disconnected")) {
381 alerted = FALSE;
382 //call is disconnected, disable sensor
383 powerd_remove_display_request(prox_sensor_req.cookie);
384 }
385 g_variant_unref(value);
386 }
387 }610 }
388}611}
389612
@@ -445,37 +668,15 @@
445 powerd_name_acquired_cb, powerd_name_lost_cb, NULL, NULL);668 powerd_name_acquired_cb, powerd_name_lost_cb, NULL, NULL);
446 powerd_debug("owner id: %u", name_id);669 powerd_debug("owner id: %u", name_id);
447670
448 /* for incoming SMS signals */671 /* Listen to modem creation */
449 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,672 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
450 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,673 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
451 NULL,674 NULL,
452 "org.ofono",675 "org.ofono",
453 "/ril_0",676 "/",
454 "org.ofono.MessageManager",677 "org.ofono.Manager",
455 NULL,678 NULL,
456 (GAsyncReadyCallback)ofono_proxy_connect_cb,679 (GAsyncReadyCallback) ofono_manager_proxy_connect_cb,
457 NULL);
458
459 /* for incoming calls Added/Removed signals */
460 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
461 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
462 NULL,
463 "org.ofono",
464 "/ril_0",
465 "org.ofono.VoiceCallManager",
466 NULL,
467 (GAsyncReadyCallback)ofono_proxy_connect_cb,
468 NULL);
469
470 /* for answering a call/hanging up signals */
471 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
472 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
473 NULL,
474 "org.ofono",
475 "/ril_0/voicecall01",
476 "org.ofono.VoiceCall",
477 NULL,
478 (GAsyncReadyCallback)ofono_proxy_connect_cb,
479 NULL);680 NULL);
480681
481 /* Init this first, data is used by other inits */682 /* Init this first, data is used by other inits */
@@ -547,5 +748,8 @@
547 power_request_deinit();748 power_request_deinit();
548 powerd_client_deinit();749 powerd_client_deinit();
549 powerd_stats_deinit();750 powerd_stats_deinit();
751 g_slist_free_full(g_modems, g_free);
752 g_slist_free_full(g_calls, free_call_data);
753
550 return g_exit_code;754 return g_exit_code;
551}755}

Subscribers

People subscribed via source and target branches