Merge lp:~phablet-team/phablet-extras/ofono-sim-pin-support into lp:phablet-extras/ofono
- ofono-sim-pin-support
- Merge into ofono
Status: | Merged |
---|---|
Approved by: | Ricardo Salveti |
Approved revision: | 53 |
Merged at revision: | 46 |
Proposed branch: | lp:~phablet-team/phablet-extras/ofono-sim-pin-support |
Merge into: | lp:phablet-extras/ofono |
Diff against target: |
860 lines (+511/-107) 5 files modified
debian/changelog (+8/-0) drivers/rilmodem/rilutil.c (+81/-61) drivers/rilmodem/rilutil.h (+42/-11) drivers/rilmodem/sim.c (+368/-30) plugins/ril.c (+12/-5) |
To merge this branch: | bzr merge lp:~phablet-team/phablet-extras/ofono-sim-pin-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Salveti (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+172204@code.launchpad.net |
Commit message
[rilmodem] Add SIM PIN/PUK support.
Description of the change
This merge adds SIM PIN/PUK support. It's based on code from Jolla that's been re-factored due to the fact that they're working on a older version of our code, and to remove some of the changes they made which were questionable.
https:/
Testing was performed on an un-flipped maguro, using the 20130629 build.
I tested an unlocked SIM, and only verified that I was able to make voice calls.
I tested a locked SIM. I manually started ofono. Before unlocked, the ofono DBus interfaces are restricted to VoiceCallManager and SimManager. I manually entered a pin via dbus-send:
I resorted to dbus-send, as I couldn't get the python enter-pin test script to run, but this was because it took me awhile to figure out that the 'pin_type' argument was the same as reported by the property ( eg. "pin" ). Here's the command I used:
# dbus-send --print-reply --system --dest=org.ofono /ril_0 org.ofono.
After entering the PIN, I verified that the rest of the modem initialization occurs, and I was able to make a phone call.
NOTE -- I did some minor cleanup of the branch before submitting, so this code definitely needs to be fully re-tested on maguro. It also needs to be tested on mako.
PS Jenkins bot (ps-jenkins) wrote : | # |
Ricardo Salveti (rsalveti) wrote : | # |
435 + if (ril_util_
436 +
437 + if (status.num_apps) {
As you only cares about status.num_apps, you could check both at the same line (with &&), and that will save you one indentation level.
Ricardo Salveti (rsalveti) wrote : | # |
521 +static void ril_query_
522 + ofono_sim_
523 +{
524 + struct sim_data *sd = ofono_sim_
525 +
526 + DBG("passwd_state %u", sd->passwd_state);
527 + CALLBACK_
528 +}
You also might want to handle the case which the passwd_state is invalid, check how this is done with isi and qmimodem.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:49
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Tony Espy (awe) wrote : | # |
I re-factored sim_status_cb() and fixed the line length problem which still existed even after combining the "if" statements per the initial review comment.
I also fixed ril_query_
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:50
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:51
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Ricardo Salveti (rsalveti) wrote : | # |
750 + g_ril_append_
751 + old, new,
752 + sd->aid_str);
The debug is wrong here, it should be old=%s,new=%d instead.
Also, there's a memory corruption when copying the aid_str string to sd, as you basically just assign the pointer (line 435), instead of copying the value (the corruption happens once ril_util_
With such fix in place I'm able to lock/unlock my sim card.
Tony Espy (awe) wrote : | # |
Both issues fixed, and pushed... Thanks!
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:52
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:53
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Ricardo Salveti (rsalveti) wrote : | # |
Good, tested with mako and working as expected. Thanks.
Preview Diff
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2013-06-26 17:24:24 +0000 | |||
3 | +++ debian/changelog 2013-07-09 19:18:24 +0000 | |||
4 | @@ -1,3 +1,11 @@ | |||
5 | 1 | ofono (1.12phablet8) saucy; urgency=low | ||
6 | 2 | |||
7 | 3 | * [rilmodem] Added SIM PIN/PUK support. This is | ||
8 | 4 | based on code from Jolla: | ||
9 | 5 | https://github.com/nemomobile-packages/ofono | ||
10 | 6 | |||
11 | 7 | -- Tony Espy <espy@canonical.com> Mon, 08 Jul 2013 13:08:32 -0400 | ||
12 | 8 | |||
13 | 1 | ofono (1.12phablet7) saucy; urgency=low | 9 | ofono (1.12phablet7) saucy; urgency=low |
14 | 2 | 10 | ||
15 | 3 | [ Tony Espy ] | 11 | [ Tony Espy ] |
16 | 4 | 12 | ||
17 | === modified file 'drivers/rilmodem/rilutil.c' | |||
18 | --- drivers/rilmodem/rilutil.c 2013-06-14 16:11:01 +0000 | |||
19 | +++ drivers/rilmodem/rilutil.c 2013-07-09 19:18:24 +0000 | |||
20 | @@ -394,24 +394,17 @@ | |||
21 | 394 | 394 | ||
22 | 395 | gboolean ril_util_parse_sim_status(GRil *gril, | 395 | gboolean ril_util_parse_sim_status(GRil *gril, |
23 | 396 | struct ril_msg *message, | 396 | struct ril_msg *message, |
25 | 397 | struct sim_app *app) | 397 | struct sim_status *status, |
26 | 398 | struct sim_app **apps) | ||
27 | 398 | { | 399 | { |
28 | 399 | struct parcel rilp; | 400 | struct parcel rilp; |
29 | 400 | gboolean result = FALSE; | 401 | gboolean result = FALSE; |
34 | 401 | char *aid_str = NULL; | 402 | int i; |
31 | 402 | char *app_str = NULL; | ||
32 | 403 | int i, card_state, num_apps, pin_state, gsm_umts_index, ims_index; | ||
33 | 404 | int app_state, app_type, pin_replaced, pin1_state, pin2_state, perso_substate; | ||
35 | 405 | 403 | ||
36 | 406 | g_ril_append_print_buf(gril, "[%04d]< %s", | 404 | g_ril_append_print_buf(gril, "[%04d]< %s", |
37 | 407 | message->serial_no, | 405 | message->serial_no, |
38 | 408 | ril_request_id_to_string(message->req)); | 406 | ril_request_id_to_string(message->req)); |
39 | 409 | 407 | ||
40 | 410 | if (app) { | ||
41 | 411 | app->app_type = RIL_APPTYPE_UNKNOWN; | ||
42 | 412 | app->app_id = NULL; | ||
43 | 413 | } | ||
44 | 414 | |||
45 | 415 | ril_util_init_parcel(message, &rilp); | 408 | ril_util_init_parcel(message, &rilp); |
46 | 416 | 409 | ||
47 | 417 | /* | 410 | /* |
48 | @@ -420,24 +413,33 @@ | |||
49 | 420 | * This could be a runtime assertion, disconnect, drop/ignore | 413 | * This could be a runtime assertion, disconnect, drop/ignore |
50 | 421 | * the message, ... | 414 | * the message, ... |
51 | 422 | * | 415 | * |
52 | 423 | * Currently if the message is smaller than expected, our parcel | ||
53 | 424 | * code happily walks off the end of the buffer and segfaults. | ||
54 | 425 | * | ||
55 | 426 | * 20 is the min length of RIL_CardStatus_v6 as the AppState | 416 | * 20 is the min length of RIL_CardStatus_v6 as the AppState |
56 | 427 | * array can be 0-length. | 417 | * array can be 0-length. |
57 | 428 | */ | 418 | */ |
58 | 429 | if (message->buf_len < 20) { | 419 | if (message->buf_len < 20) { |
59 | 430 | ofono_error("Size of SIM_STATUS reply too small: %d bytes", | 420 | ofono_error("Size of SIM_STATUS reply too small: %d bytes", |
60 | 431 | message->buf_len); | 421 | message->buf_len); |
62 | 432 | goto done; | 422 | return FALSE; |
63 | 433 | } | 423 | } |
64 | 434 | 424 | ||
71 | 435 | card_state = parcel_r_int32(&rilp); | 425 | status->card_state = parcel_r_int32(&rilp); |
72 | 436 | pin_state = parcel_r_int32(&rilp); | 426 | |
73 | 437 | gsm_umts_index = parcel_r_int32(&rilp); | 427 | /* |
74 | 438 | parcel_r_int32(&rilp); /* ignore: cdma_subscription_app_index */ | 428 | * NOTE: |
75 | 439 | ims_index = parcel_r_int32(&rilp); | 429 | * |
76 | 440 | num_apps = parcel_r_int32(&rilp); | 430 | * The global pin_status is used for multi-application |
77 | 431 | * UICC cards. For example, there are SIM cards that | ||
78 | 432 | * can be used in both GSM and CDMA phones. Instead | ||
79 | 433 | * of managed PINs for both applications, a global PIN | ||
80 | 434 | * is set instead. It's not clear at this point if | ||
81 | 435 | * such SIM cards are supported by ofono or RILD. | ||
82 | 436 | */ | ||
83 | 437 | |||
84 | 438 | status->pin_state = parcel_r_int32(&rilp); | ||
85 | 439 | status->gsm_umts_index = parcel_r_int32(&rilp); | ||
86 | 440 | status->cdma_index = parcel_r_int32(&rilp); | ||
87 | 441 | status->ims_index = parcel_r_int32(&rilp); | ||
88 | 442 | status->num_apps = parcel_r_int32(&rilp); | ||
89 | 441 | 443 | ||
90 | 442 | /* TODO: | 444 | /* TODO: |
91 | 443 | * How do we handle long (>80 chars) ril_append_print_buf strings? | 445 | * How do we handle long (>80 chars) ril_append_print_buf strings? |
92 | @@ -446,60 +448,68 @@ | |||
93 | 446 | */ | 448 | */ |
94 | 447 | g_ril_append_print_buf(gril, | 449 | g_ril_append_print_buf(gril, |
95 | 448 | "(card_state=%d,universal_pin_state=%d,gsm_umts_index=%d,cdma_index=%d,ims_index=%d, ", | 450 | "(card_state=%d,universal_pin_state=%d,gsm_umts_index=%d,cdma_index=%d,ims_index=%d, ", |
106 | 449 | card_state, | 451 | status->card_state, |
107 | 450 | pin_state, | 452 | status->pin_state, |
108 | 451 | gsm_umts_index, | 453 | status->gsm_umts_index, |
109 | 452 | -1, | 454 | status->cdma_index, |
110 | 453 | ims_index); | 455 | status->ims_index); |
111 | 454 | 456 | ||
112 | 455 | for (i = 0; i < num_apps; i++) { | 457 | if (status->card_state == RIL_CARDSTATE_PRESENT) |
113 | 456 | app_type = parcel_r_int32(&rilp); | 458 | result = TRUE; |
114 | 457 | app_state = parcel_r_int32(&rilp); | 459 | else |
115 | 458 | perso_substate = parcel_r_int32(&rilp); | 460 | goto done; |
116 | 461 | |||
117 | 462 | if (status->num_apps > MAX_UICC_APPS) { | ||
118 | 463 | ofono_error("SIM error; too many apps: %d", status->num_apps); | ||
119 | 464 | status->num_apps = MAX_UICC_APPS; | ||
120 | 465 | } | ||
121 | 466 | |||
122 | 467 | for (i = 0; i < status->num_apps; i++) { | ||
123 | 468 | DBG("processing app[%d]", i); | ||
124 | 469 | apps[i] = g_try_new0(struct sim_app, 1); | ||
125 | 470 | if (apps[i] == NULL) { | ||
126 | 471 | ofono_error("Can't allocate app_data"); | ||
127 | 472 | goto error; | ||
128 | 473 | } | ||
129 | 474 | |||
130 | 475 | apps[i]->app_type = parcel_r_int32(&rilp); | ||
131 | 476 | apps[i]->app_state = parcel_r_int32(&rilp); | ||
132 | 477 | apps[i]->perso_substate = parcel_r_int32(&rilp); | ||
133 | 459 | 478 | ||
134 | 460 | /* TODO: we need a way to instruct parcel to skip | 479 | /* TODO: we need a way to instruct parcel to skip |
135 | 461 | * a string, without allocating memory... | 480 | * a string, without allocating memory... |
136 | 462 | */ | 481 | */ |
139 | 463 | aid_str = parcel_r_string(&rilp); /* application ID (AID) */ | 482 | apps[i]->aid_str = parcel_r_string(&rilp); /* application ID (AID) */ |
140 | 464 | app_str = parcel_r_string(&rilp); /* application label */ | 483 | apps[i]->app_str = parcel_r_string(&rilp); /* application label */ |
141 | 465 | 484 | ||
145 | 466 | pin_replaced = parcel_r_int32(&rilp); | 485 | apps[i]->pin_replaced = parcel_r_int32(&rilp); |
146 | 467 | pin1_state = parcel_r_int32(&rilp); | 486 | apps[i]->pin1_state = parcel_r_int32(&rilp); |
147 | 468 | pin2_state = parcel_r_int32(&rilp); | 487 | apps[i]->pin2_state = parcel_r_int32(&rilp); |
148 | 469 | 488 | ||
149 | 470 | g_ril_append_print_buf(gril, | 489 | g_ril_append_print_buf(gril, |
150 | 471 | "%s[app_type=%d,app_state=%d,perso_substate=%d,aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],", | 490 | "%s[app_type=%d,app_state=%d,perso_substate=%d,aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],", |
151 | 472 | print_buf, | 491 | print_buf, |
173 | 473 | app_type, | 492 | apps[i]->app_type, |
174 | 474 | app_state, | 493 | apps[i]->app_state, |
175 | 475 | perso_substate, | 494 | apps[i]->perso_substate, |
176 | 476 | aid_str, | 495 | apps[i]->aid_str, |
177 | 477 | app_str, | 496 | apps[i]->app_str, |
178 | 478 | pin_replaced, | 497 | apps[i]->pin_replaced, |
179 | 479 | pin1_state, | 498 | apps[i]->pin1_state, |
180 | 480 | pin2_state); | 499 | apps[i]->pin2_state); |
160 | 481 | |||
161 | 482 | /* FIXME: CDMA/IMS -- see comment @ top-of-source. */ | ||
162 | 483 | if (i == gsm_umts_index && app) { | ||
163 | 484 | if (aid_str) { | ||
164 | 485 | app->app_id = aid_str; | ||
165 | 486 | DBG("setting app_id (AID) to: %s", aid_str); | ||
166 | 487 | } | ||
167 | 488 | |||
168 | 489 | app->app_type = app_type; | ||
169 | 490 | } else | ||
170 | 491 | g_free(aid_str); | ||
171 | 492 | |||
172 | 493 | g_free(app_str); | ||
181 | 494 | } | 500 | } |
182 | 495 | 501 | ||
183 | 496 | g_ril_append_print_buf(gril, "%s}", print_buf); | ||
184 | 497 | g_ril_print_response(gril, message); | ||
185 | 498 | |||
186 | 499 | if (card_state == RIL_CARDSTATE_PRESENT) | ||
187 | 500 | result = TRUE; | ||
188 | 501 | done: | 502 | done: |
189 | 503 | g_ril_append_print_buf(gril, "%s}", print_buf); | ||
190 | 504 | g_ril_print_response(gril, message); | ||
191 | 505 | |||
192 | 502 | return result; | 506 | return result; |
193 | 507 | |||
194 | 508 | error: | ||
195 | 509 | if (apps) | ||
196 | 510 | ril_util_free_sim_apps(apps, status->num_apps); | ||
197 | 511 | |||
198 | 512 | return FALSE; | ||
199 | 503 | } | 513 | } |
200 | 504 | 514 | ||
201 | 505 | gboolean ril_util_parse_reg(GRil *gril, | 515 | gboolean ril_util_parse_reg(GRil *gril, |
202 | @@ -714,3 +724,13 @@ | |||
203 | 714 | 724 | ||
204 | 715 | return -1; | 725 | return -1; |
205 | 716 | } | 726 | } |
206 | 727 | |||
207 | 728 | void ril_util_free_sim_apps(struct sim_app **apps, guint num_apps) { | ||
208 | 729 | guint i; | ||
209 | 730 | |||
210 | 731 | for (i = 0; i < num_apps; i++) { | ||
211 | 732 | g_free(apps[i]->aid_str); | ||
212 | 733 | g_free(apps[i]->app_str); | ||
213 | 734 | g_free(apps[i]); | ||
214 | 735 | } | ||
215 | 736 | } | ||
216 | 717 | 737 | ||
217 | === modified file 'drivers/rilmodem/rilutil.h' | |||
218 | --- drivers/rilmodem/rilutil.h 2013-06-13 13:31:46 +0000 | |||
219 | +++ drivers/rilmodem/rilutil.h 2013-07-09 19:18:24 +0000 | |||
220 | @@ -62,21 +62,48 @@ | |||
221 | 62 | RIL_UTIL_CHARSET_8859_H = 0x10000, | 62 | RIL_UTIL_CHARSET_8859_H = 0x10000, |
222 | 63 | }; | 63 | }; |
223 | 64 | 64 | ||
224 | 65 | /* TODO: consider moving these to ril_constants.h */ | ||
225 | 66 | enum app_state { | ||
226 | 67 | APPSTATE_UNKNOWN, | ||
227 | 68 | APPSTATE_DETECTED, | ||
228 | 69 | APPSTATE_PIN, | ||
229 | 70 | APPSTATE_PUK, | ||
230 | 71 | APPSTATE_SUBSCRIPTION_PERSO, | ||
231 | 72 | APPSTATE_READY, | ||
232 | 73 | }; | ||
233 | 74 | |||
234 | 65 | struct data_call { | 75 | struct data_call { |
244 | 66 | int status; | 76 | int status; |
245 | 67 | int retry; | 77 | int retry; |
246 | 68 | int cid; | 78 | int cid; |
247 | 69 | int active; | 79 | int active; |
248 | 70 | char * type; | 80 | char *type; |
249 | 71 | char * ifname; | 81 | char *ifname; |
250 | 72 | char * addresses; | 82 | char *addresses; |
251 | 73 | char * dnses; | 83 | char *dnses; |
252 | 74 | char * gateways; | 84 | char *gateways; |
253 | 85 | }; | ||
254 | 86 | |||
255 | 87 | #define MAX_UICC_APPS 16 | ||
256 | 88 | |||
257 | 89 | struct sim_status { | ||
258 | 90 | guint card_state; | ||
259 | 91 | guint pin_state; | ||
260 | 92 | guint gsm_umts_index; | ||
261 | 93 | guint cdma_index; | ||
262 | 94 | guint ims_index; | ||
263 | 95 | guint num_apps; | ||
264 | 75 | }; | 96 | }; |
265 | 76 | 97 | ||
266 | 77 | struct sim_app { | 98 | struct sim_app { |
267 | 78 | char *app_id; | ||
268 | 79 | guint app_type; | 99 | guint app_type; |
269 | 100 | guint app_state; | ||
270 | 101 | guint perso_substate; | ||
271 | 102 | char *aid_str; | ||
272 | 103 | char *app_str; | ||
273 | 104 | guint pin_replaced; | ||
274 | 105 | guint pin1_state; | ||
275 | 106 | guint pin2_state; | ||
276 | 80 | }; | 107 | }; |
277 | 81 | 108 | ||
278 | 82 | typedef void (*ril_util_sim_inserted_cb_t)(gboolean present, void *userdata); | 109 | typedef void (*ril_util_sim_inserted_cb_t)(gboolean present, void *userdata); |
279 | @@ -101,7 +128,9 @@ | |||
280 | 101 | char *ril_util_parse_sim_io_rsp(GRil *gril, struct ril_msg *message, | 128 | char *ril_util_parse_sim_io_rsp(GRil *gril, struct ril_msg *message, |
281 | 102 | int *sw1, int *sw2, | 129 | int *sw1, int *sw2, |
282 | 103 | int *hex_len); | 130 | int *hex_len); |
284 | 104 | gboolean ril_util_parse_sim_status(GRil *gril, struct ril_msg *message, struct sim_app *app); | 131 | gboolean ril_util_parse_sim_status(GRil *gril, struct ril_msg *message, |
285 | 132 | struct sim_status *status, | ||
286 | 133 | struct sim_app **apps); | ||
287 | 105 | gboolean ril_util_parse_reg(GRil *gril, struct ril_msg *message, int *status, | 134 | gboolean ril_util_parse_reg(GRil *gril, struct ril_msg *message, int *status, |
288 | 106 | int *lac, int *ci, int *tech, int *max_calls); | 135 | int *lac, int *ci, int *tech, int *max_calls); |
289 | 107 | 136 | ||
290 | @@ -109,6 +138,8 @@ | |||
291 | 109 | 138 | ||
292 | 110 | gint ril_util_get_signal(GRil *gril, struct ril_msg *message); | 139 | gint ril_util_get_signal(GRil *gril, struct ril_msg *message); |
293 | 111 | 140 | ||
294 | 141 | void ril_util_free_sim_apps(struct sim_app **apps, guint num_apps); | ||
295 | 142 | |||
296 | 112 | struct cb_data { | 143 | struct cb_data { |
297 | 113 | void *cb; | 144 | void *cb; |
298 | 114 | void *data; | 145 | void *data; |
299 | 115 | 146 | ||
300 | === modified file 'drivers/rilmodem/sim.c' | |||
301 | --- drivers/rilmodem/sim.c 2013-06-14 16:11:01 +0000 | |||
302 | +++ drivers/rilmodem/sim.c 2013-07-09 19:18:24 +0000 | |||
303 | @@ -35,6 +35,9 @@ | |||
304 | 35 | #include <ofono/log.h> | 35 | #include <ofono/log.h> |
305 | 36 | #include <ofono/modem.h> | 36 | #include <ofono/modem.h> |
306 | 37 | #include <ofono/sim.h> | 37 | #include <ofono/sim.h> |
307 | 38 | |||
308 | 39 | #include "ofono.h" | ||
309 | 40 | |||
310 | 38 | #include "simutil.h" | 41 | #include "simutil.h" |
311 | 39 | #include "util.h" | 42 | #include "util.h" |
312 | 40 | 43 | ||
313 | @@ -64,6 +67,17 @@ | |||
314 | 64 | /* FID/path of SIM/USIM root directory */ | 67 | /* FID/path of SIM/USIM root directory */ |
315 | 65 | #define ROOTMF "3F00" | 68 | #define ROOTMF "3F00" |
316 | 66 | 69 | ||
317 | 70 | /* RIL_Request* parameter counts */ | ||
318 | 71 | #define GET_IMSI_NUM_PARAMS 1 | ||
319 | 72 | #define ENTER_SIM_PIN_PARAMS 2 | ||
320 | 73 | #define SET_FACILITY_LOCK_PARAMS 5 | ||
321 | 74 | #define ENTER_SIM_PUK_PARAMS 3 | ||
322 | 75 | #define CHANGE_SIM_PIN_PARAMS 3 | ||
323 | 76 | |||
324 | 77 | /* RIL_FACILITY_LOCK parameters */ | ||
325 | 78 | #define RIL_FACILITY_UNLOCK "0" | ||
326 | 79 | #define RIL_FACILITY_LOCK "1" | ||
327 | 80 | |||
328 | 67 | /* | 81 | /* |
329 | 68 | * TODO: CDMA/IMS | 82 | * TODO: CDMA/IMS |
330 | 69 | * | 83 | * |
331 | @@ -77,8 +91,12 @@ | |||
332 | 77 | */ | 91 | */ |
333 | 78 | struct sim_data { | 92 | struct sim_data { |
334 | 79 | GRil *ril; | 93 | GRil *ril; |
336 | 80 | char *app_id; | 94 | gchar *aid_str; |
337 | 81 | guint app_type; | 95 | guint app_type; |
338 | 96 | gchar *app_str; | ||
339 | 97 | guint app_index; | ||
340 | 98 | gboolean sim_registered; | ||
341 | 99 | enum ofono_sim_password_type passwd_state; | ||
342 | 82 | }; | 100 | }; |
343 | 83 | 101 | ||
344 | 84 | static void set_path(struct sim_data *sd, struct parcel *rilp, | 102 | static void set_path(struct sim_data *sd, struct parcel *rilp, |
345 | @@ -245,7 +263,7 @@ | |||
346 | 245 | parcel_w_int32(&rilp, 15); /* P3 - max length */ | 263 | parcel_w_int32(&rilp, 15); /* P3 - max length */ |
347 | 246 | parcel_w_string(&rilp, NULL); /* data; only req'd for writes */ | 264 | parcel_w_string(&rilp, NULL); /* data; only req'd for writes */ |
348 | 247 | parcel_w_string(&rilp, NULL); /* pin2; only req'd for writes */ | 265 | parcel_w_string(&rilp, NULL); /* pin2; only req'd for writes */ |
350 | 248 | parcel_w_string(&rilp, sd->app_id); /* AID (Application ID) */ | 266 | parcel_w_string(&rilp, sd->aid_str); /* AID (Application ID) */ |
351 | 249 | 267 | ||
352 | 250 | ret = g_ril_send(sd->ril, | 268 | ret = g_ril_send(sd->ril, |
353 | 251 | request, | 269 | request, |
354 | @@ -256,7 +274,7 @@ | |||
355 | 256 | g_ril_append_print_buf(sd->ril, | 274 | g_ril_append_print_buf(sd->ril, |
356 | 257 | "%s0,0,15,(null),pin2=(null),aid=%s)", | 275 | "%s0,0,15,(null),pin2=(null),aid=%s)", |
357 | 258 | print_buf, | 276 | print_buf, |
359 | 259 | sd->app_id); | 277 | sd->aid_str); |
360 | 260 | g_ril_print_request(sd->ril, ret, RIL_REQUEST_SIM_IO); | 278 | g_ril_print_request(sd->ril, ret, RIL_REQUEST_SIM_IO); |
361 | 261 | 279 | ||
362 | 262 | parcel_free(&rilp); | 280 | parcel_free(&rilp); |
363 | @@ -330,7 +348,7 @@ | |||
364 | 330 | parcel_w_int32(&rilp, length); /* P3 */ | 348 | parcel_w_int32(&rilp, length); /* P3 */ |
365 | 331 | parcel_w_string(&rilp, NULL); /* data; only req'd for writes */ | 349 | parcel_w_string(&rilp, NULL); /* data; only req'd for writes */ |
366 | 332 | parcel_w_string(&rilp, NULL); /* pin2; only req'd for writes */ | 350 | parcel_w_string(&rilp, NULL); /* pin2; only req'd for writes */ |
368 | 333 | parcel_w_string(&rilp, sd->app_id); /* AID (Application ID) */ | 351 | parcel_w_string(&rilp, sd->aid_str); |
369 | 334 | 352 | ||
370 | 335 | ret = g_ril_send(sd->ril, | 353 | ret = g_ril_send(sd->ril, |
371 | 336 | request, | 354 | request, |
372 | @@ -344,7 +362,7 @@ | |||
373 | 344 | (start >> 8), | 362 | (start >> 8), |
374 | 345 | (start & 0xff), | 363 | (start & 0xff), |
375 | 346 | length, | 364 | length, |
377 | 347 | sd->app_id); | 365 | sd->aid_str); |
378 | 348 | g_ril_print_request(sd->ril, ret, request); | 366 | g_ril_print_request(sd->ril, ret, request); |
379 | 349 | 367 | ||
380 | 350 | parcel_free(&rilp); | 368 | parcel_free(&rilp); |
381 | @@ -383,7 +401,7 @@ | |||
382 | 383 | parcel_w_int32(&rilp, length); /* P3 */ | 401 | parcel_w_int32(&rilp, length); /* P3 */ |
383 | 384 | parcel_w_string(&rilp, NULL); /* data; only req'd for writes */ | 402 | parcel_w_string(&rilp, NULL); /* data; only req'd for writes */ |
384 | 385 | parcel_w_string(&rilp, NULL); /* pin2; only req'd for writes */ | 403 | parcel_w_string(&rilp, NULL); /* pin2; only req'd for writes */ |
386 | 386 | parcel_w_string(&rilp, sd->app_id); /* AID (Application ID) */ | 404 | parcel_w_string(&rilp, sd->aid_str); /* AID (Application ID) */ |
387 | 387 | 405 | ||
388 | 388 | ret = g_ril_send(sd->ril, | 406 | ret = g_ril_send(sd->ril, |
389 | 389 | request, | 407 | request, |
390 | @@ -397,7 +415,7 @@ | |||
391 | 397 | record, | 415 | record, |
392 | 398 | 4, | 416 | 4, |
393 | 399 | length, | 417 | length, |
395 | 400 | sd->app_id); | 418 | sd->aid_str); |
396 | 401 | g_ril_print_request(sd->ril, ret, request); | 419 | g_ril_print_request(sd->ril, ret, request); |
397 | 402 | 420 | ||
398 | 403 | parcel_free(&rilp); | 421 | parcel_free(&rilp); |
399 | @@ -451,13 +469,13 @@ | |||
400 | 451 | cbd->user = sd; | 469 | cbd->user = sd; |
401 | 452 | 470 | ||
402 | 453 | parcel_init(&rilp); | 471 | parcel_init(&rilp); |
405 | 454 | parcel_w_int32(&rilp, 1); /* Number of params */ | 472 | parcel_w_int32(&rilp, GET_IMSI_NUM_PARAMS); |
406 | 455 | parcel_w_string(&rilp, sd->app_id); /* AID (Application ID) */ | 473 | parcel_w_string(&rilp, sd->aid_str); |
407 | 456 | 474 | ||
408 | 457 | ret = g_ril_send(sd->ril, request, | 475 | ret = g_ril_send(sd->ril, request, |
409 | 458 | rilp.data, rilp.size, ril_imsi_cb, cbd, g_free); | 476 | rilp.data, rilp.size, ril_imsi_cb, cbd, g_free); |
410 | 459 | 477 | ||
412 | 460 | g_ril_append_print_buf(sd->ril, "(%s)", sd->app_id); | 478 | g_ril_append_print_buf(sd->ril, "(%s)", sd->aid_str); |
413 | 461 | g_ril_print_request(sd->ril, ret, request); | 479 | g_ril_print_request(sd->ril, ret, request); |
414 | 462 | 480 | ||
415 | 463 | parcel_free(&rilp); | 481 | parcel_free(&rilp); |
416 | @@ -468,25 +486,90 @@ | |||
417 | 468 | } | 486 | } |
418 | 469 | } | 487 | } |
419 | 470 | 488 | ||
420 | 489 | static void configure_active_app(struct sim_data *sd, | ||
421 | 490 | struct sim_app *app, | ||
422 | 491 | guint index) | ||
423 | 492 | { | ||
424 | 493 | size_t aid_size = 0, app_size = 0; | ||
425 | 494 | |||
426 | 495 | sd->app_type = app->app_type; | ||
427 | 496 | sd->aid_str = g_strdup(app->aid_str); | ||
428 | 497 | sd->app_str = g_strdup(app->app_str); | ||
429 | 498 | sd->app_index = index; | ||
430 | 499 | |||
431 | 500 | DBG("setting aid_str (AID) to: %s", sd->aid_str); | ||
432 | 501 | switch (app->app_state) { | ||
433 | 502 | case APPSTATE_PIN: | ||
434 | 503 | sd->passwd_state = OFONO_SIM_PASSWORD_SIM_PIN; | ||
435 | 504 | break; | ||
436 | 505 | case APPSTATE_PUK: | ||
437 | 506 | sd->passwd_state = OFONO_SIM_PASSWORD_SIM_PUK; | ||
438 | 507 | break; | ||
439 | 508 | case APPSTATE_SUBSCRIPTION_PERSO: | ||
440 | 509 | /* TODO: Check out how to dig out exact | ||
441 | 510 | * SIM lock. | ||
442 | 511 | */ | ||
443 | 512 | sd->passwd_state = OFONO_SIM_PASSWORD_PHSIM_PIN; | ||
444 | 513 | break; | ||
445 | 514 | case APPSTATE_READY: | ||
446 | 515 | sd->passwd_state = OFONO_SIM_PASSWORD_NONE; | ||
447 | 516 | break; | ||
448 | 517 | case APPSTATE_UNKNOWN: | ||
449 | 518 | case APPSTATE_DETECTED: | ||
450 | 519 | default: | ||
451 | 520 | sd->passwd_state = OFONO_SIM_PASSWORD_INVALID; | ||
452 | 521 | break; | ||
453 | 522 | } | ||
454 | 523 | } | ||
455 | 524 | |||
456 | 471 | static void sim_status_cb(struct ril_msg *message, gpointer user_data) | 525 | static void sim_status_cb(struct ril_msg *message, gpointer user_data) |
457 | 472 | { | 526 | { |
458 | 473 | struct ofono_sim *sim = user_data; | 527 | struct ofono_sim *sim = user_data; |
459 | 474 | struct sim_data *sd = ofono_sim_get_data(sim); | 528 | struct sim_data *sd = ofono_sim_get_data(sim); |
470 | 475 | struct sim_app app; | 529 | struct sim_app *apps[MAX_UICC_APPS]; |
471 | 476 | 530 | struct sim_status status; | |
472 | 477 | if (ril_util_parse_sim_status(sd->ril, message, &app)) { | 531 | guint i = 0; |
473 | 478 | if (app.app_id) | 532 | guint search_index = -1; |
474 | 479 | sd->app_id = app.app_id; | 533 | |
475 | 480 | 534 | if (ril_util_parse_sim_status(sd->ril, message, &status, apps) && | |
476 | 481 | if (app.app_type != RIL_APPTYPE_UNKNOWN) | 535 | status.num_apps) { |
477 | 482 | sd->app_type = app.app_type; | 536 | |
478 | 483 | 537 | DBG("num_apps: %d gsm_umts_index: %d", status.num_apps, | |
479 | 484 | ofono_sim_register(sim); | 538 | status.gsm_umts_index); |
480 | 539 | |||
481 | 540 | /* TODO(CDMA): need some kind of logic to | ||
482 | 541 | * set the correct app_index, | ||
483 | 542 | */ | ||
484 | 543 | search_index = status.gsm_umts_index; | ||
485 | 544 | |||
486 | 545 | for (i = 0; i < status.num_apps; i++) { | ||
487 | 546 | if (i == search_index && | ||
488 | 547 | apps[i]->app_type != RIL_APPTYPE_UNKNOWN) { | ||
489 | 548 | configure_active_app(sd, apps[i], i); | ||
490 | 549 | break; | ||
491 | 550 | } | ||
492 | 551 | } | ||
493 | 552 | |||
494 | 553 | if (sd->sim_registered == FALSE) { | ||
495 | 554 | ofono_sim_register(sim); | ||
496 | 555 | sd->sim_registered = TRUE; | ||
497 | 556 | } else | ||
498 | 557 | /* TODO: There doesn't seem to be any other | ||
499 | 558 | * way to force the core SIM code to | ||
500 | 559 | * recheck the PIN. | ||
501 | 560 | * Wouldn't __ofono_sim_refresh be | ||
502 | 561 | * more appropriate call here?? | ||
503 | 562 | * __ofono_sim_refresh(sim, NULL, TRUE, TRUE); | ||
504 | 563 | */ | ||
505 | 564 | __ofono_sim_recheck_pin(sim); | ||
506 | 565 | |||
507 | 566 | ril_util_free_sim_apps(apps, status.num_apps); | ||
508 | 485 | } | 567 | } |
509 | 486 | 568 | ||
510 | 487 | /* TODO: if no SIM present, handle emergency calling. */ | 569 | /* TODO: if no SIM present, handle emergency calling. */ |
511 | 488 | } | 570 | } |
512 | 489 | 571 | ||
513 | 572 | |||
514 | 490 | static int send_get_sim_status(struct ofono_sim *sim) | 573 | static int send_get_sim_status(struct ofono_sim *sim) |
515 | 491 | { | 574 | { |
516 | 492 | struct sim_data *sd = ofono_sim_get_data(sim); | 575 | struct sim_data *sd = ofono_sim_get_data(sim); |
517 | @@ -501,13 +584,265 @@ | |||
518 | 501 | return ret; | 584 | return ret; |
519 | 502 | } | 585 | } |
520 | 503 | 586 | ||
521 | 587 | static void ril_sim_status_changed(struct ril_msg *message, gpointer user_data) | ||
522 | 588 | { | ||
523 | 589 | struct ofono_sim *sim = (struct ofono_sim *) user_data; | ||
524 | 590 | struct sim_data *sd = ofono_sim_get_data(sim); | ||
525 | 591 | |||
526 | 592 | DBG(""); | ||
527 | 593 | |||
528 | 594 | g_ril_print_unsol_no_args(sd->ril, message); | ||
529 | 595 | |||
530 | 596 | send_get_sim_status(sim); | ||
531 | 597 | } | ||
532 | 598 | |||
533 | 599 | static void ril_query_passwd_state(struct ofono_sim *sim, | ||
534 | 600 | ofono_sim_passwd_cb_t cb, void *data) | ||
535 | 601 | { | ||
536 | 602 | struct sim_data *sd = ofono_sim_get_data(sim); | ||
537 | 603 | DBG("passwd_state %u", sd->passwd_state); | ||
538 | 604 | |||
539 | 605 | if (sd->passwd_state == OFONO_SIM_PASSWORD_INVALID) | ||
540 | 606 | CALLBACK_WITH_FAILURE(cb, -1, data); | ||
541 | 607 | |||
542 | 608 | CALLBACK_WITH_SUCCESS(cb, sd->passwd_state, data); | ||
543 | 609 | } | ||
544 | 610 | |||
545 | 611 | static void ril_pin_change_state_cb(struct ril_msg *message, gpointer user_data) | ||
546 | 612 | { | ||
547 | 613 | struct cb_data *cbd = user_data; | ||
548 | 614 | ofono_sim_lock_unlock_cb_t cb = cbd->cb; | ||
549 | 615 | struct sim_data *sd = cbd->user; | ||
550 | 616 | |||
551 | 617 | /* There is no reason to ask SIM status until | ||
552 | 618 | * unsolicited sim status change indication | ||
553 | 619 | * Looks like state does not change before that. | ||
554 | 620 | */ | ||
555 | 621 | |||
556 | 622 | /* TODO: re-bfactor to not use macro for FAILURE; doesn't return error! */ | ||
557 | 623 | if (message->error == RIL_E_SUCCESS) { | ||
558 | 624 | CALLBACK_WITH_SUCCESS(cb, cbd->data); | ||
559 | 625 | g_ril_print_response_no_args(sd->ril, message); | ||
560 | 626 | |||
561 | 627 | } else | ||
562 | 628 | CALLBACK_WITH_FAILURE(cb, cbd->data); | ||
563 | 629 | |||
564 | 630 | } | ||
565 | 631 | |||
566 | 632 | static void ril_pin_send(struct ofono_sim *sim, const char *passwd, | ||
567 | 633 | ofono_sim_lock_unlock_cb_t cb, void *data) | ||
568 | 634 | { | ||
569 | 635 | struct sim_data *sd = ofono_sim_get_data(sim); | ||
570 | 636 | struct cb_data *cbd = cb_data_new(cb, data); | ||
571 | 637 | struct parcel rilp; | ||
572 | 638 | int request = RIL_REQUEST_ENTER_SIM_PIN; | ||
573 | 639 | int ret; | ||
574 | 640 | |||
575 | 641 | cbd->user = sd; | ||
576 | 642 | |||
577 | 643 | parcel_init(&rilp); | ||
578 | 644 | |||
579 | 645 | parcel_w_int32(&rilp, ENTER_SIM_PIN_PARAMS); | ||
580 | 646 | parcel_w_string(&rilp, (char *) passwd); | ||
581 | 647 | parcel_w_string(&rilp, sd->aid_str); | ||
582 | 648 | |||
583 | 649 | ret = g_ril_send(sd->ril, request, | ||
584 | 650 | rilp.data, rilp.size, ril_pin_change_state_cb, | ||
585 | 651 | cbd, g_free); | ||
586 | 652 | |||
587 | 653 | g_ril_append_print_buf(sd->ril, "(%s,aid=%s)", passwd, sd->aid_str); | ||
588 | 654 | g_ril_print_request(sd->ril, ret, request); | ||
589 | 655 | |||
590 | 656 | parcel_free(&rilp); | ||
591 | 657 | |||
592 | 658 | if (ret <= 0) { | ||
593 | 659 | g_free(cbd); | ||
594 | 660 | CALLBACK_WITH_FAILURE(cb, data); | ||
595 | 661 | } | ||
596 | 662 | } | ||
597 | 663 | |||
598 | 664 | static void ril_pin_change_state(struct ofono_sim *sim, | ||
599 | 665 | enum ofono_sim_password_type passwd_type, | ||
600 | 666 | int enable, const char *passwd, | ||
601 | 667 | ofono_sim_lock_unlock_cb_t cb, void *data) | ||
602 | 668 | { | ||
603 | 669 | struct sim_data *sd = ofono_sim_get_data(sim); | ||
604 | 670 | struct cb_data *cbd = cb_data_new(cb, data); | ||
605 | 671 | struct parcel rilp; | ||
606 | 672 | int request = RIL_REQUEST_SET_FACILITY_LOCK; | ||
607 | 673 | int ret = 0; | ||
608 | 674 | |||
609 | 675 | cbd->user = sd; | ||
610 | 676 | |||
611 | 677 | parcel_init(&rilp); | ||
612 | 678 | parcel_w_int32(&rilp, SET_FACILITY_LOCK_PARAMS); | ||
613 | 679 | |||
614 | 680 | /* | ||
615 | 681 | * TODO: clean up the use of string literals & | ||
616 | 682 | * the multiple g_ril_append_print_buf() calls | ||
617 | 683 | * by using a table lookup as does the core sim code | ||
618 | 684 | */ | ||
619 | 685 | switch (passwd_type) { | ||
620 | 686 | case OFONO_SIM_PASSWORD_SIM_PIN: | ||
621 | 687 | g_ril_append_print_buf(sd->ril, "(SC,"); | ||
622 | 688 | parcel_w_string(&rilp, "SC"); | ||
623 | 689 | break; | ||
624 | 690 | case OFONO_SIM_PASSWORD_PHSIM_PIN: | ||
625 | 691 | g_ril_append_print_buf(sd->ril, "(PS,"); | ||
626 | 692 | parcel_w_string(&rilp, "PS"); | ||
627 | 693 | break; | ||
628 | 694 | case OFONO_SIM_PASSWORD_PHFSIM_PIN: | ||
629 | 695 | g_ril_append_print_buf(sd->ril, "(PF,"); | ||
630 | 696 | parcel_w_string(&rilp, "PF"); | ||
631 | 697 | break; | ||
632 | 698 | case OFONO_SIM_PASSWORD_SIM_PIN2: | ||
633 | 699 | g_ril_append_print_buf(sd->ril, "(P2,"); | ||
634 | 700 | parcel_w_string(&rilp, "P2"); | ||
635 | 701 | break; | ||
636 | 702 | case OFONO_SIM_PASSWORD_PHNET_PIN: | ||
637 | 703 | g_ril_append_print_buf(sd->ril, "(PN,"); | ||
638 | 704 | parcel_w_string(&rilp, "PN"); | ||
639 | 705 | break; | ||
640 | 706 | case OFONO_SIM_PASSWORD_PHNETSUB_PIN: | ||
641 | 707 | g_ril_append_print_buf(sd->ril, "(PU,"); | ||
642 | 708 | parcel_w_string(&rilp, "PU"); | ||
643 | 709 | break; | ||
644 | 710 | case OFONO_SIM_PASSWORD_PHSP_PIN: | ||
645 | 711 | g_ril_append_print_buf(sd->ril, "(PP,"); | ||
646 | 712 | parcel_w_string(&rilp, "PP"); | ||
647 | 713 | break; | ||
648 | 714 | case OFONO_SIM_PASSWORD_PHCORP_PIN: | ||
649 | 715 | g_ril_append_print_buf(sd->ril, "(PC,"); | ||
650 | 716 | parcel_w_string(&rilp, "PC"); | ||
651 | 717 | break; | ||
652 | 718 | default: | ||
653 | 719 | CALLBACK_WITH_FAILURE(cb, data); | ||
654 | 720 | return; | ||
655 | 721 | } | ||
656 | 722 | |||
657 | 723 | if (enable) | ||
658 | 724 | parcel_w_string(&rilp, RIL_FACILITY_LOCK); | ||
659 | 725 | else | ||
660 | 726 | parcel_w_string(&rilp, RIL_FACILITY_UNLOCK); | ||
661 | 727 | |||
662 | 728 | parcel_w_string(&rilp, (char *) passwd); | ||
663 | 729 | |||
664 | 730 | /* TODO: make this a constant... */ | ||
665 | 731 | parcel_w_string(&rilp, "0"); /* class */ | ||
666 | 732 | |||
667 | 733 | parcel_w_string(&rilp, sd->aid_str); | ||
668 | 734 | |||
669 | 735 | ret = g_ril_send(sd->ril, request, | ||
670 | 736 | rilp.data, rilp.size, ril_pin_change_state_cb, | ||
671 | 737 | cbd, g_free); | ||
672 | 738 | |||
673 | 739 | g_ril_append_print_buf(sd->ril, "%s,%d,%s,0,aid=%s)", | ||
674 | 740 | print_buf, | ||
675 | 741 | enable, | ||
676 | 742 | passwd, | ||
677 | 743 | sd->aid_str); | ||
678 | 744 | |||
679 | 745 | g_ril_print_request(sd->ril, ret, request); | ||
680 | 746 | |||
681 | 747 | parcel_free(&rilp); | ||
682 | 748 | |||
683 | 749 | if (ret <= 0) { | ||
684 | 750 | g_free(cbd); | ||
685 | 751 | CALLBACK_WITH_FAILURE(cb, data); | ||
686 | 752 | } | ||
687 | 753 | } | ||
688 | 754 | |||
689 | 755 | static void ril_pin_send_puk(struct ofono_sim *sim, | ||
690 | 756 | const char *puk, const char *passwd, | ||
691 | 757 | ofono_sim_lock_unlock_cb_t cb, void *data) | ||
692 | 758 | { | ||
693 | 759 | struct sim_data *sd = ofono_sim_get_data(sim); | ||
694 | 760 | struct cb_data *cbd = cb_data_new(cb, data); | ||
695 | 761 | struct parcel rilp; | ||
696 | 762 | int request = RIL_REQUEST_ENTER_SIM_PUK; | ||
697 | 763 | int ret = 0; | ||
698 | 764 | |||
699 | 765 | cbd->user = sd; | ||
700 | 766 | |||
701 | 767 | parcel_init(&rilp); | ||
702 | 768 | |||
703 | 769 | parcel_w_int32(&rilp, ENTER_SIM_PUK_PARAMS); | ||
704 | 770 | parcel_w_string(&rilp, (char *) puk); | ||
705 | 771 | parcel_w_string(&rilp, (char *) passwd); | ||
706 | 772 | parcel_w_string(&rilp, sd->aid_str); | ||
707 | 773 | |||
708 | 774 | ret = g_ril_send(sd->ril, request, | ||
709 | 775 | rilp.data, rilp.size, ril_pin_change_state_cb, | ||
710 | 776 | cbd, g_free); | ||
711 | 777 | |||
712 | 778 | g_ril_append_print_buf(sd->ril, "(puk=%s,pin=%s,aid=%s)", | ||
713 | 779 | puk, passwd, | ||
714 | 780 | sd->aid_str); | ||
715 | 781 | |||
716 | 782 | g_ril_print_request(sd->ril, ret, request); | ||
717 | 783 | |||
718 | 784 | parcel_free(&rilp); | ||
719 | 785 | |||
720 | 786 | if (ret <= 0) { | ||
721 | 787 | g_free(cbd); | ||
722 | 788 | CALLBACK_WITH_FAILURE(cb, data); | ||
723 | 789 | } | ||
724 | 790 | } | ||
725 | 791 | |||
726 | 792 | static void ril_change_passwd(struct ofono_sim *sim, | ||
727 | 793 | enum ofono_sim_password_type passwd_type, | ||
728 | 794 | const char *old, const char *new, | ||
729 | 795 | ofono_sim_lock_unlock_cb_t cb, void *data) | ||
730 | 796 | { | ||
731 | 797 | struct sim_data *sd = ofono_sim_get_data(sim); | ||
732 | 798 | struct cb_data *cbd = cb_data_new(cb, data); | ||
733 | 799 | struct parcel rilp; | ||
734 | 800 | int request = RIL_REQUEST_CHANGE_SIM_PIN; | ||
735 | 801 | int ret = 0; | ||
736 | 802 | |||
737 | 803 | cbd->user = sd; | ||
738 | 804 | |||
739 | 805 | parcel_init(&rilp); | ||
740 | 806 | |||
741 | 807 | parcel_w_int32(&rilp, CHANGE_SIM_PIN_PARAMS); | ||
742 | 808 | parcel_w_string(&rilp, (char *) old); /* PUK */ | ||
743 | 809 | parcel_w_string(&rilp, (char *) new); /* PIN */ | ||
744 | 810 | parcel_w_string(&rilp, sd->aid_str); | ||
745 | 811 | |||
746 | 812 | if (passwd_type == OFONO_SIM_PASSWORD_SIM_PIN2) | ||
747 | 813 | request = RIL_REQUEST_CHANGE_SIM_PIN2; | ||
748 | 814 | |||
749 | 815 | ret = g_ril_send(sd->ril, request, rilp.data, rilp.size, | ||
750 | 816 | ril_pin_change_state_cb, cbd, g_free); | ||
751 | 817 | |||
752 | 818 | g_ril_append_print_buf(sd->ril, "(old=%s,new=%s,aid=%s)", | ||
753 | 819 | old, new, | ||
754 | 820 | sd->aid_str); | ||
755 | 821 | |||
756 | 822 | g_ril_print_request(sd->ril, ret, request); | ||
757 | 823 | |||
758 | 824 | parcel_free(&rilp); | ||
759 | 825 | |||
760 | 826 | if (ret <= 0) { | ||
761 | 827 | g_free(cbd); | ||
762 | 828 | CALLBACK_WITH_FAILURE(cb, data); | ||
763 | 829 | } | ||
764 | 830 | } | ||
765 | 831 | |||
766 | 504 | static gboolean ril_sim_register(gpointer user) | 832 | static gboolean ril_sim_register(gpointer user) |
767 | 505 | { | 833 | { |
768 | 506 | struct ofono_sim *sim = user; | 834 | struct ofono_sim *sim = user; |
773 | 507 | 835 | struct sim_data *sd = ofono_sim_get_data(sim); | |
774 | 508 | DBG(""); | 836 | |
775 | 509 | 837 | DBG(""); | |
776 | 510 | send_get_sim_status(sim); | 838 | |
777 | 839 | send_get_sim_status(sim); | ||
778 | 840 | |||
779 | 841 | g_ril_register(sd->ril, RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, | ||
780 | 842 | (GRilNotifyFunc) ril_sim_status_changed, sim); | ||
781 | 843 | |||
782 | 844 | /* TODO: should we also register for RIL_UNSOL_SIM_REFRESH? */ | ||
783 | 845 | |||
784 | 511 | return FALSE; | 846 | return FALSE; |
785 | 512 | } | 847 | } |
786 | 513 | 848 | ||
787 | @@ -519,8 +854,11 @@ | |||
788 | 519 | 854 | ||
789 | 520 | sd = g_new0(struct sim_data, 1); | 855 | sd = g_new0(struct sim_data, 1); |
790 | 521 | sd->ril = g_ril_clone(ril); | 856 | sd->ril = g_ril_clone(ril); |
792 | 522 | sd->app_id = NULL; | 857 | sd->aid_str = NULL; |
793 | 858 | sd->app_str = NULL; | ||
794 | 523 | sd->app_type = RIL_APPTYPE_UNKNOWN; | 859 | sd->app_type = RIL_APPTYPE_UNKNOWN; |
795 | 860 | sd->passwd_state = OFONO_SIM_PASSWORD_NONE; | ||
796 | 861 | sd->sim_registered = FALSE; | ||
797 | 524 | 862 | ||
798 | 525 | ofono_sim_set_data(sim, sd); | 863 | ofono_sim_set_data(sim, sd); |
799 | 526 | 864 | ||
800 | @@ -559,6 +897,11 @@ | |||
801 | 559 | .read_file_linear = ril_sim_read_record, | 897 | .read_file_linear = ril_sim_read_record, |
802 | 560 | .read_file_cyclic = ril_sim_read_record, | 898 | .read_file_cyclic = ril_sim_read_record, |
803 | 561 | .read_imsi = ril_read_imsi, | 899 | .read_imsi = ril_read_imsi, |
804 | 900 | .query_passwd_state = ril_query_passwd_state, | ||
805 | 901 | .send_passwd = ril_pin_send, | ||
806 | 902 | .lock = ril_pin_change_state, | ||
807 | 903 | .reset_passwd = ril_pin_send_puk, | ||
808 | 904 | .change_passwd = ril_change_passwd, | ||
809 | 562 | /* | 905 | /* |
810 | 563 | * TODO: Implmenting PIN/PUK support requires defining | 906 | * TODO: Implmenting PIN/PUK support requires defining |
811 | 564 | * the following driver methods. | 907 | * the following driver methods. |
812 | @@ -568,12 +911,7 @@ | |||
813 | 568 | * presence of query_passwd_state, and if null, then the | 911 | * presence of query_passwd_state, and if null, then the |
814 | 569 | * function sim_initialize_after_pin() is called. | 912 | * function sim_initialize_after_pin() is called. |
815 | 570 | * | 913 | * |
816 | 571 | * .query_passwd_state = ril_pin_query, | ||
817 | 572 | * .query_pin_retries = ril_pin_retries_query, | 914 | * .query_pin_retries = ril_pin_retries_query, |
818 | 573 | * .send_passwd = ril_pin_send, | ||
819 | 574 | * .reset_passwd = ril_pin_send_puk, | ||
820 | 575 | * .lock = ril_pin_enable, | ||
821 | 576 | * .change_passwd = ril_change_passwd, | ||
822 | 577 | * .query_locked = ril_pin_query_enabled, | 915 | * .query_locked = ril_pin_query_enabled, |
823 | 578 | * | 916 | * |
824 | 579 | * TODO: Implementing SIM write file IO support requires | 917 | * TODO: Implementing SIM write file IO support requires |
825 | 580 | 918 | ||
826 | === modified file 'plugins/ril.c' | |||
827 | --- plugins/ril.c 2013-06-17 17:17:45 +0000 | |||
828 | +++ plugins/ril.c 2013-07-09 19:18:24 +0000 | |||
829 | @@ -131,6 +131,9 @@ | |||
830 | 131 | { | 131 | { |
831 | 132 | struct ofono_modem *modem = user_data; | 132 | struct ofono_modem *modem = user_data; |
832 | 133 | struct ril_data *ril = ofono_modem_get_data(modem); | 133 | struct ril_data *ril = ofono_modem_get_data(modem); |
833 | 134 | struct sim_status status; | ||
834 | 135 | struct sim_app *apps[MAX_UICC_APPS]; | ||
835 | 136 | guint i = 0; | ||
836 | 134 | 137 | ||
837 | 135 | DBG(""); | 138 | DBG(""); |
838 | 136 | 139 | ||
839 | @@ -153,12 +156,16 @@ | |||
840 | 153 | else | 156 | else |
841 | 154 | ofono_error("Max retries for GET_SIM_STATUS exceeded!"); | 157 | ofono_error("Max retries for GET_SIM_STATUS exceeded!"); |
842 | 155 | } else { | 158 | } else { |
843 | 159 | |||
844 | 156 | /* Returns TRUE if cardstate == PRESENT */ | 160 | /* Returns TRUE if cardstate == PRESENT */ |
850 | 157 | if (ril_util_parse_sim_status(ril->modem, message, NULL)) { | 161 | if (ril_util_parse_sim_status(ril->modem, message, |
851 | 158 | DBG("have_sim = TRUE; powering on modem."); | 162 | &status, apps)) { |
852 | 159 | 163 | DBG("have_sim = TRUE; powering on modem; num_apps: %d", | |
853 | 160 | /* TODO: check PinState=DISABLED, for now just | 164 | status.num_apps); |
854 | 161 | * set state to valid... */ | 165 | |
855 | 166 | if (status.num_apps) | ||
856 | 167 | ril_util_free_sim_apps(apps, status.num_apps); | ||
857 | 168 | |||
858 | 162 | ril->have_sim = TRUE; | 169 | ril->have_sim = TRUE; |
859 | 163 | power_on(modem); | 170 | power_on(modem); |
860 | 164 | } else | 171 | } else |
PASSED: Continuous integration, rev:47 jenkins. qa.ubuntu. com/job/ phablet- extras- ofono-ci/ 49/ jenkins. qa.ubuntu. com/job/ phablet- extras- ofono-saucy- armhf-ci/ 24 jenkins. qa.ubuntu. com/job/ phablet- extras- ofono-saucy- armhf-ci/ 24/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ phablet- extras- ofono-ci/ 49/rebuild
http://