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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  *  NetworkFunctions.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  MAUI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  
  47.  *
  48.  * Author:
  49.  * -------
  50.  *  
  51.  *
  52.  *==============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  * removed!
  143.  * removed!
  144.  * removed!
  145.  *
  146.  * removed!
  147.  * removed!
  148.  * removed!
  149.  *
  150.  * removed!
  151.  * removed!
  152.  * removed!
  153.  *
  154.  * removed!
  155.  * removed!
  156.  * removed!
  157.  *
  158.  * removed!
  159.  * removed!
  160.  * removed!
  161.  *
  162.  * removed!
  163.  * removed!
  164.  * removed!
  165.  *
  166.  * removed!
  167.  * removed!
  168.  * removed!
  169.  *
  170.  * removed!
  171.  * removed!
  172.  * removed!
  173.  *
  174.  * removed!
  175.  * removed!
  176.  * removed!
  177.  *
  178.  * removed!
  179.  * removed!
  180.  * removed!
  181.  *
  182.  * removed!
  183.  * removed!
  184.  * removed!
  185.  *
  186.  * removed!
  187.  * removed!
  188.  * removed!
  189.  *
  190.  * removed!
  191.  * removed!
  192.  * removed!
  193.  *
  194.  *------------------------------------------------------------------------------
  195.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  196.  *==============================================================================
  197.  *******************************************************************************/
  198. #include "MMI_features.h"       /* Robin 1217 */
  199. #include "StdC.h"
  200. #include "L4Dr1.h"
  201. #include "MiscFunctions.h"
  202. #include "CustDataRes.h"
  203. #include "ProtocolEvents.h"
  204. #include "TimerEvents.h"
  205. #include "SimDetectionGprot.h"
  206. #include "SimDetectionDef.h"
  207. #include "PixtelDataTypes.h"
  208. #include "SimDetectionGexdcl.h"
  209. #include "EventsDcl.h"
  210. #include "QueueGProt.h"
  211. #include "Unicodexdcl.h"
  212. #include "ProtocolEvents.h"
  213. #include "DebugInitDef.h"
  214. #include "UCS2prot.h"
  215. #include "TaskInit.h"
  216. #include "wgui_status_icons.h"
  217. #include "Globaldefs.h"
  218. #include "IdleAppDef.h"
  219. #include "ProfileGprots.h"
  220. #include "gpioInc.h"
  221. #include "KeyBrd.h"
  222. #include "bootup.h"
  223. #include "IdleAppProt.h"
  224. #include "SimDetectionHwMapFile.h"
  225. #include "NetworkSetupGProt.h"
  226. #include "NetworkSetupDefs.h"
  227. #include "CustResDef.h"
  228. #include "SettingDefs.h"
  229. #include "SettingsGdcl.h"
  230. #include "PhoneSetupGprots.h"
  231. #include "CallManagementGprot.h"
  232. #ifdef _NETWORK_CIPHER_SUPPORT_
  233. #include "mm_mmi_enums.h"
  234. #endif 
  235. #ifdef __MMI_IMPS__
  236. #include "mmi_imps_gprot.h"
  237. #endif 
  238. #ifdef __MMI_POC__
  239. #include "PoCGProt.h"
  240. #endif 
  241. #ifdef __HOMEZONE_SUPPORT__
  242. #include "GSM7BitDefaultAlphabet.h"
  243. #endif 
  244. #ifdef WAP_SUPPORT
  245. #include "wap_ps_struct.h"
  246. #include "wapadp.h"
  247. #endif /* WAP_SUPPORT */
  248. extern void refresh_status_icon_display(void);  /* in Wgui_status_icons.c */
  249. extern void BatteryStatusRsp(void *);           /* in PwronCharger.c */
  250. #ifdef MMS_SUPPORT
  251. extern void wap_plmn_number_indication_callback(const U8 *curPLMN);
  252. #endif
  253. #if ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) )
  254. extern void eons_get_opn_file_info_req(void);
  255. extern void eons_get_pnn_record_req(U8);
  256. extern void eons_read_opn_from_nvram(void);
  257. extern U8 eons_check_if_plmn_present(U8 *);
  258. extern kal_bool is_sim_replaced(void);
  259. #endif /* ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) ) */ 
  260. extern S8 gHomePLMNNum[MAX_PLMN_LEN_MMI + 1];
  261. U8 gGPRSStatusModified = 0;
  262. U8 gSignalStrengthLevel = 0;
  263. U8 gNWProviderName[MAX_LENGTH_DISPLAY_NAME * ENCODING_LENGTH];
  264. U8 gPLMN[MAX_PLMN_LEN_MMI + 1];
  265. U8 lastNwStatus = MMI_RAC_LIMITED_SERVICE;
  266. U8 lastPLMN[MAX_PLMN_LEN_MMI + 1];
  267. #ifdef __HOMEZONE_SUPPORT__
  268. U8 *gHomezoneText = NULL;
  269. #endif 
  270. /*****************************************************************************
  271.  * FUNCTION
  272.  *  InitNetWorkBootUpEventsCallBack
  273.  * DESCRIPTION
  274.  *  This function initializes all network related protocol handlers
  275.  * PARAMETERS
  276.  *  void
  277.  * RETURNS
  278.  *  void
  279.  *****************************************************************************/
  280. void InitNetWorkBootUpEventsCallBack(void)
  281. {
  282.     /*----------------------------------------------------------------*/
  283.     /* Local Variables                                                */
  284.     /*----------------------------------------------------------------*/
  285.     /*----------------------------------------------------------------*/
  286.     /* Code Body                                                      */
  287.     /*----------------------------------------------------------------*/
  288.     SetProtocolEventHandler(NetWorkAttachedIndication, PRT_NW_ATTACH_IND);
  289.     SetProtocolEventHandler(NetWorkSignalLevelIndication, PRT_NW_RX_LEVEL_IND);
  290.     SetProtocolEventHandler(NetWorkServiceTypeIndication, PRT_SERVICE_TYPE_IND);
  291.     SetProtocolEventHandler(NumberOfPLMNSuported, PRT_PLMN_LIST_IND);
  292.     SetProtocolEventHandler(RspToTestRoamingEnabled, PRT_GET_IMSI_RSP);
  293.     SetProtocolEventHandler(BatteryStatusRsp, PRT_BATTERY_STATUS_IND);  /* not in this file */
  294. #ifdef _NETWORK_CIPHER_SUPPORT_
  295.     SetProtocolEventHandler(NetWorkCipherIndication, PRT_MMI_SMU_CIPHER_IND);
  296. #endif 
  297. #ifdef __MANUAL_MODE_NW_SEL__
  298.     SetProtocolEventHandler(PLMNSelectionModeIndication, MSG_ID_MMI_NW_SEL_MODE_IND);
  299. #endif 
  300. #ifdef __MMI_GPRS_FEATURES__
  301.     SetProtocolEventHandler(GPRSStatusUpdateIndication, PRT_MMI_PS_GPRS_STATUS_UPDATE_IND);
  302. #endif 
  303. #ifdef __HOMEZONE_SUPPORT__
  304.     SetProtocolEventHandler(HomezoneStatusIndication, PRT_MMI_HZ_TAG_IND);
  305. #endif 
  306.     memset(gPLMN, 0, MAX_PLMN_LEN_MMI + 1);
  307. }
  308. /**************************************************************************
  309.          API of Network Attachment
  310. **************************************************************************/
  311. /*****************************************************************************
  312.  * FUNCTION
  313.  *  NetWorkAttachedIndication
  314.  * DESCRIPTION
  315.  *  This function is a call back for MSG_ID_MMI_NW_ATTACH_IND
  316.  * PARAMETERS
  317.  *  inMsg       [?]     
  318.  *  void*(?)
  319.  * RETURNS
  320.  *  void
  321.  *****************************************************************************/
  322. void NetworkErrorHandle(void);
  323. void RefreshNwProviderName(U8 *UpdatePlmn);
  324. void NetWorkAttachedIndication(void *inMsg)
  325. {
  326.     /*----------------------------------------------------------------*/
  327.     /* Local Variables                                                */
  328.     /*----------------------------------------------------------------*/
  329.     S8 plmn_prompt[30]; /* Value is hardcoded as temporarly used */
  330.     S8 current_oper[MAX_PLMN_LEN_MMI + 1];
  331.     MMINWATTACHIND *local_data = (mmi_nw_attach_ind_struct*) inMsg;
  332.     /*----------------------------------------------------------------*/
  333.     /* Code Body                                                      */
  334.     /*----------------------------------------------------------------*/
  335.     PRINT_INFORMATION(("MSG_ID_MMI_NW_ATTACH_INDICATION"));
  336.     if (local_data->status == MMI_RAC_SEARCHING)
  337.     {
  338.         return; /* do nothing because L4 is searching network */
  339.     }
  340.     /* micha0120 */
  341.     UpdateGPRSStatusIcon(local_data->gprs_status);
  342.     /* micha0317 */
  343.     if (pfnUnicodeStrcmp((PS8) gNWProviderName, (PS8) GetString(STR_ID_NETSET_SEARCHIN_NW)) == 0 ||
  344.         local_data->status != lastNwStatus || memcmp(local_data->plmn, lastPLMN, MAX_PLMN_LEN_MMI))
  345.     {
  346.         gGPRSStatusModified = 1;
  347.     }
  348.     /* diamond, 2006/06/01 Not reset gNWProviderName here to prevent from unable to get EONS PNN file */
  349. #if ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) )
  350.     if (eons_check_if_plmn_present(gPLMN) == 0)
  351. #endif 
  352.         memset(gNWProviderName, 0, MAX_LENGTH_DISPLAY_NAME * ENCODING_LENGTH);
  353.     switch (local_data->status) /* l4c_rac_response_enum */
  354.     {
  355.         case MMI_RAC_OK:    /* normal service */
  356.             /* Required for othe applications to indicate them full service */
  357.             g_pwr_context.CurrentServiceType = FULL_SERVICE;
  358.             ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  359.             ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  360.             /* Stop searching screen */
  361.             /* g_pwr_context.NetWorkFlag = 1; */
  362.             g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_NETWORK_FLAG;        /* 0x01: receive network attachment */
  363.             memset(current_oper, '', sizeof(current_oper));
  364.             memcpy(current_oper, local_data->plmn, MAX_PLMN_LEN_MMI);
  365.             sprintf(plmn_prompt, "PLMN %s", current_oper);
  366.             PRINT_INFORMATION((plmn_prompt));
  367.             /* Copy plmn to global variable to be checked later for displaying roaming signals */
  368.             /* memcpy(gPLMN,local_data->plmn,MAX_PLMN_LEN_MMI); */
  369.             strcpy((S8*) gPLMN, (S8*) local_data->plmn);    /* local_data->plmn is a null-terminated string */
  370.             RefreshNwProviderName(gPLMN);
  371.             /* Send message to check Roaming enabled or not signal */
  372.             if (g_pwr_context.testRoaming == 3) /* Robin 1202, means already get IMSI */
  373.             {
  374.                 /* diamond, 2005/09/26 support PNN and OPL */
  375.             #if ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) )
  376.                 if (eons_check_if_plmn_present(gPLMN) == 0)
  377.             #endif 
  378.                     ChangeRoamingState();
  379.             }
  380.             else if (g_pwr_context.testRoaming == 1)    /* No body send get IMSI req */
  381.             {
  382.                 RequestToTestRoamingEnabled();
  383.             }
  384.             /* Update last network information */
  385.             lastNwStatus = MMI_RAC_OK;
  386.             /* memcpy(lastPLMN, gPLMN, MAX_PLMN_LEN_MMI); */
  387.             strcpy((S8*) lastPLMN, (S8*) gPLMN);
  388.         #if defined(__GSM_RAT__) && defined(__WCDMA_RAT__) && !defined(__MMI_DUAL_MODE_SELF_TEST__)
  389.             mmi_netset_refresh_rat_icon(local_data->rat); /* set the status icon for RAT */
  390.         #endif
  391.         #ifdef __MMI_IMPS__
  392.             mmi_imps_notify_rac_ready();
  393.         #endif 
  394.         #ifdef __MMI_POC__
  395.             if (mmi_bootup_is_idle_screen_reached() == MMI_TRUE)
  396.             {
  397.                 mmi_poc_poweron_reg();
  398.             }
  399.         #endif /* __MMI_POC__ */ 
  400.             break;
  401.         case MMI_RAC_NO_CELL:   /* no service */
  402.             /* Required for othe applications to indicate them no service */
  403.             g_pwr_context.CurrentServiceType = NO_SERVICE;
  404.             PRINT_INFORMATION(("No Service"));
  405.             IdleResetStatusIcon(STATUS_ICON_ROAMING);
  406.             IdleRefreshServiceIndicationArea();
  407.             /* if(g_pwr_context.idleScreenFirst ) //1211 */
  408.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  409.             {
  410.                 StopLEDPatternNoService();  /* MTK add Robin 1009. Stop LED will trigger the Band led pattern resume mechanism */
  411.             }
  412.             /* Reset the signal level to zero */
  413.             ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, 0);
  414.             ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, 0);
  415.             lastNwStatus = MMI_RAC_NO_CELL;
  416.             if (g_idle_context.IsOnIdleScreen)
  417.             {
  418.                 IdleSetLRKey();
  419.             }
  420.             break;
  421.         case MMI_RAC_LIMITED_SERVICE:   /* limit service */
  422.             /* Required for othe applications to indicate them no service */
  423.             g_pwr_context.CurrentServiceType = LIMITED_SERVICE;
  424.             ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  425.             ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  426.             PRINT_INFORMATION(("Limited Service"));
  427.             IdleResetStatusIcon(STATUS_ICON_ROAMING);
  428.             IdleRefreshServiceIndicationArea();
  429.             /* if(g_pwr_context.idleScreenFirst ) //Robin 1211 */
  430.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  431.             {
  432.                 StopLEDPatternLimitService();   /* MTK add Robin 1009. Stop LED will trigger the Band led pattern resume mechanism */
  433.             }
  434.             lastNwStatus = MMI_RAC_LIMITED_SERVICE;
  435.             if (g_idle_context.IsOnIdleScreen)
  436.             {
  437.                 IdleSetLRKey(); /* Cylen, __MANUAL_MODE_NW_SEL__ */
  438.             }
  439.             break;
  440.         case MMI_RAC_ATTEMPT_TO_UPDATE:
  441.             g_pwr_context.CurrentServiceType = LIMITED_SERVICE;
  442.             IdleResetStatusIcon(STATUS_ICON_ROAMING);
  443.             PRINT_INFORMATION(("Limited Service"));
  444.             IdleRefreshServiceIndicationArea();
  445.             /* if( g_pwr_context.idleScreenFirst ) //Robin 1211 */
  446.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  447.             {
  448.                 StopLEDPatternLimitService();   /* MTK add Robin 1009. Stop LED will trigger the Band led pattern resume mechanism */
  449.             }
  450.             lastNwStatus = MMI_RAC_ATTEMPT_TO_UPDATE;
  451.             if (g_idle_context.IsOnIdleScreen)
  452.             {
  453.                 IdleSetLRKey(); /* Cylen, __MANUAL_MODE_NW_SEL__ */
  454.             }
  455.             break;
  456.         case MMI_RAC_INVALID_SIM:
  457.             /* g_pwr_context.InvalidSim = 1; */
  458.             g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_REG_FAILED;  /* network registration failed */
  459.             g_pwr_context.CurrentServiceType = LIMITED_SERVICE;
  460.             PRINT_INFORMATION(("Limited Service"));
  461.             IdleRefreshServiceIndicationArea();
  462.             /* if( g_pwr_context.idleScreenFirst ) //Robin 1211 */
  463.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  464.             {
  465.                 StopLEDPatternNoService();  /* MTK add Robin 1009. Stop LED will trigger the Band led pattern resume mechanism */
  466.             }
  467.             lastNwStatus = MMI_RAC_INVALID_SIM;
  468.             break;
  469.         case MMI_RAC_ERROR:
  470.             NetworkErrorHandle();
  471.             break;
  472.     }
  473.     /* micha0423 */
  474.     if (gGPRSStatusModified)    /* Robin 1128 Enter idle screen after GET IMSI RSP comming */
  475.     {
  476.         if (g_idle_context.IsOnIdleScreen && g_pwr_context.testRoaming == 3)
  477.         {
  478.         #if ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) )
  479.             if (eons_check_if_plmn_present(gPLMN) == 0)
  480.         #endif 
  481.                 EntryIdleScreen();
  482.         }
  483.         else
  484.         {
  485.             refresh_status_icon_display();
  486.         }
  487.         gGPRSStatusModified = 0;
  488.     }
  489.     if (!g_pwr_context.IsCampOnTonePlayed && g_pwr_context.CurrentServiceType == FULL_SERVICE)  /* Robin 1128 Play camp on tone after enter idle screen */
  490.     {
  491.         if (g_idle_context.IsOnIdleScreen)  /* Lisen 040406 */
  492.         {
  493.             playRequestedTone(CAMP_ON_TONE);
  494.             g_pwr_context.IsCampOnTonePlayed = 1;
  495.         }
  496.     }
  497.     //micha0923, #169    
  498.     //if( g_pwr_context.InvalidSim  && (g_idle_context.IsOnIdleScreen || IsScreenPresent(IDLE_SCREEN_ID)) &&  !g_pwr_context.InvalidSimShowed) 
  499.     if (mmi_bootup_is_nw_registration_ok() == MMI_FALSE &&
  500.         (g_idle_context.IsOnIdleScreen || IsScreenPresent(IDLE_SCREEN_ID)) && !g_pwr_context.InvalidSimShowed)
  501.     {
  502.         g_pwr_context.InvalidSimShowed = 1;
  503.         DisplayInvalidSimInfo();
  504.     }
  505. }
  506. /*****************************************************************************
  507.  * FUNCTION
  508.  *  NetworkErrorHandle
  509.  * DESCRIPTION
  510.  *  Handler for network attachment case MMI_RAC_ERROR
  511.  * PARAMETERS
  512.  *  void
  513.  * RETURNS
  514.  *  void
  515.  *****************************************************************************/
  516. void NetworkErrorHandle(void)
  517. {
  518.     /*----------------------------------------------------------------*/
  519.     /* Local Variables                                                */
  520.     /*----------------------------------------------------------------*/
  521.     /*----------------------------------------------------------------*/
  522.     /* Code Body                                                      */
  523.     /*----------------------------------------------------------------*/
  524.     switch (lastNwStatus)
  525.     {
  526.         case MMI_RAC_OK:
  527.             g_pwr_context.CurrentServiceType = FULL_SERVICE;
  528.             /* memcpy(gPLMN,lastPLMN,MAX_PLMN_LEN_MMI); */
  529.             strcpy((S8*) gPLMN, (S8*) lastPLMN);
  530.             RefreshNwProviderName(gPLMN);
  531.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  532.             {
  533.                 StopLEDPatternNoService();
  534.             }
  535.             break;
  536.         case MMI_RAC_NO_CELL:
  537.             g_pwr_context.CurrentServiceType = NO_SERVICE;
  538.             /* RefreshNwProviderName(gPLMN); */
  539.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  540.             {
  541.                 StopLEDPatternNoService();
  542.             }
  543.             break;
  544.         case MMI_RAC_LIMITED_SERVICE:
  545.             g_pwr_context.CurrentServiceType = LIMITED_SERVICE;
  546.             /* RefreshNwProviderName(gPLMN); */
  547.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  548.             {
  549.                 StopLEDPatternNoService();
  550.             }
  551.             break;
  552.         case MMI_RAC_INVALID_SIM:
  553.             /* g_pwr_context.InvalidSim = 1; */
  554.             g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_REG_FAILED;  /* network registration failed */
  555.             g_pwr_context.CurrentServiceType = LIMITED_SERVICE;
  556.             /* RefreshNwProviderName(gPLMN); */
  557.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  558.             {
  559.                 StopLEDPatternNoService();
  560.             }
  561.             break;
  562.         case MMI_RAC_ATTEMPT_TO_UPDATE:
  563.             g_pwr_context.CurrentServiceType = LIMITED_SERVICE;
  564.             /* RefreshNwProviderName(gPLMN); */
  565.             if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  566.             {
  567.                 StopLEDPatternNoService();  /* MTK add Robin 1009. Stop LED will trigger the Band led pattern resume mechanism */
  568.             }
  569.             break;
  570.         default:
  571.             break;
  572.     }
  573. }
  574. /*****************************************************************************
  575.  * FUNCTION
  576.  *  RefreshNwProviderName
  577.  * DESCRIPTION
  578.  *  Refresh the network provider name
  579.  * PARAMETERS
  580.  *  UpdatePlmn      [?]     
  581.  *  U8*(?)
  582.  * RETURNS
  583.  *  void
  584.  *****************************************************************************/
  585. void RefreshNwProviderName(U8 *UpdatePlmn)
  586. {
  587.     /*----------------------------------------------------------------*/
  588.     /* Local Variables                                                */
  589.     /*----------------------------------------------------------------*/
  590. #if ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) )
  591.     /* diamond, 2005/09/26 support PNN and OPL */
  592.     U8 recordnum = eons_check_if_plmn_present(UpdatePlmn);
  593.     /*----------------------------------------------------------------*/
  594.     /* Code Body                                                      */
  595.     /*----------------------------------------------------------------*/
  596.     if (recordnum)
  597.     {
  598.         eons_get_pnn_record_req(recordnum);
  599.         return;
  600.     }
  601. #endif /* ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) ) */ 
  602.     /* diamond, 2006/03/08 Get plmn string from gPLMN[MAX_PLMN_LEN_MMI+1] */
  603.     mmi_netset_retrieve_opname_from_plmn(UpdatePlmn, gNWProviderName);
  604. }
  605. /*****************************************************************************
  606.  * FUNCTION
  607.  *  NetWorkSignalLevelIndication
  608.  * DESCRIPTION
  609.  *  This function is a call back for PRT_NW_RX_LEVEL_IND, which is used to update signal strenth icon
  610.  * PARAMETERS
  611.  *  inMsg       [?]     
  612.  *  void*(?)
  613.  * RETURNS
  614.  *  void
  615.  *****************************************************************************/
  616. void NetWorkSignalLevelIndication(void *inMsg)
  617. {
  618.     /*----------------------------------------------------------------*/
  619.     /* Local Variables                                                */
  620.     /*----------------------------------------------------------------*/
  621.     MMINWRXLEVELIND *local_data = (MMINWRXLEVELIND*) inMsg;
  622.     /*----------------------------------------------------------------*/
  623.     /* Code Body                                                      */
  624.     /*----------------------------------------------------------------*/
  625.     PRINT_INFORMATION(("Inside NetWorkSignalLevelIndication "));
  626.     g_pwr_context.CurrentCampOnBand = local_data->current_band; /* LED display for different band */
  627.     /* MTK Modified, 030917, Robin, For Signal strength */
  628.     if (local_data->level == SIGNAL_STRENGTH_INVAILD)
  629.     {
  630.         PRINT_INFORMATION(("Invalid Signal Indication"));
  631.     }
  632.     else if (local_data->level == SIGNAL_STRENGTH_NONE)
  633.     {
  634.         PRINT_INFORMATION(("No Signal Indication"));
  635.         gSignalStrengthLevel = 0;
  636.     }
  637.     else if (local_data->level < SIGNAL_STRENGTH_LEVEL1)    /* Robin 1116 */
  638.     {
  639.         PRINT_INFORMATION(("No Signal Indication"));
  640.         gSignalStrengthLevel = 0;
  641.     }
  642. //KP Jerry modify on 2007-3-23 start
  643. #if(defined(__MMI_SIGNAL_STRENGTH_NUM__) && (__MMI_SIGNAL_STRENGTH_NUM__==5))
  644.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL1) && (local_data->level < SIGNAL_STRENGTH_LEVEL2))
  645.     {
  646.         PRINT_INFORMATION(("Show only one bar shaded "));
  647. gSignalStrengthLevel = 20;    
  648.     }
  649.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL2) && (local_data->level < SIGNAL_STRENGTH_LEVEL3))
  650.     {
  651.         PRINT_INFORMATION(("Show two  bar shaded "));
  652. gSignalStrengthLevel = 40;    
  653.     }
  654.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL3) && (local_data->level < SIGNAL_STRENGTH_LEVEL4))
  655.     {
  656.         PRINT_INFORMATION(("Show three  bar shaded "));
  657. gSignalStrengthLevel = 60;     
  658.     }
  659.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL4) && (local_data->level < SIGNAL_STRENGTH_LEVEL5))    
  660.     {
  661.         PRINT_INFORMATION(("Show four bar shaded "));
  662. gSignalStrengthLevel = 80;   
  663.     }
  664.     else if( local_data->level >= SIGNAL_STRENGTH_LEVEL5  )
  665.     {
  666.        PRINT_INFORMATION(("Show five bar shaded " ));
  667. gSignalStrengthLevel = 100; 
  668.     }
  669. #elif(defined(__MMI_SIGNAL_STRENGTH_NUM__) && (__MMI_SIGNAL_STRENGTH_NUM__==6))
  670.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL1) && (local_data->level < SIGNAL_STRENGTH_LEVEL2))
  671.     {
  672.         PRINT_INFORMATION(("Show only one bar shaded "));
  673. gSignalStrengthLevel = 16;    
  674.     }
  675.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL2) && (local_data->level < SIGNAL_STRENGTH_LEVEL3))
  676.     {
  677.         PRINT_INFORMATION(("Show two  bar shaded "));
  678. gSignalStrengthLevel = 32;    
  679.     }
  680.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL3) && (local_data->level < SIGNAL_STRENGTH_LEVEL4))
  681.     {
  682.         PRINT_INFORMATION(("Show three  bar shaded "));
  683. gSignalStrengthLevel = 48;     
  684.     }
  685.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL4) && (local_data->level < SIGNAL_STRENGTH_LEVEL5))    
  686.     {
  687.         PRINT_INFORMATION(("Show four bar shaded "));
  688. gSignalStrengthLevel = 64;   
  689.     }
  690.     else if((local_data->level >= SIGNAL_STRENGTH_LEVEL5) && (local_data->level < SIGNAL_STRENGTH_LEVEL6))
  691.     {
  692.        PRINT_INFORMATION(("Show five bar shaded " ));
  693. gSignalStrengthLevel = 80; 
  694.     }
  695.     else if( local_data->level >= SIGNAL_STRENGTH_LEVEL6  )
  696.     {
  697.        PRINT_INFORMATION(("Show six bar shaded " ));
  698. gSignalStrengthLevel = 100; 
  699.     }
  700. #elif(defined(__MMI_SIGNAL_STRENGTH_NUM__) && (__MMI_SIGNAL_STRENGTH_NUM__==7))
  701.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL1) && (local_data->level < SIGNAL_STRENGTH_LEVEL2))
  702.     {
  703.         PRINT_INFORMATION(("Show only one bar shaded "));
  704. gSignalStrengthLevel = 14;    
  705.     }
  706.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL2) && (local_data->level < SIGNAL_STRENGTH_LEVEL3))
  707.     {
  708.         PRINT_INFORMATION(("Show two  bar shaded "));
  709. gSignalStrengthLevel = 28;    
  710.     }
  711.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL3) && (local_data->level < SIGNAL_STRENGTH_LEVEL4))
  712.     {
  713.         PRINT_INFORMATION(("Show three  bar shaded "));
  714. gSignalStrengthLevel = 42;     
  715.     }
  716.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL4) && (local_data->level < SIGNAL_STRENGTH_LEVEL5))    
  717.     {
  718.         PRINT_INFORMATION(("Show four bar shaded "));
  719. gSignalStrengthLevel = 56;   
  720.     }
  721.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL5) && (local_data->level < SIGNAL_STRENGTH_LEVEL6))    
  722.     {
  723.         PRINT_INFORMATION(("Show five bar shaded "));
  724. gSignalStrengthLevel = 70;   
  725.     }
  726.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL6) && (local_data->level < SIGNAL_STRENGTH_LEVEL7))    
  727.     {
  728.         PRINT_INFORMATION(("Show six bar shaded "));
  729. gSignalStrengthLevel = 84;   
  730.     }
  731.     else if( local_data->level >= SIGNAL_STRENGTH_LEVEL7  )
  732.     {
  733.        PRINT_INFORMATION(("Show seven bar shaded " ));
  734. gSignalStrengthLevel = 100; 
  735.     }
  736. #elif(defined(__MMI_SIGNAL_STRENGTH_NUM__) && (__MMI_SIGNAL_STRENGTH_NUM__==8))
  737.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL1) && (local_data->level < SIGNAL_STRENGTH_LEVEL2))
  738.     {
  739.         PRINT_INFORMATION(("Show only one bar shaded "));
  740. gSignalStrengthLevel = 12;    
  741.     }
  742.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL2) && (local_data->level < SIGNAL_STRENGTH_LEVEL3))
  743.     {
  744.         PRINT_INFORMATION(("Show two  bar shaded "));
  745. gSignalStrengthLevel = 24;    
  746.     }
  747.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL3) && (local_data->level < SIGNAL_STRENGTH_LEVEL4))
  748.     {
  749.         PRINT_INFORMATION(("Show three  bar shaded "));
  750. gSignalStrengthLevel = 36;     
  751.     }
  752.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL4) && (local_data->level < SIGNAL_STRENGTH_LEVEL5))     
  753.     {
  754.         PRINT_INFORMATION(("Show four bar shaded "));
  755. gSignalStrengthLevel = 48;   
  756.     }
  757.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL5) && (local_data->level < SIGNAL_STRENGTH_LEVEL6))    
  758.     {
  759.         PRINT_INFORMATION(("Show five bar shaded "));
  760. gSignalStrengthLevel = 60;   
  761.     }
  762.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL6) && (local_data->level < SIGNAL_STRENGTH_LEVEL7))    
  763.     {
  764.         PRINT_INFORMATION(("Show six bar shaded "));
  765. gSignalStrengthLevel = 72;   
  766.     }
  767.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL7) && (local_data->level < SIGNAL_STRENGTH_LEVEL8))    
  768.     {
  769.         PRINT_INFORMATION(("Show seven bar shaded "));
  770. gSignalStrengthLevel = 84;   
  771.     }
  772.     else if( local_data->level >= SIGNAL_STRENGTH_LEVEL8  )
  773.     {
  774.        PRINT_INFORMATION(("Show eight bar shaded " ));
  775. gSignalStrengthLevel = 100; 
  776.     }
  777. #elif(defined(__MMI_SIGNAL_STRENGTH_NUM__) && (__MMI_SIGNAL_STRENGTH_NUM__==9))
  778.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL1) && (local_data->level < SIGNAL_STRENGTH_LEVEL2))
  779.     {
  780.         PRINT_INFORMATION(("Show only one bar shaded "));
  781. gSignalStrengthLevel = 11;    
  782.     }
  783.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL2) && (local_data->level < SIGNAL_STRENGTH_LEVEL3))
  784.     {
  785.         PRINT_INFORMATION(("Show two  bar shaded "));
  786. gSignalStrengthLevel = 22;    
  787.     }
  788.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL3) && (local_data->level < SIGNAL_STRENGTH_LEVEL4))
  789.     {
  790.         PRINT_INFORMATION(("Show three  bar shaded "));
  791. gSignalStrengthLevel = 33;     
  792.     }
  793.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL4) && (local_data->level < SIGNAL_STRENGTH_LEVEL5))     
  794.     {
  795.         PRINT_INFORMATION(("Show four bar shaded "));
  796. gSignalStrengthLevel = 44;   
  797.     }
  798.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL5) && (local_data->level < SIGNAL_STRENGTH_LEVEL6))     
  799.     {
  800.         PRINT_INFORMATION(("Show five bar shaded "));
  801. gSignalStrengthLevel = 55;   
  802.     }
  803.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL6) && (local_data->level < SIGNAL_STRENGTH_LEVEL7))     
  804.     {
  805.         PRINT_INFORMATION(("Show six bar shaded "));
  806. gSignalStrengthLevel = 66;   
  807.     }
  808.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL7) && (local_data->level < SIGNAL_STRENGTH_LEVEL8))     
  809.     {
  810.         PRINT_INFORMATION(("Show seven bar shaded "));
  811. gSignalStrengthLevel = 77;   
  812.     }
  813.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL8) && (local_data->level < SIGNAL_STRENGTH_LEVEL9))     
  814.     {
  815.         PRINT_INFORMATION(("Show eight bar shaded "));
  816. gSignalStrengthLevel = 88;   
  817.     }
  818.     else if( local_data->level >= SIGNAL_STRENGTH_LEVEL9 )
  819.     {
  820.        PRINT_INFORMATION(("Show nine bar shaded " ));
  821. gSignalStrengthLevel = 100; 
  822.     }
  823. #elif(defined(__MMI_SIGNAL_STRENGTH_NUM__) && (__MMI_SIGNAL_STRENGTH_NUM__==10))
  824.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL1) && (local_data->level < SIGNAL_STRENGTH_LEVEL2))
  825.     {
  826.         PRINT_INFORMATION(("Show only one bar shaded "));
  827. gSignalStrengthLevel = 10;    
  828.     }
  829.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL2) && (local_data->level < SIGNAL_STRENGTH_LEVEL3))
  830.     {
  831.         PRINT_INFORMATION(("Show two  bar shaded "));
  832. gSignalStrengthLevel = 20;    
  833.     }
  834.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL3) && (local_data->level < SIGNAL_STRENGTH_LEVEL4))
  835.     {
  836.         PRINT_INFORMATION(("Show three  bar shaded "));
  837. gSignalStrengthLevel = 30;     
  838.     }
  839.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL4) && (local_data->level < SIGNAL_STRENGTH_LEVEL5))     
  840.     {
  841.         PRINT_INFORMATION(("Show four bar shaded "));
  842. gSignalStrengthLevel = 40;   
  843.     }
  844.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL5) && (local_data->level < SIGNAL_STRENGTH_LEVEL6))
  845.     {
  846.         PRINT_INFORMATION(("Show five bar shaded "));
  847. gSignalStrengthLevel = 50;    
  848.     }
  849.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL6) && (local_data->level < SIGNAL_STRENGTH_LEVEL7))
  850.     {
  851.         PRINT_INFORMATION(("Show six  bar shaded "));
  852. gSignalStrengthLevel = 60;    
  853.     }
  854.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL7) && (local_data->level < SIGNAL_STRENGTH_LEVEL8))
  855.     {
  856.         PRINT_INFORMATION(("Show seven  bar shaded "));
  857. gSignalStrengthLevel = 70;     
  858.     }
  859.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL8) && (local_data->level < SIGNAL_STRENGTH_LEVEL9))     
  860.     {
  861.         PRINT_INFORMATION(("Show eight bar shaded "));
  862. gSignalStrengthLevel = 80;   
  863.     }
  864.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL9) && (local_data->level < SIGNAL_STRENGTH_LEVEL10))     
  865.     {
  866.         PRINT_INFORMATION(("Show nine bar shaded "));
  867. gSignalStrengthLevel = 90;   
  868.     }
  869.     else if( local_data->level >= SIGNAL_STRENGTH_LEVEL10  )
  870.     {
  871.        PRINT_INFORMATION(("Show ten bar shaded " ));
  872. gSignalStrengthLevel = 100; 
  873.     }
  874. #else
  875. //Old:
  876.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL1) && (local_data->level < SIGNAL_STRENGTH_LEVEL2))
  877.     {
  878.         PRINT_INFORMATION(("Show only one bar shaded "));
  879. gSignalStrengthLevel = 25;    
  880.     }
  881.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL2) && (local_data->level < SIGNAL_STRENGTH_LEVEL3))
  882.     {
  883.         PRINT_INFORMATION(("Show two  bar shaded "));
  884. gSignalStrengthLevel = 50;    
  885.     }
  886.     else if ((local_data->level >= SIGNAL_STRENGTH_LEVEL3) && (local_data->level < SIGNAL_STRENGTH_LEVEL4))
  887.     {
  888.         PRINT_INFORMATION(("Show three  bar shaded "));
  889. gSignalStrengthLevel = 75;     
  890.     }
  891.     else if (local_data->level >= SIGNAL_STRENGTH_LEVEL4)
  892.     {
  893.         PRINT_INFORMATION(("Show four bar shaded "));
  894. gSignalStrengthLevel = 100;   
  895.     }
  896. #endif
  897. //KP Jerry modify on 2007-3-23 end
  898.     /* Robin 1117, no service shall not display signal level */
  899.     if (g_pwr_context.CurrentServiceType == NO_SERVICE)
  900.     {
  901.         ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, SIGNAL_STRENGTH_NONE);
  902.     }
  903.     else
  904.     {
  905.         ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  906.     }
  907. #ifdef __MMI_SUBLCD__
  908.     if (g_pwr_context.CurrentServiceType == NO_SERVICE)
  909.     {
  910.         ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, SIGNAL_STRENGTH_NONE);
  911.     }
  912.     else
  913.     {
  914.         ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  915.     }
  916. #endif /* __MMI_SUBLCD__ */ 
  917. }
  918. /*****************************************************************************
  919.  * FUNCTION
  920.  *  NetWorkServiceTypeIndication
  921.  * DESCRIPTION
  922.  *  This function is a call back for PRT_SERVICE_TYPE_IND
  923.  * PARAMETERS
  924.  *  iMsg        [?]     
  925.  *  void*(?)
  926.  * RETURNS
  927.  *  void
  928.  *****************************************************************************/
  929. void NetWorkServiceTypeIndication(void *iMsg)
  930. {
  931.     /*----------------------------------------------------------------*/
  932.     /* Local Variables                                                */
  933.     /*----------------------------------------------------------------*/
  934.     /* MMINWREGSTATEIND *local_data = (MMINWREGSTATEIND *)iMsg; */
  935.     mmi_nw_reg_state_ind_struct *local_data = (mmi_nw_reg_state_ind_struct*) iMsg;
  936.     /*----------------------------------------------------------------*/
  937.     /* Code Body                                                      */
  938.     /*----------------------------------------------------------------*/
  939.     PRINT_INFORMATION(("n NetWorkServiceTypeIndicationn"));
  940.     if (local_data->status == MMI_RAC_OK)
  941.     {
  942.         /* micha0120 */
  943.         UpdateGPRSStatusIcon(local_data->gprs_status);
  944.         /* micha0423 */
  945.         if (gGPRSStatusModified)
  946.         {
  947.             refresh_status_icon_display();
  948.             gGPRSStatusModified = 0;
  949.         }
  950.     }
  951.     else
  952.     {
  953.         /* Do nothing, keep original state */
  954.     }
  955. }
  956. /*****************************************************************************
  957.  * FUNCTION
  958.  *  NumberOfPLMNSuported
  959.  * DESCRIPTION
  960.  *  This function is a call back for MSG_ID_MMI_SMU_SUPPORT_PLMN_LIST_IND
  961.  * PARAMETERS
  962.  *  iMsg        [?]     
  963.  *  void*(?)
  964.  * RETURNS
  965.  *  void
  966.  *****************************************************************************/
  967. void NumberOfPLMNSuported(void *iMsg)
  968. {
  969.     /*----------------------------------------------------------------*/
  970.     /* Local Variables                                                */
  971.     /*----------------------------------------------------------------*/
  972.     MMISMUSUPPORTPLMNLISTIND *local_data = (MMISMUSUPPORTPLMNLISTIND*) iMsg;
  973.     /*----------------------------------------------------------------*/
  974.     /* Code Body                                                      */
  975.     /*----------------------------------------------------------------*/
  976.     g_pwr_context.NoOfPLMNSupported = local_data->length;
  977.     PRINT_INFORMATION(("NumberOfPLMNSuported gNoOfPLMNSupported = %dn", g_pwr_context.NoOfPLMNSupported));
  978. }
  979. /**************************************************************************
  980.             Roaming API
  981. **************************************************************************/
  982. /*****************************************************************************
  983.  * FUNCTION
  984.  *  ChangeRoamingState
  985.  * DESCRIPTION
  986.  *  Change Roaming state
  987.  * PARAMETERS
  988.  *  void
  989.  * RETURNS
  990.  *  void
  991.  *****************************************************************************/
  992. void ChangeRoamingState(void)
  993. {
  994.     /*----------------------------------------------------------------*/
  995.     /* Local Variables                                                */
  996.     /*----------------------------------------------------------------*/
  997.     U8 gPLMNLen = strlen((S8*) gPLMN);
  998.     /*----------------------------------------------------------------*/
  999.     /* Code Body                                                      */
  1000.     /*----------------------------------------------------------------*/
  1001.     /* diamond, 2005/08/28 avoid the case VPLMN=OPN */
  1002.     if (memcmp(gHomePLMNNum, gPLMN, gPLMNLen) != 0 &&
  1003.         pfnUnicodeStrcmp((S8*) gNWProviderName, (S8*) gOperatorName) != 0 &&
  1004.         !((memcmp(gHomePLMNNum, "46002", 5) == 0 && memcmp(gPLMN, "46000", 5) == 0)) &&
  1005.         mmi_netset_equivalent_plmn_check() != 1)
  1006.     {
  1007.         /* Set Roaming Signal to be display on idle screen */
  1008.         /* g_pwr_context.RoamingFlag = 1; */
  1009.         g_pwr_context.PowerOnSIMStatus |= MMI_SIM_STATUS_ROAMING;
  1010.         IdleSetStatusIcon(STATUS_ICON_ROAMING);
  1011.         /* if( g_pwr_context.idleScreenFirst ) */
  1012.         if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  1013.         {
  1014.             StopLEDPatternRoaming();    /* MTK add Robin 1009. Stop LED will trigger the Band led pattern resume mechanism */
  1015.         }
  1016.     #ifdef MMS_SUPPORT
  1017.         wap_roaming_status_indication_callback((U32) 1);
  1018.     #endif 
  1019.     }
  1020.     else
  1021.     {
  1022.         /* g_pwr_context.RoamingFlag = 0; */
  1023.         g_pwr_context.PowerOnSIMStatus &= ~MMI_SIM_STATUS_ROAMING;
  1024.         IdleResetStatusIcon(STATUS_ICON_ROAMING);
  1025.         /* if( g_pwr_context.idleScreenFirst ) */
  1026.         if (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE)
  1027.         {
  1028.             StopLEDPatternRoaming();    /* MTK add Robin 1009. Stop LED will trigger the Band led pattern resume mechanism */
  1029.         }
  1030.     #ifdef MMS_SUPPORT
  1031.         wap_roaming_status_indication_callback((U32) 0);
  1032.     #endif 
  1033.     }
  1034. }
  1035. /*****************************************************************************
  1036.  * FUNCTION
  1037.  *  RequestToTestRoamingEnabled
  1038.  * DESCRIPTION
  1039.  *  To send message MSG_ID_MMI_SMU_GET_IMSI_REQ
  1040.  *  in response of this message imsi field is returned
  1041.  *  compare first 5byte of this arr , if they are not same
  1042.  *  with the plmn , means roaming is enabled, display the
  1043.  *  roaming icon.
  1044.  * PARAMETERS
  1045.  *  void
  1046.  * RETURNS
  1047.  *  void
  1048.  *****************************************************************************/
  1049. void RequestToTestRoamingEnabled(void)
  1050. {
  1051.     /*----------------------------------------------------------------*/
  1052.     /* Local Variables                                                */
  1053.     /*----------------------------------------------------------------*/
  1054.     MYQUEUE Message;
  1055.     /*----------------------------------------------------------------*/
  1056.     /* Code Body                                                      */
  1057.     /*----------------------------------------------------------------*/
  1058.     SetProtocolEventHandler(RspToTestRoamingEnabled, PRT_GET_IMSI_RSP);
  1059.     g_pwr_context.testRoaming = 2;
  1060.     PRINT_INFORMATION(("@@@@@ RequestToTestRoamingEnabled  @@@@@"));
  1061.     Message.oslSrcId = MOD_MMI;
  1062.     Message.oslDestId = MOD_L4C;
  1063.     Message.oslMsgId = PRT_GET_IMSI_REQ;
  1064.     Message.oslDataPtr = NULL;  /* (oslParaType *)local_data; */
  1065.     Message.oslPeerBuffPtr = NULL;
  1066.     OslMsgSendExtQueue(&Message);
  1067. }
  1068. /*****************************************************************************
  1069.  * FUNCTION
  1070.  *  RspToTestRoamingEnabled
  1071.  * DESCRIPTION
  1072.  *  To send message MSG_ID_MMI_SMU_GET_IMSI_REQ
  1073.  *  in response of this message imsi field is returned
  1074.  *  compare first 5byte of this arr , if they are not same
  1075.  *  with the plmn , means roaming is enabled, display the
  1076.  *  roaming icon.
  1077.  * PARAMETERS
  1078.  *  inMsg       [?]     
  1079.  *  void*(?)
  1080.  * RETURNS
  1081.  *  void
  1082.  *****************************************************************************/
  1083. void RspToTestRoamingEnabled(void *inMsg)
  1084. {
  1085.     /*----------------------------------------------------------------*/
  1086.     /* Local Variables                                                */
  1087.     /*----------------------------------------------------------------*/
  1088.     MMISMUGETIMSIRSP *local_data = (MMISMUGETIMSIRSP*) inMsg;
  1089.     /*----------------------------------------------------------------*/
  1090.     /* Code Body                                                      */
  1091.     /*----------------------------------------------------------------*/
  1092.     PRINT_INFORMATION(("Inside RspToTestRoamingEnabled"));
  1093.     if (local_data->result == ST_SUCCESS)
  1094.     {
  1095.         g_pwr_context.testRoaming = 3;
  1096.         memset(gHomePLMNNum, '', sizeof(gHomePLMNNum));
  1097.         memcpy(gHomePLMNNum, (local_data->imsi) + 1, MAX_PLMN_LEN_MMI); /* always copy 6 digits to gHomePLMNNum no matter they're 5 or 6 digits */
  1098.     #ifdef MMS_SUPPORT
  1099.         wap_plmn_number_indication_callback((const U8*)gHomePLMNNum);
  1100.     #endif 
  1101.     #if ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) )
  1102.         /* diamond, 2005/09/26 support PNN and OPL */
  1103.         if (is_sim_replaced())
  1104.         {
  1105.             eons_get_opn_file_info_req();
  1106.         }
  1107.         else
  1108.         {
  1109.             eons_read_opn_from_nvram();
  1110.         }
  1111.     #endif /* ( (defined __MMI_EONS_SUPPORT__) && (defined MMI_ON_HARDWARE_P) ) */ 
  1112.         if (g_pwr_context.CurrentServiceType == FULL_SERVICE)   /* Robin 1128 */
  1113.         {
  1114.             ChangeRoamingState();
  1115.         }
  1116.     }
  1117.     else
  1118.     {
  1119.         g_pwr_context.testRoaming = 1;
  1120.     }
  1121.     if (g_idle_context.IsOnIdleScreen)
  1122.     {
  1123.         EntryIdleScreen();
  1124.     }
  1125. }
  1126. /*****************************************************************************
  1127.  * FUNCTION
  1128.  *  NetWorkCipherIndication
  1129.  * DESCRIPTION
  1130.  *  Callback function for ciphering indeication
  1131.  * PARAMETERS
  1132.  *  info        [?]     
  1133.  *  void*(?)
  1134.  * RETURNS
  1135.  *  void
  1136.  *****************************************************************************/
  1137. #ifdef _NETWORK_CIPHER_SUPPORT_
  1138. void NetWorkCipherIndication(void *info)
  1139. {
  1140.     /*----------------------------------------------------------------*/
  1141.     /* Local Variables                                                */
  1142.     /*----------------------------------------------------------------*/
  1143.     mmi_smu_cipher_ind_struct *local_data = (mmi_smu_cipher_ind_struct*) info;
  1144.     /*----------------------------------------------------------------*/
  1145.     /* Code Body                                                      */
  1146.     /*----------------------------------------------------------------*/
  1147.     PRINT_INFORMATION(("n NetWorkCipherIndicationn"));
  1148.     if (local_data->cipher_ind == 1 && local_data->is_gsm_conn_exist && isInCall())
  1149.     {
  1150.         if (local_data->gsm_cipher_cond == GMMREG_CIPHER_OFF)
  1151.         {
  1152.             ShowStatusIcon(STATUS_ICON_NETWORK_CIPHER_GSM); /* warning for insecure network */
  1153.         }
  1154.         else if (local_data->gsm_cipher_cond == GMMREG_CIPHER_ON ||
  1155.                  local_data->gsm_cipher_cond == GMMREG_CIPHER_INVALID)
  1156.         {
  1157.             HideStatusIcon(STATUS_ICON_NETWORK_CIPHER_GSM); /* warning for insecure network */
  1158.         }
  1159.         else if (local_data->gprs_cipher_cond == GMMREG_CIPHER_OFF)
  1160.         {
  1161.             ShowStatusIcon(STATUS_ICON_NETWORK_CIPHER_GPRS);    /* warning for insecure network */
  1162.         }
  1163.         else if (local_data->gprs_cipher_cond == GMMREG_CIPHER_ON ||
  1164.                  local_data->gsm_cipher_cond == GMMREG_CIPHER_INVALID)
  1165.         {
  1166.             HideStatusIcon(STATUS_ICON_NETWORK_CIPHER_GPRS);    /* warning for insecure network */
  1167.         }
  1168.     }
  1169.     else    /* cipher not supported */
  1170.     {
  1171.         HideStatusIcon(STATUS_ICON_NETWORK_CIPHER_GSM);
  1172.         HideStatusIcon(STATUS_ICON_NETWORK_CIPHER_GPRS);
  1173.     }
  1174.     UpdateStatusIcons();
  1175. }
  1176. #endif /* _NETWORK_CIPHER_SUPPORT_ */ 
  1177. /**************************************************************************
  1178.          API of Manual Mode Network Selection
  1179. **************************************************************************/
  1180. /*****************************************************************************
  1181.  * FUNCTION
  1182.  *  PLMNSelectionModeIndication
  1183.  * DESCRIPTION
  1184.  *  Callback function for PLMN selection mode indication
  1185.  * PARAMETERS
  1186.  *  info        [?]     
  1187.  *  void*(?)
  1188.  * RETURNS
  1189.  *  void
  1190.  *****************************************************************************/
  1191. #ifdef __MANUAL_MODE_NW_SEL__
  1192. void PLMNSelectionModeIndication(void *info)
  1193. {
  1194.     /*----------------------------------------------------------------*/
  1195.     /* Local Variables                                                */
  1196.     /*----------------------------------------------------------------*/
  1197.     mmi_nw_sel_mode_ind_struct *local_data = (mmi_nw_sel_mode_ind_struct*) info;
  1198.     /*----------------------------------------------------------------*/
  1199.     /* Code Body                                                      */
  1200.     /*----------------------------------------------------------------*/
  1201.     PRINT_INFORMATION(("n NetworkSelectionModeIndicationn"));
  1202.     /* g_pwr_context.PLMNSelectionMode = local_data->network_mode; */
  1203.     if (local_data->network_mode == MANUAL_MODE)
  1204.     {
  1205.         g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_PLMNSEL_MODE;    /* 0x08: PLMN selection mode */
  1206.     }
  1207.     else
  1208.     {
  1209.         g_pwr_context.PowerOnNWStatus &= ~MMI_NW_STATUS_PLMNSEL_MODE;   /* 0x08: PLMN selection mode */
  1210.     }
  1211.     IdleRefreshServiceIndicationArea();
  1212.     if (g_idle_context.IsOnIdleScreen)
  1213.     {
  1214.         IdleSetLRKey();
  1215.     }
  1216. }
  1217. /*****************************************************************************
  1218.  * FUNCTION
  1219.  *  PLMNGetSelectionModeRsp
  1220.  * DESCRIPTION
  1221.  *  Response for PLMN selection mode
  1222.  * PARAMETERS
  1223.  *  info        [?]     
  1224.  *  void*(?)
  1225.  * RETURNS
  1226.  *  void
  1227.  *****************************************************************************/
  1228. void PLMNGetSelectionModeRsp(void *info)
  1229. {
  1230.     /*----------------------------------------------------------------*/
  1231.     /* Local Variables                                                */
  1232.     /*----------------------------------------------------------------*/
  1233.     mmi_nw_get_plmn_select_mode_rsp_struct *local_data = (mmi_nw_get_plmn_select_mode_rsp_struct*) info;
  1234.     /*----------------------------------------------------------------*/
  1235.     /* Code Body                                                      */
  1236.     /*----------------------------------------------------------------*/
  1237.     PRINT_INFORMATION(("n PLMNGetSelectionModeRspn"));
  1238.     /* g_pwr_context.PLMNSelectionMode = local_data->mode; */
  1239.     if (local_data->mode == MANUAL_MODE)
  1240.     {
  1241.         g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_PLMNSEL_MODE;    /* 0x08: PLMN selection mode */
  1242.     }
  1243.     else
  1244.     {
  1245.         g_pwr_context.PowerOnNWStatus &= ~MMI_NW_STATUS_PLMNSEL_MODE;   /* 0x08: PLMN selection mode */
  1246.     }
  1247.     ClearProtocolEventHandler(MSG_ID_MMI_NW_GET_PLMN_SELECT_MODE_RSP);
  1248.     return;
  1249. }
  1250. /*****************************************************************************
  1251.  * FUNCTION
  1252.  *  PLMNGetSelectionModeReq
  1253.  * DESCRIPTION
  1254.  *  Request for PLMN selection mode
  1255.  * PARAMETERS
  1256.  *  void
  1257.  * RETURNS
  1258.  *  void
  1259.  *****************************************************************************/
  1260. void PLMNGetSelectionModeReq(void)
  1261. {
  1262.     /*----------------------------------------------------------------*/
  1263.     /* Local Variables                                                */
  1264.     /*----------------------------------------------------------------*/
  1265.     MYQUEUE msgStruct;
  1266.     /*----------------------------------------------------------------*/
  1267.     /* Code Body                                                      */
  1268.     /*----------------------------------------------------------------*/
  1269.     SetProtocolEventHandler(PLMNGetSelectionModeRsp, MSG_ID_MMI_NW_GET_PLMN_SELECT_MODE_RSP);
  1270.     /* format the message to get band selection */
  1271.     msgStruct.oslSrcId = MOD_MMI;
  1272.     msgStruct.oslDestId = MOD_L4C;
  1273.     msgStruct.oslMsgId = (unsigned int)MSG_ID_MMI_NW_GET_PLMN_SELECT_MODE_REQ;
  1274.     msgStruct.oslSapId = (unsigned int)0;
  1275.     msgStruct.oslDataPtr = NULL;
  1276.     msgStruct.oslPeerBuffPtr = NULL;
  1277.     /* send req to l4 to get band selection */
  1278.     OslMsgSendExtQueue(&msgStruct);
  1279.     return;
  1280. }
  1281. #endif /* __MANUAL_MODE_NW_SEL__ */ 
  1282. /**************************************************************************
  1283.             GPRS API
  1284. **************************************************************************/
  1285. #ifdef WAP_SUPPORT
  1286. /*****************************************************************************
  1287.  * FUNCTION
  1288.  *  mmi_netset_update_gprs_state_to_wap
  1289.  * DESCRIPTION
  1290.  *  Send GPRS state to WAP
  1291.  * PARAMETERS
  1292.  *  state        [IN]     
  1293.  * RETURNS
  1294.  *  void
  1295.  *****************************************************************************/
  1296. static void mmi_netset_update_gprs_state_to_wap(U8 state)
  1297. {
  1298.     /*----------------------------------------------------------------*/
  1299.     /* Local Variables                                                */
  1300.     /*----------------------------------------------------------------*/
  1301.     MYQUEUE msgStruct;
  1302.     wap_bearer_status_ind_struct *local_data;
  1303.     /*----------------------------------------------------------------*/
  1304.     /* Code Body                                                      */
  1305.     /*----------------------------------------------------------------*/
  1306.     if (wap_browser_is_open())
  1307.     {
  1308.         msgStruct.oslSrcId = MOD_MMI;
  1309.         msgStruct.oslDestId = MOD_WAP;
  1310.         msgStruct.oslMsgId = MSG_ID_WAP_BEARER_STATUS_IND;
  1311.         local_data = (wap_bearer_status_ind_struct*) OslConstructDataPtr(sizeof(wap_bearer_status_ind_struct));
  1312.         local_data->bearer_type = WAP_BEARER_STATUS_GPRS;
  1313.         local_data->status = state;
  1314.         msgStruct.oslDataPtr = (oslParaType*) local_data;
  1315.         msgStruct.oslPeerBuffPtr = NULL;
  1316.         OslMsgSendExtQueue(&msgStruct);
  1317.     }
  1318. }
  1319. #endif /* WAP_SUPPORT */
  1320. /*****************************************************************************
  1321.  * FUNCTION
  1322.  *  GPRSStatusUpdateIndication
  1323.  * DESCRIPTION
  1324.  *  Callback function for GPRS status update indication
  1325.  * PARAMETERS
  1326.  *  info        [?]     
  1327.  *  void*(?)
  1328.  * RETURNS
  1329.  *  void
  1330.  *****************************************************************************/
  1331. void GPRSStatusUpdateIndication(void *info)
  1332. {
  1333. #ifdef __MMI_GPRS_FEATURES__
  1334.     /*----------------------------------------------------------------*/
  1335.     /* Local Variables                                                */
  1336.     /*----------------------------------------------------------------*/
  1337.     mmi_ps_gprs_status_update_ind_struct *local_data = (mmi_ps_gprs_status_update_ind_struct*) info;
  1338.     /*----------------------------------------------------------------*/
  1339.     /* Code Body                                                      */
  1340.     /*----------------------------------------------------------------*/
  1341.     PRINT_INFORMATION(("n GPRSStatusUpdateIndicationn"));
  1342.     UpdateGPRSStatusIcon(local_data->status);
  1343.     if (gGPRSStatusModified)
  1344.     {
  1345.         UpdateStatusIcons();
  1346.         gGPRSStatusModified = 0;
  1347.     }
  1348. #endif /* __MMI_GPRS_FEATURES__ */ 
  1349. }
  1350. /*****************************************************************************
  1351.  * FUNCTION
  1352.  *  GPRSStatusGetGPRSModeRsp
  1353.  * DESCRIPTION
  1354.  *  Response for GPRS mode
  1355.  * PARAMETERS
  1356.  *  info        [?]     
  1357.  *  void*(?)
  1358.  * RETURNS
  1359.  *  void
  1360.  *****************************************************************************/
  1361. void GPRSStatusGetGPRSModeRsp(void *info)
  1362. {
  1363. #ifdef __MMI_GPRS_FEATURES__
  1364.     /*----------------------------------------------------------------*/
  1365.     /* Local Variables                                                */
  1366.     /*----------------------------------------------------------------*/
  1367.     mmi_nw_get_gprs_connect_type_rsp_struct *localPtr;
  1368.     /*----------------------------------------------------------------*/
  1369.     /* Code Body                                                      */
  1370.     /*----------------------------------------------------------------*/
  1371.     localPtr = (mmi_nw_get_gprs_connect_type_rsp_struct*) info;
  1372.     if (localPtr->result == MMI_TRUE)
  1373.     {
  1374.         if (localPtr->type == L4C_WHEN_NEEDED)
  1375.         {
  1376.             GPRSStatusDetachGPRSReq();
  1377.         }
  1378.     }
  1379. #endif /* __MMI_GPRS_FEATURES__ */ 
  1380. }
  1381. /*****************************************************************************
  1382.  * FUNCTION
  1383.  *  GPRSStatusGetGPRSModeReq
  1384.  * DESCRIPTION
  1385.  *  Request for GPRS mode
  1386.  * PARAMETERS
  1387.  *  void
  1388.  *  void*(?)
  1389.  * RETURNS
  1390.  *  void
  1391.  *****************************************************************************/
  1392. void GPRSStatusGetGPRSModeReq(void)
  1393. {
  1394. #ifdef __MMI_GPRS_FEATURES__
  1395.     /*----------------------------------------------------------------*/
  1396.     /* Local Variables                                                */
  1397.     /*----------------------------------------------------------------*/
  1398.     MYQUEUE msgStruct;
  1399.     /*----------------------------------------------------------------*/
  1400.     /* Code Body                                                      */
  1401.     /*----------------------------------------------------------------*/
  1402.     SetProtocolEventHandler(GPRSStatusGetGPRSModeRsp, MSG_ID_MMI_NW_GET_GPRS_CONNECT_TYPE_RSP);
  1403.     /* format the message to get band selection */
  1404.     msgStruct.oslSrcId = MOD_MMI;
  1405.     msgStruct.oslDestId = MOD_L4C;
  1406.     msgStruct.oslMsgId = (unsigned int)MSG_ID_MMI_NW_GET_GPRS_CONNECT_TYPE_REQ;
  1407.     msgStruct.oslSapId = (unsigned int)0;
  1408.     msgStruct.oslDataPtr = NULL;
  1409.     msgStruct.oslPeerBuffPtr = NULL;
  1410.     /* send req to l4 to get band selection */
  1411.     OslMsgSendExtQueue(&msgStruct);
  1412.     return;
  1413. #endif /* __MMI_GPRS_FEATURES__ */ 
  1414. }
  1415. /*****************************************************************************
  1416.  * FUNCTION
  1417.  *  GPRSStatusDetachGPRSRsp
  1418.  * DESCRIPTION
  1419.  *  Response for GPRS detachment
  1420.  * PARAMETERS
  1421.  *  info        [?]     
  1422.  *  void*(?)
  1423.  * RETURNS
  1424.  *  void
  1425.  *****************************************************************************/
  1426. void GPRSStatusDetachGPRSRsp(void *info)
  1427. {
  1428.     /*----------------------------------------------------------------*/
  1429.     /* Local Variables                                                */
  1430.     /*----------------------------------------------------------------*/
  1431.     /*----------------------------------------------------------------*/
  1432.     /* Code Body                                                      */
  1433.     /*----------------------------------------------------------------*/
  1434.     /* do nothing */
  1435. }
  1436. /*****************************************************************************
  1437.  * FUNCTION
  1438.  *  GPRSStatusDetachGPRSReq
  1439.  * DESCRIPTION
  1440.  *  Request for GPRS detachment
  1441.  * PARAMETERS
  1442.  *  void
  1443.  * RETURNS
  1444.  *  void
  1445.  *****************************************************************************/
  1446. void GPRSStatusDetachGPRSReq(void)
  1447. {
  1448. #ifdef __MMI_GPRS_FEATURES__
  1449.     /*----------------------------------------------------------------*/
  1450.     /* Local Variables                                                */
  1451.     /*----------------------------------------------------------------*/
  1452.     MYQUEUE msgStruct;
  1453.     mmi_nw_set_attach_req_struct *local_data;
  1454.     /*----------------------------------------------------------------*/
  1455.     /* Code Body                                                      */
  1456.     /*----------------------------------------------------------------*/
  1457.     SetProtocolEventHandler(GPRSStatusDetachGPRSRsp, MSG_ID_MMI_NW_SET_ATTACH_RSP);
  1458.     msgStruct.oslSrcId = MOD_MMI;
  1459.     msgStruct.oslDestId = MOD_L4C;
  1460.     msgStruct.oslMsgId = MSG_ID_MMI_NW_SET_ATTACH_REQ;
  1461.     local_data = (mmi_nw_set_attach_req_struct*) OslConstructDataPtr(sizeof(mmi_nw_set_attach_req_struct));
  1462.     local_data->is_poweroff = MMI_FALSE;
  1463.     local_data->opcode = RAC_DETACH;
  1464.     local_data->type = RAC_PS;
  1465.     msgStruct.oslDataPtr = (oslParaType*) local_data;
  1466.     msgStruct.oslPeerBuffPtr = NULL;
  1467.     OslMsgSendExtQueue(&msgStruct);
  1468.     return;
  1469. #endif /* __MMI_GPRS_FEATURES__ */ 
  1470. }
  1471. /*****************************************************************************
  1472.  * FUNCTION
  1473.  *  UpdateGPRSStatusIcon
  1474.  * DESCRIPTION
  1475.  *  Update GPRS icon
  1476.  * PARAMETERS
  1477.  *  gprs_state      [IN]        
  1478.  * RETURNS
  1479.  *  void
  1480.  *****************************************************************************/
  1481. void UpdateGPRSStatusIcon(U8 gprs_state)
  1482. {
  1483.     /*----------------------------------------------------------------*/
  1484.     /* Local Variables                                                */
  1485.     /*----------------------------------------------------------------*/
  1486.     static U8 gGPRSAttachStatus = 0;
  1487.     static U8 gGPRSPDPStatus = 0;
  1488.     static U8 gGPRSCellStatus = 0;
  1489.     /* micha0202, vito G display issue */
  1490.     static U8 LastGPRSStatus = 0;   /* 0: No icon,  1:  only attach,  2: attach+pdp active */
  1491.     /*----------------------------------------------------------------*/
  1492.     /* Code Body                                                      */
  1493.     /*----------------------------------------------------------------*/
  1494.     switch (gprs_state)
  1495.     {
  1496.         case L4C_GPRS_ATTACHED:
  1497.             gGPRSCellStatus = 1;    /* diamond, 2006/04/20 Accept to display if no coverage */
  1498.             gGPRSAttachStatus = 1;
  1499.         #ifdef WAP_SUPPORT
  1500.             mmi_netset_update_gprs_state_to_wap(WAP_GPRS_ATTACHED);
  1501.         #endif
  1502.             break;
  1503.         case L4C_GPRS_DETACHED:
  1504.             gGPRSAttachStatus = 0;
  1505.         #ifdef WAP_SUPPORT
  1506.             mmi_netset_update_gprs_state_to_wap(WAP_GPRS_DETACHED);
  1507.         #endif
  1508.             break;
  1509.         case L4C_PDP_ACTIVED:
  1510.             gGPRSPDPStatus = 1;
  1511.             break;
  1512.         case L4C_PDP_DEACTIVED:
  1513.             gGPRSPDPStatus = 0;
  1514.             break;
  1515.         case L4C_GPRS_COVERAGE:
  1516.         #ifdef WAP_SUPPORT
  1517.             mmi_netset_update_gprs_state_to_wap(WAP_GPRS_COVERAGE);
  1518.         #endif
  1519.             gGPRSCellStatus = 1;
  1520.             break;
  1521.         case L4C_NONE_GPRS:
  1522.             gGPRSCellStatus = 0;
  1523.             gGPRSAttachStatus = 0;
  1524.         #ifdef WAP_SUPPORT
  1525.             mmi_netset_update_gprs_state_to_wap(WAP_GPRS_NONE);
  1526.         #endif
  1527.             break;
  1528.         default:
  1529.             break;
  1530.     }
  1531.     PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[Update G] Att:%d,PDP:%d,Cov:%d,Last:%d", gGPRSAttachStatus,
  1532.                          gGPRSPDPStatus, gGPRSCellStatus, LastGPRSStatus));
  1533.     /* micha0202, micha0224, vito display issue */
  1534.     if (gGPRSAttachStatus && gGPRSPDPStatus && gGPRSCellStatus)
  1535.     {
  1536.         if (LastGPRSStatus != 2)
  1537.         {
  1538.             HideStatusIcon(STATUS_ICON_GPRS_ATT_NO_PDP_INDICATOR);
  1539.             ShowStatusIcon(STATUS_ICON_GPRS_SERVICE);
  1540.             LastGPRSStatus = 2;
  1541.             gGPRSStatusModified = 1;
  1542.         }
  1543.     }
  1544.     else if (gGPRSAttachStatus && !gGPRSPDPStatus && gGPRSCellStatus)
  1545.     {
  1546.         if (LastGPRSStatus != 1)
  1547.         {
  1548.             HideStatusIcon(STATUS_ICON_GPRS_SERVICE);
  1549.             ShowStatusIcon(STATUS_ICON_GPRS_ATT_NO_PDP_INDICATOR);
  1550.             LastGPRSStatus = 1;
  1551.             gGPRSStatusModified = 1;
  1552.         }
  1553.     }
  1554.     else
  1555.     {
  1556.         if (LastGPRSStatus != 0)
  1557.         {
  1558.             HideStatusIcon(STATUS_ICON_GPRS_ATT_NO_PDP_INDICATOR);
  1559.             HideStatusIcon(STATUS_ICON_GPRS_SERVICE);
  1560.             LastGPRSStatus = 0;
  1561.             gGPRSStatusModified = 1;
  1562.         }
  1563.         UpdateStatusIcons();
  1564.     }
  1565. }
  1566. /**************************************************************************
  1567.          API's To Others
  1568. **************************************************************************/
  1569. /*****************************************************************************
  1570.  * FUNCTION
  1571.  *  HomezoneStatusIndication
  1572.  * DESCRIPTION
  1573.  *  This function is a call back for homezone indication
  1574.  * PARAMETERS
  1575.  *  info        [?]     
  1576.  * RETURNS
  1577.  *  void
  1578.  *****************************************************************************/
  1579. #ifdef __HOMEZONE_SUPPORT__
  1580. void HomezoneStatusIndication(void *info)
  1581. {
  1582.     /*----------------------------------------------------------------*/
  1583.     /* Local Variables                                                */
  1584.     /*----------------------------------------------------------------*/
  1585.     U16 convertOutLen = 0, originalInLen = 0, i;
  1586.     mmi_hz_tag_ind_struct *local_data;
  1587.     /*----------------------------------------------------------------*/
  1588.     /* Code Body                                                      */
  1589.     /*----------------------------------------------------------------*/
  1590.     // U8 s[4] = {0x54, 0x65, 0x73, 0x74};
  1591.     // gHomezoneText=CovertStringForPlatform((PU8)s, 4, MMI_DEFAULT_DCS, &convertOutLen);
  1592.     local_data = (mmi_hz_tag_ind_struct*) info;
  1593.     if (local_data->is_hz == MMI_TRUE)  /* homezone case */
  1594.     {
  1595.         if (local_data->action == MMI_TRUE) /* show icon and display text */
  1596.         {
  1597.             HideStatusIcon(STATUS_ICON_CITYZONE);
  1598.             ShowStatusIcon(STATUS_ICON_HOMEZONE);
  1599.             if (local_data->tag[0] != 0xFF)
  1600.             {
  1601.                 for (i = 0; i < 12; i++) /* the max HZ length is 12 */
  1602.                 {
  1603.                     if (local_data->tag[i] == 0xFF)
  1604.                     {
  1605.                         break;
  1606.                     }
  1607.                     else
  1608.                     {
  1609.                         originalInLen++;
  1610.                     }
  1611.                 }
  1612.                 gHomezoneText = CovertStringForPlatform(local_data->tag, originalInLen, MMI_DEFAULT_DCS, &convertOutLen);
  1613.             }
  1614.             else
  1615.             {
  1616.                 gHomezoneText = NULL;
  1617.             }
  1618.         }
  1619.         else    /* clear icon and text */
  1620.         {
  1621.             HideStatusIcon(STATUS_ICON_HOMEZONE);
  1622.             HideStatusIcon(STATUS_ICON_CITYZONE);
  1623.             gHomezoneText = NULL;
  1624.         }
  1625.     }
  1626.     else    /* cityzone case */
  1627.     {
  1628.         if (local_data->action == MMI_TRUE) /* show icon and display text */
  1629.         {
  1630.             HideStatusIcon(STATUS_ICON_HOMEZONE);
  1631.             ShowStatusIcon(STATUS_ICON_CITYZONE);
  1632.             if (local_data->tag[0] != 0xFF)
  1633.             {
  1634.                 for (i = 0; i < 12; i++) /* the max HZ length is 12 */
  1635.                 {
  1636.                     if (local_data->tag[i] == 0xFF)
  1637.                     {
  1638.                         break;
  1639.                     }
  1640.                     else
  1641.                     {
  1642.                         originalInLen++;
  1643.                     }
  1644.                 }
  1645.                 gHomezoneText = CovertStringForPlatform(local_data->tag, originalInLen, MMI_DEFAULT_DCS, &convertOutLen);
  1646.             }
  1647.             else
  1648.             {
  1649.                 gHomezoneText = NULL;
  1650.             }
  1651.         }
  1652.         else    /* clear icon and text */
  1653.         {
  1654.             HideStatusIcon(STATUS_ICON_HOMEZONE);
  1655.             HideStatusIcon(STATUS_ICON_CITYZONE);
  1656.             gHomezoneText = NULL;
  1657.         }
  1658.     }
  1659.     UpdateStatusIcons();
  1660.     IdleRefreshServiceIndicationArea();
  1661.     if (g_idle_context.IsOnIdleScreen)
  1662.     {
  1663.         EntryIdleScreen();
  1664.     }
  1665. }
  1666. #endif /* __HOMEZONE_SUPPORT__ */ 
  1667. #ifndef __MTK_TARGET__
  1668. /*****************************************************************************
  1669.  * FUNCTION
  1670.  *  mmi_netset_inject_network_attachment
  1671.  * DESCRIPTION
  1672.  *  This function is message injection to MMI for network attachment
  1673.  * PARAMETERS
  1674.  *  void
  1675.  * RETURNS
  1676.  *  void
  1677.  *****************************************************************************/
  1678. void mmi_netset_inject_network_attachment(void)
  1679. {
  1680.     /*----------------------------------------------------------------*/
  1681.     /* Local Variables                                                */
  1682.     /*----------------------------------------------------------------*/
  1683.     mmi_nw_attach_ind_struct *nw_attach_ind;
  1684.     MYQUEUE Message;
  1685.     /*----------------------------------------------------------------*/
  1686.     /* Code Body                                                      */
  1687.     /*----------------------------------------------------------------*/
  1688.     nw_attach_ind = (mmi_nw_attach_ind_struct*) OslConstructDataPtr(sizeof(mmi_nw_attach_ind_struct));
  1689.     
  1690.     nw_attach_ind->status = MMI_RAC_OK;
  1691.     nw_attach_ind->gprs_status = L4C_GPRS_DETACHED;
  1692.     nw_attach_ind->plmn[0] = 0x34;
  1693.     nw_attach_ind->plmn[1] = 0x36;
  1694.     nw_attach_ind->plmn[2] = 0x36;
  1695.     nw_attach_ind->plmn[3] = 0x39;
  1696.     nw_attach_ind->plmn[4] = 0x37;
  1697.     nw_attach_ind->plmn[5] = 0;
  1698.     
  1699.     Message.oslSrcId = MOD_MMI;
  1700.     Message.oslDestId = MOD_MMI;
  1701.     Message.oslMsgId = PRT_NW_ATTACH_IND;
  1702.     Message.oslDataPtr = (oslParaType*) nw_attach_ind;
  1703.     Message.oslPeerBuffPtr = NULL;
  1704.     OslMsgSendExtQueue(&Message);
  1705. }
  1706. #ifdef MMI_ON_HARDWARE_P
  1707. /*****************************************************************************
  1708.  * FUNCTION
  1709.  *  mmi_netset_write_auto_test_result
  1710.  * DESCRIPTION
  1711.  *  This function is used for auto power on test on MoDIS
  1712.  * PARAMETERS
  1713.  *  result         [IN]
  1714.  * RETURNS
  1715.  *  void
  1716.  *****************************************************************************/
  1717. void mmi_netset_write_auto_test_result(pBOOL result)
  1718. {
  1719.     /*----------------------------------------------------------------*/
  1720.     /* Local Variables                                                */
  1721.     /*----------------------------------------------------------------*/
  1722.     extern pBOOL AUTO_POWER;
  1723.     /*----------------------------------------------------------------*/
  1724.     /* Code Body                                                      */
  1725.     /*----------------------------------------------------------------*/
  1726.     if (AUTO_POWER)
  1727.     {
  1728.         if (result)
  1729.         {
  1730.             w32_modis_poweron_log(MMI_TRUE);
  1731.             ShutdownSystemOperation();
  1732.         }
  1733.         else
  1734.         {
  1735.             w32_modis_poweron_log(MMI_FALSE);
  1736.         }
  1737.     }
  1738. }
  1739. #endif /* MMI_ON_HARDWARE_P */
  1740. #endif /* __MTK_TARGET__ */