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

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.  *
  37.  * Filename:
  38.  * ---------
  39.  *  FlightMode.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *  MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  This file is intends for phone setup application
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *==============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * removed!
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * removed!
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * removed!
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * removed!
  178.  *
  179.  * removed!
  180.  * removed!
  181.  * removed!
  182.  *
  183.  * removed!
  184.  * removed!
  185.  * removed!
  186.  *
  187.  * removed!
  188.  * removed!
  189.  * removed!
  190.  *
  191.  * removed!
  192.  * removed!
  193.  * removed!
  194.  *
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  *
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  *
  231.  * removed!
  232.  * removed!
  233.  * removed!
  234.  *
  235.  * removed!
  236.  * removed!
  237.  * removed!
  238.  *
  239.  * removed!
  240.  * removed!
  241.  * removed!
  242.  *
  243.  * removed!
  244.  * removed!
  245.  * removed!
  246.  *
  247.  * removed!
  248.  * removed!
  249.  * removed!
  250.  *
  251.  * removed!
  252.  * removed!
  253.  * removed!
  254.  *
  255.  * removed!
  256.  * removed!
  257.  * removed!
  258.  *
  259.  * removed!
  260.  * removed!
  261.  * removed!
  262.  *
  263.  * removed!
  264.  * removed!
  265.  * removed!
  266.  *
  267.  * removed!
  268.  * removed!
  269.  * removed!
  270.  *
  271.  * removed!
  272.  * removed!
  273.  * removed!
  274.  *
  275.  * removed!
  276.  * removed!
  277.  * removed!
  278.  *
  279.  * removed!
  280.  * removed!
  281.  * removed!
  282.  *
  283.  * removed!
  284.  * removed!
  285.  * removed!
  286.  *
  287.  * removed!
  288.  * removed!
  289.  * removed!
  290.  *
  291.  * removed!
  292.  * removed!
  293.  * removed!
  294.  *
  295.  * removed!
  296.  * removed!
  297.  * removed!
  298.  *
  299.  * removed!
  300.  * removed!
  301.  * removed!
  302.  *
  303.  * removed!
  304.  * removed!
  305.  * removed!
  306.  *
  307.  * removed!
  308.  * removed!
  309.  * removed!
  310.  *
  311.  *------------------------------------------------------------------------------
  312.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  313.  *============================================================================== 
  314.  *******************************************************************************/
  315. #include "MMI_features.h"       /* Robin 1217 */
  316. #include "StdC.h"
  317. #include "L4Dr1.h"
  318. #include "PixtelDataTypes.h"
  319. #include "wgui_categories.h"
  320. #include "wgui_categories_inputs.h"
  321. #include "wgui_categories_popup.h"
  322. #include "CustDataRes.h"
  323. #include "CustMenuRes.h"
  324. #include "EventsGProt.h"
  325. #include "DebugInitDef.h"
  326. #include "HistoryGprot.h"
  327. #include "ProtocolEvents.h"
  328. #include "CommonScreens.h"
  329. #include "Globaldefs.h"
  330. #include "NVRAMType.h"
  331. #include "NVRAMProt.h"
  332. #include "NVRAMEnum.h"
  333. #include "SettingsGexdcl.h"
  334. #include "settingGprots.h"
  335. #include "SettingDefs.h"
  336. #include "MainMenuDef.h"        /* MAIN_MENU_TITLE_SETTINGS_ICON */
  337. #include "QueueGProt.h" /* Osl Send Message */
  338. #include "settingprot.h"        /* PhoneSetup Prototype */
  339. #include "SettingProfile.h"     /* WARNING_TONE */
  340. #include "MessagesExDcl.h"      /* GetChildMenuIDIndexByParentMenuID()  */
  341. #include "PhoneSetup.h"
  342. #include "PhoneSetupGprots.h"
  343. #include "SimDetectionDef.h"    /* for g_pwr_context */
  344. #include "SimDetectionGprot.h"
  345. #include "wgui_status_icons.h"
  346. #include "GlobalScrEnum.h"      /* diamond, 2006/01/01 Force to draw the background */
  347. #include "FlightModeGProt.h"
  348. #ifdef __FLIGHT_MODE_SUPPORT__
  349. #include "SimDetectionGexdcl.h"
  350. #include "NetworkSetupGProt.h"
  351. #include "IdleAppProt.h"        /* diamond, 2005/09/21 lock keypad by pressing RSK and # in flight mode */
  352. #include "CallSetUp.h"  /* diamond, 2005/09/28 restore signal icon with line switch */
  353. #ifdef __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__
  354. #include "StatusIconRes.h"
  355. #endif 
  356. #ifdef __MMI_BT_HP_SUPPORT__
  357. #include "BTMMIHPGprots.h"
  358. #include "BTMMIHP.h"
  359. #endif /* __MMI_BT_HP_SUPPORT__ */ 
  360. #ifdef __MMI_BT_SUPPORT__
  361. #include "BTMMIScrGprots.h"
  362. #endif 
  363. #ifdef __MMI_IRDA_SUPPORT__
  364. #include "IrdaMMIGprots.h"
  365. #include "IrdaMMIScr.h"
  366. extern void mmi_irda_exec_close_menu(void);
  367. #endif /* __MMI_IRDA_SUPPORT__ */ 
  368. #include "MessagesMiscell.h"
  369. #include "SMSApi.h"
  370. #include "SMSStruct.h"
  371. #ifdef MMI_ON_HARDWARE_P
  372. #include "Wapadp.h"
  373. #endif 
  374. #ifdef __MMI_BT_PROFILE__
  375. #include "ProfileGprots.h"
  376. #endif 
  377. #ifdef __MMI_ENGINEER_MODE__
  378. #include "EngineerModeDef.h"
  379. #endif
  380. #ifdef __MMI_WLAN_FEATURES__
  381. #include "DataAccountGProt.h"
  382. #include "NetworkSetupDefs.h"
  383. #endif /* __MMI_WLAN_FEATURES__ */
  384. #endif /* __FLIGHT_MODE_SUPPORT__ */ 
  385. /* diamond, 2005/07/05 Flight mode */
  386. /*
  387.  * External Variable
  388.  */
  389. extern PHNSET_CNTX g_phnset_cntx;
  390. extern U8 gSignalStrengthLevel;
  391. /*
  392.  * Local Variable
  393.  */
  394. typedef struct _phnset_f_mode_req
  395. {
  396.     FuncPtr phnset_flight_mode_req;
  397.     U8 state;
  398. } PHNSETFMODEREQ;
  399. static PHNSETFMODEREQ mmi_phnset_f_mode_req[] = 
  400. {
  401.     {PhnsetFlightModeSelectionReq, 1},
  402. #ifdef __MMI_WLAN_FEATURES__
  403.     {mmi_flight_mode_switch_wlan, 1},
  404. #endif
  405. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  406.     {mmi_flight_mode_switch_bluetooth, 1},
  407. #endif
  408. #ifdef __MMI_IRDA_SUPPORT__
  409.     {mmi_flight_mode_switch_irda, 1},
  410. #endif
  411.     {NULL, 0} /* dummy one, please add callbacks before this entity */
  412. };
  413. U32 StatusIconFlags[30];    /* Need to sync with RemoveStatusIconsForSimRemoved in SimDetection.c */
  414. /*****************************************************************************
  415.  * FUNCTION
  416.  *  PhnsetFlightModeHideButSaveStatusIcon
  417.  * DESCRIPTION
  418.  *  Hide the specific status icons if they are required to show in flight mode
  419.  * PARAMETERS
  420.  *  icon_ID         [IN]        
  421.  *  icon_flag       [IN]        The flag for display or hide
  422.  *  S16   icon ID     the specific icon(?)
  423.  * RETURNS
  424.  *  void
  425.  *****************************************************************************/
  426. MMI_BOOL PhnsetFlightModeHideButSaveStatusIcon(S16 icon_ID, U32 icon_flag)
  427. {
  428.     /*----------------------------------------------------------------*/
  429.     /* Local Variables                                                */
  430.     /*----------------------------------------------------------------*/
  431.     MMI_BOOL rtn = MMI_TRUE;
  432.     /*----------------------------------------------------------------*/
  433.     /* Code Body                                                      */
  434.     /*----------------------------------------------------------------*/
  435. #ifdef __MMI_WLAN_FEATURES__
  436.     if (mmi_bootup_is_sim_valid() == MMI_FALSE && mmi_netset_get_active_preferred_mode() != P_GSM_ONLY)
  437.     {
  438.         if (icon_ID == STATUS_ICON_UNREAD_EMAIL_L1L2 || icon_ID == STATUS_ICON_UNREAD_EMAIL_L1|| icon_ID == STATUS_ICON_UNREAD_EMAIL_L2
  439.     #ifdef __MMI_POC__
  440.         || icon_ID == STATUS_ICON_POC
  441.     #endif
  442.     #ifdef __MMI_IMPS__
  443.         || icon_ID == STATUS_ICON_IMPS_MSG || icon_ID == STATUS_ICON_IMPS_LOGIN
  444.     #endif
  445.         )
  446.         {
  447.             return MMI_FALSE;
  448.         }
  449.     }
  450. #endif /* __MMI_WLAN_FEATURES__ */
  451.     switch (icon_ID)
  452.     {
  453.         case STATUS_ICON_ROAMING:
  454.             StatusIconFlags[0] = icon_flag;
  455.             break;
  456.         case STATUS_ICON_CALL_DIVERT_L1L2:
  457.             StatusIconFlags[1] = icon_flag;
  458.             break;
  459.     #ifdef __MMI_CFU_SEPARATE_LINE__
  460.         case STATUS_ICON_CALL_DIVERT_L1:
  461.             StatusIconFlags[2] = icon_flag;
  462.             break;
  463.         case STATUS_ICON_CALL_DIVERT_L2:
  464.             StatusIconFlags[3] = icon_flag;
  465.             break;
  466.     #endif /* __MMI_CFU_SEPARATE_LINE__ */ 
  467.         case STATUS_ICON_INCOMING_SMS:
  468.             StatusIconFlags[4] = icon_flag;
  469.             break;
  470.         case STATUS_ICON_MISSED_CALL:
  471.             StatusIconFlags[5] = icon_flag;
  472.             break;
  473.     #ifndef __MMI_SUBLCD_SHORT_STATUSICON_LIST__
  474.         case STATUS_ICON_SUBLCD_MISSED_CALL:
  475.             StatusIconFlags[6] = icon_flag;
  476.             break;
  477.     #endif /* __MMI_SUBLCD_SHORT_STATUSICON_LIST__ */ 
  478.         case STATUS_ICON_UNREAD_VOICE_L1L2:
  479.             StatusIconFlags[7] = icon_flag;
  480.             break;
  481.         case STATUS_ICON_UNREAD_VOICE_L1:
  482.             StatusIconFlags[8] = icon_flag;
  483.             break;
  484.         case STATUS_ICON_UNREAD_VOICE_L2:
  485.             StatusIconFlags[9] = icon_flag;
  486.             break;
  487.         case STATUS_ICON_UNREAD_FAX_L1L2:
  488.             StatusIconFlags[10] = icon_flag;
  489.             break;
  490.         case STATUS_ICON_UNREAD_FAX_L1:
  491.             StatusIconFlags[11] = icon_flag;
  492.             break;
  493.         case STATUS_ICON_UNREAD_FAX_L2:
  494.             StatusIconFlags[12] = icon_flag;
  495.             break;
  496.         case STATUS_ICON_UNREAD_EMAIL_L1L2:
  497.             StatusIconFlags[13] = icon_flag;
  498.             break;
  499.         case STATUS_ICON_UNREAD_EMAIL_L1:
  500.             StatusIconFlags[14] = icon_flag;
  501.             break;
  502.         case STATUS_ICON_UNREAD_EMAIL_L2:
  503.             StatusIconFlags[15] = icon_flag;
  504.             break;
  505.         case STATUS_ICON_SUBLCD_SMS:
  506.             StatusIconFlags[16] = icon_flag;
  507.             break;
  508.         case STATUS_ICON_MMS_UNREAD:
  509.             StatusIconFlags[17] = icon_flag;
  510.             break;
  511.         case STATUS_ICON_MMS_BUSY:
  512.             StatusIconFlags[18] = icon_flag;
  513.             break;
  514.         case STATUS_ICON_CHAT_INDICATION_ROOM1:
  515.             StatusIconFlags[19] = icon_flag;
  516.             break;
  517.         case STATUS_ICON_CHAT_INDICATION_ROOM2:
  518.             StatusIconFlags[20] = icon_flag;
  519.             break;
  520.         case STATUS_ICON_WAP:
  521.             StatusIconFlags[21] = icon_flag;
  522.             break;
  523.     /*
  524.      *  case STATUS_ICON_NETWORK_CIPHER_GSM:
  525.      *      StatusIconFlags[22] = icon_flag;
  526.      *      break;
  527.      *  case STATUS_ICON_NETWORK_CIPHER_GPRS:
  528.      *      StatusIconFlags[23] = icon_flag;
  529.      *      break;
  530.      */
  531.     #ifndef __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__
  532.         case STATUS_ICON_ALTERNATE_LINE_L1:
  533.             StatusIconFlags[24] = icon_flag;
  534.             break;
  535.         case STATUS_ICON_ALTERNATE_LINE_L2:
  536.             StatusIconFlags[25] = icon_flag;
  537.             break;
  538.     #endif /* __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__ */ 
  539.     #ifdef __MMI_POC__
  540.         case STATUS_ICON_POC:
  541.             StatusIconFlags[26] = icon_flag;
  542.             break;
  543.     #endif /* __MMI_POC__ */ 
  544.     #ifdef __MMI_IMPS__
  545.         case STATUS_ICON_IMPS_MSG:
  546.             StatusIconFlags[27] = icon_flag;
  547.             break;
  548.         case STATUS_ICON_IMPS_LOGIN:
  549.             StatusIconFlags[28] = icon_flag;
  550.             break;
  551.     #endif /* __MMI_IMPS__ */ 
  552.         default:
  553.             rtn = MMI_FALSE;
  554.             break;
  555.     }
  556.     return rtn;
  557. }
  558. /*****************************************************************************
  559.  * FUNCTION
  560.  *  PhnsetFlightModeQueryBackground
  561.  * DESCRIPTION
  562.  *  
  563.  * PARAMETERS
  564.  *  void
  565.  * RETURNS
  566.  *  void
  567.  *****************************************************************************/
  568. void PhnsetFlightModeQueryBackground(void)
  569. {
  570.     /*----------------------------------------------------------------*/
  571.     /* Local Variables                                                */
  572.     /*----------------------------------------------------------------*/
  573.     /*----------------------------------------------------------------*/
  574.     /* Code Body                                                      */
  575.     /*----------------------------------------------------------------*/
  576.     /* diamond, 2006/01/01 Force to draw the background */
  577.     EntryNewScreen(GLOBAL_SCR_DUMMY, NULL, PhnsetFlightModeQueryBackground, NULL);
  578.     ShowCategory61Screen(NULL, IMG_BOOTUP_SCANNING_LOGO, NULL);
  579. }
  580. #ifdef __FLIGHT_MODE_SUPPORT__
  581. void mmi_msg_set_msg_icon(U8, U8);
  582. extern void SetCat165TimerExpireFunc(FuncPtr);
  583. extern U32 get_status_icon_flag(S16 icon_ID);
  584. extern void set_status_icon_flag(S16 icon_ID, U32 value);
  585. extern void RemoveStatusIconsForSimRemoved(void);
  586. #ifndef MMI_ON_HARDWARE_P
  587. #define NVRAM_EF_SYS_CACHE_OCTET_SIZE 8
  588. #endif 
  589. pBOOL gPowerOnWithFlightMode = MMI_FALSE;
  590. pBOOL gSetModeFromMenu = MMI_FALSE;
  591. /*****************************************************************************
  592.  * FUNCTION
  593.  *  PhnsetFlightModeSaveStatusIconFlags
  594.  * DESCRIPTION
  595.  *  Save the status icons status before enter flight mode
  596.  * PARAMETERS
  597.  *  void
  598.  * RETURNS
  599.  *  void
  600.  *****************************************************************************/
  601. void PhnsetFlightModeSaveStatusIconFlags(void)
  602. {
  603.     /*----------------------------------------------------------------*/
  604.     /* Local Variables                                                */
  605.     /*----------------------------------------------------------------*/
  606.     /*----------------------------------------------------------------*/
  607.     /* Code Body                                                      */
  608.     /*----------------------------------------------------------------*/
  609.     StatusIconFlags[0] = get_status_icon_flag(STATUS_ICON_ROAMING);
  610.     StatusIconFlags[1] = get_status_icon_flag(STATUS_ICON_CALL_DIVERT_L1L2);
  611. #ifdef __MMI_CFU_SEPARATE_LINE__
  612.     StatusIconFlags[2] = get_status_icon_flag(STATUS_ICON_CALL_DIVERT_L1);
  613.     StatusIconFlags[3] = get_status_icon_flag(STATUS_ICON_CALL_DIVERT_L2);
  614. #endif /* __MMI_CFU_SEPARATE_LINE__ */ 
  615.     StatusIconFlags[4] = get_status_icon_flag(STATUS_ICON_INCOMING_SMS);
  616.     StatusIconFlags[5] = get_status_icon_flag(STATUS_ICON_MISSED_CALL);
  617. #ifndef __MMI_SUBLCD_SHORT_STATUSICON_LIST__
  618.     StatusIconFlags[6] = get_status_icon_flag(STATUS_ICON_SUBLCD_MISSED_CALL);
  619. #endif 
  620.     StatusIconFlags[7] = get_status_icon_flag(STATUS_ICON_UNREAD_VOICE_L1L2);
  621.     StatusIconFlags[8] = get_status_icon_flag(STATUS_ICON_UNREAD_VOICE_L1);
  622.     StatusIconFlags[9] = get_status_icon_flag(STATUS_ICON_UNREAD_VOICE_L2);
  623.     StatusIconFlags[10] = get_status_icon_flag(STATUS_ICON_UNREAD_FAX_L1L2);
  624.     StatusIconFlags[11] = get_status_icon_flag(STATUS_ICON_UNREAD_FAX_L1);
  625.     StatusIconFlags[12] = get_status_icon_flag(STATUS_ICON_UNREAD_FAX_L2);
  626.     StatusIconFlags[13] = get_status_icon_flag(STATUS_ICON_UNREAD_EMAIL_L1L2);
  627.     StatusIconFlags[14] = get_status_icon_flag(STATUS_ICON_UNREAD_EMAIL_L1);
  628.     StatusIconFlags[15] = get_status_icon_flag(STATUS_ICON_UNREAD_EMAIL_L2);
  629.     StatusIconFlags[16] = get_status_icon_flag(STATUS_ICON_SUBLCD_SMS);
  630.     StatusIconFlags[17] = get_status_icon_flag(STATUS_ICON_MMS_UNREAD);
  631.     StatusIconFlags[18] = get_status_icon_flag(STATUS_ICON_MMS_BUSY);
  632.     StatusIconFlags[19] = get_status_icon_flag(STATUS_ICON_CHAT_INDICATION_ROOM1);
  633.     StatusIconFlags[20] = get_status_icon_flag(STATUS_ICON_CHAT_INDICATION_ROOM2);
  634.     StatusIconFlags[21] = get_status_icon_flag(STATUS_ICON_WAP);
  635. /*
  636.  *  StatusIconFlags[22] = get_status_icon_flag(STATUS_ICON_NETWORK_CIPHER_GSM);
  637.  *  StatusIconFlags[23] = get_status_icon_flag(STATUS_ICON_NETWORK_CIPHER_GPRS);
  638.  */
  639. #ifndef __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__
  640.     StatusIconFlags[24] = get_status_icon_flag(STATUS_ICON_ALTERNATE_LINE_L1);
  641.     StatusIconFlags[25] = get_status_icon_flag(STATUS_ICON_ALTERNATE_LINE_L2);
  642. #endif /* __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__ */ 
  643. #ifdef __MMI_POC__
  644.     StatusIconFlags[26] = get_status_icon_flag(STATUS_ICON_POC);
  645. #endif 
  646. #ifdef __MMI_IMPS__
  647.     StatusIconFlags[27] = get_status_icon_flag(STATUS_ICON_IMPS_MSG);
  648.     StatusIconFlags[28] = get_status_icon_flag(STATUS_ICON_IMPS_LOGIN);
  649. #endif /* __MMI_IMPS__ */ 
  650. }
  651. /*****************************************************************************
  652.  * FUNCTION
  653.  *  PhnsetFlightModeRestoreStatusIconFlags
  654.  * DESCRIPTION
  655.  *  Restire the status icons status before enter normal mode
  656.  * PARAMETERS
  657.  *  void
  658.  * RETURNS
  659.  *  void
  660.  *****************************************************************************/
  661. void PhnsetFlightModeRestoreStatusIconFlags(void)
  662. {
  663.     /*----------------------------------------------------------------*/
  664.     /* Local Variables                                                */
  665.     /*----------------------------------------------------------------*/
  666.     /*----------------------------------------------------------------*/
  667.     /* Code Body                                                      */
  668.     /*----------------------------------------------------------------*/
  669.     set_status_icon_flag(STATUS_ICON_ROAMING, StatusIconFlags[0]);
  670.     set_status_icon_flag(STATUS_ICON_CALL_DIVERT_L1L2, StatusIconFlags[1]);
  671. #ifdef __MMI_CFU_SEPARATE_LINE__
  672.     set_status_icon_flag(STATUS_ICON_CALL_DIVERT_L1, StatusIconFlags[2]);
  673.     set_status_icon_flag(STATUS_ICON_CALL_DIVERT_L2, StatusIconFlags[3]);
  674. #endif /* __MMI_CFU_SEPARATE_LINE__ */ 
  675.     set_status_icon_flag(STATUS_ICON_INCOMING_SMS, StatusIconFlags[4]);
  676.     set_status_icon_flag(STATUS_ICON_MISSED_CALL, StatusIconFlags[5]);
  677. #ifndef __MMI_SUBLCD_SHORT_STATUSICON_LIST__
  678.     set_status_icon_flag(STATUS_ICON_SUBLCD_MISSED_CALL, StatusIconFlags[6]);
  679. #endif 
  680.     set_status_icon_flag(STATUS_ICON_UNREAD_VOICE_L1L2, StatusIconFlags[7]);
  681.     set_status_icon_flag(STATUS_ICON_UNREAD_VOICE_L1, StatusIconFlags[8]);
  682.     set_status_icon_flag(STATUS_ICON_UNREAD_VOICE_L2, StatusIconFlags[9]);
  683.     set_status_icon_flag(STATUS_ICON_UNREAD_FAX_L1L2, StatusIconFlags[10]);
  684.     set_status_icon_flag(STATUS_ICON_UNREAD_FAX_L1, StatusIconFlags[11]);
  685.     set_status_icon_flag(STATUS_ICON_UNREAD_FAX_L2, StatusIconFlags[12]);
  686.     set_status_icon_flag(STATUS_ICON_UNREAD_EMAIL_L1L2, StatusIconFlags[13]);
  687.     set_status_icon_flag(STATUS_ICON_UNREAD_EMAIL_L1, StatusIconFlags[14]);
  688.     set_status_icon_flag(STATUS_ICON_UNREAD_EMAIL_L2, StatusIconFlags[15]);
  689.     set_status_icon_flag(STATUS_ICON_SUBLCD_SMS, StatusIconFlags[16]);
  690.     set_status_icon_flag(STATUS_ICON_MMS_UNREAD, StatusIconFlags[17]);
  691.     set_status_icon_flag(STATUS_ICON_MMS_BUSY, StatusIconFlags[18]);
  692.     set_status_icon_flag(STATUS_ICON_CHAT_INDICATION_ROOM1, StatusIconFlags[19]);
  693.     set_status_icon_flag(STATUS_ICON_CHAT_INDICATION_ROOM2, StatusIconFlags[20]);
  694.     set_status_icon_flag(STATUS_ICON_WAP, StatusIconFlags[21]);
  695. /*
  696.  *  set_status_icon_flag(STATUS_ICON_NETWORK_CIPHER_GSM,    StatusIconFlags[22]);
  697.  *  set_status_icon_flag(STATUS_ICON_NETWORK_CIPHER_GPRS,   StatusIconFlags[23]);
  698.  */
  699. #ifdef __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__
  700.     /* diamond, 2005/09/28 restore signal icon with line switch */
  701.     if (mmi_bootup_is_sim_valid())  /* diamond, 2006/02/19 Not update line id if sim is not inserted after mode switch */
  702.     {
  703.         if (g_callset_context.LineID == LINE1)
  704.         {
  705.             ChangeStatusIconImage(STATUS_ICON_SIGNAL_STRENGTH, IMG_SI_SIGNAL_STRENGTH_L1);
  706.         }
  707.         else
  708.         {
  709.             ChangeStatusIconImage(STATUS_ICON_SIGNAL_STRENGTH, IMG_SI_SIGNAL_STRENGTH_L2);
  710.         }
  711.     }
  712. #else /* __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__ */ 
  713.     set_status_icon_flag(STATUS_ICON_ALTERNATE_LINE_L1, StatusIconFlags[24]);
  714.     set_status_icon_flag(STATUS_ICON_ALTERNATE_LINE_L2, StatusIconFlags[25]);
  715. #endif /* __MMI_STATUS_ICON_SIGNAL_WITH_LINE_SWITCH__ */ 
  716. #ifdef __MMI_POC__
  717.     set_status_icon_flag(STATUS_ICON_POC, StatusIconFlags[26]);
  718. #endif 
  719. #ifdef __MMI_IMPS__
  720.     set_status_icon_flag(STATUS_ICON_IMPS_MSG, StatusIconFlags[27]);
  721.     set_status_icon_flag(STATUS_ICON_IMPS_LOGIN, StatusIconFlags[28]);
  722. #endif /* __MMI_IMPS__ */ 
  723. }
  724. /*****************************************************************************
  725.  * FUNCTION
  726.  *  HighlightPhnsetFlightMode
  727.  * DESCRIPTION
  728.  *  This function is highlight handler for Phone Setup -> Flight Mode
  729.  * PARAMETERS
  730.  *  void
  731.  * RETURNS
  732.  *  void
  733.  *****************************************************************************/
  734. void HighlightPhnsetFlightMode(void)
  735. {
  736.     /*----------------------------------------------------------------*/
  737.     /* Local Variables                                                */
  738.     /*----------------------------------------------------------------*/
  739.     /*----------------------------------------------------------------*/
  740.     /* Code Body                                                      */
  741.     /*----------------------------------------------------------------*/
  742.     /* 1 Change left soft key icon and label */
  743.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  744.     /* 2 Change right soft key icon and label */
  745.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  746. #ifdef __MTK_TARGET__
  747.     SetLeftSoftkeyFunction(EntryPhnsetFlightMode, KEY_EVENT_UP);
  748.     SetKeyHandler(EntryPhnsetFlightMode, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  749. #else /* __MTK_TARGET__ */ 
  750.     SetLeftSoftkeyFunction(PopupNoSupport, KEY_EVENT_UP);
  751.     SetKeyHandler(PopupNoSupport, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  752. #endif /* __MTK_TARGET__ */ 
  753.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  754.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  755. }
  756. /*****************************************************************************
  757.  * FUNCTION
  758.  *  HintPhnsetFlightMode
  759.  * DESCRIPTION
  760.  *  This function is hint handling function for Phone Setup -> Flight Mode
  761.  * PARAMETERS
  762.  *  index       [IN]        
  763.  * RETURNS
  764.  *  void
  765.  *****************************************************************************/
  766. void HintPhnsetFlightMode(U16 index)
  767. {
  768.     /*----------------------------------------------------------------*/
  769.     /* Local Variables                                                */
  770.     /*----------------------------------------------------------------*/
  771.     S16 error;
  772.     U8 data[NVRAM_EF_SYS_CACHE_OCTET_SIZE];
  773.     /*----------------------------------------------------------------*/
  774.     /* Code Body                                                      */
  775.     /*----------------------------------------------------------------*/
  776.     ReadRecord(NVRAM_EF_SYS_CACHE_OCTET_LID, 2, &data, NVRAM_EF_SYS_CACHE_OCTET_SIZE, &error);
  777.     g_phnset_cntx.curFlightMode = data[0];
  778.     switch (g_phnset_cntx.curFlightMode)
  779.     {
  780.         case FLIGHTMODE_OFF:    /* 0x00 */
  781.             pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_FLIGHT_MODE_NORMAL));
  782.             break;
  783.         case FLIGHTMODE_SILENT: /* 0x01 */
  784.                 pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_FLIGHT_MODE_SILENT));
  785.             break;
  786.         case FLIGHTMODE_QUERY:  /* 0x02 */
  787.             pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_FLIGHT_MODE_QUERY));
  788.             break;
  789.         default:
  790.             data[0] = FLIGHTMODE_OFF;
  791.             data[1] = FLIGHTMODE_OFF;
  792.             g_phnset_cntx.curFlightMode = 0;
  793.         #ifdef __MMI_WLAN_FEATURES__
  794.             g_phnset_cntx.curFlightMode2 = 0;
  795.         #endif
  796.             WriteRecord(NVRAM_EF_SYS_CACHE_OCTET_LID, 2, &data, NVRAM_EF_SYS_CACHE_OCTET_SIZE, &error);
  797.             pfnUnicodeStrcpy((PS8) hintData[index], (PS8) GetString(STR_FLIGHT_MODE_NORMAL));
  798.             break;
  799.     }
  800. }
  801. /*****************************************************************************
  802.  * FUNCTION
  803.  *  HiliteHandlerFlightMode
  804.  * DESCRIPTION
  805.  *  Highlight handler for mode selection
  806.  * PARAMETERS
  807.  *  index       [IN]        
  808.  * RETURNS
  809.  *  void
  810.  *****************************************************************************/
  811. void HiliteHandlerFlightMode(S32 index)
  812. {
  813.     /*----------------------------------------------------------------*/
  814.     /* Local Variables                                                */
  815.     /*----------------------------------------------------------------*/
  816.     /*----------------------------------------------------------------*/
  817.     /* Code Body                                                      */
  818.     /*----------------------------------------------------------------*/
  819.     g_phnset_cntx.selFlightMode = (U8) index;
  820.     return;
  821. }
  822. /*****************************************************************************
  823.  * FUNCTION
  824.  *  EntryFlightModeProgress
  825.  * DESCRIPTION
  826.  *  Progressing screen for mode switch
  827.  * PARAMETERS
  828.  *  void
  829.  * RETURNS
  830.  *  void
  831.  *****************************************************************************/
  832. void EntryFlightModeProgress(void)
  833. {
  834.     /*----------------------------------------------------------------*/
  835.     /* Local Variables                                                */
  836.     /*----------------------------------------------------------------*/
  837.     /*----------------------------------------------------------------*/
  838.     /* Code Body                                                      */
  839.     /*----------------------------------------------------------------*/
  840.     EntryNewScreen(SCR_FLIGHT_MODE_PROGRESS, NULL, EntryFlightModeProgress, NULL);
  841.     SetKeyHandler(NULL, KEY_END, KEY_EVENT_DOWN);
  842.     SetKeyHandler(NULL, KEY_END, KEY_EVENT_UP);
  843.     ShowCategory66Screen(
  844.         STR_MENU_FLIGHT_MODE,
  845.         0,
  846.         0,
  847.         0,
  848.         0,
  849.         0,
  850.         (PU8) GetString(STR_FLIGHT_MODE_PROGRESS),
  851.         IMG_FLIGHT_MODE_PROGRESS,
  852.         NULL);
  853. }
  854. /*****************************************************************************
  855.  * FUNCTION
  856.  *  mmi_phnset_flight_mode_camp_on_tone_hdlr
  857.  * DESCRIPTION
  858.  *  Timeout handler to play camp on tone after switch to normal mode
  859.  * PARAMETERS
  860.  *  void
  861.  * RETURNS
  862.  *  void
  863.  *****************************************************************************/
  864. static void mmi_phnset_flight_mode_camp_on_tone_hdlr(void)
  865. {
  866.     /*----------------------------------------------------------------*/
  867.     /* Local Variables                                                */
  868.     /*----------------------------------------------------------------*/
  869.     /*----------------------------------------------------------------*/
  870.     /* Code Body                                                      */
  871.     /*----------------------------------------------------------------*/
  872.     if (mmi_idle_is_on_idle_screen())
  873.     {
  874.         playRequestedTone(CAMP_ON_TONE);
  875.     }
  876.     else
  877.     {
  878.         /* start timer again if */
  879.         StartTimer(
  880.             FLIGHT_MODE_CAMP_ON_TONE_TIMER,
  881.             UI_POPUP_NOTIFYDURATION_TIME,
  882.             mmi_phnset_flight_mode_camp_on_tone_hdlr);
  883.     }
  884. }
  885. #ifdef __MMI_BT_SUPPORT__
  886. static pBOOL btNotReady = MMI_FALSE;
  887. static pBOOL btGotRsp = MMI_FALSE;
  888. #endif /* __MMI_BT_SUPPORT__ */ 
  889. /*****************************************************************************
  890.  * FUNCTION
  891.  *  mmi_phnset_flight_mode_selection_finish
  892.  * DESCRIPTION
  893.  *  Finish to perform mode switch
  894.  * PARAMETERS
  895.  *  void
  896.  * RETURNS
  897.  *  void
  898.  *****************************************************************************/
  899. void mmi_phnset_flight_mode_selection_finish(void)
  900. {
  901.     /*----------------------------------------------------------------*/
  902.     /* Local Variables                                                */
  903.     /*----------------------------------------------------------------*/
  904.     /*----------------------------------------------------------------*/
  905.     /* Code Body                                                      */
  906.     /*----------------------------------------------------------------*/
  907.     PRINT_INFORMATION(("@@@@@ Flight mode: switch done @@@@@"));
  908. #ifdef __MMI_BT_SUPPORT__
  909.     if (!gSetModeFromMenu)
  910.     {
  911.         /* BT always call this callback after set flight mode */
  912.         /* MMI doesn't have screen for set mode in power on period */
  913.         return;
  914.     }
  915.     if (btGotRsp)
  916.     {
  917.         return;
  918.     }
  919.     StopTimer(FLIGHT_MODE_DEACTIVATE_BT_TIMER);
  920. #endif /* __MMI_BT_SUPPORT__ */ 
  921.     /* do not call this fuction for BT power on by init */
  922.     if (GetActiveScreenId() != SCR_FLIGHT_MODE_PROGRESS)
  923.     {
  924.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);    /* progressing */
  925.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_SELECTION);   /* flight mode menu */
  926.         DeleteScreenIfPresent(SCR9003_INITIALSETUP);        /* phone setup */
  927.         DeleteScreenIfPresent(SCR9000_SETTINGS);            /* setting */
  928.         DeleteScreenIfPresent(MAIN_MENU_SCREENID);          /* main menu */
  929.         DeleteScreenIfPresent(SCR_SIM_OPTION);              /* sim option menu */
  930.         if (mmi_bootup_is_sim_valid() && mmi_idle_is_on_idle_screen())
  931.         {
  932.             /* already in idle screen because mode switch is interrupted by other application */
  933.             EntryIdleScreen();
  934.         }
  935.         if (g_pwr_context.CurrentServiceType == FULL_SERVICE)
  936.         {
  937.             /* play camp on tone */
  938.             mmi_phnset_flight_mode_camp_on_tone_hdlr();
  939.         }
  940.     }
  941.     else
  942.     {
  943.         DisplayPopupCallBack(
  944.             (PU8) GetString(STR_GLOBAL_DONE),
  945.             IMG_GLOBAL_ACTIVATED,
  946.             1,
  947.             UI_POPUP_NOTIFYDURATION_TIME,
  948.             SUCCESS_TONE,
  949.             DisplayIdleScreen);
  950.         if (IsScreenPresent(SCR_SIM_INSERTION))
  951.         {
  952.             DeleteUptoScrID(SCR_SIM_INSERTION);
  953.         }
  954.         else if (IsScreenPresent(SCR_SIM_BLOCK))
  955.         {
  956.             DeleteUptoScrID(SCR_SIM_BLOCK);
  957.         }
  958.         else
  959.         {
  960.             DeleteUptoScrID(IDLE_SCREEN_ID);
  961.         }
  962.         if (g_pwr_context.CurrentServiceType == FULL_SERVICE)
  963.         {
  964.             /* play camp on tone */
  965.             StartTimer(
  966.                 FLIGHT_MODE_CAMP_ON_TONE_TIMER,
  967.                 UI_POPUP_NOTIFYDURATION_TIME,
  968.                 mmi_phnset_flight_mode_camp_on_tone_hdlr);
  969.         }
  970.     }
  971.     gSetModeFromMenu = MMI_FALSE;
  972. #ifdef __MMI_BT_SUPPORT__
  973.     btGotRsp = MMI_TRUE;
  974. #endif 
  975. }
  976. #ifdef __MMI_BT_SUPPORT__
  977. /*****************************************************************************
  978.  * FUNCTION
  979.  *  mmi_phnset_flight_mode_bt_timeout_hdlr
  980.  * DESCRIPTION
  981.  *  Timeout handler for no response from BT
  982.  * PARAMETERS
  983.  *  void
  984.  * RETURNS
  985.  *  void
  986.  *****************************************************************************/
  987. static void mmi_phnset_flight_mode_bt_timeout_hdlr(void)
  988. {
  989.     /*----------------------------------------------------------------*/
  990.     /* Local Variables                                                */
  991.     /*----------------------------------------------------------------*/
  992.     /*----------------------------------------------------------------*/
  993.     /* Code Body                                                      */
  994.     /*----------------------------------------------------------------*/
  995.     PRINT_INFORMATION(("@@@@@ Flight mode: BT deactivation timeout @@@@@"));
  996.     /* Temporarily don't set BT not ready flag */
  997.     /* btNotReady = MMI_TRUE; */
  998.     //mmi_phnset_flight_mode_selection_finish();
  999.     mmi_phnset_switch_flight_mode();
  1000. }
  1001. #endif /* __MMI_BT_SUPPORT__ */ 
  1002. /*****************************************************************************
  1003.  * FUNCTION
  1004.  *  mmi_flight_mode_switch_bluetooth
  1005.  * DESCRIPTION
  1006.  *  Switch BT after flight mode switch
  1007.  * PARAMETERS
  1008.  *  void
  1009.  * RETURNS
  1010.  *  void
  1011.  *****************************************************************************/
  1012. void mmi_flight_mode_switch_bluetooth(void)
  1013. {
  1014. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  1015.     /*----------------------------------------------------------------*/
  1016.     /* Local Variables                                                */
  1017.     /*----------------------------------------------------------------*/
  1018.     U8 btSimPresent;
  1019.     U8 btChipPresent;
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Code Body                                                      */
  1022.     /*----------------------------------------------------------------*/
  1023. #ifdef __MMI_BT_HP_SUPPORT__
  1024.             btSimPresent = mmi_bootup_is_sim_valid();
  1025. #else
  1026.     #ifdef __MMI_BT_SUPPORT__
  1027.         btSimPresent = 1; /* always turn on */
  1028.         #if 0
  1029.             #ifdef __MMI_BT_BCHS_SUPPORT__
  1030. /* under construction !*/
  1031.             #else
  1032. /* under construction !*/
  1033.             #endif
  1034.         #endif /* 0 */
  1035.     #endif /* __MMI_BT_SUPPORT__ */
  1036. #endif /* __MMI_BT_HP_SUPPORT__ */
  1037. #ifdef __MMI_BT_SUPPORT__
  1038.     btChipPresent = !btNotReady;
  1039. #else
  1040.     btChipPresent = 1;
  1041. #endif
  1042.     if (btSimPresent && btChipPresent)
  1043.     {
  1044.         PRINT_INFORMATION(("@@@@@ Flight mode: BT reset @@@@@"));
  1045.         btGotRsp = MMI_FALSE;
  1046.         StartTimer(FLIGHT_MODE_DEACTIVATE_BT_TIMER, 40000, mmi_phnset_flight_mode_bt_timeout_hdlr);
  1047.         if (mmi_bootup_get_active_flight_mode() == FLIGHTMODE_OFF)
  1048.         {
  1049.             mmi_bt_reset_hw_on();
  1050.         }
  1051.         else
  1052.         {
  1053.             mmi_bt_reset_hw_off();
  1054.         }
  1055.     }
  1056.     else
  1057.     {
  1058.         mmi_phnset_switch_flight_mode();
  1059.     }
  1060. #endif /* defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__) */ 
  1061. }
  1062. /*****************************************************************************
  1063.  * FUNCTION
  1064.  *  mmi_flight_mode_switch_irda
  1065.  * DESCRIPTION
  1066.  *  Switch IrDA after flight mode switch
  1067.  * PARAMETERS
  1068.  *  void
  1069.  * RETURNS
  1070.  *  void
  1071.  *****************************************************************************/
  1072. void mmi_flight_mode_switch_irda(void)
  1073. {
  1074.     /*----------------------------------------------------------------*/
  1075.     /* Local Variables                                                */
  1076.     /*----------------------------------------------------------------*/
  1077.     /*----------------------------------------------------------------*/
  1078.     /* Code Body                                                      */
  1079.     /*----------------------------------------------------------------*/
  1080. #ifdef __MMI_IRDA_SUPPORT__
  1081.     if (MMI_IRDASCR_CNTX(irda_state) != MMIR_SCR_IRCLOSE &&
  1082.         mmi_bootup_get_active_flight_mode() == FLIGHTMODE_SILENT)
  1083.     {
  1084.         PRINT_INFORMATION(("@@@@@ Flight mode: IrDA disconnect @@@@@"));
  1085.         if (mmi_irda_is_ircomm_active() == MMI_TRUE)
  1086.         {
  1087.             mmi_irda_ircomm_disconnect_request();
  1088.         }
  1089.         mmi_irda_exec_close_menu();
  1090.     }
  1091. #endif /* __MMI_IRDA_SUPPORT__ */ 
  1092.     mmi_phnset_switch_flight_mode();
  1093. }
  1094. /*****************************************************************************
  1095.  * FUNCTION
  1096.  *  PhnsetFlightModeSelectionRsp
  1097.  * DESCRIPTION
  1098.  *  Response of mode switch
  1099.  * PARAMETERS
  1100.  *  info        [IN]     
  1101.  * RETURNS
  1102.  *  void
  1103.  *****************************************************************************/
  1104. void PhnsetFlightModeSelectionRsp(void *info)
  1105. {
  1106.     /*----------------------------------------------------------------*/
  1107.     /* Local Variables                                                */
  1108.     /*----------------------------------------------------------------*/
  1109.     mmi_nw_cfun_state_rsp_struct *cfun_state_rsp;
  1110.     extern U8 lastNwStatus;
  1111.     /*----------------------------------------------------------------*/
  1112.     /* Code Body                                                      */
  1113.     /*----------------------------------------------------------------*/
  1114.     cfun_state_rsp = (mmi_nw_cfun_state_rsp_struct*) info;
  1115.     ClearProtocolEventHandler(PRT_NW_CFUN_STATE_RSP);
  1116. #ifdef MMI_ON_HARDWARE_P
  1117.     if (cfun_state_rsp->result == KAL_TRUE)
  1118.     {
  1119. #endif /* MMI_ON_HARDWARE_P */ 
  1120.         g_phnset_cntx.curFlightMode = g_phnset_cntx.selFlightMode;      /* update flight mode if it is successfully changed */
  1121.         if (mmi_bootup_get_active_flight_mode() == FLIGHTMODE_OFF &&    /* normal mode to flight mode */
  1122.     #ifdef MMI_ON_HARDWARE_P
  1123.     #ifdef MMS_SUPPORT
  1124.             (mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) == MMI_FRM_SMS_INVALID_INDEX || !wap_is_ready()))
  1125.     #else 
  1126.             mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) == MMI_FRM_SMS_INVALID_INDEX)
  1127.     #endif 
  1128.     #else /* MMI_ON_HARDWARE_P */ 
  1129.             mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) == MMI_FRM_SMS_INVALID_INDEX)
  1130.     #endif /* MMI_ON_HARDWARE_P */ 
  1131.             gPowerOnWithFlightMode = MMI_TRUE;
  1132.         else
  1133.         {
  1134.         gPowerOnWithFlightMode = MMI_FALSE;
  1135.         }
  1136.         //if (mmi_bootup_get_active_flight_mode() == FLIGHTMODE_OFF)      /* normal mode to flight mode */
  1137.         if ((g_pwr_context.PowerOnNWStatus & MMI_NW_STATUS_FLIGHT_MODE) == FLIGHTMODE_OFF)
  1138.         {
  1139.             lastNwStatus = MMI_RAC_NO_CELL; /* update last network status as no service */
  1140.             gSignalStrengthLevel = 0;   /* avoid no signal level indication sent to MMI */
  1141.             PhnsetFlightModeSaveStatusIconFlags();
  1142.             RemoveStatusIconsForSimRemoved();
  1143.             UpdateStatusIcons();
  1144.             //mmi_flight_mode_hide_menu_items();
  1145.         }
  1146.         /* diamond, 2005/10/28 Need to update status icons first, then change mode */
  1147.         if (g_phnset_cntx.selFlightMode == FLIGHTMODE_SILENT)
  1148.         {
  1149.             g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_FLIGHT_MODE; /* 0x04: Flight mode */
  1150.         }
  1151.         else
  1152.         {
  1153.             g_pwr_context.PowerOnNWStatus &= ~MMI_NW_STATUS_FLIGHT_MODE;        /* 0x04: Flight mode */
  1154.         }
  1155.         //if (mmi_bootup_get_active_flight_mode() == FLIGHTMODE_OFF)      /* flight mode to normal mode */
  1156.         if ((g_pwr_context.PowerOnNWStatus & MMI_NW_STATUS_FLIGHT_MODE) == FLIGHTMODE_OFF)
  1157.         {
  1158.             PhnsetFlightModeRestoreStatusIconFlags();
  1159.             UpdateStatusIcons();
  1160.             //mmi_flight_mode_unhide_menu_items();
  1161.         }
  1162.         /* diamond, 2005/11/17 Force to draw signal level because signal level indication comes before flight mode switch rsp */
  1163.         ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  1164.     #ifdef __MMI_SUBLCD__
  1165.         ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  1166.     #endif 
  1167.         /* diamond, 2006/02/22 If the camp on tone comes with next network attachment indication, it might be delayed for many seconds */
  1168.         g_pwr_context.IsCampOnTonePlayed = 1;
  1169.         g_pwr_context.InvalidSimShowed = 1;
  1170.         mmi_phnset_switch_flight_mode();
  1171. #ifdef MMI_ON_HARDWARE_P
  1172.     }
  1173.     else
  1174.     {
  1175.         DisplayPopup(
  1176.             (U8*) GetString(STR_GLOBAL_NOT_DONE),
  1177.             IMG_GLOBAL_UNFINISHED,
  1178.             1,
  1179.             UI_POPUP_NOTIFYDURATION_TIME,
  1180.             (U8) ERROR_TONE);
  1181.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  1182.     }
  1183. #endif /* MMI_ON_HARDWARE_P */ 
  1184. }
  1185. /*****************************************************************************
  1186.  * FUNCTION
  1187.  *  PhnsetFlightModeSelectionReq
  1188.  * DESCRIPTION
  1189.  *  Request of mode switch
  1190.  * PARAMETERS
  1191.  *  void
  1192.  * RETURNS
  1193.  *  void
  1194.  *****************************************************************************/
  1195. void PhnsetFlightModeSelectionReq(void)
  1196. {
  1197.     /*----------------------------------------------------------------*/
  1198.     /* Local Variables                                                */
  1199.     /*----------------------------------------------------------------*/
  1200.     MYQUEUE Message;
  1201.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  1202.     /*----------------------------------------------------------------*/
  1203.     /* Code Body                                                      */
  1204.     /*----------------------------------------------------------------*/
  1205.     if (g_phnset_cntx.selFlightMode == FLIGHTMODE_QUERY)
  1206.     {
  1207.         DisplayPopup(
  1208.             (U8*) GetString(STR_GLOBAL_DONE),
  1209.             IMG_GLOBAL_ACTIVATED,
  1210.             1,
  1211.             UI_POPUP_NOTIFYDURATION_TIME,
  1212.             (U8) SUCCESS_TONE);
  1213.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_SELECTION);   /* flight mode menu */
  1214.         /* save it to NVRAM only and not necessary to send request to L4C */
  1215.         g_phnset_cntx.curFlightMode = g_phnset_cntx.selFlightMode;
  1216.         PhnsetFlightModeSaveMode();
  1217.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  1218.         return;
  1219.     }
  1220.     if ((g_phnset_cntx.selFlightMode != FLIGHTMODE_QUERY) &&
  1221.         (g_phnset_cntx.curFlightMode == FLIGHTMODE_QUERY) &&
  1222.         (mmi_bootup_get_active_flight_mode() == g_phnset_cntx.selFlightMode))
  1223.     {
  1224.         DisplayPopup(
  1225.             (U8*) GetString(STR_GLOBAL_DONE),
  1226.             IMG_GLOBAL_ACTIVATED,
  1227.             1,
  1228.             UI_POPUP_NOTIFYDURATION_TIME,
  1229.             (U8) SUCCESS_TONE);
  1230.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_SELECTION);   /* flight mode menu */
  1231.         /* save it to NVRAM only and not necessary to send request to L4C */
  1232.         g_phnset_cntx.curFlightMode = g_phnset_cntx.selFlightMode;
  1233.         PhnsetFlightModeSaveMode();
  1234.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  1235.         return;
  1236.     }
  1237.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  1238.     if (g_phnset_cntx.selFlightMode == FLIGHTMODE_OFF)  /* normal mode */
  1239.     {
  1240.         cfun_state_req->cfun_state = 1;
  1241.     }
  1242.     else    /* flight mode */
  1243.     {
  1244.         cfun_state_req->cfun_state = 4;
  1245.     }
  1246.     SetProtocolEventHandler(PhnsetFlightModeSelectionRsp, PRT_NW_CFUN_STATE_RSP);
  1247. //    EntryFlightModeProgress();  /* show searching screen */
  1248. //    gSetModeFromMenu = MMI_TRUE;
  1249.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  1250.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  1251.     Message.oslPeerBuffPtr = NULL;
  1252.     Message.oslSrcId = MOD_MMI;
  1253.     Message.oslDestId = MOD_L4C;
  1254.     OslMsgSendExtQueue(&Message);
  1255. }
  1256. /*****************************************************************************
  1257.  * FUNCTION
  1258.  *  EntryFlightModeSelectionCnf
  1259.  * DESCRIPTION
  1260.  *  Confirmation screen of mode switch
  1261.  * PARAMETERS
  1262.  *  void
  1263.  * RETURNS
  1264.  *  void
  1265.  *****************************************************************************/
  1266. void EntryFlightModeSelectionCnf(void)
  1267. {
  1268.     /*----------------------------------------------------------------*/
  1269.     /* Local Variables                                                */
  1270.     /*----------------------------------------------------------------*/
  1271.     /*----------------------------------------------------------------*/
  1272.     /* Code Body                                                      */
  1273.     /*----------------------------------------------------------------*/
  1274.     DisplayConfirm(
  1275.         STR_GLOBAL_YES,
  1276.         IMG_GLOBAL_YES,
  1277.         STR_GLOBAL_NO,
  1278.         IMG_GLOBAL_NO,
  1279.         get_string(STR_FLIGHT_MODE_CONFIRM),
  1280.         IMG_GLOBAL_QUESTION,
  1281.         WARNING_TONE);
  1282.     //SetLeftSoftkeyFunction(PhnsetFlightModeSelectionReq, KEY_EVENT_UP);
  1283.     SetLeftSoftkeyFunction(mmi_phnset_confirm_to_switch_mode, KEY_EVENT_UP);
  1284.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1285.     /* Play warning tone */
  1286.     playRequestedTone(WARNING_TONE);
  1287. }
  1288. /*****************************************************************************
  1289.  * FUNCTION
  1290.  *  PhnsetFlightModeSelectionOK
  1291.  * DESCRIPTION
  1292.  *  Handler for the mode selection by user
  1293.  * PARAMETERS
  1294.  *  void
  1295.  * RETURNS
  1296.  *  void
  1297.  *****************************************************************************/
  1298. void PhnsetFlightModeSelectionOK(void)
  1299. {
  1300.     /*----------------------------------------------------------------*/
  1301.     /* Local Variables                                                */
  1302.     /*----------------------------------------------------------------*/
  1303.     /*----------------------------------------------------------------*/
  1304.     /* Code Body                                                      */
  1305.     /*----------------------------------------------------------------*/
  1306.     if (g_phnset_cntx.selFlightMode == g_phnset_cntx.curFlightMode)
  1307.     {
  1308.         /* select mode is the same as current mode, so not necessary to send request to L4C */
  1309.         DisplayPopup(
  1310.             (U8*) GetString(STR_GLOBAL_DONE),
  1311.             IMG_GLOBAL_ACTIVATED,
  1312.             1,
  1313.             UI_POPUP_NOTIFYDURATION_TIME,
  1314.             (U8) SUCCESS_TONE);
  1315.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_SELECTION);   /* flight mode menu */
  1316.     }
  1317.     else
  1318.     {
  1319.         EntryFlightModeSelectionCnf();
  1320.     }
  1321. }
  1322. /*****************************************************************************
  1323.  * FUNCTION
  1324.  *  EntryPhnsetFlightMode
  1325.  * DESCRIPTION
  1326.  *  This function is Entry function for Phone Setup -> Flight Mode
  1327.  * PARAMETERS
  1328.  *  void
  1329.  * RETURNS
  1330.  *  void
  1331.  *****************************************************************************/
  1332. void EntryPhnsetFlightMode(void)
  1333. {
  1334.     /*----------------------------------------------------------------*/
  1335.     /* Local Variables                                                */
  1336.     /*----------------------------------------------------------------*/
  1337.     U8 nNumofItem = 3;
  1338.     U8 *guiBuffer;
  1339.     U16 nStrItemList[3] = {STR_FLIGHT_MODE_NORMAL, STR_FLIGHT_MODE_SILENT, STR_FLIGHT_MODE_QUERY};
  1340.     /*----------------------------------------------------------------*/
  1341.     /* Code Body                                                      */
  1342.     /*----------------------------------------------------------------*/
  1343.     EntryNewScreen(SCR_FLIGHT_MODE_SELECTION, NULL, EntryPhnsetFlightMode, NULL);
  1344.     guiBuffer = GetCurrGuiBuffer(SCR_FLIGHT_MODE_SELECTION);
  1345.     RegisterHighlightHandler(HiliteHandlerFlightMode);
  1346.     ShowCategory11Screen(
  1347.         STR_MENU_FLIGHT_MODE,
  1348.         MAIN_MENU_TITLE_SETTINGS_ICON,
  1349.         STR_GLOBAL_OK,
  1350.         IMG_GLOBAL_OK,
  1351.         STR_GLOBAL_BACK,
  1352.         IMG_GLOBAL_BACK,
  1353.         nNumofItem,
  1354.         nStrItemList,
  1355.         g_phnset_cntx.curFlightMode,
  1356.         guiBuffer);
  1357.     SetLeftSoftkeyFunction(PhnsetFlightModeSelectionOK, KEY_EVENT_UP);
  1358.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1359.     SetKeyHandler(0, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1360.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1361. }
  1362. /*****************************************************************************
  1363.  * FUNCTION
  1364.  *  PhnsetFlightModeSaveMode
  1365.  * DESCRIPTION
  1366.  *  Save active mode to NVRAM
  1367.  * PARAMETERS
  1368.  *  void
  1369.  * RETURNS
  1370.  *  void
  1371.  *****************************************************************************/
  1372. void PhnsetFlightModeSaveMode(void)
  1373. {
  1374.     /*----------------------------------------------------------------*/
  1375.     /* Local Variables                                                */
  1376.     /*----------------------------------------------------------------*/
  1377.     U8 data[NVRAM_EF_SYS_CACHE_OCTET_SIZE];
  1378.     S16 error;
  1379.     /*----------------------------------------------------------------*/
  1380.     /* Code Body                                                      */
  1381.     /*----------------------------------------------------------------*/
  1382.     PRINT_INFORMATION(("@@@@@ Flight mode: save mode @@@@@"));
  1383.     data[0] = g_phnset_cntx.curFlightMode;
  1384.     data[1] = (U8) mmi_bootup_get_active_flight_mode();
  1385.     WriteRecord(NVRAM_EF_SYS_CACHE_OCTET_LID, 2, &data, NVRAM_EF_SYS_CACHE_OCTET_SIZE, &error);
  1386. }
  1387. /*****************************************************************************
  1388.  * FUNCTION
  1389.  *  PowerOnFlightMode
  1390.  * DESCRIPTION
  1391.  *  Process of power on in flight mode
  1392.  * PARAMETERS
  1393.  *  void
  1394.  * RETURNS
  1395.  *  void
  1396.  *****************************************************************************/
  1397. void PowerOnFlightMode(void)
  1398. {
  1399.     /*----------------------------------------------------------------*/
  1400.     /* Local Variables                                                */
  1401.     /*----------------------------------------------------------------*/
  1402.     MYQUEUE Message;
  1403.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  1404.     /*----------------------------------------------------------------*/
  1405.     /* Code Body                                                      */
  1406.     /*----------------------------------------------------------------*/
  1407.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  1408.     PhnsetFlightModeSaveStatusIconFlags();
  1409.     RemoveStatusIconsForSimRemoved();
  1410.     UpdateStatusIcons();
  1411.     cfun_state_req->cfun_state = 4;
  1412.     g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_FLIGHT_MODE; /* 0x04: Flight mode */
  1413.     if (g_phnset_cntx.curFlightMode != FLIGHTMODE_QUERY)
  1414.     {
  1415.         g_phnset_cntx.curFlightMode = FLIGHTMODE_SILENT;
  1416.     }
  1417.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  1418.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  1419.     Message.oslPeerBuffPtr = NULL;
  1420.     Message.oslSrcId = MOD_MMI;
  1421.     Message.oslDestId = MOD_L4C;
  1422.     OslMsgSendExtQueue(&Message);
  1423.     ExitCategory165Screen();                /* StopTimer(POPUP_TIMER); */
  1424.     ClearInputEventHandler(MMI_DEVICE_ALL); /* prevent user press key after mode selection in qurey screen */
  1425.     /* apply to handphone only */
  1426. #if defined(__MMI_BT_HP_SUPPORT__)
  1427.     mmi_bt_reset_hw_off();
  1428. #endif 
  1429.     gPowerOnWithFlightMode = MMI_TRUE;
  1430.     DeleteScreenIfPresent(GLOBAL_SCR_DUMMY);
  1431.     if (g_pwr_context.PowerOnMode == POWER_ON_KEYPAD)   /* diamond, 2005/10/21 Do not play animation for exception power on */
  1432.     {
  1433.         PhnsetFlightModeSaveMode();
  1434.         mmi_bootup_exit_flight_mode_query();
  1435.     }
  1436. }
  1437. /*****************************************************************************
  1438.  * FUNCTION
  1439.  *  PowerOnNormalMode
  1440.  * DESCRIPTION
  1441.  *  Process of power on in normal mode
  1442.  * PARAMETERS
  1443.  *  void
  1444.  * RETURNS
  1445.  *  void
  1446.  *****************************************************************************/
  1447. void PowerOnNormalMode(void)
  1448. {
  1449.     /*----------------------------------------------------------------*/
  1450.     /* Local Variables                                                */
  1451.     /*----------------------------------------------------------------*/
  1452.     MYQUEUE Message;
  1453.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  1454.     /*----------------------------------------------------------------*/
  1455.     /* Code Body                                                      */
  1456.     /*----------------------------------------------------------------*/
  1457.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  1458.     cfun_state_req->cfun_state = 1;
  1459.     g_pwr_context.PowerOnNWStatus &= ~MMI_NW_STATUS_FLIGHT_MODE;        /* 0x04 Flight mode */
  1460.     if (g_phnset_cntx.curFlightMode != FLIGHTMODE_QUERY)
  1461.     {
  1462.         g_phnset_cntx.curFlightMode = FLIGHTMODE_OFF;
  1463.     }
  1464.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  1465.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  1466.     Message.oslPeerBuffPtr = NULL;
  1467.     Message.oslSrcId = MOD_MMI;
  1468.     Message.oslDestId = MOD_L4C;
  1469.     OslMsgSendExtQueue(&Message);
  1470.     ExitCategory165Screen();                /* StopTimer(POPUP_TIMER); */
  1471.     ClearInputEventHandler(MMI_DEVICE_ALL); /* prevent user press key after mode selection in qurey screen */
  1472.     DeleteScreenIfPresent(GLOBAL_SCR_DUMMY);
  1473.     if (g_pwr_context.PowerOnMode == POWER_ON_KEYPAD)   /* diamond, 2005/10/21 Do not play animation for exception power on */
  1474.     {
  1475.         PhnsetFlightModeSaveMode();
  1476.         mmi_bootup_exit_flight_mode_query();
  1477.     }
  1478. }
  1479. /*****************************************************************************
  1480.  * FUNCTION
  1481.  *  EntryQueryFlightModeScreen
  1482.  * DESCRIPTION
  1483.  *  Flight mode query screen before power on animation
  1484.  * PARAMETERS
  1485.  *  void
  1486.  * RETURNS
  1487.  *  void
  1488.  *****************************************************************************/
  1489. void EntryQueryFlightModeScreen(void)
  1490. {
  1491.     /*----------------------------------------------------------------*/
  1492.     /* Local Variables                                                */
  1493.     /*----------------------------------------------------------------*/
  1494.     U8 *guiBuffer;
  1495.     /*----------------------------------------------------------------*/
  1496.     /* Code Body                                                      */
  1497.     /*----------------------------------------------------------------*/
  1498.     g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_FLIGHT_MODE_QUERY;    /* 0x02: Flight mode screen */
  1499.     guiBuffer = GetCurrGuiBuffer(SCR_FLIGHT_MODE_QUERY);
  1500.     EntryNewScreen(SCR_FLIGHT_MODE_QUERY, NULL, EntryQueryFlightModeScreen, NULL);
  1501.     ShowCategory165Screen_ext(
  1502.         STR_GLOBAL_YES,
  1503.         IMG_GLOBAL_YES,
  1504.         STR_GLOBAL_NO,
  1505.         IMG_GLOBAL_NO,
  1506.         get_string(STR_MENU_FLIGHT_MODE),
  1507.         IMG_GLOBAL_QUESTION,
  1508.         10,
  1509.         guiBuffer);
  1510.     SetCat165TimerExpireFunc(PowerOnNormalMode);
  1511.     playRequestedTone(WARNING_TONE);
  1512.     /* ShowSubLCDScreen(ShowIdleAppSubLcd); */
  1513.     /* no sub-lcd exit handler because of no interrupt in this screen */
  1514. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1515.     if (IsClamClose())
  1516.     {
  1517.         ShowSubLCDAnalogClockScreen();
  1518.     }
  1519.     else
  1520.     {
  1521.         ShowSubLCDLogoString();
  1522.     }
  1523. #else /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1524.     ShowCategory301Screen((PU8) GetString(STR_MENU_FLIGHT_MODE), 0, NULL);
  1525. #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1526.     g_phnset_cntx.curFlightMode = FLIGHTMODE_QUERY;
  1527.     /* No history to go back */
  1528.     /* Always enter normal mode unless the flight mode is selected by pressing LSK (Yes) */
  1529.     SetKeyHandler(PowerOnNormalMode, KEY_END, KEY_EVENT_DOWN);
  1530. #ifdef __MMI_WLAN_FEATURES__
  1531.     SetLeftSoftkeyFunction(mmi_phnset_power_on_query_with_flight_mode, KEY_EVENT_UP);
  1532.     SetRightSoftkeyFunction(mmi_phnset_power_on_query_with_normal_mode, KEY_EVENT_UP);
  1533. #else
  1534.     SetLeftSoftkeyFunction(PowerOnFlightMode, KEY_EVENT_UP);
  1535.     SetRightSoftkeyFunction(PowerOnNormalMode, KEY_EVENT_UP);
  1536. #endif
  1537. }
  1538. /*****************************************************************************
  1539.  * FUNCTION
  1540.  *  PhnsetFlightModeGetLatestActionMode
  1541.  * DESCRIPTION
  1542.  *  Get latest action mode for exception power on
  1543.  * PARAMETERS
  1544.  *  void
  1545.  * RETURNS
  1546.  *  void
  1547.  *****************************************************************************/
  1548. U8 PhnsetFlightModeGetLatestActionMode(void)
  1549. {
  1550.     /*----------------------------------------------------------------*/
  1551.     /* Local Variables                                                */
  1552.     /*----------------------------------------------------------------*/
  1553.     U8 data[NVRAM_EF_SYS_CACHE_OCTET_SIZE];
  1554.     S16 error;
  1555.     /*----------------------------------------------------------------*/
  1556.     /* Code Body                                                      */
  1557.     /*----------------------------------------------------------------*/
  1558.     ReadRecord(NVRAM_EF_SYS_CACHE_OCTET_LID, 2, &data, NVRAM_EF_SYS_CACHE_OCTET_SIZE, &error);
  1559.     return data[1];
  1560. }
  1561. /*****************************************************************************
  1562.  * FUNCTION
  1563.  *  PhnsetFlightModePowerOnException
  1564.  * DESCRIPTION
  1565.  *  Process of exception power on mode switch
  1566.  * PARAMETERS
  1567.  *  void
  1568.  * RETURNS
  1569.  *  void
  1570.  *****************************************************************************/
  1571. void PhnsetFlightModePowerOnException(void)
  1572. {
  1573.     /*----------------------------------------------------------------*/
  1574.     /* Local Variables                                                */
  1575.     /*----------------------------------------------------------------*/
  1576.     /*----------------------------------------------------------------*/
  1577.     /* Code Body                                                      */
  1578.     /*----------------------------------------------------------------*/
  1579.     if (PhnsetFlightModeGetLatestActionMode() == FLIGHTMODE_OFF)
  1580.     {
  1581.         PowerOnNormalMode();
  1582.     }
  1583.     else
  1584.     {
  1585.         PowerOnFlightMode();
  1586.     }
  1587. }
  1588. #ifdef __MMI_ENGINEER_MODE__
  1589. extern void EntryEmRFTestGSM(void);
  1590. pBOOL gEnterEMWithFlightMode = MMI_FALSE;
  1591. /*****************************************************************************
  1592.  * FUNCTION
  1593.  *  mmi_em_enter_flight_mode_rsp
  1594.  * DESCRIPTION
  1595.  *  Enter flight mode from engineering mode
  1596.  * PARAMETERS
  1597.  *  info
  1598.  * RETURNS
  1599.  *  void
  1600.  *****************************************************************************/
  1601. void mmi_em_enter_flight_mode_rsp(void *info)
  1602. {
  1603.     /*----------------------------------------------------------------*/
  1604.     /* Local Variables                                                */
  1605.     /*----------------------------------------------------------------*/
  1606.     mmi_nw_cfun_state_rsp_struct *cfun_state_rsp;
  1607.     /*----------------------------------------------------------------*/
  1608.     /* Code Body                                                      */
  1609.     /*----------------------------------------------------------------*/
  1610.     cfun_state_rsp = (mmi_nw_cfun_state_rsp_struct*) info;
  1611.     ClearProtocolEventHandler(PRT_NW_CFUN_STATE_RSP);
  1612. #ifdef MMI_ON_HARDWARE_P
  1613.     if (cfun_state_rsp->result == KAL_TRUE)
  1614.     {
  1615. #endif /* MMI_ON_HARDWARE_P */ 
  1616.         /* update flight mode if it is successfully changed */
  1617.         /* g_phnset_cntx.curFlightMode = 1; */
  1618.         g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_FLIGHT_MODE;     /* 0x04: Flight mode */
  1619.         /* refresh status icons */
  1620.         gSignalStrengthLevel = 0;
  1621.         PhnsetFlightModeSaveStatusIconFlags();
  1622.         RemoveStatusIconsForSimRemoved();
  1623.         UpdateStatusIcons();
  1624.         /* write current mode to nvram */
  1625.         PhnsetFlightModeSaveMode();
  1626.         /* force to draw signal level because signal level indication comes before flight mode switch rsp */
  1627.         ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  1628.     #ifdef __MMI_SUBLCD__
  1629.         ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  1630.     #endif 
  1631.         /* enter next menu */
  1632.         EntryEmRFTestGSM();
  1633.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  1634.     #ifdef MMI_ON_HARDWARE_P
  1635.     }
  1636.     else
  1637.     {
  1638.         DisplayPopup(
  1639.             (U8*) GetString(STR_GLOBAL_NOT_DONE),
  1640.             IMG_GLOBAL_UNFINISHED,
  1641.             1,
  1642.             UI_POPUP_NOTIFYDURATION_TIME,
  1643.             (U8) ERROR_TONE);
  1644.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  1645.     }
  1646.     #endif /* MMI_ON_HARDWARE_P */ 
  1647. }
  1648. /*****************************************************************************
  1649.  * FUNCTION
  1650.  *  mmi_em_enter_flight_mode
  1651.  * DESCRIPTION
  1652.  *  Enter flight mode from engineering mode
  1653.  * PARAMETERS
  1654.  *  void
  1655.  * RETURNS
  1656.  *  void
  1657.  *****************************************************************************/
  1658. void mmi_em_enter_flight_mode(void)
  1659. {
  1660.     /*----------------------------------------------------------------*/
  1661.     /* Local Variables                                                */
  1662.     /*----------------------------------------------------------------*/
  1663.     MYQUEUE Message;
  1664.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  1665.     /*----------------------------------------------------------------*/
  1666.     /* Code Body                                                      */
  1667.     /*----------------------------------------------------------------*/
  1668.     gEnterEMWithFlightMode = MMI_FALSE;
  1669.     if (mmi_bootup_get_active_flight_mode() == FLIGHTMODE_SILENT)
  1670.     {
  1671.         /* already in flight mode */
  1672.         gEnterEMWithFlightMode = MMI_TRUE;
  1673.         /* directly enter next menu */
  1674.         EntryEmRFTestGSM();
  1675.         return;
  1676.     }
  1677.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  1678.     cfun_state_req->cfun_state = 4; /* flight mode */
  1679.     SetProtocolEventHandler(mmi_em_enter_flight_mode_rsp, PRT_NW_CFUN_STATE_RSP);
  1680.     EntryFlightModeProgress();  /* show searching screen */
  1681.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  1682.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  1683.     Message.oslPeerBuffPtr = NULL;
  1684.     Message.oslSrcId = MOD_MMI;
  1685.     Message.oslDestId = MOD_L4C;
  1686.     OslMsgSendExtQueue(&Message);
  1687. }
  1688. /*****************************************************************************
  1689.  * FUNCTION
  1690.  *  mmi_em_exit_flight_mode_rsp
  1691.  * DESCRIPTION
  1692.  *  Exit flight mode from engineering mode
  1693.  * PARAMETERS
  1694.  *  info
  1695.  * RETURNS
  1696.  *  void
  1697.  *****************************************************************************/
  1698. void mmi_em_exit_flight_mode_rsp(void *info)
  1699. {
  1700.     /*----------------------------------------------------------------*/
  1701.     /* Local Variables                                                */
  1702.     /*----------------------------------------------------------------*/
  1703.     mmi_nw_cfun_state_rsp_struct *cfun_state_rsp;
  1704.     /*----------------------------------------------------------------*/
  1705.     /* Code Body                                                      */
  1706.     /*----------------------------------------------------------------*/
  1707.     cfun_state_rsp = (mmi_nw_cfun_state_rsp_struct*) info;
  1708.     ClearProtocolEventHandler(PRT_NW_CFUN_STATE_RSP);
  1709. #ifdef MMI_ON_HARDWARE_P
  1710.     if (cfun_state_rsp->result == KAL_TRUE)
  1711.     {
  1712. #endif /* MMI_ON_HARDWARE_P */ 
  1713.         /* update flight mode if it is successfully changed */
  1714.         /* g_phnset_cntx.curFlightMode = 0; */
  1715.         g_pwr_context.PowerOnNWStatus &= ~MMI_NW_STATUS_FLIGHT_MODE;    /* 0x04: Flight mode */
  1716.         /* refresh status icons */
  1717.         PhnsetFlightModeRestoreStatusIconFlags();
  1718.         UpdateStatusIcons();
  1719.         /* write current mode to nvram */
  1720.         PhnsetFlightModeSaveMode();
  1721.         /* diamond, 2005/11/17 Force to draw signal level because signal level indication comes before flight mode switch rsp */
  1722.         ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  1723.     #ifdef __MMI_SUBLCD__
  1724.         ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  1725.     #endif 
  1726.         /* enter next menu */
  1727.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  1728.         GoBackToHistory(EM_RF_TEST_TOOL_SCR);   /* the screen of RF test tool is already in the history */
  1729.     #ifdef MMI_ON_HARDWARE_P
  1730.     }
  1731.     else
  1732.     {
  1733.         DisplayPopup(
  1734.             (U8*) GetString(STR_GLOBAL_NOT_DONE),
  1735.             IMG_GLOBAL_UNFINISHED,
  1736.             1,
  1737.             UI_POPUP_NOTIFYDURATION_TIME,
  1738.             (U8) ERROR_TONE);
  1739.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  1740.     }
  1741.     #endif /* MMI_ON_HARDWARE_P */ 
  1742. }
  1743. /*****************************************************************************
  1744.  * FUNCTION
  1745.  *  mmi_em_exit_flight_mode
  1746.  * DESCRIPTION
  1747.  *  Exit flight mode from engineering mode
  1748.  * PARAMETERS
  1749.  *  void
  1750.  * RETURNS
  1751.  *  void
  1752.  *****************************************************************************/
  1753. void mmi_em_exit_flight_mode(void)
  1754. {
  1755.     /*----------------------------------------------------------------*/
  1756.     /* Local Variables                                                */
  1757.     /*----------------------------------------------------------------*/
  1758.     MYQUEUE Message;
  1759.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  1760.     /*----------------------------------------------------------------*/
  1761.     /* Code Body                                                      */
  1762.     /*----------------------------------------------------------------*/
  1763.     if (gEnterEMWithFlightMode)
  1764.     {
  1765.         /* directly enter next menu */
  1766.         GoBackHistory();
  1767.         return;
  1768.     }
  1769.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  1770.     cfun_state_req->cfun_state = 1; /* normal mode */
  1771.     SetProtocolEventHandler(mmi_em_exit_flight_mode_rsp, PRT_NW_CFUN_STATE_RSP);
  1772.     EntryFlightModeProgress();  /* show searching screen */
  1773.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  1774.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  1775.     Message.oslPeerBuffPtr = NULL;
  1776.     Message.oslSrcId = MOD_MMI;
  1777.     Message.oslDestId = MOD_L4C;
  1778.     OslMsgSendExtQueue(&Message);
  1779. }
  1780. #endif /* __MMI_ENGINEER_MODE__ */ 
  1781. /*****************************************************************************
  1782.  * FUNCTION
  1783.  *  mmi_flight_mode_set_mode
  1784.  * DESCRIPTION
  1785.  *  Set mode for power on
  1786.  * PARAMETERS
  1787.  *  bFlightMode       [IN]     U8
  1788.  * RETURNS
  1789.  *  void
  1790.  *****************************************************************************/
  1791. void mmi_flight_mode_set_mode(U8 bFlightMode)
  1792. {
  1793.     /*----------------------------------------------------------------*/
  1794.     /* Local Variables                                                */
  1795.     /*----------------------------------------------------------------*/
  1796.     MYQUEUE Message;
  1797.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  1798.     /*----------------------------------------------------------------*/
  1799.     /* Code Body                                                      */
  1800.     /*----------------------------------------------------------------*/
  1801.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  1802.     if (bFlightMode)
  1803.     {
  1804.     #ifdef __FLIGHT_MODE_SUPPORT__
  1805.         PhnsetFlightModeSaveStatusIconFlags();
  1806.         RemoveStatusIconsForSimRemoved();
  1807.         UpdateStatusIcons();
  1808.     #endif /* __FLIGHT_MODE_SUPPORT__ */ 
  1809.         cfun_state_req->cfun_state = 4;
  1810.         g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_FLIGHT_MODE; /* 0x04: Flight mode */
  1811.     #ifdef __MMI_WLAN_FEATURES__
  1812.         if (g_phnset_cntx.curFlightMode == FLIGHTMODE_OFF && mmi_netset_get_active_preferred_mode() == P_WLAN_ONLY)
  1813.         {
  1814.             /* Not update g_phnset_cntx.curFlightMode */
  1815.         }
  1816.         else
  1817.     #endif /* __MMI_WLAN_FEATURES__ */
  1818.         if (g_phnset_cntx.curFlightMode != FLIGHTMODE_QUERY)
  1819.         {
  1820.             g_phnset_cntx.curFlightMode = FLIGHTMODE_SILENT;
  1821.         }
  1822.         gPowerOnWithFlightMode = MMI_TRUE;
  1823.     #ifdef __MMI_WLAN_FEATURES__
  1824.         if (g_phnset_cntx.curFlightMode == FLIGHTMODE_SILENT)
  1825.         {
  1826.             g_phnset_cntx.curFlightMode2 = FLIGHTMODE_SILENT;
  1827.         }
  1828.         else
  1829.         {
  1830.             g_phnset_cntx.curFlightMode2 = FLIGHTMODE_OFF;
  1831.         }
  1832.     #endif
  1833.     }
  1834.     else
  1835.     {
  1836.         cfun_state_req->cfun_state = 1;
  1837.         g_pwr_context.PowerOnNWStatus &= ~MMI_NW_STATUS_FLIGHT_MODE;        /* 0x04 Flight mode */
  1838.         if (g_phnset_cntx.curFlightMode != FLIGHTMODE_QUERY)
  1839.         {
  1840.             g_phnset_cntx.curFlightMode = FLIGHTMODE_OFF;
  1841.         }
  1842.    #ifdef __MMI_WLAN_FEATURES__
  1843.         if (mmi_netset_get_active_preferred_mode() == P_GSM_ONLY)
  1844.         {
  1845.             g_phnset_cntx.curFlightMode2 = FLIGHTMODE_SILENT;
  1846.         }
  1847.         else
  1848.         {
  1849.             g_phnset_cntx.curFlightMode2 = FLIGHTMODE_OFF;
  1850.         }
  1851.     #endif /* __MMI_WLAN_FEATURES__ */
  1852.     }
  1853.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  1854.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  1855.     Message.oslPeerBuffPtr = NULL;
  1856.     Message.oslSrcId = MOD_MMI;
  1857.     Message.oslDestId = MOD_L4C;
  1858.     OslMsgSendExtQueue(&Message);
  1859.     if (g_pwr_context.PowerOnMode == POWER_ON_KEYPAD)   /* diamond, 2005/10/21 Do not play animation for exception power on */
  1860.     {
  1861.         PhnsetFlightModeSaveMode();
  1862.     }
  1863. }
  1864. /*****************************************************************************
  1865.  * FUNCTION
  1866.  *  mmi_flight_mode_hide_menu_items
  1867.  * DESCRIPTION
  1868.  *  Hide some menus after entering flight mode
  1869.  * PARAMETERS
  1870.  *  void
  1871.  * RETURNS
  1872.  *  void
  1873.  *****************************************************************************/
  1874. void mmi_flight_mode_hide_menu_items(void)
  1875. {
  1876.     /*----------------------------------------------------------------*/
  1877.     /* Local Variables                                                */
  1878.     /*----------------------------------------------------------------*/
  1879.     /*----------------------------------------------------------------*/
  1880.     /* Code Body                                                      */
  1881.     /*----------------------------------------------------------------*/
  1882.     if (mmi_bootup_is_sim_valid())
  1883.     {
  1884.         mmi_frm_hide_menu_item(MENU_SETTING_SHOW_OWN_NUMBER);
  1885.     #if defined(__MMI_OPERATOR_NAME_MENU__)
  1886.         mmi_frm_hide_menu_item(MENU_SETTING_SHOW_OPN);
  1887.     #endif
  1888.     #ifdef __MMI_NITZ__
  1889.         mmi_frm_hide_menu_item(MENU9145_SETTIMEANDDATENITZ); /* Hide "Auto update of date and time" in flight mode */
  1890.         mmi_frm_hide_menu_item(MENU_SETTING_MENU_TREE);
  1891.     #endif /* __MMI_NITZ__ */
  1892.         mmi_frm_hide_menu_item(MENU_SETTING_DEDICATED_KEYS); /* Hide "Dedicated key" in flight mode */
  1893.     }
  1894. #ifdef __MMI_WLAN_FEATURES__
  1895.     mmi_frm_hide_menu_item(MENU9185_NETWORK_SETUP); /* Hide "Network Setup" in flight mode if WLAN is activated */
  1896. #endif
  1897. }
  1898. /*****************************************************************************
  1899.  * FUNCTION
  1900.  *  mmi_flight_mode_unhide_menu_items
  1901.  * DESCRIPTION
  1902.  *  Recover some menus after leaving flight mode
  1903.  * PARAMETERS
  1904.  *  void
  1905.  * RETURNS
  1906.  *  void
  1907.  *****************************************************************************/
  1908. void mmi_flight_mode_unhide_menu_items(void)
  1909. {
  1910.     /*----------------------------------------------------------------*/
  1911.     /* Local Variables                                                */
  1912.     /*----------------------------------------------------------------*/
  1913.     /*----------------------------------------------------------------*/
  1914.     /* Code Body                                                      */
  1915.     /*----------------------------------------------------------------*/
  1916.     if (mmi_bootup_is_sim_valid())
  1917.     {
  1918.         mmi_frm_unhide_menu_item(MENU_SETTING_SHOW_OWN_NUMBER);
  1919.     #if defined(__MMI_OPERATOR_NAME_MENU__)
  1920.         mmi_frm_unhide_menu_item(MENU_SETTING_SHOW_OPN);
  1921.     #endif
  1922.     #ifdef __MMI_NITZ__
  1923.         mmi_frm_unhide_menu_item(MENU9145_SETTIMEANDDATENITZ); /* Hide "Auto update of date and time" in flight mode */
  1924.         mmi_frm_unhide_menu_item(MENU_SETTING_MENU_TREE);
  1925.     #endif /* __MMI_NITZ__ */
  1926.         mmi_frm_unhide_menu_item(MENU_SETTING_DEDICATED_KEYS); /* Hide "Dedicated key" in flight mode */
  1927.     }
  1928. #ifdef __MMI_WLAN_FEATURES__
  1929.     mmi_frm_unhide_menu_item(MENU9185_NETWORK_SETUP); /* Hide "Network Setup" in flight mode if WLAN is activated */
  1930. #endif
  1931. }
  1932. #ifdef __MMI_WLAN_FEATURES__
  1933. /*****************************************************************************
  1934.  * FUNCTION
  1935.  *  mmi_netset_entry_preferred_mode_progress
  1936.  * DESCRIPTION
  1937.  *  Progressing screen for mode switch
  1938.  * PARAMETERS
  1939.  *  void
  1940.  * RETURNS
  1941.  *  void
  1942.  *****************************************************************************/
  1943. void mmi_netset_entry_preferred_mode_progress(void)
  1944. {
  1945.     /*----------------------------------------------------------------*/
  1946.     /* Local Variables                                                */
  1947.     /*----------------------------------------------------------------*/
  1948.     /*----------------------------------------------------------------*/
  1949.     /* Code Body                                                      */
  1950.     /*----------------------------------------------------------------*/
  1951.     EntryNewScreen(SCR_FLIGHT_MODE_PROGRESS, NULL, mmi_netset_entry_preferred_mode_progress, NULL);
  1952.     SetKeyHandler(NULL, KEY_END, KEY_EVENT_DOWN);
  1953.     SetKeyHandler(NULL, KEY_END, KEY_EVENT_UP);
  1954.     ShowCategory66Screen(
  1955.         STR_ID_NETSET_PREFERRED_MODE,
  1956.         0,
  1957.         0,
  1958.         0,
  1959.         0,
  1960.         0,
  1961.         (PU8) GetString(STR_FLIGHT_MODE_PROGRESS),
  1962.         IMG_FLIGHT_MODE_PROGRESS,
  1963.         NULL);
  1964. }
  1965. /*****************************************************************************
  1966.  * FUNCTION
  1967.  *  mmi_phnset_enter_gsm_flight_mode_rsp
  1968.  * DESCRIPTION
  1969.  *  Enter flight mode from WLAN preferred mode
  1970.  * PARAMETERS
  1971.  *  info
  1972.  * RETURNS
  1973.  *  void
  1974.  *****************************************************************************/
  1975. void mmi_phnset_enter_gsm_flight_mode_rsp(void *info)
  1976. {
  1977.     /*----------------------------------------------------------------*/
  1978.     /* Local Variables                                                */
  1979.     /*----------------------------------------------------------------*/
  1980.     mmi_nw_cfun_state_rsp_struct *cfun_state_rsp;
  1981.     /*----------------------------------------------------------------*/
  1982.     /* Code Body                                                      */
  1983.     /*----------------------------------------------------------------*/
  1984.     cfun_state_rsp = (mmi_nw_cfun_state_rsp_struct*) info;
  1985.     ClearProtocolEventHandler(PRT_NW_CFUN_STATE_RSP);
  1986. #ifdef MMI_ON_HARDWARE_P
  1987.     if (cfun_state_rsp->result == KAL_TRUE)
  1988.     {
  1989. #endif /* MMI_ON_HARDWARE_P */ 
  1990.         //g_phnset_cntx.curFlightMode = FLIGHTMODE_SILENT;
  1991.         g_pwr_context.PowerOnNWStatus |= MMI_NW_STATUS_FLIGHT_MODE;     /* 0x04: Flight mode */
  1992.         /* refresh status icons */
  1993.         gSignalStrengthLevel = 0;
  1994.         PhnsetFlightModeSaveStatusIconFlags();
  1995.         RemoveStatusIconsForSimRemoved();
  1996.         UpdateStatusIcons();
  1997.         /* write current mode to nvram */
  1998.         PhnsetFlightModeSaveMode();
  1999.         /* force to draw signal level because signal level indication comes before flight mode switch rsp */
  2000.         ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  2001.     #ifdef __MMI_SUBLCD__
  2002.         ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  2003.     #endif 
  2004.         //DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  2005.         mmi_netset_switch_preferred_mode();
  2006. #ifdef MMI_ON_HARDWARE_P
  2007.     }
  2008.     else
  2009.     {
  2010.         DisplayPopup(
  2011.             (U8*) GetString(STR_GLOBAL_NOT_DONE),
  2012.             IMG_GLOBAL_UNFINISHED,
  2013.             1,
  2014.             UI_POPUP_NOTIFYDURATION_TIME,
  2015.             (U8) ERROR_TONE);
  2016.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  2017.     }
  2018. #endif /* MMI_ON_HARDWARE_P */ 
  2019. }
  2020. /*****************************************************************************
  2021.  * FUNCTION
  2022.  *  mmi_phnset_enter_gsm_flight_mode
  2023.  * DESCRIPTION
  2024.  *  Enter flight mode from WLAN preferred mode
  2025.  * PARAMETERS
  2026.  *  void
  2027.  * RETURNS
  2028.  *  void
  2029.  *****************************************************************************/
  2030. void mmi_phnset_enter_gsm_flight_mode(void)
  2031. {
  2032.     /*----------------------------------------------------------------*/
  2033.     /* Local Variables                                                */
  2034.     /*----------------------------------------------------------------*/
  2035.     MYQUEUE Message;
  2036.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  2037.     /*----------------------------------------------------------------*/
  2038.     /* Code Body                                                      */
  2039.     /*----------------------------------------------------------------*/
  2040. #if 0
  2041. /* under construction !*/
  2042. /* under construction !*/
  2043. /* under construction !*/
  2044. /* under construction !*/
  2045. /* under construction !*/
  2046. /* under construction !*/
  2047. /* under construction !*/
  2048. /* under construction !*/
  2049. /* under construction !*/
  2050. /* under construction !*/
  2051. /* under construction !*/
  2052. #endif /* 0 */
  2053.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  2054.     cfun_state_req->cfun_state = 4; /* flight mode */
  2055.     SetProtocolEventHandler(mmi_phnset_enter_gsm_flight_mode_rsp, PRT_NW_CFUN_STATE_RSP);
  2056.     mmi_netset_entry_preferred_mode_progress();  /* show searching screen */
  2057.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  2058.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  2059.     Message.oslPeerBuffPtr = NULL;
  2060.     Message.oslSrcId = MOD_MMI;
  2061.     Message.oslDestId = MOD_L4C;
  2062.     OslMsgSendExtQueue(&Message);
  2063. }
  2064. /*****************************************************************************
  2065.  * FUNCTION
  2066.  *  mmi_phnset_exit_gsm_flight_mode_rsp
  2067.  * DESCRIPTION
  2068.  *  Exit flight mode from WLAN preferred mode
  2069.  * PARAMETERS
  2070.  *  info
  2071.  * RETURNS
  2072.  *  void
  2073.  *****************************************************************************/
  2074. void mmi_phnset_exit_gsm_flight_mode_rsp(void *info)
  2075. {
  2076.     /*----------------------------------------------------------------*/
  2077.     /* Local Variables                                                */
  2078.     /*----------------------------------------------------------------*/
  2079.     mmi_nw_cfun_state_rsp_struct *cfun_state_rsp;
  2080.     /*----------------------------------------------------------------*/
  2081.     /* Code Body                                                      */
  2082.     /*----------------------------------------------------------------*/
  2083.     cfun_state_rsp = (mmi_nw_cfun_state_rsp_struct*) info;
  2084.     ClearProtocolEventHandler(PRT_NW_CFUN_STATE_RSP);
  2085. #ifdef MMI_ON_HARDWARE_P
  2086.     if (cfun_state_rsp->result == KAL_TRUE)
  2087.     {
  2088. #endif /* MMI_ON_HARDWARE_P */ 
  2089.         //g_phnset_cntx.curFlightMode = FLIGHTMODE_OFF;
  2090.         g_pwr_context.PowerOnNWStatus &= ~MMI_NW_STATUS_FLIGHT_MODE;    /* 0x04: Flight mode */
  2091.         /* refresh status icons */
  2092.         PhnsetFlightModeRestoreStatusIconFlags();
  2093.         UpdateStatusIcons();
  2094.         /* write current mode to nvram */
  2095.         PhnsetFlightModeSaveMode();
  2096.         /* diamond, 2005/11/17 Force to draw signal level because signal level indication comes before flight mode switch rsp */
  2097.         ChangeStatusIconLevel(STATUS_ICON_SIGNAL_STRENGTH, gSignalStrengthLevel);
  2098.     #ifdef __MMI_SUBLCD__
  2099.         ChangeStatusIconLevel(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH, gSignalStrengthLevel);
  2100.     #endif 
  2101.         //DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  2102.         mmi_netset_switch_preferred_mode();
  2103.     #ifdef MMI_ON_HARDWARE_P
  2104.     }
  2105.     else
  2106.     {
  2107.         DisplayPopup(
  2108.             (U8*) GetString(STR_GLOBAL_NOT_DONE),
  2109.             IMG_GLOBAL_UNFINISHED,
  2110.             1,
  2111.             UI_POPUP_NOTIFYDURATION_TIME,
  2112.             (U8) ERROR_TONE);
  2113.         DeleteScreenIfPresent(SCR_FLIGHT_MODE_PROGRESS);
  2114.     }
  2115.     #endif /* MMI_ON_HARDWARE_P */ 
  2116. }
  2117. /*****************************************************************************
  2118.  * FUNCTION
  2119.  *  mmi_phnset_exit_gsm_flight_mode
  2120.  * DESCRIPTION
  2121.  *  Exit flight mode from WLAN preferred mode
  2122.  * PARAMETERS
  2123.  *  void
  2124.  * RETURNS
  2125.  *  void
  2126.  *****************************************************************************/
  2127. void mmi_phnset_exit_gsm_flight_mode(void)
  2128. {
  2129.     /*----------------------------------------------------------------*/
  2130.     /* Local Variables                                                */
  2131.     /*----------------------------------------------------------------*/
  2132.     MYQUEUE Message;
  2133.     mmi_nw_cfun_state_req_struct *cfun_state_req;
  2134.     /*----------------------------------------------------------------*/
  2135.     /* Code Body                                                      */
  2136.     /*----------------------------------------------------------------*/
  2137. #if 0
  2138. /* under construction !*/
  2139. /* under construction !*/
  2140. /* under construction !*/
  2141. /* under construction !*/
  2142. /* under construction !*/
  2143. /* under construction !*/
  2144. /* under construction !*/
  2145. /* under construction !*/
  2146. /* under construction !*/
  2147. /* under construction !*/
  2148. /* under construction !*/
  2149. #endif /* 0 */
  2150.     cfun_state_req = OslConstructDataPtr(sizeof(mmi_nw_cfun_state_req_struct));
  2151.     cfun_state_req->cfun_state = 1; /* normal mode */
  2152.     SetProtocolEventHandler(mmi_phnset_exit_gsm_flight_mode_rsp, PRT_NW_CFUN_STATE_RSP);
  2153.     mmi_netset_entry_preferred_mode_progress();  /* show searching screen */
  2154.     Message.oslMsgId = PRT_NW_CFUN_STATE_REQ;
  2155.     Message.oslDataPtr = (oslParaType*) cfun_state_req;
  2156.     Message.oslPeerBuffPtr = NULL;
  2157.     Message.oslSrcId = MOD_MMI;
  2158.     Message.oslDestId = MOD_L4C;
  2159.     OslMsgSendExtQueue(&Message);
  2160. }
  2161. /*****************************************************************************
  2162.  * FUNCTION
  2163.  *  mmi_flight_mode_switch_wlan
  2164.  * DESCRIPTION
  2165.  *  Switch WLAN after flight mode switch
  2166.  * PARAMETERS
  2167.  *  void
  2168.  * RETURNS
  2169.  *  void
  2170.  *****************************************************************************/
  2171. void mmi_flight_mode_switch_wlan(void)
  2172. {
  2173.     /*----------------------------------------------------------------*/
  2174.     /* Local Variables                                                */
  2175.     /*----------------------------------------------------------------*/
  2176.     /*----------------------------------------------------------------*/
  2177.     /* Code Body                                                      */
  2178.     /*----------------------------------------------------------------*/
  2179.     if (g_phnset_cntx.curFlightMode2 == FLIGHTMODE_OFF)
  2180.     {
  2181.         PRINT_INFORMATION(("@@@@@ Flight mode: turn off WLAN @@@@@"));
  2182.         g_phnset_cntx.curFlightMode2 = FLIGHTMODE_SILENT;
  2183.         mmi_wlan_reset_hw_off(mmi_phnset_switch_flight_mode);
  2184.     }
  2185.     else
  2186.     {
  2187.         PRINT_INFORMATION(("@@@@@ Flight mode: turn on WLAN @@@@@"));
  2188.         g_phnset_cntx.curFlightMode2 = FLIGHTMODE_OFF;
  2189.         mmi_wlan_reset_hw_on(mmi_phnset_switch_flight_mode);
  2190.     }
  2191. }
  2192. /*****************************************************************************
  2193.  * FUNCTION
  2194.  *  mmi_phnset_power_on_query_with_flight_mode
  2195.  * DESCRIPTION
  2196.  *  Query when power on and press No
  2197.  * PARAMETERS
  2198.  *  void
  2199.  * RETURNS
  2200.  *  void
  2201.  *****************************************************************************/
  2202. void mmi_phnset_power_on_query_with_normal_mode(void)
  2203. {
  2204.     /*----------------------------------------------------------------*/
  2205.     /* Local Variables                                                */
  2206.     /*----------------------------------------------------------------*/
  2207.     U8 mode = mmi_netset_get_active_preferred_mode();
  2208.     /*----------------------------------------------------------------*/
  2209.     /* Code Body                                                      */
  2210.     /*----------------------------------------------------------------*/
  2211.     if (mode == P_GSM_ONLY)
  2212.     {
  2213.         g_phnset_cntx.curFlightMode2 = FLIGHTMODE_SILENT;
  2214.         PowerOnNormalMode();
  2215.     }
  2216.     else if (mode == P_WLAN_ONLY)
  2217.     {
  2218.         g_phnset_cntx.curFlightMode2 = FLIGHTMODE_OFF;
  2219.         PowerOnFlightMode();
  2220.     }
  2221.     else
  2222.     {
  2223.         g_phnset_cntx.curFlightMode2 = FLIGHTMODE_OFF;
  2224.         PowerOnNormalMode();
  2225.     }
  2226. }
  2227. /*****************************************************************************
  2228.  * FUNCTION
  2229.  *  mmi_phnset_power_on_query_with_flight_mode
  2230.  * DESCRIPTION
  2231.  *  Query when power on and press Yes
  2232.  * PARAMETERS
  2233.  *  void
  2234.  * RETURNS
  2235.  *  void
  2236.  *****************************************************************************/
  2237. void mmi_phnset_power_on_query_with_flight_mode(void)
  2238. {
  2239.     /*----------------------------------------------------------------*/
  2240.     /* Local Variables                                                */
  2241.     /*----------------------------------------------------------------*/
  2242.     /*----------------------------------------------------------------*/
  2243.     /* Code Body                                                      */
  2244.     /*----------------------------------------------------------------*/
  2245.     g_phnset_cntx.curFlightMode2 = FLIGHTMODE_SILENT;
  2246.     PowerOnFlightMode();
  2247.     if (mmi_netset_get_active_preferred_mode() != P_GSM_ONLY)
  2248.     {
  2249.         PRINT_INFORMATION(("@@@@@ Flight mode: turn off WLAN @@@@@"));
  2250.         mmi_wlan_reset_hw_off(NULL);
  2251.     }
  2252. }
  2253. #endif /* __MMI_WLAN_FEATURES__ */
  2254. /*****************************************************************************
  2255.  * FUNCTION
  2256.  *  mmi_netset_switch_preferred_mode
  2257.  * DESCRIPTION
  2258.  *  Switch flight mode beginning and callback function
  2259.  * PARAMETERS
  2260.  *  void
  2261.  * RETURNS
  2262.  *  void
  2263.  *****************************************************************************/
  2264. void mmi_phnset_switch_flight_mode(void)
  2265. {
  2266.     /*----------------------------------------------------------------*/
  2267.     /* Local Variables                                                */
  2268.     /*----------------------------------------------------------------*/
  2269.     U8 i;
  2270.     /*----------------------------------------------------------------*/
  2271.     /* Code Body                                                      */
  2272.     /*----------------------------------------------------------------*/
  2273.     PRINT_INFORMATION(("@@@@@ Flight mode: switch mode @@@@@"));
  2274.     for (i = 0; mmi_phnset_f_mode_req[i].phnset_flight_mode_req != NULL; i++)
  2275.     {
  2276.         if (mmi_phnset_f_mode_req[i].state)
  2277.         {
  2278.             mmi_phnset_f_mode_req[i].state = 0;
  2279.             (*mmi_phnset_f_mode_req[i].phnset_flight_mode_req)();
  2280.             return;
  2281.         }
  2282.     }
  2283.     PhnsetFlightModeSaveMode();
  2284.     if (mmi_bootup_get_active_flight_mode() == FLIGHTMODE_OFF)
  2285.     {
  2286.         mmi_flight_mode_unhide_menu_items();
  2287.     }
  2288.     else
  2289.     {
  2290.         mmi_flight_mode_hide_menu_items();
  2291.     }
  2292.     mmi_phnset_flight_mode_selection_finish();
  2293.     for (i = 0; mmi_phnset_f_mode_req[i].phnset_flight_mode_req != NULL; i++)
  2294.     {
  2295. mmi_phnset_f_mode_req[i].state = 1;
  2296.     }
  2297. }
  2298. /*****************************************************************************
  2299.  * FUNCTION
  2300.  *  mmi_phnset_confirm_to_switch_mode
  2301.  * DESCRIPTION
  2302.  *  Confirm to perform mode switch
  2303.  * PARAMETERS
  2304.  *  void
  2305.  * RETURNS
  2306.  *  void
  2307.  *****************************************************************************/
  2308. void mmi_phnset_confirm_to_switch_mode(void)
  2309. {
  2310.     /*----------------------------------------------------------------*/
  2311.     /* Local Variables                                                */
  2312.     /*----------------------------------------------------------------*/
  2313. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__) || defined(__MMI_IRDA_SUPPORT__)
  2314.     U8 i;
  2315. #endif
  2316.     /*----------------------------------------------------------------*/
  2317.     /* Code Body                                                      */
  2318.     /*----------------------------------------------------------------*/
  2319.     if (g_phnset_cntx.selFlightMode == FLIGHTMODE_QUERY)
  2320.     {
  2321.         PhnsetFlightModeSelectionReq();
  2322.         return;
  2323.     }
  2324.     if ((g_phnset_cntx.selFlightMode != FLIGHTMODE_QUERY) &&
  2325.         (g_phnset_cntx.curFlightMode == FLIGHTMODE_QUERY) &&
  2326.         (mmi_bootup_get_active_flight_mode() == g_phnset_cntx.selFlightMode))
  2327.     {
  2328.         PhnsetFlightModeSelectionReq();
  2329.         return;
  2330.     }
  2331. #ifdef __MMI_WLAN_FEATURES__
  2332.     switch (mmi_netset_get_active_preferred_mode())
  2333.     {
  2334.         case P_GSM_ONLY:
  2335.             mmi_phnset_f_mode_req[0].state = 1;
  2336.             mmi_phnset_f_mode_req[1].state = 0;
  2337.             break;
  2338.         case P_WLAN_ONLY:
  2339.             mmi_phnset_f_mode_req[0].state = 0;
  2340.             mmi_phnset_f_mode_req[1].state = 1;
  2341.             break;
  2342.         default:
  2343.             mmi_phnset_f_mode_req[0].state = 1;
  2344.             mmi_phnset_f_mode_req[1].state = 1;
  2345.             break;
  2346.     }
  2347. #else /* __MMI_WLAN_FEATURES__ */
  2348.     mmi_phnset_f_mode_req[0].state = 1; /* GSM always needs to switch */
  2349. #endif /* __MMI_WLAN_FEATURES__ */
  2350. #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  2351.     for (i = 0; mmi_phnset_f_mode_req[i].phnset_flight_mode_req != NULL; i++)
  2352.     {
  2353.         if (mmi_phnset_f_mode_req[i].phnset_flight_mode_req == mmi_flight_mode_switch_bluetooth)
  2354.         {
  2355.             mmi_phnset_f_mode_req[i].state = 1;
  2356.             break;
  2357.         }
  2358.     }
  2359. #endif
  2360. #ifdef __MMI_IRDA_SUPPORT__
  2361.     for (i = 0; mmi_phnset_f_mode_req[i].phnset_flight_mode_req != NULL; i++)
  2362.     {
  2363.         if (mmi_phnset_f_mode_req[i].phnset_flight_mode_req == mmi_flight_mode_switch_irda)
  2364.         {
  2365.             mmi_phnset_f_mode_req[i].state = 1;
  2366.             break;
  2367.         }
  2368.     }
  2369. #endif
  2370.     gSetModeFromMenu = MMI_TRUE;
  2371.     EntryFlightModeProgress();  /* show searching screen */
  2372. #ifdef __MMI_WLAN_FEATURES__
  2373.     if (mmi_phnset_f_mode_req[0].state == 0)
  2374.     {
  2375.         g_phnset_cntx.curFlightMode = g_phnset_cntx.selFlightMode;
  2376.     }
  2377. #endif /* __MMI_WLAN_FEATURES__ */
  2378.     mmi_phnset_switch_flight_mode();
  2379. }
  2380. #endif /* __FLIGHT_MODE_SUPPORT__ */