Merge lp:~phablet-team/ofono/rtm-bug-fix-update-1 into lp:~phablet-team/ofono/ubuntu

Proposed by Tony Espy
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 6881
Merged at revision: 6878
Proposed branch: lp:~phablet-team/ofono/rtm-bug-fix-update-1
Merge into: lp:~phablet-team/ofono/ubuntu
Diff against target: 674 lines (+295/-62)
14 files modified
debian/changelog (+41/-0)
drivers/mtkmodem/radio-settings.c (+7/-1)
drivers/rilmodem/gprs.c (+9/-1)
drivers/rilmodem/gprs.h (+1/-0)
gril/gril.c (+2/-2)
gril/grilreply.c (+45/-7)
gril/ril_constants.h (+12/-0)
include/modem.h (+4/-0)
plugins/mtk.c (+115/-36)
plugins/ril.c (+8/-12)
plugins/ubuntu-apndb.c (+1/-1)
src/modem.c (+14/-1)
src/sim.c (+1/-1)
unit/test-grilreply.c (+35/-0)
To merge this branch: bzr merge lp:~phablet-team/ofono/rtm-bug-fix-update-1
Reviewer Review Type Date Requested Status
Tony Espy Approve
Sergio Schvezov Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+235521@code.launchpad.net

Commit message

* gril, unit: fix indicator-network crash (LP: #1368675)
   RIL defines a set of network registration states for emergency
   calling that don't map directly to ofono's states. This results
   in NetworkRegistration Status not being set at all, which in
   turn crashes the indicator.
* include, plugins/mtk.c, src/modem.c,sim.c: Fix PUK crash (LP: #1365481)
   If the SIM gets locked in particular sequence, ofono will crash
   while trying to free the list of SIM SPN watch events ( which
   have already been freed ). MTK fix is a bit more involved than
   the stanard RIL logic.
* plugins/mtk.c,ril.c: Show emergency numbers in flight-mode (LP: #1366188)
   Modify plugin logic to create the SimManager interface even if
   no SIM is present.
* plugins/ubuntu-apndb.c: allow MMS APNs w/out proxy (LP: #1362008)
  Prior to this change, MMS APNs w/out a proxy were skipped.
  Now APNs are skipped if message center is missing, which makes
  more sense.
* rilmodem/gprs.c: fix crash due to stale timer event (LP: # 1373351)
  A 5s timer is set to retry a STATUS request to RIL, however if
  FlightMode is enabled, the gprs atom is destroyed, and the pending
  timer callback has a stale gprs reference. Now the timer id is
  stored, and when the atom destroyed, the timer event is cancelled.
* mtkmodem/radio-setttings.c: fix RadioSettings creation (LP: #1374029 )
  If the MTK modem returns a RADIO_NOT_AVAIL error in response
  to a FastDormany RIL request, the RadioSetting initialization
  callback sequence is broken, and thus the RadioSettings interface
  isn't created. This in turn prevents powerd from enabling
  FastDorancy whenever the screen is turned off, and also has
  implications for system-settings too.

Description of the change

RTM bug fix update for ofono.

Fixes one SIM related crash, and one issue which prevents emergency calls if no SIM is installed, and one NetworkRegistration fix for an indicator-network crash.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) :
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Aside from the debian/changelog comment, I don't think much more review is needed as this is just a release review.

6880. By Tony Espy

plugins/ubuntu-apndb.c: allow MMS APNs w/out proxy (LP: #1362008)
Prior to this change, MMS APNs w/out a proxy were skipped.
Now APNs are skipped if message center is missing, which makes
more sense.

6881. By Tony Espy

Correct latest version to -0ubuntu1

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

Given
$ grep -R onfo|grep -v confor
debian/changelog: calling that don't map directly to onfo's states. This results

and that this was uploaded to phablet-team, I'm taking the liberty of modifying that typo to 'ofono'

6882. By Sergio Schvezov

debian/changelog: s/ofno/ofono/

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve
Revision history for this message
Tony Espy (awe) wrote :

I tested the package from rtm silo-007 on krillin w/RTM image #59 installed.

https://wiki.ubuntu.com/Process/Merges/TestPlans/ofono

I ran:

1. Basic Tests
I did see some weird dialer behavior ( no call time-counter, remote hang-ups didn't dismiss the call-in-progress page ) which seems intermittent. Also an incoming call when the device is locked doesn't seem to work very well at all. Other than that all of the basic tests pass.

2. SIM Tests
I ran the SIM tests section of the ofono test plan

3. I verified bug LP: #1366188 - Emergency Numbers not shown in FlightMode

4. I tried to run the dialer-app autopilot tests, and ended up with 6 failures. This seems consistent with the daily results.

5. I am seeing a new ofonod crash, so this will need to be investigated before we can land these changes.

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

I can confirm that bug #1365481 is fixed with this MP.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Provisioning of proxyless MMS contexts works with this, tested with:

env OFONO_CUSTOM_MCC=208
env OFONO_CUSTOM_MNC=15

Solves the ofono side of bug #1362008

review: Approve
Revision history for this message
Tony Espy (awe) wrote :

Image RTM/#59:

So I can reproduce the crash mentioned above. I'm testing the new urfkill ( including the device-side changes ), indicator-network, and ofono from the silo associated with this merge.

Without the new ofono, no ofonod crashes.

With it, playing around with flight-mode for a little while, with at least one reboot caused the crash in ril_gprs_registration_status() caused by a NULL pointer returned by ofono_gprs_get_data(gprs).

review: Needs Fixing
Revision history for this message
Tony Espy (awe) wrote :

Turns out this is not a regression directly caused by these changes. That said, we should have an update first thing tomorrow based upon the work/comments in the following pull request:

https://github.com/rilmodem/ofono/pull/122

and the following bug:

https://bugs.launchpad.net/ubuntu/+source/ofono/+bug/1373351

review: Approve
6883. By Tony Espy

* rilmodem/gprs.c: fix crash due to stale timer event (LP: # 1373351)
  A 5s timer is set to retry a STATUS request to RIL, however if
  FlightMode is enabled, the gprs atom is destroyed, and the pending
  timer callback has a stale gprs reference. Now the timer id is
  stored, and when the atom destroyed, the timer event is cancelled.
* mtkmodem/radio-setttings.c: fix RadioSettings creation (LP: #1374029 )
  If the MTK modem returns a RADIO_NOT_AVAIL error in response
  to a FastDormany RIL request, the RadioSetting initialization
  callback sequence is broken, and thus the RadioSettings interface
  isn't created. This in turn prevents powerd from enabling
  FastDorancy whenever the screen is turned off, and also has
  implications for system-settings too.

Revision history for this message
Tony Espy (awe) wrote :

Image RTM/#59 + ofono from rtm-silo-007 ( 1.12.bzr6878+14.10.20140926-0ubuntu1 ):

No more ofono crashes during FlightMode testing and multiple reboots.

Also verified that RadioSettings is always created and verified that the new code path works via the presence of a new log message.

review: Approve
Revision history for this message
Tony Espy (awe) wrote :

Note, the previous comment didn't specify the device, which was krillin.

mako + image Utopic/#257 + ofono from utopic-silo-024 ( 1.12.bzr6878+14.10.20140926-0ubuntu1 ):

Sanity checked basic tests ( voice in/out, sms in/out, sms&voice wake device, gprs works ).

Looks good.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-09-04 22:31:59 +0000
3+++ debian/changelog 2014-09-26 14:35:25 +0000
4@@ -1,3 +1,44 @@
5+ofono (1.12.bzr6878+14.10.20140904-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ [ Alfonso Sanchez-Beato ]
8+ * include, plugins/mtk.c, src/modem.c,sim.c: Fix PUK crash (LP: #1365481)
9+ If the SIM gets locked in particular sequence, ofono will crash
10+ while trying to free the list of SIM SPN watch events ( which
11+ have already been freed ). MTK fix is a bit more involved than
12+ the stanard RIL logic.
13+
14+ * plugins/mtk.c,ril.c: Show emergency numbers in flight-mode (LP: #1366188)
15+ Modify plugin logic to create the SimManager interface even if
16+ no SIM is present.
17+
18+ * gril, unit: fix indicator-network crash (LP: #1368675)
19+ RIL defines a set of network registration states for emergency
20+ calling that don't map directly to ofono's states. This results
21+ in NetworkRegistration Status not being set at all, which in
22+ turn crashes the indicator.
23+
24+ * rilmodem/gprs.c: fix crash due to stale timer event (LP: # 1373351)
25+ A 5s timer is set to retry a STATUS request to RIL, however if
26+ FlightMode is enabled, the gprs atom is destroyed, and the pending
27+ timer callback has a stale gprs reference. Now the timer id is
28+ stored, and when the atom destroyed, the timer event is cancelled.
29+
30+ * mtkmodem/radio-setttings.c: fix RadioSettings creation (LP: #1374029 )
31+ If the MTK modem returns a RADIO_NOT_AVAIL error in response
32+ to a FastDormany RIL request, the RadioSetting initialization
33+ callback sequence is broken, and thus the RadioSettings interface
34+ isn't created. This in turn prevents powerd from enabling
35+ FastDorancy whenever the screen is turned off, and also has
36+ implications for system-settings too.
37+
38+ [ Tony Espy ]
39+ * plugins/ubuntu-apndb.c: allow MMS APNs w/out proxy (LP: #1362008)
40+ Prior to this change, MMS APNs w/out a proxy were skipped.
41+ Now APNs are skipped if message center is missing, which makes
42+ more sense.
43+
44+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Sat, 20 Sep 2014 14:40:37 -0400
45+
46 ofono (1.12.bzr6876+14.10.20140904-0ubuntu1) utopic; urgency=medium
47
48 [ Jussi Kangas ]
49
50=== modified file 'drivers/mtkmodem/radio-settings.c'
51--- drivers/mtkmodem/radio-settings.c 2014-07-28 07:12:26 +0000
52+++ drivers/mtkmodem/radio-settings.c 2014-09-26 14:35:25 +0000
53@@ -63,7 +63,13 @@
54 struct radio_data *rsd = ofono_radio_settings_get_data(rs);
55 ofono_radio_settings_fast_dormancy_set_cb_t cb = cbd->cb;
56
57- if (message->error == RIL_E_SUCCESS) {
58+ if (message->error == RIL_E_SUCCESS ||
59+ message->error == RIL_E_RADIO_NOT_AVAILABLE) {
60+
61+ if (message->error == RIL_E_RADIO_NOT_AVAILABLE)
62+ ofono_warn("Could not set fast dormancy "
63+ "as radio is not available");
64+
65 g_ril_print_response_no_args(rsd->ril, message);
66 ril_set_fast_dormancy(rs, user->on, cb, cbd->data);
67 } else {
68
69=== modified file 'drivers/rilmodem/gprs.c'
70--- drivers/rilmodem/gprs.c 2014-04-29 17:35:03 +0000
71+++ drivers/rilmodem/gprs.c 2014-09-26 14:35:25 +0000
72@@ -160,6 +160,9 @@
73 static gboolean ril_get_status_retry(gpointer user_data)
74 {
75 struct ofono_gprs *gprs = user_data;
76+ struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
77+
78+ gd->status_retry_cb_id = 0;
79
80 ril_gprs_registration_status(gprs, NULL, NULL);
81
82@@ -302,7 +305,9 @@
83 * are registered in the voice network.
84 */
85 if (old_status == -1 && message->error == RIL_E_GENERIC_FAILURE)
86- g_timeout_add(GET_STATUS_TIMER_MS, ril_get_status_retry, gprs);
87+ gd->status_retry_cb_id =
88+ g_timeout_add(GET_STATUS_TIMER_MS,
89+ ril_get_status_retry, gprs);
90
91 if (cb)
92 CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
93@@ -449,6 +454,9 @@
94
95 DBG("");
96
97+ if (gd->status_retry_cb_id != 0)
98+ g_source_remove(gd->status_retry_cb_id);
99+
100 ofono_gprs_set_data(gprs, NULL);
101
102 g_ril_unref(gd->ril);
103
104=== modified file 'drivers/rilmodem/gprs.h'
105--- drivers/rilmodem/gprs.h 2014-07-31 06:45:32 +0000
106+++ drivers/rilmodem/gprs.h 2014-09-26 14:35:25 +0000
107@@ -28,6 +28,7 @@
108 int tech;
109 int state_changed_unsol;
110 int pending_deact_req;
111+ guint status_retry_cb_id;
112 };
113
114 int ril_gprs_probe(struct ofono_gprs *gprs, unsigned int vendor, void *data);
115
116=== modified file 'gril/gril.c'
117--- gril/gril.c 2014-08-14 08:12:16 +0000
118+++ gril/gril.c 2014-09-26 14:35:25 +0000
119@@ -467,8 +467,8 @@
120
121 /* Only log events not being listended for... */
122 if (!found)
123- DBG("RIL Event: %s\n",
124- unsol_request_to_string(p, message->req));
125+ DBG("RIL Event slot %d: %s\n",
126+ p->slot, unsol_request_to_string(p, message->req));
127
128 p->in_notify = FALSE;
129
130
131=== modified file 'gril/grilreply.c'
132--- gril/grilreply.c 2014-07-31 23:41:36 +0000
133+++ gril/grilreply.c 2014-09-26 14:35:25 +0000
134@@ -45,6 +45,8 @@
135
136 #define OPERATOR_NUM_PARAMS 3
137
138+#define MTK_MODEM_MAX_CIDS 3
139+
140 static void ril_reply_free_operator(gpointer data)
141 {
142 struct reply_operator *reply = data;
143@@ -272,11 +274,12 @@
144
145 {
146 struct parcel rilp;
147- int tmp;
148+ int tmp, status;
149 char *sstatus = NULL, *slac = NULL, *sci = NULL;
150 char *stech = NULL, *sreason = NULL, *smax = NULL;
151 struct reply_reg_state *reply;
152 char *endp;
153+ const char *strstate;
154
155 DBG("");
156
157@@ -338,12 +341,21 @@
158 * voice & data response.
159 */
160 if (tmp--) {
161- sreason = parcel_r_string(&rilp); /* TODO: different use for CDMA */
162+ /* TODO: different use for CDMA */
163+ sreason = parcel_r_string(&rilp);
164
165 if (tmp--) {
166- smax = parcel_r_string(&rilp); /* TODO: different use for CDMA */
167+ /* TODO: different use for CDMA */
168+ smax = parcel_r_string(&rilp);
169
170- if (smax)
171+ /*
172+ * MTK modem does not return max_cids, string for this
173+ * index actually contains the maximum data bearer
174+ * capability.
175+ */
176+ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
177+ reply->max_cids = MTK_MODEM_MAX_CIDS;
178+ else if (smax)
179 reply->max_cids = atoi(smax);
180 }
181 }
182@@ -356,7 +368,33 @@
183 goto error;
184 }
185
186- reply->status = atoi(sstatus);
187+ status = atoi(sstatus);
188+
189+ switch (status) {
190+ case RIL_REG_STATE_NOT_REGISTERED:
191+ case RIL_REG_STATE_REGISTERED:
192+ case RIL_REG_STATE_SEARCHING:
193+ case RIL_REG_STATE_DENIED:
194+ case RIL_REG_STATE_UNKNOWN:
195+ case RIL_REG_STATE_ROAMING:
196+ /* Only valid values for ofono */
197+ reply->status = status;
198+ strstate = registration_status_to_string(status);
199+ break;
200+ case RIL_REG_STATE_EMERGENCY_NOT_REGISTERED:
201+ case RIL_REG_STATE_EMERGENCY_SEARCHING:
202+ case RIL_REG_STATE_EMERGENCY_DENIED:
203+ case RIL_REG_STATE_EMERGENCY_UNKNOWN:
204+ /* Map to states valid for ofono core */
205+ reply->status = status - RIL_REG_STATE_EMERGENCY_NOT_REGISTERED;
206+ strstate = sstatus;
207+ break;
208+ default:
209+ reply->status = NETWORK_REGISTRATION_STATUS_UNKNOWN;
210+ strstate = sstatus;
211+ ofono_error("%s: Error unknown status code (%s)",
212+ __func__, sstatus);
213+ }
214
215
216 if (slac)
217@@ -386,12 +424,12 @@
218
219 g_ril_append_print_buf(gril,
220 "{%s,%s,%s,%s,%s,%s}",
221- registration_status_to_string(reply->status),
222+ strstate,
223 slac,
224 sci,
225 ril_radio_tech_to_string(reply->tech),
226 sreason,
227- smax);
228+ smax ? smax : "NULL");
229
230 g_ril_print_response(gril, message);
231
232
233=== modified file 'gril/ril_constants.h'
234--- gril/ril_constants.h 2014-07-29 06:11:22 +0000
235+++ gril/ril_constants.h 2014-09-26 14:35:25 +0000
236@@ -359,4 +359,16 @@
237 /* Suplementary services Service class*/
238 #define SERVICE_CLASS_NONE 0
239
240+/* Network registration states */
241+#define RIL_REG_STATE_NOT_REGISTERED 0
242+#define RIL_REG_STATE_REGISTERED 1
243+#define RIL_REG_STATE_SEARCHING 2
244+#define RIL_REG_STATE_DENIED 3
245+#define RIL_REG_STATE_UNKNOWN 4
246+#define RIL_REG_STATE_ROAMING 5
247+#define RIL_REG_STATE_EMERGENCY_NOT_REGISTERED 10
248+#define RIL_REG_STATE_EMERGENCY_SEARCHING 12
249+#define RIL_REG_STATE_EMERGENCY_DENIED 13
250+#define RIL_REG_STATE_EMERGENCY_UNKNOWN 14
251+
252 #endif /*__RIL_CONSTANTS_H*/
253
254=== modified file 'include/modem.h'
255--- include/modem.h 2012-11-02 19:02:26 +0000
256+++ include/modem.h 2014-09-26 14:35:25 +0000
257@@ -112,6 +112,10 @@
258 ofono_bool_t ofono_modem_get_boolean(struct ofono_modem *modem,
259 const char *key);
260
261+void ofono_modem_set_driver_watches_sim(struct ofono_modem *modem,
262+ ofono_bool_t value);
263+ofono_bool_t ofono_modem_get_driver_watches_sim(struct ofono_modem *modem);
264+
265 int ofono_modem_driver_register(const struct ofono_modem_driver *);
266 void ofono_modem_driver_unregister(const struct ofono_modem_driver *);
267
268
269=== modified file 'plugins/mtk.c'
270--- plugins/mtk.c 2014-08-19 15:03:08 +0000
271+++ plugins/mtk.c 2014-09-26 14:35:25 +0000
272@@ -94,10 +94,20 @@
273 int slot;
274 struct ril_sim_data sim_data;
275 struct ofono_devinfo *devinfo;
276+ struct ofono_voicecall *voicecall;
277+ struct ofono_call_volume *callvolume;
278 struct cb_data *pending_online_cbd;
279 ofono_bool_t pending_online;
280 ofono_bool_t gprs_attach;
281 int rild_connect_retries;
282+ struct ofono_sms *sms;
283+ struct ofono_netreg *netreg;
284+ struct ofono_ussd *ussd;
285+ struct ofono_call_settings *call_settings;
286+ struct ofono_call_forwarding *call_forwarding;
287+ struct ofono_call_barring *call_barring;
288+ struct ofono_gprs *gprs;
289+ struct ofono_message_waiting *message_waiting;
290 };
291
292 /*
293@@ -377,14 +387,21 @@
294 DBG("slot %d", ril->slot);
295 }
296
297+/*
298+ * sim_state_watch listens to SIM state changes and creates/removes atoms
299+ * accordingly. This is needed because we cannot rely on the modem core code,
300+ * which handles modem state transitions, to do this due to the SIM not being
301+ * accessible in the offline state for mtk modems. This causes a mismatch
302+ * between what the core thinks it can do in some states and what the mtk modem
303+ * can really do in those. This is a workaround to solve that.
304+ */
305 static void sim_state_watch(enum ofono_sim_state new_state, void *data)
306 {
307+ struct ofono_modem *modem = data;
308+ struct mtk_data *ril = ofono_modem_get_data(modem);
309+
310 if (new_state == OFONO_SIM_STATE_READY) {
311- struct ofono_modem *modem = data;
312- struct mtk_data *ril = ofono_modem_get_data(modem);
313- struct ofono_gprs *gprs;
314 struct ofono_gprs_context *gc;
315- struct ofono_message_waiting *mw;
316 struct mtk_gprs_data gprs_data = { ril->modem, modem };
317 struct ril_gprs_context_data inet_ctx =
318 { ril->modem, OFONO_GPRS_CONTEXT_TYPE_INTERNET };
319@@ -399,22 +416,26 @@
320 * - stk ( SIM toolkit )
321 * - radio_settings
322 */
323- ofono_sms_create(modem, OFONO_RIL_VENDOR_MTK,
324- RILMODEM, ril->modem);
325+ ril->sms = ofono_sms_create(modem, OFONO_RIL_VENDOR_MTK,
326+ RILMODEM, ril->modem);
327
328 /* netreg needs access to the SIM (SPN, SPDI) */
329- ofono_netreg_create(modem, OFONO_RIL_VENDOR_MTK,
330- RILMODEM, ril->modem);
331- ofono_ussd_create(modem, OFONO_RIL_VENDOR_MTK,
332- RILMODEM, ril->modem);
333- ofono_call_settings_create(modem, OFONO_RIL_VENDOR_MTK,
334- RILMODEM, ril->modem);
335- ofono_call_forwarding_create(modem, OFONO_RIL_VENDOR_MTK,
336- RILMODEM, ril->modem);
337- ofono_call_barring_create(modem, OFONO_RIL_VENDOR_MTK,
338- RILMODEM, ril->modem);
339+ ril->netreg = ofono_netreg_create(modem, OFONO_RIL_VENDOR_MTK,
340+ RILMODEM, ril->modem);
341+ ril->ussd = ofono_ussd_create(modem, OFONO_RIL_VENDOR_MTK,
342+ RILMODEM, ril->modem);
343+ ril->call_settings =
344+ ofono_call_settings_create(modem, OFONO_RIL_VENDOR_MTK,
345+ RILMODEM, ril->modem);
346+ ril->call_forwarding =
347+ ofono_call_forwarding_create(modem,
348+ OFONO_RIL_VENDOR_MTK,
349+ RILMODEM, ril->modem);
350+ ril->call_barring =
351+ ofono_call_barring_create(modem, OFONO_RIL_VENDOR_MTK,
352+ RILMODEM, ril->modem);
353
354- gprs = ofono_gprs_create(modem, OFONO_RIL_VENDOR_MTK,
355+ ril->gprs = ofono_gprs_create(modem, OFONO_RIL_VENDOR_MTK,
356 MTKMODEM, &gprs_data);
357
358 gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK,
359@@ -422,7 +443,7 @@
360 if (gc) {
361 ofono_gprs_context_set_type(gc,
362 OFONO_GPRS_CONTEXT_TYPE_INTERNET);
363- ofono_gprs_add_context(gprs, gc);
364+ ofono_gprs_add_context(ril->gprs, gc);
365 }
366
367 gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK,
368@@ -430,12 +451,49 @@
369 if (gc) {
370 ofono_gprs_context_set_type(gc,
371 OFONO_GPRS_CONTEXT_TYPE_MMS);
372- ofono_gprs_add_context(gprs, gc);
373- }
374-
375- mw = ofono_message_waiting_create(modem);
376- if (mw)
377- ofono_message_waiting_register(mw);
378+ ofono_gprs_add_context(ril->gprs, gc);
379+ }
380+
381+ ril->message_waiting = ofono_message_waiting_create(modem);
382+ if (ril->message_waiting)
383+ ofono_message_waiting_register(ril->message_waiting);
384+
385+ } else if (new_state == OFONO_SIM_STATE_LOCKED_OUT) {
386+
387+ DBG("SIM locked, removing atoms");
388+
389+ if (ril->message_waiting) {
390+ ofono_message_waiting_remove(ril->message_waiting);
391+ ril->message_waiting = NULL;
392+ }
393+ if (ril->gprs) {
394+ ofono_gprs_remove(ril->gprs);
395+ ril->gprs = NULL;
396+ }
397+ if (ril->call_barring) {
398+ ofono_call_barring_remove(ril->call_barring);
399+ ril->call_barring = NULL;
400+ }
401+ if (ril->call_forwarding) {
402+ ofono_call_forwarding_remove(ril->call_forwarding);
403+ ril->call_forwarding = NULL;
404+ }
405+ if (ril->call_settings) {
406+ ofono_call_settings_remove(ril->call_settings);
407+ ril->call_settings = NULL;
408+ }
409+ if (ril->ussd) {
410+ ofono_ussd_remove(ril->ussd);
411+ ril->ussd = NULL;
412+ }
413+ if (ril->netreg) {
414+ ofono_netreg_remove(ril->netreg);
415+ ril->netreg = NULL;
416+ }
417+ if (ril->sms) {
418+ ofono_sms_remove(ril->sms);
419+ ril->sms = NULL;
420+ }
421 }
422 }
423
424@@ -453,12 +511,6 @@
425 RILMODEM, &ril->sim_data);
426 g_assert(ril->sim != NULL);
427
428- /* Create interfaces useful for emergency calls */
429- ofono_voicecall_create(modem, OFONO_RIL_VENDOR_MTK,
430- MTKMODEM, ril->modem);
431- ofono_call_volume_create(modem, OFONO_RIL_VENDOR_MTK,
432- RILMODEM, ril->modem);
433-
434 /* Radio settings does not depend on the SIM */
435 ofono_radio_settings_create(modem, OFONO_RIL_VENDOR_MTK,
436 MTKMODEM, ril->modem);
437@@ -658,6 +710,32 @@
438 }
439 }
440
441+static void create_atoms_on_connection(struct ofono_modem *modem)
442+{
443+ struct mtk_data *ril = ofono_modem_get_data(modem);
444+
445+ ril->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK,
446+ RILMODEM, ril->modem);
447+
448+ /* Create interfaces useful for emergency calls */
449+ ril->voicecall = ofono_voicecall_create(modem, OFONO_RIL_VENDOR_MTK,
450+ MTKMODEM, ril->modem);
451+ ril->callvolume = ofono_call_volume_create(modem, OFONO_RIL_VENDOR_MTK,
452+ RILMODEM, ril->modem);
453+}
454+
455+static void remove_atoms_on_disconnection(struct ofono_modem *modem)
456+{
457+ struct mtk_data *ril = ofono_modem_get_data(modem);
458+
459+ ofono_call_volume_remove(ril->callvolume);
460+ ril->callvolume = NULL;
461+ ofono_voicecall_remove(ril->voicecall);
462+ ril->voicecall = NULL;
463+ ofono_devinfo_remove(ril->devinfo);
464+ ril->devinfo = NULL;
465+}
466+
467 static gboolean mtk_connected(gpointer user_data)
468 {
469 struct ofono_modem *modem = (struct ofono_modem *) user_data;
470@@ -669,8 +747,7 @@
471
472 ofono_modem_set_powered(modem, TRUE);
473
474- ril->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK,
475- RILMODEM, ril->modem);
476+ create_atoms_on_connection(modem);
477
478 /* Call the function just once */
479 return FALSE;
480@@ -686,8 +763,7 @@
481 if (create_gril(modem) < 0)
482 return TRUE;
483
484- ril->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK,
485- RILMODEM, ril->modem);
486+ create_atoms_on_connection(modem);
487
488 if (ril->pending_cb)
489 ril->pending_cb(ril->pending_cbd);
490@@ -705,8 +781,8 @@
491
492 DBG("slot %d", ril->slot);
493
494- /* Uses old gril object, remove and recreate later */
495- ofono_devinfo_remove(ril->devinfo);
496+ /* Atoms use old gril object, remove and recreate later */
497+ remove_atoms_on_disconnection(modem);
498
499 g_ril_unref(ril->modem);
500 ril->modem = NULL;
501@@ -804,6 +880,9 @@
502 g_timeout_add_seconds(RILD_CONNECT_RETRY_TIME_S,
503 connect_rild, modem);
504
505+ /* We handle SIM states due to MTK peculiarities */
506+ ofono_modem_set_driver_watches_sim(modem, TRUE);
507+
508 /*
509 * We will mark the modem as powered when we receive an event that
510 * confirms that the radio is in a state different from unavailable
511
512=== modified file 'plugins/ril.c'
513--- plugins/ril.c 2014-08-19 16:29:51 +0000
514+++ plugins/ril.c 2014-09-26 14:35:25 +0000
515@@ -80,7 +80,7 @@
516 ofono_bool_t ofono_online;
517 int radio_state;
518 struct ofono_sim *sim;
519- struct ofono_voicecall *voice;
520+ struct ofono_radio_settings *radio_settings;
521 int rild_connect_retries;
522 };
523
524@@ -121,17 +121,11 @@
525 switch (radio_state) {
526 case RADIO_STATE_ON:
527
528- if (ril->voice == NULL) {
529- ril->voice =
530- ofono_voicecall_create(modem,
531- ril->vendor,
532- RILMODEM,
533- ril->modem);
534- ofono_call_volume_create(modem, ril->vendor,
535- RILMODEM, ril->modem);
536- ofono_radio_settings_create(modem, ril->vendor,
537- RILMODEM, ril->modem);
538- }
539+ if (ril->radio_settings == NULL)
540+ ril->radio_settings =
541+ ofono_radio_settings_create(modem,
542+ ril->vendor, RILMODEM,
543+ ril->modem);
544
545 send_get_sim_status(modem);
546 break;
547@@ -257,6 +251,8 @@
548 DBG("");
549
550 ofono_devinfo_create(modem, ril->vendor, RILMODEM, ril->modem);
551+ ofono_voicecall_create(modem, ril->vendor, RILMODEM, ril->modem);
552+ ofono_call_volume_create(modem, ril->vendor, RILMODEM, ril->modem);
553
554 sim_data.gril = ril->modem;
555 sim_data.modem = modem;
556
557=== modified file 'plugins/ubuntu-apndb.c'
558--- plugins/ubuntu-apndb.c 2014-07-29 06:35:48 +0000
559+++ plugins/ubuntu-apndb.c 2014-09-26 14:35:25 +0000
560@@ -400,7 +400,7 @@
561 type = determine_apn_type(types);
562
563 if (type == OFONO_GPRS_CONTEXT_TYPE_ANY ||
564- (type == OFONO_GPRS_CONTEXT_TYPE_MMS && mmsproxy == NULL)) {
565+ (type == OFONO_GPRS_CONTEXT_TYPE_MMS && mmscenter == NULL)) {
566 DBG("Skipping %s context; types: %s", apn, types);
567 return;
568 }
569
570=== modified file 'src/modem.c'
571--- src/modem.c 2014-03-13 16:33:34 +0000
572+++ src/modem.c 2014-09-26 14:35:25 +0000
573@@ -87,6 +87,7 @@
574 void *driver_data;
575 char *driver_type;
576 char *name;
577+ ofono_bool_t driver_watches_sim;
578 };
579
580 struct ofono_devinfo {
581@@ -697,7 +698,8 @@
582 case OFONO_SIM_STATE_RESETTING:
583 break;
584 case OFONO_SIM_STATE_LOCKED_OUT:
585- modem_change_state(modem, MODEM_STATE_PRE_SIM);
586+ if (modem->driver_watches_sim == FALSE)
587+ modem_change_state(modem, MODEM_STATE_PRE_SIM);
588 break;
589 case OFONO_SIM_STATE_READY:
590 /* Avoid state regressions */
591@@ -1803,6 +1805,17 @@
592 modem->driver_type = g_strdup(type);
593 }
594
595+void ofono_modem_set_driver_watches_sim(struct ofono_modem *modem,
596+ ofono_bool_t value)
597+{
598+ modem->driver_watches_sim = value;
599+}
600+
601+ofono_bool_t ofono_modem_get_driver_watches_sim(struct ofono_modem *modem)
602+{
603+ return modem->driver_watches_sim;
604+}
605+
606 struct ofono_modem *ofono_modem_create(const char *name, const char *type)
607 {
608 struct ofono_modem *modem;
609
610=== modified file 'src/sim.c'
611--- src/sim.c 2013-11-11 10:37:02 +0000
612+++ src/sim.c 2014-09-26 14:35:25 +0000
613@@ -2727,7 +2727,7 @@
614
615 DBG("%p", sim);
616
617- if (sim == NULL)
618+ if (sim == NULL || sim->spn_watches == NULL)
619 return FALSE;
620
621 ret = __ofono_watchlist_remove_item(sim->spn_watches, *id);
622
623=== modified file 'unit/test-grilreply.c'
624--- unit/test-grilreply.c 2014-07-16 22:55:36 +0000
625+++ unit/test-grilreply.c 2014-09-26 14:35:25 +0000
626@@ -829,6 +829,36 @@
627 }
628 };
629
630+/*
631+ * The following hex data represents a valid
632+ * RIL_REQUEST_VOICE_REGISTRATION_STATE reply with the following parameters:
633+ *
634+ * {13,(null),(null),UNKNOWN,(null),(null)}
635+ */
636+static const guchar reply_voice_reg_state_valid_parcel12[] = {
637+ 0x0f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x31, 0x00, 0x33, 0x00,
638+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
639+ 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
640+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
641+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
642+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00,
643+ 0x31, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
644+ 0x31, 0x00, 0x62, 0x00, 0x65, 0x00, 0x00, 0x00
645+};
646+
647+static const reg_state_test voice_reg_valid_12 = {
648+ .status = NETWORK_REGISTRATION_STATUS_DENIED,
649+ .tech = RADIO_TECH_UNKNOWN,
650+ .msg = {
651+ .buf = (gchar *) &reply_voice_reg_state_valid_parcel12,
652+ .buf_len = sizeof(reply_voice_reg_state_valid_parcel12),
653+ .unsolicited = FALSE,
654+ .req = RIL_REQUEST_VOICE_REGISTRATION_STATE,
655+ .serial_no = 0,
656+ .error = 0,
657+ }
658+};
659+
660 static const struct ril_msg reply_operator_invalid_1 = {
661 .buf = "",
662 .buf_len = 0,
663@@ -1866,6 +1896,11 @@
664 test_reply_reg_state_valid);
665
666 g_test_add_data_func("/testgrilreply/netreg: "
667+ "valid VOICE_REG_STATE Test 12",
668+ &voice_reg_valid_12,
669+ test_reply_reg_state_valid);
670+
671+ g_test_add_data_func("/testgrilreply/netreg: "
672 "invalid GET_OPERATOR Test 1",
673 &reply_operator_invalid_1,
674 test_reply_operator_invalid);

Subscribers

People subscribed via source and target branches

to all changes: