comparison g23m/condat/ms/src/mfw/mfw_sim.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_sim.c $|
4 | $Author:: Vo $Revision:: 1 $|
5 | CREATED: 13.10.98 $Modtime:: 22.03.00 17:21 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : MFW_SIM
10
11 PURPOSE : This modul contains the functions for SIM management.
12
13
14 $History:: mfw_sim.c
15
16 Feb 15, 2006 ER: OMAPS00065203 x0pleela
17 Description: Cingular Operator Name Prioritization implementation required
18 Solution: Incorporated review comments
19 Combined both checks for services 51 and 52 in rAT_PlusCFUNP
20
21 Feb 09, 2006 ER: OMAPS00065203 x0pleela
22 Description: Cingular Operator Name Prioritization implementation required
23 Solution: Check for services 51 - OPL and 52 - PNN in function rAT_PlusCFUNP and
24 gEons_alloc_active is updated accordingly
25
26 Nov 24, 2005 DR: OMAPS00045909 - Shashi Shekar B.S.
27 Description: Improve IMEI control mechanism
28 Solution : When MMI calls sAT_PLUSCFUN, if an IMEI invalid error is returned,
29 we will block on that screen & will not allow the user to browse menus further,
30 since the PS will not be booted at all!!!
31
32 Nov 15,2005 DR : OMAPS00057280 - x0034700
33 Description: Compilation Errors in Neptune build while integrating latest MMI Changes
34 Solution: Included the compilation FLAG "NEPTUNE_BOARD" for un wanted code for Neptune build
35
36 Nov 03, 2005 DR: OMAPS00052032 - xpradipg
37 Description : Locosto: SIMP - integration of issues submitted by solDel on
38 ME Personalization - changes as per the new interfaces
39 Solution : The return value of sAT_PlusCLCK of AT_EXCT is handled and
40 a please wait screen is displayed until the response is recieved
41
42 Nov 03, 2005 DR: OMAPS00050595 - xpradipg
43 Description: SIMP: If the SIM is blocked (by entering invalid PIN1), the user is
44 not able to unblock it even after entering the valid PUK1
45 Solution : The global flag for SIM Personlaization PUK request was set even
46 for the SIM PUK request. This setting is removed. Also the condition
47 check has been done first for the global flag and then the rest of the
48 checks.
49
50 Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
51 Description: Integration changes required with new aci labe
52 Solution: changes to adopt to the new ACI label
53
54 July 19, 2005 REF: CRR LOCOSTO-ENH-28173 xpradipg
55 Description: To provide MMI Support to enable/disable/change password and
56 query all the Personalization locks
57 Solution: Integration of the changes for the same provided by the soldel
58 team
59
60 Aug 16, 2004 REF: CRR 24323 Deepa M.D
61 Bug:Clenup of sprintf used for tracing
62 Fix:Replace the char buf[]; sprintf (buf, "...", ...); TRACE_EVENT (buf); statements by TRACE_EVENT_PX $
63 * * ***************** Version 43 *****************
64 * User: MC Date: 14.11.02 Time: 10:40
65 * Updated in $/BMI/Condat/MS/SRC/MFW
66 * Changed simlock functions into wrappers for aci_slock functions, and
67 * removed variables definitions and helper functions rendered obsolete.
68 *
69 * ***************** Version 43 *****************
70 * User: Vo Date: 22.03.00 Time: 17:29
71 * Updated in $/GSM/Condat/MS/SRC/MFW
72 * Add new parameter PIN type in structure T_MFW_SIM_STATUS to
73 * identify PIN type
74 * Change in SIM lock
75 *
76 * ***************** Version 42 *****************
77 * User: Es Date: 2.03.00 Time: 16:18
78 * Updated in $/GSM/Condat/MS/SRC/MFW
79 * use 'aci_delete()' instead of 'aci_ext_init()' to clear the
80 * primitive routing for mfw_sim. (because other routings may have to
81 * be preserved!)
82 *
83 * ***************** Version 41 *****************
84 * User: Vo Date: 22.12.99 Time: 16:03
85 * Updated in $/GSM/Condat/MS/SRC/MFW
86 * Remove maximum preferred PLMN records and used preferred PLMN
87 * records in local memory
88 *
89 * ***************** Version 40 *****************
90 * User: Vo Date: 2.12.99 Time: 13:18
91 * Updated in $/GSM/Condat/MS/SRC/MFW
92 * New: request of max/used perferred PLMN list
93 *
94 * ***************** Version 39 *****************
95 * User: Vo Date: 17.11.99 Time: 11:37
96 * Updated in $/GSM/Condat/MS/SRC/MFW
97 * Bug fix: de-personalisation for SIM lock
98 * New: SIM inserted
99 *
100 * ***************** Version 38 *****************
101 * User: Vo Date: 21.10.99 Time: 13:26
102 * Updated in $/GSM/Condat/MS/SRC/MFW
103 * add response of de-registration
104 |
105 | ***************** Version 37 *****************
106 | User: Le Date: 11.10.99 Time: 16:27
107 | Updated in $/GSM/Condat/MS/SRC/MFW
108 |
109 | ***************** Version 36 *****************
110 | User: Le Date: 8.10.99 Time: 13:38
111 | Updated in $/GSM/Condat/MS/SRC/MFW
112 |
113 | ***************** Version 35 *****************
114 | User: Le Date: 4.10.99 Time: 10:33
115 | Updated in $/GSM/Condat/MS/SRC/MFW
116 *
117 * ***************** Version 34 *****************
118 * User: Es Date: 29.09.99 Time: 11:20
119 * Updated in $/GSM/DEV/MS/SRC/MFW
120 * including CFUN_OK enhancement by AK, not fully implemented
121 *
122 * ***************** Version 33 *****************
123 * User: Es Date: 16.09.99 Time: 16:56
124 * Updated in $/GSM/DEV/MS/SRC/MFW
125 * reordered include statements due to addons in mfw_phb.h
126 *
127 * ***************** Version 32 *****************
128 * User: Vo Date: 13.09.99 Time: 12:05
129 * Updated in $/GSM/DEV/MS/SRC/MFW
130 * change comment
131 *
132 * ***************** Version 31 *****************
133 * User: Vo Date: 12.09.99 Time: 15:32
134 * Updated in $/GSM/DEV/MS/SRC/MFW
135 * Bug fix: change PIN
136 * Bug fix/New: SIM lock
137 * New: request of PIN status
138 * New: save preferred language
139 * New: read group identifier level 1 & 2
140 *
141 * ***************** Version 30 *****************
142 * User: Vo Date: 30.08.99 Time: 14:23
143 * Updated in $/GSM/DEV/MS/SRC/MFW
144 * bug fix
145 * new function
146 *
147 * ***************** Version 29 *****************
148 * User: Vo Date: 9.08.99 Time: 13:11
149 * Updated in $/GSM/DEV/MS/SRC/MFW
150 * PIN/PUK count
151 *
152 * ***************** Version 28 *****************
153 * User: Vo Date: 26.07.99 Time: 14:34
154 * Updated in $/GSM/DEV/MS/SRC/MFW
155 * Move include file mfw_cb.h
156 *
157 * ***************** Version 27 *****************
158 * User: Vo Date: 21.07.99 Time: 14:41
159 * Updated in $/GSM/DEV/MS/SRC/MFW
160 *
161 * ***************** Version 26 *****************
162 * User: Vo Date: 16.07.99 Time: 13:50
163 * Updated in $/GSM/DEV/MS/SRC/MFW
164 *
165 * ***************** Version 25 *****************
166 * User: Vo Date: 9.07.99 Time: 14:34
167 * Updated in $/GSM/DEV/MS/SRC/MFW
168 *
169 * ***************** Version 24 *****************
170 * User: Vo Date: 2.07.99 Time: 19:03
171 * Updated in $/GSM/DEV/MS/SRC/MFW
172 *
173 * ***************** Version 23 *****************
174 * User: Vo Date: 28.05.99 Time: 9:52
175 * Updated in $/GSM/DEV/MS/SRC/MFW
176 *
177 * ***************** Version 22 *****************
178 * User: Vo Date: 31.03.99 Time: 14:09
179 * Updated in $/GSM/DEV/MS/SRC/MFW
180 *
181 * ***************** Version 21 *****************
182 * User: Es Date: 15.03.99 Time: 18:21
183 * Updated in $/GSM/DEV/MS/SRC/MFW
184 * recode
185 *
186 * ***************** Version 20 *****************
187 * User: Vo Date: 25.02.99 Time: 16:47
188 * Updated in $/GSM/DEV/MS/SRC/MFW
189 *
190 * ***************** Version 19 *****************
191 * User: Vo Date: 17.02.99 Time: 19:03
192 * Updated in $/GSM/DEV/MS/SRC/MFW
193 *
194 * ***************** Version 18 *****************
195 * User: Vo Date: 12.02.99 Time: 18:05
196 * Updated in $/GSM/DEV/MS/SRC/MFW
197 *
198 * ***************** Version 17 *****************
199 * User: Vo Date: 12.02.99 Time: 17:46
200 * Updated in $/GSM/DEV/MS/SRC/MFW
201 *
202 * ***************** Version 16 *****************
203 * User: Vo Date: 9.02.99 Time: 14:54
204 * Updated in $/GSM/DEV/MS/SRC/MFW
205 *
206 * ***************** Version 15 *****************
207 * User: Vo Date: 12.01.99 Time: 14:27
208 * Updated in $/GSM/DEV/MS/SRC/MFW
209 *
210 * ***************** Version 14 *****************
211 * User: Es Date: 23.12.98 Time: 15:47
212 * Updated in $/GSM/DEV/MS/SRC/MFW
213 *
214 * ***************** Version 12 *****************
215 * User: Es Date: 18.12.98 Time: 13:05
216 * Updated in $/GSM/DEV/MS/SRC/MFW
217 *
218 * ***************** Version 11 *****************
219 * User: Vo Date: 17.12.98 Time: 14:31
220 * Updated in $/GSM/DEV/MS/SRC/MFW
221 *
222 * ***************** Version 10 *****************
223 * User: Es Date: 8.12.98 Time: 16:53
224 * Updated in $/GSM/DEV/MS/SRC/MFW
225 *
226 * ***************** Version 8 *****************
227 * User: Vo Date: 24.11.98 Time: 21:40
228 * Updated in $/GSM/DEV/MS/SRC/MFW
229 * first successful compilation of MFW
230 |
231 | ***************** Version 6 *****************
232 | User: Le Date: 11.11.98 Time: 13:35
233 | Updated in $/GSM/DEV/MS/SRC/MFW
234 |
235 | ***************** Version 5 *****************
236 | User: Le Date: 10.11.98 Time: 16:07
237 | Updated in $/GSM/DEV/MS/SRC/MFW
238 |
239 | ***************** Version 4 *****************
240 | User: Le Date: 10.11.98 Time: 11:08
241 | Updated in $/GSM/DEV/MS/SRC/MFW
242 |
243 | ***************** Version 3 *****************
244 | User: Le Date: 27.10.98 Time: 15:59
245 | Updated in $/GSM/DEV/MS/SRC/MFW
246 |
247 | ***************** Version 2 *****************
248 | User: Le Date: 21.10.98 Time: 16:20
249 | Updated in $/GSM/DEV/MS/SRC/MFW
250 */
251
252 #define ENTITY_MFW
253
254 #include <string.h>
255 #include <stdio.h>
256 #include <stdlib.h>
257
258 #if defined (NEW_FRAME)
259
260 #include "typedefs.h"
261 #include "vsi.h"
262 #include "pei.h"
263 #include "custom.h"
264 #include "gsm.h"
265
266 #else
267
268 #include "STDDEFS.H"
269 #include "custom.h"
270 #include "gsm.h"
271 #include "vsi.h"
272
273 #endif
274 #ifdef SIM_PERS
275 #include "p_sim.h"
276 #endif
277 #include "prim.h"
278 #include "message.h"
279 #include "prim.h"
280 #include "aci_cmh.h"
281 #include "psa.h"
282 #include "psa_sim.h"
283
284 #ifndef PCM_2_FFS
285 #include "pcm.h"
286 #endif
287
288 #include "mfw_mfw.h"
289 #include "mfw_nm.h"
290 #include "mfw_sim.h"
291 #include "mfw_sima.h"
292 #include "mfw_simi.h"
293 #include "mfw_nmi.h"
294 #include "mfw_nma.h"
295 #include "mfw_phb.h"
296 #include "mfw_cm.h"
297 #include "mfw_cmi.h"
298 #include "mfw_acie.h"
299 #include "mfw_sms.h"
300 #include "mfw_smsi.h"
301 #include "mfw_win.h"
302
303
304 #include "ksd.h"
305 #include "psa.h"
306
307 #if defined (FAX_AND_DATA)
308 #include "aci_fd.h"
309 #endif
310
311 #include "cmh.h"
312 #include "phb.h"
313 #include "cmh_phb.h"
314
315 #include "mfw_ss.h"
316 #include "mfw_ssi.h"
317
318 #include "aci_ext_pers.h" /*MC, SPR 1351 include ACI simlock files*/
319 #include "aci_slock.h"
320
321 #ifdef SIM_TOOLKIT
322 #include "mfw_sat.h"
323 #endif
324
325 extern BOOL sima_response_cb (ULONG opc, void * data);
326 extern void simDecodeIMSI (UBYTE *ci, UBYTE li, UBYTE *di);
327 static int simCommand (ULONG cmd, void *h); /* handle win commands */
328 extern UBYTE mfw_IMSI []; /* expanded IMSI (ASCIIZ) */
329
330 #ifdef SIM_TOOLKIT
331 char mfwSATLPRefresh;
332 #endif
333
334 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
335 // required for the new compiler 2.54
336 #ifdef SIM_PERS
337 T_ACI_CLCK_FAC mfw_simlock_return_lock_type(S16 lck);
338 T_MFW mfw_simlock_check_status(S16 lcktyp,int *max,int *curr);
339 int mfw_simlock_get_lock_status(S16 lcktyp);
340 int C_KEY_REQ = 0;
341 #endif
342
343 static T_MFW_SIM_STATUS sim_status;
344 static T_MFW_SIM_CONFIG sim_config;
345 static int pin_flag;
346 static UBYTE pin_ident;
347
348 static UBYTE sim_service_table [10]; /* SIM service table */
349 static UBYTE sim_stat = SIM_NOT_ACTIVE;
350
351 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
352 // Fix for the wrong screens in PIN enable/disable/change password
353 UBYTE pin1_set = MFW_SIM_DISABLE;
354 UBYTE pin2_set = MFW_SIM_ENABLE;
355
356 static BOOL sat_update = FALSE;
357
358 static int pSlot; /* primitive handler slot */
359
360 CallbackCPRI mmi_cprs_cb;
361
362 EXTERN MfwHdr * current_mfw_elem;
363 #if defined (WIN32)
364 /*
365 * Only for windows to check several SIM lock combinations
366 */
367 UBYTE sim_lock_mode = 0;
368 #endif
369 UBYTE sim_lock_field = NOT_PRESENT_8BIT; /* type of sim lock field */
370
371 #ifdef SIM_PERS
372 EXTERN UBYTE gsim_status;
373 // Nov 03, 2005 DR: OMAPS00052032 - xpradipg
374 U8 sim_unlock_in_prog = FALSE;
375 #endif
376
377
378 //x0pleela 10 Feb, 2006 ER: OMAPS00065203
379 EXTERN UBYTE gEons_alloc_active; /* EONS allocation and activation */
380
381 /*
382 +--------------------------------------------------------------------+
383 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
384 | STATE : code ROUTINE : sim_init |
385 +--------------------------------------------------------------------+
386
387 PURPOSE : initialize SIM manager
388
389 */
390
391 int sim_init (void)
392 {
393
394 #ifdef PCM_2_FFS
395 T_PSPDF_SIMLCKEXT simlck;
396 #else
397 EF_SIMLCKEXT simlck;
398 #endif
399
400
401 TRACE_FUNCTION("sim_init()");
402
403 pin_flag = -1;
404 pin_ident = MFW_SIM_UNKNOWN;
405
406 /*
407 * install prim handler
408 */
409 pSlot = aci_create(sima_response_cb,NULL);
410 mfwCommand[MfwTypSim] = (MfwCb) simCommand;
411
412 return TRUE;
413 }
414
415
416 /*
417 +---------------------------------------------------------------------+
418 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
419 | STATE : code ROUTINE : sim_init_sim_insert |
420 +---------------------------------------------------------------------+
421
422 PURPOSE : initialize SIM manager
423
424 */
425
426 void sim_init_sim_insert()
427 {
428 }
429
430
431 /*
432 +--------------------------------------------------------------------+
433 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
434 | STATE : code ROUTINE : sim_exit |
435 +--------------------------------------------------------------------+
436
437 PURPOSE : finalize SIM manager
438
439 */
440
441 void sim_exit (void)
442 {
443 TRACE_FUNCTION("sim_exit()");
444
445 /*
446 * remove prim handler
447 */
448 aci_delete(pSlot);
449 sim_stat = SIM_NOT_ACTIVE;
450 }
451
452
453 /*
454 +--------------------------------------------------------------------+
455 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
456 | STATE : code ROUTINE : sim_create |
457 +--------------------------------------------------------------------+
458
459 PURPOSE : create SIM event handler
460
461 */
462
463 T_MFW_HND sim_create (MfwHnd hWin, MfwEvt event, MfwCb cbfunc)
464 {
465 MfwHdr *hdr;
466 T_MFW_SIM *sim_para;
467 MfwHdr *insert_status =0;
468
469 TRACE_FUNCTION("sim_create()");
470
471 hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
472 sim_para = (T_MFW_SIM *) mfwAlloc(sizeof(T_MFW_SIM));
473
474 if (!hdr || !sim_para)
475 {
476 TRACE_ERROR("ERROR: sim_create() Mem Alloc Failed.");
477
478 if(hdr)
479 mfwFree((U8*)hdr,sizeof(MfwHdr));
480
481 if(sim_para)
482 mfwFree((U8*)sim_para,sizeof(T_MFW_SIM));
483
484 return 0;
485 }
486 sim_para->emask = event;
487 sim_para->handler = cbfunc;
488
489 hdr->data = sim_para;
490 hdr->type = MfwTypSim;
491
492 insert_status = mfwInsert((MfwHdr *) hWin,hdr);
493
494 if(!insert_status)
495 {
496 TRACE_ERROR("ERROR: sim_create() Failed to Install Handler. ");
497 mfwFree((U8*)hdr,sizeof(MfwHdr));
498 mfwFree((U8*)sim_para,sizeof(T_MFW_SIM));
499 return 0;
500 }
501 return insert_status;
502
503 }
504
505
506 /*
507 +--------------------------------------------------------------------+
508 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
509 | STATE : code ROUTINE : sim_delete |
510 +--------------------------------------------------------------------+
511
512 PURPOSE : delete SIM event handler
513
514 */
515
516 MfwRes sim_delete (MfwHnd h)
517 {
518 TRACE_FUNCTION("sim_delete()");
519
520 if (!h || !((MfwHdr *) h)->data)
521 return MfwResIllHnd;
522
523 if (!mfwRemove((MfwHdr *) h))
524 return MfwResIllHnd;
525
526 mfwFree((U8 *) ((MfwHdr *) h)->data,sizeof(T_MFW_SIM));
527 mfwFree((U8 *) h,sizeof(MfwHdr));
528
529 return MfwResOk;
530 }
531
532
533 /*
534 +--------------------------------------------------------------------+
535 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
536 | STATE : code ROUTINE : sim_signal |
537 +--------------------------------------------------------------------+
538
539 PURPOSE : Send a signal
540
541 */
542
543 void sim_signal (MfwEvt event, void *para)
544 {
545 UBYTE temp = dspl_Enable(0);
546 TRACE_FUNCTION ("sim_signal()");
547
548 if (mfwSignallingMethod EQ 0)
549 {
550 if (mfwFocus)
551 if (sim_sign_exec(mfwFocus,event,para))
552 {
553 dspl_Enable(temp);
554 return;
555 }
556 if (mfwRoot)
557 sim_sign_exec(mfwRoot,event,para);
558 }
559 else
560 {
561 MfwHdr * h = 0;
562
563 /*
564 * Focus set, then start here
565 */
566 if (mfwFocus)
567 h = mfwFocus;
568 /*
569 * Focus not set, then start root
570 */
571 if (!h)
572 h = mfwRoot;
573
574 /*
575 * No elements available, return
576 */
577
578 while (h)
579
580
581 {
582 /*
583 * Signal consumed, then return
584 */
585 if (sim_sign_exec (h, event, para))
586 {
587 dspl_Enable(temp);
588 return;
589 }
590
591 /*
592 * All windows tried inclusive root
593 */
594 if (h == mfwRoot)
595 {
596 dspl_Enable(temp);
597 return;
598 }
599
600 /*
601 * get parent window
602 */
603 h = mfwParent(mfwParent(h));
604 if(h)
605 h = ((MfwWin * )(h->data))->elems;
606 }
607 sim_sign_exec (mfwRoot, event, para);
608 }
609 dspl_Enable(temp);
610 return;
611 }
612
613
614 /*
615 +--------------------------------------------------------------------+
616 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
617 | STATE : code ROUTINE : sim_sign_exec |
618 +--------------------------------------------------------------------+
619
620 PURPOSE : Send a signal if SIM management handler
621
622 */
623
624 int sim_sign_exec (MfwHdr *cur_elem, MfwEvt event, T_MFW_SIM_PARA *para)
625 {
626
627 TRACE_FUNCTION("sim_sign_exec()");
628
629 while (cur_elem)
630 {
631 if (cur_elem->type == MfwTypSim)
632 {
633 T_MFW_SIM *sim_data;
634 sim_data = (T_MFW_SIM *) cur_elem->data;
635 if (sim_data->emask & event)
636 {
637 sim_data->event = event;
638 switch (event)
639 {
640 case E_SIM_STATUS:
641 memcpy(&sim_data->para.status,
642 para,sizeof(T_MFW_SIM_STATUS));
643 break;
644 /*MC CONQ5862, 13/06/02*, added new event*/
645 case E_SIM_READ_CALLBACK:
646 memcpy(&sim_data->para.callback,
647 para,sizeof(T_MFW_READ_CALLBACK));
648 break;
649 }
650 if (sim_data->handler)
651 {
652 // PATCH LE 06.06.00
653 // store current mfw elem
654 current_mfw_elem = cur_elem;
655 // END PATCH LE 06.06.00
656 if ((*(sim_data->handler))(sim_data->event,
657 (void *) &sim_data->para))
658 return TRUE;
659 }
660 }
661 }
662 cur_elem = cur_elem->next;
663 }
664
665 return FALSE;
666 }
667
668
669 /*
670 +--------------------------------------------------------------------+
671 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
672 | STATE : code ROUTINE : sim_activate |
673 +--------------------------------------------------------------------+
674
675 PURPOSE : Start SIM card activation
676
677 */
678
679 void sim_activate (void)
680 {
681
682 T_ACI_RETURN cfun;
683 T_ACI_ERR_DESC cfun_err;
684
685 TRACE_FUNCTION("sim_activate()");
686
687 /*
688 * Full functionality is used don´t reset the ME
689 */
690
691 // Nov 24, 2005, a0876501, DR: OMAPS00045909
692 cfun = sAT_PlusCFUN(CMD_SRC_LCL,CFUN_FUN_Full,CFUN_RST_NotPresent);
693
694 if (cfun EQ AT_FAIL)
695 {
696 cfun_err = qAT_ErrDesc();
697
698 if((cfun_err & 0x0000FFFF) EQ EXT_ERR_IMEICheck)
699 {
700 sim_stat = IMEI_NOT_VALID;
701 sim_status.sim_status = MFW_IMEI_NOT_VALID;
702 sim_status.sim_operation_mode = sim_config.oper_mode;
703 sim_status.sim_pin_retries = 0;
704 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
705 sim_status.sim_status_type = MFW_SIM_UNKNOWN;
706
707 sim_signal(E_SIM_STATUS,&sim_status);
708 }
709 }
710 else if (cfun NEQ AT_EXCT)
711 {
712 TRACE_ERROR("sAT_PlusCFUN error");
713 }
714 }
715
716
717 /*
718 +--------------------------------------------------------------------+
719 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
720 | STATE : code ROUTINE : sim_spn_req |
721 +--------------------------------------------------------------------+
722
723 PURPOSE : Request service provider name
724
725 */
726
727 void sim_spn_req (void)
728 {
729 T_EF_SPN spn;
730
731 TRACE_FUNCTION("sim_spn_req()");
732
733 memset(&spn,0,sizeof(T_EF_SPN));
734
735 if (sim_check_service(17,sim_service_table)
736 EQ ALLOCATED_AND_ACTIVATED)
737 sim_read_sim(SIM_SPN,17,17);
738 else
739 #ifdef FF_2TO1_PS
740 nm_spn_cnf(CAUSE_SIM_ACCESS_PROHIBIT, &spn);
741 #else
742 nm_spn_cnf(SIM_CAUSE_ACCESS_PROHIBIT, &spn);
743 #endif
744
745 }
746
747
748 /*
749 +--------------------------------------------------------------------+
750 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
751 | STATE : code ROUTINE : sim_ok_cfun |
752 +--------------------------------------------------------------------+
753
754 PURPOSE : Notify successful end of SIM card activation
755
756 */
757
758 void sim_ok_cfun (void)
759 {
760 T_ACI_CFUN_FUN fun;
761
762 TRACE_FUNCTION ("sim_ok_cfun()");
763
764 qAT_PlusCFUN( CMD_SRC_LCL, &fun );
765
766 if( fun EQ CFUN_FUN_Full )
767 {
768 sim_stat = SIM_ACTIVE;
769 sim_status.sim_status = MFW_SIM_NO_PIN;
770 sim_status.sim_operation_mode = sim_config.oper_mode;
771 sim_status.sim_pin_retries = 0;
772 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
773 sim_status.sim_status_type = pin_ident;
774
775 pin_ident = MFW_SIM_UNKNOWN;
776 sim_signal(E_SIM_STATUS,&sim_status);
777 nm_activate(MFW_SIM_NO_PIN);
778
779 pin1_set = MFW_SIM_DISABLE;
780 }
781 else if( fun EQ CFUN_FUN_Minimum )
782 {
783 nm_ok_deregistration();
784 }
785 }
786
787
788 /*
789 +--------------------------------------------------------------------+
790 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
791 | STATE : code ROUTINE : sim_error_cfun |
792 +--------------------------------------------------------------------+
793
794 PURPOSE : Notify error status of SIM card
795
796 */
797
798 void sim_error_cfun (U8 result)
799 {
800 TRACE_FUNCTION("sim_error_cfun()");
801
802 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
803 sim_status.sim_operation_mode = sim_config.oper_mode;
804
805 switch (result)
806 {
807 case CME_ERR_SimPinReq: /* PIN 1 must be entered */
808 sim_status.sim_status = MFW_SIM_PIN_REQ;
809 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN1);
810 sim_status.sim_status_type = MFW_SIM_PIN1;
811 sim_stat = SIM_ACTIVE;
812 break;
813 case CME_ERR_SimPin2Req: /* PIN 2 must be entered */
814 sim_status.sim_status = MFW_SIM_PIN2_REQ;
815 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN2);
816 sim_status.sim_status_type = MFW_SIM_PIN2;
817 sim_stat = SIM_ACTIVE;
818 break;
819
820 #ifdef SIM_PERS
821 case CME_ERR_PhoneFail:
822 case CME_ERR_NetworkPersPukReq:
823 case CME_ERR_NetworkSubsetPersPukReq:
824 case CME_ERR_ProviderPersPukReq:
825 case CME_ERR_CorporatePersPukReq:
826 C_KEY_REQ = 1;
827 #endif
828 // Nov 03, 2005 DR: OMAPS00050595 - xpradipg
829 // the setting of C_KEY_REQ is done only for SIM Personalization PUK request
830 case CME_ERR_SimPukReq: /* PUK 1 must be entered */
831 sim_status.sim_status = MFW_SIM_PUK_REQ;
832 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PUK1);
833 sim_status.sim_status_type = MFW_SIM_PUK1;
834 sim_stat = SIM_ACTIVE;
835 break;
836 case CME_ERR_SimPuk2Req: /* PUK 2 must be entered */
837 sim_status.sim_status = MFW_SIM_PUK2_REQ;
838 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PUK2);
839 sim_status.sim_status_type = MFW_SIM_PUK2;
840 sim_stat = SIM_ACTIVE;
841 break;
842 case CME_ERR_NotPresent: /* JVJ -#1580. Unexpected error should be treated as INVALID CARD for FTA*/
843 case CME_ERR_SimFail: /* SIM card is invalid */
844 case CME_ERR_SimWrong:
845 sim_status.sim_status = MFW_SIM_INVALID_CARD;
846 sim_status.sim_pin_retries = 0;
847 sim_status.sim_status_type = MFW_SIM_UNKNOWN;
848 sim_stat = SIM_NOT_ACTIVE;
849 break;
850 case CME_ERR_SimNotIns: /* no SIM card inserted */
851 sim_status.sim_status = MFW_SIM_NO_SIM_CARD;
852 sim_status.sim_pin_retries = 0;
853 sim_status.sim_status_type = MFW_SIM_UNKNOWN;
854 sim_stat = SIM_NOT_ACTIVE;
855 break;
856 #ifdef SIM_PERS
857 //The events are handled that are posted by rAT_PlusCME()
858 //for all the five SIM Locks.
859 case CME_ERR_PhSimPinReq:
860 sim_status.sim_status = MFW_SIM_PLOCK_REQ;
861 sim_status.sim_pin_retries = 0;
862 sim_status.sim_status_type = MFW_SIM_LOCKED ;
863 sim_stat = SIM_ACTIVE;
864 break;
865 case CME_ERR_NetworkPersPinReq:
866 sim_status.sim_status = MFW_SIM_NLOCK_REQ;
867 sim_status.sim_pin_retries = 0;
868 sim_status.sim_status_type = MFW_SIM_LOCKED;
869 sim_stat = SIM_ACTIVE;
870 gsim_status=sim_stat;
871 break;
872 case CME_ERR_NetworkSubsetPersPinReq:
873 sim_status.sim_status = MFW_SIM_NSLOCK_REQ;
874 sim_status.sim_pin_retries = 0;
875 sim_status.sim_status_type = MFW_SIM_LOCKED;
876 sim_stat = SIM_ACTIVE;
877 break;
878 case CME_ERR_ProviderPersPinReq:
879 sim_status.sim_status = MFW_SIM_SPLOCK_REQ;
880 sim_status.sim_pin_retries = 0;
881 sim_status.sim_status_type = MFW_SIM_LOCKED;
882 sim_stat = SIM_ACTIVE;
883 break;
884 case CME_ERR_CorporatePersPinReq:
885 sim_status.sim_status = MFW_SIM_CLOCK_REQ;
886 sim_status.sim_pin_retries = 0;
887 sim_status.sim_status_type = MFW_SIM_LOCKED;
888 sim_stat = SIM_ACTIVE;
889 break;
890
891 #endif
892 default:
893 TRACE_ERROR("sim_error_cfun(): result");
894 return;
895 }
896
897 sim_signal(E_SIM_STATUS,&sim_status);
898
899 if ((result == CME_ERR_SimPinReq)
900 OR (result == CME_ERR_SimPukReq))
901 pin1_set = MFW_SIM_ENABLE;
902 }
903
904
905 /*
906 +--------------------------------------------------------------------+
907 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
908 | STATE : code ROUTINE : sim_error_cpin |
909 +--------------------------------------------------------------------+
910
911 PURPOSE : Inform about error of PIN entering or PUK entering
912
913 */
914
915 void sim_error_cpin (T_ACI_CME_ERR reason)
916 {
917 T_ACI_CPIN_RSLT code;
918
919 TRACE_FUNCTION("sim_error_cpin()");
920
921 sim_status.sim_procedure = pin_flag;
922 sim_status.sim_operation_mode = sim_config.oper_mode;
923 sim_status.sim_status = MFW_SIM_FAILURE;
924 sim_status.sim_status_type = pin_ident;
925
926 pin_flag = -1;
927 pin_ident = MFW_SIM_UNKNOWN;
928
929 switch (reason)
930 {
931 case CME_ERR_WrongPasswd:
932 if (qAT_PlusCPIN(CMD_SRC_LCL,&code) != AT_CMPL)
933 {
934 TRACE_ERROR("sim_error_cpin():CPIN? failed");
935 sim_signal(E_SIM_STATUS,&sim_status);
936 return;
937 }
938 break;
939 #ifdef SIM_PERS
940 case CME_ERR_SimPinReq: /* PIN 1 must be entered */
941 sim_status.sim_status = MFW_SIM_PIN_REQ;
942 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN1);
943 sim_status.sim_status_type = MFW_SIM_PIN1;
944 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
945 sim_stat = SIM_ACTIVE;
946 sim_signal(E_SIM_STATUS,&sim_status);
947 return;
948
949 case CME_ERR_SimPin2Req: /* PIN 2 must be entered */
950 sim_status.sim_status = MFW_SIM_PIN2_REQ;
951 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN2);
952 sim_status.sim_status_type = MFW_SIM_PIN2;
953 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
954 sim_stat = SIM_ACTIVE;
955 sim_signal(E_SIM_STATUS,&sim_status);
956 return;
957 case CME_ERR_PhoneFail:
958 case CME_ERR_NetworkPersPukReq:
959 case CME_ERR_NetworkSubsetPersPukReq:
960 case CME_ERR_ProviderPersPukReq:
961 case CME_ERR_CorporatePersPukReq:
962
963 C_KEY_REQ = 1;
964 // Nov 03, 2005 DR: OMAPS00050595 - xpradipg
965 case CME_ERR_SimPukReq: /* PUK 1 must be entered */
966
967 sim_status.sim_status = MFW_SIM_PUK_REQ;
968 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PUK1);
969 sim_status.sim_status_type = MFW_SIM_PUK1;
970 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
971 sim_stat = SIM_ACTIVE;
972 sim_signal(E_SIM_STATUS,&sim_status);
973 return;
974 case CME_ERR_SimPuk2Req: /* PUK 2 must be entered */
975 sim_status.sim_status = MFW_SIM_PUK2_REQ;
976 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PUK2);
977 sim_status.sim_status_type = MFW_SIM_PUK2;
978 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
979 sim_stat = SIM_ACTIVE;
980 sim_signal(E_SIM_STATUS,&sim_status);
981 return;
982 case CME_ERR_NotPresent: /* JVJ -#1580. Unexpected error should be treated as INVALID CARD for FTA*/
983 case CME_ERR_SimFail: /* SIM card is invalid */
984 #endif
985 case CME_ERR_SimWrong:
986 sim_status.sim_status = MFW_SIM_INVALID_CARD;
987 #ifdef SIM_PERS
988 sim_status.sim_pin_retries = 0;
989 sim_status.sim_status_type = MFW_SIM_UNKNOWN;
990 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
991 sim_stat = SIM_NOT_ACTIVE;
992 sim_signal(E_SIM_STATUS,&sim_status);
993 #else
994 sim_signal(E_SIM_STATUS,&sim_status);
995 #endif
996 return;
997
998
999 case CME_ERR_SimNotIns: /* no SIM card inserted */
1000 sim_status.sim_status = MFW_SIM_NO_SIM_CARD;
1001 sim_status.sim_pin_retries = 0;
1002 sim_status.sim_status_type = MFW_SIM_UNKNOWN;
1003 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
1004 sim_stat = SIM_NOT_ACTIVE;
1005 sim_signal(E_SIM_STATUS,&sim_status);
1006 return;
1007
1008 #ifdef SIM_PERS
1009 //The events are handled that are posted by rAT_PlusCME()
1010 //for all the five SIM Locks.
1011 case CME_ERR_PhSimPinReq:
1012 sim_status.sim_status = MFW_SIM_PLOCK_REQ;
1013 sim_status.sim_pin_retries = 0;
1014 sim_status.sim_status_type = MFW_SIM_LOCKED ;
1015 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
1016 sim_stat = SIM_ACTIVE;
1017 sim_signal(E_SIM_STATUS,&sim_status);
1018 return;
1019 case CME_ERR_NetworkPersPinReq:
1020 sim_status.sim_status = MFW_SIM_NLOCK_REQ;
1021 sim_status.sim_pin_retries = 0;
1022 sim_status.sim_status_type = MFW_SIM_LOCKED;
1023 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
1024 //sim_stat = SIM_NOT_ACTIVE; temporary changes
1025 sim_stat = SIM_ACTIVE;
1026 sim_signal(E_SIM_STATUS,&sim_status);
1027 return;
1028 case CME_ERR_NetworkSubsetPersPinReq:
1029 sim_status.sim_status = MFW_SIM_NSLOCK_REQ;
1030 sim_status.sim_pin_retries = 0;
1031 sim_status.sim_status_type = MFW_SIM_LOCKED;
1032 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
1033 sim_stat = SIM_ACTIVE;
1034 sim_signal(E_SIM_STATUS,&sim_status);
1035 return;
1036 case CME_ERR_ProviderPersPinReq:
1037 sim_status.sim_status = MFW_SIM_SPLOCK_REQ;
1038 sim_status.sim_pin_retries = 0;
1039 sim_status.sim_status_type = MFW_SIM_LOCKED;
1040 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
1041 sim_stat = SIM_ACTIVE;
1042 sim_signal(E_SIM_STATUS,&sim_status);
1043 return;
1044 case CME_ERR_CorporatePersPinReq:
1045 sim_status.sim_status = MFW_SIM_CLOCK_REQ;
1046 sim_status.sim_pin_retries = 0;
1047 sim_status.sim_status_type = MFW_SIM_LOCKED;
1048 sim_status.sim_procedure = MFW_SIM_ACTIVATION;
1049 sim_stat = SIM_ACTIVE;
1050 sim_signal(E_SIM_STATUS,&sim_status);
1051 return;
1052 #endif
1053 default:
1054 TRACE_ERROR("sim_error_cpin():Ill reason");
1055 sim_signal(E_SIM_STATUS,&sim_status);
1056 return;
1057 }
1058
1059 switch (code)
1060 {
1061 case CPIN_RSLT_SimPinReq:
1062 sim_status.sim_status = MFW_SIM_PIN_REQ;
1063 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN1);
1064 break;
1065 case CPIN_RSLT_SimPukReq:
1066 sim_status.sim_status = MFW_SIM_PUK_REQ;
1067 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PUK1);
1068 break;
1069 case CPIN_RSLT_SimPin2Req:
1070 sim_status.sim_status = MFW_SIM_PIN2_REQ;
1071 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN2);
1072 break;
1073 case CPIN_RSLT_SimPuk2Req:
1074 sim_status.sim_status = MFW_SIM_PUK2_REQ;
1075 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PUK2);
1076 break;
1077 case CPIN_RSLT_NotPresent:
1078 case CPIN_RSLT_SimReady:
1079 default:
1080 TRACE_ERROR("sim_error_cpin():Ill code");
1081 break;
1082 }
1083
1084 sim_signal(E_SIM_STATUS,&sim_status);
1085 }
1086
1087
1088 /*
1089 +--------------------------------------------------------------------+
1090 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1091 | STATE : code ROUTINE : sim_ok_cpin |
1092 +--------------------------------------------------------------------+
1093
1094 PURPOSE : Successful end of PIN entering or PUK entering
1095
1096 */
1097
1098 void sim_ok_cpin (void)
1099 {
1100 #ifdef SIM_PERS
1101 int pin_flag_temp;
1102 TRACE_FUNCTION_P1("sim_ok_cpin() %d",pin_flag);
1103 pin_flag_temp = pin_flag;
1104 #endif
1105 switch (pin_flag)
1106 {
1107 case MFW_SIM_VERIFY:
1108 sim_status.sim_procedure = MFW_SIM_VERIFY;
1109 sim_status.sim_status = MFW_SIM_NO_PIN;
1110 sim_status.sim_status_type = pin_ident;
1111 break;
1112 case MFW_SIM_UNBLOCK:
1113 sim_status.sim_procedure = MFW_SIM_UNBLOCK;
1114 sim_status.sim_status = MFW_SIM_SUCCESS;
1115 sim_status.sim_status_type = pin_ident;
1116 #ifdef SIM_PERS
1117 pin1_set = MFW_SIM_ENABLE;
1118 #endif
1119 break;
1120 default:
1121 break;
1122 }
1123
1124 pin_flag = -1;
1125 pin_ident = MFW_SIM_UNKNOWN;
1126 sim_status.sim_operation_mode = sim_config.oper_mode;
1127 sim_status.sim_pin_retries = 0;
1128
1129 sim_signal (E_SIM_STATUS, &sim_status);
1130 if (nm_reg_flag_req())
1131 nm_activate(MFW_SIM_NO_PIN);
1132 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
1133 // removed the flag that was getting set
1134
1135 }
1136
1137
1138 /*
1139 +--------------------------------------------------------------------+
1140 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1141 | STATE : code ROUTINE : sim_ss_unblock |
1142 +--------------------------------------------------------------------+
1143
1144 PURPOSE : SIM unblock via SS string
1145
1146 */
1147
1148 void sim_ss_unblock(UBYTE result, T_ACI_CME_ERR reason)
1149 {
1150 TRACE_FUNCTION("sim_ss_unblock()");
1151
1152 pin_flag = MFW_SIM_UNBLOCK;
1153
1154 if (result == SIM_UBLK_ERROR)
1155 sim_error_cpin (reason);
1156 if (result == SIM_UBLK_OK)
1157 sim_ok_cpin ();
1158 }
1159
1160
1161 /*
1162 +--------------------------------------------------------------------+
1163 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1164 | STATE : code ROUTINE : sim_verify_pin |
1165 +--------------------------------------------------------------------+
1166
1167 PURPOSE : Verify PIN
1168
1169 */
1170
1171 void sim_verify_pin (U8 pin_id, char *pin)
1172 {
1173 TRACE_FUNCTION("sim_verify_pin()");
1174
1175 pin_flag = MFW_SIM_VERIFY;
1176 pin_ident = pin_id;
1177 switch (pin_id)
1178 {
1179 case MFW_SIM_PIN1:
1180 sAT_PercentPVRF(CMD_SRC_LCL, PVRF_TYPE_Pin1, pin, 0);
1181 break;
1182 case MFW_SIM_PIN2:
1183 sAT_PercentPVRF(CMD_SRC_LCL, PVRF_TYPE_Pin2, pin, 0);
1184 break;
1185 }
1186 }
1187
1188
1189 /*
1190 +--------------------------------------------------------------------+
1191 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1192 | STATE : code ROUTINE : sim_unblock_pin |
1193 +--------------------------------------------------------------------+
1194
1195 PURPOSE : unblock SIM
1196
1197 */
1198
1199 void sim_unblock_pin (U8 pin_id, char *puk, char *newpin)
1200 {
1201 TRACE_FUNCTION("sim_unblock_pin()");
1202
1203 pin_flag = MFW_SIM_UNBLOCK;
1204 pin_ident = pin_id;
1205 switch (pin_id)
1206 {
1207 case MFW_SIM_PUK1:
1208 sAT_PercentPVRF(CMD_SRC_LCL, PVRF_TYPE_Puk1, puk, newpin);
1209 break;
1210 case MFW_SIM_PUK2:
1211 sAT_PercentPVRF(CMD_SRC_LCL, PVRF_TYPE_Puk2, puk, newpin);
1212 break;
1213 }
1214 }
1215
1216
1217 /*
1218 +--------------------------------------------------------------------+
1219 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1220 | STATE : code ROUTINE : sim_change_pin |
1221 +--------------------------------------------------------------------+
1222
1223 PURPOSE : Request of PIN change
1224
1225 */
1226
1227 void sim_change_pin (U8 pin_id, U8 *old_pin, U8 *new_pin)
1228 {
1229 TRACE_FUNCTION("sim_change_pin()");
1230
1231 pin_ident = pin_id;
1232 switch (pin_id)
1233 {
1234 case MFW_SIM_PIN1:
1235 sAT_PlusCPWD(CMD_SRC_LCL, CPWD_FAC_Sc,
1236 (char *)old_pin, (char *)new_pin);
1237 break;
1238 case MFW_SIM_PIN2:
1239 sAT_PlusCPWD(CMD_SRC_LCL, CPWD_FAC_P2,
1240 (char *)old_pin, (char *)new_pin);
1241 break;
1242 }
1243 }
1244
1245
1246 /*
1247 +--------------------------------------------------------------------+
1248 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1249 | STATE : code ROUTINE : sim_ok_cpinc |
1250 +--------------------------------------------------------------------+
1251
1252 PURPOSE : Notify successful end of PIN change
1253
1254 */
1255
1256 void sim_ok_cpinc (void)
1257 {
1258 TRACE_FUNCTION("sim_ok_cpinc()");
1259
1260 sim_status.sim_procedure = MFW_SIM_CHANGE;
1261 sim_status.sim_status = MFW_SIM_SUCCESS;
1262 sim_status.sim_operation_mode = sim_config.oper_mode;
1263 sim_status.sim_pin_retries = 0;
1264 sim_status.sim_status_type = pin_ident;
1265
1266 pin_ident = MFW_SIM_UNKNOWN;
1267 sim_signal(E_SIM_STATUS,&sim_status);
1268 }
1269
1270
1271 /*
1272 +--------------------------------------------------------------------+
1273 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1274 | STATE : code ROUTINE : sim_error_cpinc |
1275 +--------------------------------------------------------------------+
1276
1277 PURPOSE : Notify failed PIN change
1278
1279 */
1280
1281 void sim_error_cpinc (void)
1282 {
1283 TRACE_FUNCTION("sim_error_cpinc()");
1284
1285 sim_status.sim_procedure = MFW_SIM_CHANGE;
1286 sim_status.sim_status = MFW_SIM_FAILURE;
1287 sim_status.sim_operation_mode = sim_config.oper_mode;
1288 if (pin_ident EQ MFW_SIM_PIN1)
1289 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN1);
1290 else if (pin_ident EQ MFW_SIM_PIN2)
1291 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN2);
1292 else
1293 sim_status.sim_pin_retries = 0;
1294 sim_status.sim_status_type = pin_ident;
1295
1296 pin_ident = MFW_SIM_UNKNOWN;
1297 sim_signal(E_SIM_STATUS,&sim_status);
1298 }
1299
1300
1301 /*
1302 +--------------------------------------------------------------------+
1303 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1304 | STATE : code ROUTINE : sim_disable_pin |
1305 +--------------------------------------------------------------------+
1306
1307 PURPOSE : Request PIN disability.SPR 2145 now returns status
1308
1309 */
1310
1311 T_MFW sim_disable_pin (U8 *pin)
1312 {
1313 TRACE_FUNCTION("sim_disable_pin()");
1314
1315 return ss_set_clck(CLCK_FAC_Sc, CLCK_MOD_Unlock,
1316 (char *)pin, -1, MFW_SIM_CPIND);
1317 }
1318
1319
1320 /*
1321 +--------------------------------------------------------------------+
1322 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1323 | STATE : code ROUTINE : sim_ok_cpind |
1324 +--------------------------------------------------------------------+
1325
1326 PURPOSE : Successful end of PIN disability
1327
1328 */
1329
1330 void sim_ok_cpind (void)
1331 {
1332 TRACE_FUNCTION("sim_ok_cpind()");
1333
1334 sim_status.sim_procedure = MFW_SIM_DISABLE;
1335 sim_status.sim_status = MFW_SIM_SUCCESS;
1336 sim_status.sim_operation_mode = sim_config.oper_mode;
1337 sim_status.sim_pin_retries = 0;
1338 sim_status.sim_status_type = MFW_SIM_UNKNOWN; // no indication
1339
1340 pin1_set = MFW_SIM_DISABLE;
1341 sim_signal(E_SIM_STATUS,&sim_status);
1342 }
1343
1344
1345 /*
1346 +--------------------------------------------------------------------+
1347 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1348 | STATE : code ROUTINE : sim_error_cpind |
1349 +--------------------------------------------------------------------+
1350
1351 PURPOSE : Failed PIN disability
1352
1353 */
1354
1355 void sim_error_cpind (void)
1356 {
1357 TRACE_FUNCTION("sim_error_cpind()");
1358
1359 sim_status.sim_procedure = MFW_SIM_DISABLE;
1360 sim_status.sim_status = MFW_SIM_FAILURE;
1361 sim_status.sim_operation_mode = sim_config.oper_mode;
1362 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN1);
1363 sim_status.sim_status_type = MFW_SIM_UNKNOWN; // no indication
1364
1365 sim_signal(E_SIM_STATUS,&sim_status);
1366 }
1367
1368
1369 /*
1370 +--------------------------------------------------------------------+
1371 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1372 | STATE : code ROUTINE : sim_enable_pin |
1373 +--------------------------------------------------------------------+
1374
1375 PURPOSE : Request PIN enability. SPR 2145 now returns status
1376
1377 */
1378
1379 T_MFW sim_enable_pin (U8 *pin)
1380 {
1381 TRACE_FUNCTION("sim_enable_pin()");
1382
1383 return ss_set_clck(CLCK_FAC_Sc, CLCK_MOD_Lock,
1384 (char *)pin, -1, MFW_SIM_CPINE);
1385 }
1386
1387 #ifdef SIM_PERS
1388 // Nov 03, 2005 DR: OMAPS00052032 - xpradipg
1389 /*******************************************************************************
1390 $Function: mfw_simlock_continue
1391 $Description: for displaying the sAT_PlusCLCK result
1392 $Returns: None
1393 $Arguments: state if passed / failed
1394
1395 *******************************************************************************/
1396 void mfw_simlock_continue(U8 state)
1397 {
1398 mmi_display_result(state);
1399 }
1400
1401 /*******************************************************************************
1402 $Function: mfw_simlock_unblockME
1403 $Description: for unblocking ME
1404 $Returns: SUCCESS or FAILURE
1405 $Arguments: PUK
1406
1407 *******************************************************************************/
1408 int mfw_simlock_unblockME(char *puk)
1409 {
1410 TRACE_FUNCTION("mfw_simlock_unblockME");
1411 if( sAT_PlusCLCK(CMD_SRC_LCL,CLCK_FAC_Fc,CLCK_MOD_Unlock,(char*)puk,-1)==AT_CMPL)
1412 //return UNBLOCK_SUCESS;
1413 return MFW_SS_OK;
1414 else
1415 //return UNBLOCK_FAILURE;
1416 return MFW_SS_FAIL;
1417 }
1418
1419 /*******************************************************************************
1420 $Function: mfw_simlock_check_lock_bootup
1421 $Description: checking PIN during bootup
1422 $Returns: SUCCESS or FAILURE
1423 $Arguments: PIN
1424
1425 *******************************************************************************/
1426 mfw_simlock_check_lock_bootup(char *pin, S16 lcktype)
1427 {
1428
1429 /* if( sAT_PlusCPIN(CMD_SRC_LCL, pin, NULL)==AT_CMPL)
1430 return BOOTUP_LOCK_SUCCESS;
1431 else
1432 return BOOTUP_LOCK_FAILURE;*/ //Leela for CPIN to CLCK change
1433
1434 T_ACI_CLCK_FAC lckFac;
1435 T_ACI_CLSSTAT clsStat;
1436 UBYTE slock_status;
1437 int status, maxval, curval;
1438
1439 TRACE_FUNCTION("mfw_simlock_check_lock_bootup");
1440
1441 lckFac= mfw_simlock_return_lock_type(lcktype);
1442
1443 if(sAT_PlusCLCK(CMD_SRC_LCL,lckFac,CLCK_MOD_Unlock,(char*)pin,-1)== AT_FAIL)
1444 {
1445 status = mfw_simlock_check_status(lcktype,&maxval,&curval);
1446 //set the error descriptor
1447 switch( lcktype)
1448 {
1449 case MFW_SIM_NLOCK:
1450 if(curval !=0)
1451 {
1452 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkPersPinReq );
1453 }
1454 else
1455 {
1456 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkPersPukReq);
1457 }
1458 break;
1459
1460 case MFW_SIM_NSLOCK:
1461 if(curval !=0)
1462 {
1463 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkSubsetPersPinReq );
1464 }
1465 else
1466 {
1467 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkSubsetPersPukReq);
1468 }
1469 break;
1470
1471 case MFW_SIM_SPLOCK:
1472
1473 if(curval !=0)
1474 {
1475 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_ProviderPersPinReq);
1476 }
1477 else
1478 {
1479 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_ProviderPersPukReq );
1480 }
1481
1482 break;
1483
1484 case MFW_SIM_CLOCK:
1485
1486 if(curval !=0)
1487 {
1488 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_CorporatePersPinReq);
1489 }
1490 else
1491 {
1492 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_CorporatePersPukReq );
1493 }
1494
1495 break;
1496
1497 case MFW_SIM_PLOCK:
1498
1499 if(curval !=0)
1500 {
1501 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_PhSimPinReq );
1502 }
1503 else
1504 {
1505 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_PhoneFail);
1506 }
1507
1508 break;
1509
1510 default:
1511 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd );
1512 break;
1513
1514 }
1515
1516 return BOOTUP_LOCK_FAILURE;
1517 }
1518 else
1519 {
1520 lcktype++;
1521
1522 if( lcktype > MFW_SIM_PLOCK)
1523 return BOOTUP_LOCK_SUCCESS;
1524
1525 while( lcktype <= MFW_SIM_PLOCK)
1526 {
1527 lckFac= mfw_simlock_return_lock_type(lcktype);
1528 slock_status = mfw_simlock_get_lock_status(lcktype);
1529
1530 if(slock_status EQ MFW_SIM_DISABLE)
1531 {
1532 lcktype++;
1533
1534 if( lcktype > MFW_SIM_PLOCK)
1535 return BOOTUP_LOCK_SUCCESS;
1536 else
1537 continue;
1538 }
1539
1540 else
1541 {
1542 status = mfw_simlock_check_status(lcktype,&maxval,&curval);
1543 //set the error descriptor
1544 switch( lcktype)
1545 {
1546 case MFW_SIM_NLOCK:
1547 if(curval !=0)
1548 {
1549 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkPersPinReq );
1550 }
1551 else
1552 {
1553 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkPersPukReq);
1554 }
1555 break;
1556
1557 case MFW_SIM_NSLOCK:
1558 if(curval !=0)
1559 {
1560 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkSubsetPersPinReq );
1561 }
1562 else
1563 {
1564 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkSubsetPersPukReq);
1565 }
1566 break;
1567
1568 case MFW_SIM_SPLOCK:
1569 if(curval !=0)
1570 {
1571 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_ProviderPersPinReq);
1572 }
1573 else
1574 {
1575 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_ProviderPersPukReq );
1576 }
1577 break;
1578
1579 case MFW_SIM_CLOCK:
1580 if(curval !=0)
1581 {
1582 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_CorporatePersPinReq);
1583 }
1584 else
1585 {
1586 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_CorporatePersPukReq );
1587 }
1588 break;
1589
1590 case MFW_SIM_PLOCK:
1591 if(curval !=0)
1592 {
1593 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_PhSimPinReq );
1594 }
1595 else
1596 {
1597 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_PhoneFail);
1598 }
1599 break;
1600
1601 default:
1602 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd );
1603 break;
1604
1605 }
1606 return BOOTUP_LOCK_FAILURE;
1607 }
1608 }
1609 }
1610 }
1611
1612 /*******************************************************************************
1613 $Function: mfw_simlock_get_sup_info
1614 $Description: for getting the fc value
1615 $Returns: value of the req fc type
1616 $Arguments: fc type
1617
1618 *******************************************************************************/
1619 int mfw_simlock_get_sup_info(int flag)
1620 {
1621 T_SUP_INFO sup_info;
1622 // sup_info=(T_SUP_INFO *)malloc(sizeof(T_SUP_INFO));
1623 sup_info.infoType=flag;
1624 if(qAT_PercentMEPD( CMD_SRC_LCL, &sup_info) EQ AT_CMPL)
1625 {
1626 //TRACE_EVENT_P1("Leela: FC: %d", sup_info.datavalue);
1627 return sup_info.datavalue;
1628 }
1629 else
1630 return MFW_FAILURE;
1631 }
1632 /*******************************************************************************
1633 $Function: mfw_simlock_return_lock_type
1634 $Description: The lock type is converted to the ACI enum type
1635 $Returns: corresponding ACi lock type
1636 $Arguments: MMI lock type - (SIM Locks Only)
1637
1638 *******************************************************************************/
1639 T_ACI_CLCK_FAC mfw_simlock_return_lock_type(S16 lck)
1640 {
1641 switch (lck)
1642 {
1643 //case 0:
1644 case MFW_SIM_NLOCK:
1645 return CLCK_FAC_Pn;
1646 //case 1:
1647 case MFW_SIM_SPLOCK:
1648 return CLCK_FAC_Pp;
1649 //case 2:
1650 case MFW_SIM_NSLOCK:
1651 return CLCK_FAC_Pu;
1652 //case 3:
1653 case MFW_SIM_CLOCK:
1654 return CLCK_FAC_Pc;
1655 //case 4:
1656 case MFW_SIM_PLOCK:
1657 return CLCK_FAC_Ps;
1658
1659 case MFW_SIM_FC:
1660 return CLCK_FAC_Fc;
1661
1662
1663 case MFW_SIM_FCM:
1664 return CLCK_FAC_Fcm;
1665 default:
1666 return -1;
1667 }
1668
1669 }
1670
1671
1672 /*******************************************************************************
1673 $Function: mfw_simlock_check_status
1674 $Description: stub function to retireve the maximum and current number of tries
1675 for a given lock type
1676 $Returns: success or failure
1677 $Arguments: input - type of lock,
1678 output - *max and *curr to return the values
1679 *******************************************************************************/
1680 T_MFW mfw_simlock_check_status(S16 lcktyp,int *max,int *curr)
1681 {
1682 T_SUP_INFO_TYPE FLAG;
1683 int curr_fc, max_fc,FC_Reset_Fail_Max,FC_Reset_Fail_Current,FC_Reset_Success_Max,FC_Reset_Success_Current ;
1684 //T_DISPLAY_DATA display_info;
1685
1686 // T_MFW_HND win = mfwParent(mfw_header());
1687 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
1688 // used new enum value
1689 FLAG=FCMAX; /* set flag to current */
1690 max_fc=mfw_simlock_get_sup_info(FLAG); /* get the value of the corresponding flag*/
1691
1692 FLAG=FCATTEMPTSLEFT; /* set flag to current */
1693 curr_fc=mfw_simlock_get_sup_info(FLAG); /* get the value of the corresponding flag*/
1694
1695 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
1696 // used new enum value
1697 FLAG = FCRESETFAILMAX;
1698 FC_Reset_Fail_Max=mfw_simlock_get_sup_info(FLAG);
1699 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
1700 // used new enum value
1701 FLAG =FCRESETFAILATTEMPTSLEFT;
1702 FC_Reset_Fail_Current=mfw_simlock_get_sup_info(FLAG);
1703 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
1704 // used new enum value
1705 FLAG =FCRESETSUCCESSMAX;
1706 FC_Reset_Success_Max=mfw_simlock_get_sup_info(FLAG);
1707 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
1708 // used new enum value
1709 FLAG =FCRESETSUCCESSATTEMPTSLEFT;
1710 FC_Reset_Success_Current=mfw_simlock_get_sup_info(FLAG);
1711
1712 if( lcktyp !=0)
1713 {
1714 *max = max_fc;
1715 *curr = curr_fc;
1716 }
1717 else
1718 {
1719 *max = FC_Reset_Fail_Current;
1720 *curr = FC_Reset_Success_Current;
1721 }
1722
1723 TRACE_FUNCTION_P4(" FC_Reset_Fail_Max %d FC_Reset_Fail_Current %d FC_Reset_Success_Max %d FC_Reset_Success_Current %d",FC_Reset_Fail_Max,FC_Reset_Fail_Current,FC_Reset_Success_Max,FC_Reset_Success_Current);
1724
1725 if( lcktyp == 0 )
1726 {
1727 if(( FC_Reset_Fail_Current !=0 )&& (FC_Reset_Success_Current !=0) )
1728 {
1729 //temporarily blocked
1730 TRACE_FUNCTION("chk_status:MFW_SIM_BLOCKED");
1731 return MFW_SIM_BLOCKED;
1732
1733 }
1734 else
1735 {
1736 //permanently blocked
1737 TRACE_FUNCTION("check_staus: MFW_SIM_PERM_BLOCKED");
1738 return MFW_SIM_PERM_BLOCKED;
1739 }
1740
1741 }
1742 else
1743 {
1744 if( curr_fc == 0 )
1745 return MFW_SIM_BLOCKED;
1746 else
1747 return MFW_SIM_NOT_BLOCKED;
1748 }
1749 }
1750
1751 /*******************************************************************************
1752 $Function: mfw_simlock_get_lock_status
1753 $Description: returns the status of the lock - enabled / disabled
1754 $Returns: lock status
1755 $Arguments: lock type
1756
1757 *******************************************************************************/
1758 int mfw_simlock_get_lock_status(S16 lcktyp)
1759 {
1760 UBYTE stat;
1761 T_ACI_CLSSTAT clsStat;
1762 T_ACI_CLCK_FAC lckfac;
1763 int status;
1764 int maxval;
1765 int curval;
1766
1767 status = mfw_simlock_check_status(lcktyp,&maxval,&curval);
1768 if((status == MFW_SIM_BLOCKED))
1769 return MFW_SIM_BLOCKED;
1770 if(status == MFW_SIM_PERM_BLOCKED)
1771 return MFW_SIM_PERM_BLOCKED;
1772
1773 lckfac= mfw_simlock_return_lock_type(lcktyp);
1774 if (qAT_PlusCLCK(CMD_SRC_LCL, lckfac,
1775 CLASS_NotPresent, &clsStat) EQ AT_CMPL)
1776 {
1777 TRACE_FUNCTION("Leela:qAT_PlusCLCK->AT_CMPL ");
1778 switch (clsStat.status)
1779 {
1780 case STATUS_NotActive:
1781 return MFW_SIM_DISABLE;
1782
1783 case STATUS_Active:
1784 return MFW_SIM_ENABLE;
1785
1786 }
1787 }
1788 return MFW_SIM_FAILURE;
1789
1790 }
1791
1792
1793
1794
1795 /*******************************************************************************
1796 $Function: mfw_simlock_enable_lock
1797 $Description: Changes the oldpassword with the new one for the given
1798 lock type
1799 $Returns: success or failure
1800 $Arguments: type of lock and old and new password
1801
1802 *******************************************************************************/
1803
1804 T_MFW mfw_simlock_enable_lock(U8 *pin, S16 lcktyp)
1805 {
1806
1807 T_ACI_CLCK_FAC lckFac;
1808 // Nov 03, 2005 DR: OMAPS00052032 - xpradipg
1809 T_ACI_RETURN ret;
1810 TRACE_FUNCTION("mfw_simlock_enable_lock()");
1811
1812 /* return ss_set_clck(CLCK_FAC_Ps, CLCK_MOD_Lock,
1813 (char *)pin, -1, MFW_SIM_CPINE);*/
1814 lckFac= mfw_simlock_return_lock_type(lcktyp);
1815 ret = sAT_PlusCLCK(CMD_SRC_LCL,lckFac,CLCK_MOD_Lock,(char*)pin,-1);
1816 // Nov 03, 2005 DR: OMAPS00052032 - xpradipg
1817 // handle the AT_EXCT case and set the global to true
1818 switch(ret)
1819 {
1820 case AT_CMPL:
1821 return MFW_SS_OK;
1822 case AT_EXCT:
1823 sim_unlock_in_prog = TRUE;
1824 return MFW_EXCT;
1825 case AT_FAIL:
1826 return MFW_SS_FAIL;
1827 }
1828
1829 }
1830
1831 /*******************************************************************************
1832 $Function: mfw_simlock_disable_lock
1833 $Description: disables the lock with the given password for the given lock
1834 $Returns: success or failure
1835 $Arguments: type of lock and password
1836
1837 *******************************************************************************/
1838 T_MFW mfw_simlock_disable_lock(U8 *pin, S16 lcktyp)
1839 {
1840 T_ACI_CLCK_FAC lckFac;
1841 T_ACI_RETURN ret;
1842
1843 TRACE_FUNCTION("mfw_simlock_disable_lock()");
1844 /* return ss_set_clck(CLCK_FAC_Ps, CLCK_MOD_Lock,
1845 (char *)pin, -1, MFW_SIM_CPINE);*/
1846 lckFac= mfw_simlock_return_lock_type(lcktyp);
1847 ret = sAT_PlusCLCK(CMD_SRC_LCL,lckFac,CLCK_MOD_Unlock,(char*)pin,-1) ;
1848 if(ret != AT_CMPL)
1849 return MFW_SS_FAIL;
1850 else
1851 return MFW_SS_OK;
1852 }
1853
1854 T_MFW mfw_simlock_reset_fc_value(U8 *pin, int fc_flag)
1855 {
1856
1857 T_ACI_CLCK_FAC lckFac;
1858 T_ACI_RETURN stat;
1859 TRACE_FUNCTION("mfw_simlock_reset_fc_value()");
1860 TRACE_EVENT_P1("Vidya: SimLock_MFW FC Password=%s",pin);
1861 lckFac= mfw_simlock_return_lock_type(fc_flag);
1862 stat = sAT_PlusCLCK(CMD_SRC_LCL,lckFac,CLCK_MOD_Unlock,(char*)pin,-1) ;
1863 if( stat != AT_CMPL)
1864 {
1865 TRACE_FUNCTION_P1("Vidya: Reset Failed %d",stat);
1866 return MFW_SS_FAIL;
1867 }
1868 else
1869 {
1870 TRACE_FUNCTION("Vidya: Reset Success");
1871 return MFW_SS_OK;
1872 }
1873 }
1874 // Sept 24, 2005 REF: LOCOSTO-ENH-34438, xpradipg
1875 // this function is never referenced and this inturn calls sAT_PercentSLPVRF
1876 // which has been removed at ACI leve
1877 #if 0
1878 /*******************************************************************************
1879 $Function: mfw_simlock_verify_lock
1880 $Description: If locked, it performs unlock + lock, if unlocks, it performs
1881 lock + unlock, thus validating if the password provided is correct
1882 $Returns: success or failure
1883 $Arguments: type of lock and password
1884
1885 *******************************************************************************/
1886
1887 int mfw_simlock_verify_lock(char* pwd,S16 lock)
1888 {
1889 int status;
1890 T_ACI_CLCK_FAC lckfac;
1891
1892 TRACE_FUNCTION("mfw_simlock_verify_lock()");
1893 TRACE_EVENT_P1("Vidya: SimLock_MFW Password=%s",pwd);
1894
1895 // status = mfw_simlock_get_lock_status(lock);
1896 lckfac=mfw_simlock_return_lock_type(lock);
1897 if(sAT_PercentSLPVRF(CMD_SRC_LCL, lckfac, pwd)==AT_CMPL)
1898 return MFW_SS_OK;
1899 else
1900 return MFW_SS_FAIL;
1901 /*
1902 if(status==MFW_SIM_ENABLE)
1903
1904 {
1905 if( sAT_PlusCLCK(CMD_SRC_LCL,lckfac,CLCK_MOD_Unlock,pwd,CLASS_NotPresent) !=AT_CMPL)
1906 {
1907 TRACE_EVENT("Vidya: SIM_ENABLE unlock fail");
1908 return MFW_SS_FAIL;
1909 }
1910 else
1911 {
1912 if(sAT_PlusCLCK(CMD_SRC_LCL,lckfac,CLCK_MOD_Lock,pwd,CLASS_NotPresent)!=AT_CMPL)
1913 {
1914 TRACE_EVENT("Vidya: SIM_ENABLE lock fail");
1915 return MFW_SS_FAIL;
1916 }
1917 else
1918 return MFW_SS_OK;
1919 }
1920
1921 }
1922 else if(status==MFW_SIM_DISABLE)
1923 {
1924 if( sAT_PlusCLCK(CMD_SRC_LCL,lckfac,CLCK_MOD_Lock,pwd,CLASS_NotPresent) !=AT_CMPL)
1925 {
1926 TRACE_EVENT("Vidya: SIM_DISABLE lock fail");
1927 return MFW_SS_FAIL;
1928 }
1929 else
1930 {
1931 if(sAT_PlusCLCK(CMD_SRC_LCL,lckfac,CLCK_MOD_Unlock,pwd,CLASS_NotPresent)!=AT_CMPL)
1932 {
1933 TRACE_EVENT("Vidya: SIM_DISABLE unlock fail");
1934 return MFW_SS_FAIL;
1935 }
1936 else
1937 return MFW_SS_OK;
1938 }
1939
1940
1941 }
1942 */
1943 /* if(aci_ext_personalisation_MMI_verify_password(pwd) != MMILOCK_VERIFIED)
1944 MFW_SS_FAIL;
1945 else
1946 MFW_SS_OK;*/
1947
1948 }
1949 #endif
1950 /*******************************************************************************
1951 $Function: mfw_simlock_change_lock_code
1952 $Description: Changes the oldpassword with the new one for the given
1953 lock type
1954 $Returns: success or failure
1955 $Arguments: type of lock and old and new password
1956
1957 *******************************************************************************/
1958 T_MFW mfw_simlock_change_lock_code(int type,char*oldpswd,char* newpswd)
1959 {
1960 T_ACI_CLCK_FAC lckType;
1961
1962 switch(type)
1963 {
1964 case MFW_SIM_NLOCK:
1965 lckType = CPWD_FAC_Pn;
1966 break;
1967 case MFW_SIM_SPLOCK:
1968 lckType = CPWD_FAC_Pp;
1969 break;
1970 case MFW_SIM_NSLOCK:
1971 lckType = CPWD_FAC_Pu;
1972 break;
1973 case MFW_SIM_CLOCK:
1974 lckType = CPWD_FAC_Pc;
1975 break;
1976 case MFW_SIM_PLOCK:
1977 lckType = CPWD_FAC_Ps;
1978 break;
1979 }
1980
1981 if(sAT_PlusCPWD(CMD_SRC_LCL, lckType,
1982 (char *)oldpswd,(char *)newpswd)!=AT_CMPL)
1983 return MFW_SS_FAIL;
1984 else
1985 return MFW_SS_OK;
1986 }
1987
1988 #endif
1989
1990 /*
1991 +--------------------------------------------------------------------+
1992 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1993 | STATE : code ROUTINE : sim_ok_cpine |
1994 +--------------------------------------------------------------------+
1995
1996 PURPOSE : Successful end of PIN enability
1997
1998 */
1999
2000 void sim_ok_cpine()
2001 {
2002 TRACE_FUNCTION("sim_ok_cpine()");
2003
2004 sim_status.sim_procedure = MFW_SIM_ENABLE;
2005 sim_status.sim_status = MFW_SIM_SUCCESS;
2006 sim_status.sim_operation_mode = sim_config.oper_mode;
2007 sim_status.sim_pin_retries = 0;
2008 sim_status.sim_status_type = MFW_SIM_UNKNOWN; // no indication
2009
2010 pin1_set = MFW_SIM_ENABLE;
2011 sim_signal(E_SIM_STATUS,&sim_status);
2012 }
2013
2014
2015 /*
2016 +--------------------------------------------------------------------+
2017 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2018 | STATE : code ROUTINE : sim_error_cpine |
2019 +--------------------------------------------------------------------+
2020
2021 PURPOSE : Failed PIN enability
2022
2023 */
2024
2025 void sim_error_cpine (void)
2026 {
2027 TRACE_FUNCTION("sim_error_cpine()");
2028
2029 sim_status.sim_procedure = MFW_SIM_ENABLE;
2030 sim_status.sim_status = MFW_SIM_FAILURE;
2031 sim_status.sim_operation_mode = sim_config.oper_mode;
2032 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN1);
2033 sim_status.sim_status_type = MFW_SIM_UNKNOWN; // no indication
2034
2035 sim_signal(E_SIM_STATUS,&sim_status);
2036 }
2037
2038
2039 /*
2040 +--------------------------------------------------------------------+
2041 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2042 | STATE : code ROUTINE : sim_check_service |
2043 +--------------------------------------------------------------------+
2044
2045 PURPOSE : Checks a service status
2046
2047 */
2048
2049 U8 sim_check_service (U8 nr, U8 *serv_table)
2050 {
2051 U8 value;
2052
2053 TRACE_FUNCTION("sim_check_service()");
2054
2055 value = *(serv_table + (nr - 1) / 4);
2056 value >>= ((nr - 1) & 3) * 2;
2057
2058 return (value & 3);
2059 }
2060
2061
2062 /*
2063 +-----------------------------------------------------------------------+
2064 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2065 | STATE : code ROUTINE : sim_serv_table_check |
2066 +-----------------------------------------------------------------------+
2067
2068 PURPOSE : Checks a service status in SIM service table
2069
2070 */
2071
2072 T_MFW sim_serv_table_check(UBYTE serv_num)
2073 {
2074 TRACE_FUNCTION("sim_serv_table_check()");
2075 return sim_check_service(serv_num, sim_service_table);
2076 }
2077
2078
2079 /*
2080 +--------------------------------------------------------------------+
2081 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2082 | STATE : code ROUTINE : rAT_PlusCFUNP |
2083 +--------------------------------------------------------------------+
2084
2085 PURPOSE : MMI relevant parameters from the SIM card
2086
2087 */
2088
2089 void rAT_PlusCFUNP (T_SIM_MMI_INSERT_IND *mmi_insert_ind)
2090 {
2091 TRACE_FUNCTION("rAT_PlusCFUNP()");
2092
2093 sim_stat = SIM_ACTIVE;
2094
2095 sim_config.oper_mode = mmi_insert_ind->func;
2096 nm_mmi_parameters(&mmi_insert_ind->imsi_field,
2097 &mmi_insert_ind->pref_plmn);
2098 #ifdef FF_2TO1_PS
2099 memcpy(sim_service_table,mmi_insert_ind->serv_table,
2100 #else
2101 memcpy(sim_service_table,mmi_insert_ind->sim_serv,
2102 #endif
2103 sizeof(sim_service_table));
2104 sim_config.phase = mmi_insert_ind->phase;
2105 sim_config.access_acm = mmi_insert_ind->access_acm;
2106 sim_config.access_acmmax = mmi_insert_ind->access_acmmax;
2107 sim_config.access_puct = mmi_insert_ind->access_puct;
2108
2109
2110 /* Apr 13, 2004 REF: CRR 16303 JuanVi Jativa-Villoldo */
2111 /* SPN must always be read, not only when nm_registration is called */
2112 sim_spn_req();
2113
2114 //x0pleela 08 Feb, 2006 ER: OMAPS00065203
2115 //Check for services 51 - OPL and 52 - PNN
2116
2117 //x0pleela 15 Feb, 2006 ER OMAPS00065203
2118 //Combined both checks for services 51 and 52 as per review comments
2119 if ( (sim_check_service(51,sim_service_table)
2120 EQ ALLOCATED_AND_ACTIVATED) OR
2121 (sim_check_service(52,sim_service_table)
2122 EQ ALLOCATED_AND_ACTIVATED) )
2123 {
2124 gEons_alloc_active = TRUE;
2125 }
2126 else
2127 {
2128 gEons_alloc_active = FALSE;
2129 }
2130
2131 if (sim_check_service(15,sim_service_table)
2132 == ALLOCATED_AND_ACTIVATED)
2133 sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, 5);
2134 #ifdef BMI_TEST_MC_SIM_EVENT
2135 TRACE_EVENT("Reading SIM_ICCID");
2136 sim_read_sim(SIM_ICCID, NOT_PRESENT_8BIT, 5);
2137 #endif
2138 }
2139
2140
2141 /*
2142 +--------------------------------------------------------------------+
2143 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2144 | STATE : code ROUTINE : sim_mmi_parameter |
2145 +--------------------------------------------------------------------+
2146
2147 PURPOSE : MMI relevant parameters from the SIM card
2148
2149 */
2150
2151 void sim_mmi_parameter(T_SIM_ACTIVATE_CNF *sim_act_cnf)
2152 {
2153 TRACE_FUNCTION("sim_mmi_parameter()");
2154
2155 memcpy( sim_config.pref_lang, sim_act_cnf->pref_lang, 5);
2156 }
2157
2158
2159 /*
2160 +--------------------------------------------------------------------+
2161 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2162 | STATE : code ROUTINE : sim_gid1_cnf |
2163 +--------------------------------------------------------------------+
2164
2165 PURPOSE : read SIM group identifier 1 from SIM card
2166
2167 */
2168
2169 void sim_gid1_cnf(SHORT error, UBYTE *data)
2170 {
2171 TRACE_FUNCTION("sim_gid1_cnf()");
2172
2173 #ifdef FF_2TO1_PS
2174 if (error EQ CAUSE_SIM_NO_ERROR)
2175 #else
2176 if (error EQ SIM_NO_ERROR)
2177 #endif
2178 memcpy(sim_config.sim_gidl1, data, 5);
2179
2180 if (!sat_update)
2181 {
2182 if (sim_check_service(16,sim_service_table)
2183 == ALLOCATED_AND_ACTIVATED)
2184 sim_read_sim(SIM_GID2, NOT_PRESENT_8BIT, 5);
2185 }
2186 #ifdef SIM_TOOLKIT
2187 else
2188 {
2189 sat_update = FALSE;
2190 satUpdateFiles ( TRUE, SIM_GID1 );
2191 }
2192 #endif
2193 }
2194
2195
2196 /*
2197 +--------------------------------------------------------------------+
2198 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2199 | STATE : code ROUTINE : sim_gid2_cnf |
2200 +--------------------------------------------------------------------+
2201
2202 PURPOSE : read SIM group identifier 2 from SIM card
2203
2204 */
2205
2206 void sim_gid2_cnf(SHORT error, UBYTE *data)
2207 {
2208 TRACE_FUNCTION("sim_gid2_cnf()");
2209 #ifdef FF_2TO1_PS
2210 if (error EQ CAUSE_SIM_NO_ERROR)
2211 #else
2212 if (error EQ SIM_NO_ERROR)
2213 #endif
2214 memcpy(sim_config.sim_gidl2, data, 5);
2215
2216 #ifdef SIM_TOOLKIT
2217 if ( sat_update )
2218 {
2219 sat_update = FALSE;
2220 satUpdateFiles ( TRUE, SIM_GID2 );
2221 }
2222 #endif
2223 }
2224
2225
2226 /*
2227 +--------------------------------------------------------------------+
2228 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2229 | STATE : code ROUTINE : sim_save_pref_lang |
2230 +--------------------------------------------------------------------+
2231
2232 PURPOSE : save preferred language
2233
2234 */
2235
2236 void sim_save_pref_lang (UBYTE *lang, UBYTE len)
2237 {
2238 UBYTE sim_data[7];
2239 UBYTE i;
2240
2241 TRACE_FUNCTION("sim_save_pref_lang()");
2242
2243 //
2244 // copy a maximum of 5 bytes for storing on the SIM card
2245 //
2246 for (i=0;i<len AND i<5;i++)
2247 sim_data[i] = lang[i];
2248
2249 //
2250 // if less than 5 bytes fill with dummy values
2251 //
2252 for (i=len; i<5;i++)
2253 sim_data[i] = 0xFF;
2254
2255 //
2256 // write to the SIM card
2257 //
2258 sim_write_sim(SIM_LP, sim_data, 5);
2259 }
2260
2261
2262 /*
2263 +--------------------------------------------------------------------+
2264 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2265 | STATE : code ROUTINE : rAT_PercentSIMREM |
2266 +--------------------------------------------------------------------+
2267
2268 PURPOSE : call back for SIM removed
2269
2270 */
2271
2272 void rAT_PercentSIMREM( T_ACI_SIMREM_TYPE srType )
2273 {
2274 TRACE_FUNCTION("rAT_PercentSIMREM()");
2275
2276 if ( srType EQ SIMREM_FAILURE )
2277 {
2278 sim_status.sim_procedure = MFW_SIM_REMOVED;
2279 sim_status.sim_status = MFW_SIM_NO_SIM_CARD;
2280 sim_status.sim_operation_mode = sim_config.oper_mode;
2281 sim_status.sim_pin_retries = 0;
2282 sim_status.sim_status_type = MFW_SIM_UNKNOWN;
2283 sim_stat = SIM_NOT_ACTIVE;
2284 sim_signal(E_SIM_STATUS,&sim_status);
2285 }
2286 else if ( srType EQ SIMREM_RESET )
2287 {
2288 #ifdef SIM_TOOLKIT
2289 sim_signal(E_SIM_RESET, 0);
2290 #endif
2291 }
2292 }
2293
2294
2295 /*
2296 +--------------------------------------------------------------------+
2297 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2298 | STATE : code ROUTINE : rAT_percentSIMINS |
2299 +--------------------------------------------------------------------+
2300
2301 PURPOSE : call back for SIM inserted
2302
2303 */
2304
2305 void rAT_PercentSIMINS( T_ACI_CME_ERR err )
2306 {
2307 TRACE_FUNCTION("rAT_percentSIMINS()");
2308
2309 sim_signal(E_SIM_INSERTED, 0);
2310
2311 switch ( err )
2312 {
2313 case CME_ERR_SimPinReq:
2314 sim_status.sim_status = MFW_SIM_PIN_REQ;
2315 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PIN1);
2316 sim_status.sim_status_type = MFW_SIM_PIN1;
2317 sim_stat = SIM_ACTIVE;
2318 sim_signal(E_SIM_STATUS, &sim_status);
2319 break;
2320
2321 case CME_ERR_SimPukReq:
2322 sim_status.sim_status = MFW_SIM_PUK_REQ;
2323 sim_status.sim_pin_retries = sim_pin_count(MFW_SIM_PUK1);
2324 sim_status.sim_status_type = MFW_SIM_PUK1;
2325 sim_stat = SIM_ACTIVE;
2326 sim_signal(E_SIM_STATUS, &sim_status);
2327 break;
2328
2329 default:
2330 break;
2331 }
2332 }
2333
2334 /*
2335 +--------------------------------------------------------------------+
2336 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2337 | STATE : code ROUTINE : sim_configuration |
2338 +--------------------------------------------------------------------+
2339
2340 PURPOSE : Request the configuration of SIM card
2341
2342 */
2343
2344 UBYTE sim_cvt_access_status(UBYTE acs)
2345 {
2346 TRACE_FUNCTION("sim_cvt_access_status()");
2347
2348 switch(acs)
2349 {
2350 #ifdef FF_2TO1_PS
2351 case SIM_ACCESS_ALWAYS: return MFW_SIM_NO_PIN;
2352 case SIM_ACCESS_PIN_1: return MFW_SIM_PIN1;
2353 case SIM_ACCESS_PIN_2: return MFW_SIM_PIN2;
2354 #else
2355 case ACCESS_ALWAYS: return MFW_SIM_NO_PIN;
2356 case ACCESS_PIN_1: return MFW_SIM_PIN1;
2357 case ACCESS_PIN_2: return MFW_SIM_PIN2;
2358 #endif
2359 default: return MFW_SIM_UNKNOWN;
2360 }
2361 }
2362
2363
2364 /*
2365 +--------------------------------------------------------------------+
2366 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2367 | STATE : code ROUTINE : sim_configuration |
2368 +--------------------------------------------------------------------+
2369
2370 PURPOSE : Request the configuration of SIM card
2371
2372 */
2373
2374 MfwRes sim_configuration (U8 *phase, U8 *serv, U8 *slen,
2375 U8 *lang, U8 *llen,
2376 T_MFW_AOC_ACCESS *access)
2377 {
2378 U8 l;
2379 TRACE_FUNCTION("sim_configuration()");
2380
2381 //PATCH2 TB 1310: Add test of NULL parameter to avoid to declare parameter of unwanted data
2382 if (sim_stat != SIM_ACTIVE)
2383 return MFW_SIM_FAILURE;
2384
2385 if (phase != NULL)
2386 *phase = sim_config.phase;
2387
2388 if ((serv != NULL) && (slen != NULL))
2389 {
2390 l = sizeof(sim_service_table);
2391 if (l < *slen)
2392 *slen = l;
2393 memcpy(serv,sim_service_table,*slen);
2394 }
2395
2396 //PATCH1 TB 1310: replace slen by llen
2397 if ((lang != NULL) && (llen != NULL))
2398 {
2399 l = sizeof(sim_config.pref_lang);
2400 if (l < *llen)
2401 *llen = l;
2402 memcpy(lang, sim_config.pref_lang, *llen);
2403 }
2404 //END PATCH1 TB
2405
2406 if (access != NULL)
2407 {
2408 access->access_acm = sim_cvt_access_status(sim_config.access_acm);
2409 access->access_acmmax = sim_cvt_access_status(sim_config.access_acmmax);
2410 access->access_puct = sim_cvt_access_status(sim_config.access_puct);
2411 }
2412 //END PATCH2 TB
2413
2414 return MFW_SIM_SUCCESS;
2415 }
2416
2417
2418 /*
2419 +--------------------------------------------------------------------+
2420 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2421 | STATE : code ROUTINE : sim_status_check |
2422 +--------------------------------------------------------------------+
2423
2424 PURPOSE : check activation of SIM card
2425
2426 */
2427
2428 int sim_status_check (void)
2429 {
2430 TRACE_FUNCTION("sim_status_check()");
2431
2432 return sim_stat;
2433 }
2434
2435
2436 /*
2437 +--------------------------------------------------------------------+
2438 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2439 | STATE : code ROUTINE : sim_pin_count |
2440 +--------------------------------------------------------------------+
2441
2442 PURPOSE : Request PIN/PUK count
2443
2444 */
2445
2446 int sim_pin_count(U8 pin_id)
2447 {
2448 SHORT pn1Cnt;
2449 SHORT pn2Cnt;
2450 SHORT pk1Cnt;
2451 SHORT pk2Cnt;
2452 T_ACI_PVRF_STAT ps1;
2453 T_ACI_PVRF_STAT ps2;
2454
2455 TRACE_FUNCTION("sim_pin_count()");
2456
2457
2458 if (qAT_PercentPVRF(CMD_SRC_LCL, &pn1Cnt,
2459 &pn2Cnt, &pk1Cnt, &pk2Cnt, &ps1, &ps2) != AT_CMPL)
2460 return -1;
2461
2462 switch (pin_id)
2463 {
2464 case MFW_SIM_PIN1: return pn1Cnt;
2465 case MFW_SIM_PIN2: return pn2Cnt;
2466 case MFW_SIM_PUK1: return pk1Cnt;
2467 case MFW_SIM_PUK2: return pk2Cnt;
2468 default: return -1;
2469 }
2470 }
2471
2472 int SimHasPin(U8 pin_id)
2473 {
2474 SHORT pn1Cnt;
2475 SHORT pn2Cnt;
2476 SHORT pk1Cnt;
2477 SHORT pk2Cnt;
2478 T_ACI_PVRF_STAT ps1;
2479 T_ACI_PVRF_STAT ps2;
2480
2481 TRACE_FUNCTION("sim_pin_count()");
2482
2483
2484 if (qAT_PercentPVRF(CMD_SRC_LCL, &pn1Cnt,
2485 &pn2Cnt, &pk1Cnt, &pk2Cnt, &ps1, &ps2) != AT_CMPL)
2486 return -1;
2487 /***************************Go-lite Optimization changes Start***********************/
2488 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
2489 TRACE_EVENT_P1("PIN2 STATUS: %d", ps2);
2490 /***************************Go-lite Optimization changes end***********************/
2491 switch (pin_id)
2492 {
2493 case MFW_SIM_PIN1:
2494 { if (ps1 ==PVRF_STAT_NotPresent)
2495 return 0;
2496 else
2497 return 1;
2498 } // break; // RAVI
2499 case MFW_SIM_PIN2:
2500 { if (ps2 ==PVRF_STAT_NotPresent)
2501 return 0;
2502 else
2503 return 1;
2504 }// break; // RAVI
2505 default: return -1;
2506 }
2507 }
2508
2509 /*SPR 1351, added new function*/
2510 /*
2511 +---------------------------------------------------------------------+
2512 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2513 | STATE : code ROUTINE : sim_convert_simlock_status|
2514 +---------------------------------------------------------------------+
2515
2516 PURPOSE : Conversion of ACI simlock status to MFW simlock status codes for
2517 compatibility with existing MMI layer.
2518
2519 */
2520 UBYTE sim_convert_simlock_status(T_SIMLOCK_STATUS aci_status)
2521 {
2522 switch(aci_status)
2523 {
2524 case(SIMLOCK_DISABLED): return MFW_SIM_DISABLE; //break; // RAVI
2525 case(SIMLOCK_ENABLED): return MFW_SIM_ENABLE; //break; // RAVI
2526 case(SIMLOCK_BLOCKED): return MFW_SIM_BLOCKED; // break; // RAVI
2527 case(SIMLOCK_LOCKED): return MFW_SIM_LOCKED; //break; // RAVI
2528 case (SIMLOCK_FAIL): return MFW_SIM_FAILURE; // break; // RAVI
2529 default: return MFW_SIM_FAILURE;
2530 }
2531
2532 }
2533 /*
2534 +---------------------------------------------------------------------+
2535 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2536 | STATE : code ROUTINE : sim_unlock_sim_lock |
2537 +---------------------------------------------------------------------+
2538
2539 PURPOSE : de-personalisation(unlocking) for SIM lock.
2540 Returns code for lock type if successful, or return MFW_SIM_UNLOCK_ERR if not.
2541
2542 */
2543 /*MC SPR1351, replaced previous implemnetation with wrapper for aci implementation*/
2544 T_MFW sim_unlock_sim_lock(UBYTE type, UBYTE *passwd)
2545 {
2546
2547 T_SIMLOCK_STATUS simlock_status=SIMLOCK_DISABLED;/*status from ACI */
2548 /*for CQ-34324 -- While Integrating of VLE5 ME personalization code aci_slock_unlock
2549 function is moved under SIM_PERS flag and this function is never called . So variable
2550 simlock_status is hardcoded to default value */
2551 UBYTE mfw_simlock_status;/*status converted to MFW encoding*/
2552
2553 TRACE_EVENT_P1("sim_unlock_sim_lock(): %d", type);
2554
2555
2556 switch (type)
2557 {
2558 /*
2559 * N-Lock
2560 */
2561 case MFW_SIM_NLOCK:
2562 #ifdef MMI_34324
2563 simlock_status= aci_slock_unlock(SIMLOCK_NETWORK, (char*)passwd);
2564 #endif
2565 mfw_simlock_status = sim_convert_simlock_status(simlock_status);
2566 switch(mfw_simlock_status)
2567 {
2568 case (MFW_SIM_DISABLE): return MFW_SIM_NLOCK;
2569 case(MFW_SIM_LOCKED): return MFW_SIM_UNLOCK_ERR;
2570 default: return MFW_SIM_UNLOCK_ERR;
2571 }
2572 // break; // RAVI
2573
2574 /*
2575 * SP-Lock
2576 */
2577 case MFW_SIM_SPLOCK:
2578 #ifdef MMI_34324
2579 simlock_status = aci_slock_unlock(SIMLOCK_SERVICE_PROVIDER, (char*)passwd);
2580 #endif
2581 mfw_simlock_status = sim_convert_simlock_status(simlock_status);
2582 switch(mfw_simlock_status)
2583 {
2584
2585 case (MFW_SIM_DISABLE): return MFW_SIM_SPLOCK;
2586 case(MFW_SIM_LOCKED): return MFW_SIM_UNLOCK_ERR;
2587 default: return MFW_SIM_UNLOCK_ERR;
2588 }
2589 // break; // RAVI
2590
2591 /*
2592 * NS-Lock
2593 */
2594 case MFW_SIM_NSLOCK:
2595 #ifdef MMI_34324
2596 simlock_status = aci_slock_unlock(SIMLOCK_NETWORK_SUBSET, (char*)passwd);
2597 #endif
2598 mfw_simlock_status = sim_convert_simlock_status(simlock_status);
2599 switch(mfw_simlock_status)
2600 {
2601
2602 case (MFW_SIM_DISABLE): return MFW_SIM_NSLOCK;
2603 case(MFW_SIM_LOCKED): return MFW_SIM_UNLOCK_ERR;
2604 default: return MFW_SIM_UNLOCK_ERR;
2605 }
2606 // break; // RAVI
2607
2608 /*
2609 * C-Lock
2610 */
2611 case MFW_SIM_CLOCK:
2612 #ifdef MMI_34324
2613 simlock_status = aci_slock_unlock(SIMLOCK_CORPORATE, (char*)passwd);
2614 #endif
2615 mfw_simlock_status = sim_convert_simlock_status(simlock_status);
2616 switch(mfw_simlock_status)
2617 {
2618
2619 case (MFW_SIM_DISABLE): return MFW_SIM_CLOCK;
2620 case(MFW_SIM_LOCKED): return MFW_SIM_UNLOCK_ERR;
2621 default: return MFW_SIM_UNLOCK_ERR;
2622 }
2623 // break; // RAVI
2624
2625 /*
2626 * P-Lock
2627 */
2628 case MFW_SIM_PLOCK:
2629
2630 #ifdef MMI_34324
2631 simlock_status = aci_slock_unlock( SIMLOCK_SIM, (char*)passwd);
2632 #endif
2633 mfw_simlock_status = sim_convert_simlock_status(simlock_status);
2634 switch(mfw_simlock_status)
2635 {
2636 case (MFW_SIM_DISABLE): return MFW_SIM_PLOCK;
2637 case(MFW_SIM_LOCKED): return MFW_SIM_UNLOCK_ERR;
2638 default:return MFW_SIM_UNLOCK_ERR;
2639 }
2640 // break; // RAVI
2641
2642 }
2643
2644 return MFW_SIM_UNLOCK_ERR;
2645 }
2646
2647 /*
2648 +---------------------------------------------------------------------+
2649 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2650 | STATE : code ROUTINE : sim_check_sim_Plock |
2651 +---------------------------------------------------------------------+
2652
2653 PURPOSE : check SIM lock
2654
2655 */
2656 /*MC SPR1351, replaced previous implemnetation with wrapper for aci implementation*/
2657 int sim_check_sim_Plock (void)
2658 { T_SIMLOCK_STATUS simlock_status = SIMLOCK_DISABLED;
2659 /*ACI set default value for CQ-34324--While Integrating of VLE5 ME personalization code
2660 aci_slock_checklock function is removed and this function is never called. So variable
2661 simlock_status is hardcoded to default value
2662 */
2663
2664 TRACE_EVENT ("sim_check_sim_Plock");
2665 #ifdef MMI_34324
2666 simlock_status =aci_slock_checklock(SIMLOCK_SIM);
2667 #endif
2668 TRACE_EVENT_P1("PLock: %d", simlock_status);
2669 /*convert status from ACI to MFW encoding*/
2670 return sim_convert_simlock_status(simlock_status);
2671
2672 }
2673
2674
2675 /*
2676 +---------------------------------------------------------------------+
2677 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2678 | STATE : code ROUTINE : sim_check_sim_Nlock |
2679 +---------------------------------------------------------------------+
2680
2681 PURPOSE : Check network lock
2682
2683 */
2684 /*MC SPR1351, replaced previous implemnetation with wrapper for aci implementation*/
2685 int sim_check_sim_Nlock (void)
2686 { T_SIMLOCK_STATUS simlock_status = SIMLOCK_DISABLED;
2687 /*ACI set default value for CQ-34324--While Integrating of VLE5 ME personalization code
2688 aci_slock_checklock function is removed and this function is never called. So variable
2689 simlock_status is hardcoded to default value
2690 */
2691 TRACE_EVENT ("sim_check_sim_Nlock()");
2692 #ifdef MMI_34324
2693 simlock_status =aci_slock_checklock(SIMLOCK_NETWORK);
2694 #endif
2695 TRACE_EVENT_P1("NLock: %d", simlock_status);
2696 /*convert status from ACI to MFW encoding*/
2697 return sim_convert_simlock_status(simlock_status);
2698
2699
2700 }
2701
2702
2703 /*
2704 +---------------------------------------------------------------------+
2705 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2706 | STATE : code ROUTINE : sim_check_sim_SPlock|
2707 +---------------------------------------------------------------------+
2708
2709 PURPOSE : Check SIM service provider lock. It only works with SIMs
2710 which support GID1 file.
2711
2712 */
2713 /*MC SPR1351, replaced previous implemnetation with wrapper for aci implementation*/
2714 int sim_check_sim_SPlock (void)
2715 { T_SIMLOCK_STATUS simlock_status = SIMLOCK_DISABLED;
2716 /*ACI set default value for CQ-34324--While Integrating of VLE5 ME personalization code
2717 aci_slock_checklock function is removed and this function is never called. So variable
2718 simlock_status is hardcoded to default value
2719 */
2720 TRACE_EVENT ("sim_check_sim_SPlock()");
2721
2722 #ifdef MMI_34324
2723 simlock_status =aci_slock_checklock(SIMLOCK_SERVICE_PROVIDER);
2724 #endif
2725
2726 TRACE_EVENT_P1("NLock: %d", simlock_status);
2727 /*convert status from ACI to MFW encoding*/
2728 return sim_convert_simlock_status(simlock_status);
2729
2730 }
2731
2732
2733 /*
2734 +---------------------------------------------------------------------+
2735 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2736 | STATE : code ROUTINE : sim_check_sim_NSlock|
2737 +---------------------------------------------------------------------+
2738
2739 PURPOSE : Check network subset lock
2740
2741 */
2742 /*MC SPR1351, replaced previous implementation with wrapper for aci implementation*/
2743 int sim_check_sim_NSlock (void)
2744 { T_SIMLOCK_STATUS simlock_status = SIMLOCK_DISABLED;
2745 /*ACI set default value for CQ-34324--While Integrating of VLE5 ME personalization code
2746 aci_slock_checklock function is removed and this function is never called. So variable
2747 simlock_status is hardcoded to default value
2748 */
2749 TRACE_EVENT ("sim_check_sim_NSlock()");
2750
2751 #ifdef MMI_34324
2752 simlock_status =aci_slock_checklock(SIMLOCK_NETWORK_SUBSET);
2753 #endif
2754 TRACE_EVENT_P1("NSLock: %d", simlock_status);
2755
2756 /*convert status from ACI to MFW encoding*/
2757 return sim_convert_simlock_status(simlock_status);
2758 }
2759
2760 /*
2761 +---------------------------------------------------------------------+
2762 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2763 | STATE : code ROUTINE : sim_check_sim_Clock |
2764 +---------------------------------------------------------------------+
2765
2766 PURPOSE : Check corporate lock. It only works with SIMs
2767 which support GID1 and GID2 files.
2768
2769 */
2770 /*MC SPR1351, replaced previous implemnetation with wrapper for aci implementation*/
2771 int sim_check_sim_Clock (void)
2772 { T_SIMLOCK_STATUS simlock_status = SIMLOCK_DISABLED;
2773 /*ACI set default value for CQ-34324--While Integrating of VLE5 ME personalization code
2774 aci_slock_checklock function is removed and this function is never called. So variable
2775 simlock_status is hardcoded to default value
2776 */
2777 TRACE_EVENT ("sim_check_sim_Clock()");
2778 #ifdef MMI_34324
2779 simlock_status =aci_slock_checklock(SIMLOCK_CORPORATE);
2780 #endif
2781 TRACE_EVENT_P1("CLock: %d", simlock_status);
2782 /*convert status from ACI to MFW encoding*/
2783 return sim_convert_simlock_status(simlock_status);
2784 }
2785
2786
2787
2788 /*
2789 +--------------------------------------------------------------------+
2790 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2791 | STATE : code ROUTINE : sim_pin_status |
2792 +--------------------------------------------------------------------+
2793
2794 PURPOSE : Request PIN1/PIN2 status
2795
2796 */
2797
2798 void sim_pin_status(T_MFW_SIM_PIN_STATUS *status)
2799 {
2800 SHORT pn1Cnt;
2801 SHORT pn2Cnt;
2802 SHORT pk1Cnt;
2803 SHORT pk2Cnt;
2804 T_ACI_PVRF_STAT ps1;
2805 T_ACI_PVRF_STAT ps2;
2806 // char debug[30]; // RAVI
2807 TRACE_FUNCTION("sim_pin_status()");
2808
2809 status->stat = MFW_SIM_UNKNOWN;
2810 status->set = MFW_SIM_UNKNOWN;
2811
2812 if (qAT_PercentPVRF(CMD_SRC_LCL, &pn1Cnt,
2813 &pn2Cnt, &pk1Cnt, &pk2Cnt, &ps1, &ps2) == AT_CMPL)
2814 {
2815 switch (status->type)
2816 {
2817 case MFW_SIM_PIN1:
2818 /*CONQ 5578, check service table to see if allowed to disable PIN1*/
2819 if (!psaSIM_ChkSIMSrvSup(SRV_CHV1_Disable))
2820 {
2821 status->stat = MFW_SIM_NO_DISABLE;
2822 }
2823 else
2824 {
2825 status->stat = sim_cvtPINstatus(ps1, MFW_SIM_PIN1);
2826 }
2827 status->set = pin1_set;
2828 break;
2829 case MFW_SIM_PIN2:
2830 status->stat = sim_cvtPINstatus(ps2, MFW_SIM_PIN2);
2831 status->set = pin2_set;
2832 break;
2833 }
2834 }
2835 }
2836
2837
2838 /*
2839 +--------------------------------------------------------------------+
2840 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2841 | STATE : code ROUTINE : sim_cvtPINstatus |
2842 +--------------------------------------------------------------------+
2843
2844 PURPOSE :
2845
2846 */
2847
2848 UBYTE sim_cvtPINstatus(T_ACI_PVRF_STAT ps, UBYTE type)
2849 {
2850 TRACE_FUNCTION("sim_cvtPINstatus()");
2851
2852 switch (ps)
2853 {
2854 case PVRF_STAT_NotRequired:
2855 return MFW_SIM_NO_PIN;
2856 case PVRF_STAT_Required:
2857 if (type EQ MFW_SIM_PIN1)
2858 return MFW_SIM_PIN_REQ;
2859 if (type EQ MFW_SIM_PIN2)
2860 return MFW_SIM_PIN2_REQ;
2861 return MFW_SIM_UNKNOWN;
2862 default:
2863 return MFW_SIM_UNKNOWN;
2864 }
2865 }
2866
2867
2868 /*
2869 +--------------------------------------------------------------------+
2870 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2871 | STATE : code ROUTINE : simDecodeIMSI |
2872 +--------------------------------------------------------------------+
2873
2874 PURPOSE : convert imsi (packed bcd to ASCIIZ; ->11.11)
2875
2876 */
2877
2878 void simDecodeIMSI (UBYTE * imsi_field,
2879 UBYTE imsi_c_field,
2880 UBYTE * imsi_extracted)
2881 {
2882 UBYTE length;
2883 UBYTE i;
2884 UBYTE digit;
2885
2886 TRACE_FUNCTION ("simDecodeImsi()");
2887
2888 /*
2889 * calculate number of digits
2890 */
2891 length = (imsi_c_field-1)*2;
2892
2893 /*
2894 * if odd number of digits add one
2895 */
2896 if (imsi_field[0] & 0x08)
2897 length++;
2898
2899 /*
2900 * extract all digits
2901 */
2902 for (i = 0; i < length; i++)
2903 {
2904 digit = (i & 1) ?
2905 imsi_field[(i + 1) / 2] & 0x0f :
2906 (imsi_field[(i + 1) / 2] & 0xf0) >> 4;
2907
2908 #if defined (WIN32)
2909 {
2910 /***************************Go-lite Optimization changes Start***********************/
2911 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
2912 TRACE_EVENT_P2("DIGIT [%d] = %d",i, digit);
2913 /***************************Go-lite Optimization changes end***********************/
2914 }
2915 #endif
2916 if (i < LONG_NAME)
2917 imsi_extracted [i] = digit + 0x30;
2918 else
2919 {
2920 imsi_extracted [i] = 0;
2921 return;
2922 }
2923 }
2924 }
2925
2926 /*
2927 +--------------------------------------------------------------------+
2928 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2929 | STATE : code ROUTINE : sim_pin_ident |
2930 +--------------------------------------------------------------------+
2931
2932 PURPOSE : handle mfw windows command
2933
2934 */
2935
2936 void sim_pin_ident(UBYTE id)
2937 {
2938 TRACE_FUNCTION("sim_pin_ident()");
2939 pin_ident = id;
2940 }
2941
2942
2943
2944 /*
2945 +--------------------------------------------------------------------+
2946 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2947 | STATE : code ROUTINE : simCommand |
2948 +--------------------------------------------------------------------+
2949
2950 PURPOSE : handle mfw windows command
2951
2952 */
2953
2954 static int simCommand (U32 cmd, void *h)
2955 {
2956 switch (cmd)
2957 {
2958 case MfwCmdDelete: /* delete me */
2959 if (!h)
2960 return 0;
2961 sim_delete(h);
2962 return 1;
2963 default:
2964 break;
2965 }
2966
2967 return 0;
2968 }
2969
2970
2971
2972
2973
2974
2975
2976 /*
2977 +--------------------------------------------------------------------+
2978 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
2979 | STATE : code ROUTINE : sim_simlock_ok |
2980 +--------------------------------------------------------------------+
2981
2982 PURPOSE : The function checks all simlocks and returns SIMLOCK_DISABLED
2983 if none are set.
2984
2985 */
2986 /*spr 1351, replaced previous implemntation with a wrapper for aci implentation*/
2987 UBYTE sim_simlock_ok (void)
2988 {
2989 T_SIMLOCK_STATUS simlock_status = SIMLOCK_ENABLED;
2990 /*ACI set default value for CQ-34324 -- While Integrating of VLE5 ME personalization code
2991 aci_slock_checkpersonalisation function is moved under SIM_PERS flag and this function is
2992 never called . So variable simlock_status is hardcoded to default value */
2993 #ifdef MMI_34324
2994 simlock_status = aci_slock_checkpersonalisation();
2995 #endif
2996 return sim_convert_simlock_status(simlock_status);
2997
2998 }
2999
3000 void mfwSimRestartPinEntry(void)
3001 {
3002 sim_signal(E_SIM_STATUS, &sim_status);
3003 return;
3004 }
3005
3006 /*
3007 +--------------------------------------------------------------------+
3008 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
3009 | STATE : code ROUTINE : sim_get_imsi |
3010 +--------------------------------------------------------------------+
3011
3012 PURPOSE : Request IMSI number in SIM card
3013
3014 */
3015
3016 UBYTE * sim_get_imsi (void)
3017 {
3018 return mfw_IMSI;
3019 }
3020
3021 /*
3022 +---------------------------------------------------------------------+
3023 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
3024 | STATE : code ROUTINE : sim_mmi_update_parameter |
3025 +---------------------------------------------------------------------+
3026
3027 PURPOSE : MMI relevant parameters from the SIM card
3028
3029 */
3030
3031 void sim_mmi_update_parameter(T_SIM_ACTIVATE_IND *sim_act_ind)
3032 {
3033 TRACE_FUNCTION("sim_mmi_update_parameter()");
3034
3035 memcpy( sim_config.pref_lang, sim_act_ind->pref_lang, 5);
3036 }
3037
3038 #ifdef SIM_TOOLKIT
3039 /*
3040 +---------------------------------------------------------------------+
3041 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
3042 | STATE : code ROUTINE : sim_sat_file_update |
3043 +---------------------------------------------------------------------+
3044
3045 PURPOSE : SIM file change indication
3046
3047 */
3048
3049 void sim_sat_file_update(USHORT dataId)
3050 {
3051 TRACE_FUNCTION("sim_sat_file_update()");
3052
3053 sat_update = TRUE;
3054 switch (dataId)
3055 {
3056 case SIM_SST:
3057 sim_read_sim(SIM_SST, NOT_PRESENT_8BIT, 10);
3058 break;
3059 case SIM_GID1:
3060 sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, 5);
3061 break;
3062 case SIM_GID2:
3063 sim_read_sim(SIM_GID2, NOT_PRESENT_8BIT, 5);
3064 break;
3065 case SIM_LP:
3066 {
3067 T_ACI_LAN_SUP lngCde;
3068 CHAR lang_buffer[3];
3069
3070 memset(lang_buffer, 0, sizeof(lang_buffer));
3071 lngCde.str = lang_buffer;
3072 if (qAT_PlusCLAN(CMD_SRC_LCL, &lngCde) == AT_EXCT)
3073 return;
3074 #ifdef SIM_TOOLKIT
3075 else
3076 if (mfwSATLPRefresh)
3077 {
3078 sat_update = FALSE;
3079 mfwSATLPRefresh =FALSE;
3080 psaSAT_FUConfirm (0, SIM_FU_ERROR); /*If not possible, notify to the SIM */
3081 }
3082 #endif
3083 }
3084 break;
3085 default:
3086 break;
3087 }
3088 }
3089 #endif
3090
3091 /*
3092 +---------------------------------------------------------------------+
3093 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
3094 | STATE : code ROUTINE : sim_read_sst_cnf |
3095 +---------------------------------------------------------------------+
3096
3097 PURPOSE : SIM file change indication
3098
3099 */
3100
3101 void sim_read_sst_cnf (SHORT error, UBYTE *data)
3102 {
3103 TRACE_FUNCTION("sim_read_sst_cnf()");
3104
3105 #ifdef FF_2TO1_PS
3106 if (error EQ CAUSE_SIM_NO_ERROR)
3107 #else
3108 if (error EQ SIM_NO_ERROR)
3109 #endif
3110 memcpy(sim_service_table, data, sizeof(sim_service_table));
3111 else
3112 TRACE_EVENT("SST read error");
3113
3114 #ifdef SIM_TOOLKIT
3115 if (sat_update)
3116 {
3117 sat_update = FALSE;
3118 satUpdateFiles ( TRUE, SIM_SST );
3119 }
3120 #endif
3121 }
3122
3123
3124
3125
3126 /*
3127 +--------------------------------------------------------------------+
3128 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
3129 | STATE : code ROUTINE : sim_init_CPRS |
3130 +--------------------------------------------------------------------+
3131
3132 PURPOSE : initialize the ciphering indication
3133
3134 */
3135
3136 UBYTE sim_init_CPRS (CallbackCPRI func, UBYTE CPRImode )
3137 {
3138
3139 //UBYTE getCPRImode; // RAVI
3140
3141 TRACE_FUNCTION("sim_init_CPRS()");
3142
3143 //keep the callback function from MMI
3144 if (func != NULL)
3145 mmi_cprs_cb = func;
3146 else
3147 return FALSE;
3148
3149 //now set the mode
3150 sAT_PercentCPRI (CMD_SRC_LCL, CPRImode);
3151
3152 return TRUE;
3153 }
3154
3155
3156 /*
3157 +--------------------------------------------------------------------+
3158 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
3159 | STATE : code ROUTINE : rAT_PercentCPRI |
3160 +--------------------------------------------------------------------+
3161
3162 PURPOSE : is called to inform the application about a received ciphering indication.
3163 gsm_ciph and gprs_ciph are used to inform the application about a change in ciphering
3164 mode in GSM or GPRS.
3165
3166 */
3167
3168
3169 void rAT_PercentCPRI (UBYTE gsm_ciph, UBYTE gprs_ciph)
3170 {
3171
3172 //call here the function from MMI
3173 mmi_cprs_cb(gsm_ciph, gprs_ciph);
3174 }
3175
3176 /*
3177 +---------------------------------------------------------------------+
3178 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
3179 | STATE : code ROUTINE : sim_read_lp_cnf |
3180 +---------------------------------------------------------------------+
3181
3182 PURPOSE :
3183
3184 */
3185
3186 void sim_read_lp_cnf (SHORT error, T_ACI_LAN_SUP *CLang)
3187 {
3188 TRACE_FUNCTION("sim_read_lp_cnf()");
3189
3190
3191 #ifdef SIM_TOOLKIT
3192 if ((mfwSATLPRefresh)&&(sat_update))
3193 {
3194 mfwSATLPRefresh= FALSE;
3195 sat_update = FALSE;
3196 #ifdef FF_2TO1_PS
3197 if (error EQ CAUSE_SIM_NO_ERROR)
3198 #else
3199 if (error EQ SIM_NO_ERROR)
3200 #endif
3201 satUpdateFiles ( TRUE, SIM_SST );
3202 else
3203 psaSAT_FUConfirm (0, SIM_FU_ERROR); /*If not possible, notify to the SIM */
3204 }
3205 #endif
3206 }
3207
3208