Merge lp:~awe/ofono/midori-switch-4g-update into lp:~phablet-team/ofono/ubuntu

Proposed by Tony Espy
Status: Merged
Approved by: Scott Sweeny
Approved revision: 6918
Merged at revision: 6918
Proposed branch: lp:~awe/ofono/midori-switch-4g-update
Merge into: lp:~phablet-team/ofono/ubuntu
Diff against target: 1169 lines (+609/-171)
14 files modified
debian/changelog (+18/-0)
drivers/mtk2modem/gprs.c (+0/-1)
drivers/mtkmodem/gprs.c (+0/-1)
drivers/mtkmodem/radio-settings.c (+5/-0)
drivers/qcommsimmodem/gprs.c (+0/-1)
drivers/qcommsimmodem/radio-settings.c (+3/-0)
drivers/rilmodem/gprs.c (+0/-48)
drivers/rilmodem/gprs.h (+0/-4)
drivers/rilmodem/radio-settings.c (+514/-35)
drivers/rilmodem/radio-settings.h (+19/-0)
gril/grilreply.c (+9/-3)
include/gprs.h (+2/-4)
plugins/ril.c (+35/-55)
src/gprs.c (+4/-19)
To merge this branch: bzr merge lp:~awe/ofono/midori-switch-4g-update
Reviewer Review Type Date Requested Status
Scott Sweeny (community) Approve
Review via email: mp+300483@code.launchpad.net

Commit message

  * Add automatic SIM slot capability switching for midori:
   * include: gprs: remove set ia
   * gprs: remove calls to set_ia_apn
   * gril: fix memory leak, print radio_caps event
   * ril: create radio settings when onlining
   * rilmodem: gprs: remove set_ia_apn
   * rilmodem: radio-settings: enable switch slots caps
   * qcommsimmodem: remote set_ia_apn
   * qcommsimmodem: adapt to radio settings changes
   * mtkmodem: adapt to radio settings changes
   * mtkmodem: remove set_ia_apn
   * mtk2modem: remove set_ia_apn

Description of the change

This change adds support for dynamic switching of radio capabilities for dual-standby modems which use the rilmodem driver ( eg. midori ).

Instead of having to explicitly call a DBus method to switch which SIM slot has the ability use 3g or 4g, now the client just uses the standard method of changing the network technology preference. If this new setting requires the slot capabilities to be swapped, rilmodem will do this automatically on behalf of the client.

This change re-works some of the code necessary for LTE support, and as such, we should ensure that LTE still works properly on the MX4 ( EU / China only ).

To post a comment you must log in.
Revision history for this message
Scott Sweeny (ssweeny) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2016-07-01 17:31:30 +0000
+++ debian/changelog 2016-07-19 15:19:28 +0000
@@ -1,3 +1,21 @@
1ofono (1.17.bzr6919+16.10.20160719-0ubuntu1) UNRELEASED; urgency=medium
2
3 [ Alfonso Sanchez-Beato ]
4 * Add automatic SIM slot capability switching for midori:
5 * include: gprs: remove set ia
6 * gprs: remove calls to set_ia_apn
7 * gril: fix memory leak, print radio_caps event
8 * ril: create radio settings when onlining
9 * rilmodem: gprs: remove set_ia_apn
10 * rilmodem: radio-settings: enable switch slots caps
11 * qcommsimmodem: remote set_ia_apn
12 * qcommsimmodem: adapt to radio settings changes
13 * mtkmodem: adapt to radio settings changes
14 * mtkmodem: remove set_ia_apn
15 * mtk2modem: remove set_ia_apn
16
17 -- Tony Espy <espy@canonical.com> Tue, 19 Jul 2016 10:29:20 -0400
18
1ofono (1.17.bzr6919+16.10.20160701.2-0ubuntu1) yakkety; urgency=medium19ofono (1.17.bzr6919+16.10.20160701.2-0ubuntu1) yakkety; urgency=medium
220
3 [ Ratchanan Srirattanamet ]21 [ Ratchanan Srirattanamet ]
422
=== modified file 'drivers/mtk2modem/gprs.c'
--- drivers/mtk2modem/gprs.c 2016-06-28 06:50:11 +0000
+++ drivers/mtk2modem/gprs.c 2016-07-19 15:19:28 +0000
@@ -74,7 +74,6 @@
74 .remove = ril_gprs_remove,74 .remove = ril_gprs_remove,
75 .set_attached = ril_gprs_set_attached,75 .set_attached = ril_gprs_set_attached,
76 .attached_status = ril_gprs_registration_status,76 .attached_status = ril_gprs_registration_status,
77 .set_ia_apn = ril_gprs_set_ia_apn,
78};77};
7978
80void mtk2_gprs_init(void)79void mtk2_gprs_init(void)
8180
=== modified file 'drivers/mtkmodem/gprs.c'
--- drivers/mtkmodem/gprs.c 2015-09-29 08:46:20 +0000
+++ drivers/mtkmodem/gprs.c 2016-07-19 15:19:28 +0000
@@ -175,7 +175,6 @@
175 .remove = mtk_gprs_remove,175 .remove = mtk_gprs_remove,
176 .set_attached = mtk_gprs_set_attached,176 .set_attached = mtk_gprs_set_attached,
177 .attached_status = ril_gprs_registration_status,177 .attached_status = ril_gprs_registration_status,
178 .set_ia_apn = ril_gprs_set_ia_apn,
179};178};
180179
181void mtk_gprs_init(void)180void mtk_gprs_init(void)
182181
=== modified file 'drivers/mtkmodem/radio-settings.c'
--- drivers/mtkmodem/radio-settings.c 2015-09-29 08:46:20 +0000
+++ drivers/mtkmodem/radio-settings.c 2016-07-19 15:19:28 +0000
@@ -105,6 +105,8 @@
105 }105 }
106}106}
107107
108static struct ofono_radio_settings_driver driver;
109
108static int mtk_radio_settings_probe(struct ofono_radio_settings *rs,110static int mtk_radio_settings_probe(struct ofono_radio_settings *rs,
109 unsigned int vendor, void *user)111 unsigned int vendor, void *user)
110{112{
@@ -116,6 +118,7 @@
116 return -ENOMEM;118 return -ENOMEM;
117 }119 }
118120
121 rsd->virt_tbl = &driver;
119 rsd->ril = g_ril_clone(rs_init_data->gril);122 rsd->ril = g_ril_clone(rs_init_data->gril);
120 rsd->modem = rs_init_data->modem;123 rsd->modem = rs_init_data->modem;
121124
@@ -159,6 +162,8 @@
159 available_rats |= OFONO_RADIO_ACCESS_MODE_LTE;162 available_rats |= OFONO_RADIO_ACCESS_MODE_LTE;
160 }163 }
161164
165 rd->available_rats = available_rats;
166
162 CALLBACK_WITH_SUCCESS(cb, available_rats, cbd->data);167 CALLBACK_WITH_SUCCESS(cb, available_rats, cbd->data);
163}168}
164169
165170
=== modified file 'drivers/qcommsimmodem/gprs.c'
--- drivers/qcommsimmodem/gprs.c 2016-04-15 14:12:39 +0000
+++ drivers/qcommsimmodem/gprs.c 2016-07-19 15:19:28 +0000
@@ -104,7 +104,6 @@
104 .remove = ril_gprs_remove,104 .remove = ril_gprs_remove,
105 .set_attached = qcom_msim_gprs_set_attached,105 .set_attached = qcom_msim_gprs_set_attached,
106 .attached_status = ril_gprs_registration_status,106 .attached_status = ril_gprs_registration_status,
107 .set_ia_apn = ril_gprs_set_ia_apn,
108};107};
109108
110void qcom_msim_gprs_init(void)109void qcom_msim_gprs_init(void)
111110
=== modified file 'drivers/qcommsimmodem/radio-settings.c'
--- drivers/qcommsimmodem/radio-settings.c 2016-02-25 11:59:14 +0000
+++ drivers/qcommsimmodem/radio-settings.c 2016-07-19 15:19:28 +0000
@@ -225,6 +225,8 @@
225 qcom_msim_do_set_rat_mode(rs, pref, cbd);225 qcom_msim_do_set_rat_mode(rs, pref, cbd);
226}226}
227227
228static struct ofono_radio_settings_driver driver;
229
228static int qcom_msim_radio_settings_probe(struct ofono_radio_settings *rs,230static int qcom_msim_radio_settings_probe(struct ofono_radio_settings *rs,
229 unsigned int vendor, void *user)231 unsigned int vendor, void *user)
230{232{
@@ -237,6 +239,7 @@
237 return -ENOMEM;239 return -ENOMEM;
238 }240 }
239241
242 rsd->virt_tbl = &driver;
240 rsd->ril = g_ril_clone(rs_init_data->gril);243 rsd->ril = g_ril_clone(rs_init_data->gril);
241 rsd->modem = rs_init_data->modem;244 rsd->modem = rs_init_data->modem;
242245
243246
=== modified file 'drivers/rilmodem/gprs.c'
--- drivers/rilmodem/gprs.c 2016-06-30 17:41:18 +0000
+++ drivers/rilmodem/gprs.c 2016-07-19 15:19:28 +0000
@@ -106,53 +106,6 @@
106 }106 }
107}107}
108108
109static void set_ia_apn_cb(struct ril_msg *message, gpointer user_data)
110{
111 struct cb_data *cbd = user_data;
112 ofono_gprs_cb_t cb = cbd->cb;
113 struct ofono_gprs *gprs = cbd->user;
114 struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
115
116 if (message->error != RIL_E_SUCCESS) {
117 ofono_error("%s: reply failure: %s", __func__,
118 ril_error_to_string(message->error));
119 CALLBACK_WITH_FAILURE(cb, cbd->data);
120 return;
121 }
122
123 g_ril_print_response_no_args(gd->ril, message);
124
125 CALLBACK_WITH_SUCCESS(cb, cbd->data);
126}
127
128void ril_gprs_set_ia_apn(struct ofono_gprs *gprs, const char *apn,
129 enum ofono_gprs_proto proto, const char *user,
130 const char *passwd, const char *mccmnc,
131 ofono_gprs_cb_t cb, void *data)
132{
133 struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
134 struct cb_data *cbd;
135 struct parcel rilp;
136
137 if (!ofono_modem_get_boolean(gd->modem, MODEM_PROP_LTE_CAPABLE)) {
138 CALLBACK_WITH_SUCCESS(cb, data);
139 return;
140 }
141
142 cbd = cb_data_new(cb, data, gprs);
143
144 g_ril_request_set_initial_attach_apn(gd->ril, apn, proto, user, passwd,
145 mccmnc, &rilp);
146
147 if (g_ril_send(gd->ril, RIL_REQUEST_SET_INITIAL_ATTACH_APN,
148 &rilp, set_ia_apn_cb, cbd, g_free) == 0) {
149 ofono_error("%s: failure sending request", __func__);
150
151 g_free(cbd);
152 CALLBACK_WITH_FAILURE(cb, data);
153 }
154}
155
156static void ril_gprs_state_change(struct ril_msg *message, gpointer user_data)109static void ril_gprs_state_change(struct ril_msg *message, gpointer user_data)
157{110{
158 struct ofono_gprs *gprs = user_data;111 struct ofono_gprs *gprs = user_data;
@@ -604,7 +557,6 @@
604 .remove = ril_gprs_remove,557 .remove = ril_gprs_remove,
605 .set_attached = ril_gprs_set_attached,558 .set_attached = ril_gprs_set_attached,
606 .attached_status = ril_gprs_registration_status,559 .attached_status = ril_gprs_registration_status,
607 .set_ia_apn = ril_gprs_set_ia_apn,
608};560};
609561
610void ril_gprs_init(void)562void ril_gprs_init(void)
611563
=== modified file 'drivers/rilmodem/gprs.h'
--- drivers/rilmodem/gprs.h 2016-06-16 13:29:18 +0000
+++ drivers/rilmodem/gprs.h 2016-07-19 15:19:28 +0000
@@ -42,7 +42,3 @@
42 ofono_gprs_cb_t cb, void *data);42 ofono_gprs_cb_t cb, void *data);
43void ril_gprs_registration_status(struct ofono_gprs *gprs,43void ril_gprs_registration_status(struct ofono_gprs *gprs,
44 ofono_gprs_status_cb_t cb, void *data);44 ofono_gprs_status_cb_t cb, void *data);
45void ril_gprs_set_ia_apn(struct ofono_gprs *gprs, const char *apn,
46 enum ofono_gprs_proto proto, const char *user,
47 const char *passwd, const char *mccmnc,
48 ofono_gprs_cb_t cb, void *data);
4945
=== modified file 'drivers/rilmodem/radio-settings.c'
--- drivers/rilmodem/radio-settings.c 2016-06-30 16:41:34 +0000
+++ drivers/rilmodem/radio-settings.c 2016-07-19 15:19:28 +0000
@@ -30,9 +30,11 @@
30#include <stdlib.h>30#include <stdlib.h>
31#include <string.h>31#include <string.h>
32#include <errno.h>32#include <errno.h>
33#include <stdint.h>
3334
34#include <glib.h>35#include <glib.h>
3536
37#include <ofono.h>
36#include <ofono/log.h>38#include <ofono/log.h>
37#include <ofono/modem.h>39#include <ofono/modem.h>
38#include <ofono/radio-settings.h>40#include <ofono/radio-settings.h>
@@ -46,6 +48,63 @@
46#include "grilreply.h"48#include "grilreply.h"
47#include "radio-settings.h"49#include "radio-settings.h"
4850
51struct radio_data *radio_data_0;
52struct radio_data *radio_data_1;
53
54static int g_session;
55
56static struct radio_data *radio_data_complement(struct radio_data *rd)
57{
58 if (rd == radio_data_0)
59 return radio_data_1;
60 else
61 return radio_data_0;
62}
63
64static void set_ia_apn_cb(struct ril_msg *message, gpointer user_data)
65{
66 struct ofono_radio_settings *rs = user_data;
67 struct radio_data *rd = ofono_radio_settings_get_data(rs);
68
69 if (message->error != RIL_E_SUCCESS) {
70 ofono_error("%s: reply failure: %s", __func__,
71 ril_error_to_string(message->error));
72 return;
73 }
74
75 g_ril_print_response_no_args(rd->ril, message);
76}
77
78static void set_ia_apn(struct ofono_radio_settings *rs)
79{
80 char mccmnc[OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1];
81 struct radio_data *rd = ofono_radio_settings_get_data(rs);
82 struct parcel rilp;
83 struct ofono_gprs *gprs;
84 const struct ofono_gprs_primary_context *ia_ctx;
85
86 if ((rd->available_rats & OFONO_RADIO_ACCESS_MODE_LTE) == 0)
87 return;
88
89 gprs = __ofono_atom_find(OFONO_ATOM_TYPE_GPRS, rd->modem);
90 if (gprs == NULL)
91 return;
92
93 /* Ask for APN data */
94 ia_ctx = ofono_gprs_get_ia_apn(gprs, mccmnc);
95 if (ia_ctx == NULL)
96 return;
97
98 g_ril_request_set_initial_attach_apn(rd->ril, ia_ctx->apn,
99 ia_ctx->proto, ia_ctx->username,
100 ia_ctx->password, mccmnc,
101 &rilp);
102
103 if (g_ril_send(rd->ril, RIL_REQUEST_SET_INITIAL_ATTACH_APN,
104 &rilp, set_ia_apn_cb, rs, NULL) == 0)
105 ofono_error("%s: failure sending request", __func__);
106}
107
49static void ril_set_rat_cb(struct ril_msg *message, gpointer user_data)108static void ril_set_rat_cb(struct ril_msg *message, gpointer user_data)
50{109{
51 struct cb_data *cbd = user_data;110 struct cb_data *cbd = user_data;
@@ -54,7 +113,13 @@
54 ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;113 ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
55114
56 if (message->error == RIL_E_SUCCESS) {115 if (message->error == RIL_E_SUCCESS) {
116 rd->rat_mode = rd->pending_mode;
117
57 g_ril_print_response_no_args(rd->ril, message);118 g_ril_print_response_no_args(rd->ril, message);
119
120 if (rd->rat_mode == OFONO_RADIO_ACCESS_MODE_LTE)
121 set_ia_apn(rs);
122
58 CALLBACK_WITH_SUCCESS(cb, cbd->data);123 CALLBACK_WITH_SUCCESS(cb, cbd->data);
59 } else {124 } else {
60 ofono_error("%s: rat mode setting failed", __func__);125 ofono_error("%s: rat mode setting failed", __func__);
@@ -62,13 +127,10 @@
62 }127 }
63}128}
64129
65void ril_set_rat_mode(struct ofono_radio_settings *rs,130static void set_preferred_network(struct radio_data *rd, struct cb_data *cbd,
66 enum ofono_radio_access_mode mode,131 enum ofono_radio_access_mode mode)
67 ofono_radio_settings_rat_mode_set_cb_t cb,
68 void *data)
69{132{
70 struct radio_data *rd = ofono_radio_settings_get_data(rs);133 ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
71 struct cb_data *cbd = cb_data_new(cb, data, rs);
72 struct parcel rilp;134 struct parcel rilp;
73 int pref = PREF_NET_TYPE_GSM_WCDMA;135 int pref = PREF_NET_TYPE_GSM_WCDMA;
74136
@@ -87,14 +149,340 @@
87 break;149 break;
88 }150 }
89151
152 rd->pending_mode = mode;
153
90 g_ril_request_set_preferred_network_type(rd->ril, pref, &rilp);154 g_ril_request_set_preferred_network_type(rd->ril, pref, &rilp);
91155
92 if (g_ril_send(rd->ril, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,156 if (g_ril_send(rd->ril, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
93 &rilp, ril_set_rat_cb, cbd, g_free) == 0) {157 &rilp, ril_set_rat_cb, cbd, g_free) == 0) {
94 ofono_error("%s: unable to set rat mode", __func__);158 ofono_error("%s: unable to set rat mode", __func__);
95 g_free(cbd);159 g_free(cbd);
96 CALLBACK_WITH_FAILURE(cb, data);160 CALLBACK_WITH_FAILURE(cb, cbd->data);
97 }161 }
162}
163
164static gboolean send_set_radio_cap(struct radio_data *rd,
165 int session, int phase, int ril_rats,
166 const char *logical_modem, int status,
167 GRilResponseFunc cb)
168{
169 struct parcel rilp;
170 int version = 1;
171
172 parcel_init(&rilp);
173
174 parcel_w_int32(&rilp, version);
175 parcel_w_int32(&rilp, session);
176 parcel_w_int32(&rilp, phase);
177 parcel_w_int32(&rilp, ril_rats);
178 parcel_w_string(&rilp, logical_modem);
179 parcel_w_int32(&rilp, status);
180
181 g_ril_append_print_buf(rd->ril, "(%d,%d,%d,0x%X,%s,%d)", version,
182 session, phase, ril_rats, logical_modem, status);
183
184 if (g_ril_send(rd->ril, RIL_REQUEST_SET_RADIO_CAPABILITY,
185 &rilp, cb, rd, NULL) == 0)
186 return FALSE;
187
188 return TRUE;
189}
190
191static unsigned set_rat_from_ril_rat(int ril_rat)
192{
193 unsigned rat = 0;
194
195 if (ril_rat & RIL_RAF_GSM)
196 rat |= OFONO_RADIO_ACCESS_MODE_GSM;
197
198 if (ril_rat & (RIL_RAF_UMTS | RIL_RAF_TD_SCDMA))
199 rat |= OFONO_RADIO_ACCESS_MODE_UMTS;
200
201 if (ril_rat & RIL_RAF_LTE)
202 rat |= OFONO_RADIO_ACCESS_MODE_LTE;
203
204 return rat;
205}
206
207static void set_preferred_cb(const struct ofono_error *error, void *data)
208{
209 struct radio_data *rd = data;
210
211 if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
212 ofono_error("%s: error setting radio access mode", __func__);
213
214 return;
215 }
216
217 ofono_radio_settings_set_rat_mode(rd->radio_settings, rd->rat_mode);
218}
219
220static enum ofono_radio_access_mode
221 get_best_available_tech(unsigned available_rats)
222{
223 int i;
224 uint32_t tech;
225
226 for (i = sizeof(uint32_t) * CHAR_BIT; i > 0; i--) {
227 tech = 1 << (i - 1);
228
229 if ((available_rats & tech) != 0)
230 break;
231 }
232
233 if (i == 0)
234 tech = OFONO_RADIO_ACCESS_MODE_GSM;
235
236 return tech;
237}
238
239static void switch_finish_cb(struct ril_msg *message, gpointer user_data)
240{
241 struct radio_data *rd = user_data;
242 struct switch_data *sd = rd->switch_d;
243 struct radio_data *rd1 = sd->rd_1;
244 struct radio_data *rd2 = sd->rd_2;
245 struct reply_radio_capability *caps;
246
247 sd->pending_msgs--;
248
249 if (message->error != RIL_E_SUCCESS) {
250 ofono_error("%s: error %s", __func__,
251 ril_error_to_string(message->error));
252 return;
253 }
254
255 caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
256 if (caps == NULL) {
257 ofono_error("%s: parse error", __func__);
258 return;
259 }
260
261 if (sd->pending_msgs != 0)
262 return;
263
264 ofono_info("Switching radio caps between slots - FINISH");
265
266 set_preferred_network(rd1, sd->cbd, sd->mode_to_switch);
267
268 /*
269 * If the complementary slot does not support anymore its current
270 * technology, we change it to the best possible among available ones.
271 */
272 if ((rd2->rat_mode & rd2->available_rats) == 0) {
273
274 struct cb_data *cbd =
275 cb_data_new(set_preferred_cb, rd2, rd2->radio_settings);
276
277 set_preferred_network(rd2, cbd,
278 get_best_available_tech(rd2->available_rats));
279 }
280
281 rd1->switch_d = NULL;
282 rd2->switch_d = NULL;
283 g_free(sd);
284 g_free(caps);
285}
286
287static void radio_caps_event(struct ril_msg *message, gpointer user_data)
288{
289 struct radio_data *rd = user_data;
290 struct switch_data *sd = rd->switch_d;
291 struct radio_data *rd1;
292 struct radio_data *rd2;
293 struct reply_radio_capability *caps;
294
295 if (sd == NULL)
296 return;
297
298 rd1 = sd->rd_1;
299 rd2 = sd->rd_2;
300
301 caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
302 if (caps == NULL) {
303 ofono_error("%s: parse error", __func__);
304 return;
305 }
306
307 /*
308 * Update rats. They come also in the replies to SET_RADIO_CAPABILITY,
309 * but those seem to be unreliable, at least for midori.
310 */
311 rd->ril_rats = caps->rat;
312 rd->available_rats = set_rat_from_ril_rat(caps->rat);
313
314 strcpy(rd->modem_uuid, caps->modem_uuid);
315
316 sd->pending_msgs--;
317
318 if (sd->pending_msgs != 0)
319 return;
320
321 DBG("Sending requests for FINISH phase");
322
323 send_set_radio_cap(rd1, g_session, RIL_RC_PHASE_FINISH,
324 rd1->ril_rats, rd1->modem_uuid,
325 RIL_RC_STATUS_SUCCESS, switch_finish_cb);
326 send_set_radio_cap(rd2, g_session, RIL_RC_PHASE_FINISH,
327 rd2->ril_rats, rd2->modem_uuid,
328 RIL_RC_STATUS_SUCCESS, switch_finish_cb);
329 sd->pending_msgs = 2;
330
331 g_free(caps);
332}
333
334/*
335 * This function is just for completeness, as we actually need to wait for the
336 * unsolocited events to continue the capabilities switch.
337 */
338static void switch_apply_cb(struct ril_msg *message, gpointer user_data)
339{
340 struct radio_data *rd = user_data;
341 struct reply_radio_capability *caps;
342
343 if (message->error != RIL_E_SUCCESS) {
344 ofono_error("%s: error %s", __func__,
345 ril_error_to_string(message->error));
346 return;
347 }
348
349 caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
350 if (caps == NULL)
351 ofono_error("%s: parse error", __func__);
352
353 g_free(caps);
354}
355
356static void switch_start_cb(struct ril_msg *message, gpointer user_data)
357{
358 struct radio_data *rd = user_data;
359 struct switch_data *sd = rd->switch_d;
360 struct radio_data *rd1 = sd->rd_1;
361 struct radio_data *rd2 = sd->rd_2;
362 struct reply_radio_capability *caps;
363
364 sd->pending_msgs--;
365
366 if (message->error != RIL_E_SUCCESS) {
367 ofono_error("%s: error %s", __func__,
368 ril_error_to_string(message->error));
369 return;
370 }
371
372 caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
373 if (caps == NULL) {
374 ofono_error("%s: parse error", __func__);
375 return;
376 }
377
378 if (sd->pending_msgs != 0)
379 return;
380
381 DBG("Sending requests for APPLY phase");
382
383 send_set_radio_cap(rd1, g_session, RIL_RC_PHASE_APPLY,
384 rd2->ril_rats, rd2->modem_uuid,
385 RIL_RC_STATUS_NONE, switch_apply_cb);
386 send_set_radio_cap(rd2, g_session, RIL_RC_PHASE_APPLY,
387 rd1->ril_rats, rd1->modem_uuid,
388 RIL_RC_STATUS_NONE, switch_apply_cb);
389 sd->pending_msgs = 2;
390
391 g_free(caps);
392}
393
394static void switch_caps(struct switch_data *sd)
395{
396 struct radio_data *rd1 = sd->rd_1;
397 struct radio_data *rd2 = sd->rd_2;
398
399 /* START phase */
400 g_session++;
401
402 send_set_radio_cap(rd1, g_session, RIL_RC_PHASE_START,
403 rd1->ril_rats, rd1->modem_uuid,
404 RIL_RC_STATUS_NONE, switch_start_cb);
405 send_set_radio_cap(rd2, g_session, RIL_RC_PHASE_START,
406 rd2->ril_rats, rd2->modem_uuid,
407 RIL_RC_STATUS_NONE, switch_start_cb);
408 sd->pending_msgs = 2;
409}
410
411static void get_rs_with_mode(struct ofono_modem *modem, void *data)
412{
413 struct switch_data *sd = data;
414 struct radio_data *rd_ref = sd->rd_1;
415 struct ofono_atom *atom;
416 struct ofono_radio_settings *rs;
417 struct radio_data *rd;
418 const char *standby_group, *modem_group;
419
420 atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_RADIO_SETTINGS);
421 if (atom == NULL)
422 return;
423
424 rs = __ofono_atom_get_data(atom);
425 rd = ofono_radio_settings_get_data(rs);
426 if (rd == rd_ref)
427 return;
428
429 standby_group = ofono_modem_get_string(rd_ref->modem, "StandbyGroup");
430 if (standby_group == NULL)
431 return;
432
433 modem_group = ofono_modem_get_string(modem, "StandbyGroup");
434 if (g_strcmp0(standby_group, modem_group) != 0)
435 return;
436
437 if ((rd->available_rats & sd->mode_to_switch) == 0)
438 return;
439
440 sd->rd_2 = rd;
441}
442
443void ril_set_rat_mode(struct ofono_radio_settings *rs,
444 enum ofono_radio_access_mode mode,
445 ofono_radio_settings_rat_mode_set_cb_t cb,
446 void *data)
447{
448 struct radio_data *rd = ofono_radio_settings_get_data(rs);
449 struct cb_data *cbd = cb_data_new(cb, data, rs);
450 struct switch_data *sd = NULL;
451
452 if (rd->switch_d != NULL)
453 goto error;
454
455 if ((rd->available_rats & mode) == 0) {
456 if (g_ril_get_version(rd->ril) < 11)
457 goto error;
458
459 /* Check if we can switch rats with other slot */
460 sd = g_malloc0(sizeof (*sd));
461 sd->rd_1 = rd;
462 sd->mode_to_switch = mode;
463 sd->cbd = cbd;
464
465 __ofono_modem_foreach(get_rs_with_mode, sd);
466
467 if (sd->rd_2 == NULL)
468 goto error;
469
470 ofono_info("Switching radio caps between slots - START");
471 sd->rd_1->switch_d = sd;
472 sd->rd_2->switch_d = sd;
473
474 switch_caps(sd);
475 } else {
476 set_preferred_network(rd, cbd, mode);
477 }
478
479 return;
480
481error:
482 ofono_error("%s: unable to set rat mode", __func__);
483 g_free(sd);
484 g_free(cbd);
485 CALLBACK_WITH_FAILURE(cb, data);
98}486}
99487
100static void ril_rat_mode_cb(struct ril_msg *message, gpointer user_data)488static void ril_rat_mode_cb(struct ril_msg *message, gpointer user_data)
@@ -108,15 +496,13 @@
108 if (message->error != RIL_E_SUCCESS) {496 if (message->error != RIL_E_SUCCESS) {
109 ofono_error("%s: error %s", __func__,497 ofono_error("%s: error %s", __func__,
110 ril_error_to_string(message->error));498 ril_error_to_string(message->error));
111 CALLBACK_WITH_FAILURE(cb, -1, cbd->data);499 goto error;
112 return;
113 }500 }
114501
115 pref = g_ril_reply_parse_get_preferred_network_type(rd->ril, message);502 pref = g_ril_reply_parse_get_preferred_network_type(rd->ril, message);
116 if (pref < 0) {503 if (pref < 0) {
117 ofono_error("%s: parse error", __func__);504 ofono_error("%s: parse error", __func__);
118 CALLBACK_WITH_FAILURE(cb, -1, cbd->data);505 goto error;
119 return;
120 }506 }
121507
122 /*508 /*
@@ -144,7 +530,22 @@
144 break;530 break;
145 }531 }
146532
533 rd->rat_mode = mode;
534
147 CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);535 CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
536
537 return;
538
539error:
540 /*
541 * If error, we assume GSM. This is preferable to not being able to
542 * access the radio settings properties. Midori returns error if we
543 * have not completed successfully a capability switch. This should
544 * not happen if there are no bugs in our implementation, but it is
545 * better to leave this here so system settings shows something that
546 * can be manually changed by the user, just in case.
547 */
548 CALLBACK_WITH_SUCCESS(cb, OFONO_RADIO_ACCESS_MODE_GSM, cbd->data);
148}549}
149550
150void ril_query_rat_mode(struct ofono_radio_settings *rs,551void ril_query_rat_mode(struct ofono_radio_settings *rs,
@@ -211,19 +612,18 @@
211612
212static ofono_bool_t query_available_rats_cb(gpointer user_data)613static ofono_bool_t query_available_rats_cb(gpointer user_data)
213{614{
214 unsigned int available_rats;
215 struct cb_data *cbd = user_data;615 struct cb_data *cbd = user_data;
216 ofono_radio_settings_available_rats_query_cb_t cb = cbd->cb;616 ofono_radio_settings_available_rats_query_cb_t cb = cbd->cb;
217 struct ofono_radio_settings *rs = cbd->user;617 struct ofono_radio_settings *rs = cbd->user;
218 struct radio_data *rd = ofono_radio_settings_get_data(rs);618 struct radio_data *rd = ofono_radio_settings_get_data(rs);
219619
220 available_rats = OFONO_RADIO_ACCESS_MODE_GSM620 rd->available_rats = OFONO_RADIO_ACCESS_MODE_GSM
221 | OFONO_RADIO_ACCESS_MODE_UMTS;621 | OFONO_RADIO_ACCESS_MODE_UMTS;
222622
223 if (ofono_modem_get_boolean(rd->modem, MODEM_PROP_LTE_CAPABLE))623 if (getenv("OFONO_RIL_RAT_LTE") != NULL)
224 available_rats |= OFONO_RADIO_ACCESS_MODE_LTE;624 rd->available_rats |= OFONO_RADIO_ACCESS_MODE_LTE;
225625
226 CALLBACK_WITH_SUCCESS(cb, available_rats, cbd->data);626 CALLBACK_WITH_SUCCESS(cb, rd->available_rats, cbd->data);
227627
228 g_free(cbd);628 g_free(cbd);
229629
@@ -232,12 +632,13 @@
232632
233static void get_radio_caps_cb(struct ril_msg *message, gpointer user_data)633static void get_radio_caps_cb(struct ril_msg *message, gpointer user_data)
234{634{
235 unsigned int available_rats = 0;
236 struct cb_data *cbd = user_data;635 struct cb_data *cbd = user_data;
237 ofono_radio_settings_available_rats_query_cb_t cb = cbd->cb;636 ofono_radio_settings_available_rats_query_cb_t cb = cbd->cb;
238 struct ofono_radio_settings *rs = cbd->user;637 struct ofono_radio_settings *rs = cbd->user;
239 struct radio_data *rd = ofono_radio_settings_get_data(rs);638 struct radio_data *rd = ofono_radio_settings_get_data(rs);
639 struct radio_data *rd_comp;
240 struct reply_radio_capability *caps;640 struct reply_radio_capability *caps;
641 unsigned all_rats;
241642
242 if (message->error != RIL_E_SUCCESS) {643 if (message->error != RIL_E_SUCCESS) {
243 ofono_error("%s: error %s", __func__,644 ofono_error("%s: error %s", __func__,
@@ -253,18 +654,21 @@
253 return;654 return;
254 }655 }
255656
256 if (caps->rat & RIL_RAF_GSM)657 rd->ril_rats = caps->rat;
257 available_rats |= OFONO_RADIO_ACCESS_MODE_GSM;658 rd->available_rats = set_rat_from_ril_rat(caps->rat);
258659
259 if (caps->rat & (RIL_RAF_UMTS | RIL_RAF_TD_SCDMA))660 strcpy(rd->modem_uuid, caps->modem_uuid);
260 available_rats |= OFONO_RADIO_ACCESS_MODE_UMTS;
261
262 if (caps->rat & RIL_RAF_LTE)
263 available_rats |= OFONO_RADIO_ACCESS_MODE_LTE;
264661
265 g_free(caps);662 g_free(caps);
266663
267 CALLBACK_WITH_SUCCESS(cb, available_rats, cbd->data);664 /* We show all rats, as we can switch the ownership between slots */
665 all_rats = rd->available_rats;
666
667 rd_comp = radio_data_complement(rd);
668 if (rd_comp != NULL)
669 all_rats |= rd_comp->available_rats;
670
671 CALLBACK_WITH_SUCCESS(cb, all_rats, cbd->data);
268}672}
269673
270void ril_query_available_rats(struct ofono_radio_settings *rs,674void ril_query_available_rats(struct ofono_radio_settings *rs,
@@ -286,20 +690,90 @@
286 }690 }
287}691}
288692
693static void gprs_watch_cb(struct ofono_atom *atom,
694 enum ofono_atom_watch_condition cond,
695 void *data)
696{
697 struct ofono_radio_settings *rs = data;
698
699 if (cond != OFONO_ATOM_WATCH_CONDITION_REGISTERED)
700 return;
701
702 set_ia_apn(rs);
703}
704
705static void set_safe_preferred_cb(const struct ofono_error *error, void *data)
706{
707 if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
708 ofono_error("%s: error setting radio access mode", __func__);
709
710 return;
711 }
712}
713
714static void radio_settings_register(const struct ofono_error *error,
715 unsigned int available_rats,
716 void *data)
717{
718 struct ofono_radio_settings *rs = data;
719 struct radio_data *rd = ofono_radio_settings_get_data(rs);
720
721 g_ril_register(rd->ril, RIL_UNSOL_RADIO_CAPABILITY,
722 radio_caps_event, rd);
723
724 rd->gprs_atom_watch =
725 __ofono_modem_add_atom_watch(rd->modem, OFONO_ATOM_TYPE_GPRS,
726 gprs_watch_cb, rs, NULL);
727
728 /*
729 * If the preferred technology was unknown/unsupported, change to a
730 * valid one (midori can return PREF_NET_TYPE_CDMA_ONLY, for instance).
731 */
732 if (rd->rat_mode == OFONO_RADIO_ACCESS_MODE_ANY) {
733 struct cb_data *cbd = cb_data_new(set_safe_preferred_cb, rd,
734 rd->radio_settings);
735
736 set_preferred_network(rd, cbd,
737 get_best_available_tech(rd->available_rats));
738 }
739
740 /*
741 * We register in all cases, setting FD some times fails until radio is
742 * available (this happens on turbo and maybe in other devices).
743 */
744 ofono_radio_settings_register(rs);
745}
746
747static void ril_after_query_rat_mode(const struct ofono_error *error,
748 enum ofono_radio_access_mode mode,
749 void *data)
750{
751 struct ofono_radio_settings *rs = data;
752 struct radio_data *rd = ofono_radio_settings_get_data(rs);
753
754 rd->virt_tbl->query_available_rats(rs, radio_settings_register, rs);
755}
756
289void ril_delayed_register(const struct ofono_error *error, void *user_data)757void ril_delayed_register(const struct ofono_error *error, void *user_data)
290{758{
291 struct ofono_radio_settings *rs = user_data;759 struct ofono_radio_settings *rs = user_data;
760 struct radio_data *rd = ofono_radio_settings_get_data(rs);
292761
293 if (error->type != OFONO_ERROR_TYPE_NO_ERROR)762 if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
294 ofono_error("%s: cannot set default fast dormancy", __func__);763 ofono_error("%s: cannot set default fast dormancy", __func__);
295764
296 /*765 rd->radio_settings = rs;
297 * We register in all cases, setting FD some times fails until radio is766
298 * available (this happens on turbo and maybe in other devices).767 if (ofono_modem_get_integer(rd->modem, "Slot") == 0)
299 */768 radio_data_0 = rd;
300 ofono_radio_settings_register(rs);769 else
770 radio_data_1 = rd;
771
772 rd->virt_tbl->query_rat_mode(rs, ril_after_query_rat_mode, rs);
301}773}
302774
775static struct ofono_radio_settings_driver driver;
776
303static int ril_radio_settings_probe(struct ofono_radio_settings *rs,777static int ril_radio_settings_probe(struct ofono_radio_settings *rs,
304 unsigned int vendor, void *user)778 unsigned int vendor, void *user)
305{779{
@@ -311,6 +785,7 @@
311 return -ENOMEM;785 return -ENOMEM;
312 }786 }
313787
788 rsd->virt_tbl = &driver;
314 rsd->ril = g_ril_clone(rs_init_data->gril);789 rsd->ril = g_ril_clone(rs_init_data->gril);
315 rsd->modem = rs_init_data->modem;790 rsd->modem = rs_init_data->modem;
316791
@@ -324,8 +799,12 @@
324void ril_radio_settings_remove(struct ofono_radio_settings *rs)799void ril_radio_settings_remove(struct ofono_radio_settings *rs)
325{800{
326 struct radio_data *rd = ofono_radio_settings_get_data(rs);801 struct radio_data *rd = ofono_radio_settings_get_data(rs);
802
327 ofono_radio_settings_set_data(rs, NULL);803 ofono_radio_settings_set_data(rs, NULL);
328804
805 if (rd->gprs_atom_watch)
806 __ofono_modem_remove_atom_watch(rd->modem, rd->gprs_atom_watch);
807
329 g_ril_unref(rd->ril);808 g_ril_unref(rd->ril);
330 g_free(rd);809 g_free(rd);
331}810}
332811
=== modified file 'drivers/rilmodem/radio-settings.h'
--- drivers/rilmodem/radio-settings.h 2015-07-31 13:44:26 +0000
+++ drivers/rilmodem/radio-settings.h 2016-07-19 15:19:28 +0000
@@ -19,11 +19,30 @@
19 *19 *
20 */20 */
2121
22struct switch_data;
23
22struct radio_data {24struct radio_data {
25 struct ofono_radio_settings_driver *virt_tbl;
23 GRil *ril;26 GRil *ril;
24 struct ofono_modem *modem;27 struct ofono_modem *modem;
28 struct ofono_radio_settings *radio_settings;
25 gboolean fast_dormancy;29 gboolean fast_dormancy;
26 gboolean pending_fd;30 gboolean pending_fd;
31 int rat_mode;
32 int pending_mode;
33 unsigned available_rats;
34 int ril_rats;
35 char modem_uuid[RIL_MAX_UUID_LENGTH];
36 struct switch_data *switch_d;
37 unsigned gprs_atom_watch;
38};
39
40struct switch_data {
41 struct radio_data *rd_1;
42 struct radio_data *rd_2;
43 enum ofono_radio_access_mode mode_to_switch;
44 int pending_msgs;
45 struct cb_data *cbd;
27};46};
2847
29void ril_delayed_register(const struct ofono_error *error, void *user_data);48void ril_delayed_register(const struct ofono_error *error, void *user_data);
3049
=== modified file 'gril/grilreply.c'
--- gril/grilreply.c 2016-06-28 15:26:37 +0000
+++ gril/grilreply.c 2016-07-19 15:19:28 +0000
@@ -1477,8 +1477,11 @@
1477 reply->phase = parcel_r_int32(&rilp);1477 reply->phase = parcel_r_int32(&rilp);
1478 reply->rat = parcel_r_int32(&rilp);1478 reply->rat = parcel_r_int32(&rilp);
1479 modem_uuid = parcel_r_string(&rilp);1479 modem_uuid = parcel_r_string(&rilp);
1480 if (modem_uuid != NULL)1480 if (modem_uuid != NULL) {
1481 strcpy(reply->modem_uuid, modem_uuid);1481 strncpy(reply->modem_uuid, modem_uuid,
1482 sizeof(reply->modem_uuid) - 1);
1483 g_free(modem_uuid);
1484 }
14821485
1483 reply->status = parcel_r_int32(&rilp);1486 reply->status = parcel_r_int32(&rilp);
14841487
@@ -1552,7 +1555,10 @@
1552 reply->modem_uuid,1555 reply->modem_uuid,
1553 ril_rc_status_to_string(reply->status));1556 ril_rc_status_to_string(reply->status));
15541557
1555 g_ril_print_response(gril, message);1558 if (message->unsolicited)
1559 g_ril_print_unsol(gril, message);
1560 else
1561 g_ril_print_response(gril, message);
15561562
1557end:1563end:
1558 return reply;1564 return reply;
15591565
=== modified file 'include/gprs.h'
--- include/gprs.h 2015-01-28 13:58:34 +0000
+++ include/gprs.h 2016-07-19 15:19:28 +0000
@@ -46,10 +46,6 @@
46 ofono_gprs_cb_t cb, void *data);46 ofono_gprs_cb_t cb, void *data);
47 void (*attached_status)(struct ofono_gprs *gprs,47 void (*attached_status)(struct ofono_gprs *gprs,
48 ofono_gprs_status_cb_t cb, void *data);48 ofono_gprs_status_cb_t cb, void *data);
49 void (*set_ia_apn)(struct ofono_gprs *gprs, const char *apn,
50 enum ofono_gprs_proto proto, const char *user,
51 const char *passwd, const char *mccmnc,
52 ofono_gprs_cb_t cb, void *data);
53};49};
5450
55enum gprs_suspend_cause {51enum gprs_suspend_cause {
@@ -82,6 +78,8 @@
82 unsigned int min, unsigned int max);78 unsigned int min, unsigned int max);
83void ofono_gprs_add_context(struct ofono_gprs *gprs,79void ofono_gprs_add_context(struct ofono_gprs *gprs,
84 struct ofono_gprs_context *gc);80 struct ofono_gprs_context *gc);
81const struct ofono_gprs_primary_context *ofono_gprs_get_ia_apn(
82 struct ofono_gprs *gprs, char *mccmnc);
8583
86#ifdef __cplusplus84#ifdef __cplusplus
87}85}
8886
=== modified file 'plugins/ril.c'
--- plugins/ril.c 2016-06-30 17:41:18 +0000
+++ plugins/ril.c 2016-07-19 15:19:28 +0000
@@ -128,6 +128,33 @@
128 return RILMODEM;128 return RILMODEM;
129}129}
130130
131/*
132 * oFono moves to "Online" state only when told to online the modem AND there is
133 * a SIM a card. However, we want to have RadioSettings even when there is no
134 * SIM, but we also want it *only* when we are online. Normally, ofono atoms are
135 * created/destroyed when the ofono state changes, but for this atom the ofono
136 * states do not fit, as we do never move from Offline state if there is no SIM.
137 * Therefore, we handle this atom on modem onlining/offlining.
138 */
139static void manage_radio_settings_atom(struct ofono_modem *modem)
140{
141 struct ril_data *rd = ofono_modem_get_data(modem);
142 struct ofono_radio_settings *rs;
143
144 rs = __ofono_atom_find(OFONO_ATOM_TYPE_RADIO_SETTINGS, modem);
145
146 if (rd->ofono_online && rs == NULL) {
147 struct ril_radio_settings_driver_data rs_data =
148 { rd->ril, modem };
149
150 ofono_radio_settings_create(modem, rd->vendor,
151 get_driver_type(rd, OFONO_ATOM_TYPE_RADIO_SETTINGS),
152 &rs_data);
153 } else if(!rd->ofono_online && rs != NULL) {
154 ofono_radio_settings_remove(rs);
155 }
156}
157
131static void ril_send_power(struct ril_data *rd, ofono_bool_t online,158static void ril_send_power(struct ril_data *rd, ofono_bool_t online,
132 GRilResponseFunc func, gpointer user_data)159 GRilResponseFunc func, gpointer user_data)
133{160{
@@ -206,6 +233,8 @@
206233
207 DBG("%s: set_online OK: rd->ofono_online: %d",234 DBG("%s: set_online OK: rd->ofono_online: %d",
208 __func__, rd->ofono_online);235 __func__, rd->ofono_online);
236 manage_radio_settings_atom(modem);
237
209 CALLBACK_WITH_SUCCESS(cb, rd->set_online_cbd->data);238 CALLBACK_WITH_SUCCESS(cb, rd->set_online_cbd->data);
210239
211 g_free(rd->set_online_cbd);240 g_free(rd->set_online_cbd);
@@ -286,7 +315,6 @@
286 struct ril_data *rd = ofono_modem_get_data(modem);315 struct ril_data *rd = ofono_modem_get_data(modem);
287 struct ril_voicecall_driver_data vc_data = { rd->ril, modem };316 struct ril_voicecall_driver_data vc_data = { rd->ril, modem };
288 struct ril_sim_data sim_data;317 struct ril_sim_data sim_data;
289 struct ril_radio_settings_driver_data rs_data = { rd->ril, modem };
290318
291 DBG("");319 DBG("");
292320
@@ -306,16 +334,6 @@
306334
307 rd->sim = ofono_sim_create(modem, rd->vendor,335 rd->sim = ofono_sim_create(modem, rd->vendor,
308 get_driver_type(rd, OFONO_ATOM_TYPE_SIM), &sim_data);336 get_driver_type(rd, OFONO_ATOM_TYPE_SIM), &sim_data);
309
310 /*
311 * We need to create radio settings here so FastDormancy property is
312 * available even when there is no SIM (no SIM -> post_sim and
313 * post_online are not called) so we can make the modem enter low power
314 * state in that case.
315 */
316 ofono_radio_settings_create(modem, rd->vendor,
317 get_driver_type(rd, OFONO_ATOM_TYPE_RADIO_SETTINGS),
318 &rs_data);
319}337}
320338
321void ril_post_sim(struct ofono_modem *modem)339void ril_post_sim(struct ofono_modem *modem)
@@ -334,7 +352,7 @@
334 get_driver_type(rd, OFONO_ATOM_TYPE_PHONEBOOK), modem);352 get_driver_type(rd, OFONO_ATOM_TYPE_PHONEBOOK), modem);
335}353}
336354
337static void create_post_online_atoms(struct ofono_modem *modem)355void ril_post_online(struct ofono_modem *modem)
338{356{
339 struct ril_data *rd = ofono_modem_get_data(modem);357 struct ril_data *rd = ofono_modem_get_data(modem);
340 struct ofono_gprs *gprs;358 struct ofono_gprs *gprs;
@@ -382,47 +400,6 @@
382 }400 }
383}401}
384402
385static void get_radio_caps_cb(struct ril_msg *message, gpointer user_data)
386{
387 struct ofono_modem *modem = user_data;
388 struct ril_data *rd = ofono_modem_get_data(modem);
389 struct reply_radio_capability *caps;
390
391 if (message->error == RIL_E_SUCCESS) {
392 caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
393 if (caps != NULL && (caps->rat & RIL_RAF_LTE)) {
394 ofono_modem_set_boolean(modem,
395 MODEM_PROP_LTE_CAPABLE, TRUE);
396 g_free(caps);
397 }
398 } else {
399 ofono_error("%s: RIL error %s", __func__,
400 ril_error_to_string(message->error));
401 }
402
403 create_post_online_atoms(modem);
404}
405
406void ril_post_online(struct ofono_modem *modem)
407{
408 struct ril_data *rd = ofono_modem_get_data(modem);
409 ofono_bool_t lte_cap;
410
411 /* Radio ON -> we can ask for capabilities */
412 if (g_ril_get_version(rd->ril) >= 11) {
413 if (g_ril_send(rd->ril, RIL_REQUEST_GET_RADIO_CAPABILITY, NULL,
414 get_radio_caps_cb, modem, NULL))
415 return;
416
417 ofono_error("%s: error sending GET_RADIO_CAPABILITY", __func__);
418 }
419
420 lte_cap = getenv("OFONO_RIL_RAT_LTE") ? TRUE : FALSE;
421 ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap);
422
423 create_post_online_atoms(modem);
424}
425
426static void ril_set_online_cb(struct ril_msg *message, gpointer user_data)403static void ril_set_online_cb(struct ril_msg *message, gpointer user_data)
427{404{
428 struct ril_data *rd = user_data;405 struct ril_data *rd = user_data;
@@ -449,11 +426,14 @@
449static gboolean set_online_done_cb(gpointer user_data)426static gboolean set_online_done_cb(gpointer user_data)
450{427{
451 struct cb_data *cbd = user_data;428 struct cb_data *cbd = user_data;
452 struct ril_data *rd = cbd->user;429 struct ofono_modem *modem = cbd->user;
430 struct ril_data *rd = ofono_modem_get_data(modem);
453 ofono_modem_online_cb_t cb = cbd->cb;431 ofono_modem_online_cb_t cb = cbd->cb;
454432
455 DBG("%s: set_online OK: rd->ofono_online: %d",433 DBG("%s: set_online OK: rd->ofono_online: %d",
456 __func__, rd->ofono_online);434 __func__, rd->ofono_online);
435 manage_radio_settings_atom(modem);
436
457 CALLBACK_WITH_SUCCESS(cb, cbd->data);437 CALLBACK_WITH_SUCCESS(cb, cbd->data);
458 g_free(cbd);438 g_free(cbd);
459439
@@ -464,7 +444,7 @@
464 ofono_modem_online_cb_t callback, void *data)444 ofono_modem_online_cb_t callback, void *data)
465{445{
466 struct ril_data *rd = ofono_modem_get_data(modem);446 struct ril_data *rd = ofono_modem_get_data(modem);
467 struct cb_data *cbd = cb_data_new(callback, data, rd);447 struct cb_data *cbd = cb_data_new(callback, data, modem);
468448
469 rd->ofono_online = online;449 rd->ofono_online = online;
470450
471451
=== modified file 'src/gprs.c'
--- src/gprs.c 2016-06-28 15:26:37 +0000
+++ src/gprs.c 2016-07-19 15:19:28 +0000
@@ -3444,32 +3444,20 @@
3444 return gprs->contexts->data;3444 return gprs->contexts->data;
3445}3445}
34463446
3447static void set_ia_apn_cb(const struct ofono_error *error, void *data)3447const struct ofono_gprs_primary_context *ofono_gprs_get_ia_apn(
3448{3448 struct ofono_gprs *gprs, char *mccmnc)
3449 if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
3450 ofono_error("Could not set IA APN");
3451}
3452
3453static void set_ia_apn(struct ofono_gprs *gprs)
3454{3449{
3455 struct pri_context *ctx = gprs_context_for_ia(gprs);3450 struct pri_context *ctx = gprs_context_for_ia(gprs);
3456 struct ofono_gprs_primary_context *ofono_ctx;
3457 char mccmnc[OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1];
3458 const char *mcc = ofono_sim_get_mcc(gprs->sim);3451 const char *mcc = ofono_sim_get_mcc(gprs->sim);
3459 const char *mnc = ofono_sim_get_mnc(gprs->sim);3452 const char *mnc = ofono_sim_get_mnc(gprs->sim);
34603453
3461 if (ctx == NULL)3454 if (ctx == NULL)
3462 return;3455 return NULL;
3463
3464 ofono_ctx = &ctx->context;
34653456
3466 strcpy(mccmnc, mcc);3457 strcpy(mccmnc, mcc);
3467 strcpy(mccmnc + strlen(mcc), mnc);3458 strcpy(mccmnc + strlen(mcc), mnc);
34683459
3469 gprs->driver->set_ia_apn(gprs, ofono_ctx->apn, ofono_ctx->proto,3460 return &ctx->context;
3470 ofono_ctx->username,
3471 ofono_ctx->password, mccmnc,
3472 set_ia_apn_cb, gprs);
3473}3461}
34743462
3475static void ofono_gprs_finish_register(struct ofono_gprs *gprs)3463static void ofono_gprs_finish_register(struct ofono_gprs *gprs)
@@ -3481,9 +3469,6 @@
3481 if (gprs->contexts == NULL) /* Automatic provisioning failed */3469 if (gprs->contexts == NULL) /* Automatic provisioning failed */
3482 add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);3470 add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
34833471
3484 if (gprs->driver->set_ia_apn)
3485 set_ia_apn(gprs);
3486
3487 if (!g_dbus_register_interface(conn, path,3472 if (!g_dbus_register_interface(conn, path,
3488 OFONO_CONNECTION_MANAGER_INTERFACE,3473 OFONO_CONNECTION_MANAGER_INTERFACE,
3489 manager_methods, manager_signals, NULL,3474 manager_methods, manager_signals, NULL,

Subscribers

People subscribed via source and target branches

to all changes: