SimDetection.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:205k
源码类别:

MTK

开发平台:

C/C++

  1.  *****************************************************************************/
  2. void EntryScrEmergencyCallDialing(void)
  3. {
  4.     /*----------------------------------------------------------------*/
  5.     /* Local Variables                                                */
  6.     /*----------------------------------------------------------------*/
  7.     /*----------------------------------------------------------------*/
  8.     /* Code Body                                                      */
  9.     /*----------------------------------------------------------------*/
  10.     g_pwr_context.SOSCallFlagTOAvoidHistorySave = 1;
  11.     /* diamond, 2005/11/28 Remove keypad lock icon if user pressed emergency call number */
  12.     if (g_keylock_context.gKeyPadLockFlag == 1)
  13.     {
  14.         g_keylock_context.gKeyPadLockFlag = 0;
  15.     #ifdef __MMI_TOUCH_SCREEN__
  16.         ChangeStatusIconImage(STATUS_ICON_KEYPAD_LOCK, IMG_SI_KEYPAD_UNLOCK);
  17.         UpdateStatusIcons();
  18.     #else /* __MMI_TOUCH_SCREEN__ */ 
  19.         IdleResetStatusIcon(STATUS_ICON_KEYPAD_LOCK);
  20.     #endif /* __MMI_TOUCH_SCREEN__ */ 
  21.     #ifndef __MMI_KEYPADLOCK_WITH_KEYTONE__
  22.         mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);
  23.     #endif 
  24.     }
  25.     if (CheckValidEmergencyNo1(g_idle_context.DialPadCallBuffer))
  26.     {
  27.         g_pwr_context.ForCMToIdentifySOSCall = TRUE;
  28.     #ifdef __FLIGHT_MODE_SUPPORT__
  29.         if (mmi_bootup_get_active_flight_mode() == 1)   /* 2005/11/01 Cannot allow to dial in flight mode insert SIM screen */
  30.         {
  31.             EntryScrSOSErrorMessage(STR_MENU_FLIGHT_MODE);
  32.         }
  33.         else
  34.     #endif /* __FLIGHT_MODE_SUPPORT__ */ 
  35.         if (IsSOSPossible())
  36.     #ifdef __MMI_Emergency_Call_911_Support__
  37.             /*  For insert SIM case, dail 911 as emergency call */
  38.             MakeCall((PS8) EmergencyNumber[0]);
  39.     #else /* __MMI_Emergency_Call_911_Support__ */ 
  40.             MakeCall(g_idle_context.DialPadCallBuffer);
  41.     #endif /* __MMI_Emergency_Call_911_Support__ */ 
  42.         else
  43.         {
  44.             EntryScrSOSErrorMessage(STR_NO_SERVICE_RUNNING_TEXT);
  45.         }
  46.     }
  47.     else if (!SSCStringParsing2())
  48.     {
  49.     #ifdef __FLIGHT_MODE_SUPPORT__
  50.         if (mmi_bootup_get_active_flight_mode() == 1)   /* 2005/11/01 Cannot allow to dial in flight mode insert SIM screen */
  51.         {
  52.             EntryScrSOSErrorMessage(STR_MENU_FLIGHT_MODE);
  53.         }
  54.         else
  55.     #endif /* __FLIGHT_MODE_SUPPORT__ */ 
  56.             EntryScrSOSErrorMessage(STR_NOT_SOS_NUMBER);
  57.     }
  58. }
  59. /*****************************************************************************
  60.  * FUNCTION
  61.  *  IsSOSPossible
  62.  * DESCRIPTION
  63.  *  Return the possibility of SOS call
  64.  * PARAMETERS
  65.  *  void
  66.  * RETURNS
  67.  *  void
  68.  *****************************************************************************/
  69. pBOOL IsSOSPossible(void)
  70. {
  71.     /*----------------------------------------------------------------*/
  72.     /* Local Variables                                                */
  73.     /*----------------------------------------------------------------*/
  74.     /*----------------------------------------------------------------*/
  75.     /* Code Body                                                      */
  76.     /*----------------------------------------------------------------*/
  77.     if (g_pwr_context.CurrentServiceType == FULL_SERVICE || g_pwr_context.CurrentServiceType == LIMITED_SERVICE ||
  78.         /* g_pwr_context.InvalidSim) */
  79.         mmi_bootup_is_nw_registration_ok() == MMI_TRUE)
  80.     {
  81.         return TRUE;
  82.     }
  83.     else
  84.     {
  85.         return FALSE;
  86.     }
  87. }
  88. /*****************************************************************************
  89.  * FUNCTION
  90.  *  CheckSIMSOSEntries
  91.  * DESCRIPTION
  92.  *  Checks for Emergency Nos in Different conditions
  93.  * PARAMETERS
  94.  *  tempbuffer      [IN]        
  95.  * RETURNS
  96.  *  void
  97.  *****************************************************************************/
  98. pBOOL CheckSIMSOSEntries(S8 *tempbuffer)
  99. {
  100.     /*----------------------------------------------------------------*/
  101.     /* Local Variables                                                */
  102.     /*----------------------------------------------------------------*/
  103.     U8 count = 0;
  104.     S8 SimEccNum[(EMERGENCY_NUMBER_LENGTH + 1) * ENCODING_LENGTH];
  105.     /*----------------------------------------------------------------*/
  106.     /* Code Body                                                      */
  107.     /*----------------------------------------------------------------*/
  108.     while (count < MAX_ECC_NUMBER_LIST_LENGTH)
  109.     {
  110.         AnsiiToUnicodeString((S8*) SimEccNum, (S8*) (gSimEccNumList[count]));
  111.         if (pfnUnicodeStrcmp(tempbuffer, (S8*) SimEccNum) == 0)
  112.         {
  113.             return 1;
  114.         }
  115.         count++;
  116.     }
  117.     return 0;
  118. }
  119. /*****************************************************************************
  120.  * FUNCTION
  121.  *  CheckValidEmergencyNo1
  122.  * DESCRIPTION
  123.  *  Checks for Emergency Nos in Different conditions
  124.  * PARAMETERS
  125.  *  eccbuffer       [IN]        
  126.  * RETURNS
  127.  *  void
  128.  *****************************************************************************/
  129. pBOOL CheckValidEmergencyNo1(S8 *eccbuffer)
  130. {
  131.     /*----------------------------------------------------------------*/
  132.     /* Local Variables                                                */
  133.     /*----------------------------------------------------------------*/
  134.     U8 i;
  135.     S8 *tempbuffer;
  136.     U16 AdditionalCheckNumber[5][5] = 
  137.     {
  138.         {0x002A, 0x0033, 0x0031, 0x0023, 0x002B}
  139.         ,       /* prefix = *31#+ */
  140.         {0x0023, 0x0033, 0x0031, 0x0023, 0x002B}
  141.         ,       /* prefix = #31#+ */
  142.         {0x002A, 0x0033, 0x0031, 0x0023}
  143.         ,       /* prefix = *31# */
  144.         {0x0023, 0x0033, 0x0031, 0x0023}
  145.         ,       /* prefix = #31# */
  146.         {0x002B}    /* prefix = + */
  147.     };
  148.     S8 EmergencyNumberExt[16];
  149.     /*----------------------------------------------------------------*/
  150.     /* Code Body                                                      */
  151.     /*----------------------------------------------------------------*/
  152.     /* diamond, 2006/02/08 Additional check for *31# and #31# before emergency call */
  153.     /* diamond, 2006/03/26 Additional check for + before emergency call */
  154.     if ((pfnUnicodeStrncmp(eccbuffer, (PS8) AdditionalCheckNumber[0], 5) == 0) ||
  155.         (pfnUnicodeStrncmp(eccbuffer, (PS8) AdditionalCheckNumber[1], 5) == 0))
  156.     {
  157.         tempbuffer = eccbuffer + 10;
  158.     }
  159.     else if ((pfnUnicodeStrncmp(eccbuffer, (PS8) AdditionalCheckNumber[2], 4) == 0) ||
  160.              (pfnUnicodeStrncmp(eccbuffer, (PS8) AdditionalCheckNumber[3], 4) == 0))
  161.     {
  162.         tempbuffer = eccbuffer + 8;
  163.     }
  164.     else if (pfnUnicodeStrncmp(eccbuffer, (PS8) AdditionalCheckNumber[4], 1) == 0)
  165.     {
  166.         tempbuffer = eccbuffer + 2;
  167.     }
  168.     else
  169.     {
  170.         tempbuffer = eccbuffer;
  171.     }
  172.     if (pfnUnicodeStrlen(tempbuffer) != 0)
  173.     {
  174.         for (i = 0; i < MAX_EMERGENCYNUMBER; i++)
  175.         {
  176.             if (pfnUnicodeStrcmp(tempbuffer, (PS8) EmergencyNumber[i]) == 0)
  177.             {
  178.                 return 1;
  179.             }
  180.             /* diamond, 2006/03/31 Additional check for p or w after emergency call */
  181.             pfnUnicodeStrcpy(EmergencyNumberExt, (PS8) EmergencyNumber[i]);
  182.             pfnUnicodeStrcat(EmergencyNumberExt, (PS8) L"p");
  183.             if (pfnUnicodeStrncmp(tempbuffer, EmergencyNumberExt, pfnUnicodeStrlen(EmergencyNumberExt)) == 0)
  184.             {
  185.                 return 1;
  186.             }
  187.             pfnUnicodeStrcpy(EmergencyNumberExt, (PS8) EmergencyNumber[i]);
  188.             pfnUnicodeStrcat(EmergencyNumberExt, (PS8) L"w");
  189.             if (pfnUnicodeStrncmp(tempbuffer, EmergencyNumberExt, pfnUnicodeStrlen(EmergencyNumberExt)) == 0)
  190.             {
  191.                 return 1;
  192.             }
  193.             /* diamond, 2006/05/12 Additional check for + after emergency call */
  194.             pfnUnicodeStrcpy(EmergencyNumberExt, (PS8) EmergencyNumber[i]);
  195.             pfnUnicodeStrcat(EmergencyNumberExt, (PS8) L"+");
  196.             if (pfnUnicodeStrncmp(tempbuffer, EmergencyNumberExt, pfnUnicodeStrlen(EmergencyNumberExt)) == 0 &&
  197.                 pfnUnicodeStrncmp(tempbuffer + ((pfnUnicodeStrlen(tempbuffer) - 1) * ENCODING_LENGTH), (PS8) L"#", 1) != 0)
  198.             {
  199.                 return 1;
  200.             }
  201.         }
  202.         if ((g_pwr_context.PrevScreenIndicator != ENTER_SIM_BLOCK) &&
  203.             (g_pwr_context.PrevScreenIndicator != ENTER_SIM_INSERTION))
  204.         {
  205.             if (CheckSIMSOSEntries(tempbuffer))
  206.             {
  207.                 return 1;
  208.             }
  209.             else
  210.             {
  211.                 return 0;
  212.             }
  213.         }
  214.     }
  215.     return 0;
  216. }
  217. /*****************************************************************************
  218.  * FUNCTION
  219.  *  SimECCInfoSave
  220.  * DESCRIPTION
  221.  *  Callback of PRT_SMU_STARTUP_INFO_IND
  222.  * PARAMETERS
  223.  *  inMsg       [IN]        
  224.  * RETURNS
  225.  *  void
  226.  *****************************************************************************/
  227. void SimECCInfoSave(void *inMsg)
  228. {
  229.     /*----------------------------------------------------------------*/
  230.     /* Local Variables                                                */
  231.     /*----------------------------------------------------------------*/
  232.     mmi_smu_startup_info_ind_struct *local_data = (mmi_smu_startup_info_ind_struct*) inMsg;
  233.     U8 Count = 0;
  234.     U8 i = 0, j = 0;
  235.     /*----------------------------------------------------------------*/
  236.     /* Code Body                                                      */
  237.     /*----------------------------------------------------------------*/
  238.     /* fill ECC codes to buffer */
  239.     if (local_data->num > 0)
  240.     {
  241.         for (Count = 0; Count < local_data->num; Count++)
  242.         {
  243.             j = Count * (NUM_OF_BYTE_ECC * 2 + 1);
  244.             while (local_data->ecc[i] != '')
  245.             {
  246.                 gSimEccNumList[Count][i] = local_data->ecc[j];
  247.                 i++;
  248.                 j++;
  249.             }
  250.             gSimEccNumList[Count][i] = '';
  251.             i = 0;
  252.         }
  253.     }
  254. #ifdef __MMI_AUTO_LANG_EN__
  255.     /* process and store LP in context */
  256.     PhnsetPLPInd(local_data->language);
  257.     /* If UsrLangIdx != 0xFF, not necessary to handle it because */
  258.     /* 1. PhnsetSetLangByNvramValue() has been executed --> Language has already set */
  259.     /* 2. PhnsetSetLangByNvramValue() did not executed --> */
  260.     /*    PhnsetSetLangByNvramValue() will be execute later and Language will be set at that time */
  261.     if (PhnsetGetLang() == 0xFF)
  262.     {
  263.         SetCurrentLanguage((S8) PhnsetGetAutoLangIdx());    /* in ReadRes.c */
  264.     }
  265. #endif /* __MMI_AUTO_LANG_EN__ */ 
  266. #ifdef __MANUAL_MODE_NW_SEL__
  267.     /* get PLMN selection mode */
  268.     PLMNGetSelectionModeReq();
  269. #endif /* __MANUAL_MODE_NW_SEL__ */ 
  270. }
  271. /**************************************************************************
  272.    SIM security check APIs:
  273.       void SimPasswdReqResponse(void *inMsg)
  274.       void SimQueryFailureRsp(void *inMsg)
  275.       void EntryScrIncorrectPin(void)
  276.       void EntryScrIncorrectPhoneLock(void)
  277.       void EntryScrIncorrectPUK(void)
  278.       void EntryScrPinBlocked(void)
  279.       void ExitScrPinBlocked(void)
  280.       void EntryScrCodeVerified(void)
  281.       void ExitCodeVerifiedScr(void)
  282.       void CodeVerifiedTimeoutFn(void)
  283. **************************************************************************/
  284. /*****************************************************************************
  285.  * FUNCTION
  286.  *  mmi_bootup_sim_indication_bt_power_on
  287.  * DESCRIPTION
  288.  *  
  289.  * PARAMETERS
  290.  *  sim_ind         [IN]        
  291.  *  msg_type        [IN]        
  292.  * RETURNS
  293.  *  void
  294.  *****************************************************************************/
  295. static void mmi_bootup_sim_indication_bt_power_on(U8 sim_ind, U16 msg_type)
  296. {
  297.     /*----------------------------------------------------------------*/
  298.     /* Local Variables                                                */
  299.     /*----------------------------------------------------------------*/
  300. #ifdef __MMI_BT_SUPPORT__
  301.     static U8 BTPowerOnFlag = MMI_FALSE;
  302.     pBOOL status;
  303. #endif /* __MMI_BT_SUPPORT__ */ 
  304.     /*----------------------------------------------------------------*/
  305.     /* Code Body                                                      */
  306.     /*----------------------------------------------------------------*/
  307. #ifdef __MMI_IRDA_SUPPORT__
  308.     if (mmi_bootup_is_sim_valid() == MMI_TRUE && sim_ind == 0 && msg_type != MMI_SIM_REFRESH &&
  309.         MMI_IRDASCR_CNTX(irda_state) != MMIR_SCR_IRCLOSE)
  310.     {
  311.         if (mmi_irda_is_ircomm_active() == MMI_TRUE)
  312.         {
  313.             mmi_irda_ircomm_disconnect_request();
  314.         }
  315.         mmi_irda_exec_close_menu();
  316.     }
  317. #endif /* __MMI_IRDA_SUPPORT__ */ 
  318. #ifdef __MMI_BT_SUPPORT__
  319.     if (BTPowerOnFlag)
  320.     {
  321.         return;
  322.     }
  323.     if (sim_ind == 0)   /* sim failure indication */
  324.     {
  325.         status = MMI_FALSE;
  326.     }
  327.     else    /* sim password indication */
  328.     {
  329.         switch (msg_type)
  330.         {
  331.             case MMI_TYPE_PHONELOCK:
  332.             case MMI_TYPE_CHV1:
  333.             case MMI_TYPE_UBCHV1:
  334.             case MMI_TYPE_NP:
  335.             case MMI_TYPE_NSP:
  336.             case MMI_TYPE_SP:
  337.             case MMI_TYPE_CP:
  338.             case MMI_TYPE_IMSI_LOCK:
  339.             case MMI_TYPE_LINK_NS_SP:
  340.             case MMI_TYPE_LINK_SIM_C:
  341.                 return;
  342.                 break;
  343.             case MMI_TYPE_SIM_CARD_BLOCKED:
  344.                 status = MMI_FALSE;
  345.                 break;
  346.             case MMI_TYPE_NO_REQUIRED:
  347.             default:
  348.                 status = MMI_TRUE;
  349.                 break;
  350.         }
  351.     }
  352.     mmi_bt_ps_stack_and_hw_init(mmi_bootup_get_active_flight_mode(), status);
  353.     BTPowerOnFlag = MMI_TRUE;
  354. #endif /* __MMI_BT_SUPPORT__ */ 
  355. }
  356. /*****************************************************************************
  357.  * FUNCTION
  358.  *  mmi_bootup_phone_lock_history
  359.  * DESCRIPTION
  360.  *  History of phone lock if SimPasswdReqResponse is received in call
  361.  * PARAMETERS
  362.  *  void
  363.  * RETURNS
  364.  *  void
  365.  *****************************************************************************/
  366. static void mmi_bootup_phone_lock_history(void)
  367. {
  368.     /*----------------------------------------------------------------*/
  369.     /* Local Variables                                                */
  370.     /*----------------------------------------------------------------*/
  371.     /*----------------------------------------------------------------*/
  372.     /* Code Body                                                      */
  373.     /*----------------------------------------------------------------*/
  374.     EntryScrEnterPhoneLock();
  375.     InitEnterPasswordScreen(MMI_TRUE);
  376. }
  377. /*****************************************************************************
  378.  * FUNCTION
  379.  *  mmi_bootup_sim_lock_history
  380.  * DESCRIPTION
  381.  *  History of PIN lock if SimPasswdReqResponse is received in call
  382.  * PARAMETERS
  383.  *  void
  384.  * RETURNS
  385.  *  void
  386.  *****************************************************************************/
  387. static void mmi_bootup_sim_lock_history(void)
  388. {
  389.     /*----------------------------------------------------------------*/
  390.     /* Local Variables                                                */
  391.     /*----------------------------------------------------------------*/
  392.     /*----------------------------------------------------------------*/
  393.     /* Code Body                                                      */
  394.     /*----------------------------------------------------------------*/
  395.     EntryScrEnterPIN();
  396.     InitEnterPasswordScreen(MMI_TRUE);
  397. }
  398. /*****************************************************************************
  399.  * FUNCTION
  400.  *  mmi_frm_add_history_before_cm_marker
  401.  * DESCRIPTION
  402.  *  Add a screen to the history before CM_SCR_MARKER
  403.  * PARAMETERS
  404.  *  void
  405.  * RETURNS
  406.  *  void
  407.  *****************************************************************************/
  408. void mmi_frm_add_history_before_cm_marker(U16 scrn_id, FuncPtr func_ptr)
  409. {
  410.     /*----------------------------------------------------------------*/
  411.     /* Local Variables                                                */
  412.     /*----------------------------------------------------------------*/
  413.     history Scr;
  414.     /*----------------------------------------------------------------*/
  415.     /* Code Body                                                      */
  416.     /*----------------------------------------------------------------*/
  417.     Scr.scrnID = scrn_id;
  418.     Scr.entryFuncPtr = func_ptr;
  419.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) L"");
  420.     InsertHistoryBeforeThisScrn(CM_SCR_MARKER, Scr);
  421. }
  422. /*****************************************************************************
  423.  * FUNCTION
  424.  *  SimPasswdReqResponse
  425.  * DESCRIPTION
  426.  *  This is called as a call back when MMI_SMU_PASSWORD_REQUIRED_IND is received from the L4
  427.  * PARAMETERS
  428.  *  inMsg       [IN]        
  429.  * RETURNS
  430.  *  void
  431.  *****************************************************************************/
  432. void mmi_ready_to_idle_screen_ind(void);
  433. void SimPasswdReqResponse(void *inMsg)
  434. {
  435.     /*----------------------------------------------------------------*/
  436.     /* Local Variables                                                */
  437.     /*----------------------------------------------------------------*/
  438.     /* MMI will repeatedly receive this indication if its content isn't MMI_TYPE_NO_REQUIRED */
  439.     /* (MMI_TYPE_PHONELOCK) -> (MMI_TYPE_CHV1) -> MMI_TYPE_NO_REQUIRED */
  440.     static U8 gCodeVerifyRequiredFlag = 0;
  441.     MMISMUPASSWDREQIND *local_data = (MMISMUPASSWDREQIND*) inMsg;
  442.     /*----------------------------------------------------------------*/
  443.     /* Code Body                                                      */
  444.     /*----------------------------------------------------------------*/
  445.     if (g_pwr_context.PrevScreenIndicator == ENTER_SIM_INSERTION ||
  446.         g_pwr_context.PrevScreenIndicator == ENTER_SIM_BLOCK)
  447.     {
  448.         return; /* diamond, 2005/12/26 If SIM is not inserted, verifying phone lock shall meet this message */
  449.     }
  450.     /* Retry count for PIN/PUK and personalization locks */
  451.     FillCountDownNumber(local_data->chv_info);
  452.     gCPHSRetryCount = local_data->cphs_retry_count;
  453.     /* if((!g_pwr_context.PowerOnAnimationComplete) */
  454.     if (mmi_bootup_is_power_on_animation_complete() == MMI_FALSE
  455. #if defined(__FS_CHECKDRIVE_SUPPORT__)
  456.         || (SanityCheckDone == 0) || (SanityCheckDone == 3)
  457. #endif 
  458.         )
  459.     {
  460.         MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_RECV_SIM_PSWD));
  461.         memcpy(&gSMUPwdDataStruct, local_data, sizeof(MMISMUPASSWDREQIND));
  462.         /* g_pwr_context.PasswdReqIndFlag=1; */
  463.         if (mmi_bootup_is_power_on_animation_complete() == MMI_FALSE)
  464.         {
  465.             /* nand check first then receive this message */
  466.             g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_ANIMATION_PSWD_REQ;       /* 0x05: Power on animation with password requirement indication */
  467.         }
  468.         g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_SECURITY_CHECK;        /* 0x08: Need security check */
  469.         /* Robin 0719, Cannon+ SCR 3585: [China FT]MMI-PLNM is display TWN GSM  then display CU-GSM  */
  470.         /* Current, MMI will postpone handling SMU_PASSWORD_REQUIRED_IND to align with power on animation */
  471.         /* So will delay the IMSI retrieve, cause realize roaming status too late. */
  472.         /* Duplicate here to get IMSI immediately once SIM password verified done. */
  473.         if (local_data->type == MMI_TYPE_NO_REQUIRED)
  474.         {
  475.             g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_INVALID;  /* 0x01: Invalid SIM reset */
  476.             if (g_pwr_context.testRoaming == 1) /* Shall send GET IMSI REQ once */
  477.             {
  478.                 RequestToTestRoamingEnabled();
  479.             }
  480.         }
  481.         return; /* postpone this indication after power on animation completes */
  482.     }
  483.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_PROC_SIM_PSWD));
  484.     /* Notify BT to start init bt ps stack and hw */
  485.     mmi_bootup_sim_indication_bt_power_on(1, local_data->type);
  486.     /* g_pwr_context.PasswdReqIndFlag=0; */
  487.     g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_SECURITY_CHECK;   /* 0x08: Security check done */
  488.     StopLEDPatternPowerOn();
  489.     ClearKeyEvents();
  490.     memset((S8*) gInputPwdBuffer, 0, MAX_PWD_LENGTH_MMI * ENCODING_LENGTH);
  491.     memset((S8*) gInputNewPinBufferFirstTime, 0, MAX_PWD_LENGTH_MMI * ENCODING_LENGTH);
  492.     memset((S8*) gInputNewPinBufferSecondTime, 0, MAX_PWD_LENGTH_MMI * ENCODING_LENGTH);
  493.     /* Close backling when enter password */
  494. #if MMI_ON_HARDWARE_P
  495.     if (local_data->type != 0)
  496.     {
  497.         FirstTimeTurnOnBackLight();
  498.     }
  499. #endif /* MMI_ON_HARDWARE_P */ 
  500.     /* g_pwr_context.SimRemoveFlag=0; */
  501.     g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_NOT_INSERT;       /* 0x02: SIM removed reset */
  502.     //g_pwr_context.PowerOnTillIdleApp=1;
  503.     //g_pwr_context.PowerOnPeriod=0;
  504. #ifdef MMI_ON_HARDWARE_P
  505.     /* call this stop animation to stop all play power display, */
  506.     /* which will stop all timer and avoid NVRAM & timer interlace problem */
  507.     mmi_pwron_stop_animation();
  508. #else /* MMI_ON_HARDWARE_P */ 
  509.     /* diamond, 2006/02/07 PC simulator cannot accept sim lock or phone lock case */
  510.     local_data->type = MMI_TYPE_NO_REQUIRED;
  511. #endif /* MMI_ON_HARDWARE_P */ 
  512.     switch (local_data->type)
  513.     {
  514.             /* Directly jump to idle screen */
  515.         case MMI_TYPE_NO_REQUIRED:
  516.             g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_INVALID;  /* 0x01: Invalid SIM reset */
  517.             g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_SECURITY_NO_PSWD;     /* 0x10: Security check */
  518.             /* if(gSIMRefresh == 1) */
  519.             if (mmi_bootup_is_sim_refresh() == MMI_TRUE)
  520.             {
  521.                 g_phb_cntx.phb_ready = FALSE;   /* MTK 2003-12-22 Wilson, for SIM refresh */
  522.                 //g_pwr_context.IsSimValid = 1;
  523.                 //EntryIdleScreen();
  524.                 if (IsInSATScreen())
  525.                 {
  526.                     SATMessageWaitTimer();
  527.                     DisplayPopup(
  528.                         (U8*) GetString(STR_ID_SIM_REFRESH),
  529.                         IMG_GLOBAL_WARNING,
  530.                         0,
  531.                         UI_POPUP_NOTIFYDURATION_TIME,
  532.                         (U8) ERROR_TONE);
  533.                 }
  534.                 /* gSIMRefresh = 0; */
  535.                 if (GetActiveScreenId() == SCR_ENTER_PHONELOCK)
  536.                 {
  537.                     ExitVariables();
  538.                     EntryIdleScreen();
  539.                 }
  540.                 g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_REFRESH;      /* SIM refresh reset */
  541.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE;
  542.                 /* diamond, 2006/04/04 Avoid the case of SIM refreshing before power on animation is complete */
  543.                 if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  544.                 {
  545.                     return;
  546.                 }
  547.             }
  548.             // MTK end
  549.             //g_pwr_context.PowerOnPeriod=1;
  550.             PRINT_INFORMATION(("MMI_TYPE_NO_REQUIRED"));
  551.             g_pwr_context.SSCFromEnterPukAtBootUp = 0;
  552.             // gTypeNoReq = 1;
  553.             //g_pwr_context.IsSimValid = 1;
  554.             g_pwr_context.PrevScreenIndicator = 0;
  555.         #ifdef __MMI_SML_MENU__
  556.             mmi_sml_power_on_query_req();
  557.         #endif
  558.         #ifdef __MMI_WLAN_FEATURES__
  559.             mmi_netset_update_preferred_mode_menu();
  560.         #endif
  561.             /* Robin 0719, Cannon+ SCR 3585: [China FT]MMI-PLNM is display TWN GSM  then display CU-GSM  */
  562.             /* Current, MMI will postpone handling SMU_PASSWORD_REQUIRED_IND to align with power on animation */
  563.             /* So will delay the IMSI retrieve, cause realize roaming status too late. */
  564.             /* Will duplicate to the top of this fucntion to get IMSI immediately once SIM password verified done. */
  565.             if (g_pwr_context.testRoaming == 1) /* Shall send GET IMSI REQ once */
  566.             {
  567.                 RequestToTestRoamingEnabled();
  568.             }
  569.             if (g_charbat_context.isChargerConnected == 1)
  570.             {
  571.                 /* Hide status icon temporary, entry idle screen will start animation again */
  572.                 HideStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  573.                 ShowStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  574.                 UpdateStatusIcons();
  575.             }
  576.             if (gCodeVerifyRequiredFlag)
  577.             {
  578.                 EntryScrCodeVerified();
  579.             }
  580.             else
  581.             {
  582.                 /* DinitHistory(); // Not necessary to deinit history because there might be an incoming call */
  583.             #ifdef MMI_ON_HARDWARE_P
  584.                 mmi_bootup_exit_security_check();   /* send message to it slef notify ready to go to idle */
  585.             #else 
  586.                 goto_opening_screen();
  587.             #endif 
  588.             }
  589.             break;
  590.         case MMI_TYPE_PHONELOCK:
  591.             PRINT_INFORMATION(("MMI_TYPE_PHONELOCK"));
  592.             if (g_pwr_context.PrevScreenIndicator == ENTER_PHONELOCK)
  593.             {
  594.                 EntryScrIncorrectPhoneLock();
  595.             }
  596.             else
  597.             {
  598.                 if (isInCall())
  599.                 {
  600.                     mmi_frm_add_history_before_cm_marker(SCR_ENTER_PHONELOCK, mmi_bootup_phone_lock_history);
  601.                 }
  602.                 else
  603.                 {
  604.                     EntryScrEnterPhoneLock();
  605.                     InitEnterPasswordScreen(MMI_TRUE);
  606.                 }
  607.             }
  608.             break;
  609.             /* Show Enter PIN Screen */
  610.         case MMI_TYPE_CHV1:
  611.             PRINT_INFORMATION(("Enter PIN [MMI_TYPE_CHV1]"));
  612.             if (g_pwr_context.PrevScreenIndicator == ENTER_PIN_SCR)
  613.             {
  614.                 EntryScrIncorrectPin();
  615.             }
  616.             else
  617.             {
  618.                 gCodeVerifyRequiredFlag = 1;
  619.                 if (isInCall())
  620.                 {
  621.                     mmi_frm_add_history_before_cm_marker(SCR_ENTER_PIN, mmi_bootup_sim_lock_history);
  622.                 }
  623.                 else
  624.                 {
  625.                     EntryScrEnterPIN();
  626.                     InitEnterPasswordScreen(MMI_TRUE);
  627.                 }
  628.             }
  629.             break;
  630.         case MMI_TYPE_CHV2:
  631.             PRINT_INFORMATION(("Enter PIN [MMI_TYPE_CHV2]"));
  632.             break;
  633.         case MMI_TYPE_UBCHV1:
  634.             PRINT_INFORMATION(("MMI_TYPE_UBCHV1"));
  635.             if ((g_pwr_context.PrevScreenIndicator == ENTER_CONFIRM_PIN) || (g_pwr_context.SSCFromEnterPukAtBootUp))
  636.             {
  637.                 EntryScrIncorrectPUK();
  638.             }
  639.             else
  640.             {
  641.                 EntryScrPinBlocked();
  642.                 gCodeVerifyRequiredFlag = 1;
  643.             }
  644.             break;
  645.         case MMI_TYPE_UBCHV2:
  646.             PRINT_INFORMATION(("MMI_TYPE_UBCHV2"));
  647.             break;
  648.         case MMI_TYPE_CHV1_BLOCKED:
  649.             PRINT_INFORMATION(("MMI_TYPE_CHV1_BLOCKED"));
  650.             break;
  651.         case MMI_TYPE_CHV2_BLOCKED:
  652.             /* L4 not taking care it */
  653.             PRINT_INFORMATION(("MMI_TYPE_CHV2_BLOCKED"));
  654.             break;
  655.         case MMI_TYPE_SIM_CARD_BLOCKED:
  656.             PRINT_INFORMATION(("MMI_TYPE_SIM_CARD_BLOCKED"));
  657.             g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  658.             simErrorDisplayString = STR_SIM_BLOCK_MSG; 
  659.             InitSimBlockedScreen();
  660.             break;
  661.         case MMI_TYPE_UBCHV2_BLOCKED:
  662.             /* Not used by L4 */
  663.             PRINT_INFORMATION(("MMI_TYPE_UBCHV2_BLOCKED"));
  664.             break;
  665.         case MMI_TYPE_UBCHV1_CHV1_NOT_LOCK:
  666.             /* Not used by L4 */
  667.             PRINT_INFORMATION(("MMI_TYPE_UBCHV1_CHV1_NOT_LOCK"));
  668.             break;
  669.         case MMI_TYPE_NP:
  670.             /* Not used by L4 */
  671.             PRINT_INFORMATION(("MMI_TYPE_NP"));
  672.             if (gCPHSRetryCount == 0)
  673.             {
  674.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  675.                 InitSimBlockedScreen();
  676.             }
  677.             else
  678.             {
  679.                 if (g_pwr_context.PrevScreenIndicator == ENTER_NP)
  680.                 {
  681.                     EntryScrIncorrectNP();
  682.                 }
  683.                 else
  684.                 {
  685.                     EntryScrEnterNP();
  686.                     InitEnterPasswordScreen(MMI_TRUE);
  687.                 }
  688.             }
  689.             break;
  690.         case MMI_TYPE_NSP:
  691.             /* Not used by L4 */
  692.             PRINT_INFORMATION(("MMI_TYPE_NSP"));
  693.             if (gCPHSRetryCount == 0)
  694.             {
  695.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  696.                 InitSimBlockedScreen();
  697.             }
  698.             else
  699.             {
  700.                 if (g_pwr_context.PrevScreenIndicator == ENTER_NSP)
  701.                 {
  702.                     EntryScrIncorrectNSP();
  703.                 }
  704.                 else
  705.                 {
  706.                     EntryScrEnterNSP();
  707.                     InitEnterPasswordScreen(MMI_TRUE);
  708.                 }
  709.             }
  710.             break;
  711.         case MMI_TYPE_SP:
  712.             /* Not used by L4 */
  713.             PRINT_INFORMATION(("MMI_TYPE_SP"));
  714.             if (gCPHSRetryCount == 0)
  715.             {
  716.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  717.                 InitSimBlockedScreen();
  718.             }
  719.             else
  720.             {
  721.                 if (g_pwr_context.PrevScreenIndicator == ENTER_SP)
  722.                 {
  723.                     EntryScrIncorrectSP();
  724.                 }
  725.                 else
  726.                 {
  727.                     EntryScrEnterSP();
  728.                     InitEnterPasswordScreen(MMI_TRUE);
  729.                 }
  730.             }
  731.             break;
  732.         case MMI_TYPE_CP:
  733.             /* Not used by L4 */
  734.             PRINT_INFORMATION(("MMI_TYPE_CP"));
  735.             if (gCPHSRetryCount == 0)
  736.             {
  737.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  738.                 InitSimBlockedScreen();
  739.             }
  740.             else
  741.             {
  742.                 if (g_pwr_context.PrevScreenIndicator == ENTER_CP)
  743.                 {
  744.                     EntryScrIncorrectCP();
  745.                 }
  746.                 else
  747.                 {
  748.                     EntryScrEnterCP();
  749.                     InitEnterPasswordScreen(MMI_TRUE);
  750.                 }
  751.             }
  752.             break;
  753.         case MMI_TYPE_IMSI_LOCK:
  754.             /* Not used by L4 */
  755.             PRINT_INFORMATION(("MMI_TYPE_IMSI_LOCK"));
  756.             if (gCPHSRetryCount == 0)
  757.             {
  758.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  759.                 InitSimBlockedScreen();
  760.             }
  761.             else
  762.             {
  763.                 if (g_pwr_context.PrevScreenIndicator == ENTER_SIMP)
  764.                 {
  765.                     EntryScrIncorrectSIMP();
  766.                 }
  767.                 else
  768.                 {
  769.                     EntryScrEnterSIMP();
  770.                     InitEnterPasswordScreen(MMI_TRUE);
  771.                 }
  772.             }
  773.             break;
  774. #ifdef __MMI_SML_MENU__
  775.         case MMI_TYPE_LINK_NS_SP:
  776.             /* Not used by L4 */
  777.             PRINT_INFORMATION(("MMI_TYPE_LINK_NS_SP"));
  778.             if (gCPHSRetryCount == 0)
  779.             {
  780.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  781.                 InitSimBlockedScreen();
  782.             }
  783.             else
  784.             {
  785.                 if (g_pwr_context.PrevScreenIndicator == ENTER_NS_SP)
  786.                 {
  787.                     EntryScrIncorrectNSSP();
  788.                 }
  789.                 else
  790.                 {
  791.                     EntryScrEnterNSSP();
  792.                     InitEnterPasswordScreen(MMI_TRUE);
  793.                 }
  794.             }
  795.             break;
  796.         case MMI_TYPE_LINK_SIM_C:
  797.             /* Not used by L4 */
  798.             PRINT_INFORMATION(("MMI_TYPE_LINK_SIM_C"));
  799.             if (gCPHSRetryCount == 0)
  800.             {
  801.                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  802.                 InitSimBlockedScreen();
  803.             }
  804.             else
  805.             {
  806.                 if (g_pwr_context.PrevScreenIndicator == ENTER_SIM_C)
  807.                 {
  808.                     EntryScrIncorrectSIMC();
  809.                 }
  810.                 else
  811.                 {
  812.                     EntryScrEnterSIMC();
  813.                     InitEnterPasswordScreen(MMI_TRUE);
  814.                 }
  815.             }
  816.             break;
  817. #endif /* __MMI_SML_MENU__ */
  818.         case MMI_TYPE_PERSONALIZATION_KEY:
  819.             /* Not used by L4 */
  820.             PRINT_INFORMATION(("MMI_TYPE_PERSONALIZATION_KEY"));
  821.             break;
  822.         case MMI_TYPE_UNSPECIFIED:
  823.             /* Not a response from L4 needed by mmi to set PIN */
  824.             PRINT_INFORMATION(("MMI_TYPE_UNSPECIFIED"));
  825.             break;
  826.         default:
  827.             PRINT_INFORMATION(("Unhandled enum type in SimPasswdReqResponse"));
  828.             break;
  829.     }
  830. }
  831. /*****************************************************************************
  832.  * FUNCTION
  833.  *  SimQueryFailureRsp
  834.  * DESCRIPTION
  835.  *  This is called as a call back when MMI_SMU_FAIL_IND is received from the L4
  836.  * PARAMETERS
  837.  *  inMsg       [IN]        
  838.  * RETURNS
  839.  *  void
  840.  *****************************************************************************/
  841. void SimQueryFailureRsp(void *inMsg)
  842. {
  843.     /*----------------------------------------------------------------*/
  844.     /* Local Variables                                                */
  845.     /*----------------------------------------------------------------*/
  846.     MMISMUFAILIND *local_data = (MMISMUFAILIND*) inMsg;
  847.     /*----------------------------------------------------------------*/
  848.     /* Code Body                                                      */
  849.     /*----------------------------------------------------------------*/
  850.     /* if((!g_pwr_context.PowerOnAnimationComplete) */
  851.     if (mmi_bootup_is_power_on_animation_complete() == MMI_FALSE
  852. #if defined(__FS_CHECKDRIVE_SUPPORT__)
  853.         || (SanityCheckDone == 0) || (SanityCheckDone == 3)
  854. #endif 
  855.         )
  856.     {
  857.         MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_RECV_SIM_FAIL));
  858.         /* g_pwr_context.SimQueryFailIndFlag=1; */
  859.         g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_INVALID;       /* 0x01: Invalid SIM */
  860.         if (local_data->cause != MMI_SIM_REFRESH)
  861.         {
  862.             g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_FAILURE_RSP;       /* 0x10: SIM failure rsp */
  863.         }
  864.         if (mmi_bootup_is_power_on_animation_complete() == MMI_FALSE)
  865.         {
  866.             /* nand check first then receive this message */
  867.             g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_ANIMATION_SIM_FAIL;       /* 0x06: Power on animation with SIM failure indication */
  868.         }
  869.         memcpy(&gSMUFailIndStruct, local_data, sizeof(MMISMUFAILIND));
  870.         return; /* postpone this indication after power on animation completes */
  871.     }
  872.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_PROC_SIM_FAIL));
  873.     /* Notify BT not to init bt ps stack and hw */
  874.     mmi_bootup_sim_indication_bt_power_on(0, local_data->cause);
  875.     //g_pwr_context.SimQueryFailIndFlag=0;
  876.     //g_pwr_context.PowerOnPeriod=0;
  877.     g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_IDLE; /* 0x80: insert/blocked SIM idle screen */
  878.     StopLEDPatternPowerOn();
  879.     /* g_pwr_context.IsSimValid = 0; */
  880.     g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_INVALID;   /* 0x01: Invalid SIM */
  881.     /* g_pwr_context.PowerOnTillIdleApp=0; */
  882.     ClearKeyEvents();
  883. #ifdef MMI_ON_HARDWARE_P
  884.     FirstTimeTurnOnBackLight();
  885. #endif 
  886.     mmi_idle_notify_bootup_ready_to_l4c();
  887.     switch (local_data->cause)
  888.     {
  889.         case MMI_SIM_CARD_REMOVED:
  890.             PRINT_INFORMATION(("MMI_SIM_CARD_REMOVED"));
  891.             /* if(g_pwr_context.SimRemoveFlag==0) */
  892.             if (mmi_bootup_is_sim_removed() == MMI_FALSE)
  893.             {
  894.                 /* g_pwr_context.SimRemoveFlag=1; */
  895.                 g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_NOT_INSERT;    /* 0x02: SIM removed */
  896.                 simErrorDisplayString = STR_SIM_INSERTION_MSG;
  897.                 InitSimErrorScreen();
  898.             }
  899.             break;
  900.         case MMI_SIM_ACCESS_ERROR:
  901.             PRINT_INFORMATION(("MMI_SIM_ACCESS_ERROR"));
  902.             simErrorDisplayString = STR_SIM_ACCESS_ERROR_MSG;
  903.             InitSimErrorScreen();
  904.             break;
  905.         case MMI_SIM_CMD_SUCCESS:
  906.             PRINT_INFORMATION(("MMI_SIM_CMD_SUCCESS"));
  907.             break;
  908.         case MMI_SIM_CMD_FAIL:
  909.             PRINT_INFORMATION(("MMI_SIM_CMD_FAIL"));
  910.             /* g_pwr_context.SimRemoveFlag=1; */
  911.             g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_NOT_INSERT;        /* 0x02: SIM removed */
  912.             simErrorDisplayString = STR_SIM_INSERTION_MSG;
  913.             InitSimErrorScreen();
  914.             break;
  915.         case MMI_SIM_FATAL_ERROR:
  916.             PRINT_INFORMATION(("MMI_SIM_FATAL_ERROR"));
  917.             simErrorDisplayString = STR_SIM_ACCESS_ERROR_MSG;
  918.             InitSimErrorScreen();
  919.             break;
  920.         case MMI_SIM_NO_INSERTED:
  921.             PRINT_INFORMATION(("MMI_SIM_NO_INSERTED"));
  922.             /* g_pwr_context.SimRemoveFlag=1; */
  923.             g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_NOT_INSERT;        /* 0x02: SIM removed */
  924.             simErrorDisplayString = STR_SIM_INSERTION_MSG;
  925.             InitSimErrorScreen();
  926.             break;
  927.         case MMI_SIM_CHV_NOT_INIT:
  928.             PRINT_INFORMATION(("MMI_SIM_CHV_NOT_INIT"));
  929.             break;
  930.         case MMI_SIM_CHV_RETRY_ALLOW:
  931.             PRINT_INFORMATION(("MMI_SIM_CHV_RETRY_ALLOW"));
  932.             break;
  933.         case MMI_SIM_CHV_BLOCK:
  934.             PRINT_INFORMATION(("MMI_SIM_CHV_BLOCK"));
  935.             InitSimBlockedScreen();
  936.             break;
  937.         case MMI_SIM_ACCESS_NOT_ALLOW:
  938.             PRINT_INFORMATION(("MMI_SIM_ACCESS_NOT_ALLOW"));
  939.             break;
  940.         case MMI_SIM_SAT_CMD_BUSY:
  941.             PRINT_INFORMATION(("MMI_SIM_SAT_CMD_BUSY"));
  942.             break;
  943.         case MMI_SIM_DL_ERROR:
  944.             PRINT_INFORMATION(("MMI_SIM_DL_ERROR"));
  945.             break;
  946.         case MMI_SIM_MEMORY_PROBLEM:
  947.             PRINT_INFORMATION(("MMI_SIM_MEMORY_PROBLEM"));
  948.             break;
  949.         case MMI_SIM_TECHNICAL_PROBLEM:
  950.             PRINT_INFORMATION(("MMI_SIM_TECHNICAL_PROBLEM"));
  951.             break;
  952.         case MMI_SIM_REFRESH:
  953.             /* gSIMRefresh = 1; */
  954.             g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_REFRESH;           /* 0x04 SIM refresh */
  955.             break;
  956. #ifdef __MMI_SIMAP_SUPPORT__
  957.         case MMI_SIM_BT_ACCESS_PROFILE_ON:
  958.             if (!mmi_bootup_get_active_bt_access_profile_mode())
  959.             {
  960.                 g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_BT_ACCESS;     /* 0x40 BT SIM access profile */
  961.                 g_pwr_context.CurrentServiceType = LIMITED_SERVICE;             /* prevent from no following network attachment indication  */
  962.             #ifdef __MMI_WLAN_FEATURES__
  963.                 mmi_sim_error_update_sim_access_profile_menu_items();
  964.             #endif
  965.                 if (isInCall())
  966.                 {
  967.                     DeleteBeyondScrTillScr(CM_SCR_MARKER, IDLE_SCREEN_ID);
  968.                     mmi_frm_add_history_before_cm_marker(IDLE_SCREEN_ID, EntryIdleScreen);
  969.                 }
  970.                 else
  971.                 {
  972.                     EntryIdleScreen();
  973.                 }
  974.             }
  975.             break;
  976.         case MMI_SIM_BT_ACCESS_PROFILE_OFF:
  977.             if (mmi_bootup_get_active_bt_access_profile_mode())
  978.             {
  979.                 g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_INVALID;       /* 0x02: SIM removed reset */
  980.              g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_BT_ACCESS;     /* 0x40 BT SIM access profile */
  981.             #ifdef __MMI_WLAN_FEATURES__
  982.                 mmi_sim_error_restore_sim_access_profile_menu_items();
  983.             #endif
  984.                 if (isInCall())
  985.                 {
  986.                     DeleteBeyondScrTillScr(CM_SCR_MARKER, IDLE_SCREEN_ID);
  987.                     mmi_frm_add_history_before_cm_marker(IDLE_SCREEN_ID, EntryIdleScreen);
  988.                 }
  989.                 else
  990.                 {
  991.                     EntryIdleScreen();
  992.                 }
  993.             }
  994.             break;
  995. #endif /* __MMI_SIMAP_SUPPORT__ */
  996.         default:
  997.             PRINT_INFORMATION(("Invalid cause from SIM FAIL error"));
  998.             break;
  999.     }
  1000. }
  1001. /*****************************************************************************
  1002.  * FUNCTION
  1003.  *  EntryScrIncorrectPin
  1004.  * DESCRIPTION
  1005.  *  Flash message incorrect PIN try again
  1006.  * PARAMETERS
  1007.  *  void
  1008.  * RETURNS
  1009.  *  void
  1010.  *****************************************************************************/
  1011. void EntryScrIncorrectPin(void)
  1012. {
  1013.     /*----------------------------------------------------------------*/
  1014.     /* Local Variables                                                */
  1015.     /*----------------------------------------------------------------*/
  1016.     /*----------------------------------------------------------------*/
  1017.     /* Code Body                                                      */
  1018.     /*----------------------------------------------------------------*/
  1019.     DisplayPopup((U8*) GetString(STR_INCORRECT_PIN), IMG_GLOBAL_ERROR, 0, 2000, (U8) ERROR_TONE);
  1020. }
  1021. /*****************************************************************************
  1022.  * FUNCTION
  1023.  *  EntryScrIncorrectPhoneLock
  1024.  * DESCRIPTION
  1025.  *  Flash message incorrect phonelock try again
  1026.  * PARAMETERS
  1027.  *  void
  1028.  * RETURNS
  1029.  *  void
  1030.  *****************************************************************************/
  1031. void EntryScrIncorrectPhoneLock(void)
  1032. {
  1033.     /*----------------------------------------------------------------*/
  1034.     /* Local Variables                                                */
  1035.     /*----------------------------------------------------------------*/
  1036.     /*----------------------------------------------------------------*/
  1037.     /* Code Body                                                      */
  1038.     /*----------------------------------------------------------------*/
  1039.     DisplayPopup((U8*) GetString(STR_INCORRECT_PHONELOCK), IMG_GLOBAL_ERROR, 0, 2000, (U8) ERROR_TONE);
  1040. }
  1041. /*****************************************************************************
  1042.  * FUNCTION
  1043.  *  EntryScrIncorrectPUK
  1044.  * DESCRIPTION
  1045.  *  Flash message incorrect PUK try again
  1046.  * PARAMETERS
  1047.  *  void
  1048.  * RETURNS
  1049.  *  void
  1050.  *****************************************************************************/
  1051. void EntryScrIncorrectPUK(void)
  1052. {
  1053.     /*----------------------------------------------------------------*/
  1054.     /* Local Variables                                                */
  1055.     /*----------------------------------------------------------------*/
  1056.     /*----------------------------------------------------------------*/
  1057.     /* Code Body                                                      */
  1058.     /*----------------------------------------------------------------*/
  1059.     DisplayPopup((U8*) GetString(STR_INCORRECT_PUK), IMG_GLOBAL_ERROR, 0, 2000, (U8) ERROR_TONE);
  1060.     DeleteUptoScrID(SCR_ENTER_PUK);
  1061. }
  1062. /*****************************************************************************
  1063.  * FUNCTION
  1064.  *  EntryScrPinBlocked
  1065.  * DESCRIPTION
  1066.  *  Flash message PIN is blocked
  1067.  * PARAMETERS
  1068.  *  void
  1069.  * RETURNS
  1070.  *  void
  1071.  *****************************************************************************/
  1072. void EntryScrPinBlocked(void)
  1073. {
  1074.     /*----------------------------------------------------------------*/
  1075.     /* Local Variables                                                */
  1076.     /*----------------------------------------------------------------*/
  1077.     /*----------------------------------------------------------------*/
  1078.     /* Code Body                                                      */
  1079.     /*----------------------------------------------------------------*/
  1080.     EntryNewScreen(STR_PIN_BLOCKED_PUK, ExitScrPinBlocked, NULL, NULL);
  1081.     GenericExitScreen(SCR_POP_UP_HISTORY, EntryScrEnterPUK);
  1082.     ShowCategory123Screen(0, 0, 0, 0, 0, 0, STR_PIN_BLOCKED_PUK, IMG_GLOBAL_WARNING, NULL);
  1083.     playRequestedTone(WARNING_TONE);
  1084.     StartTimer(CODE_VERIFIED_TIMER, CODE_VERIFIED_TIMEOUT, EntryScrEnterPUK);
  1085.     SetGroupKeyHandler(EntryScrEnterPUK, (PU16) PresentAllKeys, (U8) TOTAL_KEYS, (U16) KEY_EVENT_DOWN);
  1086. }
  1087. /*****************************************************************************
  1088.  * FUNCTION
  1089.  *  ExitScrPinBlocked
  1090.  * DESCRIPTION
  1091.  *  Exit function for PIN blocked screen
  1092.  * PARAMETERS
  1093.  *  void
  1094.  * RETURNS
  1095.  *  void
  1096.  *****************************************************************************/
  1097. void ExitScrPinBlocked(void)
  1098. {
  1099.     /*----------------------------------------------------------------*/
  1100.     /* Local Variables                                                */
  1101.     /*----------------------------------------------------------------*/
  1102.     /*----------------------------------------------------------------*/
  1103.     /* Code Body                                                      */
  1104.     /*----------------------------------------------------------------*/
  1105.     stopRequestedTone(WARNING_TONE);
  1106.     StopTimer(CODE_VERIFIED_TIMER);
  1107. }
  1108. /*****************************************************************************
  1109.  * FUNCTION
  1110.  *  EntryScrCodeVerified
  1111.  * DESCRIPTION
  1112.  *  PopUp when code is verified
  1113.  * PARAMETERS
  1114.  *  void
  1115.  * RETURNS
  1116.  *  void
  1117.  *****************************************************************************/
  1118. void EntryScrCodeVerified(void)
  1119. {
  1120.     /*----------------------------------------------------------------*/
  1121.     /* Local Variables                                                */
  1122.     /*----------------------------------------------------------------*/
  1123.     /*----------------------------------------------------------------*/
  1124.     /* Code Body                                                      */
  1125.     /*----------------------------------------------------------------*/
  1126.     DisplayPopup((U8*) GetString(STR_CODE_VERIFIED), IMG_GLOBAL_ACTIVATED, 0, 2000, (U8) SUCCESS_TONE);
  1127.     DeleteScreenIfPresent(SCR_ENTER_PIN);
  1128.     DeleteScreenIfPresent(SCR_ENTER_PUK);
  1129.     DeleteScreenIfPresent(SCR_ENTER_NEW_PIN);
  1130.     DeleteScreenIfPresent(SCR_ENTER_CONFIRM_PIN);
  1131.     DeleteScreenIfPresent(SCR_ENTER_NP);
  1132.     DeleteScreenIfPresent(SCR_ENTER_NSP);
  1133.     DeleteScreenIfPresent(SCR_ENTER_CP);
  1134.     DeleteScreenIfPresent(SCR_ENTER_SP);
  1135.     DeleteScreenIfPresent(SCR_ENTER_SIMP);
  1136. #ifdef __MMI_SML_MENU__
  1137.     DeleteScreenIfPresent(SCR_ENTER_NS_SP);
  1138.     DeleteScreenIfPresent(SCR_ENTER_SIM_C);
  1139. #endif /* __MMI_SML_MENU__ */
  1140.     if (isInCall())
  1141.     {
  1142.         /* input PIN1 screen + incoming call + code accepted screen */
  1143.         mmi_frm_add_history_before_cm_marker(GLOBAL_SCR_DUMMY, mmi_bootup_exit_security_check);
  1144.     }
  1145.     else
  1146.     {
  1147.         /* input PIN1 screen + unfinished code accepted screen + incoming call */
  1148.         GenericExitScreen(GLOBAL_SCR_DUMMY, mmi_bootup_exit_security_check);
  1149.     }
  1150. }
  1151. /**************************************************************************
  1152.    SSC APIs:
  1153.       void SSCHandleEnterPUK(void)
  1154.       void ExitSSCHandleEnterPUK(void)
  1155.       void ValidateSSCStringPUK(void)
  1156.       void MakeCallSSCStringPUK(void)
  1157. **************************************************************************/
  1158. /*****************************************************************************
  1159.  * FUNCTION
  1160.  *  SSCHandleEnterPUK
  1161.  * DESCRIPTION
  1162.  *  Input PUK by SSC string
  1163.  * PARAMETERS
  1164.  *  void
  1165.  * RETURNS
  1166.  *  void
  1167.  *****************************************************************************/
  1168. void SSCHandleEnterPUK(void)
  1169. {
  1170.     /*----------------------------------------------------------------*/
  1171.     /* Local Variables                                                */
  1172.     /*----------------------------------------------------------------*/
  1173.     U16 Keycode, Keytype;
  1174.     U8 *history_buffer;
  1175.     /*----------------------------------------------------------------*/
  1176.     /* Code Body                                                      */
  1177.     /*----------------------------------------------------------------*/
  1178.     if (pfnUnicodeStrlen((S8*) gInputPwdBuffer) == 0)
  1179.     {
  1180.         EntryNewScreen(SCR_SSC_ENTER_PUK, ExitSSCHandleEnterPUK, NULL, NULL);
  1181.         GetkeyInfo(&Keycode, &Keytype);
  1182.         if (pfnUnicodeStrlen(g_idle_context.DialPadCallBuffer) == 0)
  1183.         {
  1184.             g_idle_context.IdleScreenDigitKeyCode = Keycode;
  1185.         }
  1186.         g_pwr_context.SSCFromEnterPukAtBootUp = 0;
  1187.         history_buffer = GetCurrGuiBuffer(SCR_SSC_ENTER_PUK);
  1188.         ShowCategory16Screen(
  1189.             0,
  1190.             0,
  1191.             STR_GLOBAL_BACK,
  1192.             0,
  1193.             (U8*) g_idle_context.DialPadCallBuffer,
  1194.             MAX_DIAL_PAD,
  1195.             history_buffer);
  1196.         if (g_idle_context.IdleScreenDigitKeyCode >= 0)
  1197.         {
  1198.             ExecuteCurrKeyHandler(g_idle_context.IdleScreenDigitKeyCode, KEY_EVENT_DOWN);
  1199.         }
  1200.         /* if come from setting PUK scr then should not go to idle scr on press on END --vanita */
  1201.         if (IsScreenPresent(SCR_ID_SECSET_PUK1))
  1202.         {
  1203.             ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1204.             ClearKeyHandler(KEY_END, KEY_EVENT_UP);
  1205.         }
  1206.         SetKeyHandler(ValidateSSCStringPUK, KEY_POUND, KEY_EVENT_UP);
  1207.         SetCategory16RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1208.     }
  1209. }
  1210. /*****************************************************************************
  1211.  * FUNCTION
  1212.  *  ExitSSCHandleEnterPUK
  1213.  * DESCRIPTION
  1214.  *  Exit function for SSC screen from PUK
  1215.  * PARAMETERS
  1216.  *  void
  1217.  * RETURNS
  1218.  *  void
  1219.  *****************************************************************************/
  1220. void ExitSSCHandleEnterPUK(void)
  1221. {
  1222.     /*----------------------------------------------------------------*/
  1223.     /* Local Variables                                                */
  1224.     /*----------------------------------------------------------------*/
  1225.     /*----------------------------------------------------------------*/
  1226.     /* Code Body                                                      */
  1227.     /*----------------------------------------------------------------*/
  1228.     if (!g_pwr_context.SSCFromEnterPukAtBootUp)
  1229.     {
  1230.         GenericExitScreen(SCR_SSC_ENTER_PUK, SSCHandleEnterPUK);
  1231.     }
  1232.     g_idle_context.IdleScreenDigitKeyCode = -1;
  1233. }
  1234. /*****************************************************************************
  1235.  * FUNCTION
  1236.  *  ValidateSSCStringPUK
  1237.  * DESCRIPTION
  1238.  *  Validate is it a valid SSC for puk screen
  1239.  * PARAMETERS
  1240.  *  void
  1241.  * RETURNS
  1242.  *  void
  1243.  *****************************************************************************/
  1244. void ValidateSSCStringPUK(void)
  1245. {
  1246.     /*----------------------------------------------------------------*/
  1247.     /* Local Variables                                                */
  1248.     /*----------------------------------------------------------------*/
  1249.     /*----------------------------------------------------------------*/
  1250.     /* Code Body                                                      */
  1251.     /*----------------------------------------------------------------*/
  1252.     g_pwr_context.SSCFromEnterPukAtBootUp = 1;
  1253.     if (!SSCStringParsing3())
  1254.     {
  1255.         DisplayPopup((U8*) GetString(STR_INCORRECT_SSC), IMG_GLOBAL_WARNING, 0, 2000, (U8) ERROR_TONE);
  1256.         g_pwr_context.SSCFromEnterPukAtBootUp = 0;
  1257.         DeleteScreenIfPresent(SCR_SSC_ENTER_PUK);
  1258.     }
  1259. }
  1260. /*****************************************************************************
  1261.  * FUNCTION
  1262.  *  MakeCallSSCStringPUK
  1263.  * DESCRIPTION
  1264.  *  Make call for PUK screen SSC
  1265.  * PARAMETERS
  1266.  *  void
  1267.  * RETURNS
  1268.  *  void
  1269.  *****************************************************************************/
  1270. void MakeCallSSCStringPUK(void)
  1271. {
  1272.     /*----------------------------------------------------------------*/
  1273.     /* Local Variables                                                */
  1274.     /*----------------------------------------------------------------*/
  1275.     /*----------------------------------------------------------------*/
  1276.     /* Code Body                                                      */
  1277.     /*----------------------------------------------------------------*/
  1278.     MakeCall(g_idle_context.DialPadCallBuffer);
  1279. }
  1280. /**************************************************************************
  1281.    NAND sanity check APIs:
  1282.       void PWR_NAND_SanityCheck_Popup(void)
  1283.       void PWR_NAND_SanityCheck_response_handler(void)
  1284.       void PWR_NAND_SanityCheck_skip_check(void)
  1285.       void PWR_NAND_SanityCheck_proceed_check(void)
  1286.       void PWR_NAND_SanityCheckDisplay_Exit(void)
  1287.       void PWR_NAND_SanityCheckDisplay(void)
  1288. **************************************************************************/
  1289. #ifdef __FS_CHECKDRIVE_SUPPORT__
  1290. /*****************************************************************************
  1291.  * FUNCTION
  1292.  *  PWR_NAND_SanityCheck_Popup
  1293.  * DESCRIPTION
  1294.  *  NAND check popup for done
  1295.  * PARAMETERS
  1296.  *  info        [IN]        
  1297.  * RETURNS
  1298.  *  void
  1299.  *****************************************************************************/
  1300. extern pBOOL isInCall(void);
  1301. extern void mmi_pwron_entry_animation_screen(void);
  1302. static void PWR_NAND_SanityCheck_Popup(void *info)
  1303. {
  1304.     /*----------------------------------------------------------------*/
  1305.     /* Local Variables                                                */
  1306.     /*----------------------------------------------------------------*/
  1307.     /*----------------------------------------------------------------*/
  1308.     /* Code Body                                                      */
  1309.     /*----------------------------------------------------------------*/
  1310.     DisplayPopup(
  1311.         (U8*) GetString(STR_GLOBAL_DONE),
  1312.         IMG_GLOBAL_ACTIVATED,
  1313.         1,
  1314.         2000,
  1315.         (U8) SUCCESS_TONE);
  1316.     ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1317.     SanityCheckDone = 2;
  1318.     DeleteScreenIfPresent(SCR_NAND_FLASH_CHECK);
  1319.     DeleteScreenIfPresent(SCR_NAND_CHECK_PROCESSING);
  1320.     DeleteScreenIfPresent(SCR_CHARGER_POPUP);
  1321.     /* Aviod no history to go back */
  1322.     if (!IsScreenPresent(SCR_OPEN_SCREEN_ID))
  1323.     {
  1324.         if (isInCall())
  1325.         {
  1326.             mmi_frm_add_history_before_cm_marker(SCR_OPEN_SCREEN_ID, mmi_pwron_entry_animation_screen);
  1327.         }
  1328.         else
  1329.         {
  1330.             GenericExitScreen(SCR_OPEN_SCREEN_ID, mmi_pwron_entry_animation_screen);
  1331.         }
  1332.     }
  1333.     FS_ClearDiskFlag();
  1334. }
  1335. /*****************************************************************************
  1336.  * FUNCTION
  1337.  *  PWR_NAND_SanityCheck_skip_check
  1338.  * DESCRIPTION
  1339.  *  Skip NAND check
  1340.  * PARAMETERS
  1341.  *  void
  1342.  * RETURNS
  1343.  *  void
  1344.  *****************************************************************************/
  1345. static void PWR_NAND_SanityCheck_skip_check(void)
  1346. {
  1347.     /*----------------------------------------------------------------*/
  1348.     /* Local Variables                                                */
  1349.     /*----------------------------------------------------------------*/
  1350.     /*----------------------------------------------------------------*/
  1351.     /* Code Body                                                      */
  1352.     /*----------------------------------------------------------------*/
  1353.     SanityCheckDone = 1;
  1354.     mmi_bootup_exit_nand_check_query();
  1355. }
  1356. /*****************************************************************************
  1357.  * FUNCTION
  1358.  *  PWR_NAND_SanityCheck_proceed_check
  1359.  * DESCRIPTION
  1360.  *  Proceed NAND check
  1361.  * PARAMETERS
  1362.  *  void
  1363.  * RETURNS
  1364.  *  void
  1365.  *****************************************************************************/
  1366. static void PWR_NAND_SanityCheck_proceed_check(void)
  1367. {
  1368. #ifdef MMI_ON_HARDWARE_P
  1369.     /*----------------------------------------------------------------*/
  1370.     /* Local Variables                                                */
  1371.     /*----------------------------------------------------------------*/
  1372.     MYQUEUE Message;
  1373.     mmi_fmt_check_drive_req_strcut *req =
  1374.         (mmi_fmt_check_drive_req_strcut*) OslConstructDataPtr(sizeof(mmi_fmt_check_drive_req_strcut));
  1375.     /*----------------------------------------------------------------*/
  1376.     /* Code Body                                                      */
  1377.     /*----------------------------------------------------------------*/
  1378.     EntryNewScreen(SCR_NAND_CHECK_PROCESSING, NULL, PWR_NAND_SanityCheck_proceed_check, NULL);
  1379. #ifdef __MMI_FILE_MANAGER__
  1380.     req->drive = MMI_PUBLIC_DRV;
  1381. #endif 
  1382.     if (SanityCheckDone != 3)
  1383.     {
  1384.         SanityCheckDone = 3;    /* processing */
  1385.         /* Send message to FMT */
  1386.         Message.oslSrcId = MOD_MMI;
  1387.         Message.oslDestId = MOD_FMT;
  1388.         Message.oslMsgId = MSG_ID_MMI_FMT_CHECK_DRIVE_REQ;
  1389.         Message.oslDataPtr = (oslParaType*) req;
  1390.         Message.oslPeerBuffPtr = NULL;
  1391.         OslMsgSendExtQueue(&Message);
  1392.         SetProtocolEventHandler(PWR_NAND_SanityCheck_Popup, PRT_MMI_FMGR_CHECK_DRIVE_RSP);
  1393.     }
  1394.     ShowCategory66Screen(
  1395.         STR_NAND_CHECK_TITLE,
  1396.         0,
  1397.         0,
  1398.         0,
  1399.         0,
  1400.         0,
  1401.         (PU8) GetString(STR_NAND_CHECK_PROCESSING),
  1402.         IMG_GLOBAL_PROGRESS,
  1403.         NULL);
  1404.     ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1405. #else /* MMI_ON_HARDWARE_P */ /* for pc simulator */
  1406.     extern void EntryScrDisplayUSSNMsg(void);
  1407.     EntryNewScreen(SCR_NAND_CHECK_PROCESSING, NULL, PWR_NAND_SanityCheck_proceed_check, NULL);
  1408.     StopTimer(WELCOME_SCR_TIMER);
  1409.     if (SanityCheckDone != 3)
  1410.     {
  1411.         SanityCheckDone = 3;    /* processing */
  1412.         StartTimer(WELCOME_SCR_TIMER, 5000, PWR_NAND_SanityCheck_Popup);
  1413.     }
  1414.     ShowCategory66Screen(
  1415.         STR_NAND_CHECK_TITLE,
  1416.         0,
  1417.         0,
  1418.         0,
  1419.         0,
  1420.         0,
  1421.         (PU8) GetString(STR_NAND_CHECK_PROCESSING),
  1422.         IMG_GLOBAL_PROGRESS,
  1423.         NULL);
  1424.     ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1425. #endif /* MMI_ON_HARDWARE_P */ 
  1426. }
  1427. /*****************************************************************************
  1428.  * FUNCTION
  1429.  *  PWR_NAND_SanityCheckDisplay_Exit
  1430.  * DESCRIPTION
  1431.  *  Exit NAND check
  1432.  * PARAMETERS
  1433.  *  void
  1434.  * RETURNS
  1435.  *  void
  1436.  *****************************************************************************/
  1437. void PWR_NAND_SanityCheckDisplay_Exit(void)
  1438. {
  1439.     /*----------------------------------------------------------------*/
  1440.     /* Local Variables                                                */
  1441.     /*----------------------------------------------------------------*/
  1442.     /*----------------------------------------------------------------*/
  1443.     /* Code Body                                                      */
  1444.     /*----------------------------------------------------------------*/
  1445. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1446.     restore_small_screen();
  1447. #endif
  1448.     stopRequestedTone(WARNING_TONE);
  1449. }
  1450. /*****************************************************************************
  1451.  * FUNCTION
  1452.  *  PWR_NAND_SanityCheckDisplay
  1453.  * DESCRIPTION
  1454.  *  Display NAND check operation screen
  1455.  *  Pressing End key will come back here except during a call
  1456.  * PARAMETERS
  1457.  *  void
  1458.  * RETURNS
  1459.  *  void
  1460.  *****************************************************************************/
  1461. extern void SetCat165TimerExpireFunc(FuncPtr f);
  1462. static void PWR_NAND_SanityCheckDisplay(void)
  1463. {
  1464.     /*----------------------------------------------------------------*/
  1465.     /* Local Variables                                                */
  1466.     /*----------------------------------------------------------------*/
  1467.     U8 *guiBuffer;
  1468.     /*----------------------------------------------------------------*/
  1469.     /* Code Body                                                      */
  1470.     /*----------------------------------------------------------------*/
  1471.     guiBuffer = GetCurrGuiBuffer(SCR_NAND_FLASH_CHECK);
  1472.     /* Some application might be performed during NAND check */
  1473.     /* if the user press end key, here will be the root entry function */
  1474.     if (GetActiveScreenId() != SCR_NAND_FLASH_CHECK)    /* root and only nand check screen */
  1475.     {
  1476.         if (SanityCheckDone == 0)
  1477.         {
  1478.             EntryNewScreen(SCR_NAND_FLASH_CHECK, PWR_NAND_SanityCheckDisplay_Exit, PWR_NAND_SanityCheckDisplay, NULL);
  1479.         #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1480.             force_no_small_screen();
  1481.         #endif
  1482.             ShowCategory165Screen_ext(
  1483.                 STR_GLOBAL_YES,
  1484.                 IMG_GLOBAL_YES,
  1485.                 STR_GLOBAL_NO,
  1486.                 IMG_GLOBAL_NO,
  1487.                 get_string(STR_NAND_CHECK),
  1488.                 IMG_GLOBAL_QUESTION,
  1489.                 10,
  1490.                 guiBuffer);
  1491.             SetCat165TimerExpireFunc(PWR_NAND_SanityCheck_proceed_check);
  1492.             playRequestedTone(WARNING_TONE);
  1493.             StopLEDPatternPowerOn();
  1494.             ShowIdleAppSubLcd();
  1495.             SetKeyHandler(PWR_NAND_SanityCheck_skip_check, KEY_END, KEY_EVENT_DOWN);
  1496.             SetLeftSoftkeyFunction(PWR_NAND_SanityCheck_proceed_check, KEY_EVENT_UP);
  1497.             SetRightSoftkeyFunction(PWR_NAND_SanityCheck_skip_check, KEY_EVENT_UP);
  1498.         }
  1499.         else
  1500.         {
  1501.             /* skip or done or processing */
  1502.             mmi_bootup_exit_low_battery_warning();  /* a little strange... */
  1503.         }
  1504.     }
  1505. }
  1506. #endif /* __FS_CHECKDRIVE_SUPPORT__ */ 
  1507. /**************************************************************************
  1508.    Welcome screen APIs:
  1509.       void ShowWelcomeScr(void)
  1510.       void ExitWelcomeScreen(void)
  1511.       void ShowAphorismScr(void)
  1512.       void ExitAphorismScreen(void)
  1513.       S8* GetAphorismScrText(void)
  1514.       void BeforeEntryIdleScr(void)
  1515. **************************************************************************/
  1516. /*****************************************************************************
  1517.  * FUNCTION
  1518.  *  ShowWelcomeScr
  1519.  * DESCRIPTION
  1520.  *  Show welcome screen
  1521.  * PARAMETERS
  1522.  *  void
  1523.  * RETURNS
  1524.  *  void
  1525.  *****************************************************************************/
  1526. void ShowWelcomeScr(void)
  1527. {
  1528.     /*----------------------------------------------------------------*/
  1529.     /* Local Variables                                                */
  1530.     /*----------------------------------------------------------------*/
  1531.     S8 *WelcomeString = NULL;
  1532.     /*----------------------------------------------------------------*/
  1533.     /* Code Body                                                      */
  1534.     /*----------------------------------------------------------------*/
  1535.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_START_WELCOME));
  1536.     g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_WELCOME;  /* 0x20: Welcome screen */
  1537.     if (IsShowWelcomeScr1())
  1538.     {
  1539.         EntryNewScreen(WELCOME_SCREEN_ID, ExitWelcomeScreen, ShowWelcomeScr, NULL);
  1540.         DeleteScreenIfPresent(GLOBAL_SCR_DUMMY);
  1541.         WelcomeString = GetWelcomeText();
  1542.         StartTimer(WELCOME_SCR_TIMER, WELCOME_SCR_TIME, mmi_bootup_exit_welcome_screen);
  1543.         ShowCategory61Screen((U8*) WelcomeString, IMG_WELCOME_SCR, NULL);
  1544.         OslMfree(WelcomeString);
  1545.         /* diamond, 2005/12/22 Not allow to press END key to prevent from going back to power on animation */
  1546.         ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1547.     }
  1548.     else
  1549.     {
  1550.         mmi_bootup_exit_welcome_screen();
  1551.     }
  1552. }
  1553. /*****************************************************************************
  1554.  * FUNCTION
  1555.  *  ExitWelcomeScreen
  1556.  * DESCRIPTION
  1557.  *  Exit welcome screen
  1558.  * PARAMETERS
  1559.  *  void
  1560.  * RETURNS
  1561.  *  void
  1562.  *****************************************************************************/
  1563. void ExitWelcomeScreen(void)
  1564. {
  1565.     /*----------------------------------------------------------------*/
  1566.     /* Local Variables                                                */
  1567.     /*----------------------------------------------------------------*/
  1568.     /*----------------------------------------------------------------*/
  1569.     /* Code Body                                                      */
  1570.     /*----------------------------------------------------------------*/
  1571.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_STOP_WELCOME));
  1572.     StopTimer(WELCOME_SCR_TIMER);
  1573. }
  1574. #if defined(__MMI_APHORISM__)
  1575. /* under construction !*/
  1576. /* under construction !*/
  1577. /* under construction !*/
  1578. /* under construction !*/
  1579. /* under construction !*/
  1580. /* under construction !*/
  1581. /* under construction !*/
  1582. /* under construction !*/
  1583. /* under construction !*/
  1584. /* under construction !*/
  1585. /* under construction !*/
  1586. /* under construction !*/
  1587. /* under construction !*/
  1588. /* under construction !*/
  1589. /* under construction !*/
  1590. /* under construction !*/
  1591. /* under construction !*/
  1592. /* under construction !*/
  1593. /* under construction !*/
  1594. /* under construction !*/
  1595. /* under construction !*/
  1596. /* under construction !*/
  1597. /* under construction !*/
  1598. /* under construction !*/
  1599. /* under construction !*/
  1600. /* under construction !*/
  1601. /* under construction !*/
  1602. /* under construction !*/
  1603. /* under construction !*/
  1604. /* under construction !*/
  1605. /* under construction !*/
  1606. /* under construction !*/
  1607. /* under construction !*/
  1608. /* under construction !*/
  1609. /* under construction !*/
  1610. /* under construction !*/
  1611. /* under construction !*/
  1612. /* under construction !*/
  1613. /* under construction !*/
  1614. /* under construction !*/
  1615. /* under construction !*/
  1616. /* under construction !*/
  1617. /* under construction !*/
  1618. /* under construction !*/
  1619. /* under construction !*/
  1620. /* under construction !*/
  1621. /* under construction !*/
  1622. /* under construction !*/
  1623. /* under construction !*/
  1624. /* under construction !*/
  1625. /* under construction !*/
  1626. /* under construction !*/
  1627. /* under construction !*/
  1628. /* under construction !*/
  1629. /* under construction !*/
  1630. /* under construction !*/
  1631. /* under construction !*/
  1632. /* under construction !*/
  1633. /* under construction !*/
  1634. /* under construction !*/
  1635. /* under construction !*/
  1636. /* under construction !*/
  1637. /* under construction !*/
  1638. /* under construction !*/
  1639. /* under construction !*/
  1640. /* under construction !*/
  1641. /* under construction !*/
  1642. /* under construction !*/
  1643. /* under construction !*/
  1644. /* under construction !*/
  1645. /* under construction !*/
  1646. /* under construction !*/
  1647. /* under construction !*/
  1648. /* under construction !*/
  1649. /* under construction !*/
  1650. /* under construction !*/
  1651. /* under construction !*/
  1652. /* under construction !*/
  1653. /* under construction !*/
  1654. /* under construction !*/
  1655. /* under construction !*/
  1656. /* under construction !*/
  1657. /* under construction !*/
  1658. #endif /* defined(__MMI_APHORISM__) */ // #if defined(__MMI_APHORISM__)
  1659. /*****************************************************************************
  1660.  * FUNCTION
  1661.  *  BeforeEntryIdleScr
  1662.  * DESCRIPTION
  1663.  *  Function to be called before entry into idle screen
  1664.  * PARAMETERS
  1665.  *  void
  1666.  * RETURNS
  1667.  *  void
  1668.  *****************************************************************************/
  1669. void BeforeEntryIdleScr(void)
  1670. {
  1671.     /*----------------------------------------------------------------*/
  1672.     /* Local Variables                                                */
  1673.     /*----------------------------------------------------------------*/
  1674.     /*----------------------------------------------------------------*/
  1675.     /* Code Body                                                      */
  1676.     /*----------------------------------------------------------------*/
  1677.     /* if (  g_pwr_context.InvalidSim && !g_pwr_context.InvalidSimShowed) */
  1678.     if (mmi_bootup_is_nw_registration_ok() == MMI_FALSE && !g_pwr_context.InvalidSimShowed)
  1679.     {
  1680.         g_pwr_context.InvalidSimShowed = 1;
  1681.         DisplayInvalidSimInfo();
  1682.         DinitHistory(); /* do not go back to power on animation */
  1683.         ExitIdleScreen();
  1684.     }
  1685.     else
  1686.     {
  1687.         if (isEarphonePlugged)  /* MTK add, Robin 1015 for earphone indication comming before power on indication */
  1688.         {
  1689. #ifdef __CTM_SUPPORT__
  1690.             mmi_ctm_switch_tty_status(MMI_TRUE);
  1691.             if (mmi_ctm_is_tty_on())
  1692.             {
  1693.               /* TTY in, hide earphone icon */
  1694. #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  1695.                 IdleResetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1696. #endif
  1697.                 mdi_audio_set_audio_mode(AUD_MODE_NORMAL);
  1698.                 SetModeSpeechVolume();
  1699.                 mmi_profiles_headset_deactivate_profile();
  1700.             }
  1701.             else /* not TTY, it's earphone */
  1702. #endif /* __CTM_SUPPORT__ */ 
  1703.             {
  1704.             SetModeSpeechVolume();
  1705.             mmi_profiles_headset_activate_profile();
  1706.             }
  1707.         }
  1708.         else if (gactivatedprofile == MMI_PROFILE_HEADSET)
  1709.         {
  1710.             mdi_audio_set_audio_mode(AUD_MODE_NORMAL);
  1711.             SetModeSpeechVolume();
  1712.             mmi_profiles_headset_deactivate_profile();
  1713.         }
  1714.         EntryIdleScreen();
  1715.     }
  1716. }
  1717. /**************************************************************************
  1718.    Abnormal reset APIs:
  1719.       U8 GetAbnormalReset(void)
  1720.       void SetAbnormalReset(void)
  1721.       void ResetAbnormalReset(void)
  1722. **************************************************************************/
  1723. /*****************************************************************************
  1724.  * FUNCTION
  1725.  *  GetAbnormalReset
  1726.  * DESCRIPTION
  1727.  *  Get the status of abnormal reset
  1728.  * PARAMETERS
  1729.  *  void
  1730.  * RETURNS
  1731.  *  void
  1732.  *****************************************************************************/
  1733. U8 GetAbnormalReset(void)
  1734. {
  1735.     /*----------------------------------------------------------------*/
  1736.     /* Local Variables                                                */
  1737.     /*----------------------------------------------------------------*/
  1738.     /*----------------------------------------------------------------*/
  1739.     /* Code Body                                                      */
  1740.     /*----------------------------------------------------------------*/
  1741.     return g_pwr_context.AbnormalReset;
  1742. }
  1743. /*****************************************************************************
  1744.  * FUNCTION
  1745.  *  SetAbnormalReset
  1746.  * DESCRIPTION
  1747.  *  Set the status of abnormal reset
  1748.  * PARAMETERS
  1749.  *  void
  1750.  * RETURNS
  1751.  *  void
  1752.  *****************************************************************************/
  1753. void SetAbnormalReset(void)
  1754. {
  1755.     /*----------------------------------------------------------------*/
  1756.     /* Local Variables                                                */
  1757.     /*----------------------------------------------------------------*/
  1758.     /*----------------------------------------------------------------*/
  1759.     /* Code Body                                                      */
  1760.     /*----------------------------------------------------------------*/
  1761.     g_pwr_context.AbnormalReset = 1;
  1762.     g_pwr_context.IsCampOnTonePlayed = 1;
  1763.     //g_pwr_context.PowerOnAnimationComplete = 1;
  1764.     //g_pwr_context.PowerOnPeriod = 1;
  1765.     g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_LOW_BATTERY;  /* 0x08: Power on animation complete */
  1766.     SanityCheckDone = 2;    /* diamond, 2005/12/18 NAND check should be "done" in abnormal reset */
  1767. }
  1768. /*****************************************************************************
  1769.  * FUNCTION
  1770.  *  ResetAbnormalReset
  1771.  * DESCRIPTION
  1772.  *  Reset the status of abnormal reset
  1773.  * PARAMETERS
  1774.  *  void
  1775.  * RETURNS
  1776.  *  void
  1777.  *****************************************************************************/
  1778. void ResetAbnormalReset(void)
  1779. {
  1780.     /*----------------------------------------------------------------*/
  1781.     /* Local Variables                                                */
  1782.     /*----------------------------------------------------------------*/
  1783.     /*----------------------------------------------------------------*/
  1784.     /* Code Body                                                      */
  1785.     /*----------------------------------------------------------------*/
  1786.     g_pwr_context.AbnormalReset = 0;
  1787. }
  1788. /**************************************************************************
  1789.    Other APIs:
  1790.       void ServiceIndicationStringDisplay(void *inMsg)
  1791.       void mmi_ready_to_idle_screen_ind_hdlr(void* msg)
  1792.       void mmi_ready_to_idle_screen_ind(void)
  1793.       void mmi_idle_notify_bootup_ready_to_l4c(void)
  1794.       void DisplayInvalidSimInfo(void)
  1795.       void RemoveStatusIconsForSimRemoved(void)
  1796.       void FirstTimeTurnOnBackLight(void)
  1797.       void PowerOnBatteryIndicationCompletePhase2(void)
  1798.       void PowerOnBatteryIndicationComplete(void)
  1799.       void CallBackPowerOnAnimationComplete(GDI_RESULT ret)
  1800.       void ExitLowBatteryScrAtPowerOn(void)
  1801. **************************************************************************/
  1802. /*****************************************************************************
  1803.  * FUNCTION
  1804.  *  ServiceIndicationStringDisplay
  1805.  * DESCRIPTION
  1806.  *  This function is a call back for MSG_ID_MMI_CPHS_MMI_INFO_IND
  1807.  *  It will be passed to CPHSMMInfoInd first
  1808.  * PARAMETERS
  1809.  *  inMsg       [IN]        
  1810.  * RETURNS
  1811.  *  void
  1812.  *****************************************************************************/
  1813. void ServiceIndicationStringDisplay(void *inMsg)
  1814. {
  1815.     /*----------------------------------------------------------------*/
  1816.     /* Local Variables                                                */
  1817.     /*----------------------------------------------------------------*/
  1818.     mmi_cphs_mmi_info_ind_struct *local_data = (mmi_cphs_mmi_info_ind_struct*) inMsg;
  1819.     U8 i = 0, len = 0;
  1820.     PS8 pString;
  1821.     /*----------------------------------------------------------------*/
  1822.     /* Code Body                                                      */
  1823.     /*----------------------------------------------------------------*/
  1824.     gOpNameValid = local_data->is_opname_valid;
  1825.     gShortOpnameValid = local_data->is_sopname_valid;
  1826.     gSpnValid = local_data->is_spn_valid;
  1827.     /* not to display RPLMN if SPN say so */
  1828.     if (gSpnValid == 1)
  1829.     {
  1830.         g_pwr_context.RequireRPLMN = local_data->is_spn_RPLMN_required;
  1831.     }
  1832.     if (gOpNameValid)
  1833.     {
  1834.         AnsiiToUnicodeString(gOperatorName, (S8*) local_data->opname);
  1835.     }
  1836.     if (gShortOpnameValid)
  1837.     {
  1838.         AnsiiToUnicodeString(gShortOperatorName, (S8*) local_data->sopname);
  1839.     }
  1840.     if (gSpnValid)
  1841.     {
  1842.         if (local_data->spn[0] >= 0x80) /* diamond, 2005/08/03 support SPN with UCS2 from SIM */
  1843.         {
  1844.             U8 *convertedData = NULL;
  1845.             U8 dcs;
  1846.             switch (local_data->spn[0])
  1847.             {
  1848.                 case 0x80:
  1849.                     dcs = MMI_UCS2_DCS;
  1850.                     break;
  1851.                 case 0x81:
  1852.                     dcs = MMI_UCS2_81;
  1853.                     break;
  1854.                 case 0x82:
  1855.                     dcs = MMI_UCS2_82;
  1856.                     break;
  1857.                 default:
  1858.                     dcs = 0;
  1859.                     break;
  1860.             }
  1861.             if (dcs == 0)
  1862.             {
  1863.                 gSpnValid = 0;
  1864.             }
  1865.             else
  1866.             {
  1867.                 convertedData = CovertStringForPlatform(
  1868.                                     local_data->spn + 1,
  1869.                                     (U16) (strlen((PS8) (local_data->spn + 1))),
  1870.                                     dcs,
  1871.                                     NULL);
  1872.                 pfnUnicodeStrcpy((PS8) gServProvderName, (PS8) convertedData);
  1873.                 OslMfree(convertedData);
  1874.             }
  1875.         }
  1876.         else
  1877.         {
  1878.             AnsiiToUnicodeString(gServProvderName, (S8*) local_data->spn);
  1879.         }
  1880.     }
  1881.     /* Owner Number */
  1882.     memset((void*)&gDispOwnerNumber, 0, sizeof(gDispOwnerNumber));
  1883.     if (local_data->no_msisdn > 0)
  1884.     {
  1885.         for (i = 0; ((i < MAX_LINE_NUM) && (i < local_data->no_msisdn)); i++)
  1886.         {
  1887.             if (local_data->msisdn[i].alpha_id_size != 0)
  1888.             {
  1889.                 len =
  1890.                     (((local_data->msisdn[i].alpha_id_size) >
  1891.                       MAX_PB_NAME_LENGTH) ? MAX_PB_NAME_LENGTH : (local_data->msisdn[i].alpha_id_size));
  1892.                 InputboxConvertGSMToDeviceEncoding(
  1893.                     local_data->msisdn[i].alpha_id,
  1894.                     gDispOwnerNumber[i].name,
  1895.                     len,
  1896.                     (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH,
  1897.                     local_data->msisdn[i].alpha_id_dcs,
  1898.                     0,
  1899.                     1);
  1900.             }
  1901.             if ((strlen((S8*) local_data->msisdn[i].digit) != 0) ||
  1902.                 (local_data->msisdn[i].ton_npi != 0xFF && ((local_data->msisdn[i].ton_npi) & 0x10) != 0))
  1903.             {
  1904.                 /* Prevent PS error. Watch out!! should sync with l4csmu_addr_struct */
  1905.                 local_data->msisdn[i].digit[MAX_PB_NUMBER_LENGTH] = 0x0;
  1906.                 local_data->msisdn[i].digit[MAX_PB_NUMBER_LENGTH - 1] = 0x0;
  1907.                 if (((local_data->msisdn[i].ton_npi) & 0x10) != 0)
  1908.                 {
  1909.                     len = MAX_PB_NUMBER_LENGTH;
  1910.                     gDispOwnerNumber[i].number[0] = '+';
  1911.                     pString = (PS8) gDispOwnerNumber[i].number + ENCODING_LENGTH;
  1912.                 }
  1913.                 else
  1914.                 {
  1915.                     len = MAX_PB_NUMBER_LENGTH + 1;
  1916.                     pString = (PS8) gDispOwnerNumber[i].number;
  1917.                 }
  1918.                 AnsiiNToUnicodeString((PS8) pString, (S8*) local_data->msisdn[i].digit, len);
  1919.             }
  1920.         }
  1921.     }
  1922.     RefreshDisplayOwnerNumber((U8) g_callset_context.LineID);   /* in LineSwitching.c */
  1923.     if (g_idle_context.IsOnIdleScreen)
  1924.     {
  1925.         EntryIdleScreen();
  1926.     }
  1927. }
  1928. /*****************************************************************************
  1929.  * FUNCTION
  1930.  *  mmi_ready_to_idle_screen_ind_hdlr
  1931.  * DESCRIPTION
  1932.  *  Ready go to idle handler
  1933.  *  We use this message to enter idle screen, this is used to solve NVRAM/timer interlace problem
  1934.  * PARAMETERS
  1935.  *  msg     [IN]        
  1936.  * RETURNS
  1937.  *  void
  1938.  *****************************************************************************/
  1939. void mmi_ready_to_idle_screen_ind_hdlr(void *msg)
  1940. {
  1941.     /*----------------------------------------------------------------*/
  1942.     /* Local Variables                                                */
  1943.     /*----------------------------------------------------------------*/
  1944.     /*----------------------------------------------------------------*/
  1945.     /* Code Body                                                      */
  1946.     /*----------------------------------------------------------------*/
  1947.     /* there might be an very critail timing issue here */
  1948.     /*
  1949.      * (PS. set Tab=3 to view the following diagram correctly)
  1950.      * 
  1951.      * (1) =======================================================
  1952.      * 
  1953.      * [Sim ready, send SIM_READY_IND to MMI]
  1954.      * 
  1955.      * 
  1956.      * PS         ------------------------------------------------
  1957.      * 
  1958.      * (SIM ready)
  1959.      * SIM        ----------*-------------------------------------
  1960.      * | SIM_RDY_IND
  1961.      * v
  1962.      * PWRON HDLR ------------------------------------------------
  1963.      * 
  1964.      * 
  1965.      * MT SCREEN  ------------------------------------------------
  1966.      * 
  1967.      * 
  1968.      * [MSG Queue: (1)SIM_RDY_INC]
  1969.      * 
  1970.      * ===========================================================
  1971.      * 
  1972.      * 
  1973.      * (2) =======================================================
  1974.      * 
  1975.      * [Before SIM_RDY_IND arrive MMI, MT Call happened]
  1976.      * (MT Call)
  1977.      * PS         ------------*-----------------------------------
  1978.      * | MT_CALL_IND
  1979.      * |
  1980.      * SIM        ----------*-|-----------------------------------
  1981.      * | |
  1982.      * v |
  1983.      * PWRON HDLR ------------|-----------------------------------
  1984.      * |                                    
  1985.      * v                                    
  1986.      * MT SCREEN  ------------------------------------------------ 
  1987.      * 
  1988.      * 
  1989.      * [MSG Queue: (1)SIM_RDY_INC, (2) MT_CALL_IND]
  1990.      * ===========================================================
  1991.      * 
  1992.      * 
  1993.      * (3) =======================================================
  1994.      * 
  1995.      * [Then we will process SIM_RDY_INC, it will call this function 
  1996.      * to send MMI_RDT_TO_IDLE_SCR_IND to it self]
  1997.      * 
  1998.      * 
  1999.      * (MT Call)
  2000.      * PS         ------------*-----------------------------------
  2001.      * | MT_CALL_IND
  2002.      * |
  2003.      * SIM        ----------*-|-----------------------------------
  2004.      * | |
  2005.      * | |
  2006.      * PWRON HDLR ----------#-|-----------------------------------
  2007.      * |                                    
  2008.      * v
  2009.      * MT SCREEN  ------------------------------------------------ 
  2010.      * 
  2011.      * 
  2012.      * [MSG Queue: (1) MT_CALL_IND (2) MMI_RDT_TO_IDLE_SCR_IND ]
  2013.      * ===========================================================
  2014.      * 
  2015.      * (4) Then will proceed MT_CALL_IND first, it will enter MT call screen.
  2016.      * (5) But it will follow up by proceeding MMI_RDT_TO_IDLE_SCR_IND, it 
  2017.      * will force to enter idle screen. So the MT call screen will gone..
  2018.      * 
  2019.      * [Soultion]
  2020.      * We have to check if it is already in MT call screen. If yes, we do not send 
  2021.      * MSG_ID_MMI_READY_TO_IDLE_SCREEN_IND.
  2022.      * 
  2023.      */
  2024.     /* 
  2025.      * the reason to send out this message, it to solve NVRAM/Timer interleaving problem 
  2026.      * while powering on.
  2027.      */
  2028.     if (isInCall())
  2029.     {
  2030.         /* is in call, after call end, call management will lead to idle screen */
  2031.         MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_CALL_BEFORE_IDLE));
  2032.         return;
  2033.     }
  2034.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_READY_TO_IDLE));
  2035.     ClearProtocolEventHandler(MSG_ID_MMI_READY_TO_IDLE_SCREEN_IND);
  2036.     goto_opening_screen();
  2037. }
  2038. /*****************************************************************************
  2039.  * FUNCTION
  2040.  *  mmi_ready_to_idle_screen_ind
  2041.  * DESCRIPTION
  2042.  *  Send message to MMI itself for ready to idle screen
  2043.  * PARAMETERS
  2044.  *  void
  2045.  * RETURNS
  2046.  *  void
  2047.  *****************************************************************************/
  2048. void mmi_ready_to_idle_screen_ind(void) /* this function is call by MMI */
  2049. {
  2050. #ifdef MMI_ON_HARDWARE_P
  2051.     /*----------------------------------------------------------------*/
  2052.     /* Local Variables                                                */
  2053.     /*----------------------------------------------------------------*/
  2054.     MYQUEUE Message;
  2055.     /*----------------------------------------------------------------*/
  2056.     /* Code Body                                                      */
  2057.     /*----------------------------------------------------------------*/
  2058.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_SEND_MSG_2_MMI));
  2059.     Message.oslSrcId = MOD_MMI;
  2060.     Message.oslDestId = MOD_MMI;
  2061.     Message.oslMsgId = MSG_ID_MMI_READY_TO_IDLE_SCREEN_IND;
  2062.     Message.oslDataPtr = (oslParaType*) NULL;
  2063.     Message.oslPeerBuffPtr = NULL;
  2064.     OslMsgSendExtQueue(&Message);
  2065.     SetProtocolEventHandler(mmi_ready_to_idle_screen_ind_hdlr, MSG_ID_MMI_READY_TO_IDLE_SCREEN_IND);
  2066. #endif /* MMI_ON_HARDWARE_P */ 
  2067. }
  2068. /*****************************************************************************
  2069.  * FUNCTION
  2070.  *  mmi_idle_notify_bootup_ready_to_l4c
  2071.  * DESCRIPTION
  2072.  *  Send message to L4C to notify idle screen reached
  2073.  * PARAMETERS
  2074.  *  void
  2075.  * RETURNS
  2076.  *  void
  2077.  *****************************************************************************/
  2078. void mmi_idle_notify_bootup_ready_to_l4c(void)  /* this function is call by MMI */
  2079. {
  2080. #ifdef MMI_ON_HARDWARE_P
  2081.     /*----------------------------------------------------------------*/
  2082.     /* Local Variables                                                */
  2083.     /*----------------------------------------------------------------*/
  2084.     static BOOL haveBeenCalled = MMI_FALSE;
  2085.     MYQUEUE Message;
  2086.     /*----------------------------------------------------------------*/
  2087.     /* Code Body                                                      */
  2088.     /*----------------------------------------------------------------*/
  2089.     if (haveBeenCalled == MMI_FALSE)
  2090.     {
  2091.         haveBeenCalled = MMI_TRUE;
  2092.         Message.oslSrcId = MOD_MMI;
  2093.         Message.oslDestId = MOD_L4C;
  2094.         Message.oslMsgId = MSG_ID_MMI_READY_NOTIFY_REQ;
  2095.         Message.oslDataPtr = (oslParaType*) NULL;
  2096.         Message.oslPeerBuffPtr = NULL;
  2097.         OslMsgSendExtQueue(&Message);
  2098.     }
  2099. #endif /* MMI_ON_HARDWARE_P */ 
  2100. }
  2101. /*****************************************************************************
  2102.  * FUNCTION
  2103.  *  DisplayInvalidSimInfo
  2104.  * DESCRIPTION
  2105.  *  Display invalid SIM info
  2106.  * PARAMETERS
  2107.  *  void
  2108.  * RETURNS
  2109.  *  void
  2110.  *****************************************************************************/
  2111. void DisplayInvalidSimInfo(void)
  2112. {
  2113.     /*----------------------------------------------------------------*/
  2114.     /* Local Variables                                                */
  2115.     /*----------------------------------------------------------------*/
  2116.     /*----------------------------------------------------------------*/
  2117.     /* Code Body                                                      */
  2118.     /*----------------------------------------------------------------*/
  2119.     EntryNewScreen(SCR_INVALID_SIM_INFO, NULL, DisplayInvalidSimInfo, NULL);
  2120.     ShowCategory2Screen(
  2121.         STR_SIM_INVALID_SIM_TITLE,
  2122.         0,
  2123.         STR_GLOBAL_OK,
  2124.         IMG_GLOBAL_OK,
  2125.         0,
  2126.         0,
  2127.         STR_SIM_INVALID_SIM_TXT,
  2128.         NULL);
  2129.     if (gSecuritySetupContext.PINBlocked || IsScreenPresent(IDLE_SCREEN_ID))
  2130.     {
  2131.         SetLeftSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2132.     }
  2133.     else
  2134.     {
  2135.         SetLeftSoftkeyFunction(EntryIdleScreen, KEY_EVENT_UP);
  2136.     }
  2137.     /* end the network searching screen */
  2138.     g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_NETWORK_FLAG;
  2139. }
  2140. /*****************************************************************************
  2141.  * FUNCTION
  2142.  *  RemoveStatusIconsForSimRemoved
  2143.  * DESCRIPTION
  2144.  *  Remove invalid status icon when sim is removed or blocked in running condition
  2145.  * PARAMETERS
  2146.  *  void
  2147.  * RETURNS
  2148.  *  void
  2149.  *****************************************************************************/
  2150. void RemoveStatusIconsForSimRemoved(void)
  2151. {
  2152.     /*----------------------------------------------------------------*/
  2153.     /* Local Variables                                                */
  2154.     /*----------------------------------------------------------------*/
  2155.     /*----------------------------------------------------------------*/
  2156.     /* Code Body                                                      */
  2157.     /*----------------------------------------------------------------*/
  2158.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_REMOVE_ICONS));
  2159.     HideStatusIcon(STATUS_ICON_ROAMING);
  2160.     HideStatusIcon(STATUS_ICON_CALL_DIVERT_L1L2);
  2161. #ifdef __MMI_CFU_SEPARATE_LINE__
  2162.     HideStatusIcon(STATUS_ICON_CALL_DIVERT_L1);
  2163.     HideStatusIcon(STATUS_ICON_CALL_DIVERT_L2);
  2164. #endif /* __MMI_CFU_SEPARATE_LINE__ */ 
  2165.     HideStatusIcon(STATUS_ICON_INCOMING_SMS);
  2166. #ifndef __MMI_TOUCH_SCREEN__
  2167.     HideStatusIcon(STATUS_ICON_KEYPAD_LOCK);
  2168. #endif 
  2169.     HideStatusIcon(STATUS_ICON_MISSED_CALL);
  2170. #ifndef __MMI_SUBLCD_SHORT_STATUSICON_LIST__
  2171.     HideStatusIcon(STATUS_ICON_SUBLCD_MISSED_CALL);
  2172. #endif 
  2173.     HideStatusIcon(STATUS_ICON_UNREAD_VOICE_L1L2);
  2174.     HideStatusIcon(STATUS_ICON_UNREAD_VOICE_L1);
  2175.     HideStatusIcon(STATUS_ICON_UNREAD_VOICE_L2);
  2176.     HideStatusIcon(STATUS_ICON_UNREAD_FAX_L1L2);
  2177.     HideStatusIcon(STATUS_ICON_UNREAD_FAX_L1);
  2178.     HideStatusIcon(STATUS_ICON_UNREAD_FAX_L2);
  2179.     HideStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1L2);
  2180.     HideStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
  2181.     HideStatusIcon(STATUS_ICON_UNREAD_EMAIL_L2);
  2182.     HideStatusIcon(STATUS_ICON_SUBLCD_SMS);
  2183.     HideStatusIcon(STATUS_ICON_MMS_UNREAD);
  2184.     HideStatusIcon(STATUS_ICON_MMS_BUSY);
  2185.     HideStatusIcon(STATUS_ICON_CHAT_INDICATION_ROOM1);
  2186.     HideStatusIcon(STATUS_ICON_CHAT_INDICATION_ROOM2);
  2187.     HideStatusIcon(STATUS_ICON_WAP);
  2188.     HideStatusIcon(STATUS_ICON_NETWORK_CIPHER_GSM);
  2189.     HideStatusIcon(STATUS_ICON_NETWORK_CIPHER_GPRS);
  2190. #ifdef __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__
  2191.     ChangeStatusIconImage(STATUS_ICON_SIGNAL_STRENGTH, IMG_SI_SIGNAL_STRENGTH);
  2192. #else /* __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__ */ 
  2193.     HideStatusIcon(STATUS_ICON_ALTERNATE_LINE_L1);
  2194.     HideStatusIcon(STATUS_ICON_ALTERNATE_LINE_L2);
  2195. #endif /* __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__ */ 
  2196. #ifdef __MMI_POC__
  2197.     HideStatusIcon(STATUS_ICON_POC);
  2198. #endif 
  2199. #ifndef __MMI_BT_MTK_SUPPORT__
  2200. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  2201.     HideStatusIcon(STATUS_ICON_BT);
  2202.     HideStatusIcon(STATUS_ICON_BT_CON);
  2203.     HideStatusIcon(STATUS_ICON_BT_ND);
  2204. #endif /* defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__) */ 
  2205. #endif /* __MMI_BT_MTK_SUPPORT__ */ 
  2206. #ifdef __MMI_IMPS__
  2207.     HideStatusIcon(STATUS_ICON_IMPS_MSG);
  2208.     HideStatusIcon(STATUS_ICON_IMPS_LOGIN);
  2209. #endif /* __MMI_IMPS__ */ 
  2210.     UpdateStatusIcons();
  2211. }
  2212. /*****************************************************************************
  2213.  * FUNCTION
  2214.  *  FirstTimeTurnOnBackLight
  2215.  * DESCRIPTION
  2216.  *  Enter this function once after maui is finished to turn on backlight
  2217.  * PARAMETERS
  2218.  *  void
  2219.  * RETURNS
  2220.  *  void
  2221.  *****************************************************************************/
  2222. void FirstTimeTurnOnBackLight(void)
  2223. {
  2224.     /*----------------------------------------------------------------*/
  2225.     /* Local Variables                                                */
  2226.     /*----------------------------------------------------------------*/
  2227.     static U8 FirstTime = 0;
  2228.     /*----------------------------------------------------------------*/
  2229.     /* Code Body                                                      */
  2230.     /*----------------------------------------------------------------*/
  2231.     if (!FirstTime)
  2232.     {
  2233.         FirstTime = 1;
  2234.         TurnOffBacklight();
  2235.         if (isEarphonePlugged)  /* for earphone indication comming before power on indication */
  2236.         {
  2237.             mmi_profiles_headset_activate_profile();
  2238.             SetModeSpeechVolume();
  2239.         }
  2240.     }
  2241.     else
  2242.     {
  2243.         TurnOnBacklight(1);
  2244.     }
  2245. }
  2246. /*****************************************************************************
  2247.  * FUNCTION
  2248.  *  PowerOnBatteryIndicationCompletePhase2
  2249.  * DESCRIPTION
  2250.  *  Start to process SimQueryFailureRsp or SimPasswdReqResponse
  2251.  * PARAMETERS
  2252.  *  void
  2253.  * RETURNS
  2254.  *  void
  2255.  *****************************************************************************/
  2256. void PowerOnBatteryIndicationCompletePhase2(void)
  2257. {
  2258.     /*----------------------------------------------------------------*/
  2259.     /* Local Variables                                                */
  2260.     /*----------------------------------------------------------------*/
  2261.     /*----------------------------------------------------------------*/
  2262.     /* Code Body                                                      */
  2263.     /*----------------------------------------------------------------*/
  2264. #ifdef MMI_ON_HARDWARE_P
  2265.     FS_SetDiskFlag();
  2266. #endif 
  2267.     if (mmi_bootup_is_sim_failure_received() == MMI_TRUE)   /* if(g_pwr_context.SimQueryFailIndFlag) */
  2268.     {
  2269.         SimQueryFailureRsp(&gSMUFailIndStruct);
  2270.     }
  2271.     else if (mmi_bootup_is_sim_need_security_check() == MMI_TRUE)       /* else if(g_pwr_context.PasswdReqIndFlag) */
  2272.     {
  2273.         SimPasswdReqResponse(&gSMUPwdDataStruct);
  2274.     }
  2275.     else if (mmi_bootup_is_sim_valid() == MMI_TRUE)
  2276.     {
  2277.         ShowWelcomeScr();
  2278.     }
  2279.     /* else */
  2280.     /* diamond, 2006/04/17 Re-entry power on animation */
  2281. }
  2282. /*****************************************************************************
  2283.  * FUNCTION
  2284.  *  PowerOnBatteryIndicationComplete
  2285.  * DESCRIPTION
  2286.  *  Function to be called after power on animatin is completed
  2287.  * PARAMETERS
  2288.  *  void
  2289.  * RETURNS
  2290.  *  void
  2291.  *****************************************************************************/
  2292. void PowerOnBatteryIndicationComplete(void)
  2293. {
  2294.     /*----------------------------------------------------------------*/
  2295.     /* Local Variables                                                */
  2296.     /*----------------------------------------------------------------*/
  2297.     /*----------------------------------------------------------------*/
  2298.     /* Code Body                                                      */
  2299.     /*----------------------------------------------------------------*/
  2300.     /* g_pwr_context.PowerOnAnimationComplete=1; */
  2301.     if (mmi_bootup_is_in_security_check() != MMI_TRUE)
  2302.     {
  2303.         g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_NAND_CHECK;       /* 0x09: NAND check screen */
  2304.     }
  2305. #ifdef __FS_CHECKDRIVE_SUPPORT__
  2306. #ifdef MMI_ON_HARDWARE_P
  2307.     if (FS_CheckDiskFlag() && g_pwr_context.NandIdCheckRes)
  2308. #else 
  2309.     if (1)
  2310. #endif 
  2311.     {
  2312.         if ((SanityCheckDone == 0) || (SanityCheckDone == 3))
  2313.         {
  2314.             if (IsScreenPresent(SCR_NAND_CHECK_PROCESSING))
  2315.             {
  2316.                 GoBackToHistory(SCR_NAND_CHECK_PROCESSING);
  2317.             }
  2318.             else if (IsScreenPresent(SCR_NAND_FLASH_CHECK))
  2319.             {
  2320.                 GoBackToHistory(SCR_NAND_FLASH_CHECK);
  2321.             }
  2322.             else
  2323.             {
  2324.                 PWR_NAND_SanityCheckDisplay();
  2325.             }
  2326.             return; /* wait for PRT_MMI_FMGR_CHECK_DRIVE_RSP */
  2327.         }
  2328.     }
  2329.     else
  2330.     {
  2331.         SanityCheckDone = 2;
  2332.     }
  2333. #endif /* __FS_CHECKDRIVE_SUPPORT__ */ 
  2334.     mmi_bootup_exit_nand_check_query();
  2335. }
  2336. /*****************************************************************************
  2337.  * FUNCTION
  2338.  *  BatteryCheckAfterPowerOnAnimation
  2339.  * DESCRIPTION
  2340.  *  Battrey status check function
  2341.  * PARAMETERS
  2342.  *  void
  2343.  * RETURNS
  2344.  *  void
  2345.  *****************************************************************************/
  2346. void BatteryCheckAfterPowerOnAnimation(void)
  2347. {
  2348.     /*----------------------------------------------------------------*/
  2349.     /* Local Variables                                                */
  2350.     /*----------------------------------------------------------------*/
  2351.     /*----------------------------------------------------------------*/
  2352.     /* Code Body                                                      */
  2353.     /*----------------------------------------------------------------*/
  2354.     /* Low battery warning */
  2355.     if (g_charbat_context.chargerLevel == BATTERY_LOW_TX_PROHIBIT ||
  2356.         g_charbat_context.chargerLevel == BATTERY_LOW_WARNING)
  2357.     {
  2358.         g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_LOW_BATTERY;      /* 0x08: Power on animation complete */
  2359.         EntryNewScreen(SCR_CHARGER_POPUP, ExitLowBatteryScrAtPowerOn, NULL, NULL);
  2360.         ClearKeyEvents();
  2361.         ShowCategory64Screen(STR_LOW_BATTERY, IMG_GLOBAL_WARNING, 0);
  2362.         /* StartTimer(LOW_BATTERY_SCR_TIMER,LOW_BATTERY_SCR_TIMEOUT, PowerOnBatteryIndicationComplete ); */
  2363.         StartTimer(LOW_BATTERY_SCR_TIMER, LOW_BATTERY_SCR_TIMEOUT, mmi_bootup_exit_low_battery_warning);
  2364.     }
  2365.     else
  2366.     {
  2367.         mmi_bootup_exit_low_battery_warning();
  2368.     }
  2369. }
  2370. /*****************************************************************************
  2371.  * FUNCTION
  2372.  *  CallBackPowerOnAnimationComplete
  2373.  * DESCRIPTION
  2374.  *  Callback function when power on animation is completed
  2375.  * PARAMETERS
  2376.  *  ret     [IN]        
  2377.  * RETURNS
  2378.  *  void
  2379.  *****************************************************************************/
  2380. void CallBackPowerOnAnimationComplete(GDI_RESULT ret)
  2381. {
  2382.     /*----------------------------------------------------------------*/
  2383.     /* Local Variables                                                */
  2384.     /*----------------------------------------------------------------*/
  2385.     /*----------------------------------------------------------------*/
  2386.     /* Code Body                                                      */
  2387.     /*----------------------------------------------------------------*/
  2388.     /* power on sequence after animation: */
  2389.     /* animation stop -> CallBackPowerOnAnimationComplete -> PowerOnBatteryIndicationComplete -> */
  2390.     /* (nand check) -> PowerOnBatteryIndicationCompletePhase2 -> (security check) */
  2391.     /* Low battery shutdown */
  2392.     if (((g_charbat_context.batteryStatus == PMIC_VBAT_STATUS || g_charbat_context.batteryStatus == PMIC_CHARGER_OUT) && g_charbat_context.isChargerConnected == 0)     /* Battery Status */
  2393.         && (g_charbat_context.chargerLevel == BATTERY_LOW_POWEROFF) /* Battery Level */ )
  2394.     {
  2395.         ShowLowPowerShutdownScr();
  2396.         return;
  2397.     }
  2398.     if (ret < 0 || ret == GDI_IMAGE_IS_STILL_IMAGE)
  2399.     {
  2400.         /* Broken animation image - force enter */
  2401.         mmi_bootup_exit_low_battery_warning();
  2402.         return;
  2403.     }
  2404.     /* SIM ready/fail indication has been arrival */
  2405.     /* if( g_pwr_context.PasswdReqIndFlag || g_pwr_context.SimQueryFailIndFlag ) */
  2406.     if (g_pwr_context.PowerOnMMIStatus > 0x04)
  2407.     {
  2408.     #ifdef __MMI_TOUCH_SCREEN__
  2409.         /* 
  2410.          * Pen calibration is invoked between power-on animation and mmi_bootup_exit_animation()
  2411.          *
  2412.          * 1. On production line, LCD might not be connected and it's impossible to complete pen calibration.
  2413.          *    However, we may need to use ATD command to test RF hardware. If we invoke pen calibration 
  2414.          *    before poweron animation, network is not ready at the time and ATD command never succeeds, 
  2415.          *    it causes problem in hardware testing.
  2416.          * 
  2417.          * 2. If we invoke pen calibration at idle screen, we cannot use pen to input PIN code, etc.
  2418.          *
  2419.          * As a result, pen calibration is invoked immediately after power-on animation.
  2420.          */
  2421.         if (PhnsetNeedFactoryDefaultCalibration())
  2422.         {
  2423.             /* Although we have not reached idle screen, but it still sends MSG_ID_MMI_READY_NOTIFY_REQ to L4
  2424.                to allow ATD command in the first-time boot after flash download. */
  2425.             mmi_idle_notify_bootup_ready_to_l4c();
  2426.             
  2427.             EntryPhnseFactoryDefaultCalibrationScr(mmi_bootup_exit_animation);
  2428.         }
  2429.         else
  2430.         {
  2431.             mmi_bootup_exit_animation();
  2432.         }
  2433.     #else /* __MMI_TOUCH_SCREEN__ */
  2434.         mmi_bootup_exit_animation();
  2435.     #endif /* __MMI_TOUCH_SCREEN__ */
  2436.     }
  2437. }
  2438. /*****************************************************************************
  2439.  * FUNCTION
  2440.  *  ExitLowBatteryScrAtPowerOn
  2441.  * DESCRIPTION
  2442.  *  Exit Low battery screen when it appears just after power on animation
  2443.  * PARAMETERS
  2444.  *  void
  2445.  * RETURNS
  2446.  *  void
  2447.  *****************************************************************************/
  2448. void ExitLowBatteryScrAtPowerOn(void)
  2449. {
  2450.     /*----------------------------------------------------------------*/
  2451.     /* Local Variables                                                */
  2452.     /*----------------------------------------------------------------*/
  2453.     /*----------------------------------------------------------------*/
  2454.     /* Code Body                                                      */
  2455.     /*----------------------------------------------------------------*/
  2456.     GenericExitScreen(SCR_CHARGER_POPUP, mmi_bootup_exit_low_battery_warning);
  2457.     StopTimer(LOW_BATTERY_SCR_TIMER);
  2458. }
  2459. /*****************************************************************************
  2460.  * FUNCTION
  2461.  *  EntryScrInvalidPINPUKPLOCKLength
  2462.  * DESCRIPTION
  2463.  *  
  2464.  * PARAMETERS
  2465.  *  void
  2466.  * RETURNS
  2467.  *  void
  2468.  *****************************************************************************/
  2469. void EntryScrInvalidPINPUKPLOCKLength(void) /* referred by personalization.c */
  2470. {
  2471.     /*----------------------------------------------------------------*/
  2472.     /* Local Variables                                                */
  2473.     /*----------------------------------------------------------------*/
  2474.     /*----------------------------------------------------------------*/
  2475.     /* Code Body                                                      */
  2476.     /*----------------------------------------------------------------*/
  2477.     DisplayPopup(
  2478.         (U8*) GetString(STR_INVALID_PINPUKPLOCK_LENGTH_RUNNING_TEXT),
  2479.         IMG_GLOBAL_WARNING,
  2480.         0,
  2481.         2000,
  2482.         (U8) ERROR_TONE);
  2483. }
  2484. /**************************************************************************
  2485.    Insert SIM keypad lock APIs:
  2486.       void InsertSimRSKPressOnScreenSaver(void)
  2487.       void InsertSimSetKeyPadLockFlag(void)
  2488. **************************************************************************/
  2489. /*****************************************************************************
  2490.  * FUNCTION
  2491.  *  InsertSimRSKPressOnScreenSaver
  2492.  * DESCRIPTION
  2493.  *  Handle RSK pressed in keypad locked insert SIM screen
  2494.  * PARAMETERS
  2495.  *  void
  2496.  * RETURNS
  2497.  *  void
  2498.  *****************************************************************************/
  2499. void InsertSimRSKPressOnScreenSaver(void)
  2500. {
  2501.     /*----------------------------------------------------------------*/
  2502.     /* Local Variables                                                */
  2503.     /*----------------------------------------------------------------*/
  2504.     /*----------------------------------------------------------------*/
  2505.     /* Code Body                                                      */
  2506.     /*----------------------------------------------------------------*/
  2507.     g_idle_context.IsRSKPressOnScreenSaver = 1;
  2508.     if (IsScreenPresent(SCR_SIM_BLOCK) || GetActiveScreenId() == SCR_SIM_BLOCK)
  2509.     {
  2510.         EntryScrnSimBlockRsp();
  2511.     }
  2512.     else
  2513.     {
  2514.         EntryScrnSimErrorScreen();
  2515.     }
  2516. }
  2517. /*****************************************************************************
  2518.  * FUNCTION
  2519.  *  InsertSimSetKeyPadLockFlag
  2520.  * DESCRIPTION
  2521.  *  Timeout to lock keypad in insert SIM screen
  2522.  * PARAMETERS
  2523.  *  void
  2524.  * RETURNS
  2525.  *  void
  2526.  *****************************************************************************/
  2527.  //KP Jerry add on 2007-4-10 start
  2528. #if defined(__MMI_PEN_BLOCK_WHEN_KAYPAD_LOCKED__)
  2529. extern BOOL GetLCDSleepStatus(void);
  2530. #endif
  2531. //KP Jerry add on 2007-4-10 end
  2532. void InsertSimSetKeyPadLockFlag(void)
  2533. {
  2534.     /*----------------------------------------------------------------*/
  2535.     /* Local Variables                                                */
  2536.     /*----------------------------------------------------------------*/
  2537.     /*----------------------------------------------------------------*/
  2538.     /* Code Body                                                      */
  2539.     /*----------------------------------------------------------------*/
  2540.     g_keylock_context.gKeyPadLockFlag = 1;
  2541. #if 0   /* diamond, 2006/03/07 Not necessary to block pen here because pen is blocked in EntryIdleScreen */
  2542. #ifdef __MMI_TOUCH_SCREEN__
  2543. /* under construction !*/
  2544. #endif
  2545. #endif /* 0 */ 
  2546. #ifdef __MMI_KEYPADLOCK_WITH_KEYTONE__
  2547. #else 
  2548.     mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_DISABLED);
  2549. #endif 
  2550.     if (IsScreenPresent(SCR_SIM_BLOCK) || GetActiveScreenId() == SCR_SIM_BLOCK)
  2551.     {
  2552.         EntryScrnSimBlockRsp();
  2553.     }
  2554.     else
  2555.     {
  2556.         EntryScrnSimErrorScreen();
  2557.     }
  2558. #if defined(__MMI_TOUCH_SCREEN__) && (!defined(__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__) || defined(__MMI_SLIDE__)) //KP Jerry add "!defined(__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__)" on 2007-3-26
  2559.     SetKeyHandler(InsertSimRSKPressOnScreenSaver, KEY_SEND, KEY_EVENT_DOWN);
  2560. #else /* __MMI_TOUCH_SCREEN__ && !__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__ */ //KP Jerry add "!__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__" on 2007-3-26 
  2561. #if defined(__MMI_KEYPAD_LOCK_PATTERN_1__) || defined(__MMI_KEYPAD_LOCK_PATTERN_3__) || defined(__MMI_KEYPAD_LOCK_PATTERN_4__)    //KP Jerry add "__MMI_KEYPAD_LOCK_PATTERN_3__" on 2007-3-26      /* Robin 1223 */
  2562.     SetRightSoftkeyFunction(InsertSimRSKPressOnScreenSaver, KEY_EVENT_DOWN);
  2563. #endif 
  2564. #ifdef __MMI_KEYPAD_LOCK_PATTERN_2__    /* Robin 1223 */
  2565.     SetLeftSoftkeyFunction(InsertSimRSKPressOnScreenSaver, KEY_EVENT_DOWN);
  2566. #endif 
  2567. #endif /* __MMI_TOUCH_SCREEN__ && !__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__ */ //KP Jerry add "!__MMI_TOUCH_SCREEN_WITH_NUMERIC_KEY__" on 2007-3-26 
  2568. #ifdef __MMI_TOUCH_SCREEN__
  2569.     ChangeStatusIconImage(STATUS_ICON_KEYPAD_LOCK, IMG_SI_KEYPAD_LOCK);
  2570.     UpdateStatusIcons();
  2571. #else /* __MMI_TOUCH_SCREEN__ */ 
  2572.     IdleSetStatusIcon(STATUS_ICON_KEYPAD_LOCK);
  2573. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2574.     StopTimer(IDLE_APP_AUTO_LOCK_TIMER_ID);
  2575. //KP Jerry add on 2007-4-10 start
  2576. #if defined(__MMI_PEN_BLOCK_WHEN_KAYPAD_LOCKED__)
  2577.     if(GetLCDSleepStatus())
  2578.     {
  2579.         //touch_panel_enable(KAL_FALSE);
  2580.         //touch_panel_flush();        
  2581.         //mmi_pen_forced_block();      
  2582.     }
  2583. #endif
  2584. //KP Jerry add on 2007-4-10 end
  2585. }
  2586. #ifdef __MMI_SIMAP_SUPPORT__
  2587. /*****************************************************************************
  2588.  * FUNCTION
  2589.  *  mmi_sim_error_update_sim_access_profile_menu_items
  2590.  * DESCRIPTION
  2591.  *  
  2592.  * PARAMETERS
  2593.  *  void
  2594.  * RETURNS
  2595.  *  void
  2596.  *****************************************************************************/
  2597. void mmi_sim_error_update_sim_access_profile_menu_items(void)
  2598. {
  2599.     /*----------------------------------------------------------------*/
  2600.     /* Local Variables                                                */
  2601.     /*----------------------------------------------------------------*/
  2602.     /*----------------------------------------------------------------*/
  2603.     /* Code Body                                                      */
  2604.     /*----------------------------------------------------------------*/
  2605.     mmi_frm_hide_menu_item(MENU_IDLE_SCR_DISP);          /* Hide "Display Characteristic" in No SIM screen */
  2606.     mmi_frm_hide_menu_item(MENU9146_WELCOME_TEXT);       /* Hide "Greeting Text" in No SIM screen */
  2607.     mmi_frm_hide_menu_item(MENU_SETTING_DEDICATED_KEYS); /* Hide "Dedicated key" in No SIM screen */
  2608. #ifdef __MMI_NITZ__
  2609.     mmi_frm_hide_menu_item(MENU9145_SETTIMEANDDATENITZ); /* Hide "Auto update of date and time" in No SIM screen */
  2610.     mmi_frm_hide_menu_item(MENU_SETTING_MENU_TREE);
  2611. #endif /* __MMI_NITZ__ */ 
  2612.     mmi_frm_hide_menu_item(MENU9169_SIM_LOCK);           /* Hide "SIM Lock" in No SIM screen */
  2613.     mmi_frm_hide_menu_item(MENU9167_FIXED_DIAL);         /* Hide "Fixed Dial" in No SIM screen */
  2614.     mmi_frm_hide_menu_item(MENU9168_BARRED_DAIL);        /* Hide "Barred Dail" in No SIM screen */
  2615.     mmi_frm_hide_menu_item(MENU9174_CP_PIN1);            /* Hide "Change Password/PIN1" in No SIM screen */
  2616.     mmi_frm_hide_menu_item(MENU9175_CP_PIN2);            /* Hide "Change Password/PIN2" in No SIM screen */
  2617.     mmi_frm_hide_menu_item(MENU_SETTING_SPEED_DIAL);     /* Hide "Speed Dial" in No SIM screen */
  2618. #ifdef __MMI_WLAN_FEATURES__
  2619.     mmi_frm_hide_menu_item(MENU9186_SELECTION_MODE);
  2620.     mmi_frm_hide_menu_item(MENU9189_GPRS_CONNECTION_MODE);
  2621. #if defined(__GSM_RAT__) && defined(__WCDMA_RAT__)
  2622.     mmi_frm_hide_menu_item(MENU_ID_NETSET_SERVICE_SELECTION);
  2623.     mmi_frm_hide_menu_item(MENU_ID_NETSET_NETWORK_INFO);
  2624. #endif
  2625. #ifdef __MMI_USER_CTRL_PLMN_SUPPORT__
  2626.     mmi_frm_hide_menu_item(MENU_ID_NETSET_USER_CTRL_PLMN);
  2627. #endif
  2628.     mmi_frm_hide_menu_item(MESSAGES_MENU_SMS_MENUID);      /* SMS */
  2629.     mmi_frm_hide_menu_item(MESSAGES_MENU_MMS_MENUID);      /* MMS */
  2630.     mmi_frm_hide_menu_item(MENU_CHATAPP_ID);               /* Chat */
  2631.     mmi_frm_hide_menu_item(MESSAGES_MENU_VMAIL_MENUID);    /* Voice Mail */
  2632.     mmi_frm_hide_menu_item(MESSAGES_MENU_CB_MENUID);       /* Cell Broadcast */
  2633.     mmi_frm_hide_menu_item(MENU_ID_UM_MAIN);               /* Unified Message */
  2634.     mmi_frm_hide_menu_item(MENU_CALL_TIME_SETUP);          /* Call Time */
  2635.     mmi_frm_hide_menu_item(MENU_CALL_HISTORY_CALLCOST);    /* Call Cost */
  2636.     mmi_frm_hide_menu_item(MENU_CALL_HISTORY_SMSCOUNTER);  /* SMS Counter */
  2637.     mmi_frm_hide_menu_item(MENU_CALL_HISTORY_GPRSCOUNTER); /* GPRS Counter */
  2638.     mmi_frm_hide_menu_item(MENU8237_SCR8093_MNGCALL_MENU_MAIN);
  2639. #endif /* __MMI_WLAN_FEATURES__ */
  2640.     PhnsetFlightModeSaveStatusIconFlags();
  2641.     RemoveStatusIconsForSimRemoved();
  2642.     UpdateStatusIcons();
  2643. }
  2644. /*****************************************************************************
  2645.  * FUNCTION
  2646.  *  mmi_sim_error_restore_sim_access_profile_menu_items
  2647.  * DESCRIPTION
  2648.  *  
  2649.  * PARAMETERS
  2650.  *  void
  2651.  * RETURNS
  2652.  *  void
  2653.  *****************************************************************************/
  2654. void mmi_sim_error_restore_sim_access_profile_menu_items(void)
  2655. {
  2656.     /*----------------------------------------------------------------*/
  2657.     /* Local Variables                                                */
  2658.     /*----------------------------------------------------------------*/
  2659.     /*----------------------------------------------------------------*/
  2660.     /* Code Body                                                      */
  2661.     /*----------------------------------------------------------------*/
  2662.     mmi_frm_unhide_menu_item(MENU_IDLE_SCR_DISP);          /* Hide "Display Characteristic" in No SIM screen */
  2663.     mmi_frm_unhide_menu_item(MENU9146_WELCOME_TEXT);       /* Hide "Greeting Text" in No SIM screen */
  2664.     mmi_frm_unhide_menu_item(MENU_SETTING_DEDICATED_KEYS); /* Hide "Dedicated key" in No SIM screen */
  2665. #ifdef __MMI_NITZ__
  2666.     mmi_frm_unhide_menu_item(MENU9145_SETTIMEANDDATENITZ); /* Hide "Auto update of date and time" in No SIM screen */
  2667.     mmi_frm_unhide_menu_item(MENU_SETTING_MENU_TREE);
  2668. #endif /* __MMI_NITZ__ */ 
  2669.     mmi_frm_unhide_menu_item(MENU9169_SIM_LOCK);           /* Hide "SIM Lock" in No SIM screen */
  2670.     mmi_frm_unhide_menu_item(MENU9167_FIXED_DIAL);         /* Hide "Fixed Dial" in No SIM screen */
  2671.     mmi_frm_unhide_menu_item(MENU9168_BARRED_DAIL);        /* Hide "Barred Dail" in No SIM screen */
  2672.     mmi_frm_unhide_menu_item(MENU9174_CP_PIN1);            /* Hide "Change Password/PIN1" in No SIM screen */
  2673.     mmi_frm_unhide_menu_item(MENU9175_CP_PIN2);            /* Hide "Change Password/PIN2" in No SIM screen */
  2674.     mmi_frm_unhide_menu_item(MENU_SETTING_SPEED_DIAL);     /* Hide "Speed Dial" in No SIM screen */
  2675. #ifdef __MMI_WLAN_FEATURES__
  2676.     mmi_frm_unhide_menu_item(MENU9186_SELECTION_MODE);
  2677.     mmi_frm_unhide_menu_item(MENU9189_GPRS_CONNECTION_MODE);
  2678. #if defined(__GSM_RAT__) && defined(__WCDMA_RAT__)
  2679.     mmi_frm_unhide_menu_item(MENU_ID_NETSET_SERVICE_SELECTION);
  2680.     mmi_frm_unhide_menu_item(MENU_ID_NETSET_NETWORK_INFO);
  2681. #endif
  2682. #ifdef __MMI_USER_CTRL_PLMN_SUPPORT__
  2683.     mmi_frm_unhide_menu_item(MENU_ID_NETSET_USER_CTRL_PLMN);
  2684. #endif
  2685.     mmi_frm_unhide_menu_item(MESSAGES_MENU_SMS_MENUID);      /* SMS */
  2686.     mmi_frm_unhide_menu_item(MESSAGES_MENU_MMS_MENUID);      /* MMS */
  2687.     mmi_frm_unhide_menu_item(MENU_CHATAPP_ID);               /* Chat */
  2688.     mmi_frm_unhide_menu_item(MESSAGES_MENU_VMAIL_MENUID);    /* Voice Mail */
  2689.     mmi_frm_unhide_menu_item(MESSAGES_MENU_CB_MENUID);       /* Cell Broadcast */
  2690.     mmi_frm_unhide_menu_item(MENU_ID_UM_MAIN);               /* Unified Message */
  2691.     mmi_frm_unhide_menu_item(MENU_CALL_TIME_SETUP);          /* Call Time */
  2692.     mmi_frm_unhide_menu_item(MENU_CALL_HISTORY_CALLCOST);    /* Call Cost */
  2693.     mmi_frm_unhide_menu_item(MENU_CALL_HISTORY_SMSCOUNTER);  /* SMS Counter */
  2694.     mmi_frm_unhide_menu_item(MENU_CALL_HISTORY_GPRSCOUNTER); /* GPRS Counter */
  2695.     mmi_frm_unhide_menu_item(MENU8237_SCR8093_MNGCALL_MENU_MAIN);
  2696. #endif /* __MMI_WLAN_FEATURES__ */
  2697.     PhnsetFlightModeRestoreStatusIconFlags();
  2698.     UpdateStatusIcons();
  2699. }
  2700. #endif /* __MMI_SIMAP_SUPPORT__ */