Merge lp:~phablet-team/ofono/arale-enablement into lp:~phablet-team/ofono/ubuntu
- arale-enablement
- Merge into ubuntu
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Alfonso Sanchez-Beato | ||||||||
Approved revision: | 6886 | ||||||||
Merged at revision: | 6886 | ||||||||
Proposed branch: | lp:~phablet-team/ofono/arale-enablement | ||||||||
Merge into: | lp:~phablet-team/ofono/ubuntu | ||||||||
Diff against target: |
5469 lines (+3206/-570) 51 files modified
debian/changelog (+37/-0) drivers/mtkmodem/gprs.c (+3/-5) drivers/mtkmodem/mtk_constants.h (+4/-0) drivers/mtkmodem/mtkreply.c (+31/-0) drivers/mtkmodem/mtkreply.h (+3/-0) drivers/mtkmodem/mtkrequest.c (+28/-0) drivers/mtkmodem/mtkrequest.h (+28/-0) drivers/mtkmodem/mtkunsol.c (+31/-0) drivers/mtkmodem/mtkunsol.h (+4/-0) drivers/mtkmodem/mtkutil.c (+8/-0) drivers/mtkmodem/mtkutil.h (+0/-5) drivers/mtkmodem/radio-settings.c (+4/-3) drivers/mtkmodem/voicecall.c (+3/-2) drivers/rilmodem/gprs.c (+54/-5) drivers/rilmodem/gprs.h (+8/-2) drivers/rilmodem/radio-settings.c (+6/-3) drivers/rilmodem/radio-settings.h (+1/-0) drivers/rilmodem/rilutil.h (+17/-23) drivers/rilmodem/sim.c (+16/-16) drivers/rilmodem/voicecall.c (+57/-4) drivers/rilmodem/voicecall.h (+3/-1) gril/grilreply.c (+23/-3) gril/grilrequest.c (+57/-0) gril/grilrequest.h (+7/-0) gril/grilutil.c (+20/-0) gril/grilutil.h (+1/-0) gril/ril_constants.h (+43/-0) gril/ringbuffer.h (+0/-107) include/gprs-context.h (+1/-0) include/gprs.h (+5/-0) plugins/mbpi.c (+1/-0) plugins/mtk.c (+554/-283) plugins/ril.c (+83/-75) src/gprs.c (+57/-2) src/modem.c (+2/-1) test/rilmodem/sim/simtestutil.py (+391/-0) test/rilmodem/sim/test-no-sims-offline (+82/-0) test/rilmodem/sim/test-no-sims-online (+74/-0) test/rilmodem/sim/test-sim-change-pin (+128/-0) test/rilmodem/sim/test-sim-disable-pin-lock (+106/-0) test/rilmodem/sim/test-sim-enable-pin-lock (+101/-0) test/rilmodem/sim/test-sim-pin-unlock (+149/-0) test/rilmodem/sim/test-sim-puk-unlock (+227/-0) test/rilmodem/sim/test-sim-removal (+156/-0) test/rilmodem/sim/test-sims-offline (+106/-0) test/rilmodem/sim/test-sims-online (+108/-0) test/test-call-forwarding (+18/-10) unit/test-grilrequest.c (+54/-0) unit/test-mtkreply.c (+43/-0) unit/test-mtkrequest.c (+228/-20) unit/test-mtkunsol.c (+35/-0) |
||||||||
To merge this branch: | bzr merge lp:~phablet-team/ofono/arale-enablement | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email:
|
Commit message
[ Tony Espy ]
* test/rilmodem/sim: add new SIM test scripts
* test: fix test-call-
[ Vicamo Yang ]
* mtkmodem, rilmodem: re-factor naming
This change makes the naming of GRil, mtk_data,
ofono_modem, and ril_data instances consistent.
* rilmodem: fix duplicate APPSTATE* constants
* gril: get rid of duplicate ringbuffer.h (LP: #1408250)
* mtk.c: use RIL_RADIO_POWER request for single slot modems
[ Alfonso Sanchez-Beato ]
* gril, unit, mtk.c: SIM mode and session ID fixes for arale
For MTK modems, DUAL_SIM_MODE requests aren't necessary. Also
add session-id to SIM IO requests for newer MTK modems.
* rilmodem, mtk.c, ril.c: add auto-answer support
This change adds auto-answer support which is triggered
by usage of a special test SIM (MCC/MNC 001/01 or 001/001).
* mtkmodem, unit, mtk.c: support arale firmware switch
This change will cause the correct modem firmware to
be loaded based upon the SIM MCC abd MNC. If new
firmware is loaded, a modem reset is triggered.
* mtkmodem, unit, mtk.c: handle suspend events
RIL_
MTK modems if suspend events are received.
* gril, include, mbpi, rilmodem, mtkmodem, rilmodem,
gprs, unit, modem, ril.c, mtk.c: LTE updates
This changes detection logic for LTE modems to rilmodem
( via an environment var ) and mtkmodem ( via a modem
query ). If detected, a RIL_INITIAL_
is not sent to the modem during gprs initialization.
Description of the change
This merge includes multiple changes necessry for the enablement of arale. As such, most of the changes affect arale or krillin, however some bug fixes and test scripts are also included.
Changes include:
1. New rilmodem SIM test scripts added
2. Re-factoring of mtkmodem/rilmodem to making variable naming consistent
3. Use std RADIO_POWER request for MTK single slot modems
4. DUAL_SIM_MODE requests aren't necessary for MTK single slot modems
5. Auto-answer support added when special TEST SIMs are detected
6. Support dynamic arale modem firmware switching
7. Send RESUME_REGISTRATION requests to MTK modems when suspend events are received
8. Detect LTE modem capability, and send an INITIAL_ATTACH_APN request during GPRS initialization ( applies to mtkmodem and standard rilmodem )
- 6886. By Tony Espy
-
* test/rilmodem/sim: add new SIM test scripts
* test: fix test-call-forwarding script (LP: #1396323)
* mtkmodem, rilmodem: re-factor naming
This change makes the naming of GRil, mtk_data,
ofono_modem, and ril_data instances consistent.
* rilmodem: fix duplicate APPSTATE* constants
* gril: get rid of duplicate ringbuffer.h (LP: #1408250)
* mtk.c: use RIL_RADIO_POWER request for single slot modems
* gril, unit, mtk.c: SIM mode and session ID fixes for arale
For MTK modems, DUAL_SIM_MODE requests aren't necessary. Also
add session-id to SIM IO requests for newer MTK modems.
* rilmodem, mtk.c, ril.c: add auto-answer support
This change adds auto-answer support which is triggered
by usage of a special test SIM (MCC/MNC 001/01 or 001/001).
* mtkmodem, unit, mtk.c: support arale firmware switch
This change will cause the correct modem firmware to
be loaded based upon the SIM MCC and MNC. If new
firmware is loaded, a modem reset is triggered.
* mtkmodem, unit, mtk.c: handle suspend events
RIL_RESUME_REGISTRATION requests are not sent to
MTK modems if suspend events are received.
* gril, include, mbpi, rilmodem, mtkmodem, rilmodem,
gprs, unit, modem, ril.c, mtk.c: LTE updates
This changes detection logic for LTE modems to rilmodem
( via an environment var ) and mtkmodem ( via a modem
query ). If detected, a RIL_INITIAL_ATTACH_ APN request
is not sent to the modem during gprs initialization.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
Here's my test results:
1. mako/vivid/#90 ( checked voice in/out, sms in/out, gprs, flight-mode, pin-unlock ) - OK
2. krillin/vivid/#99 ( checked the same areas )
- NM delay starting mobile data when FM disabled ( known bug )
- the message-indicator does go green when a new SMS received
3. arale/vivid/#90 ( checked the same areas )
- sending SMS from message-indicator seems broken
- atfer enabling FM, indicator shows 'airplane' + 'HSPA' icons together!
- couldn't disable FM from the UI; cmd-line works
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Re: FM in arale, with latest alpha release (vivid 97) I was able to use FM from the GUI.
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2015-01-15 16:26:34 +0000 |
3 | +++ debian/changelog 2015-02-04 00:09:49 +0000 |
4 | @@ -1,3 +1,40 @@ |
5 | +ofono (1.12.bzr6886+15.04.20150203-0ubuntu1) UNRELEASED; urgency=medium |
6 | + |
7 | + [ Tony Espy ] |
8 | + * test/rilmodem/sim: add new SIM test scripts |
9 | + * test: fix test-call-forwarding script (LP: #1396323) |
10 | + |
11 | + [ Vicamo Yang ] |
12 | + * mtkmodem, rilmodem: re-factor naming |
13 | + This change makes the naming of GRil, mtk_data, |
14 | + ofono_modem, and ril_data instances consistent. |
15 | + * rilmodem: fix duplicate APPSTATE* constants |
16 | + * gril: get rid of duplicate ringbuffer.h (LP: #1408250) |
17 | + * mtk.c: use RIL_RADIO_POWER request for single slot modems |
18 | + |
19 | + [ Alfonso Sanchez-Beato ] |
20 | + * gril, unit, mtk.c: SIM mode and session ID fixes for arale |
21 | + For MTK modems, DUAL_SIM_MODE requests aren't necessary. Also |
22 | + add session-id to SIM IO requests for newer MTK modems. |
23 | + * rilmodem, mtk.c, ril.c: add auto-answer support |
24 | + This change adds auto-answer support which is triggered |
25 | + by usage of a special test SIM (MCC/MNC 001/01 or 001/001). |
26 | + * mtkmodem, unit, mtk.c: support arale firmware switch |
27 | + This change will cause the correct modem firmware to |
28 | + be loaded based upon the SIM MCC and MNC. If new |
29 | + firmware is loaded, a modem reset is triggered. |
30 | + * mtkmodem, unit, mtk.c: handle suspend events |
31 | + RIL_RESUME_REGISTRATION requests are not sent to |
32 | + MTK modems if suspend events are received. |
33 | + * gril, include, mbpi, rilmodem, mtkmodem, rilmodem, |
34 | + gprs, unit, modem, ril.c, mtk.c: LTE updates |
35 | + This changes detection logic for LTE modems to rilmodem |
36 | + ( via an environment var ) and mtkmodem ( via a modem |
37 | + query ). If detected, a RIL_INITIAL_ATTACH_APN request |
38 | + is not sent to the modem during gprs initialization. |
39 | + |
40 | + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 03 Feb 2015 18:17:48 -0500 |
41 | + |
42 | ofono (1.12.bzr6882+15.04.20150115-0ubuntu1) vivid; urgency=low |
43 | |
44 | [ Martin Pitt ] |
45 | |
46 | === modified file 'drivers/mtkmodem/gprs.c' |
47 | --- drivers/mtkmodem/gprs.c 2014-07-31 06:45:32 +0000 |
48 | +++ drivers/mtkmodem/gprs.c 2015-02-04 00:09:49 +0000 |
49 | @@ -138,17 +138,14 @@ |
50 | static int mtk_gprs_probe(struct ofono_gprs *gprs, |
51 | unsigned int vendor, void *data) |
52 | { |
53 | - struct mtk_gprs_data *gprs_data = data; |
54 | - GRil *ril = gprs_data->gril; |
55 | + struct ril_gprs_driver_data *driver_data = data; |
56 | struct ril_gprs_data *gd; |
57 | |
58 | gd = g_try_new0(struct ril_gprs_data, 1); |
59 | if (gd == NULL) |
60 | return -ENOMEM; |
61 | |
62 | - ril_gprs_start(ril, gprs, gd); |
63 | - |
64 | - gd->modem = gprs_data->modem; |
65 | + ril_gprs_start(driver_data, gprs, gd); |
66 | |
67 | /* |
68 | * In MTK the event emitted when the gprs state changes is different |
69 | @@ -178,6 +175,7 @@ |
70 | .remove = mtk_gprs_remove, |
71 | .set_attached = mtk_gprs_set_attached, |
72 | .attached_status = ril_gprs_registration_status, |
73 | + .set_ia_apn = ril_gprs_set_ia_apn, |
74 | }; |
75 | |
76 | void mtk_gprs_init(void) |
77 | |
78 | === modified file 'drivers/mtkmodem/mtk_constants.h' |
79 | --- drivers/mtkmodem/mtk_constants.h 2014-11-03 17:50:24 +0000 |
80 | +++ drivers/mtkmodem/mtk_constants.h 2015-02-04 00:09:49 +0000 |
81 | @@ -31,7 +31,11 @@ |
82 | #define MTK_RIL_REQUEST_SET_CALL_INDICATION 2036 |
83 | #define MTK_RIL_REQUEST_GET_3G_CAPABILITY 2038 |
84 | #define MTK_RIL_REQUEST_SET_3G_CAPABILITY 2039 |
85 | +#define MTK_RIL_REQUEST_SET_TRM 2053 |
86 | #define MTK_RIL_REQUEST_SET_FD_MODE 2073 |
87 | +#define MTK_RIL_REQUEST_RESUME_REGISTRATION 2077 |
88 | +#define MTK_RIL_REQUEST_STORE_MODEM_TYPE 2078 |
89 | +#define MTK_RIL_REQUEST_QUERY_MODEM_TYPE 2079 |
90 | |
91 | /* RIL Unsolicited Messages */ |
92 | #define MTK_RIL_UNSOL_MTK_BASE 3000 |
93 | |
94 | === modified file 'drivers/mtkmodem/mtkreply.c' |
95 | --- drivers/mtkmodem/mtkreply.c 2014-11-03 17:50:24 +0000 |
96 | +++ drivers/mtkmodem/mtkreply.c 2015-02-04 00:09:49 +0000 |
97 | @@ -65,3 +65,34 @@ |
98 | error: |
99 | return -1; |
100 | } |
101 | + |
102 | +int g_mtk_reply_parse_query_modem_type(GRil *gril, |
103 | + const struct ril_msg *message) |
104 | +{ |
105 | + struct parcel rilp; |
106 | + int numint, type; |
107 | + |
108 | + g_ril_init_parcel(message, &rilp); |
109 | + |
110 | + numint = parcel_r_int32(&rilp); |
111 | + if (numint != 1) { |
112 | + ofono_error("%s Wrong format", __func__); |
113 | + goto error; |
114 | + } |
115 | + |
116 | + type = parcel_r_int32(&rilp); |
117 | + |
118 | + if (rilp.malformed) { |
119 | + ofono_error("%s: malformed parcel", __func__); |
120 | + goto error; |
121 | + } |
122 | + |
123 | + g_ril_append_print_buf(gril, "{%d}", type); |
124 | + g_ril_print_response(gril, message); |
125 | + |
126 | + return type; |
127 | + |
128 | +error: |
129 | + return -1; |
130 | + |
131 | +} |
132 | |
133 | === modified file 'drivers/mtkmodem/mtkreply.h' |
134 | --- drivers/mtkmodem/mtkreply.h 2014-07-24 08:31:18 +0000 |
135 | +++ drivers/mtkmodem/mtkreply.h 2015-02-04 00:09:49 +0000 |
136 | @@ -33,6 +33,9 @@ |
137 | int g_mtk_reply_parse_get_3g_capability(GRil *gril, |
138 | const struct ril_msg *message); |
139 | |
140 | +int g_mtk_reply_parse_query_modem_type(GRil *gril, |
141 | + const struct ril_msg *message); |
142 | + |
143 | #ifdef __cplusplus |
144 | } |
145 | #endif |
146 | |
147 | === modified file 'drivers/mtkmodem/mtkrequest.c' |
148 | --- drivers/mtkmodem/mtkrequest.c 2014-11-03 17:50:24 +0000 |
149 | +++ drivers/mtkmodem/mtkrequest.c 2015-02-04 00:09:49 +0000 |
150 | @@ -133,3 +133,31 @@ |
151 | |
152 | g_ril_append_print_buf(gril, "(%d)", mode); |
153 | } |
154 | + |
155 | +void g_mtk_request_store_modem_type(GRil *gril, int mode, struct parcel *rilp) |
156 | +{ |
157 | + parcel_init(rilp); |
158 | + parcel_w_int32(rilp, 1); |
159 | + parcel_w_int32(rilp, mode); |
160 | + |
161 | + g_ril_append_print_buf(gril, "(%d)", mode); |
162 | +} |
163 | + |
164 | +void g_mtk_request_set_trm(GRil *gril, int trm, struct parcel *rilp) |
165 | +{ |
166 | + parcel_init(rilp); |
167 | + parcel_w_int32(rilp, 1); |
168 | + parcel_w_int32(rilp, trm); |
169 | + |
170 | + g_ril_append_print_buf(gril, "(%d)", trm); |
171 | +} |
172 | + |
173 | +void g_mtk_request_resume_registration(GRil *gril, int session_id, |
174 | + struct parcel *rilp) |
175 | +{ |
176 | + parcel_init(rilp); |
177 | + parcel_w_int32(rilp, 1); |
178 | + parcel_w_int32(rilp, session_id); |
179 | + |
180 | + g_ril_append_print_buf(gril, "(%d)", session_id); |
181 | +} |
182 | |
183 | === modified file 'drivers/mtkmodem/mtkrequest.h' |
184 | --- drivers/mtkmodem/mtkrequest.h 2014-11-03 17:50:24 +0000 |
185 | +++ drivers/mtkmodem/mtkrequest.h 2015-02-04 00:09:49 +0000 |
186 | @@ -52,6 +52,18 @@ |
187 | #define MTK_FD_PAR1_SCREEN_OFF 0 |
188 | #define MTK_FD_PAR1_SCREEN_ON 1 |
189 | |
190 | +#define MTK_MD_TYPE_INVALID 0 |
191 | +#define MTK_MD_TYPE_2G 1 |
192 | +#define MTK_MD_TYPE_3G 2 |
193 | +#define MTK_MD_TYPE_WG 3 |
194 | +#define MTK_MD_TYPE_TG 4 |
195 | +/* FDD CSFB modem */ |
196 | +#define MTK_MD_TYPE_LWG 5 |
197 | +/* TDD CSFB modem */ |
198 | +#define MTK_MD_TYPE_LTG 6 |
199 | +/* SGLTE modem */ |
200 | +#define MTK_MD_TYPE_LTNG 7 |
201 | + |
202 | /* |
203 | * The meaning of mode seems to be: |
204 | * -1 -> Both SIMs inactive |
205 | @@ -108,6 +120,22 @@ |
206 | */ |
207 | void g_mtk_request_set_3g_capability(GRil *gril, struct parcel *rilp); |
208 | |
209 | +/* |
210 | + * Set the MTK modem mode. See MTK_MD_TYPE_*. |
211 | + */ |
212 | +void g_mtk_request_store_modem_type(GRil *gril, int mode, struct parcel *rilp); |
213 | + |
214 | +/* |
215 | + * Set TRM |
216 | + */ |
217 | +void g_mtk_request_set_trm(GRil *gril, int trm, struct parcel *rilp); |
218 | + |
219 | +/* |
220 | + * Request to resume registration. |
221 | + */ |
222 | +void g_mtk_request_resume_registration(GRil *gril, int session_id, |
223 | + struct parcel *rilp); |
224 | + |
225 | #ifdef __cplusplus |
226 | } |
227 | #endif |
228 | |
229 | === modified file 'drivers/mtkmodem/mtkunsol.c' |
230 | --- drivers/mtkmodem/mtkunsol.c 2014-03-20 07:46:16 +0000 |
231 | +++ drivers/mtkmodem/mtkunsol.c 2015-02-04 00:09:49 +0000 |
232 | @@ -131,3 +131,34 @@ |
233 | |
234 | return NULL; |
235 | } |
236 | + |
237 | +int g_mtk_unsol_parse_registration_suspended(GRil *gril, |
238 | + const struct ril_msg *message) |
239 | +{ |
240 | + struct parcel rilp; |
241 | + int numint, session_id; |
242 | + |
243 | + g_ril_init_parcel(message, &rilp); |
244 | + |
245 | + numint = parcel_r_int32(&rilp); |
246 | + if (numint != 1) { |
247 | + ofono_error("%s Wrong format", __func__); |
248 | + goto error; |
249 | + } |
250 | + |
251 | + session_id = parcel_r_int32(&rilp); |
252 | + |
253 | + if (rilp.malformed) { |
254 | + ofono_error("%s: malformed parcel", __func__); |
255 | + goto error; |
256 | + } |
257 | + |
258 | + g_ril_append_print_buf(gril, "{%d}", session_id); |
259 | + g_ril_print_unsol(gril, message); |
260 | + |
261 | + return session_id; |
262 | + |
263 | +error: |
264 | + return -1; |
265 | + |
266 | +} |
267 | |
268 | === modified file 'drivers/mtkmodem/mtkunsol.h' |
269 | --- drivers/mtkmodem/mtkunsol.h 2014-03-20 07:46:16 +0000 |
270 | +++ drivers/mtkmodem/mtkunsol.h 2015-02-04 00:09:49 +0000 |
271 | @@ -41,6 +41,10 @@ |
272 | struct unsol_call_indication *g_mtk_unsol_parse_incoming_call_indication( |
273 | GRil *gril, struct ril_msg *message); |
274 | |
275 | +/* Returns a session id that must be used in resume registration request */ |
276 | +int g_mtk_unsol_parse_registration_suspended(GRil *gril, |
277 | + const struct ril_msg *message); |
278 | + |
279 | #ifdef __cplusplus |
280 | } |
281 | #endif |
282 | |
283 | === modified file 'drivers/mtkmodem/mtkutil.c' |
284 | --- drivers/mtkmodem/mtkutil.c 2014-11-03 17:50:24 +0000 |
285 | +++ drivers/mtkmodem/mtkutil.c 2015-02-04 00:09:49 +0000 |
286 | @@ -43,8 +43,16 @@ |
287 | return "MTK_RIL_REQUEST_GET_3G_CAPABILITY"; |
288 | case MTK_RIL_REQUEST_SET_3G_CAPABILITY: |
289 | return "MTK_RIL_REQUEST_SET_3G_CAPABILITY"; |
290 | + case MTK_RIL_REQUEST_SET_TRM: |
291 | + return "MTK_RIL_REQUEST_SET_TRM"; |
292 | case MTK_RIL_REQUEST_SET_FD_MODE: |
293 | return "MTK_RIL_REQUEST_SET_FD_MODE"; |
294 | + case MTK_RIL_REQUEST_STORE_MODEM_TYPE: |
295 | + return "MTK_RIL_REQUEST_STORE_MODEM_TYPE"; |
296 | + case MTK_RIL_REQUEST_RESUME_REGISTRATION: |
297 | + return "MTK_RIL_REQUEST_RESUME_REGISTRATION"; |
298 | + case MTK_RIL_REQUEST_QUERY_MODEM_TYPE: |
299 | + return "MTK_RIL_REQUEST_QUERY_MODEM_TYPE"; |
300 | default: |
301 | return NULL; |
302 | } |
303 | |
304 | === modified file 'drivers/mtkmodem/mtkutil.h' |
305 | --- drivers/mtkmodem/mtkutil.h 2014-11-17 15:43:35 +0000 |
306 | +++ drivers/mtkmodem/mtkutil.h 2015-02-04 00:09:49 +0000 |
307 | @@ -36,11 +36,6 @@ |
308 | |
309 | void mtk_reset_all_modems(void); |
310 | |
311 | -struct mtk_gprs_data { |
312 | - GRil *gril; |
313 | - struct ofono_modem *modem; |
314 | -}; |
315 | - |
316 | const char *mtk_request_id_to_string(int req); |
317 | const char *mtk_unsol_request_to_string(int req); |
318 | |
319 | |
320 | === modified file 'drivers/mtkmodem/radio-settings.c' |
321 | --- drivers/mtkmodem/radio-settings.c 2014-11-05 10:51:01 +0000 |
322 | +++ drivers/mtkmodem/radio-settings.c 2015-02-04 00:09:49 +0000 |
323 | @@ -108,7 +108,7 @@ |
324 | static int mtk_radio_settings_probe(struct ofono_radio_settings *rs, |
325 | unsigned int vendor, void *user) |
326 | { |
327 | - GRil *ril = user; |
328 | + struct ril_radio_settings_driver_data* rs_init_data = user; |
329 | struct radio_data *rsd = g_try_new0(struct radio_data, 1); |
330 | |
331 | if (rsd == NULL) { |
332 | @@ -116,7 +116,8 @@ |
333 | return -ENOMEM; |
334 | } |
335 | |
336 | - rsd->ril = g_ril_clone(ril); |
337 | + rsd->ril = g_ril_clone(rs_init_data->gril); |
338 | + rsd->modem = rs_init_data->modem; |
339 | |
340 | ofono_radio_settings_set_data(rs, rsd); |
341 | |
342 | @@ -155,7 +156,7 @@ |
343 | if (is_3g) { |
344 | modem_rats[OFONO_RADIO_ACCESS_MODE_UMTS] = TRUE; |
345 | |
346 | - if (getenv("OFONO_RIL_RAT_LTE")) |
347 | + if (ofono_modem_get_boolean(rd->modem, MODEM_PROP_LTE_CAPABLE)) |
348 | modem_rats[OFONO_RADIO_ACCESS_MODE_LTE] = TRUE; |
349 | } |
350 | |
351 | |
352 | === modified file 'drivers/mtkmodem/voicecall.c' |
353 | --- drivers/mtkmodem/voicecall.c 2014-07-28 07:12:26 +0000 |
354 | +++ drivers/mtkmodem/voicecall.c 2015-02-04 00:09:49 +0000 |
355 | @@ -42,6 +42,7 @@ |
356 | |
357 | #include "common.h" |
358 | #include "mtkmodem.h" |
359 | +#include "drivers/rilmodem/rilutil.h" |
360 | #include "drivers/rilmodem/voicecall.h" |
361 | |
362 | /* |
363 | @@ -111,14 +112,14 @@ |
364 | static int mtk_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor, |
365 | void *data) |
366 | { |
367 | - GRil *ril = data; |
368 | + struct ril_voicecall_driver_data *driver_data = data; |
369 | struct ril_voicecall_data *vd; |
370 | |
371 | vd = g_try_new0(struct ril_voicecall_data, 1); |
372 | if (vd == NULL) |
373 | return -ENOMEM; |
374 | |
375 | - ril_voicecall_start(ril, vc, vendor, vd); |
376 | + ril_voicecall_start(driver_data, vc, vendor, vd); |
377 | |
378 | /* |
379 | * Register events after ofono_voicecall_register() is called from |
380 | |
381 | === modified file 'drivers/rilmodem/gprs.c' |
382 | --- drivers/rilmodem/gprs.c 2014-11-20 00:03:31 +0000 |
383 | +++ drivers/rilmodem/gprs.c 2015-02-04 00:09:49 +0000 |
384 | @@ -100,6 +100,53 @@ |
385 | } |
386 | } |
387 | |
388 | +static void set_ia_apn_cb(struct ril_msg *message, gpointer user_data) |
389 | +{ |
390 | + struct cb_data *cbd = user_data; |
391 | + ofono_gprs_cb_t cb = cbd->cb; |
392 | + struct ofono_gprs *gprs = cbd->user; |
393 | + struct ril_gprs_data *gd = ofono_gprs_get_data(gprs); |
394 | + |
395 | + if (message->error != RIL_E_SUCCESS) { |
396 | + ofono_error("%s: reply failure: %s", __func__, |
397 | + ril_error_to_string(message->error)); |
398 | + CALLBACK_WITH_FAILURE(cb, cbd->data); |
399 | + return; |
400 | + } |
401 | + |
402 | + g_ril_print_response_no_args(gd->ril, message); |
403 | + |
404 | + CALLBACK_WITH_SUCCESS(cb, cbd->data); |
405 | +} |
406 | + |
407 | +void ril_gprs_set_ia_apn(struct ofono_gprs *gprs, const char *apn, |
408 | + enum ofono_gprs_proto proto, const char *user, |
409 | + const char *passwd, const char *mccmnc, |
410 | + ofono_gprs_cb_t cb, void *data) |
411 | +{ |
412 | + struct ril_gprs_data *gd = ofono_gprs_get_data(gprs); |
413 | + struct cb_data *cbd; |
414 | + struct parcel rilp; |
415 | + |
416 | + if (!ofono_modem_get_boolean(gd->modem, MODEM_PROP_LTE_CAPABLE)) { |
417 | + CALLBACK_WITH_SUCCESS(cb, data); |
418 | + return; |
419 | + } |
420 | + |
421 | + cbd = cb_data_new(cb, data, gprs); |
422 | + |
423 | + g_ril_request_set_initial_attach_apn(gd->ril, apn, proto, user, passwd, |
424 | + mccmnc, &rilp); |
425 | + |
426 | + if (g_ril_send(gd->ril, RIL_REQUEST_SET_INITIAL_ATTACH_APN, |
427 | + &rilp, set_ia_apn_cb, cbd, g_free) == 0) { |
428 | + ofono_error("%s: failure sending request", __func__); |
429 | + |
430 | + g_free(cbd); |
431 | + CALLBACK_WITH_FAILURE(cb, data); |
432 | + } |
433 | +} |
434 | + |
435 | static void ril_gprs_state_change(struct ril_msg *message, gpointer user_data) |
436 | { |
437 | struct ofono_gprs *gprs = user_data; |
438 | @@ -421,10 +468,11 @@ |
439 | ofono_error("%s: send failed", __func__); |
440 | } |
441 | |
442 | -void ril_gprs_start(GRil *ril, struct ofono_gprs *gprs, |
443 | - struct ril_gprs_data *gd) |
444 | +void ril_gprs_start(struct ril_gprs_driver_data *driver_data, |
445 | + struct ofono_gprs *gprs, struct ril_gprs_data *gd) |
446 | { |
447 | - gd->ril = g_ril_clone(ril); |
448 | + gd->ril = g_ril_clone(driver_data->gril); |
449 | + gd->modem = driver_data->modem; |
450 | gd->ofono_attached = FALSE; |
451 | gd->max_cids = 0; |
452 | gd->rild_status = -1; |
453 | @@ -440,14 +488,14 @@ |
454 | |
455 | int ril_gprs_probe(struct ofono_gprs *gprs, unsigned int vendor, void *data) |
456 | { |
457 | - GRil *ril = data; |
458 | + struct ril_gprs_driver_data *driver_data = data; |
459 | struct ril_gprs_data *gd; |
460 | |
461 | gd = g_try_new0(struct ril_gprs_data, 1); |
462 | if (gd == NULL) |
463 | return -ENOMEM; |
464 | |
465 | - ril_gprs_start(ril, gprs, gd); |
466 | + ril_gprs_start(driver_data, gprs, gd); |
467 | |
468 | return 0; |
469 | } |
470 | @@ -473,6 +521,7 @@ |
471 | .remove = ril_gprs_remove, |
472 | .set_attached = ril_gprs_set_attached, |
473 | .attached_status = ril_gprs_registration_status, |
474 | + .set_ia_apn = ril_gprs_set_ia_apn, |
475 | }; |
476 | |
477 | void ril_gprs_init(void) |
478 | |
479 | === modified file 'drivers/rilmodem/gprs.h' |
480 | --- drivers/rilmodem/gprs.h 2014-09-26 08:45:20 +0000 |
481 | +++ drivers/rilmodem/gprs.h 2015-02-04 00:09:49 +0000 |
482 | @@ -19,6 +19,8 @@ |
483 | * |
484 | */ |
485 | |
486 | +#include "drivers/rilmodem/rilutil.h" |
487 | + |
488 | struct ril_gprs_data { |
489 | GRil *ril; |
490 | struct ofono_modem *modem; |
491 | @@ -33,8 +35,12 @@ |
492 | |
493 | int ril_gprs_probe(struct ofono_gprs *gprs, unsigned int vendor, void *data); |
494 | void ril_gprs_remove(struct ofono_gprs *gprs); |
495 | -void ril_gprs_start(GRil *ril, struct ofono_gprs *gprs, |
496 | - struct ril_gprs_data *gd); |
497 | +void ril_gprs_start(struct ril_gprs_driver_data *driver_data, |
498 | + struct ofono_gprs *gprs, struct ril_gprs_data *gd); |
499 | gboolean ril_gprs_set_attached_cb(gpointer user_data); |
500 | void ril_gprs_registration_status(struct ofono_gprs *gprs, |
501 | ofono_gprs_status_cb_t cb, void *data); |
502 | +void ril_gprs_set_ia_apn(struct ofono_gprs *gprs, const char *apn, |
503 | + enum ofono_gprs_proto proto, const char *user, |
504 | + const char *passwd, const char *mccmnc, |
505 | + ofono_gprs_cb_t cb, void *data); |
506 | |
507 | === modified file 'drivers/rilmodem/radio-settings.c' |
508 | --- drivers/rilmodem/radio-settings.c 2014-11-17 15:43:35 +0000 |
509 | +++ drivers/rilmodem/radio-settings.c 2015-02-04 00:09:49 +0000 |
510 | @@ -213,11 +213,13 @@ |
511 | ofono_bool_t modem_rats[OFONO_RADIO_ACCESS_MODE_LAST] = { FALSE }; |
512 | struct cb_data *cbd = user_data; |
513 | ofono_radio_settings_modem_rats_query_cb_t cb = cbd->cb; |
514 | + struct ofono_radio_settings *rs = cbd->user; |
515 | + struct radio_data *rd = ofono_radio_settings_get_data(rs); |
516 | |
517 | modem_rats[OFONO_RADIO_ACCESS_MODE_GSM] = TRUE; |
518 | modem_rats[OFONO_RADIO_ACCESS_MODE_UMTS] = TRUE; |
519 | |
520 | - if (getenv("OFONO_RIL_RAT_LTE")) |
521 | + if (ofono_modem_get_boolean(rd->modem, MODEM_PROP_LTE_CAPABLE)) |
522 | modem_rats[OFONO_RADIO_ACCESS_MODE_LTE] = TRUE; |
523 | |
524 | CALLBACK_WITH_SUCCESS(cb, modem_rats, cbd->data); |
525 | @@ -249,7 +251,7 @@ |
526 | static int ril_radio_settings_probe(struct ofono_radio_settings *rs, |
527 | unsigned int vendor, void *user) |
528 | { |
529 | - GRil *ril = user; |
530 | + struct ril_radio_settings_driver_data* rs_init_data = user; |
531 | struct radio_data *rsd = g_try_new0(struct radio_data, 1); |
532 | |
533 | if (rsd == NULL) { |
534 | @@ -257,7 +259,8 @@ |
535 | return -ENOMEM; |
536 | } |
537 | |
538 | - rsd->ril = g_ril_clone(ril); |
539 | + rsd->ril = g_ril_clone(rs_init_data->gril); |
540 | + rsd->modem = rs_init_data->modem; |
541 | |
542 | ofono_radio_settings_set_data(rs, rsd); |
543 | |
544 | |
545 | === modified file 'drivers/rilmodem/radio-settings.h' |
546 | --- drivers/rilmodem/radio-settings.h 2014-06-12 10:47:10 +0000 |
547 | +++ drivers/rilmodem/radio-settings.h 2015-02-04 00:09:49 +0000 |
548 | @@ -21,6 +21,7 @@ |
549 | |
550 | struct radio_data { |
551 | GRil *ril; |
552 | + struct ofono_modem *modem; |
553 | gboolean fast_dormancy; |
554 | gboolean pending_fd; |
555 | }; |
556 | |
557 | === modified file 'drivers/rilmodem/rilutil.h' |
558 | --- drivers/rilmodem/rilutil.h 2014-07-29 06:11:22 +0000 |
559 | +++ drivers/rilmodem/rilutil.h 2015-02-04 00:09:49 +0000 |
560 | @@ -36,6 +36,8 @@ |
561 | #define PREFIX_25_NETMASK "255.255.255.128" |
562 | #define PREFIX_24_NETMASK "255.255.255.0" |
563 | |
564 | +#define MODEM_PROP_LTE_CAPABLE "lte-capable" |
565 | + |
566 | enum ril_util_sms_store { |
567 | RIL_UTIL_SMS_STORE_SM = 0, |
568 | RIL_UTIL_SMS_STORE_ME = 1, |
569 | @@ -65,29 +67,6 @@ |
570 | RIL_UTIL_CHARSET_8859_H = 0x10000, |
571 | }; |
572 | |
573 | -/* TODO: consider moving these to ril_constants.h */ |
574 | -enum app_state { |
575 | - APPSTATE_UNKNOWN, |
576 | - APPSTATE_DETECTED, |
577 | - APPSTATE_PIN, |
578 | - APPSTATE_PUK, |
579 | - APPSTATE_SUBSCRIPTION_PERSO, |
580 | - APPSTATE_READY, |
581 | -}; |
582 | - |
583 | -enum perso_state { |
584 | - PERSOSUBSTATE_SIM_NETWORK = 3, |
585 | - PERSOSUBSTATE_SIM_NETWORK_SUBSET, |
586 | - PERSOSUBSTATE_SIM_CORPORATE, |
587 | - PERSOSUBSTATE_SIM_SERVICE_PROVIDER, |
588 | - PERSOSUBSTATE_SIM_SIM, |
589 | - PERSOSUBSTATE_SIM_NETWORK_PUK, |
590 | - PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK, |
591 | - PERSOSUBSTATE_SIM_CORPORATE_PUK, |
592 | - PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK, |
593 | - PERSOSUBSTATE_SIM_SIM_PUK, |
594 | -}; |
595 | - |
596 | struct ril_sim_data { |
597 | struct ofono_modem *modem; |
598 | GRil *gril; |
599 | @@ -99,6 +78,21 @@ |
600 | enum ofono_gprs_context_type type; |
601 | }; |
602 | |
603 | +struct ril_voicecall_driver_data { |
604 | + GRil *gril; |
605 | + struct ofono_modem *modem; |
606 | +}; |
607 | + |
608 | +struct ril_gprs_driver_data { |
609 | + GRil *gril; |
610 | + struct ofono_modem *modem; |
611 | +}; |
612 | + |
613 | +struct ril_radio_settings_driver_data { |
614 | + GRil *gril; |
615 | + struct ofono_modem *modem; |
616 | +}; |
617 | + |
618 | typedef void (*ril_util_sim_inserted_cb_t)(gboolean present, void *userdata); |
619 | |
620 | void decode_ril_error(struct ofono_error *error, const char *final); |
621 | |
622 | === modified file 'drivers/rilmodem/sim.c' |
623 | --- drivers/rilmodem/sim.c 2014-11-20 00:03:31 +0000 |
624 | +++ drivers/rilmodem/sim.c 2015-02-04 00:09:49 +0000 |
625 | @@ -586,42 +586,42 @@ |
626 | |
627 | DBG("setting aid_str (AID) to: %s", sd->aid_str); |
628 | switch (app->app_state) { |
629 | - case APPSTATE_PIN: |
630 | + case RIL_APPSTATE_PIN: |
631 | sd->passwd_state = OFONO_SIM_PASSWORD_SIM_PIN; |
632 | break; |
633 | - case APPSTATE_PUK: |
634 | + case RIL_APPSTATE_PUK: |
635 | sd->passwd_state = OFONO_SIM_PASSWORD_SIM_PUK; |
636 | break; |
637 | - case APPSTATE_SUBSCRIPTION_PERSO: |
638 | + case RIL_APPSTATE_SUBSCRIPTION_PERSO: |
639 | switch (app->perso_substate) { |
640 | - case PERSOSUBSTATE_SIM_NETWORK: |
641 | + case RIL_PERSOSUBSTATE_SIM_NETWORK: |
642 | sd->passwd_state = OFONO_SIM_PASSWORD_PHNET_PIN; |
643 | break; |
644 | - case PERSOSUBSTATE_SIM_NETWORK_SUBSET: |
645 | + case RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET: |
646 | sd->passwd_state = OFONO_SIM_PASSWORD_PHNETSUB_PIN; |
647 | break; |
648 | - case PERSOSUBSTATE_SIM_CORPORATE: |
649 | + case RIL_PERSOSUBSTATE_SIM_CORPORATE: |
650 | sd->passwd_state = OFONO_SIM_PASSWORD_PHCORP_PIN; |
651 | break; |
652 | - case PERSOSUBSTATE_SIM_SERVICE_PROVIDER: |
653 | + case RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER: |
654 | sd->passwd_state = OFONO_SIM_PASSWORD_PHSP_PIN; |
655 | break; |
656 | - case PERSOSUBSTATE_SIM_SIM: |
657 | + case RIL_PERSOSUBSTATE_SIM_SIM: |
658 | sd->passwd_state = OFONO_SIM_PASSWORD_PHSIM_PIN; |
659 | break; |
660 | - case PERSOSUBSTATE_SIM_NETWORK_PUK: |
661 | + case RIL_PERSOSUBSTATE_SIM_NETWORK_PUK: |
662 | sd->passwd_state = OFONO_SIM_PASSWORD_PHNET_PUK; |
663 | break; |
664 | - case PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK: |
665 | + case RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK: |
666 | sd->passwd_state = OFONO_SIM_PASSWORD_PHNETSUB_PUK; |
667 | break; |
668 | - case PERSOSUBSTATE_SIM_CORPORATE_PUK: |
669 | + case RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK: |
670 | sd->passwd_state = OFONO_SIM_PASSWORD_PHCORP_PUK; |
671 | break; |
672 | - case PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK: |
673 | + case RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK: |
674 | sd->passwd_state = OFONO_SIM_PASSWORD_PHSP_PUK; |
675 | break; |
676 | - case PERSOSUBSTATE_SIM_SIM_PUK: |
677 | + case RIL_PERSOSUBSTATE_SIM_SIM_PUK: |
678 | sd->passwd_state = OFONO_SIM_PASSWORD_PHFSIM_PUK; |
679 | break; |
680 | default: |
681 | @@ -629,11 +629,11 @@ |
682 | break; |
683 | }; |
684 | break; |
685 | - case APPSTATE_READY: |
686 | + case RIL_APPSTATE_READY: |
687 | sd->passwd_state = OFONO_SIM_PASSWORD_NONE; |
688 | break; |
689 | - case APPSTATE_UNKNOWN: |
690 | - case APPSTATE_DETECTED: |
691 | + case RIL_APPSTATE_UNKNOWN: |
692 | + case RIL_APPSTATE_DETECTED: |
693 | default: |
694 | sd->passwd_state = OFONO_SIM_PASSWORD_INVALID; |
695 | break; |
696 | |
697 | === modified file 'drivers/rilmodem/voicecall.c' |
698 | --- drivers/rilmodem/voicecall.c 2014-04-25 16:10:01 +0000 |
699 | +++ drivers/rilmodem/voicecall.c 2015-02-04 00:09:49 +0000 |
700 | @@ -33,6 +33,8 @@ |
701 | |
702 | #include <glib.h> |
703 | |
704 | +#include <ofono.h> |
705 | + |
706 | #include <ofono/log.h> |
707 | #include <ofono/modem.h> |
708 | #include <ofono/voicecall.h> |
709 | @@ -56,6 +58,9 @@ |
710 | /* To use with change_state_req::affected_types */ |
711 | #define AFFECTED_STATES_ALL 0x3F |
712 | |
713 | +/* Auto-answer delay in seconds */ |
714 | +#define AUTO_ANSWER_DELAY_S 3 |
715 | + |
716 | struct release_id_req { |
717 | struct ofono_voicecall *vc; |
718 | ofono_voicecall_cb_t cb; |
719 | @@ -100,6 +105,47 @@ |
720 | ofono_voicecall_disconnected(vc, reqdata->id, reason, NULL); |
721 | } |
722 | |
723 | +static gboolean auto_answer_call(gpointer user_data) |
724 | +{ |
725 | + struct ofono_voicecall *vc = user_data; |
726 | + |
727 | + DBG(""); |
728 | + |
729 | + ril_answer(vc, NULL, NULL); |
730 | + |
731 | + return FALSE; |
732 | +} |
733 | + |
734 | +static gboolean is_auto_answer(struct ril_voicecall_data *vd, |
735 | + struct ofono_call* call) |
736 | +{ |
737 | + static const char test_mcc_mnc_1[] = "00101"; |
738 | + static const char test_mcc_mnc_2[] = "001001"; |
739 | + |
740 | + const char *imsi; |
741 | + struct ofono_sim *sim; |
742 | + |
743 | + if (call->status != CALL_STATUS_INCOMING) |
744 | + return FALSE; |
745 | + |
746 | + sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, vd->modem); |
747 | + if (sim == NULL) |
748 | + return FALSE; |
749 | + |
750 | + imsi = ofono_sim_get_imsi(sim); |
751 | + if (imsi == NULL) |
752 | + return FALSE; |
753 | + |
754 | + if (strncmp(imsi, test_mcc_mnc_1, sizeof(test_mcc_mnc_1) - 1) == 0 || |
755 | + strncmp(imsi, test_mcc_mnc_2, sizeof(test_mcc_mnc_2) - 1) |
756 | + == 0) { |
757 | + ofono_info("Auto answering incoming call, imsi is %s", imsi); |
758 | + return TRUE; |
759 | + } |
760 | + |
761 | + return FALSE; |
762 | +} |
763 | + |
764 | static void clcc_poll_cb(struct ril_msg *message, gpointer user_data) |
765 | { |
766 | struct ofono_voicecall *vc = user_data; |
767 | @@ -151,6 +197,7 @@ |
768 | /* new call, signal it */ |
769 | if (nc->type) { |
770 | ofono_voicecall_notify(vc, nc); |
771 | + |
772 | if (vd->cb) { |
773 | struct ofono_error error; |
774 | ofono_voicecall_cb_t cb = vd->cb; |
775 | @@ -160,6 +207,10 @@ |
776 | vd->data = NULL; |
777 | } |
778 | |
779 | + if (is_auto_answer(vd, nc)) |
780 | + g_timeout_add_seconds( |
781 | + AUTO_ANSWER_DELAY_S, |
782 | + auto_answer_call, vc); |
783 | } |
784 | |
785 | n = n->next; |
786 | @@ -677,11 +728,13 @@ |
787 | return FALSE; |
788 | } |
789 | |
790 | -void ril_voicecall_start(GRil *ril, struct ofono_voicecall *vc, |
791 | +void ril_voicecall_start(struct ril_voicecall_driver_data *driver_data, |
792 | + struct ofono_voicecall *vc, |
793 | unsigned int vendor, |
794 | struct ril_voicecall_data *vd) |
795 | { |
796 | - vd->ril = g_ril_clone(ril); |
797 | + vd->ril = g_ril_clone(driver_data->gril); |
798 | + vd->modem = driver_data->modem; |
799 | vd->vendor = vendor; |
800 | vd->cb = NULL; |
801 | vd->data = NULL; |
802 | @@ -703,14 +756,14 @@ |
803 | int ril_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor, |
804 | void *data) |
805 | { |
806 | - GRil *ril = data; |
807 | + struct ril_voicecall_driver_data *driver_data = data; |
808 | struct ril_voicecall_data *vd; |
809 | |
810 | vd = g_try_new0(struct ril_voicecall_data, 1); |
811 | if (vd == NULL) |
812 | return -ENOMEM; |
813 | |
814 | - ril_voicecall_start(ril, vc, vendor, vd); |
815 | + ril_voicecall_start(driver_data, vc, vendor, vd); |
816 | |
817 | return 0; |
818 | } |
819 | |
820 | === modified file 'drivers/rilmodem/voicecall.h' |
821 | --- drivers/rilmodem/voicecall.h 2014-03-20 07:46:16 +0000 |
822 | +++ drivers/rilmodem/voicecall.h 2015-02-04 00:09:49 +0000 |
823 | @@ -25,6 +25,7 @@ |
824 | unsigned int local_release; |
825 | unsigned int clcc_source; |
826 | GRil *ril; |
827 | + struct ofono_modem *modem; |
828 | unsigned int vendor; |
829 | unsigned char flags; |
830 | ofono_voicecall_cb_t cb; |
831 | @@ -62,7 +63,8 @@ |
832 | void ril_release_all_active(struct ofono_voicecall *vc, |
833 | ofono_voicecall_cb_t cb, void *data); |
834 | |
835 | -void ril_voicecall_start(GRil *ril, struct ofono_voicecall *vc, |
836 | +void ril_voicecall_start(struct ril_voicecall_driver_data *driver_data, |
837 | + struct ofono_voicecall *vc, |
838 | unsigned int vendor, |
839 | struct ril_voicecall_data *vd); |
840 | void ril_call_state_notify(struct ril_msg *message, gpointer user_data); |
841 | |
842 | === modified file 'gril/grilreply.c' |
843 | --- gril/grilreply.c 2014-11-20 00:03:31 +0000 |
844 | +++ gril/grilreply.c 2015-02-04 00:09:49 +0000 |
845 | @@ -1157,7 +1157,7 @@ |
846 | const struct ril_msg *message) |
847 | { |
848 | struct parcel rilp; |
849 | - int numint, net_type; |
850 | + int numint, parcel_net_type, net_type; |
851 | |
852 | g_ril_init_parcel(message, &rilp); |
853 | |
854 | @@ -1167,7 +1167,27 @@ |
855 | goto error; |
856 | } |
857 | |
858 | - net_type = parcel_r_int32(&rilp); |
859 | + parcel_net_type = parcel_r_int32(&rilp); |
860 | + net_type = parcel_net_type; |
861 | + |
862 | + /* Try to translate special MTK settings */ |
863 | + if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) { |
864 | + switch (net_type) { |
865 | + /* 4G preferred */ |
866 | + case MTK_PREF_NET_TYPE_LTE_GSM_WCDMA: |
867 | + case MTK_PREF_NET_TYPE_LTE_GSM_WCDMA_MMDC: |
868 | + case MTK_PREF_NET_TYPE_LTE_GSM_TYPE: |
869 | + case MTK_PREF_NET_TYPE_LTE_GSM_MMDC_TYPE: |
870 | + net_type = PREF_NET_TYPE_LTE_GSM_WCDMA; |
871 | + break; |
872 | + /* 3G or 2G preferred over LTE */ |
873 | + case MTK_PREF_NET_TYPE_GSM_WCDMA_LTE: |
874 | + case MTK_PREF_NET_TYPE_GSM_WCDMA_LTE_MMDC: |
875 | + net_type = PREF_NET_TYPE_GSM_WCDMA; |
876 | + break; |
877 | + } |
878 | + } |
879 | + |
880 | if (net_type < 0 || net_type > PREF_NET_TYPE_LTE_ONLY) { |
881 | ofono_error("%s: unknown network type", __func__); |
882 | goto error; |
883 | @@ -1178,7 +1198,7 @@ |
884 | goto error; |
885 | } |
886 | |
887 | - g_ril_append_print_buf(gril, "{%d}", net_type); |
888 | + g_ril_append_print_buf(gril, "{%d}", parcel_net_type); |
889 | g_ril_print_response(gril, message); |
890 | |
891 | return net_type; |
892 | |
893 | === modified file 'gril/grilrequest.c' |
894 | --- gril/grilrequest.c 2014-07-29 06:11:22 +0000 |
895 | +++ gril/grilrequest.c 2015-02-04 00:09:49 +0000 |
896 | @@ -399,6 +399,14 @@ |
897 | parcel_w_string(rilp, NULL); /* pin2; only req'd for writes */ |
898 | parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */ |
899 | |
900 | + /* |
901 | + * sessionId, specific to latest MTK modems (harmless for older ones). |
902 | + * It looks like this field selects one or another SIM application, but |
903 | + * we use only one at a time so using zero here seems safe. |
904 | + */ |
905 | + if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) |
906 | + parcel_w_int32(rilp, 0); |
907 | + |
908 | return TRUE; |
909 | |
910 | error: |
911 | @@ -429,6 +437,10 @@ |
912 | parcel_w_string(rilp, NULL); /* pin2; only req'd for writes */ |
913 | parcel_w_string(rilp, req->aid_str); |
914 | |
915 | + /* sessionId, specific to latest MTK modems (harmless for older ones) */ |
916 | + if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) |
917 | + parcel_w_int32(rilp, 0); |
918 | + |
919 | return TRUE; |
920 | |
921 | error: |
922 | @@ -459,6 +471,10 @@ |
923 | parcel_w_string(rilp, NULL); /* pin2; only req'd for writes */ |
924 | parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */ |
925 | |
926 | + /* sessionId, specific to latest MTK modems (harmless for older ones) */ |
927 | + if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) |
928 | + parcel_w_int32(rilp, 0); |
929 | + |
930 | return TRUE; |
931 | |
932 | error: |
933 | @@ -494,6 +510,10 @@ |
934 | parcel_w_string(rilp, NULL); /* pin2; only for FDN/BDN */ |
935 | parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */ |
936 | |
937 | + /* sessionId, specific to latest MTK modems (harmless for older ones) */ |
938 | + if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) |
939 | + parcel_w_int32(rilp, 0); |
940 | + |
941 | g_ril_append_print_buf(gril, |
942 | "%s%d,%d,%d,%s,pin2=(null),aid=%s)", |
943 | print_buf, |
944 | @@ -555,6 +575,10 @@ |
945 | parcel_w_string(rilp, NULL); /* pin2; only for FDN/BDN */ |
946 | parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */ |
947 | |
948 | + /* sessionId, specific to latest MTK modems (harmless for older ones) */ |
949 | + if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) |
950 | + parcel_w_int32(rilp, 0); |
951 | + |
952 | g_ril_append_print_buf(gril, |
953 | "%s%d,%d,%d,%s,pin2=(null),aid=%s)", |
954 | print_buf, |
955 | @@ -1057,3 +1081,36 @@ |
956 | g_ril_append_print_buf(gril, "(%s)", hex_dump? hex_dump: "(null)"); |
957 | g_free(hex_dump); |
958 | } |
959 | + |
960 | +void g_ril_request_set_initial_attach_apn(GRil *gril, const char *apn, |
961 | + int proto, |
962 | + const char *user, |
963 | + const char *passwd, |
964 | + const char *mccmnc, |
965 | + struct parcel *rilp) |
966 | +{ |
967 | + const char *proto_str; |
968 | + const int auth_type = RIL_AUTH_ANY; |
969 | + |
970 | + parcel_init(rilp); |
971 | + |
972 | + parcel_w_string(rilp, apn); |
973 | + |
974 | + proto_str = ril_ofono_protocol_to_ril_string(proto); |
975 | + parcel_w_string(rilp, proto_str); |
976 | + |
977 | + parcel_w_int32(rilp, auth_type); |
978 | + parcel_w_string(rilp, user); |
979 | + parcel_w_string(rilp, passwd); |
980 | + |
981 | + g_ril_append_print_buf(gril, "(%s,%s,%s,%s,%s", apn, proto_str, |
982 | + ril_authtype_to_string(auth_type), |
983 | + user, passwd); |
984 | + |
985 | + if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) { |
986 | + parcel_w_string(rilp, mccmnc); |
987 | + g_ril_append_print_buf(gril, "%s,%s)", print_buf, mccmnc); |
988 | + } else { |
989 | + g_ril_append_print_buf(gril, "%s)", print_buf); |
990 | + } |
991 | +} |
992 | |
993 | === modified file 'gril/grilrequest.h' |
994 | --- gril/grilrequest.h 2014-07-29 06:11:22 +0000 |
995 | +++ gril/grilrequest.h 2015-02-04 00:09:49 +0000 |
996 | @@ -269,6 +269,13 @@ |
997 | void g_ril_request_oem_hook_raw(GRil *gril, const void *payload, size_t length, |
998 | struct parcel *rilp); |
999 | |
1000 | +void g_ril_request_set_initial_attach_apn(GRil *gril, const char *apn, |
1001 | + int proto, |
1002 | + const char *user, |
1003 | + const char *passwd, |
1004 | + const char *mccmnc, |
1005 | + struct parcel *rilp); |
1006 | + |
1007 | #ifdef __cplusplus |
1008 | } |
1009 | #endif |
1010 | |
1011 | === modified file 'gril/grilutil.c' |
1012 | --- gril/grilutil.c 2014-04-29 15:50:22 +0000 |
1013 | +++ gril/grilutil.c 2015-02-04 00:09:49 +0000 |
1014 | @@ -123,6 +123,24 @@ |
1015 | } |
1016 | } |
1017 | |
1018 | +const char *ril_authtype_to_string(int auth_type) |
1019 | +{ |
1020 | + switch (auth_type) { |
1021 | + case RIL_AUTH_NONE: |
1022 | + return "NONE"; |
1023 | + case RIL_AUTH_PAP: |
1024 | + return "PAP"; |
1025 | + case RIL_AUTH_CHAP: |
1026 | + return "CHAP"; |
1027 | + case RIL_AUTH_BOTH: |
1028 | + return "BOTH"; |
1029 | + case RIL_AUTH_ANY: |
1030 | + return "ANY"; |
1031 | + default: |
1032 | + return "<INVALID>"; |
1033 | + } |
1034 | +} |
1035 | + |
1036 | const char *ril_cardstate_to_string(int card_state) |
1037 | { |
1038 | switch (card_state) { |
1039 | @@ -475,6 +493,8 @@ |
1040 | return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU"; |
1041 | case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: |
1042 | return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS"; |
1043 | + case RIL_REQUEST_SET_INITIAL_ATTACH_APN: |
1044 | + return "RIL_REQUEST_SET_INITIAL_ATTACH_APN"; |
1045 | default: |
1046 | return "<INVALID>"; |
1047 | } |
1048 | |
1049 | === modified file 'gril/grilutil.h' |
1050 | --- gril/grilutil.h 2014-04-29 15:50:22 +0000 |
1051 | +++ gril/grilutil.h 2015-02-04 00:09:49 +0000 |
1052 | @@ -35,6 +35,7 @@ |
1053 | int ril_protocol_string_to_ofono_protocol(gchar *protocol_str); |
1054 | const char *ril_appstate_to_string(int app_state); |
1055 | const char *ril_apptype_to_string(int app_type); |
1056 | +const char *ril_authtype_to_string(int auth_type); |
1057 | const char *ril_cardstate_to_string(int card_state); |
1058 | const char *ril_error_to_string(int error); |
1059 | const char *ril_pinstate_to_string(int pin_state); |
1060 | |
1061 | === modified file 'gril/ril_constants.h' |
1062 | --- gril/ril_constants.h 2014-09-22 16:06:53 +0000 |
1063 | +++ gril/ril_constants.h 2015-02-04 00:09:49 +0000 |
1064 | @@ -73,6 +73,14 @@ |
1065 | #define PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA 10 |
1066 | #define PREF_NET_TYPE_LTE_ONLY 11 |
1067 | #define PREF_NET_TYPE_LTE_WCDMA 12 |
1068 | +/* MTK specific network types */ |
1069 | +#define MTK_PREF_NET_TYPE_BASE 30 |
1070 | +#define MTK_PREF_NET_TYPE_LTE_GSM_WCDMA (MTK_PREF_NET_TYPE_BASE + 1) |
1071 | +#define MTK_PREF_NET_TYPE_LTE_GSM_WCDMA_MMDC (MTK_PREF_NET_TYPE_BASE + 2) |
1072 | +#define MTK_PREF_NET_TYPE_GSM_WCDMA_LTE (MTK_PREF_NET_TYPE_BASE + 3) |
1073 | +#define MTK_PREF_NET_TYPE_GSM_WCDMA_LTE_MMDC (MTK_PREF_NET_TYPE_BASE + 4) |
1074 | +#define MTK_PREF_NET_TYPE_LTE_GSM_TYPE (MTK_PREF_NET_TYPE_BASE + 5) |
1075 | +#define MTK_PREF_NET_TYPE_LTE_GSM_MMDC_TYPE (MTK_PREF_NET_TYPE_BASE + 6) |
1076 | |
1077 | /* |
1078 | * Data Call Failure causes ( see TS 24.008 ) |
1079 | @@ -172,6 +180,13 @@ |
1080 | /* MTK specific profile for MMS */ |
1081 | #define RIL_DATA_PROFILE_MTK_MMS (RIL_DATA_PROFILE_OEM_BASE + 1) |
1082 | |
1083 | +/* |
1084 | + * auth type -1 seems to mean 0 (RIL_AUTH_NONE) if no user/password is |
1085 | + * specified or 3 (RIL_AUTH_BOTH) otherwise. See $ANDROID/packages/ |
1086 | + * providers/TelephonyProvider/src/com/android/providers/telephony/ |
1087 | + * TelephonyProvider.java. |
1088 | + */ |
1089 | +#define RIL_AUTH_ANY -1 |
1090 | #define RIL_AUTH_NONE 0 |
1091 | #define RIL_AUTH_PAP 1 |
1092 | #define RIL_AUTH_CHAP 2 |
1093 | @@ -206,6 +221,33 @@ |
1094 | #define RIL_APPTYPE_CSIM 4 |
1095 | #define RIL_APPTYPE_ISIM 5 |
1096 | |
1097 | +/* SIM - PersoSubstate */ |
1098 | +#define RIL_PERSOSUBSTATE_UNKNOWN 0 |
1099 | +#define RIL_PERSOSUBSTATE_IN_PROGRESS 1 |
1100 | +#define RIL_PERSOSUBSTATE_READY 2 |
1101 | +#define RIL_PERSOSUBSTATE_SIM_NETWORK 3 |
1102 | +#define RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET 4 |
1103 | +#define RIL_PERSOSUBSTATE_SIM_CORPORATE 5 |
1104 | +#define RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER 6 |
1105 | +#define RIL_PERSOSUBSTATE_SIM_SIM 7 |
1106 | +#define RIL_PERSOSUBSTATE_SIM_NETWORK_PUK 8 |
1107 | +#define RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK 9 |
1108 | +#define RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK 10 |
1109 | +#define RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK 11 |
1110 | +#define RIL_PERSOSUBSTATE_SIM_SIM_PUK 12 |
1111 | +#define RIL_PERSOSUBSTATE_RUIM_NETWORK1 13 |
1112 | +#define RIL_PERSOSUBSTATE_RUIM_NETWORK2 14 |
1113 | +#define RIL_PERSOSUBSTATE_RUIM_HRPD 15 |
1114 | +#define RIL_PERSOSUBSTATE_RUIM_CORPORATE 16 |
1115 | +#define RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER 17 |
1116 | +#define RIL_PERSOSUBSTATE_RUIM_RUIM 18 |
1117 | +#define RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK 19 |
1118 | +#define RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK 20 |
1119 | +#define RIL_PERSOSUBSTATE_RUIM_HRPD_PUK 21 |
1120 | +#define RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK 22 |
1121 | +#define RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK 23 |
1122 | +#define RIL_PERSOSUBSTATE_RUIM_RUIM_PUK 24 |
1123 | + |
1124 | /* RIL Request Messages */ |
1125 | #define RIL_REQUEST_GET_SIM_STATUS 1 |
1126 | #define RIL_REQUEST_ENTER_SIM_PIN 2 |
1127 | @@ -316,6 +358,7 @@ |
1128 | #define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106 |
1129 | #define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107 |
1130 | #define RIL_REQUEST_VOICE_RADIO_TECH 108 |
1131 | +#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111 |
1132 | |
1133 | /* RIL Unsolicited Messages */ |
1134 | #define RIL_UNSOL_RESPONSE_BASE 1000 |
1135 | |
1136 | === removed file 'gril/ringbuffer.h' |
1137 | --- gril/ringbuffer.h 2013-09-09 19:21:32 +0000 |
1138 | +++ gril/ringbuffer.h 1970-01-01 00:00:00 +0000 |
1139 | @@ -1,107 +0,0 @@ |
1140 | -/* |
1141 | - * |
1142 | - * AT chat library with GLib integration |
1143 | - * |
1144 | - * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. |
1145 | - * |
1146 | - * This program is free software; you can redistribute it and/or modify |
1147 | - * it under the terms of the GNU General Public License version 2 as |
1148 | - * published by the Free Software Foundation. |
1149 | - * |
1150 | - * This program is distributed in the hope that it will be useful, |
1151 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1152 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1153 | - * GNU General Public License for more details. |
1154 | - * |
1155 | - * You should have received a copy of the GNU General Public License |
1156 | - * along with this program; if not, write to the Free Software |
1157 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1158 | - * |
1159 | - */ |
1160 | - |
1161 | -struct ring_buffer; |
1162 | - |
1163 | -/*! |
1164 | - * Creates a new ring buffer with capacity size |
1165 | - */ |
1166 | -struct ring_buffer *ring_buffer_new(unsigned int size); |
1167 | - |
1168 | -/*! |
1169 | - * Frees the resources allocated for the ring buffer |
1170 | - */ |
1171 | -void ring_buffer_free(struct ring_buffer *buf); |
1172 | - |
1173 | -/*! |
1174 | - * Returns the capacity of the ring buffer |
1175 | - */ |
1176 | -int ring_buffer_capacity(struct ring_buffer *buf); |
1177 | - |
1178 | -/*! |
1179 | - * Resets the ring buffer, all data inside the buffer is lost |
1180 | - */ |
1181 | -void ring_buffer_reset(struct ring_buffer *buf); |
1182 | - |
1183 | -/*! |
1184 | - * Writes data of size len into the ring buffer buf. Returns -1 if the |
1185 | - * write failed or the number of bytes written |
1186 | - */ |
1187 | -int ring_buffer_write(struct ring_buffer *buf, const void *data, |
1188 | - unsigned int len); |
1189 | - |
1190 | -/*! |
1191 | - * Advances the write counter by len, this is meant to be used with |
1192 | - * the ring_buffer_write_ptr function. Returns the number of bytes |
1193 | - * actually advanced (the capacity of the buffer) |
1194 | - */ |
1195 | -int ring_buffer_write_advance(struct ring_buffer *buf, unsigned int len); |
1196 | - |
1197 | -/*! |
1198 | - * Returns the write pointer with write offset specified by offset. Careful |
1199 | - * not to write past the end of the buffer. Use the ring_buffer_avail_no_wrap |
1200 | - * function, and ring_buffer_write_advance. |
1201 | - */ |
1202 | -unsigned char *ring_buffer_write_ptr(struct ring_buffer *buf, |
1203 | - unsigned int offset); |
1204 | - |
1205 | -/*! |
1206 | - * Returns the number of free bytes available in the buffer |
1207 | - */ |
1208 | -int ring_buffer_avail(struct ring_buffer *buf); |
1209 | - |
1210 | -/*! |
1211 | - * Returns the number of free bytes available in the buffer without wrapping |
1212 | - */ |
1213 | -int ring_buffer_avail_no_wrap(struct ring_buffer *buf); |
1214 | - |
1215 | -/*! |
1216 | - * Reads data from the ring buffer buf into memory region pointed to by data. |
1217 | - * A maximum of len bytes will be read. Returns -1 if the read failed or |
1218 | - * the number of bytes read |
1219 | - */ |
1220 | -int ring_buffer_read(struct ring_buffer *buf, void *data, |
1221 | - unsigned int len); |
1222 | - |
1223 | -/*! |
1224 | - * Returns the read pointer with read offset specified by offset. No bounds |
1225 | - * checking is performed. Be careful not to read past the end of the buffer. |
1226 | - * Use the ring_buffer_len_no_wrap function, and ring_buffer_drain. |
1227 | - */ |
1228 | -unsigned char *ring_buffer_read_ptr(struct ring_buffer *buf, |
1229 | - unsigned int offset); |
1230 | - |
1231 | -/*! |
1232 | - * Returns the number of bytes currently available to be read in the buffer |
1233 | - */ |
1234 | -int ring_buffer_len(struct ring_buffer *buf); |
1235 | - |
1236 | -/*! |
1237 | - * Returns the number of bytes currently available to be read in the buffer |
1238 | - * without wrapping. |
1239 | - */ |
1240 | -int ring_buffer_len_no_wrap(struct ring_buffer *buf); |
1241 | - |
1242 | -/*! |
1243 | - * Drains the ring buffer of len bytes. Returns the number of bytes the |
1244 | - * read counter was actually advanced. |
1245 | - */ |
1246 | -int ring_buffer_drain(struct ring_buffer *buf, unsigned int len); |
1247 | |
1248 | === modified file 'include/gprs-context.h' |
1249 | --- include/gprs-context.h 2012-07-16 01:05:23 +0000 |
1250 | +++ include/gprs-context.h 2015-02-04 00:09:49 +0000 |
1251 | @@ -46,6 +46,7 @@ |
1252 | OFONO_GPRS_CONTEXT_TYPE_MMS, |
1253 | OFONO_GPRS_CONTEXT_TYPE_WAP, |
1254 | OFONO_GPRS_CONTEXT_TYPE_IMS, |
1255 | + OFONO_GPRS_CONTEXT_TYPE_IA, |
1256 | }; |
1257 | |
1258 | struct ofono_gprs_primary_context { |
1259 | |
1260 | === modified file 'include/gprs.h' |
1261 | --- include/gprs.h 2011-10-10 20:39:42 +0000 |
1262 | +++ include/gprs.h 2015-02-04 00:09:49 +0000 |
1263 | @@ -27,6 +27,7 @@ |
1264 | #endif |
1265 | |
1266 | #include <ofono/types.h> |
1267 | +#include <ofono/gprs-context.h> |
1268 | |
1269 | struct ofono_gprs; |
1270 | struct ofono_gprs_context; |
1271 | @@ -45,6 +46,10 @@ |
1272 | ofono_gprs_cb_t cb, void *data); |
1273 | void (*attached_status)(struct ofono_gprs *gprs, |
1274 | ofono_gprs_status_cb_t cb, void *data); |
1275 | + void (*set_ia_apn)(struct ofono_gprs *gprs, const char *apn, |
1276 | + enum ofono_gprs_proto proto, const char *user, |
1277 | + const char *passwd, const char *mccmnc, |
1278 | + ofono_gprs_cb_t cb, void *data); |
1279 | }; |
1280 | |
1281 | enum gprs_suspend_cause { |
1282 | |
1283 | === modified file 'plugins/mbpi.c' |
1284 | --- plugins/mbpi.c 2013-10-02 07:11:31 +0000 |
1285 | +++ plugins/mbpi.c 2015-02-04 00:09:49 +0000 |
1286 | @@ -73,6 +73,7 @@ |
1287 | _(OFONO_GPRS_CONTEXT_TYPE_MMS); |
1288 | _(OFONO_GPRS_CONTEXT_TYPE_WAP); |
1289 | _(OFONO_GPRS_CONTEXT_TYPE_IMS); |
1290 | + _(OFONO_GPRS_CONTEXT_TYPE_IA); |
1291 | } |
1292 | |
1293 | return "OFONO_GPRS_CONTEXT_TYPE_<UNKNOWN>"; |
1294 | |
1295 | === modified file 'plugins/mtk.c' |
1296 | --- plugins/mtk.c 2014-11-17 15:43:35 +0000 |
1297 | +++ plugins/mtk.c 2015-02-04 00:09:49 +0000 |
1298 | @@ -56,7 +56,9 @@ |
1299 | |
1300 | #include "ofono.h" |
1301 | |
1302 | +#include <gril.h> |
1303 | #include <grilreply.h> |
1304 | +#include <grilrequest.h> |
1305 | #include <grilunsol.h> |
1306 | |
1307 | #include "drivers/rilmodem/rilmodem.h" |
1308 | @@ -67,6 +69,7 @@ |
1309 | #include "drivers/mtkmodem/mtkutil.h" |
1310 | #include "drivers/mtkmodem/mtkrequest.h" |
1311 | #include "drivers/mtkmodem/mtkreply.h" |
1312 | +#include "drivers/mtkmodem/mtkunsol.h" |
1313 | #include "drivers/mtkmodem/mtksettings.h" |
1314 | |
1315 | #define MAX_SIM_STATUS_RETRIES 15 |
1316 | @@ -87,13 +90,19 @@ |
1317 | |
1318 | #define T_WAIT_DISCONN_MS 1000 |
1319 | |
1320 | +enum mtk_sim_type { |
1321 | + MTK_SIM_TYPE_1 = 1, |
1322 | + MTK_SIM_TYPE_2 = 2, |
1323 | + MTK_SIM_TYPE_3 = 3 |
1324 | +}; |
1325 | + |
1326 | static const char hex_slot_0[] = "Slot 0: "; |
1327 | static const char hex_slot_1[] = "Slot 1: "; |
1328 | |
1329 | typedef void (*pending_cb_t)(struct cb_data *cbd); |
1330 | |
1331 | struct mtk_data { |
1332 | - GRil *modem; |
1333 | + GRil *ril; |
1334 | int sim_status_retries; |
1335 | ofono_bool_t ofono_online; |
1336 | ofono_bool_t ofono_online_target; |
1337 | @@ -120,9 +129,10 @@ |
1338 | struct ofono_phonebook *phonebook; |
1339 | struct ofono_gprs *gprs; |
1340 | struct ofono_message_waiting *message_waiting; |
1341 | - struct ofono_modem *ofono_modem; |
1342 | + struct ofono_modem *modem; |
1343 | ofono_bool_t has_3g; |
1344 | struct mtk_settings_data *mtk_settings; |
1345 | + int fw_type; |
1346 | }; |
1347 | |
1348 | /* |
1349 | @@ -131,15 +141,15 @@ |
1350 | * only through the socket for slot 0. So we need a pointer to the main socket. |
1351 | * Also, we need to access information of one channel from the other channel. |
1352 | */ |
1353 | -static struct mtk_data *mtk_0; |
1354 | -static struct mtk_data *mtk_1; |
1355 | +static struct mtk_data *mtk_data_0; |
1356 | +static struct mtk_data *mtk_data_1; |
1357 | |
1358 | /* Some variables control global state of the modem and are then static */ |
1359 | static gboolean disconnect_expected; |
1360 | static guint not_disconn_cb_id; |
1361 | |
1362 | struct socket_data { |
1363 | - GRil *gril; |
1364 | + GRil *ril; |
1365 | const char *path; |
1366 | int radio_state; |
1367 | guint radio_state_ev_id; |
1368 | @@ -153,7 +163,7 @@ |
1369 | ofono_modem_online_cb_t callback, void *data); |
1370 | static void query_3g_caps(struct socket_data *sock); |
1371 | static void socket_disconnected(gpointer user_data); |
1372 | -static void start_slot(struct mtk_data *ril, struct socket_data *sock, |
1373 | +static void start_slot(struct mtk_data *md, struct socket_data *sock, |
1374 | const char *hex_prefix); |
1375 | |
1376 | static void mtk_debug(const char *str, void *user_data) |
1377 | @@ -163,12 +173,12 @@ |
1378 | ofono_info("%s%s", prefix, str); |
1379 | } |
1380 | |
1381 | -static struct mtk_data *ril_complement(struct mtk_data *ril) |
1382 | +static struct mtk_data *mtk_data_complement(struct mtk_data *md) |
1383 | { |
1384 | - if (ril->slot == MULTISIM_SLOT_0) |
1385 | - return mtk_1; |
1386 | + if (md->slot == MULTISIM_SLOT_0) |
1387 | + return mtk_data_1; |
1388 | else |
1389 | - return mtk_0; |
1390 | + return mtk_data_0; |
1391 | } |
1392 | |
1393 | static struct socket_data *socket_complement(struct socket_data *sock) |
1394 | @@ -196,17 +206,17 @@ |
1395 | |
1396 | void mtk_set_attach_state(struct ofono_modem *modem, ofono_bool_t attached) |
1397 | { |
1398 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1399 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1400 | |
1401 | - ril->gprs_attach = attached; |
1402 | + md->gprs_attach = attached; |
1403 | } |
1404 | |
1405 | static void detach_received_cb(struct ril_msg *message, gpointer user_data) |
1406 | { |
1407 | - struct mtk_data *ril = user_data; |
1408 | + struct mtk_data *md = user_data; |
1409 | |
1410 | if (message->error == RIL_E_SUCCESS) |
1411 | - g_ril_print_response_no_args(ril->modem, message); |
1412 | + g_ril_print_response_no_args(md->ril, message); |
1413 | else |
1414 | ofono_error("%s: RIL error %s", __func__, |
1415 | ril_error_to_string(message->error)); |
1416 | @@ -214,18 +224,18 @@ |
1417 | |
1418 | void mtk_detach_received(struct ofono_modem *modem) |
1419 | { |
1420 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1421 | - struct mtk_data *ril_c = ril_complement(ril); |
1422 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1423 | + struct mtk_data *md_c = mtk_data_complement(md); |
1424 | |
1425 | - if (ril_c != NULL && ril_c->gprs_attach) { |
1426 | + if (md_c != NULL && md_c->gprs_attach) { |
1427 | struct parcel rilp; |
1428 | |
1429 | - g_mtk_request_set_gprs_connect_type(ril_c->modem, |
1430 | - ril_c->gprs_attach, &rilp); |
1431 | + g_mtk_request_set_gprs_connect_type(md_c->ril, |
1432 | + md_c->gprs_attach, &rilp); |
1433 | |
1434 | - if (g_ril_send(ril_c->modem, |
1435 | + if (g_ril_send(md_c->ril, |
1436 | MTK_RIL_REQUEST_SET_GPRS_CONNECT_TYPE, |
1437 | - &rilp, detach_received_cb, ril_c, NULL) == 0) |
1438 | + &rilp, detach_received_cb, md_c, NULL) == 0) |
1439 | ofono_error("%s: send failed", __func__); |
1440 | } |
1441 | } |
1442 | @@ -233,7 +243,7 @@ |
1443 | static void radio_state_changed(struct ril_msg *message, gpointer user_data) |
1444 | { |
1445 | struct socket_data *sock = user_data; |
1446 | - int radio_state = g_ril_unsol_parse_radio_state_changed(sock->gril, |
1447 | + int radio_state = g_ril_unsol_parse_radio_state_changed(sock->ril, |
1448 | message); |
1449 | |
1450 | if (radio_state != sock->radio_state) { |
1451 | @@ -247,9 +257,9 @@ |
1452 | * who owns the 3G capabilities in case both slots have already |
1453 | * radio state different from UNAVAILABLE. |
1454 | */ |
1455 | - if (mtk_1 == NULL) { |
1456 | - mtk_0->has_3g = TRUE; |
1457 | - start_slot(mtk_0, sock, hex_slot_0); |
1458 | + if (mtk_data_1 == NULL) { |
1459 | + mtk_data_0->has_3g = TRUE; |
1460 | + start_slot(mtk_data_0, sock, hex_slot_0); |
1461 | } else if (sock->radio_state == RADIO_STATE_UNAVAILABLE && |
1462 | sock_c != NULL && sock_c->radio_state != |
1463 | RADIO_STATE_UNAVAILABLE) { |
1464 | @@ -263,18 +273,18 @@ |
1465 | static void mtk_radio_state_changed(struct ril_msg *message, gpointer user_data) |
1466 | { |
1467 | struct ofono_modem *modem = user_data; |
1468 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1469 | - int radio_state = g_ril_unsol_parse_radio_state_changed(ril->modem, |
1470 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1471 | + int radio_state = g_ril_unsol_parse_radio_state_changed(md->ril, |
1472 | message); |
1473 | |
1474 | - if (radio_state != ril->radio_state) { |
1475 | + if (radio_state != md->radio_state) { |
1476 | |
1477 | - ofono_info("%s, slot %d: state: %s ril->ofono_online: %d", |
1478 | - __func__, ril->slot, |
1479 | + ofono_info("%s, slot %d: state: %s md->ofono_online: %d", |
1480 | + __func__, md->slot, |
1481 | ril_radio_state_to_string(radio_state), |
1482 | - ril->ofono_online); |
1483 | + md->ofono_online); |
1484 | |
1485 | - ril->radio_state = radio_state; |
1486 | + md->radio_state = radio_state; |
1487 | |
1488 | switch (radio_state) { |
1489 | case RADIO_STATE_ON: |
1490 | @@ -286,9 +296,9 @@ |
1491 | |
1492 | case RADIO_STATE_UNAVAILABLE: |
1493 | case RADIO_STATE_OFF: |
1494 | - if (ril->ofono_online) { |
1495 | + if (md->ofono_online) { |
1496 | ofono_warn("%s, slot %d: radio powered off!", |
1497 | - __func__, ril->slot); |
1498 | + __func__, md->slot); |
1499 | } |
1500 | break; |
1501 | default: |
1502 | @@ -298,14 +308,48 @@ |
1503 | } |
1504 | } |
1505 | |
1506 | +static void reg_suspended_cb(struct ril_msg *message, gpointer user_data) |
1507 | +{ |
1508 | + struct ofono_modem *modem = user_data; |
1509 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1510 | + |
1511 | + if (message->error != RIL_E_SUCCESS) { |
1512 | + ofono_error("%s: RIL error %s", __func__, |
1513 | + ril_error_to_string(message->error)); |
1514 | + return; |
1515 | + } |
1516 | + |
1517 | + g_ril_print_response_no_args(md->ril, message); |
1518 | +} |
1519 | + |
1520 | +static void reg_suspended(struct ril_msg *message, gpointer user_data) |
1521 | +{ |
1522 | + struct ofono_modem *modem = user_data; |
1523 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1524 | + struct parcel rilp; |
1525 | + int session_id; |
1526 | + |
1527 | + session_id = g_mtk_unsol_parse_registration_suspended(md->ril, message); |
1528 | + if (session_id < 0) { |
1529 | + ofono_error("%s: parse error", __func__); |
1530 | + return; |
1531 | + } |
1532 | + |
1533 | + g_mtk_request_resume_registration(md->ril, session_id, &rilp); |
1534 | + |
1535 | + if (g_ril_send(md->ril, MTK_RIL_REQUEST_RESUME_REGISTRATION, &rilp, |
1536 | + reg_suspended_cb, modem, NULL) == 0) |
1537 | + ofono_error("%s: failure sending request", __func__); |
1538 | +} |
1539 | + |
1540 | static void sim_removed(struct ril_msg *message, gpointer user_data) |
1541 | { |
1542 | struct ofono_modem *modem = (struct ofono_modem *) user_data; |
1543 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1544 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1545 | |
1546 | DBG(""); |
1547 | |
1548 | - g_ril_print_unsol_no_args(ril->modem, message); |
1549 | + g_ril_print_unsol_no_args(md->ril, message); |
1550 | |
1551 | ofono_modem_set_powered(modem, FALSE); |
1552 | g_idle_add(mtk_connected, modem); |
1553 | @@ -314,11 +358,11 @@ |
1554 | static void sim_inserted(struct ril_msg *message, gpointer user_data) |
1555 | { |
1556 | struct ofono_modem *modem = (struct ofono_modem *) user_data; |
1557 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1558 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1559 | |
1560 | DBG(""); |
1561 | |
1562 | - g_ril_print_unsol_no_args(ril->modem, message); |
1563 | + g_ril_print_unsol_no_args(md->ril, message); |
1564 | |
1565 | if (getenv("OFONO_RIL_HOT_SIM_SWAP")) { |
1566 | ofono_modem_set_powered(modem, FALSE); |
1567 | @@ -326,65 +370,203 @@ |
1568 | } |
1569 | } |
1570 | |
1571 | +static void set_trm_cb(struct ril_msg *message, gpointer user_data) |
1572 | +{ |
1573 | + struct ofono_modem *modem = user_data; |
1574 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1575 | + |
1576 | + if (message->error != RIL_E_SUCCESS) { |
1577 | + ofono_error("%s: RIL error %s", __func__, |
1578 | + ril_error_to_string(message->error)); |
1579 | + return; |
1580 | + } |
1581 | + |
1582 | + g_ril_print_response_no_args(md->ril, message); |
1583 | + |
1584 | + /* |
1585 | + * rild will close now the socket, so we set our state to power off: |
1586 | + * we will set the modem to powered when we reconnect to the socket. |
1587 | + * Measurements showed that rild takes around 5 seconds to re-start, but |
1588 | + * we use an 8 seconds timeout as times can vary and that value is also |
1589 | + * compatible with krillin modem. |
1590 | + */ |
1591 | + md->ofono_online = FALSE; |
1592 | + ofono_modem_set_powered(md->modem, FALSE); |
1593 | +} |
1594 | + |
1595 | +static void store_type_cb(struct ril_msg *message, gpointer user_data) |
1596 | +{ |
1597 | + struct ofono_modem *modem = user_data; |
1598 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1599 | + struct parcel rilp; |
1600 | + |
1601 | + if (message->error != RIL_E_SUCCESS) { |
1602 | + ofono_error("%s: RIL error %s", __func__, |
1603 | + ril_error_to_string(message->error)); |
1604 | + return; |
1605 | + } |
1606 | + |
1607 | + g_ril_print_response_no_args(md->ril, message); |
1608 | + |
1609 | + /* |
1610 | + * Send SET_TRM, which reloads the FW. We do not know the meaning of the |
1611 | + * magic number 0x0B. |
1612 | + */ |
1613 | + g_mtk_request_set_trm(md->ril, 0x0B, &rilp); |
1614 | + |
1615 | + if (g_ril_send(md->ril, MTK_RIL_REQUEST_SET_TRM, &rilp, |
1616 | + set_trm_cb, modem, NULL) == 0) |
1617 | + ofono_error("%s: failure sending request", __func__); |
1618 | +} |
1619 | + |
1620 | +static gboolean find_in_table(const char *str, |
1621 | + const char **table, int num_elem) |
1622 | +{ |
1623 | + int i; |
1624 | + |
1625 | + for (i = 0; i < num_elem; ++i) |
1626 | + if (strncmp(str, table[i], strlen(table[i])) == 0) |
1627 | + return TRUE; |
1628 | + |
1629 | + return FALSE; |
1630 | +} |
1631 | + |
1632 | +static enum mtk_sim_type sim_type_for_fw_loading(const char *imsi) |
1633 | +{ |
1634 | + /* China Mobile MCC/MNC codes */ |
1635 | + const char *table_type1[] = { "46000", "46002", "46007" }; |
1636 | + /* China Unicom and China Telecom MCC/MNC codes */ |
1637 | + const char *table_type3[] = |
1638 | + { "46001", "46006", "46009", "45407", "46005", "45502" }; |
1639 | + |
1640 | + if (find_in_table(imsi, table_type1, |
1641 | + sizeof(table_type1)/sizeof(table_type1[0]))) |
1642 | + return MTK_SIM_TYPE_1; |
1643 | + |
1644 | + if (find_in_table(imsi, table_type3, |
1645 | + sizeof(table_type3)/sizeof(table_type3[0]))) |
1646 | + return MTK_SIM_TYPE_3; |
1647 | + |
1648 | + return MTK_SIM_TYPE_2; |
1649 | +} |
1650 | + |
1651 | +static int sim_modem_fw(const char *imsi) |
1652 | +{ |
1653 | + enum mtk_sim_type sim_type; |
1654 | + int sim_fw = MTK_MD_TYPE_LWG; |
1655 | + |
1656 | + /* Find out our SIM type */ |
1657 | + sim_type = sim_type_for_fw_loading(imsi); |
1658 | + switch (sim_type) { |
1659 | + case MTK_SIM_TYPE_1: |
1660 | + /* LTE TDD - TD-SCDMA - GSM */ |
1661 | + sim_fw = MTK_MD_TYPE_LTG; |
1662 | + break; |
1663 | + case MTK_SIM_TYPE_2: |
1664 | + case MTK_SIM_TYPE_3: |
1665 | + /* LTE FDD - WCDMA - GSM */ |
1666 | + sim_fw = MTK_MD_TYPE_LWG; |
1667 | + break; |
1668 | + }; |
1669 | + |
1670 | + return sim_fw; |
1671 | +} |
1672 | + |
1673 | +static void set_fw_type(struct ofono_modem *modem, int type) |
1674 | +{ |
1675 | + ofono_bool_t lte_cap; |
1676 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1677 | + |
1678 | + md->fw_type = type; |
1679 | + |
1680 | + lte_cap = (type >= MTK_MD_TYPE_LWG) ? TRUE : FALSE; |
1681 | + ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap); |
1682 | +} |
1683 | + |
1684 | +static void check_modem_fw(struct ofono_modem *modem) |
1685 | +{ |
1686 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1687 | + int sim_type; |
1688 | + struct parcel rilp; |
1689 | + |
1690 | + /* We handle only LWG <-> LTG modem fw changes (arale case) */ |
1691 | + if (md->fw_type != MTK_MD_TYPE_LTG && md->fw_type != MTK_MD_TYPE_LWG) |
1692 | + return; |
1693 | + |
1694 | + /* Right modem fw type for our SIM */ |
1695 | + sim_type = sim_modem_fw(ofono_sim_get_imsi(md->sim)); |
1696 | + |
1697 | + if (md->fw_type == sim_type) |
1698 | + return; |
1699 | + |
1700 | + set_fw_type(modem, sim_type); |
1701 | + |
1702 | + g_mtk_request_store_modem_type(md->ril, sim_type, &rilp); |
1703 | + |
1704 | + if (g_ril_send(md->ril, MTK_RIL_REQUEST_STORE_MODEM_TYPE, &rilp, |
1705 | + store_type_cb, modem, NULL) == 0) |
1706 | + ofono_error("%s: failure sending request", __func__); |
1707 | +} |
1708 | + |
1709 | static int mtk_probe(struct ofono_modem *modem) |
1710 | { |
1711 | - struct mtk_data *ril = g_try_new0(struct mtk_data, 1); |
1712 | + struct mtk_data *md = g_try_new0(struct mtk_data, 1); |
1713 | |
1714 | - if (ril == NULL) { |
1715 | + if (md == NULL) { |
1716 | errno = ENOMEM; |
1717 | goto error; |
1718 | } |
1719 | |
1720 | - ril->ofono_online = FALSE; |
1721 | - ril->radio_state = RADIO_STATE_UNAVAILABLE; |
1722 | - |
1723 | - ril->slot = ofono_modem_get_integer(modem, "Slot"); |
1724 | - |
1725 | - if (ril->slot == MULTISIM_SLOT_0) |
1726 | - mtk_0 = ril; |
1727 | + md->ofono_online = FALSE; |
1728 | + md->radio_state = RADIO_STATE_UNAVAILABLE; |
1729 | + |
1730 | + md->slot = ofono_modem_get_integer(modem, "Slot"); |
1731 | + |
1732 | + if (md->slot == MULTISIM_SLOT_0) |
1733 | + mtk_data_0 = md; |
1734 | else |
1735 | - mtk_1 = ril; |
1736 | - |
1737 | - DBG("slot %d", ril->slot); |
1738 | - |
1739 | - ril->ofono_modem = modem; |
1740 | - |
1741 | - ofono_modem_set_data(modem, ril); |
1742 | + mtk_data_1 = md; |
1743 | + |
1744 | + DBG("slot %d", md->slot); |
1745 | + |
1746 | + md->modem = modem; |
1747 | + |
1748 | + ofono_modem_set_data(modem, md); |
1749 | |
1750 | return 0; |
1751 | |
1752 | error: |
1753 | - g_free(ril); |
1754 | + g_free(md); |
1755 | |
1756 | return -errno; |
1757 | } |
1758 | |
1759 | static void mtk_remove(struct ofono_modem *modem) |
1760 | { |
1761 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1762 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1763 | |
1764 | ofono_modem_set_data(modem, NULL); |
1765 | |
1766 | - if (!ril) |
1767 | + if (!md) |
1768 | return; |
1769 | |
1770 | - g_ril_unref(ril->modem); |
1771 | + g_ril_unref(md->ril); |
1772 | |
1773 | - g_free(ril); |
1774 | + g_free(md); |
1775 | } |
1776 | |
1777 | static void mtk_pre_sim(struct ofono_modem *modem) |
1778 | { |
1779 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1780 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1781 | |
1782 | - DBG("slot %d", ril->slot); |
1783 | + DBG("slot %d", md->slot); |
1784 | } |
1785 | |
1786 | static void mtk_post_sim(struct ofono_modem *modem) |
1787 | { |
1788 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1789 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1790 | |
1791 | - DBG("slot %d", ril->slot); |
1792 | + DBG("slot %d", md->slot); |
1793 | } |
1794 | |
1795 | /* |
1796 | @@ -398,15 +580,15 @@ |
1797 | static void sim_state_watch(enum ofono_sim_state new_state, void *data) |
1798 | { |
1799 | struct ofono_modem *modem = data; |
1800 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1801 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1802 | |
1803 | if (new_state == OFONO_SIM_STATE_READY) { |
1804 | struct ofono_gprs_context *gc; |
1805 | - struct mtk_gprs_data gprs_data = { ril->modem, modem }; |
1806 | + struct ril_gprs_driver_data gprs_data = { md->ril, modem }; |
1807 | struct ril_gprs_context_data inet_ctx = |
1808 | - { ril->modem, OFONO_GPRS_CONTEXT_TYPE_INTERNET }; |
1809 | + { md->ril, OFONO_GPRS_CONTEXT_TYPE_INTERNET }; |
1810 | struct ril_gprs_context_data mms_ctx = |
1811 | - { ril->modem, OFONO_GPRS_CONTEXT_TYPE_MMS }; |
1812 | + { md->ril, OFONO_GPRS_CONTEXT_TYPE_MMS }; |
1813 | |
1814 | DBG("SIM ready, creating more atoms"); |
1815 | |
1816 | @@ -416,28 +598,28 @@ |
1817 | * - stk ( SIM toolkit ) |
1818 | * - radio_settings |
1819 | */ |
1820 | - ril->sms = ofono_sms_create(modem, OFONO_RIL_VENDOR_MTK, |
1821 | - RILMODEM, ril->modem); |
1822 | + md->sms = ofono_sms_create(modem, OFONO_RIL_VENDOR_MTK, |
1823 | + RILMODEM, md->ril); |
1824 | |
1825 | /* netreg needs access to the SIM (SPN, SPDI) */ |
1826 | - ril->netreg = ofono_netreg_create(modem, OFONO_RIL_VENDOR_MTK, |
1827 | - RILMODEM, ril->modem); |
1828 | - ril->ussd = ofono_ussd_create(modem, OFONO_RIL_VENDOR_MTK, |
1829 | - RILMODEM, ril->modem); |
1830 | - ril->call_settings = |
1831 | + md->netreg = ofono_netreg_create(modem, OFONO_RIL_VENDOR_MTK, |
1832 | + RILMODEM, md->ril); |
1833 | + md->ussd = ofono_ussd_create(modem, OFONO_RIL_VENDOR_MTK, |
1834 | + RILMODEM, md->ril); |
1835 | + md->call_settings = |
1836 | ofono_call_settings_create(modem, OFONO_RIL_VENDOR_MTK, |
1837 | - RILMODEM, ril->modem); |
1838 | - ril->call_forwarding = |
1839 | + RILMODEM, md->ril); |
1840 | + md->call_forwarding = |
1841 | ofono_call_forwarding_create(modem, |
1842 | OFONO_RIL_VENDOR_MTK, |
1843 | - RILMODEM, ril->modem); |
1844 | - ril->call_barring = |
1845 | + RILMODEM, md->ril); |
1846 | + md->call_barring = |
1847 | ofono_call_barring_create(modem, OFONO_RIL_VENDOR_MTK, |
1848 | - RILMODEM, ril->modem); |
1849 | - ril->phonebook = |
1850 | + RILMODEM, md->ril); |
1851 | + md->phonebook = |
1852 | ofono_phonebook_create(modem, OFONO_RIL_VENDOR_MTK, |
1853 | RILMODEM, modem); |
1854 | - ril->gprs = ofono_gprs_create(modem, OFONO_RIL_VENDOR_MTK, |
1855 | + md->gprs = ofono_gprs_create(modem, OFONO_RIL_VENDOR_MTK, |
1856 | MTKMODEM, &gprs_data); |
1857 | |
1858 | gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK, |
1859 | @@ -445,7 +627,7 @@ |
1860 | if (gc) { |
1861 | ofono_gprs_context_set_type(gc, |
1862 | OFONO_GPRS_CONTEXT_TYPE_INTERNET); |
1863 | - ofono_gprs_add_context(ril->gprs, gc); |
1864 | + ofono_gprs_add_context(md->gprs, gc); |
1865 | } |
1866 | |
1867 | gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK, |
1868 | @@ -453,78 +635,117 @@ |
1869 | if (gc) { |
1870 | ofono_gprs_context_set_type(gc, |
1871 | OFONO_GPRS_CONTEXT_TYPE_MMS); |
1872 | - ofono_gprs_add_context(ril->gprs, gc); |
1873 | + ofono_gprs_add_context(md->gprs, gc); |
1874 | } |
1875 | |
1876 | - ril->message_waiting = ofono_message_waiting_create(modem); |
1877 | - if (ril->message_waiting) |
1878 | - ofono_message_waiting_register(ril->message_waiting); |
1879 | + md->message_waiting = ofono_message_waiting_create(modem); |
1880 | + if (md->message_waiting) |
1881 | + ofono_message_waiting_register(md->message_waiting); |
1882 | + |
1883 | + /* |
1884 | + * Now that we can access IMSI, see if a FW change is needed. |
1885 | + * TODO: Roaming case and timeout case when no network is found. |
1886 | + */ |
1887 | + check_modem_fw(modem); |
1888 | |
1889 | } else if (new_state == OFONO_SIM_STATE_LOCKED_OUT) { |
1890 | |
1891 | DBG("SIM locked, removing atoms"); |
1892 | |
1893 | - if (ril->message_waiting) { |
1894 | - ofono_message_waiting_remove(ril->message_waiting); |
1895 | - ril->message_waiting = NULL; |
1896 | - } |
1897 | - if (ril->gprs) { |
1898 | - ofono_gprs_remove(ril->gprs); |
1899 | - ril->gprs = NULL; |
1900 | - } |
1901 | - if (ril->phonebook) { |
1902 | - ofono_phonebook_remove(ril->phonebook); |
1903 | - ril->phonebook = NULL; |
1904 | - } |
1905 | - if (ril->call_barring) { |
1906 | - ofono_call_barring_remove(ril->call_barring); |
1907 | - ril->call_barring = NULL; |
1908 | - } |
1909 | - if (ril->call_forwarding) { |
1910 | - ofono_call_forwarding_remove(ril->call_forwarding); |
1911 | - ril->call_forwarding = NULL; |
1912 | - } |
1913 | - if (ril->call_settings) { |
1914 | - ofono_call_settings_remove(ril->call_settings); |
1915 | - ril->call_settings = NULL; |
1916 | - } |
1917 | - if (ril->ussd) { |
1918 | - ofono_ussd_remove(ril->ussd); |
1919 | - ril->ussd = NULL; |
1920 | - } |
1921 | - if (ril->netreg) { |
1922 | - ofono_netreg_remove(ril->netreg); |
1923 | - ril->netreg = NULL; |
1924 | - } |
1925 | - if (ril->sms) { |
1926 | - ofono_sms_remove(ril->sms); |
1927 | - ril->sms = NULL; |
1928 | + if (md->message_waiting) { |
1929 | + ofono_message_waiting_remove(md->message_waiting); |
1930 | + md->message_waiting = NULL; |
1931 | + } |
1932 | + if (md->gprs) { |
1933 | + ofono_gprs_remove(md->gprs); |
1934 | + md->gprs = NULL; |
1935 | + } |
1936 | + if (md->phonebook) { |
1937 | + ofono_phonebook_remove(md->phonebook); |
1938 | + md->phonebook = NULL; |
1939 | + } |
1940 | + if (md->call_barring) { |
1941 | + ofono_call_barring_remove(md->call_barring); |
1942 | + md->call_barring = NULL; |
1943 | + } |
1944 | + if (md->call_forwarding) { |
1945 | + ofono_call_forwarding_remove(md->call_forwarding); |
1946 | + md->call_forwarding = NULL; |
1947 | + } |
1948 | + if (md->call_settings) { |
1949 | + ofono_call_settings_remove(md->call_settings); |
1950 | + md->call_settings = NULL; |
1951 | + } |
1952 | + if (md->ussd) { |
1953 | + ofono_ussd_remove(md->ussd); |
1954 | + md->ussd = NULL; |
1955 | + } |
1956 | + if (md->netreg) { |
1957 | + ofono_netreg_remove(md->netreg); |
1958 | + md->netreg = NULL; |
1959 | + } |
1960 | + if (md->sms) { |
1961 | + ofono_sms_remove(md->sms); |
1962 | + md->sms = NULL; |
1963 | } |
1964 | } |
1965 | } |
1966 | |
1967 | -static void mtk_post_online(struct ofono_modem *modem) |
1968 | +static void create_online_atoms(struct ofono_modem *modem) |
1969 | { |
1970 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
1971 | - |
1972 | - DBG("slot %d", ril->slot); |
1973 | - |
1974 | - ril->sim_data.gril = ril->modem; |
1975 | - ril->sim_data.modem = modem; |
1976 | - ril->sim_data.ril_state_watch = sim_state_watch; |
1977 | - |
1978 | - ril->sim = ofono_sim_create(modem, OFONO_RIL_VENDOR_MTK, |
1979 | - RILMODEM, &ril->sim_data); |
1980 | - g_assert(ril->sim != NULL); |
1981 | + struct mtk_data *md = ofono_modem_get_data(modem); |
1982 | + struct ril_radio_settings_driver_data rs_data = { md->ril, modem }; |
1983 | + |
1984 | + md->sim_data.gril = md->ril; |
1985 | + md->sim_data.modem = modem; |
1986 | + md->sim_data.ril_state_watch = sim_state_watch; |
1987 | + |
1988 | + md->sim = ofono_sim_create(modem, OFONO_RIL_VENDOR_MTK, |
1989 | + RILMODEM, &md->sim_data); |
1990 | + g_assert(md->sim != NULL); |
1991 | |
1992 | /* Radio settings does not depend on the SIM */ |
1993 | ofono_radio_settings_create(modem, OFONO_RIL_VENDOR_MTK, |
1994 | - MTKMODEM, ril->modem); |
1995 | + MTKMODEM, &rs_data); |
1996 | +} |
1997 | + |
1998 | +static void query_type_cb(struct ril_msg *message, gpointer user_data) |
1999 | +{ |
2000 | + struct ofono_modem *modem = user_data; |
2001 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2002 | + int type; |
2003 | + |
2004 | + if (message->error != RIL_E_SUCCESS) { |
2005 | + ofono_error("%s: RIL error %s", __func__, |
2006 | + ril_error_to_string(message->error)); |
2007 | + return; |
2008 | + } |
2009 | + |
2010 | + type = g_mtk_reply_parse_query_modem_type(md->ril, message); |
2011 | + if (type < 0) { |
2012 | + ofono_error("%s: parse error", __func__); |
2013 | + return; |
2014 | + } |
2015 | + |
2016 | + set_fw_type(modem, type); |
2017 | + |
2018 | + create_online_atoms(modem); |
2019 | +} |
2020 | + |
2021 | +static void mtk_post_online(struct ofono_modem *modem) |
2022 | +{ |
2023 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2024 | + DBG("slot %d", md->slot); |
2025 | + |
2026 | + /* With modem powered we can query the type in krillin */ |
2027 | + if (g_ril_send(md->ril, MTK_RIL_REQUEST_QUERY_MODEM_TYPE, |
2028 | + NULL, query_type_cb, md->modem, NULL) == 0) |
2029 | + ofono_error("%s: failure sending QUERY_MODEM_TYPE", __func__); |
2030 | |
2031 | /* Register for changes in SIM insertion */ |
2032 | - g_ril_register(ril->modem, MTK_RIL_UNSOL_SIM_PLUG_OUT, |
2033 | + g_ril_register(md->ril, MTK_RIL_UNSOL_SIM_PLUG_OUT, |
2034 | sim_removed, modem); |
2035 | - g_ril_register(ril->modem, MTK_RIL_UNSOL_SIM_PLUG_IN, |
2036 | + g_ril_register(md->ril, MTK_RIL_UNSOL_SIM_PLUG_IN, |
2037 | sim_inserted, modem); |
2038 | } |
2039 | |
2040 | @@ -533,13 +754,13 @@ |
2041 | struct cb_data *cbd = user_data; |
2042 | ofono_modem_online_cb_t cb = cbd->cb; |
2043 | struct ofono_modem *modem = cbd->user; |
2044 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2045 | - struct mtk_data *ril_c; |
2046 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2047 | + struct mtk_data *md_c; |
2048 | |
2049 | - mtk_0->pending_cb = NULL; |
2050 | + mtk_data_0->pending_cb = NULL; |
2051 | |
2052 | if (message->error == RIL_E_SUCCESS) { |
2053 | - g_ril_print_response_no_args(ril->modem, message); |
2054 | + g_ril_print_response_no_args(md->ril, message); |
2055 | |
2056 | CALLBACK_WITH_SUCCESS(cb, cbd->data); |
2057 | } else { |
2058 | @@ -548,33 +769,33 @@ |
2059 | CALLBACK_WITH_FAILURE(cb, cbd->data); |
2060 | } |
2061 | |
2062 | - if (ril->ofono_online) |
2063 | - ril->mtk_settings = |
2064 | - mtk_settings_create(ril->ofono_modem, ril->modem, |
2065 | - ril->has_3g); |
2066 | + if (md->ofono_online) |
2067 | + md->mtk_settings = |
2068 | + mtk_settings_create(md->modem, md->ril, |
2069 | + md->has_3g); |
2070 | else |
2071 | - mtk_settings_remove(ril->mtk_settings); |
2072 | + mtk_settings_remove(md->mtk_settings); |
2073 | |
2074 | /* Execute possible pending operation on the other modem */ |
2075 | |
2076 | - ril_c = ril_complement(ril); |
2077 | + md_c = mtk_data_complement(md); |
2078 | |
2079 | - if (ril_c != NULL && ril_c->pending_online_cbd) { |
2080 | - struct cb_data *pending_cbd = ril_c->pending_online_cbd; |
2081 | + if (md_c != NULL && md_c->pending_online_cbd) { |
2082 | + struct cb_data *pending_cbd = md_c->pending_online_cbd; |
2083 | ofono_modem_online_cb_t pending_cb = pending_cbd->cb; |
2084 | |
2085 | - mtk_set_online(pending_cbd->user, ril_c->pending_online, |
2086 | + mtk_set_online(pending_cbd->user, md_c->pending_online, |
2087 | pending_cb, pending_cbd->data); |
2088 | |
2089 | - g_free(ril_c->pending_online_cbd); |
2090 | - ril_c->pending_online_cbd = NULL; |
2091 | + g_free(md_c->pending_online_cbd); |
2092 | + md_c->pending_online_cbd = NULL; |
2093 | } |
2094 | } |
2095 | |
2096 | static int sim_state() |
2097 | { |
2098 | - int state = mtk_0->ofono_online ? SIM_1_ACTIVE : NO_SIM_ACTIVE; |
2099 | - if (mtk_1 && mtk_1->ofono_online) |
2100 | + int state = mtk_data_0->ofono_online ? SIM_1_ACTIVE : NO_SIM_ACTIVE; |
2101 | + if (mtk_data_1 && mtk_data_1->ofono_online) |
2102 | state |= SIM_2_ACTIVE; |
2103 | |
2104 | return state; |
2105 | @@ -584,7 +805,7 @@ |
2106 | { |
2107 | struct parcel rilp; |
2108 | struct cb_data *cbd = user_data; |
2109 | - ofono_modem_online_cb_t cb; |
2110 | + ofono_modem_online_cb_t cb = NULL; |
2111 | GDestroyNotify notify = NULL; |
2112 | int sim_mode; |
2113 | |
2114 | @@ -593,19 +814,34 @@ |
2115 | cb = cbd->cb; |
2116 | } |
2117 | |
2118 | + /* Case of modems with just one slot */ |
2119 | + if (mtk_data_1 == NULL) { |
2120 | + mtk_data_0->pending_cb = NULL; |
2121 | + |
2122 | + if (cbd != NULL) { |
2123 | + CALLBACK_WITH_SUCCESS(cb, cbd->data); |
2124 | + g_free(cbd); |
2125 | + } |
2126 | + return; |
2127 | + } |
2128 | + |
2129 | sim_mode = sim_state(); |
2130 | |
2131 | if (sim_mode == NO_SIM_ACTIVE) |
2132 | sim_mode = MTK_SWITCH_MODE_ALL_INACTIVE; |
2133 | |
2134 | - g_mtk_request_dual_sim_mode_switch(mtk_0->modem, sim_mode, &rilp); |
2135 | + g_mtk_request_dual_sim_mode_switch(mtk_data_0->ril, sim_mode, &rilp); |
2136 | |
2137 | /* This request is always sent through the main socket */ |
2138 | - if (g_ril_send(mtk_0->modem, MTK_RIL_REQUEST_DUAL_SIM_MODE_SWITCH, |
2139 | + if (g_ril_send(mtk_data_0->ril, MTK_RIL_REQUEST_DUAL_SIM_MODE_SWITCH, |
2140 | &rilp, func, cbd, notify) == 0 && cbd != NULL) { |
2141 | ofono_error("%s: failure sending request", __func__); |
2142 | - CALLBACK_WITH_FAILURE(cb, cbd->data); |
2143 | - g_free(cbd); |
2144 | + mtk_data_0->pending_cb = NULL; |
2145 | + |
2146 | + if (cbd != NULL) { |
2147 | + CALLBACK_WITH_FAILURE(cb, cbd->data); |
2148 | + g_free(cbd); |
2149 | + } |
2150 | } |
2151 | } |
2152 | |
2153 | @@ -625,7 +861,7 @@ |
2154 | { |
2155 | struct cb_data *cbd = user_data; |
2156 | struct ofono_modem *modem = cbd->user; |
2157 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2158 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2159 | ofono_modem_online_cb_t cb = cbd->cb; |
2160 | |
2161 | DBG(""); |
2162 | @@ -658,7 +894,7 @@ |
2163 | */ |
2164 | |
2165 | if (message->error == RIL_E_SUCCESS) { |
2166 | - g_ril_print_response_no_args(ril->modem, message); |
2167 | + g_ril_print_response_no_args(md->ril, message); |
2168 | |
2169 | if (disconnect_expected) |
2170 | not_disconn_cb_id = g_timeout_add(T_WAIT_DISCONN_MS, |
2171 | @@ -680,17 +916,17 @@ |
2172 | mtk_send_sim_mode(mtk_sim_mode_cb, cbd); |
2173 | } |
2174 | |
2175 | -static void online_off_cb(struct ril_msg *message, gpointer user_data) |
2176 | +static void poweroff_cb(struct ril_msg *message, gpointer user_data) |
2177 | { |
2178 | struct cb_data *cbd = user_data; |
2179 | ofono_modem_online_cb_t cb = cbd->cb; |
2180 | struct ofono_modem *modem = cbd->user; |
2181 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2182 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2183 | |
2184 | if (message->error == RIL_E_SUCCESS) { |
2185 | - g_ril_print_response_no_args(ril->modem, message); |
2186 | + g_ril_print_response_no_args(md->ril, message); |
2187 | |
2188 | - mtk_settings_remove(ril->mtk_settings); |
2189 | + mtk_settings_remove(md->mtk_settings); |
2190 | |
2191 | CALLBACK_WITH_SUCCESS(cb, cbd->data); |
2192 | } else { |
2193 | @@ -700,10 +936,51 @@ |
2194 | } |
2195 | } |
2196 | |
2197 | +static int power_on_off(GRil *ril, gboolean on, struct cb_data *cbd) |
2198 | +{ |
2199 | + int cancel_id; |
2200 | + int req; |
2201 | + struct parcel rilp; |
2202 | + struct parcel *p_rilp; |
2203 | + GRilResponseFunc resp; |
2204 | + GDestroyNotify notify; |
2205 | + ofono_modem_online_cb_t cb = cbd->cb; |
2206 | + |
2207 | + /* Case of modems with just one slot */ |
2208 | + if (mtk_data_1 == NULL) { |
2209 | + /* Fall back to generic RIL_REQUEST_RADIO_POWER */ |
2210 | + req = RIL_REQUEST_RADIO_POWER; |
2211 | + g_ril_request_power(ril, on, &rilp); |
2212 | + p_rilp = &rilp; |
2213 | + } else { |
2214 | + req = on ? MTK_RIL_REQUEST_RADIO_POWERON |
2215 | + : MTK_RIL_REQUEST_RADIO_POWEROFF; |
2216 | + p_rilp = NULL; |
2217 | + } |
2218 | + |
2219 | + if (on) { |
2220 | + resp = poweron_cb; |
2221 | + notify = NULL; |
2222 | + } else { |
2223 | + resp = poweroff_cb; |
2224 | + notify = g_free; |
2225 | + } |
2226 | + |
2227 | + if ((cancel_id = g_ril_send(ril, req, p_rilp, resp, cbd, notify)) |
2228 | + == 0) { |
2229 | + ofono_error("%s: failure sending request", __func__); |
2230 | + CALLBACK_WITH_FAILURE(cb, cbd->data); |
2231 | + g_free(cbd); |
2232 | + return 0; |
2233 | + } |
2234 | + |
2235 | + return cancel_id; |
2236 | +} |
2237 | + |
2238 | static void mtk_set_online(struct ofono_modem *modem, ofono_bool_t online, |
2239 | ofono_modem_online_cb_t callback, void *data) |
2240 | { |
2241 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2242 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2243 | struct cb_data *cbd = cb_data_new(callback, data, modem); |
2244 | ofono_modem_online_cb_t cb = cbd->cb; |
2245 | int current_state, next_state; |
2246 | @@ -721,21 +998,21 @@ |
2247 | * need to do this serialization, which is different from the one done |
2248 | * per modem by ofono core. |
2249 | */ |
2250 | - if (mtk_0->pending_cb != NULL) { |
2251 | - ril->pending_online_cbd = cbd; |
2252 | - ril->pending_online = online; |
2253 | + if (mtk_data_0->pending_cb != NULL) { |
2254 | + md->pending_online_cbd = cbd; |
2255 | + md->pending_online = online; |
2256 | return; |
2257 | } |
2258 | |
2259 | current_state = sim_state(); |
2260 | |
2261 | - ril->ofono_online = online; |
2262 | + md->ofono_online = online; |
2263 | |
2264 | - /* Changes as ril points to either mtk_0 or mtk_1 global variables */ |
2265 | + /* Changes as md points to either mtk_data_0 or mtk_data_1 variables */ |
2266 | next_state = sim_state(); |
2267 | |
2268 | - DBG("setting mtk_%d->ofono_online to: %d (from %d to %d)", |
2269 | - ril->slot, online, current_state, next_state); |
2270 | + DBG("setting md_%d->ofono_online to: %d (from %d to %d)", |
2271 | + md->slot, online, current_state, next_state); |
2272 | |
2273 | if (current_state == next_state) { |
2274 | CALLBACK_WITH_SUCCESS(cb, cbd->data); |
2275 | @@ -745,28 +1022,18 @@ |
2276 | |
2277 | /* Reset mtk_data variables */ |
2278 | if (online == FALSE) |
2279 | - ril->sim_status_retries = 0; |
2280 | + md->sim_status_retries = 0; |
2281 | |
2282 | if (current_state == NO_SIM_ACTIVE) { |
2283 | /* Old state was off, need to power on the modem */ |
2284 | - if (g_ril_send(mtk_0->modem, MTK_RIL_REQUEST_RADIO_POWERON, |
2285 | - NULL, poweron_cb, cbd, NULL) == 0) { |
2286 | - CALLBACK_WITH_FAILURE(cb, cbd->data); |
2287 | - g_free(cbd); |
2288 | - } else { |
2289 | + if (power_on_off(mtk_data_0->ril, TRUE, cbd)) { |
2290 | /* Socket might disconnect... failsafe */ |
2291 | - mtk_0->pending_cb = poweron_disconnect; |
2292 | - mtk_0->pending_cbd = cbd; |
2293 | + mtk_data_0->pending_cb = poweron_disconnect; |
2294 | + mtk_data_0->pending_cbd = cbd; |
2295 | } |
2296 | } else if (next_state == NO_SIM_ACTIVE) { |
2297 | - if (g_ril_send(mtk_0->modem, MTK_RIL_REQUEST_RADIO_POWEROFF, |
2298 | - NULL, online_off_cb, cbd, g_free) == 0) { |
2299 | - ofono_error("%s: failure sending request", __func__); |
2300 | - CALLBACK_WITH_FAILURE(cb, cbd->data); |
2301 | - g_free(cbd); |
2302 | - } else { |
2303 | + if (power_on_off(mtk_data_0->ril, FALSE, cbd)) |
2304 | disconnect_expected = TRUE; |
2305 | - } |
2306 | } else { |
2307 | mtk_send_sim_mode(mtk_sim_mode_cb, cbd); |
2308 | } |
2309 | @@ -774,97 +1041,98 @@ |
2310 | |
2311 | static void set_online_cb(const struct ofono_error *error, void *data) |
2312 | { |
2313 | - if (mtk_1->ofono_online_target && !mtk_1->ofono_online) |
2314 | - mtk_set_online(mtk_1->ofono_modem, TRUE, set_online_cb, NULL); |
2315 | + if (mtk_data_1->ofono_online_target && !mtk_data_1->ofono_online) |
2316 | + mtk_set_online(mtk_data_1->modem, TRUE, set_online_cb, NULL); |
2317 | } |
2318 | |
2319 | static void set_offline_cb(const struct ofono_error *error, void *data) |
2320 | { |
2321 | - if (mtk_1->ofono_online) |
2322 | - mtk_set_online(mtk_1->ofono_modem, FALSE, set_offline_cb, NULL); |
2323 | - else if (mtk_0->ofono_online_target) |
2324 | - mtk_set_online(mtk_0->ofono_modem, TRUE, set_online_cb, NULL); |
2325 | + if (mtk_data_1->ofono_online) |
2326 | + mtk_set_online(mtk_data_1->modem, FALSE, set_offline_cb, NULL); |
2327 | + else if (mtk_data_0->ofono_online_target) |
2328 | + mtk_set_online(mtk_data_0->modem, TRUE, set_online_cb, NULL); |
2329 | else |
2330 | - mtk_set_online(mtk_1->ofono_modem, TRUE, set_online_cb, NULL); |
2331 | + mtk_set_online(mtk_data_1->modem, TRUE, set_online_cb, NULL); |
2332 | } |
2333 | |
2334 | void mtk_reset_all_modems(void) |
2335 | { |
2336 | - if (!mtk_0->ofono_online && !mtk_1->ofono_online) |
2337 | + if (!mtk_data_0->ofono_online && !mtk_data_1->ofono_online) |
2338 | return; |
2339 | |
2340 | - mtk_0->ofono_online_target = mtk_0->ofono_online; |
2341 | - mtk_1->ofono_online_target = mtk_1->ofono_online; |
2342 | - |
2343 | - ofono_modem_set_powered(mtk_0->ofono_modem, FALSE); |
2344 | - ofono_modem_set_powered(mtk_1->ofono_modem, FALSE); |
2345 | - |
2346 | - if (mtk_0->ofono_online) |
2347 | - mtk_set_online(mtk_0->ofono_modem, FALSE, set_offline_cb, NULL); |
2348 | + mtk_data_0->ofono_online_target = mtk_data_0->ofono_online; |
2349 | + mtk_data_1->ofono_online_target = mtk_data_1->ofono_online; |
2350 | + |
2351 | + ofono_modem_set_powered(mtk_data_0->modem, FALSE); |
2352 | + ofono_modem_set_powered(mtk_data_1->modem, FALSE); |
2353 | + |
2354 | + if (mtk_data_0->ofono_online) |
2355 | + mtk_set_online(mtk_data_0->modem, FALSE, set_offline_cb, NULL); |
2356 | else |
2357 | - mtk_set_online(mtk_1->ofono_modem, FALSE, set_offline_cb, NULL); |
2358 | + mtk_set_online(mtk_data_1->modem, FALSE, set_offline_cb, NULL); |
2359 | } |
2360 | |
2361 | static void create_atoms_on_connection(struct ofono_modem *modem) |
2362 | { |
2363 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2364 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2365 | + struct ril_voicecall_driver_data vc_data = { md->ril, modem }; |
2366 | |
2367 | - ril->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK, |
2368 | - RILMODEM, ril->modem); |
2369 | + md->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK, |
2370 | + RILMODEM, md->ril); |
2371 | |
2372 | /* Create interfaces useful for emergency calls */ |
2373 | - ril->voicecall = ofono_voicecall_create(modem, OFONO_RIL_VENDOR_MTK, |
2374 | - MTKMODEM, ril->modem); |
2375 | - ril->callvolume = ofono_call_volume_create(modem, OFONO_RIL_VENDOR_MTK, |
2376 | - RILMODEM, ril->modem); |
2377 | + md->voicecall = ofono_voicecall_create(modem, OFONO_RIL_VENDOR_MTK, |
2378 | + MTKMODEM, &vc_data); |
2379 | + md->callvolume = ofono_call_volume_create(modem, OFONO_RIL_VENDOR_MTK, |
2380 | + RILMODEM, md->ril); |
2381 | } |
2382 | |
2383 | static void remove_atoms_on_disconnection(struct ofono_modem *modem) |
2384 | { |
2385 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2386 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2387 | |
2388 | if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPES_CALL_VOLUME)) |
2389 | - ofono_call_volume_remove(ril->callvolume); |
2390 | - ril->callvolume = NULL; |
2391 | + ofono_call_volume_remove(md->callvolume); |
2392 | + md->callvolume = NULL; |
2393 | if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_VOICECALL)) |
2394 | - ofono_voicecall_remove(ril->voicecall); |
2395 | - ril->voicecall = NULL; |
2396 | + ofono_voicecall_remove(md->voicecall); |
2397 | + md->voicecall = NULL; |
2398 | if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_DEVINFO)) |
2399 | - ofono_devinfo_remove(ril->devinfo); |
2400 | - ril->devinfo = NULL; |
2401 | + ofono_devinfo_remove(md->devinfo); |
2402 | + md->devinfo = NULL; |
2403 | } |
2404 | |
2405 | -static void start_slot(struct mtk_data *ril, struct socket_data *sock, |
2406 | +static void start_slot(struct mtk_data *md, struct socket_data *sock, |
2407 | const char *hex_prefix) |
2408 | { |
2409 | - ofono_info("Physical slot %d in socket %s", ril->slot, sock->path); |
2410 | - |
2411 | - ril->modem = sock->gril; |
2412 | - ril->radio_state = sock->radio_state; |
2413 | - |
2414 | - g_ril_set_slot(ril->modem, ril->slot); |
2415 | + ofono_info("Physical slot %d in socket %s", md->slot, sock->path); |
2416 | + |
2417 | + md->ril = sock->ril; |
2418 | + md->radio_state = sock->radio_state; |
2419 | + |
2420 | + g_ril_set_slot(md->ril, md->slot); |
2421 | |
2422 | if (getenv("OFONO_RIL_TRACE")) |
2423 | - g_ril_set_trace(ril->modem, TRUE); |
2424 | + g_ril_set_trace(md->ril, TRUE); |
2425 | |
2426 | if (getenv("OFONO_RIL_HEX_TRACE")) |
2427 | - g_ril_set_debugf(ril->modem, mtk_debug, (char *) hex_prefix); |
2428 | - |
2429 | - g_ril_set_disconnect_function(ril->modem, socket_disconnected, |
2430 | - ril->ofono_modem); |
2431 | - |
2432 | - g_ril_unregister(sock->gril, sock->radio_state_ev_id); |
2433 | - |
2434 | - g_ril_register(ril->modem, RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
2435 | - mtk_radio_state_changed, ril->ofono_modem); |
2436 | - |
2437 | - mtk_connected(ril->ofono_modem); |
2438 | + g_ril_set_debugf(md->ril, mtk_debug, (char *) hex_prefix); |
2439 | + |
2440 | + g_ril_set_disconnect_function(md->ril, socket_disconnected, |
2441 | + md->modem); |
2442 | + |
2443 | + g_ril_unregister(sock->ril, sock->radio_state_ev_id); |
2444 | + |
2445 | + g_ril_register(md->ril, RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
2446 | + mtk_radio_state_changed, md->modem); |
2447 | + |
2448 | + mtk_connected(md->modem); |
2449 | } |
2450 | |
2451 | static void query_3g_caps_cb(struct ril_msg *message, gpointer user_data) |
2452 | { |
2453 | struct socket_data *sock = user_data; |
2454 | - struct socket_data *sock_for_mtk_0, *sock_for_mtk_1; |
2455 | + struct socket_data *sock_for_md_0, *sock_for_md_1; |
2456 | int slot_3g; |
2457 | |
2458 | if (message->error != RIL_E_SUCCESS) { |
2459 | @@ -873,7 +1141,7 @@ |
2460 | return; |
2461 | } |
2462 | |
2463 | - slot_3g = g_mtk_reply_parse_get_3g_capability(sock->gril, message); |
2464 | + slot_3g = g_mtk_reply_parse_get_3g_capability(sock->ril, message); |
2465 | |
2466 | /* |
2467 | * The socket at sock_slot_0 always connects to the slot with 3G |
2468 | @@ -883,23 +1151,23 @@ |
2469 | * to different physical slots depending on the current configuration. |
2470 | * We want to keep the relationship between the physical slots and |
2471 | * the modem names in DBus (so /ril_0 and /ril_1 always refer to the |
2472 | - * same physical slots), so here we assign the sockets needed by mtk_0 |
2473 | - * and mtk_1 structures to make sure that happens. |
2474 | + * same physical slots), so here we assign the sockets needed by |
2475 | + * mtk_data_0 and mtk_data_1 structures to make sure that happens. |
2476 | */ |
2477 | if (slot_3g == MULTISIM_SLOT_0) { |
2478 | - sock_for_mtk_0 = sock_0; |
2479 | - sock_for_mtk_1 = sock_1; |
2480 | - mtk_0->has_3g = TRUE; |
2481 | - mtk_1->has_3g = FALSE; |
2482 | + sock_for_md_0 = sock_0; |
2483 | + sock_for_md_1 = sock_1; |
2484 | + mtk_data_0->has_3g = TRUE; |
2485 | + mtk_data_1->has_3g = FALSE; |
2486 | } else { |
2487 | - sock_for_mtk_0 = sock_1; |
2488 | - sock_for_mtk_1 = sock_0; |
2489 | - mtk_0->has_3g = FALSE; |
2490 | - mtk_1->has_3g = TRUE; |
2491 | + sock_for_md_0 = sock_1; |
2492 | + sock_for_md_1 = sock_0; |
2493 | + mtk_data_0->has_3g = FALSE; |
2494 | + mtk_data_1->has_3g = TRUE; |
2495 | } |
2496 | |
2497 | - start_slot(mtk_0, sock_for_mtk_0, hex_slot_0); |
2498 | - start_slot(mtk_1, sock_for_mtk_1, hex_slot_1); |
2499 | + start_slot(mtk_data_0, sock_for_md_0, hex_slot_0); |
2500 | + start_slot(mtk_data_1, sock_for_md_1, hex_slot_1); |
2501 | |
2502 | g_free(sock_0); |
2503 | sock_0 = NULL; |
2504 | @@ -909,7 +1177,7 @@ |
2505 | |
2506 | static void query_3g_caps(struct socket_data *sock) |
2507 | { |
2508 | - if (g_ril_send(sock->gril, MTK_RIL_REQUEST_GET_3G_CAPABILITY, NULL, |
2509 | + if (g_ril_send(sock->ril, MTK_RIL_REQUEST_GET_3G_CAPABILITY, NULL, |
2510 | query_3g_caps_cb, sock, NULL) <= 0) |
2511 | ofono_error("%s Error querying 3G capabilities", __func__); |
2512 | } |
2513 | @@ -917,9 +1185,9 @@ |
2514 | static gboolean mtk_connected(gpointer user_data) |
2515 | { |
2516 | struct ofono_modem *modem = (struct ofono_modem *) user_data; |
2517 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2518 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2519 | |
2520 | - ofono_info("[slot %d] CONNECTED", ril->slot); |
2521 | + ofono_info("[slot %d] CONNECTED", md->slot); |
2522 | |
2523 | DBG("calling set_powered(TRUE)"); |
2524 | |
2525 | @@ -928,8 +1196,8 @@ |
2526 | |
2527 | create_atoms_on_connection(modem); |
2528 | |
2529 | - if (ril->pending_cb) |
2530 | - ril->pending_cb(ril->pending_cbd); |
2531 | + if (md->pending_cb) |
2532 | + md->pending_cb(md->pending_cbd); |
2533 | |
2534 | /* Call the function just once */ |
2535 | return FALSE; |
2536 | @@ -938,9 +1206,9 @@ |
2537 | static gboolean reconnect_rild(gpointer user_data) |
2538 | { |
2539 | struct ofono_modem *modem = (struct ofono_modem *) user_data; |
2540 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2541 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2542 | |
2543 | - ofono_info("[slot %d] trying to reconnect", ril->slot); |
2544 | + ofono_info("[slot %d] trying to reconnect", md->slot); |
2545 | |
2546 | if (create_gril(modem) < 0) |
2547 | return TRUE; |
2548 | @@ -954,15 +1222,15 @@ |
2549 | static void socket_disconnected(gpointer user_data) |
2550 | { |
2551 | struct ofono_modem *modem = user_data; |
2552 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2553 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2554 | |
2555 | - DBG("slot %d", ril->slot); |
2556 | + DBG("slot %d", md->slot); |
2557 | |
2558 | /* Atoms use old gril object, remove and recreate later */ |
2559 | remove_atoms_on_disconnection(modem); |
2560 | |
2561 | - g_ril_unref(ril->modem); |
2562 | - ril->modem = NULL; |
2563 | + g_ril_unref(md->ril); |
2564 | + md->ril = NULL; |
2565 | |
2566 | /* Disconnection happened so we do not call failsafe function */ |
2567 | if (not_disconn_cb_id != 0) { |
2568 | @@ -979,13 +1247,13 @@ |
2569 | |
2570 | static int create_gril(struct ofono_modem *modem) |
2571 | { |
2572 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2573 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2574 | struct socket_data *sock; |
2575 | int sock_num; |
2576 | |
2577 | - DBG("slot %d", ril->slot); |
2578 | + DBG("slot %d", md->slot); |
2579 | |
2580 | - if (ril->modem != NULL) |
2581 | + if (md->ril != NULL) |
2582 | return 0; |
2583 | |
2584 | sock = g_try_malloc0(sizeof(*sock)); |
2585 | @@ -994,7 +1262,7 @@ |
2586 | return -ENOMEM; |
2587 | } |
2588 | |
2589 | - if (ril->slot == MULTISIM_SLOT_0) { |
2590 | + if (md->slot == MULTISIM_SLOT_0) { |
2591 | sock_num = SOCKET_NUM_FOR_DBG_0; |
2592 | sock->path = sock_slot_0; |
2593 | } else { |
2594 | @@ -1003,7 +1271,7 @@ |
2595 | } |
2596 | |
2597 | /* Opens the socket to RIL */ |
2598 | - sock->gril = g_ril_new(sock->path, OFONO_RIL_VENDOR_MTK); |
2599 | + sock->ril = g_ril_new(sock->path, OFONO_RIL_VENDOR_MTK); |
2600 | |
2601 | /* |
2602 | * NOTE: Since AT modems open a tty, and then call |
2603 | @@ -1014,11 +1282,11 @@ |
2604 | * abstraction... ( probaby not a bad idea ). |
2605 | */ |
2606 | |
2607 | - if (sock->gril == NULL) { |
2608 | + if (sock->ril == NULL) { |
2609 | ofono_error("g_ril_new() failed to connect to %s!", sock->path); |
2610 | g_free(sock); |
2611 | return -EIO; |
2612 | - } else if (ril->slot == MULTISIM_SLOT_0) { |
2613 | + } else if (md->slot == MULTISIM_SLOT_0) { |
2614 | sock_0 = sock; |
2615 | } else { |
2616 | sock_1 = sock; |
2617 | @@ -1026,22 +1294,25 @@ |
2618 | |
2619 | sock->radio_state = RADIO_STATE_UNAVAILABLE; |
2620 | sock->radio_state_ev_id = |
2621 | - g_ril_register(sock->gril, |
2622 | + g_ril_register(sock->ril, |
2623 | RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
2624 | radio_state_changed, sock); |
2625 | |
2626 | + g_ril_register(sock->ril, MTK_RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED, |
2627 | + reg_suspended, modem); |
2628 | + |
2629 | /* sock_num is negative to avoid confusion with physical slots */ |
2630 | - g_ril_set_slot(sock->gril, sock_num); |
2631 | + g_ril_set_slot(sock->ril, sock_num); |
2632 | |
2633 | - g_ril_set_vendor_print_msg_id_funcs(sock->gril, |
2634 | + g_ril_set_vendor_print_msg_id_funcs(sock->ril, |
2635 | mtk_request_id_to_string, |
2636 | mtk_unsol_request_to_string); |
2637 | |
2638 | if (getenv("OFONO_RIL_TRACE")) |
2639 | - g_ril_set_trace(sock->gril, TRUE); |
2640 | + g_ril_set_trace(sock->ril, TRUE); |
2641 | |
2642 | if (getenv("OFONO_RIL_HEX_TRACE")) |
2643 | - g_ril_set_debugf(sock->gril, mtk_debug, (char *) sock->path); |
2644 | + g_ril_set_debugf(sock->ril, mtk_debug, (char *) sock->path); |
2645 | |
2646 | return 0; |
2647 | } |
2648 | @@ -1049,11 +1320,11 @@ |
2649 | static gboolean connect_rild(gpointer user_data) |
2650 | { |
2651 | struct ofono_modem *modem = (struct ofono_modem *) user_data; |
2652 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2653 | - |
2654 | - ofono_info("Trying to reconnect to slot %d...", ril->slot); |
2655 | - |
2656 | - if (ril->rild_connect_retries++ < RILD_MAX_CONNECT_RETRIES) { |
2657 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2658 | + |
2659 | + ofono_info("Trying to reconnect to slot %d...", md->slot); |
2660 | + |
2661 | + if (md->rild_connect_retries++ < RILD_MAX_CONNECT_RETRIES) { |
2662 | if (create_gril(modem) < 0) |
2663 | return TRUE; |
2664 | } else { |
2665 | @@ -1086,17 +1357,17 @@ |
2666 | |
2667 | static int mtk_disable(struct ofono_modem *modem) |
2668 | { |
2669 | - struct mtk_data *ril = ofono_modem_get_data(modem); |
2670 | + struct mtk_data *md = ofono_modem_get_data(modem); |
2671 | |
2672 | DBG("%p", modem); |
2673 | |
2674 | - if (ril->slot == MULTISIM_SLOT_0 && not_disconn_cb_id != 0) { |
2675 | + if (md->slot == MULTISIM_SLOT_0 && not_disconn_cb_id != 0) { |
2676 | g_source_remove(not_disconn_cb_id); |
2677 | not_disconn_cb_id = 0; |
2678 | } |
2679 | |
2680 | - if (ril->ofono_online) { |
2681 | - ril->ofono_online = FALSE; |
2682 | + if (md->ofono_online) { |
2683 | + md->ofono_online = FALSE; |
2684 | mtk_send_sim_mode(NULL, NULL); |
2685 | } |
2686 | |
2687 | |
2688 | === modified file 'plugins/ril.c' |
2689 | --- plugins/ril.c 2014-11-20 00:03:31 +0000 |
2690 | +++ plugins/ril.c 2015-02-04 00:09:49 +0000 |
2691 | @@ -73,7 +73,7 @@ |
2692 | #define RILD_CMD_SOCKET "/dev/socket/rild" |
2693 | |
2694 | struct ril_data { |
2695 | - GRil *modem; |
2696 | + GRil *ril; |
2697 | enum ofono_ril_vendor vendor; |
2698 | int sim_status_retries; |
2699 | ofono_bool_t connected; |
2700 | @@ -94,27 +94,29 @@ |
2701 | static void ril_radio_state_changed(struct ril_msg *message, gpointer user_data) |
2702 | { |
2703 | struct ofono_modem *modem = user_data; |
2704 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2705 | - int radio_state = g_ril_unsol_parse_radio_state_changed(ril->modem, |
2706 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2707 | + int radio_state = g_ril_unsol_parse_radio_state_changed(rd->ril, |
2708 | message); |
2709 | |
2710 | - if (radio_state != ril->radio_state) { |
2711 | + if (radio_state != rd->radio_state) { |
2712 | |
2713 | - ofono_info("%s: state: %s ril->ofono_online: %d", |
2714 | + ofono_info("%s: state: %s rd->ofono_online: %d", |
2715 | __func__, |
2716 | ril_radio_state_to_string(radio_state), |
2717 | - ril->ofono_online); |
2718 | + rd->ofono_online); |
2719 | |
2720 | - ril->radio_state = radio_state; |
2721 | + rd->radio_state = radio_state; |
2722 | |
2723 | switch (radio_state) { |
2724 | case RADIO_STATE_ON: |
2725 | |
2726 | - if (ril->radio_settings == NULL) |
2727 | - ril->radio_settings = |
2728 | + if (rd->radio_settings == NULL) { |
2729 | + struct ril_radio_settings_driver_data rs_data = |
2730 | + { rd->ril, modem }; |
2731 | + rd->radio_settings = |
2732 | ofono_radio_settings_create(modem, |
2733 | - ril->vendor, RILMODEM, |
2734 | - ril->modem); |
2735 | + rd->vendor, RILMODEM, &rs_data); |
2736 | + } |
2737 | |
2738 | break; |
2739 | |
2740 | @@ -125,7 +127,7 @@ |
2741 | * If radio powers off asychronously, then |
2742 | * assert, and let upstart re-start the stack. |
2743 | */ |
2744 | - if (ril->ofono_online) { |
2745 | + if (rd->ofono_online) { |
2746 | ofono_error("%s: radio self-powered off!", |
2747 | __func__); |
2748 | g_assert(FALSE); |
2749 | @@ -140,24 +142,28 @@ |
2750 | |
2751 | int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor) |
2752 | { |
2753 | - struct ril_data *ril = g_try_new0(struct ril_data, 1); |
2754 | - if (ril == NULL) { |
2755 | + ofono_bool_t lte_cap; |
2756 | + struct ril_data *rd = g_try_new0(struct ril_data, 1); |
2757 | + if (rd == NULL) { |
2758 | errno = ENOMEM; |
2759 | goto error; |
2760 | } |
2761 | |
2762 | DBG(""); |
2763 | |
2764 | - ril->vendor = vendor; |
2765 | - ril->ofono_online = FALSE; |
2766 | - ril->radio_state = RADIO_STATE_OFF; |
2767 | - |
2768 | - ofono_modem_set_data(modem, ril); |
2769 | + rd->vendor = vendor; |
2770 | + rd->ofono_online = FALSE; |
2771 | + rd->radio_state = RADIO_STATE_OFF; |
2772 | + |
2773 | + lte_cap = getenv("OFONO_RIL_RAT_LTE") ? TRUE : FALSE; |
2774 | + ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap); |
2775 | + |
2776 | + ofono_modem_set_data(modem, rd); |
2777 | |
2778 | return 0; |
2779 | |
2780 | error: |
2781 | - g_free(ril); |
2782 | + g_free(rd); |
2783 | |
2784 | return -errno; |
2785 | } |
2786 | @@ -169,57 +175,59 @@ |
2787 | |
2788 | void ril_remove(struct ofono_modem *modem) |
2789 | { |
2790 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2791 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2792 | |
2793 | ofono_modem_set_data(modem, NULL); |
2794 | |
2795 | - if (!ril) |
2796 | + if (!rd) |
2797 | return; |
2798 | |
2799 | - g_ril_unref(ril->modem); |
2800 | + g_ril_unref(rd->ril); |
2801 | |
2802 | - g_free(ril); |
2803 | + g_free(rd); |
2804 | } |
2805 | |
2806 | void ril_pre_sim(struct ofono_modem *modem) |
2807 | { |
2808 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2809 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2810 | + struct ril_voicecall_driver_data vc_data = { rd->ril, modem }; |
2811 | struct ril_sim_data sim_data; |
2812 | |
2813 | DBG(""); |
2814 | |
2815 | - ofono_devinfo_create(modem, ril->vendor, RILMODEM, ril->modem); |
2816 | - ofono_voicecall_create(modem, ril->vendor, RILMODEM, ril->modem); |
2817 | - ofono_call_volume_create(modem, ril->vendor, RILMODEM, ril->modem); |
2818 | + ofono_devinfo_create(modem, rd->vendor, RILMODEM, rd->ril); |
2819 | + ofono_voicecall_create(modem, rd->vendor, RILMODEM, &vc_data); |
2820 | + ofono_call_volume_create(modem, rd->vendor, RILMODEM, rd->ril); |
2821 | |
2822 | - sim_data.gril = ril->modem; |
2823 | + sim_data.gril = rd->ril; |
2824 | sim_data.modem = modem; |
2825 | sim_data.ril_state_watch = NULL; |
2826 | |
2827 | - ril->sim = ofono_sim_create(modem, ril->vendor, RILMODEM, &sim_data); |
2828 | - g_assert(ril->sim != NULL); |
2829 | + rd->sim = ofono_sim_create(modem, rd->vendor, RILMODEM, &sim_data); |
2830 | + g_assert(rd->sim != NULL); |
2831 | } |
2832 | |
2833 | void ril_post_sim(struct ofono_modem *modem) |
2834 | { |
2835 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2836 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2837 | struct ofono_gprs *gprs; |
2838 | struct ofono_gprs_context *gc; |
2839 | struct ofono_message_waiting *mw; |
2840 | + struct ril_gprs_driver_data gprs_data = { rd->ril, modem }; |
2841 | struct ril_gprs_context_data inet_ctx = |
2842 | - { ril->modem, OFONO_GPRS_CONTEXT_TYPE_INTERNET }; |
2843 | + { rd->ril, OFONO_GPRS_CONTEXT_TYPE_INTERNET }; |
2844 | struct ril_gprs_context_data mms_ctx = |
2845 | - { ril->modem, OFONO_GPRS_CONTEXT_TYPE_MMS }; |
2846 | + { rd->ril, OFONO_GPRS_CONTEXT_TYPE_MMS }; |
2847 | |
2848 | /* TODO: this function should setup: |
2849 | * - phonebook |
2850 | * - stk ( SIM toolkit ) |
2851 | * - radio_settings |
2852 | */ |
2853 | - ofono_sms_create(modem, ril->vendor, RILMODEM, ril->modem); |
2854 | + ofono_sms_create(modem, rd->vendor, RILMODEM, rd->ril); |
2855 | |
2856 | - gprs = ofono_gprs_create(modem, ril->vendor, RILMODEM, ril->modem); |
2857 | - gc = ofono_gprs_context_create(modem, ril->vendor, RILMODEM, &inet_ctx); |
2858 | + gprs = ofono_gprs_create(modem, rd->vendor, RILMODEM, &gprs_data); |
2859 | + gc = ofono_gprs_context_create(modem, rd->vendor, RILMODEM, &inet_ctx); |
2860 | |
2861 | if (gc) { |
2862 | ofono_gprs_context_set_type(gc, |
2863 | @@ -227,7 +235,7 @@ |
2864 | ofono_gprs_add_context(gprs, gc); |
2865 | } |
2866 | |
2867 | - gc = ofono_gprs_context_create(modem, ril->vendor, RILMODEM, &mms_ctx); |
2868 | + gc = ofono_gprs_context_create(modem, rd->vendor, RILMODEM, &mms_ctx); |
2869 | |
2870 | if (gc) { |
2871 | ofono_gprs_context_set_type(gc, |
2872 | @@ -239,39 +247,39 @@ |
2873 | if (mw) |
2874 | ofono_message_waiting_register(mw); |
2875 | |
2876 | - ofono_call_forwarding_create(modem, ril->vendor, RILMODEM, ril->modem); |
2877 | + ofono_call_forwarding_create(modem, rd->vendor, RILMODEM, rd->ril); |
2878 | |
2879 | - ofono_phonebook_create(modem, ril->vendor, RILMODEM, modem); |
2880 | + ofono_phonebook_create(modem, rd->vendor, RILMODEM, modem); |
2881 | } |
2882 | |
2883 | void ril_post_online(struct ofono_modem *modem) |
2884 | { |
2885 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2886 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2887 | |
2888 | - ofono_netreg_create(modem, ril->vendor, RILMODEM, ril->modem); |
2889 | - ofono_ussd_create(modem, ril->vendor, RILMODEM, ril->modem); |
2890 | - ofono_call_settings_create(modem, ril->vendor, RILMODEM, ril->modem); |
2891 | - ofono_call_barring_create(modem, ril->vendor, RILMODEM, ril->modem); |
2892 | + ofono_netreg_create(modem, rd->vendor, RILMODEM, rd->ril); |
2893 | + ofono_ussd_create(modem, rd->vendor, RILMODEM, rd->ril); |
2894 | + ofono_call_settings_create(modem, rd->vendor, RILMODEM, rd->ril); |
2895 | + ofono_call_barring_create(modem, rd->vendor, RILMODEM, rd->ril); |
2896 | } |
2897 | |
2898 | static void ril_set_online_cb(struct ril_msg *message, gpointer user_data) |
2899 | { |
2900 | struct cb_data *cbd = user_data; |
2901 | - struct ril_data *ril = cbd->user; |
2902 | + struct ril_data *rd = cbd->user; |
2903 | ofono_modem_online_cb_t cb = cbd->cb; |
2904 | |
2905 | if (message->error == RIL_E_SUCCESS) { |
2906 | - DBG("%s: set_online OK: ril->ofono_online: %d", __func__, |
2907 | - ril->ofono_online); |
2908 | + DBG("%s: set_online OK: rd->ofono_online: %d", __func__, |
2909 | + rd->ofono_online); |
2910 | CALLBACK_WITH_SUCCESS(cb, cbd->data); |
2911 | } else { |
2912 | ofono_error("%s: set_online: %d failed", __func__, |
2913 | - ril->ofono_online); |
2914 | + rd->ofono_online); |
2915 | CALLBACK_WITH_FAILURE(cb, cbd->data); |
2916 | } |
2917 | } |
2918 | |
2919 | -static void ril_send_power(struct ril_data *ril, ofono_bool_t online, |
2920 | +static void ril_send_power(struct ril_data *rd, ofono_bool_t online, |
2921 | GRilResponseFunc func, |
2922 | gpointer user_data) |
2923 | { |
2924 | @@ -287,9 +295,9 @@ |
2925 | |
2926 | DBG("(online = 1, offline = 0)): %i", online); |
2927 | |
2928 | - g_ril_request_power(ril->modem, (const gboolean) online, &rilp); |
2929 | + g_ril_request_power(rd->ril, (const gboolean) online, &rilp); |
2930 | |
2931 | - if (g_ril_send(ril->modem, RIL_REQUEST_RADIO_POWER, &rilp, |
2932 | + if (g_ril_send(rd->ril, RIL_REQUEST_RADIO_POWER, &rilp, |
2933 | func, cbd, notify) == 0 && cbd != NULL) { |
2934 | |
2935 | CALLBACK_WITH_FAILURE(cb, cbd->data); |
2936 | @@ -300,26 +308,26 @@ |
2937 | void ril_set_online(struct ofono_modem *modem, ofono_bool_t online, |
2938 | ofono_modem_online_cb_t callback, void *data) |
2939 | { |
2940 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2941 | - struct cb_data *cbd = cb_data_new(callback, data, ril); |
2942 | - |
2943 | - ril->ofono_online = online; |
2944 | - |
2945 | - DBG("setting ril->ofono_online to: %d", online); |
2946 | - |
2947 | - ril_send_power(ril, online, ril_set_online_cb, cbd); |
2948 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2949 | + struct cb_data *cbd = cb_data_new(callback, data, rd); |
2950 | + |
2951 | + rd->ofono_online = online; |
2952 | + |
2953 | + DBG("setting rd->ofono_online to: %d", online); |
2954 | + |
2955 | + ril_send_power(rd, online, ril_set_online_cb, cbd); |
2956 | } |
2957 | |
2958 | static void ril_connected(struct ril_msg *message, gpointer user_data) |
2959 | { |
2960 | struct ofono_modem *modem = (struct ofono_modem *) user_data; |
2961 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2962 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2963 | |
2964 | - ofono_info("[%d,UNSOL]< %s", g_ril_get_slot(ril->modem), |
2965 | - g_ril_unsol_request_to_string(ril->modem, message->req)); |
2966 | + ofono_info("[%d,UNSOL]< %s", g_ril_get_slot(rd->ril), |
2967 | + g_ril_unsol_request_to_string(rd->ril, message->req)); |
2968 | |
2969 | /* TODO: need a disconnect function to restart things! */ |
2970 | - ril->connected = TRUE; |
2971 | + rd->connected = TRUE; |
2972 | |
2973 | DBG("calling set_powered(TRUE)"); |
2974 | |
2975 | @@ -328,9 +336,9 @@ |
2976 | |
2977 | static int create_gril(struct ofono_modem *modem) |
2978 | { |
2979 | - struct ril_data *ril = ofono_modem_get_data(modem); |
2980 | + struct ril_data *rd = ofono_modem_get_data(modem); |
2981 | |
2982 | - ril->modem = g_ril_new(RILD_CMD_SOCKET, OFONO_RIL_VENDOR_AOSP); |
2983 | + rd->ril = g_ril_new(RILD_CMD_SOCKET, OFONO_RIL_VENDOR_AOSP); |
2984 | |
2985 | /* NOTE: Since AT modems open a tty, and then call |
2986 | * g_at_chat_new(), they're able to return -EIO if |
2987 | @@ -340,21 +348,21 @@ |
2988 | * abstraction... ( probaby not a bad idea ). |
2989 | */ |
2990 | |
2991 | - if (ril->modem == NULL) { |
2992 | + if (rd->ril == NULL) { |
2993 | ofono_error("g_ril_new() failed to create modem!"); |
2994 | return -EIO; |
2995 | } |
2996 | |
2997 | if (getenv("OFONO_RIL_TRACE")) |
2998 | - g_ril_set_trace(ril->modem, TRUE); |
2999 | + g_ril_set_trace(rd->ril, TRUE); |
3000 | |
3001 | if (getenv("OFONO_RIL_HEX_TRACE")) |
3002 | - g_ril_set_debugf(ril->modem, ril_debug, "Device: "); |
3003 | + g_ril_set_debugf(rd->ril, ril_debug, "Device: "); |
3004 | |
3005 | - g_ril_register(ril->modem, RIL_UNSOL_RIL_CONNECTED, |
3006 | + g_ril_register(rd->ril, RIL_UNSOL_RIL_CONNECTED, |
3007 | ril_connected, modem); |
3008 | |
3009 | - g_ril_register(ril->modem, RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
3010 | + g_ril_register(rd->ril, RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, |
3011 | ril_radio_state_changed, modem); |
3012 | |
3013 | return 0; |
3014 | @@ -363,11 +371,11 @@ |
3015 | static gboolean connect_rild(gpointer user_data) |
3016 | { |
3017 | struct ofono_modem *modem = (struct ofono_modem *) user_data; |
3018 | - struct ril_data *ril = ofono_modem_get_data(modem); |
3019 | + struct ril_data *rd = ofono_modem_get_data(modem); |
3020 | |
3021 | ofono_info("Trying to reconnect to rild..."); |
3022 | |
3023 | - if (ril->rild_connect_retries++ < RILD_MAX_CONNECT_RETRIES) { |
3024 | + if (rd->rild_connect_retries++ < RILD_MAX_CONNECT_RETRIES) { |
3025 | if (create_gril(modem) < 0) |
3026 | return TRUE; |
3027 | } else { |
3028 | @@ -394,11 +402,11 @@ |
3029 | |
3030 | int ril_disable(struct ofono_modem *modem) |
3031 | { |
3032 | - struct ril_data *ril = ofono_modem_get_data(modem); |
3033 | + struct ril_data *rd = ofono_modem_get_data(modem); |
3034 | |
3035 | DBG("%p", modem); |
3036 | |
3037 | - ril_send_power(ril, FALSE, NULL, NULL); |
3038 | + ril_send_power(rd, FALSE, NULL, NULL); |
3039 | |
3040 | return 0; |
3041 | } |
3042 | |
3043 | === modified file 'src/gprs.c' |
3044 | --- src/gprs.c 2014-09-04 21:39:42 +0000 |
3045 | +++ src/gprs.c 2015-02-04 00:09:49 +0000 |
3046 | @@ -157,6 +157,8 @@ |
3047 | return "WAP"; |
3048 | case OFONO_GPRS_CONTEXT_TYPE_IMS: |
3049 | return "IMS"; |
3050 | + case OFONO_GPRS_CONTEXT_TYPE_IA: |
3051 | + return "IA"; |
3052 | } |
3053 | |
3054 | return NULL; |
3055 | @@ -176,6 +178,8 @@ |
3056 | return "wap"; |
3057 | case OFONO_GPRS_CONTEXT_TYPE_IMS: |
3058 | return "ims"; |
3059 | + case OFONO_GPRS_CONTEXT_TYPE_IA: |
3060 | + return "ia"; |
3061 | } |
3062 | |
3063 | return NULL; |
3064 | @@ -196,6 +200,9 @@ |
3065 | } else if (g_str_equal(str, "ims")) { |
3066 | *out = OFONO_GPRS_CONTEXT_TYPE_IMS; |
3067 | return TRUE; |
3068 | + } else if (g_str_equal(str, "ia")) { |
3069 | + *out = OFONO_GPRS_CONTEXT_TYPE_IA; |
3070 | + return TRUE; |
3071 | } |
3072 | |
3073 | return FALSE; |
3074 | @@ -1232,8 +1239,9 @@ |
3075 | } |
3076 | |
3077 | if (ctx->type == OFONO_GPRS_CONTEXT_TYPE_ANY || |
3078 | - ctx->type == OFONO_GPRS_CONTEXT_TYPE_WAP || |
3079 | - ctx->type == OFONO_GPRS_CONTEXT_TYPE_IMS) |
3080 | + ctx->type == OFONO_GPRS_CONTEXT_TYPE_WAP || |
3081 | + ctx->type == OFONO_GPRS_CONTEXT_TYPE_IMS || |
3082 | + ctx->type == OFONO_GPRS_CONTEXT_TYPE_IA) |
3083 | return __ofono_error_invalid_args(msg); |
3084 | |
3085 | if (!strcmp(property, "MessageProxy")) { |
3086 | @@ -2973,6 +2981,50 @@ |
3087 | __ofono_gprs_provision_free_settings(settings, count); |
3088 | } |
3089 | |
3090 | +static struct pri_context *gprs_context_for_ia(struct ofono_gprs *gprs) |
3091 | +{ |
3092 | + GSList *l; |
3093 | + |
3094 | + for (l = gprs->contexts; l; l = l->next) { |
3095 | + struct pri_context *ctx = l->data; |
3096 | + |
3097 | + if (ctx->type == OFONO_GPRS_CONTEXT_TYPE_IA) |
3098 | + return ctx; |
3099 | + } |
3100 | + |
3101 | + for (l = gprs->contexts; l; l = l->next) { |
3102 | + struct pri_context *ctx = l->data; |
3103 | + |
3104 | + if (ctx->type == OFONO_GPRS_CONTEXT_TYPE_INTERNET) |
3105 | + return ctx; |
3106 | + } |
3107 | + |
3108 | + return gprs->contexts->data; |
3109 | +} |
3110 | + |
3111 | +static void set_ia_apn_cb(const struct ofono_error *error, void *data) |
3112 | +{ |
3113 | + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) |
3114 | + ofono_error("Could not set IA APN"); |
3115 | +} |
3116 | + |
3117 | +static void set_ia_apn(struct ofono_gprs *gprs) |
3118 | +{ |
3119 | + struct pri_context *ctx = gprs_context_for_ia(gprs); |
3120 | + struct ofono_gprs_primary_context *ofono_ctx = &ctx->context; |
3121 | + char mccmnc[OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1]; |
3122 | + const char *mcc = ofono_sim_get_mcc(gprs->sim); |
3123 | + const char *mnc = ofono_sim_get_mnc(gprs->sim); |
3124 | + |
3125 | + strcpy(mccmnc, mcc); |
3126 | + strcpy(mccmnc + strlen(mcc), mnc); |
3127 | + |
3128 | + gprs->driver->set_ia_apn(gprs, ofono_ctx->apn, ofono_ctx->proto, |
3129 | + ofono_ctx->username, |
3130 | + ofono_ctx->password, mccmnc, |
3131 | + set_ia_apn_cb, gprs); |
3132 | +} |
3133 | + |
3134 | static void ofono_gprs_finish_register(struct ofono_gprs *gprs) |
3135 | { |
3136 | DBusConnection *conn = ofono_dbus_get_connection(); |
3137 | @@ -2982,6 +3034,9 @@ |
3138 | if (gprs->contexts == NULL) /* Automatic provisioning failed */ |
3139 | add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET); |
3140 | |
3141 | + if (gprs->driver->set_ia_apn) |
3142 | + set_ia_apn(gprs); |
3143 | + |
3144 | if (!g_dbus_register_interface(conn, path, |
3145 | OFONO_CONNECTION_MANAGER_INTERFACE, |
3146 | manager_methods, manager_signals, NULL, |
3147 | |
3148 | === modified file 'src/modem.c' |
3149 | --- src/modem.c 2014-09-16 08:02:58 +0000 |
3150 | +++ src/modem.c 2015-02-04 00:09:49 +0000 |
3151 | @@ -1664,7 +1664,8 @@ |
3152 | DBG("modem %p property %s", modem, name); |
3153 | |
3154 | if (type != PROPERTY_TYPE_STRING && |
3155 | - type != PROPERTY_TYPE_INTEGER) |
3156 | + type != PROPERTY_TYPE_INTEGER && |
3157 | + type != PROPERTY_TYPE_BOOLEAN) |
3158 | return -EINVAL; |
3159 | |
3160 | property = g_try_new0(struct modem_property, 1); |
3161 | |
3162 | === added directory 'test/rilmodem/sim' |
3163 | === added file 'test/rilmodem/sim/simtestutil.py' |
3164 | --- test/rilmodem/sim/simtestutil.py 1970-01-01 00:00:00 +0000 |
3165 | +++ test/rilmodem/sim/simtestutil.py 2015-02-04 00:09:49 +0000 |
3166 | @@ -0,0 +1,391 @@ |
3167 | +#!/usr/bin/python3 |
3168 | +# |
3169 | +# oFono - Open Source Telephony - RIL Modem test |
3170 | +# |
3171 | +# Copyright (C) 2014 Canonical Ltd. |
3172 | +# |
3173 | +# This program is free software; you can redistribute it and/or modify |
3174 | +# it under the terms of the GNU General Public License version 2 as |
3175 | +# published by the Free Software Foundation. |
3176 | +# |
3177 | +# This program is distributed in the hope that it will be useful, |
3178 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3179 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3180 | +# GNU General Public License for more details. |
3181 | +# |
3182 | +# You should have received a copy of the GNU General Public License |
3183 | +# along with this program; if not, write to the Free Software |
3184 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3185 | +# |
3186 | +# This test ensures that basic modem information is available |
3187 | +# when the modem is online and has a valid, unlocked SIM present. |
3188 | + |
3189 | +"""SIM Test utility functions. |
3190 | + |
3191 | +This module contains functions used by the SIM functional test scripts. |
3192 | + |
3193 | +ToDo: |
3194 | + * Add check for optional SimManager 'PreferredLanguage' property |
3195 | +""" |
3196 | + |
3197 | +import argparse |
3198 | +import dbus |
3199 | +import subprocess |
3200 | +import sys |
3201 | +import unittest |
3202 | + |
3203 | +emergency_numbers = ["08", "000", "999", "110", "112", "911", "118", "119"] |
3204 | + |
3205 | +# Note - rilmodem doesn't remove 'rat' when modem is offlined; |
3206 | +# as this is different behavior than when booted offline, "rat" |
3207 | +# is not present in either of the following offline lists |
3208 | + |
3209 | +no_sim_offline_features = [ "sim" ] |
3210 | +sim_offline_features = [ "sim", "gprs", "sms" ] |
3211 | + |
3212 | +no_sim_online_features = [ "rat", "sim" ] |
3213 | +sim_online_features = [ "gprs", "ussd", "net", "sms", "rat", "sim" ] |
3214 | + |
3215 | +no_sim_offline_ifaces = [ "org.ofono.CallVolume", |
3216 | + "org.ofono.VoiceCallManager" ] |
3217 | + |
3218 | +# LP: #1399756; RadioSettings isn't properly removed from |
3219 | +# 'Interfaces' ( and correspondingly "rat" from 'Features' ) |
3220 | +# when rilmodem is set offline. Neither are present if the |
3221 | +# device boots with modems offline. That's why it's not |
3222 | +# included in this list. |
3223 | +sim_offline_ifaces = [ "org.ofono.ConnectionManager", |
3224 | + "org.ofono.Phonebook", |
3225 | + "org.ofono.CallForwarding", |
3226 | + "org.ofono.SmartMessaging", |
3227 | + "org.ofono.PushNotification", |
3228 | + "org.ofono.MessageManager", |
3229 | + "org.ofono.NetworkTime", |
3230 | + "org.ofono.MessageWaiting", |
3231 | + "org.ofono.SimManager", |
3232 | + "org.ofono.CallVolume", |
3233 | + "org.ofono.VoiceCallManager" ] |
3234 | + |
3235 | +no_sim_online_ifaces = [ "org.ofono.RadioSettings", |
3236 | + "org.ofono.SimManager", |
3237 | + "org.ofono.CallVolume", |
3238 | + "org.ofono.VoiceCallManager" ] |
3239 | + |
3240 | +sim_online_ifaces = [ "org.ofono.ConnectionManager", |
3241 | + "org.ofono.CallBarring", |
3242 | + "org.ofono.CallSettings", |
3243 | + "org.ofono.SupplementaryServices", |
3244 | + "org.ofono.NetworkRegistration", |
3245 | + "org.ofono.Phonebook", |
3246 | + "org.ofono.CallForwarding", |
3247 | + "org.ofono.SmartMessaging", |
3248 | + "org.ofono.PushNotification", |
3249 | + "org.ofono.MessageManager", |
3250 | + "org.ofono.NetworkTime", |
3251 | + "org.ofono.MessageWaiting", |
3252 | + "org.ofono.RadioSettings", |
3253 | + "org.ofono.SimManager", |
3254 | + "org.ofono.CallVolume", |
3255 | + "org.ofono.VoiceCallManager" ] |
3256 | + |
3257 | +modem_properties = [ "Revision", "Serial", "Model", |
3258 | + "Features", "Online", "Type", |
3259 | + "Interfaces", "Emergency", "Manufacturer", |
3260 | + "Powered", "Lockdown" ] |
3261 | + |
3262 | +sim_properties = [ "Present", "FixedDialing", "BarredDialing", |
3263 | + "SubscriberNumbers", "LockedPins", |
3264 | + "PinRequired", "Retries" ] |
3265 | + |
3266 | +def get_product(): |
3267 | + product_bytes = subprocess.check_output(["getprop", "ro.build.product"]) |
3268 | + return product_bytes.decode('utf-8').strip('\n') |
3269 | + |
3270 | +def sim_unittest_main(args): |
3271 | + |
3272 | + if args.debug: |
3273 | + print(args) |
3274 | + print(sys.argv[0]) |
3275 | + |
3276 | + if len(args.unittest_args) == 0: |
3277 | + args.unittest_args.append("sys.argv[0]") |
3278 | + unittest.main(argv=args.unittest_args) |
3279 | + else: |
3280 | + unittest.main() |
3281 | + |
3282 | +def parse_args(parser=None): |
3283 | + |
3284 | + if parser is None: |
3285 | + parser = argparse.ArgumentParser() |
3286 | + |
3287 | + parser.add_argument("-d", |
3288 | + "--debug", |
3289 | + dest="debug", |
3290 | + action="store_true", |
3291 | + help="""Enables debug verbosity""", |
3292 | + ) |
3293 | + |
3294 | + parser.add_argument("-m", |
3295 | + "--modem", |
3296 | + dest="modem", |
3297 | + action="store", |
3298 | + help="""Specifies modem path""", |
3299 | + ) |
3300 | + |
3301 | + parser.add_argument("unittest_args", nargs="*") |
3302 | + |
3303 | + parser.set_defaults(modem="") |
3304 | + |
3305 | + args = parser.parse_args() |
3306 | + |
3307 | + return args |
3308 | + |
3309 | +def parse_lock_test_args(): |
3310 | + |
3311 | + parser = argparse.ArgumentParser() |
3312 | + |
3313 | + group = parser.add_mutually_exclusive_group(required=True) |
3314 | + |
3315 | + group.add_argument("--pin", |
3316 | + dest="pin", |
3317 | + help="""Specify the SIM PIN code""", |
3318 | + metavar="<PIN Code>", |
3319 | + ) |
3320 | + |
3321 | + group.add_argument("--continue", |
3322 | + dest="cont", |
3323 | + action="store_true", |
3324 | + help="""Continue verification after |
3325 | + a reboot""", |
3326 | + ) |
3327 | + |
3328 | + return parse_args(parser) |
3329 | + |
3330 | +class SimTestCase(unittest.TestCase): |
3331 | + |
3332 | + def setUp(self): |
3333 | + self.bus = dbus.SystemBus() |
3334 | + |
3335 | + self.manager = dbus.Interface(self.bus.get_object('org.ofono', |
3336 | + '/'), |
3337 | + 'org.ofono.Manager') |
3338 | + self.modems = self.manager.GetModems() |
3339 | + |
3340 | + def get_simmanager(self, path): |
3341 | + return dbus.Interface(self.bus.get_object('org.ofono', |
3342 | + path), |
3343 | + 'org.ofono.SimManager') |
3344 | + def if_supports_sim_offline(self): |
3345 | + if self.product != "krillin": |
3346 | + return True |
3347 | + else: |
3348 | + return False |
3349 | + |
3350 | + def check_no_sim_present(self, path): |
3351 | + |
3352 | + properties = self.get_simmanager(path).GetProperties() |
3353 | + |
3354 | + return (properties["Present"] != 1) |
3355 | + |
3356 | + def validate_modem_properties(self, path, test_online, test_sims): |
3357 | + |
3358 | + modem = dbus.Interface(self.bus.get_object('org.ofono', path), |
3359 | + 'org.ofono.Modem') |
3360 | + properties = modem.GetProperties() |
3361 | + |
3362 | + if self.args.debug == True: |
3363 | + print("[ %s ]" % path) |
3364 | + |
3365 | + for property in modem_properties: |
3366 | + self.assertTrue(property in properties) |
3367 | + |
3368 | + self.assertTrue(properties["Revision"] != "ValueError") |
3369 | + self.assertTrue(properties["Type"] == "hardware") |
3370 | + self.assertTrue(properties["Manufacturer"] == "Fake Manufacturer") |
3371 | + self.assertTrue(properties["Model"] == "Fake Modem Model") |
3372 | + self.assertTrue(properties["Powered"] == 1) |
3373 | + self.assertTrue(properties["Emergency"] == 0) |
3374 | + self.assertTrue(properties["Lockdown"] == 0) |
3375 | + |
3376 | + # emulator == "goldfish" |
3377 | + # |
3378 | + if self.product == "goldfish": |
3379 | + self.assertTrue(properties["Serial"] == "000000000000000") |
3380 | + else: |
3381 | + self.assertTrue(properties["Serial"] != "") |
3382 | + |
3383 | + self.assertTrue(properties["Online"] == test_online) |
3384 | + |
3385 | + # test features |
3386 | + features = properties["Features"] |
3387 | + |
3388 | + if test_online: |
3389 | + if test_sims: |
3390 | + check_features = sim_online_features[:] |
3391 | + else: |
3392 | + check_features = no_sim_online_features[:] |
3393 | + else: |
3394 | + if self.product == "krillin": |
3395 | + check_features = [] |
3396 | + else: |
3397 | + if test_sims: |
3398 | + check_features = sim_offline_features[:] |
3399 | + else: |
3400 | + check_features = no_sim_offline_features[:] |
3401 | + |
3402 | + for feature in check_features: |
3403 | + if self.args.debug: |
3404 | + print(feature) |
3405 | + |
3406 | + self.assertTrue(feature in features) |
3407 | + |
3408 | + # test interfaces |
3409 | + ifaces = properties["Interfaces"] |
3410 | + |
3411 | + if test_online: |
3412 | + if test_sims: |
3413 | + check_ifaces = sim_online_ifaces[:] |
3414 | + |
3415 | + if self.product == "krillin": |
3416 | + check_ifaces.append( |
3417 | + "org.ofono.MtkSettings") |
3418 | + else: |
3419 | + check_ifaces = no_sim_online_ifaces[:] |
3420 | + |
3421 | + # LP: #1399746; NetworkTime is only |
3422 | + # available on krillin in this state, |
3423 | + # and shouldn't be without a SIM present |
3424 | + |
3425 | + if self.product == "krillin": |
3426 | + check_ifaces.append( |
3427 | + "org.ofono.NetworkTime") |
3428 | + check_ifaces.append( |
3429 | + "org.ofono.MtkSettings") |
3430 | + else: |
3431 | + |
3432 | + # krillin no diff between sim/no-SIM when offline |
3433 | + if self.product == "krillin": |
3434 | + check_ifaces = no_sim_offline_ifaces[:] |
3435 | + check_ifaces.append("org.ofono.NetworkTime") |
3436 | + else: |
3437 | + if test_sims: |
3438 | + check_ifaces = sim_offline_ifaces[:] |
3439 | + else: |
3440 | + check_ifaces = no_sim_offline_ifaces[:] |
3441 | + check_ifaces.append("org.ofono.SimManager") |
3442 | + |
3443 | + for iface in check_ifaces: |
3444 | + if self.args.debug: |
3445 | + print(iface) |
3446 | + |
3447 | + self.assertTrue(iface in ifaces) |
3448 | + |
3449 | + return modem |
3450 | + |
3451 | + def validate_call_volume_properties(self, path): |
3452 | + |
3453 | + call_volume = dbus.Interface(self.bus.get_object('org.ofono', |
3454 | + path), |
3455 | + 'org.ofono.CallVolume') |
3456 | + properties = call_volume.GetProperties() |
3457 | + keys = list(properties.keys()) |
3458 | + |
3459 | + self.assertTrue(properties["MicrophoneVolume"] == 0) |
3460 | + self.assertTrue(properties["SpeakerVolume"] == 0) |
3461 | + |
3462 | + # The value of 'Muted' differs on mako/krillin: see |
3463 | + # bug for details: |
3464 | + # |
3465 | + # https://bugs.launchpad.net/ubuntu/+source/ofono/+bug/1396317 |
3466 | + |
3467 | + if self.product == "krillin": |
3468 | + self.assertTrue(properties["Muted"] == 0) |
3469 | + else: |
3470 | + self.assertTrue(properties["Muted"] == 1) |
3471 | + |
3472 | + self.assertTrue(keys.index("Muted") != "ValueError") |
3473 | + |
3474 | + def validate_emergency_numbers(self, path): |
3475 | + # valid VoiceCallManager properties |
3476 | + voice = dbus.Interface(self.bus.get_object('org.ofono', path), |
3477 | + 'org.ofono.VoiceCallManager') |
3478 | + |
3479 | + properties = voice.GetProperties() |
3480 | + keys = list(properties.keys()) |
3481 | + |
3482 | + self.assertTrue(keys.index("EmergencyNumbers") != "ValueError") |
3483 | + |
3484 | + numbers = properties["EmergencyNumbers"] |
3485 | + |
3486 | + if self.args.debug: |
3487 | + print("%s" % numbers) |
3488 | + |
3489 | + for number in numbers: |
3490 | + self.assertTrue(number in emergency_numbers) |
3491 | + |
3492 | + def validate_sim_properties(self, path, mnc="", mcc="", subs=""): |
3493 | + |
3494 | + # valid SimManager properties |
3495 | + properties = self.get_simmanager(path).GetProperties() |
3496 | + keys = list(properties.keys()) |
3497 | + |
3498 | + for property in sim_properties: |
3499 | + self.assertTrue(property in keys) |
3500 | + |
3501 | + self.assertTrue(properties["Present"] == 1) |
3502 | + |
3503 | + # Don't validate "Retries"; it's only populated |
3504 | + # after failed PIN/PUK unlock attempts |
3505 | + |
3506 | + self.assertTrue(properties["BarredDialing"] == 0) |
3507 | + self.assertTrue(properties["FixedDialing"] == 0) |
3508 | + |
3509 | + # emulator == "goldfish" |
3510 | + if self.product == "goldfish": |
3511 | + self.assertTrue(properties["SubscriberNumbers"][0] |
3512 | + == "15555215554") |
3513 | + |
3514 | + self.assertTrue(properties["PinRequired"] == "none") |
3515 | + |
3516 | + # validate optional properties |
3517 | + |
3518 | + if "CardIdentifier" in keys and self.product == "goldfish": |
3519 | + self.assertTrue(properties["CardIdentifier"] |
3520 | + == "89014103211118510720") |
3521 | + |
3522 | + if "MobileCountryCode" in keys: |
3523 | + if self.product == "goldfish": |
3524 | + self.assertTrue(properties["MobileCountryCode"] |
3525 | + == "310") |
3526 | + elif mcc != "": |
3527 | + self.assertTrue(properties["MobileCountryCode"] |
3528 | + == mcc) |
3529 | + |
3530 | + if "MobileNetworkCode" in keys: |
3531 | + if self.product == "goldfish": |
3532 | + self.assertTrue(properties["MobileNetworkCode"] |
3533 | + == "260") |
3534 | + elif mnc != "": |
3535 | + self.assertTrue(properties["MobileNetworkCode"] |
3536 | + == mnc) |
3537 | + |
3538 | + if "SubscriberIdentity" in keys: |
3539 | + if self.product == "goldfish": |
3540 | + self.assertTrue(properties["SubscriberIdentity"] |
3541 | + == "310260000000000") |
3542 | + elif subs != "": |
3543 | + self.assertTrue(properties["SubscriberIdentity"] |
3544 | + == subs) |
3545 | + |
3546 | + def main(self, args): |
3547 | + self.args = args |
3548 | + self.product = get_product() |
3549 | + |
3550 | + if args.debug: |
3551 | + print ("ro.build.product: %s" % self.product) |
3552 | + |
3553 | + if len(args.modem) > 0: |
3554 | + self.validate_modem(args.modem) |
3555 | + else: |
3556 | + for modem in self.modems: |
3557 | + self.validate_modem(modem[0]) |
3558 | |
3559 | === added file 'test/rilmodem/sim/test-no-sims-offline' |
3560 | --- test/rilmodem/sim/test-no-sims-offline 1970-01-01 00:00:00 +0000 |
3561 | +++ test/rilmodem/sim/test-no-sims-offline 2015-02-04 00:09:49 +0000 |
3562 | @@ -0,0 +1,82 @@ |
3563 | +#!/usr/bin/python3 |
3564 | +# |
3565 | +# oFono - Open Source Telephony - RIL Modem test |
3566 | +# |
3567 | +# Copyright (C) 2014 Canonical Ltd. |
3568 | +# |
3569 | +# This program is free software; you can redistribute it and/or modify |
3570 | +# it under the terms of the GNU General Public License version 2 as |
3571 | +# published by the Free Software Foundation. |
3572 | +# |
3573 | +# This program is distributed in the hope that it will be useful, |
3574 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3575 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3576 | +# GNU General Public License for more details. |
3577 | +# |
3578 | +# You should have received a copy of the GNU General Public License |
3579 | +# along with this program; if not, write to the Free Software |
3580 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3581 | +# |
3582 | +# This test ensures that basic modem information is available |
3583 | +# when the modem is online and has a valid, unlocked SIM present. |
3584 | + |
3585 | +"""Tests no SIM(s) and modem(s) offline. |
3586 | + |
3587 | +This module contains a functional test which checks a running |
3588 | +ofono/rilmodem/mtkmodem instance to ensure that the correct |
3589 | +DBus properties are exported when no SIM(s) are inserted AND |
3590 | +the corresponding modem(s) are offline. As such it validates |
3591 | +the properties of the following interfaces: |
3592 | + |
3593 | + * org.ofono.Modem |
3594 | + * org.ofono.SimManager ( on supported hw ) |
3595 | + * org.ofono.VoiceCallManager ( EmergencyNumbers ) |
3596 | + * org.ofono.CallVolume |
3597 | + |
3598 | +NOTE - this test by default verifies all modems present a device. |
3599 | +If the device is multi-SIM and not all slots have unlocked SIMs, |
3600 | +then please use the -m to verify a specific modem. |
3601 | + |
3602 | +SETUP: |
3603 | + |
3604 | + * Power off the phone |
3605 | + |
3606 | + * Remove any SIMs |
3607 | + |
3608 | + * Power on the phone |
3609 | + |
3610 | + * Enable FlightMode from System Setttings ( or net indicator ) |
3611 | + |
3612 | + * Run this script |
3613 | + |
3614 | + * [Optional] Reboot the phone and re-run script |
3615 | + |
3616 | + * Disable FlightMode |
3617 | + |
3618 | +ToDo: |
3619 | + * If run on the emulator, make this script use console |
3620 | + commands to configure the modem(s) for the required |
3621 | + conditions ( ie. no SIM(s), online ) |
3622 | +""" |
3623 | + |
3624 | +from simtestutil import * |
3625 | + |
3626 | +class TestNoSimsOffline(SimTestCase): |
3627 | + |
3628 | + def validate_modem(self, path): |
3629 | + self.validate_modem_properties(path, False, False) |
3630 | + |
3631 | + # krillin doesn't expose SimManager when offline |
3632 | + if (self.product != "krillin"): |
3633 | + self.assertTrue(self.check_no_sim_present(path)) |
3634 | + |
3635 | + self.validate_emergency_numbers(path) |
3636 | + self.validate_call_volume_properties(path) |
3637 | + |
3638 | + def test_main(self): |
3639 | + self.main(args) |
3640 | + |
3641 | +if __name__ == "__main__": |
3642 | + args = parse_args() |
3643 | + |
3644 | + sim_unittest_main(args) |
3645 | |
3646 | === added file 'test/rilmodem/sim/test-no-sims-online' |
3647 | --- test/rilmodem/sim/test-no-sims-online 1970-01-01 00:00:00 +0000 |
3648 | +++ test/rilmodem/sim/test-no-sims-online 2015-02-04 00:09:49 +0000 |
3649 | @@ -0,0 +1,74 @@ |
3650 | +#!/usr/bin/python3 |
3651 | +# |
3652 | +# oFono - Open Source Telephony - RIL Modem test |
3653 | +# |
3654 | +# Copyright (C) 2014 Canonical Ltd. |
3655 | +# |
3656 | +# This program is free software; you can redistribute it and/or modify |
3657 | +# it under the terms of the GNU General Public License version 2 as |
3658 | +# published by the Free Software Foundation. |
3659 | +# |
3660 | +# This program is distributed in the hope that it will be useful, |
3661 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3662 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3663 | +# GNU General Public License for more details. |
3664 | +# |
3665 | +# You should have received a copy of the GNU General Public License |
3666 | +# along with this program; if not, write to the Free Software |
3667 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3668 | +# |
3669 | +# This test ensures that basic modem information is available |
3670 | +# when the modem is online and has a valid, unlocked SIM present. |
3671 | + |
3672 | +"""Tests no SIM(s) and modem(s) online. |
3673 | + |
3674 | +This module contains a functional test which checks a running |
3675 | +ofono/rilmodem/mtkmodem instance to ensure that the correct |
3676 | +DBus properties are exported when no SIM(s) are inserted AND |
3677 | +the corresponding modem(s) are online. As such it validates |
3678 | +the properties of the following interfaces: |
3679 | + |
3680 | + * org.ofono.Modem |
3681 | + * org.ofono.SimManager |
3682 | + * org.ofono.VoiceCallManager ( EmergencyNumbers ) |
3683 | + * org.ofono.CallVolume |
3684 | + |
3685 | +NOTE - this test by default verifies all modems present a device. |
3686 | +If the device is multi-SIM and not all slots have unlocked SIMs, |
3687 | +then please use the -m to verify a specific modem. |
3688 | + |
3689 | +SETUP: |
3690 | + |
3691 | + * Power off the phone |
3692 | + |
3693 | + * Remove any SIMs |
3694 | + |
3695 | + * Power on the phone |
3696 | + |
3697 | + * Run this script |
3698 | + |
3699 | + * [Optional] Reboot the phone and re-run the script |
3700 | + |
3701 | +ToDo: |
3702 | + * If run on the emulator, make this script use console |
3703 | + commands to configure the modem(s) for the required |
3704 | + conditions ( ie. no SIM(s), online ) |
3705 | +""" |
3706 | + |
3707 | +from simtestutil import * |
3708 | + |
3709 | +class TestNoSimsOnline(SimTestCase): |
3710 | + |
3711 | + def validate_modem(self, path): |
3712 | + self.validate_modem_properties(path, True, False) |
3713 | + self.assertTrue(self.check_no_sim_present(path)) |
3714 | + self.validate_emergency_numbers(path) |
3715 | + self.validate_call_volume_properties(path) |
3716 | + |
3717 | + def test_main(self): |
3718 | + self.main(args) |
3719 | + |
3720 | +if __name__ == "__main__": |
3721 | + args = parse_args() |
3722 | + |
3723 | + sim_unittest_main(args) |
3724 | |
3725 | === added file 'test/rilmodem/sim/test-sim-change-pin' |
3726 | --- test/rilmodem/sim/test-sim-change-pin 1970-01-01 00:00:00 +0000 |
3727 | +++ test/rilmodem/sim/test-sim-change-pin 2015-02-04 00:09:49 +0000 |
3728 | @@ -0,0 +1,128 @@ |
3729 | +#!/usr/bin/python3 |
3730 | +# |
3731 | +# oFono - Open Source Telephony - RIL Modem test |
3732 | +# |
3733 | +# Copyright (C) 2014 Canonical Ltd. |
3734 | +# |
3735 | +# This program is free software; you can redistribute it and/or modify |
3736 | +# it under the terms of the GNU General Public License version 2 as |
3737 | +# published by the Free Software Foundation. |
3738 | +# |
3739 | +# This program is distributed in the hope that it will be useful, |
3740 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3741 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3742 | +# GNU General Public License for more details. |
3743 | +# |
3744 | +# You should have received a copy of the GNU General Public License |
3745 | +# along with this program; if not, write to the Free Software |
3746 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3747 | +# |
3748 | +# This test ensures that basic modem information is available |
3749 | +# when the modem is online and has a valid, unlocked SIM present. |
3750 | + |
3751 | +"""Tests the abilty to change a SIM PIN. |
3752 | + |
3753 | +This module contains a functional test which checks an |
3754 | +ofono/rilmodem/mtkmodem instance to ensure that the a |
3755 | +SIM PIN can be changed. |
3756 | + |
3757 | +NOTE - this test by default tries to change the PIN of a |
3758 | +single SIM. If the device is multi-SIM, the first modem |
3759 | +will be used by default. The -m argument can be used to |
3760 | +specify the second modem if needed. |
3761 | + |
3762 | +Requirements: |
3763 | + |
3764 | + * a SIM with PIN-locking enabled |
3765 | + |
3766 | + * the current PIN code for the SIM |
3767 | + |
3768 | +Setup: |
3769 | + |
3770 | + * Ensure that FlightMode is NOT enabled |
3771 | + |
3772 | + * Ensure that at least one SIM with PIN-locking |
3773 | + enabled is inserted in the phone AND STILL LOCKED! |
3774 | + ( ie. the PIN hasn't been entered yet ) |
3775 | + |
3776 | + * Run this script |
3777 | + |
3778 | +Notes: |
3779 | + |
3780 | +On some phones, this script will enter the SIM PIN |
3781 | +to unlock it before changing the PIN. |
3782 | + |
3783 | +ToDo: |
3784 | + * If run on the emulator, make this script use console |
3785 | + commands to configure the modem(s) for the required |
3786 | + conditions ( ie. no SIM(s), online ) |
3787 | +""" |
3788 | + |
3789 | +import simtestutil |
3790 | + |
3791 | +from simtestutil import * |
3792 | + |
3793 | +def parse_test_args(): |
3794 | + |
3795 | + parser = argparse.ArgumentParser() |
3796 | + |
3797 | + parser.add_argument("--old-pin", |
3798 | + dest="old_pin", |
3799 | + help="""Specify the SIM PIN code""", |
3800 | + required="yes", |
3801 | + ) |
3802 | + |
3803 | + parser.add_argument("--new-pin", |
3804 | + dest="new_pin", |
3805 | + help="""Specify the new SIM PIN code""", |
3806 | + required="yes" |
3807 | + ) |
3808 | + |
3809 | + return parse_args(parser) |
3810 | + |
3811 | +class TestSimChangePin(SimTestCase): |
3812 | + |
3813 | + def change_pin_lock(self, path): |
3814 | + |
3815 | + if self.args.debug: |
3816 | + print("change_pin_lock called, " |
3817 | + "pin= {} " |
3818 | + "new_pin: {}".format(self.args.old_pin, |
3819 | + self.args.new_pin)) |
3820 | + |
3821 | + simmanager = self.get_simmanager(path) |
3822 | + properties = simmanager.GetProperties() |
3823 | + |
3824 | + locked_pins = properties["LockedPins"] |
3825 | + self.assertTrue(len(locked_pins) == 1) |
3826 | + self.assertTrue(locked_pins[0] == "pin") |
3827 | + |
3828 | + if self.product == "krillin" and properties["PinRequired"] == "pin": |
3829 | + simmanager.EnterPin("pin", self.args.old_pin) |
3830 | + |
3831 | + simmanager.ChangePin("pin", self.args.old_pin, |
3832 | + self.args.new_pin) |
3833 | + |
3834 | + simmanager.UnlockPin("pin", self.args.new_pin) |
3835 | + simmanager.LockPin("pin", self.args.new_pin) |
3836 | + |
3837 | + properties = simmanager.GetProperties() |
3838 | + |
3839 | + locked_pins = properties["LockedPins"] |
3840 | + self.assertTrue(len(locked_pins) == 1) |
3841 | + self.assertTrue(locked_pins[0] == "pin") |
3842 | + |
3843 | + self.assertTrue(properties["PinRequired"] == "none") |
3844 | + |
3845 | + def validate_modem(self, path): |
3846 | + |
3847 | + self.change_pin_lock(path) |
3848 | + |
3849 | + def test_main(self): |
3850 | + self.main(args) |
3851 | + |
3852 | +if __name__ == "__main__": |
3853 | + args = parse_test_args() |
3854 | + |
3855 | + sim_unittest_main(args) |
3856 | + |
3857 | |
3858 | === added file 'test/rilmodem/sim/test-sim-disable-pin-lock' |
3859 | --- test/rilmodem/sim/test-sim-disable-pin-lock 1970-01-01 00:00:00 +0000 |
3860 | +++ test/rilmodem/sim/test-sim-disable-pin-lock 2015-02-04 00:09:49 +0000 |
3861 | @@ -0,0 +1,106 @@ |
3862 | +#!/usr/bin/python3 |
3863 | +# |
3864 | +# oFono - Open Source Telephony - RIL Modem test |
3865 | +# |
3866 | +# Copyright (C) 2014 Canonical Ltd. |
3867 | +# |
3868 | +# This program is free software; you can redistribute it and/or modify |
3869 | +# it under the terms of the GNU General Public License version 2 as |
3870 | +# published by the Free Software Foundation. |
3871 | +# |
3872 | +# This program is distributed in the hope that it will be useful, |
3873 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3874 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3875 | +# GNU General Public License for more details. |
3876 | +# |
3877 | +# You should have received a copy of the GNU General Public License |
3878 | +# along with this program; if not, write to the Free Software |
3879 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3880 | +# |
3881 | +# This test ensures that basic modem information is available |
3882 | +# when the modem is online and has a valid, unlocked SIM present. |
3883 | + |
3884 | +"""Tests disabling PIN locking for a SIM. |
3885 | + |
3886 | +This module contains a functional test which checks an |
3887 | +ofono/rilmodem/mtkmodem instance to ensure that the correct |
3888 | +things happen when SIM PIN locking is disabled. |
3889 | + |
3890 | +NOTE - this test by default disables locking for a single SIM. |
3891 | +If the device is multi-SIM, the first modem will be used by |
3892 | +default. The -m argument can be used to specify the second |
3893 | +modem if needed. |
3894 | + |
3895 | +Requirements: |
3896 | + |
3897 | + * a locked SIM card |
3898 | + |
3899 | + * the current PIN code for the SIM |
3900 | + |
3901 | +SETUP: |
3902 | + |
3903 | + * Ensure that at least one locked SIM is inserted in the phone |
3904 | + |
3905 | + * Ensure that FlightMode is NOT enabled |
3906 | + |
3907 | + * [Optional] Some phones may require the SIM to be entered |
3908 | + before PIN locking can be disabled. |
3909 | + |
3910 | + * Run this script |
3911 | + |
3912 | + * Reboot the phone and re-run this script specifying --continue |
3913 | + ( DON'T enter the PIN on the UI after rebooting!!! ) |
3914 | + |
3915 | +ToDo: |
3916 | + * If run on the emulator, make this script use console |
3917 | + commands to configure the modem(s) for the required |
3918 | + conditions ( ie. no SIM(s), online ) |
3919 | +""" |
3920 | + |
3921 | +import simtestutil |
3922 | + |
3923 | +from simtestutil import * |
3924 | + |
3925 | +class TestSimDisablePinLock(SimTestCase): |
3926 | + |
3927 | + def validate_pin_props(self, path): |
3928 | + simmanager = self.get_simmanager(path) |
3929 | + properties = simmanager.GetProperties() |
3930 | + |
3931 | + self.assertTrue(len(properties["LockedPins"]) == 0) |
3932 | + self.assertTrue(properties["PinRequired"] == "none") |
3933 | + |
3934 | + def disable_pin_lock(self, path): |
3935 | + |
3936 | + simmanager = self.get_simmanager(path) |
3937 | + properties = simmanager.GetProperties() |
3938 | + |
3939 | + if self.args.debug: |
3940 | + print("disable_pin_lock called, LockedPins: %s" |
3941 | + % properties["LockedPins"]) |
3942 | + print("pin=%s" % self.args.pin) |
3943 | + |
3944 | + locked_pins = properties["LockedPins"] |
3945 | + self.assertTrue(len(locked_pins) == 1) |
3946 | + self.assertTrue(locked_pins[0] == "pin") |
3947 | + |
3948 | + simmanager.UnlockPin("pin", self.args.pin) |
3949 | + properties = simmanager.GetProperties() |
3950 | + self.assertTrue(len(properties["LockedPins"]) == 0) |
3951 | + |
3952 | + def validate_modem(self, path): |
3953 | + |
3954 | + if self.args.cont == False: |
3955 | + self.validate_modem_properties(path, True, True) |
3956 | + self.disable_pin_lock(path) |
3957 | + else: |
3958 | + self.validate_pin_props(path) |
3959 | + |
3960 | + def test_main(self): |
3961 | + self.main(args) |
3962 | + |
3963 | +if __name__ == "__main__": |
3964 | + args = simtestutil.parse_lock_test_args() |
3965 | + |
3966 | + sim_unittest_main(args) |
3967 | + |
3968 | |
3969 | === added file 'test/rilmodem/sim/test-sim-enable-pin-lock' |
3970 | --- test/rilmodem/sim/test-sim-enable-pin-lock 1970-01-01 00:00:00 +0000 |
3971 | +++ test/rilmodem/sim/test-sim-enable-pin-lock 2015-02-04 00:09:49 +0000 |
3972 | @@ -0,0 +1,101 @@ |
3973 | +#!/usr/bin/python3 |
3974 | +# |
3975 | +# oFono - Open Source Telephony - RIL Modem test |
3976 | +# |
3977 | +# Copyright (C) 2014 Canonical Ltd. |
3978 | +# |
3979 | +# This program is free software; you can redistribute it and/or modify |
3980 | +# it under the terms of the GNU General Public License version 2 as |
3981 | +# published by the Free Software Foundation. |
3982 | +# |
3983 | +# This program is distributed in the hope that it will be useful, |
3984 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3985 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3986 | +# GNU General Public License for more details. |
3987 | +# |
3988 | +# You should have received a copy of the GNU General Public License |
3989 | +# along with this program; if not, write to the Free Software |
3990 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3991 | +# |
3992 | +# This test ensures that basic modem information is available |
3993 | +# when the modem is online and has a valid, unlocked SIM present. |
3994 | + |
3995 | +"""Tests enabling a SIM for PIN locking. |
3996 | + |
3997 | +This module contains a functional test which checks an |
3998 | +ofono/rilmodem/mtkmodem instance to ensure that the correct |
3999 | +things happen when SIM PIN locking is enabled. |
4000 | + |
4001 | +NOTE - this test by default enables locking for a single SIM. |
4002 | +If the device is multi-SIM, the first modem will be used by |
4003 | +default. The -m argument can be used to specify the second |
4004 | +modem if needed. |
4005 | + |
4006 | +Requirements: |
4007 | + |
4008 | + * an unlocked SIM card |
4009 | + |
4010 | + * the current PIN code for the SIM |
4011 | + |
4012 | +SETUP: |
4013 | + |
4014 | + * Ensure that at least one unlocked SIM is inserted in the phone |
4015 | + |
4016 | + * Ensure that FlightMode is NOT enabled |
4017 | + |
4018 | + * Run this script |
4019 | + |
4020 | + * Reboot the phone and re-run this script specifying --continue |
4021 | + ( DON'T enter the PIN on the UI after rebooting!!! ) |
4022 | + |
4023 | +ToDo: |
4024 | + * If run on the emulator, make this script use console |
4025 | + commands to configure the modem(s) for the required |
4026 | + conditions ( ie. no SIM(s), online ) |
4027 | +""" |
4028 | + |
4029 | +import simtestutil |
4030 | + |
4031 | +from simtestutil import * |
4032 | + |
4033 | +class TestSimEnablePinLock(SimTestCase): |
4034 | + |
4035 | + def validate_pin_props(self, path): |
4036 | + simmanager = self.get_simmanager(path) |
4037 | + properties = simmanager.GetProperties() |
4038 | + |
4039 | + self.assertTrue(len(properties["LockedPins"]) == 1) |
4040 | + self.assertTrue(properties["PinRequired"] == "pin") |
4041 | + |
4042 | + def enable_pin_lock(self, path): |
4043 | + |
4044 | + if self.args.debug: |
4045 | + print("enable_pin_lock called, pin=%s" % self.args.pin) |
4046 | + |
4047 | + simmanager = self.get_simmanager(path) |
4048 | + properties = simmanager.GetProperties() |
4049 | + self.assertTrue(len(properties["LockedPins"]) == 0) |
4050 | + |
4051 | + simmanager.LockPin("pin", self.args.pin) |
4052 | + properties = simmanager.GetProperties() |
4053 | + |
4054 | + locked_pins = properties["LockedPins"] |
4055 | + self.assertTrue(len(locked_pins) == 1) |
4056 | + self.assertTrue(locked_pins[0] == "pin") |
4057 | + |
4058 | + def validate_modem(self, path): |
4059 | + |
4060 | + if self.args.cont == False: |
4061 | + self.validate_modem_properties(path, True, True) |
4062 | + self.enable_pin_lock(path) |
4063 | + else: |
4064 | + self.validate_pin_props(path) |
4065 | + |
4066 | + def test_main(self): |
4067 | + self.main(args) |
4068 | + |
4069 | +if __name__ == "__main__": |
4070 | + args = simtestutil.parse_lock_test_args() |
4071 | + |
4072 | + sim_unittest_main(args) |
4073 | + |
4074 | |
4075 | === added file 'test/rilmodem/sim/test-sim-pin-unlock' |
4076 | --- test/rilmodem/sim/test-sim-pin-unlock 1970-01-01 00:00:00 +0000 |
4077 | +++ test/rilmodem/sim/test-sim-pin-unlock 2015-02-04 00:09:49 +0000 |
4078 | @@ -0,0 +1,149 @@ |
4079 | +#!/usr/bin/python3 |
4080 | +# |
4081 | +# oFono - Open Source Telephony - RIL Modem test |
4082 | +# |
4083 | +# Copyright (C) 2014 Canonical Ltd. |
4084 | +# |
4085 | +# This program is free software; you can redistribute it and/or modify |
4086 | +# it under the terms of the GNU General Public License version 2 as |
4087 | +# published by the Free Software Foundation. |
4088 | +# |
4089 | +# This program is distributed in the hope that it will be useful, |
4090 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4091 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4092 | +# GNU General Public License for more details. |
4093 | +# |
4094 | +# You should have received a copy of the GNU General Public License |
4095 | +# along with this program; if not, write to the Free Software |
4096 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4097 | +# |
4098 | +# This test ensures that basic modem information is available |
4099 | +# when the modem is online and has a valid, unlocked SIM present. |
4100 | + |
4101 | +"""Tests the abilty to unlock a locked SIM for use. |
4102 | + |
4103 | +This module contains a functional test which checks an |
4104 | +ofono/rilmodem/mtkmodem instance to ensure that the a |
4105 | +SIM PIN can be entered and thus unlock the SIM for use. |
4106 | + |
4107 | +NOTE - this test by default tries to unlock the PIN of a |
4108 | +single SIM. If the device is multi-SIM, the first modem |
4109 | +will be used by default. The -m argument can be used to |
4110 | +specify the second modem if needed. |
4111 | + |
4112 | +Requirements: |
4113 | + |
4114 | + * a SIM with PIN-locking enabled |
4115 | + |
4116 | + * the current PIN code for the SIM |
4117 | + |
4118 | +Setup: |
4119 | + |
4120 | + * Ensure that FlightMode is NOT enabled |
4121 | + |
4122 | + * Ensure that at least one SIM with PIN-locking |
4123 | + enabled is inserted in the phone AND STILL LOCKED! |
4124 | + ( ie. the PIN hasn't been entered yet ) |
4125 | + |
4126 | + * Run this script |
4127 | + |
4128 | +ToDo: |
4129 | + * If run on the emulator, make this script use console |
4130 | + commands to configure the modem(s) for the required |
4131 | + conditions ( ie. no SIM(s), online ) |
4132 | +""" |
4133 | + |
4134 | +import dbus.mainloop.glib |
4135 | +import simtestutil |
4136 | + |
4137 | +from gi.repository import GLib |
4138 | +from simtestutil import * |
4139 | + |
4140 | +def parse_test_args(): |
4141 | + |
4142 | + parser = argparse.ArgumentParser() |
4143 | + |
4144 | + parser.add_argument("--pin", |
4145 | + dest="pin", |
4146 | + help="""Specify the SIM PIN code""", |
4147 | + required="yes", |
4148 | + ) |
4149 | + |
4150 | + parser.add_argument("-t", |
4151 | + "--timeout", |
4152 | + dest="timeout", |
4153 | + help="""Specify a timeout which causes |
4154 | + the script to exit""", |
4155 | + default=10, |
4156 | + ) |
4157 | + |
4158 | + return parse_args(parser) |
4159 | + |
4160 | +class TestSimPukUnlock(SimTestCase): |
4161 | + |
4162 | + def setUp(self): |
4163 | + self.args = args |
4164 | + self.product = get_product() |
4165 | + self.timer = False |
4166 | + |
4167 | + self.mainloop = GLib.MainLoop() |
4168 | + |
4169 | + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
4170 | + |
4171 | + SimTestCase.setUp(self) |
4172 | + |
4173 | + interval_ms = 1000 * int(self.args.timeout) |
4174 | + GLib.timeout_add(interval_ms, self.timeout_cb) |
4175 | + |
4176 | + def pin_unlock(self, path): |
4177 | + |
4178 | + if self.args.debug: |
4179 | + print("pin_unlock called," |
4180 | + "pin: {}".format(self.args.pin)) |
4181 | + |
4182 | + simmanager = self.get_simmanager(path) |
4183 | + simmanager.connect_to_signal("PropertyChanged", |
4184 | + self.sim_listener) |
4185 | + |
4186 | + properties = simmanager.GetProperties() |
4187 | + |
4188 | + locked_pins = properties["LockedPins"] |
4189 | + self.assertTrue(len(locked_pins) == 1) |
4190 | + self.assertTrue(locked_pins[0] == "pin") |
4191 | + |
4192 | + self.assertTrue(properties["PinRequired"] == "pin") |
4193 | + |
4194 | + simmanager.EnterPin("pin", self.args.pin) |
4195 | + |
4196 | + def sim_listener(self, name, value): |
4197 | + if self.args.debug: |
4198 | + print("SIM property: {} changed " |
4199 | + "to {}".format(name, str(value))) |
4200 | + |
4201 | + if name == "PinRequired": |
4202 | + self.assertTrue(value == "none") |
4203 | + self.mainloop.quit() |
4204 | + |
4205 | + def timeout_cb(self): |
4206 | + if self.args.debug: |
4207 | + print("ALL DONE - timer fired!!!") |
4208 | + |
4209 | + self.timer = True |
4210 | + self.mainloop.quit() |
4211 | + |
4212 | + def validate_modem(self, path): |
4213 | + |
4214 | + self.pin_unlock(path) |
4215 | + |
4216 | + self.mainloop.run() |
4217 | + |
4218 | + self.assertTrue(self.timer == False) |
4219 | + |
4220 | + def test_main(self): |
4221 | + self.main(args) |
4222 | + |
4223 | +if __name__ == "__main__": |
4224 | + args = parse_test_args() |
4225 | + |
4226 | + sim_unittest_main(args) |
4227 | + |
4228 | |
4229 | === added file 'test/rilmodem/sim/test-sim-puk-unlock' |
4230 | --- test/rilmodem/sim/test-sim-puk-unlock 1970-01-01 00:00:00 +0000 |
4231 | +++ test/rilmodem/sim/test-sim-puk-unlock 2015-02-04 00:09:49 +0000 |
4232 | @@ -0,0 +1,227 @@ |
4233 | +#!/usr/bin/python3 |
4234 | +# |
4235 | +# oFono - Open Source Telephony - RIL Modem test |
4236 | +# |
4237 | +# Copyright (C) 2014 Canonical Ltd. |
4238 | +# |
4239 | +# This program is free software; you can redistribute it and/or modify |
4240 | +# it under the terms of the GNU General Public License version 2 as |
4241 | +# published by the Free Software Foundation. |
4242 | +# |
4243 | +# This program is distributed in the hope that it will be useful, |
4244 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4245 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4246 | +# GNU General Public License for more details. |
4247 | +# |
4248 | +# You should have received a copy of the GNU General Public License |
4249 | +# along with this program; if not, write to the Free Software |
4250 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4251 | +# |
4252 | +# This test ensures that basic modem information is available |
4253 | +# when the modem is online and has a valid, unlocked SIM present. |
4254 | + |
4255 | +"""Tests the abilty to unlock a PUK-locked SIM. |
4256 | + |
4257 | +Requirements: |
4258 | + |
4259 | + * a SIM with PIN-locking enabled |
4260 | + |
4261 | + * the current PUK code for the SIM |
4262 | + |
4263 | +Setup: |
4264 | + |
4265 | + * Ensure that FlightMode is NOT enabled |
4266 | + |
4267 | + * Ensure that at least one SIM with PIN-locking |
4268 | + enabled is inserted in the phone AND STILL LOCKED! |
4269 | + ( ie. the PIN hasn't been entered yet ) |
4270 | + |
4271 | + * Run this script |
4272 | + |
4273 | +Notes: |
4274 | + |
4275 | +This script will actually cause the SIM to become PUK-locked |
4276 | +by entering a hard-coded SIM three times in a row. This is |
4277 | +done to verify that the 'Retries' property is properly updated |
4278 | +on incorrect PIN attempts. Likewise, once PUK-locked this |
4279 | +test will also attempt on incorrect PUK reset to again check |
4280 | +'Retries'. It will then reset the SIM to the given new PIN. |
4281 | + |
4282 | +ToDo: |
4283 | + * If run on the emulator, make this script use console |
4284 | + commands to configure the modem(s) for the required |
4285 | + conditions ( ie. no SIM(s), online ) |
4286 | +""" |
4287 | + |
4288 | +import dbus.mainloop.glib |
4289 | +import simtestutil |
4290 | + |
4291 | +from gi.repository import GLib |
4292 | +from simtestutil import * |
4293 | + |
4294 | +def parse_test_args(): |
4295 | + |
4296 | + parser = argparse.ArgumentParser() |
4297 | + |
4298 | + parser.add_argument("--puk", |
4299 | + dest="puk", |
4300 | + help="""Specify the SIM PUK code""", |
4301 | + required="yes", |
4302 | + ) |
4303 | + |
4304 | + parser.add_argument("--new-pin", |
4305 | + dest="new_pin", |
4306 | + help="""Spicy the new SIM PIN code""", |
4307 | + required="yes" |
4308 | + ) |
4309 | + |
4310 | + parser.add_argument("-t", |
4311 | + "--timeout", |
4312 | + dest="timeout", |
4313 | + help="""Specify a timeout which causes |
4314 | + the script to exit""", |
4315 | + default=10, |
4316 | + ) |
4317 | + |
4318 | + return parse_args(parser) |
4319 | + |
4320 | +class TestSimUnlockPuk(SimTestCase): |
4321 | + |
4322 | + def setUp(self): |
4323 | + self.args = args |
4324 | + self.product = get_product() |
4325 | + self.pin_retries = 3 |
4326 | + self.puk_retries = 10 |
4327 | + self.pin_retry_failure = False |
4328 | + self.puk_retry_failure = False |
4329 | + self.timeout_failure = False |
4330 | + self.bad_puk_sent = False |
4331 | + |
4332 | + self.mainloop = GLib.MainLoop() |
4333 | + |
4334 | + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
4335 | + |
4336 | + SimTestCase.setUp(self) |
4337 | + |
4338 | + interval_ms = 1000 * int(self.args.timeout) |
4339 | + GLib.timeout_add(interval_ms, self.timeout_cb) |
4340 | + |
4341 | + def enter_bad_pin(self, path, simmanager=None): |
4342 | + if simmanager == None: |
4343 | + simmanager = self.get_simmanager(path) |
4344 | + |
4345 | + try: |
4346 | + simmanager.EnterPin("pin", "0000") |
4347 | + except dbus.DBusException as e: |
4348 | + if self.args.debug: |
4349 | + print("EnterPin failed") |
4350 | + |
4351 | + def enter_puk(self, path, puk, pin, simmanager=None): |
4352 | + if simmanager == None: |
4353 | + simmanager = self.get_simmanager(path) |
4354 | + |
4355 | + try: |
4356 | + simmanager.ResetPin("puk", puk, pin) |
4357 | + except dbus.DBusException as e: |
4358 | + if self.args.debug: |
4359 | + print("ResetPin failed") |
4360 | + |
4361 | + # now do a valid PUK unlock |
4362 | + if self.bad_puk_sent == False: |
4363 | + self.bad_puk_sent = True |
4364 | + self.enter_puk(path, |
4365 | + self.args.puk, |
4366 | + self.args.new_pin) |
4367 | + |
4368 | + def retry_listener(self, name, value, path): |
4369 | + if self.args.debug: |
4370 | + print("modem: {} SIM property: {} changed " |
4371 | + "to {}".format(path, name, str(value))) |
4372 | + |
4373 | + if name == "Retries" and len(value) > 0: |
4374 | + |
4375 | + # bug: lp: #14028 - Retries not updated for |
4376 | + # bad PUK attempts! If it's possible to fix |
4377 | + # this bug, then code should be added here to |
4378 | + # validate puk retries decreasing... |
4379 | + |
4380 | + if self.bad_puk_sent == False: |
4381 | + if "pin" in value: |
4382 | + retries = int(value["pin"]) |
4383 | + else: |
4384 | + retries = 0 |
4385 | + |
4386 | + if retries != (self.pin_retries - 1): |
4387 | + self.pin_retry_failure = True |
4388 | + self.mainloop.quit() |
4389 | + else: |
4390 | + self.pin_retries = retries |
4391 | + |
4392 | + if retries > 0: |
4393 | + if self.args.debug: |
4394 | + print("enter another bad pin") |
4395 | + |
4396 | + self.enter_bad_pin(path) |
4397 | + |
4398 | + elif name == "PinRequired": |
4399 | + if value == "none": |
4400 | + if self.args.debug: |
4401 | + print("Pin reset; all done!"); |
4402 | + |
4403 | + self.mainloop.quit() |
4404 | + elif value == "puk": |
4405 | + |
4406 | + # trigger an invalid PUK unlock |
4407 | + self.enter_puk(path, |
4408 | + "0000000000", |
4409 | + "0000") |
4410 | + |
4411 | + def timeout_cb(self): |
4412 | + if self.args.debug: |
4413 | + print("ALL DONE - timer fired!!!") |
4414 | + |
4415 | + self.timeout_failure = True |
4416 | + self.mainloop.quit() |
4417 | + |
4418 | + def puk_unlock(self, path): |
4419 | + |
4420 | + if self.args.debug: |
4421 | + print("puk_unlock called, puk= {} " |
4422 | + "new_pin: {}".format(self.args.puk, |
4423 | + self.args.new_pin)) |
4424 | + |
4425 | + simmanager = self.get_simmanager(path) |
4426 | + properties = simmanager.GetProperties() |
4427 | + |
4428 | + # verify SIM is PIN-locked |
4429 | + locked_pins = properties["LockedPins"] |
4430 | + self.assertTrue(len(locked_pins) == 1) |
4431 | + self.assertTrue(locked_pins[0] == "pin") |
4432 | + |
4433 | + self.assertTrue(properties["PinRequired"] == "pin") |
4434 | + |
4435 | + # enter wrong PIN x3 |
4436 | + simmanager.connect_to_signal("PropertyChanged", |
4437 | + self.retry_listener, |
4438 | + path_keyword="path") |
4439 | + |
4440 | + self.enter_bad_pin(path, simmanager) |
4441 | + |
4442 | + def validate_modem(self, path): |
4443 | + |
4444 | + self.puk_unlock(path) |
4445 | + |
4446 | + self.mainloop.run() |
4447 | + |
4448 | + self.assertFalse(self.timeout_failure) |
4449 | + self.assertFalse(self.pin_retry_failure) |
4450 | + self.assertFalse(self.puk_retry_failure) |
4451 | + |
4452 | + def test_main(self): |
4453 | + self.main(args) |
4454 | + |
4455 | +if __name__ == "__main__": |
4456 | + args = parse_test_args() |
4457 | + |
4458 | + sim_unittest_main(args) |
4459 | + |
4460 | |
4461 | === added file 'test/rilmodem/sim/test-sim-removal' |
4462 | --- test/rilmodem/sim/test-sim-removal 1970-01-01 00:00:00 +0000 |
4463 | +++ test/rilmodem/sim/test-sim-removal 2015-02-04 00:09:49 +0000 |
4464 | @@ -0,0 +1,156 @@ |
4465 | +#!/usr/bin/python3 |
4466 | +# |
4467 | +# oFono - Open Source Telephony - RIL Modem test |
4468 | +# |
4469 | +# Copyright (C) 2014 Canonical Ltd. |
4470 | +# |
4471 | +# This program is free software; you can redistribute it and/or modify |
4472 | +# it under the terms of the GNU General Public License version 2 as |
4473 | +# published by the Free Software Foundation. |
4474 | +# |
4475 | +# This program is distributed in the hope that it will be useful, |
4476 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4477 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4478 | +# GNU General Public License for more details. |
4479 | +# |
4480 | +# You should have received a copy of the GNU General Public License |
4481 | +# along with this program; if not, write to the Free Software |
4482 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4483 | +# |
4484 | +# This test ensures that basic modem information is available |
4485 | +# when the modem is online and has a valid, unlocked SIM present. |
4486 | + |
4487 | +"""Tests SIM removal detection/notification |
4488 | + |
4489 | +This module contains a functional test which checks a running |
4490 | +ofono/rilmodem/mtkmodem instance to ensure that the correct |
4491 | +DBus signals are generated and the correct properties updated |
4492 | +when a SIM is removed from a running device. The script by |
4493 | +default will wait for 60 seconds for the SIM to be removed after |
4494 | +which it will exit. |
4495 | + |
4496 | +NOTE - this test by default verifies the removal of a SIM from |
4497 | +a single modem. If the device is multi-SIM, the first modem |
4498 | +will be used by default. The -m argument can be used to specify |
4499 | +the second modem if needed. |
4500 | + |
4501 | +SETUP: |
4502 | + |
4503 | + * Run this script |
4504 | + |
4505 | + * Remove the SIM card |
4506 | + |
4507 | +Options: |
4508 | + |
4509 | + * -t / --timer - specify a timeout after which the script |
4510 | + will exit. |
4511 | + |
4512 | +ToDo: |
4513 | + * If run on the emulator, make this script use console |
4514 | + commands to configure the modem(s) for the required |
4515 | + conditions ( ie. no SIM(s), online ) |
4516 | +""" |
4517 | + |
4518 | +import dbus.mainloop.glib |
4519 | +import simtestutil |
4520 | + |
4521 | +from gi.repository import GLib |
4522 | +from simtestutil import * |
4523 | + |
4524 | +def parse_args(): |
4525 | + |
4526 | + parser = argparse.ArgumentParser() |
4527 | + |
4528 | + parser.add_argument("-t", |
4529 | + "--timeout", |
4530 | + dest="timeout", |
4531 | + help="""Specify a timeout which causes |
4532 | + the script to exit""", |
4533 | + default=60, |
4534 | + ) |
4535 | + |
4536 | + return simtestutil.parse_args(parser) |
4537 | + |
4538 | +class TestSimRemovalNotification(SimTestCase): |
4539 | + |
4540 | + def modem_listener(self, name, value, path=None): |
4541 | + if self.args.debug: |
4542 | + print("Modem property: '%s' changed to '%s'" |
4543 | + % (name, str(value))) |
4544 | + |
4545 | + if name == "Interfaces": |
4546 | + if "org.ofono.SimManager" in value: |
4547 | + if (self.check_no_sim_present(path) != True): |
4548 | + self.sim_present_failure = True |
4549 | + |
4550 | + self.mainloop.quit() |
4551 | + |
4552 | + def sim_listener(self, name, value): |
4553 | + if self.args.debug: |
4554 | + print("SIM property: '%s' changed to '%s'" |
4555 | + % (name, str(value))) |
4556 | + |
4557 | + if name == "Present": |
4558 | + if value != 0: |
4559 | + self.sim_present_signal_failure = True |
4560 | + |
4561 | + self.mainloop.quit() |
4562 | + |
4563 | + def setUp(self): |
4564 | + self.args = args |
4565 | + self.product = get_product() |
4566 | + |
4567 | + self.sim_present_failure = False |
4568 | + self.sim_present_signal_failure = False |
4569 | + self.timeout_failure = False |
4570 | + |
4571 | + self.mainloop = GLib.MainLoop() |
4572 | + |
4573 | + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
4574 | + |
4575 | + SimTestCase.setUp(self) |
4576 | + |
4577 | + interval_ms = 1000 * int(self.args.timeout) |
4578 | + GLib.timeout_add(interval_ms, self.timeout_cb) |
4579 | + |
4580 | + def timeout_cb(self): |
4581 | + if self.args.debug: |
4582 | + print("ALL DONE - timer fired!!!") |
4583 | + |
4584 | + self.timeout_failure = True |
4585 | + self.mainloop.quit() |
4586 | + |
4587 | + def validate_modem(self, path): |
4588 | + modem = self.validate_modem_properties(path, True, True) |
4589 | + |
4590 | + if self.if_supports_sim_offline() == True: |
4591 | + |
4592 | + # valid SimManager properties |
4593 | + simmanager = self.get_simmanager(path) |
4594 | + |
4595 | + simmanager.connect_to_signal("PropertyChanged", |
4596 | + self.sim_listener) |
4597 | + else: |
4598 | + modem.connect_to_signal("PropertyChanged", |
4599 | + self.modem_listener, |
4600 | + path_keyword="path") |
4601 | + |
4602 | + def test_main(self): |
4603 | + if args.debug: |
4604 | + print ("ro.build.product: %s" % self.product) |
4605 | + |
4606 | + if len(args.modem) > 0: |
4607 | + self.validate_modem(args.modem) |
4608 | + else: |
4609 | + self.validate_modem(self.modems[0][0]) |
4610 | + |
4611 | + self.mainloop.run() |
4612 | + |
4613 | + self.assertFalse(self.timeout_failure) |
4614 | + self.assertFalse(self.sim_present_failure) |
4615 | + self.assertFalse(self.sim_present_signal_failure) |
4616 | + |
4617 | +if __name__ == "__main__": |
4618 | + args = parse_args() |
4619 | + |
4620 | + sim_unittest_main(args) |
4621 | |
4622 | === added file 'test/rilmodem/sim/test-sims-offline' |
4623 | --- test/rilmodem/sim/test-sims-offline 1970-01-01 00:00:00 +0000 |
4624 | +++ test/rilmodem/sim/test-sims-offline 2015-02-04 00:09:49 +0000 |
4625 | @@ -0,0 +1,106 @@ |
4626 | +#!/usr/bin/python3 |
4627 | +# |
4628 | +# oFono - Open Source Telephony - RIL Modem test |
4629 | +# |
4630 | +# Copyright (C) 2014 Canonical Ltd. |
4631 | +# |
4632 | +# This program is free software; you can redistribute it and/or modify |
4633 | +# it under the terms of the GNU General Public License version 2 as |
4634 | +# published by the Free Software Foundation. |
4635 | +# |
4636 | +# This program is distributed in the hope that it will be useful, |
4637 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4638 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4639 | +# GNU General Public License for more details. |
4640 | +# |
4641 | +# You should have received a copy of the GNU General Public License |
4642 | +# along with this program; if not, write to the Free Software |
4643 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4644 | +# |
4645 | +# This test ensures that basic modem information is available |
4646 | +# when the modem is online and has a valid, unlocked SIM present. |
4647 | + |
4648 | +"""Tests SIM(s) and modem(s) offline. |
4649 | + |
4650 | +This module contains a functional test which checks a running |
4651 | +ofono/rilmodem/mtkmodem instance to ensure that the correct |
4652 | +DBus properties are exported when one or more SIMs (unlocked) |
4653 | +are inserted AND the corresponding modem(s) are offline. As such |
4654 | +it validates the properties of the followinh interfaces: |
4655 | + |
4656 | + * org.ofono.Modem |
4657 | + * org.ofono.SimManager ( on supported hw ) |
4658 | + * org.ofono.VoiceCallManager ( EmergencyNumbers ) |
4659 | + * org.ofono.CallVolume |
4660 | + |
4661 | +NOTE - this test by default verifies all modems present a device. |
4662 | +If the device is multi-SIM and not all slots have unlocked SIMs, |
4663 | +then please use the -m to verify a specific modem. |
4664 | + |
4665 | +SETUP: |
4666 | + |
4667 | + * Ensure that at least one unlocked SIM is inserted in the phone |
4668 | + |
4669 | + * Ensure FlightMode from System Settings ( or net-indicator ) |
4670 | + |
4671 | + * Run this script |
4672 | + |
4673 | + * Disable FlightMode |
4674 | + |
4675 | +ToDo: |
4676 | + * If run on the emulator, make this script use console |
4677 | + commands to configure the modem(s) for the required |
4678 | + conditions ( ie. no SIM(s), online ) |
4679 | +""" |
4680 | + |
4681 | +import argparse |
4682 | +import simtestutil |
4683 | + |
4684 | +from simtestutil import * |
4685 | + |
4686 | +def parse_args(): |
4687 | + parser = argparse.ArgumentParser() |
4688 | + |
4689 | + parser.add_argument("--mnc", |
4690 | + dest="mnc", |
4691 | + help="""Specify a MNC (mobile-network-code) to |
4692 | + match against""", |
4693 | + default="", |
4694 | + ) |
4695 | + parser.add_argument("--mcc", |
4696 | + dest="mcc", |
4697 | + help="""Specify a MCC (mobile-country-code) to |
4698 | + match against""", |
4699 | + default="", |
4700 | + ) |
4701 | + parser.add_argument("--subscriber", |
4702 | + dest="subscriber", |
4703 | + help="""Specify a SubscriberIdentity to |
4704 | + match against""", |
4705 | + default="", |
4706 | + ) |
4707 | + |
4708 | + return simtestutil.parse_args(parser) |
4709 | + |
4710 | +class TestSimsOffline(SimTestCase): |
4711 | + |
4712 | + def validate_modem(self, path): |
4713 | + |
4714 | + self.validate_modem_properties(path, False, True) |
4715 | + |
4716 | + # krillin: no SIM access when modem offline |
4717 | + if (self.product != "krillin"): |
4718 | + self.validate_sim_properties(path, self.args.mcc, |
4719 | + self.args.mnc, |
4720 | + self.args.subscriber) |
4721 | + |
4722 | + self.validate_emergency_numbers(path) |
4723 | + self.validate_call_volume_properties(path) |
4724 | + |
4725 | + def test_main(self): |
4726 | + self.main(args) |
4727 | + |
4728 | +if __name__ == "__main__": |
4729 | + args = parse_args() |
4730 | + |
4731 | + sim_unittest_main(args) |
4732 | |
4733 | === added file 'test/rilmodem/sim/test-sims-online' |
4734 | --- test/rilmodem/sim/test-sims-online 1970-01-01 00:00:00 +0000 |
4735 | +++ test/rilmodem/sim/test-sims-online 2015-02-04 00:09:49 +0000 |
4736 | @@ -0,0 +1,108 @@ |
4737 | +#!/usr/bin/python3 |
4738 | +# |
4739 | +# oFono - Open Source Telephony - RIL Modem test |
4740 | +# |
4741 | +# Copyright (C) 2014 Canonical Ltd. |
4742 | +# |
4743 | +# This program is free software; you can redistribute it and/or modify |
4744 | +# it under the terms of the GNU General Public License version 2 as |
4745 | +# published by the Free Software Foundation. |
4746 | +# |
4747 | +# This program is distributed in the hope that it will be useful, |
4748 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4749 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4750 | +# GNU General Public License for more details. |
4751 | +# |
4752 | +# You should have received a copy of the GNU General Public License |
4753 | +# along with this program; if not, write to the Free Software |
4754 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4755 | +# |
4756 | +# This test ensures that basic modem information is available |
4757 | +# when the modem is online and has a valid, unlocked SIM present. |
4758 | + |
4759 | +"""Tests SIM(s) and modem(s) online. |
4760 | + |
4761 | +This module contains a functional test which checks a running |
4762 | +ofono/rilmodem/mtkmodem instance to ensure that the correct |
4763 | +DBus properties are exported when one or more SIMs are |
4764 | +inserted AND the corresponding modem(s) are online. |
4765 | + |
4766 | +NOTE - this test by default verifies all modems present a device. |
4767 | +If the device is multi-SIM and not all slots have unlocked SIMs, |
4768 | +then please use the -m to verify a specific modem. |
4769 | + |
4770 | +SETUP: |
4771 | + |
4772 | + * Ensure that at least one unlocked SIM is inserted in the phone |
4773 | + |
4774 | + * Ensure that FlightMode is NOT enabled |
4775 | + |
4776 | + * Run this script |
4777 | + |
4778 | +Options: |
4779 | + |
4780 | + * --mnc - specify a mobile network code to match against |
4781 | + |
4782 | + * --mcc - specify a mobile country code to match against |
4783 | + |
4784 | + * --subscriber - specify a subscriber identity to match against |
4785 | + |
4786 | +ToDo: |
4787 | + * If run on the emulator, make this script use console |
4788 | + commands to configure the modem(s) for the required |
4789 | + conditions ( ie. no SIM(s), online ) |
4790 | +""" |
4791 | + |
4792 | +import argparse |
4793 | +import simtestutil |
4794 | + |
4795 | +from simtestutil import * |
4796 | + |
4797 | +def parse_args(): |
4798 | + |
4799 | + parser = argparse.ArgumentParser() |
4800 | + |
4801 | + parser.add_argument("--mnc", |
4802 | + dest="mnc", |
4803 | + help="""Specify a MNC (mobile-network-code) to |
4804 | + match against""", |
4805 | + default="", |
4806 | + ) |
4807 | + |
4808 | + parser.add_argument("--mcc", |
4809 | + dest="mcc", |
4810 | + help="""Specify a MCC (mobile-country-code) to |
4811 | + match against""", |
4812 | + default="", |
4813 | + ) |
4814 | + |
4815 | + parser.add_argument("--subscriber", |
4816 | + dest="subscriber", |
4817 | + help="""Specify a SubscriberIdentity to |
4818 | + match against""", |
4819 | + default="", |
4820 | + ) |
4821 | + |
4822 | + return simtestutil.parse_args(parser) |
4823 | + |
4824 | +class TestSimsOnline(SimTestCase): |
4825 | + |
4826 | + def validate_modem(self, path): |
4827 | + self.validate_modem_properties(path, True, True) |
4828 | + |
4829 | + |
4830 | + self.validate_sim_properties(path, self.args.mcc, |
4831 | + self.args.mnc, |
4832 | + self.args.subscriber) |
4833 | + |
4834 | + self.validate_emergency_numbers(path) |
4835 | + self.validate_call_volume_properties(path) |
4836 | + |
4837 | + def test_main(self): |
4838 | + self.main(args) |
4839 | + |
4840 | +if __name__ == "__main__": |
4841 | + args = parse_args() |
4842 | + |
4843 | + sim_unittest_main(args) |
4844 | + |
4845 | |
4846 | === modified file 'test/test-call-forwarding' |
4847 | --- test/test-call-forwarding 2014-03-13 18:19:25 +0000 |
4848 | +++ test/test-call-forwarding 2015-02-04 00:09:49 +0000 |
4849 | @@ -53,6 +53,8 @@ |
4850 | |
4851 | def main(args): |
4852 | |
4853 | + path = "" |
4854 | + |
4855 | dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
4856 | |
4857 | bus = dbus.SystemBus() |
4858 | @@ -62,16 +64,22 @@ |
4859 | |
4860 | modems = manager.GetModems() |
4861 | |
4862 | - if (args.modem == ""): |
4863 | - modem = modems[0][0] |
4864 | - |
4865 | - if (args.noreply_timeout == -1): |
4866 | - noreply_timeout = dbus.UInt16(30) |
4867 | - else: |
4868 | - noreply_timeout = dbus.UInt16(args.noreply_timeout) |
4869 | - |
4870 | - cf = dbus.Interface(bus.get_object('org.ofono', modem), |
4871 | - 'org.ofono.CallForwarding') |
4872 | + assert len(modems) >= 1 |
4873 | + |
4874 | + for modem in modems: |
4875 | + if modem[0] == args.modem: |
4876 | + path = args.modem |
4877 | + |
4878 | + if path == "": |
4879 | + path = modems[0][0] |
4880 | + |
4881 | + if args.noreply_timeout == -1: |
4882 | + noreply_timeout = dbus.UInt16(30) |
4883 | + else: |
4884 | + noreply_timeout = dbus.UInt16(args.noreply_timeout) |
4885 | + |
4886 | + cf = dbus.Interface(bus.get_object('org.ofono', path), |
4887 | + 'org.ofono.CallForwarding') |
4888 | |
4889 | cf.connect_to_signal("PropertyChanged", property_changed) |
4890 | |
4891 | |
4892 | === modified file 'unit/test-grilrequest.c' |
4893 | --- unit/test-grilrequest.c 2014-07-16 22:55:36 +0000 |
4894 | +++ unit/test-grilrequest.c 2015-02-04 00:09:49 +0000 |
4895 | @@ -821,6 +821,40 @@ |
4896 | .parcel_size = sizeof(req_oem_hook_raw_valid_2), |
4897 | }; |
4898 | |
4899 | +/* set_initial_attach_apn tests */ |
4900 | + |
4901 | +struct request_test_set_initial_attach_apn { |
4902 | + const char *apn; |
4903 | + const int proto; |
4904 | + const char *user; |
4905 | + const char *passwd; |
4906 | + const char *mccmnc; |
4907 | + const guchar *parcel_data; |
4908 | + gsize parcel_size; |
4909 | +}; |
4910 | + |
4911 | +static const guchar req_set_initial_attach_apn_valid_1[] = { |
4912 | + 0x0c, 0x00, 0x00, 0x00, 0x61, 0x00, 0x69, 0x00, 0x72, 0x00, 0x74, 0x00, |
4913 | + 0x65, 0x00, 0x6c, 0x00, 0x77, 0x00, 0x61, 0x00, 0x70, 0x00, 0x2e, 0x00, |
4914 | + 0x65, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
4915 | + 0x49, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, |
4916 | + 0x07, 0x00, 0x00, 0x00, 0x77, 0x00, 0x61, 0x00, 0x70, 0x00, 0x40, 0x00, |
4917 | + 0x77, 0x00, 0x61, 0x00, 0x70, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, |
4918 | + 0x77, 0x00, 0x61, 0x00, 0x70, 0x00, 0x31, 0x00, 0x32, 0x00, 0x35, 0x00, |
4919 | + 0x00, 0x00, 0x00, 0x00 |
4920 | +}; |
4921 | + |
4922 | +static const struct request_test_set_initial_attach_apn |
4923 | + set_initial_attach_apn_valid_test_1 = { |
4924 | + .apn = "airtelwap.es", |
4925 | + .proto = OFONO_GPRS_PROTO_IP, |
4926 | + .user = "wap@wap", |
4927 | + .passwd = "wap125", |
4928 | + .mccmnc = "21401", |
4929 | + .parcel_data = req_set_initial_attach_apn_valid_1, |
4930 | + .parcel_size = sizeof(req_set_initial_attach_apn_valid_1), |
4931 | +}; |
4932 | + |
4933 | /* |
4934 | * The following hexadecimal data represents a serialized Binder parcel |
4935 | * instance containing a valid RIL_REQUEST_RADIO_POWER 'OFF' message. |
4936 | @@ -1338,6 +1372,22 @@ |
4937 | parcel_free(&rilp); |
4938 | } |
4939 | |
4940 | +static void test_request_set_initial_attach_apn(gconstpointer data) |
4941 | +{ |
4942 | + const struct request_test_set_initial_attach_apn *test_data = data; |
4943 | + struct parcel rilp; |
4944 | + |
4945 | + g_ril_request_set_initial_attach_apn(NULL, test_data->apn, |
4946 | + test_data->proto, test_data->user, |
4947 | + test_data->passwd, test_data->mccmnc, |
4948 | + &rilp); |
4949 | + |
4950 | + g_assert(!memcmp(rilp.data, test_data->parcel_data, |
4951 | + test_data->parcel_size)); |
4952 | + |
4953 | + parcel_free(&rilp); |
4954 | +} |
4955 | + |
4956 | static void test_request_change_barring_password(gconstpointer data) |
4957 | { |
4958 | const struct request_test_change_barring_password_data *test_data = |
4959 | @@ -1627,6 +1677,10 @@ |
4960 | &oem_hook_raw_valid_test_2, |
4961 | test_request_oem_hook_raw); |
4962 | |
4963 | + g_test_add_data_func("/testgrilrequest/set-ia-apn: " |
4964 | + "valid SET_INITIAL_ATTACH_APN Test 1", |
4965 | + &set_initial_attach_apn_valid_test_1, |
4966 | + test_request_set_initial_attach_apn); |
4967 | #endif |
4968 | return g_test_run(); |
4969 | } |
4970 | |
4971 | === modified file 'unit/test-mtkreply.c' |
4972 | --- unit/test-mtkreply.c 2014-11-17 15:43:36 +0000 |
4973 | +++ unit/test-mtkreply.c 2015-02-04 00:09:49 +0000 |
4974 | @@ -36,6 +36,7 @@ |
4975 | #include "common.h" |
4976 | #include "grilreply.h" |
4977 | #include "drivers/mtkmodem/mtk_constants.h" |
4978 | +#include "drivers/mtkmodem/mtkrequest.h" |
4979 | #include "drivers/mtkmodem/mtkreply.h" |
4980 | |
4981 | /* |
4982 | @@ -57,6 +58,11 @@ |
4983 | const struct ril_msg msg; |
4984 | }; |
4985 | |
4986 | +struct rep_query_modem_type_test { |
4987 | + int type; |
4988 | + const struct ril_msg msg; |
4989 | +}; |
4990 | + |
4991 | /* |
4992 | * The following hexadecimal data contains the event data of a valid |
4993 | * MTK-specific RIL_REQUEST_AVAILABLE_NETWORKS with the following parameters: |
4994 | @@ -124,6 +130,27 @@ |
4995 | } |
4996 | }; |
4997 | |
4998 | +/* |
4999 | + * The following hexadecimal data contains the reply to a |
5000 | + * MTK_RIL_REQUEST_QUERY_MODEM_TYPE request with parameter {6} |
PASSED: Continuous integration, rev:6886 jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- ci/65/ jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- vivid-amd64- ci/3 jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- vivid-armhf- ci/3 jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- vivid-armhf- ci/3/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- vivid-i386- ci/3
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/phablet- team-ofono- ubuntu- ci/65/rebuild
http://