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
1=== modified file 'src/display.c'
2--- src/display.c 2014-01-14 03:14:22 +0000
3+++ src/display.c 2014-03-28 08:00:57 +0000
4@@ -153,7 +153,7 @@
5 current_state = state;
6 }
7
8-gboolean display_set_power_mode(int display, char *power_mode)
9+gboolean display_set_power_mode(int display, const char *power_mode)
10 {
11 GError *error = NULL;
12 GDBusProxy *unity_proxy = NULL;
13
14=== modified file 'src/powerd-internal.h'
15--- src/powerd-internal.h 2014-01-14 03:14:22 +0000
16+++ src/powerd-internal.h 2014-03-28 08:00:57 +0000
17@@ -51,6 +51,12 @@
18 uint ref_count;
19 };
20
21+/* Used to track call state */
22+struct call_data {
23+ char *obj_name;
24+ GDBusProxy *ofono_proxy;
25+};
26+
27 void powerd_shutdown(void);
28 void powerd_exit(int exit_code);
29 void powerd_hal_signal_activity(void);
30@@ -80,7 +86,7 @@
31 /* Display functions */
32 void powerd_brightness_set_value(gint value);
33 gboolean powerd_display_enabled(void);
34-gboolean display_set_power_mode(int display, char *powerd_mode);
35+gboolean display_set_power_mode(int display, const char *powerd_mode);
36 void powerd_set_display_state(struct powerd_display_request *req);
37 int powerd_display_init(void);
38 void powerd_proximity_event(gboolean near);
39@@ -153,16 +159,28 @@
40 gpointer user_data);
41 void powerd_name_vanished_cb(GDBusConnection *connection, const gchar *name,
42 gpointer user_data);
43+void ofono_get_modems_cb(GObject *source_object, GAsyncResult *res,
44+ gpointer user_data);
45+void ofono_voicecall_get_props_cb(GObject *source_object, GAsyncResult *res,
46+ gpointer user_data);
47
48 /* dbus signal handlers */
49+void on_ofono_manager_signal(GDBusProxy *proxy, gchar *sender_name,
50+ gchar *signal_name, GVariant *parameters, gpointer user_data);
51+void on_ofono_voicecall_signal(GDBusProxy *proxy, gchar *sender_name,
52+ gchar *signal_name, GVariant *parameters, gpointer user_data);
53 void on_ofono_voicecallmanager_signal(GDBusProxy *proxy, gchar *sender_name,
54 gchar *signal_name, GVariant *parameters, gpointer user_data);
55 void on_ofono_messagemanager_signal(GDBusProxy *proxy, gchar *sender_name,
56 gchar *signal_name, GVariant *parameters, gpointer user_data);
57-void on_ofono_voicecall_signal(GDBusProxy *proxy, gchar *sender_name,
58+void on_ofono_ussd_signal(GDBusProxy *proxy, gchar *sender_name,
59 gchar *signal_name, GVariant *parameters, gpointer user_data);
60
61 /* dbus proxy async setup */
62+void ofono_manager_proxy_connect_cb(GObject *source_object, GAsyncResult *res,
63+ gpointer user_data);
64+void ofono_voicecall_proxy_connect_cb(GObject *source_object, GAsyncResult *res,
65+ gpointer user_data);
66 void ofono_proxy_connect_cb(GObject *source_object, GAsyncResult *res,
67 gpointer user_data);
68
69
70=== modified file 'src/powerd-object.c'
71--- src/powerd-object.c 2013-09-12 14:23:02 +0000
72+++ src/powerd-object.c 2014-03-28 08:00:57 +0000
73@@ -259,6 +259,60 @@
74 }
75
76 void
77+ofono_manager_proxy_connect_cb(GObject *source_object,
78+ GAsyncResult *res,
79+ gpointer user_data)
80+{
81+ GError *error = NULL;
82+ GDBusProxy *ofono_proxy;
83+
84+ ofono_proxy = g_dbus_proxy_new_finish(res, &error);
85+ if (error) {
86+ powerd_warn("%s failed: %s", __func__, error->message);
87+ g_error_free(error);
88+ return;
89+ }
90+
91+ /* Register for insertion and removal of modems */
92+ g_signal_connect(ofono_proxy, "g-signal",
93+ G_CALLBACK(on_ofono_manager_signal), NULL);
94+
95+ /* Get current modems */
96+ g_dbus_proxy_call(ofono_proxy, "GetModems", NULL,
97+ G_DBUS_CALL_FLAGS_NONE, -1, NULL,
98+ ofono_get_modems_cb, NULL);
99+}
100+
101+void
102+ofono_voicecall_proxy_connect_cb(GObject *source_object,
103+ GAsyncResult *res,
104+ gpointer user_data)
105+{
106+ GError *error = NULL;
107+ GDBusProxy *ofono_proxy;
108+ struct call_data *call;
109+
110+ ofono_proxy = g_dbus_proxy_new_finish(res, &error);
111+ if (error) {
112+ powerd_warn("%s failed: %s", __func__, error->message);
113+ g_error_free(error);
114+ return;
115+ }
116+
117+ call = user_data;
118+ call->ofono_proxy = ofono_proxy;
119+
120+ /* Register for voicecall signals */
121+ g_signal_connect(ofono_proxy, "g-signal",
122+ G_CALLBACK(on_ofono_voicecall_signal), NULL);
123+
124+ /* Get current voice call state */
125+ g_dbus_proxy_call(ofono_proxy, "GetProperties", NULL,
126+ G_DBUS_CALL_FLAGS_NONE, -1, NULL,
127+ ofono_voicecall_get_props_cb, NULL);
128+}
129+
130+void
131 ofono_proxy_connect_cb(GObject *source_object,
132 GAsyncResult *res,
133 gpointer user_data)
134@@ -275,18 +329,18 @@
135 else {
136 interface_name = g_dbus_proxy_get_interface_name(ofono_proxy);
137 powerd_debug("ofono_proxy_connect_cb: proxy is %s", interface_name);
138- if (!strcmp(interface_name,"org.ofono.VoiceCall")) {
139- g_signal_connect(ofono_proxy, "g-signal",
140- G_CALLBACK (on_ofono_voicecall_signal), NULL);
141- }
142- else if (!strcmp(interface_name,"org.ofono.VoiceCallManager")) {
143+ if (!strcmp(interface_name, "org.ofono.VoiceCallManager")) {
144 g_signal_connect(ofono_proxy, "g-signal",
145 G_CALLBACK (on_ofono_voicecallmanager_signal), NULL);
146 }
147- else if (!strcmp(interface_name,"org.ofono.MessageManager")) {
148+ else if (!strcmp(interface_name, "org.ofono.MessageManager")) {
149 g_signal_connect(ofono_proxy, "g-signal",
150 G_CALLBACK (on_ofono_messagemanager_signal), NULL);
151 }
152+ else if (!strcmp(interface_name, "org.ofono.SupplementaryServices")) {
153+ g_signal_connect(ofono_proxy, "g-signal",
154+ G_CALLBACK (on_ofono_ussd_signal), NULL);
155+ }
156 else {
157 powerd_warn("unknown interface name for this proxy, ignoring");
158 }
159
160=== modified file 'src/powerd.cpp'
161--- src/powerd.cpp 2014-03-27 21:00:43 +0000
162+++ src/powerd.cpp 2014-03-28 08:00:57 +0000
163@@ -125,6 +125,31 @@
164 POWERD_DISPLAY_FLAG_BRIGHT /* flags */
165 };
166
167+/* List with detected modems */
168+static GSList *g_modems = NULL;
169+
170+static void free_call_data(void *data)
171+{
172+ struct call_data *call = (struct call_data *) data;
173+ g_free(call->obj_name);
174+ if (call->ofono_proxy)
175+ g_object_unref(call->ofono_proxy);
176+}
177+
178+static gint call_data_cmp(gconstpointer a, gconstpointer b)
179+{
180+ const struct call_data *call = (const struct call_data *) a;
181+ const char *call_name = (const char *) b;
182+
183+ return strcmp(call->obj_name, call_name);
184+}
185+
186+/* List with existing calls */
187+static GSList *g_calls = NULL;
188+
189+/* Flag set when proximity sensor is on */
190+static gboolean g_proximity_on = FALSE;
191+
192 gboolean activity_monitor(gpointer data);
193 void update_screen_state(int state);
194
195@@ -294,6 +319,184 @@
196 powerd_reset_activity_timer(1);
197 }
198
199+static void watch_modem(const char *modem)
200+{
201+ /* for incoming SMS signals */
202+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
203+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
204+ NULL,
205+ "org.ofono",
206+ modem,
207+ "org.ofono.MessageManager",
208+ NULL,
209+ (GAsyncReadyCallback)ofono_proxy_connect_cb,
210+ NULL);
211+
212+ /* for incoming calls Added/Removed signals */
213+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
214+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
215+ NULL,
216+ "org.ofono",
217+ modem,
218+ "org.ofono.VoiceCallManager",
219+ NULL,
220+ (GAsyncReadyCallback)ofono_proxy_connect_cb,
221+ NULL);
222+
223+ /* for USSD notifications/network requests */
224+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
225+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
226+ NULL,
227+ "org.ofono",
228+ modem,
229+ "org.ofono.SupplementaryServices",
230+ NULL,
231+ (GAsyncReadyCallback)ofono_proxy_connect_cb,
232+ NULL);
233+}
234+
235+void
236+ofono_get_modems_cb(GObject *source_object,
237+ GAsyncResult *res,
238+ gpointer user_data)
239+{
240+ GDBusProxy *client = G_DBUS_PROXY(source_object);
241+ GVariant *result;
242+ GVariant *item;
243+ GError *error = NULL;
244+ GVariantIter *iter;
245+
246+ result = g_dbus_proxy_call_finish(client, res, &error);
247+ if (result == NULL) {
248+ powerd_warn("%s: call error", __func__);
249+ return;
250+ }
251+
252+ g_variant_get(result, "(a(oa{sv}))", &iter);
253+ while ((item = g_variant_iter_next_value(iter))) {
254+ const char *obj_path;
255+
256+ g_variant_get_child(item, 0, "&o", &obj_path);
257+
258+ if (g_slist_find_custom(g_modems, obj_path, (GCompareFunc) strcmp)
259+ == NULL) {
260+ powerd_debug("active ofono modem %s", obj_path);
261+ g_modems = g_slist_prepend(g_modems, g_strdup(obj_path));
262+ watch_modem(obj_path);
263+ }
264+
265+ g_variant_unref(item);
266+ }
267+
268+ g_variant_unref(result);
269+}
270+
271+static void notify_proximity_sensor(const char *call_state)
272+{
273+ /*
274+ * This function enables the proximity sensor in case the new state of the
275+ * call is:
276+ *
277+ * Active - meaning, the call is in progress --> Proximity On
278+ * Dialing - a signal made on outbound calls only which means that
279+ * we have started to talk to the network, but the call has not
280+ * been picked up. --> Proximity On (this signal is not
281+ * sent on inbound calls)
282+ * Note that the proximity sensor is not activated for "incoming" state
283+ * For more details on states see voicecall-api.txt in the ofono source
284+ */
285+
286+ if (g_proximity_on)
287+ return;
288+
289+ if (strcmp("active", call_state) == 0
290+ || strcmp("dialing", call_state) == 0) {
291+ if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
292+ powerd_warn("Request to use proximity sensor failed");
293+ g_proximity_on = TRUE;
294+ }
295+}
296+
297+static void deactivate_proximity_sensor(void)
298+{
299+ if (!g_proximity_on)
300+ return;
301+
302+ powerd_remove_display_request(prox_sensor_req.cookie);
303+ g_proximity_on = FALSE;
304+}
305+
306+void
307+ofono_voicecall_get_props_cb(GObject *source_object, GAsyncResult *res,
308+ gpointer user_data)
309+{
310+ GDBusProxy *client = G_DBUS_PROXY(source_object);
311+ GVariant *result;
312+ GVariant *item;
313+ GError *error = NULL;
314+ GVariantIter *iter = NULL;
315+
316+ result = g_dbus_proxy_call_finish(client, res, &error);
317+ if (result == NULL) {
318+ powerd_warn("%s: call error", __func__);
319+ return;
320+ }
321+
322+ g_variant_get(result, "(a{sv})", &iter);
323+
324+ while ((item = g_variant_iter_next_value(iter))) {
325+ GVariant *value = NULL;
326+ const char *prop_name = NULL;
327+ const char *call_state = NULL;
328+
329+ g_variant_get(item, "{&sv}", &prop_name, &value);
330+
331+ if (strcmp("State", prop_name) == 0) {
332+ g_variant_get(value, "&s", &call_state);
333+ notify_proximity_sensor(call_state);
334+ powerd_info("GetProperties. Call State = %s", call_state);
335+ }
336+
337+ g_variant_unref(value);
338+ g_variant_unref(item);
339+ }
340+
341+ g_variant_unref(result);
342+}
343+
344+void on_ofono_manager_signal(GDBusProxy *proxy, gchar *sender_name,
345+ gchar *signal_name, GVariant *parameters, gpointer user_data)
346+{
347+ const gchar *object_path;
348+ GVariant *tmp;
349+ char *modem;
350+ GSList *node;
351+
352+ tmp = g_variant_get_child_value(parameters, 0);
353+
354+ object_path = g_variant_get_string(tmp, NULL);
355+ node = g_slist_find_custom(g_modems, object_path, (GCompareFunc) strcmp);
356+
357+ if (strcmp("ModemAdded", signal_name) == 0) {
358+ /* Add if not already in list */
359+ if (node == NULL) {
360+ powerd_debug("watching ofono modem %s", object_path);
361+ modem = g_strdup(object_path);
362+ g_modems = g_slist_prepend(g_modems, modem);
363+ watch_modem(modem);
364+ }
365+ } else if(strcmp("ModemRemoved", signal_name) == 0) {
366+ /* Remove if found in list */
367+ if (node != NULL) {
368+ powerd_debug("stop watch on ofono modem %s", object_path);
369+ g_free(g_modems->data);
370+ g_modems = g_slist_delete_link(g_modems, node);
371+ }
372+ }
373+
374+ g_variant_unref(tmp);
375+}
376+
377 void
378 on_ofono_voicecallmanager_signal (GDBusProxy *proxy,
379 gchar *sender_name,
380@@ -301,12 +504,76 @@
381 GVariant *parameters,
382 gpointer user_data)
383 {
384- powerd_debug("we get signal from %s: %s", sender_name, signal_name);
385- /* from org.ofono.VoiceCallManager - a call was added */
386+ GVariant *tmp;
387+
388 if (!strcmp(signal_name, "CallAdded")) {
389- powerd_debug("Waking up the device - Incoming Call");
390+ struct call_data *call;
391+
392 powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
393 powerd_reset_activity_timer(1);
394+
395+ call = (struct call_data *) calloc(1, sizeof(*call));
396+ tmp = g_variant_get_child_value(parameters, 0);
397+ call->obj_name = g_variant_dup_string(tmp, NULL);
398+ g_calls = g_slist_prepend(g_calls, call);
399+
400+ powerd_info("%s incoming call", call->obj_name);
401+
402+ /* Connect to voicecall interface */
403+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
404+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
405+ NULL,
406+ "org.ofono",
407+ call->obj_name,
408+ "org.ofono.VoiceCall",
409+ NULL,
410+ (GAsyncReadyCallback) ofono_voicecall_proxy_connect_cb,
411+ call);
412+
413+ g_variant_unref(tmp);
414+
415+ } else if (!strcmp(signal_name, "CallRemoved")) {
416+ const gchar *object_path;
417+ GSList *node;
418+
419+ tmp = g_variant_get_child_value(parameters, 0);
420+ object_path = g_variant_get_string(tmp, NULL);
421+ node = g_slist_find_custom(g_calls, object_path, call_data_cmp);
422+ if (node != NULL) {
423+ free_call_data(node->data);
424+ g_calls = g_slist_delete_link(g_calls, node);
425+ powerd_info("%s call removed", object_path);
426+ }
427+
428+ if (g_calls == NULL)
429+ deactivate_proximity_sensor();
430+
431+ g_variant_unref(tmp);
432+ }
433+}
434+
435+void
436+on_ofono_voicecall_signal (GDBusProxy *proxy,
437+ gchar *sender_name,
438+ gchar *signal_name,
439+ GVariant *parameters,
440+ gpointer user_data)
441+{
442+ GVariant *value = NULL;
443+ const char *prop_name = NULL;
444+ const char *call_state = NULL;
445+
446+ if (!strcmp(signal_name, "PropertyChanged")) {
447+ g_variant_get(parameters, "(&sv)", &prop_name, &value);
448+
449+ if (!strcmp(prop_name, "State")) {
450+ g_variant_get(value, "&s", &call_state);
451+
452+ powerd_info("Call State = %s", call_state);
453+ notify_proximity_sensor(call_state);
454+ }
455+
456+ g_variant_unref(value);
457 }
458 }
459
460@@ -327,63 +594,19 @@
461 }
462 }
463
464-void
465-on_ofono_voicecall_signal (GDBusProxy *proxy,
466+void on_ofono_ussd_signal(GDBusProxy *proxy,
467 gchar *sender_name,
468 gchar *signal_name,
469 GVariant *parameters,
470 gpointer user_data)
471 {
472- GVariant *value = NULL;
473- const char *prop_name;
474- const char *prop_value;
475- static gboolean alerted = FALSE;
476-
477 powerd_debug("we get signal from %s: %s", sender_name, signal_name);
478-
479- /* This function enables and disables the proximity sensor based
480- * on the state of the call.
481- *
482- * Active - meaning, the call is in progress --> Proximity On
483- * Alerting - a signal made on outbound calls only which means that
484- * the phone is ringing on the other side, but has not
485- * been picked up. --> Proximity On (this signal is not
486- * sent on inbound calls)
487- * Disconnected - the call is over. --> Proximity Off.
488- *
489- * For more details on states see voicecall-api.txt in the ofono source
490- */
491-
492- /* Note: As of June 13, 2013, the phone cannot successfully
493- * accept a call while another call is in progress. When this is fixed
494- * the code below will need to be rewritten to handle multiple
495- * active/disconnected signals. LP: #1191033 (mfisch) */
496-
497- if (!strcmp(signal_name, "PropertyChanged")) {
498- g_variant_get(parameters, "(&sv)", &prop_name, &value);
499- if (!strcmp(prop_name,"State")) {
500- g_variant_get(value, "&s", &prop_value);
501- powerd_debug("Call State = %s", prop_value);
502- if (!strcmp(prop_value,"active")) {
503- if (!alerted) {
504- //call is active, enable sensor
505- if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
506- powerd_warn("Request to use proximity sensor failed");
507- }
508- }
509- if (!strcmp(prop_value,"alerting")) {
510- alerted = TRUE;
511- //call is altering, enable sensor
512- if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
513- powerd_warn("Request to use proximity sensor failed");
514- }
515- else if (!strcmp(prop_value,"disconnected")) {
516- alerted = FALSE;
517- //call is disconnected, disable sensor
518- powerd_remove_display_request(prox_sensor_req.cookie);
519- }
520- g_variant_unref(value);
521- }
522+ /* from org.ofono.MessageManager */
523+ if ((!strcmp(signal_name, "NotificationReceived")) ||
524+ (!strcmp(signal_name, "RequestReceived"))) {
525+ powerd_debug("Waking up the device - Incoming USSD");
526+ powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
527+ powerd_reset_activity_timer(1);
528 }
529 }
530
531@@ -445,37 +668,15 @@
532 powerd_name_acquired_cb, powerd_name_lost_cb, NULL, NULL);
533 powerd_debug("owner id: %u", name_id);
534
535- /* for incoming SMS signals */
536- g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
537- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
538- NULL,
539- "org.ofono",
540- "/ril_0",
541- "org.ofono.MessageManager",
542- NULL,
543- (GAsyncReadyCallback)ofono_proxy_connect_cb,
544- NULL);
545-
546- /* for incoming calls Added/Removed signals */
547- g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
548- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
549- NULL,
550- "org.ofono",
551- "/ril_0",
552- "org.ofono.VoiceCallManager",
553- NULL,
554- (GAsyncReadyCallback)ofono_proxy_connect_cb,
555- NULL);
556-
557- /* for answering a call/hanging up signals */
558- g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
559- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
560- NULL,
561- "org.ofono",
562- "/ril_0/voicecall01",
563- "org.ofono.VoiceCall",
564- NULL,
565- (GAsyncReadyCallback)ofono_proxy_connect_cb,
566+ /* Listen to modem creation */
567+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
568+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
569+ NULL,
570+ "org.ofono",
571+ "/",
572+ "org.ofono.Manager",
573+ NULL,
574+ (GAsyncReadyCallback) ofono_manager_proxy_connect_cb,
575 NULL);
576
577 /* Init this first, data is used by other inits */
578@@ -547,5 +748,8 @@
579 power_request_deinit();
580 powerd_client_deinit();
581 powerd_stats_deinit();
582+ g_slist_free_full(g_modems, g_free);
583+ g_slist_free_full(g_calls, free_call_data);
584+
585 return g_exit_code;
586 }

Subscribers

People subscribed via source and target branches