MMITask.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.  * MMITask.C
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   Protocol task functionality.
  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.  * removed!
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * removed!
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * removed!
  95.  *
  96.  * removed!
  97.  * removed!
  98.  * removed!
  99.  *
  100.  * removed!
  101.  * removed!
  102.  * removed!
  103.  *
  104.  * removed!
  105.  * removed!
  106.  * removed!
  107.  *
  108.  * removed!
  109.  * removed!
  110.  * removed!
  111.  *
  112.  * removed!
  113.  * removed!
  114.  * removed!
  115.  *
  116.  * removed!
  117.  * removed!
  118.  * removed!
  119.  *
  120.  * removed!
  121.  * removed!
  122.  * removed!
  123.  *
  124.  * removed!
  125.  * removed!
  126.  * removed!
  127.  *
  128.  * removed!
  129.  * removed!
  130.  * removed!
  131.  *
  132.  * removed!
  133.  * removed!
  134.  * removed!
  135.  *
  136.  * removed!
  137.  * removed!
  138.  * removed!
  139.  *
  140.  * removed!
  141.  * removed!
  142.  * removed!
  143.  *
  144.  * removed!
  145.  * removed!
  146.  * removed!
  147.  *
  148.  * removed!
  149.  * removed!
  150.  * removed!
  151.  *
  152.  * removed!
  153.  * removed!
  154.  * removed!
  155.  *
  156.  * removed!
  157.  * removed!
  158.  * removed!
  159.  *
  160.  * removed!
  161.  * removed!
  162.  * removed!
  163.  *
  164.  * removed!
  165.  * removed!
  166.  * removed!
  167.  *
  168.  * removed!
  169.  * removed!
  170.  * removed!
  171.  *
  172.  * removed!
  173.  * removed!
  174.  * removed!
  175.  *
  176.  * removed!
  177.  * removed!
  178.  * removed!
  179.  *
  180.  * removed!
  181.  * removed!
  182.  * removed!
  183.  *
  184.  * removed!
  185.  * removed!
  186.  * removed!
  187.  *
  188.  * removed!
  189.  * removed!
  190.  * removed!
  191.  *
  192.  * removed!
  193.  * removed!
  194.  * removed!
  195.  *
  196.  * removed!
  197.  * removed!
  198.  * removed!
  199.  *
  200.  * removed!
  201.  * removed!
  202.  * removed!
  203.  *
  204.  * removed!
  205.  * removed!
  206.  * removed!
  207.  *
  208.  * removed!
  209.  * removed!
  210.  * removed!
  211.  *
  212.  * removed!
  213.  * removed!
  214.  * removed!
  215.  *
  216.  * removed!
  217.  * removed!
  218.  * removed!
  219.  *
  220.  * removed!
  221.  * removed!
  222.  * removed!
  223.  *
  224.  * removed!
  225.  * removed!
  226.  * removed!
  227.  * removed!
  228.  *
  229.  * removed!
  230.  * removed!
  231.  * removed!
  232.  *
  233.  * removed!
  234.  * removed!
  235.  * removed!
  236.  *
  237.  * removed!
  238.  * removed!
  239.  * removed!
  240.  *
  241.  * removed!
  242.  * removed!
  243.  * removed!
  244.  *
  245.  * removed!
  246.  * removed!
  247.  * removed!
  248.  *
  249.  * removed!
  250.  * removed!
  251.  * removed!
  252.  *
  253.  * removed!
  254.  * removed!
  255.  * removed!
  256.  *
  257.  * removed!
  258.  * removed!
  259.  * removed!
  260.  *
  261.  * removed!
  262.  * removed!
  263.  * removed!
  264.  *
  265.  * removed!
  266.  * removed!
  267.  * removed!
  268.  *
  269.  * removed!
  270.  * removed!
  271.  * removed!
  272.  * removed!
  273.  *
  274.  * removed!
  275.  * removed!
  276.  * removed!
  277.  *
  278.  * removed!
  279.  * removed!
  280.  * removed!
  281.  *
  282.  * removed!
  283.  * removed!
  284.  * removed!
  285.  *
  286.  * removed!
  287.  * removed!
  288.  * removed!
  289.  *
  290.  * removed!
  291.  * removed!
  292.  * removed!
  293.  *
  294.  * removed!
  295.  * removed!
  296.  * removed!
  297.  *
  298.  * removed!
  299.  * removed!
  300.  * removed!
  301.  *
  302.  * removed!
  303.  * removed!
  304.  * removed!
  305.  *
  306.  * removed!
  307.  * removed!
  308.  * removed!
  309.  *
  310.  * removed!
  311.  * removed!
  312.  * removed!
  313.  *
  314.  * removed!
  315.  * removed!
  316.  * removed!
  317.  *
  318.  * removed!
  319.  * removed!
  320.  * removed!
  321.  *
  322.  * removed!
  323.  * removed!
  324.  * removed!
  325.  *
  326.  * removed!
  327.  * removed!
  328.  * removed!
  329.  *
  330.  * removed!
  331.  * removed!
  332.  * removed!
  333.  *
  334.  * removed!
  335.  * removed!
  336.  * removed!
  337.  *
  338.  * removed!
  339.  * removed!
  340.  * removed!
  341.  *
  342.  * removed!
  343.  * removed!
  344.  * removed!
  345.  *
  346.  * removed!
  347.  * removed!
  348.  * removed!
  349.  *
  350.  * removed!
  351.  * removed!
  352.  * removed!
  353.  *
  354.  * removed!
  355.  * removed!
  356.  * removed!
  357.  *
  358.  * removed!
  359.  * removed!
  360.  * removed!
  361.  *
  362.  * removed!
  363.  * removed!
  364.  * removed!
  365.  *
  366.  * removed!
  367.  * removed!
  368.  * removed!
  369.  *
  370.  * removed!
  371.  * removed!
  372.  * removed!
  373.  *
  374.  * removed!
  375.  * removed!
  376.  * removed!
  377.  *
  378.  * removed!
  379.  * removed!
  380.  * removed!
  381.  *
  382.  * removed!
  383.  * removed!
  384.  * removed!
  385.  *
  386.  * removed!
  387.  * removed!
  388.  * removed!
  389.  *
  390.  * removed!
  391.  * removed!
  392.  * removed!
  393.  *
  394.  * removed!
  395.  * removed!
  396.  * removed!
  397.  *
  398.  * removed!
  399.  * removed!
  400.  * removed!
  401.  *
  402.  * removed!
  403.  * removed!
  404.  * removed!
  405.  *
  406.  * removed!
  407.  * removed!
  408.  * removed!
  409.  *
  410.  * removed!
  411.  * removed!
  412.  * removed!
  413.  *
  414.  * removed!
  415.  * removed!
  416.  * removed!
  417.  *
  418.  * removed!
  419.  * removed!
  420.  * removed!
  421.  *
  422.  * removed!
  423.  * removed!
  424.  * removed!
  425.  *
  426.  * removed!
  427.  * removed!
  428.  * removed!
  429.  *
  430.  * removed!
  431.  * removed!
  432.  * removed!
  433.  *
  434.  * removed!
  435.  * removed!
  436.  * removed!
  437.  *
  438.  * removed!
  439.  * removed!
  440.  * removed!
  441.  *
  442.  * removed!
  443.  * removed!
  444.  * removed!
  445.  *
  446.  * removed!
  447.  * removed!
  448.  * removed!
  449.  *
  450.  * removed!
  451.  * removed!
  452.  * removed!
  453.  *
  454.  * removed!
  455.  * removed!
  456.  * removed!
  457.  *
  458.  * removed!
  459.  * removed!
  460.  * removed!
  461.  *
  462.  * removed!
  463.  * removed!
  464.  * removed!
  465.  *
  466.  * removed!
  467.  * removed!
  468.  * removed!
  469.  *
  470.  * removed!
  471.  * removed!
  472.  * removed!
  473.  *
  474.  * removed!
  475.  * removed!
  476.  * removed!
  477.  *
  478.  * removed!
  479.  * removed!
  480.  * removed!
  481.  *
  482.  * removed!
  483.  * removed!
  484.  * removed!
  485.  *
  486.  * removed!
  487.  * removed!
  488.  * removed!
  489.  *
  490.  * removed!
  491.  * removed!
  492.  * removed!
  493.  *
  494.  * removed!
  495.  * removed!
  496.  * removed!
  497.  *
  498.  * removed!
  499.  * removed!
  500.  * removed!
  501.  *
  502.  * removed!
  503.  * removed!
  504.  * removed!
  505.  *
  506.  * removed!
  507.  * removed!
  508.  * removed!
  509.  *
  510.  * removed!
  511.  * removed!
  512.  * removed!
  513.  *
  514.  * removed!
  515.  * removed!
  516.  * removed!
  517.  *
  518.  * removed!
  519.  * removed!
  520.  * removed!
  521.  *
  522.  * removed!
  523.  * removed!
  524.  * removed!
  525.  *
  526.  * removed!
  527.  * removed!
  528.  * removed!
  529.  *
  530.  *------------------------------------------------------------------------------
  531.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  532.  *============================================================================
  533.  ****************************************************************************/
  534. /**
  535.  * Copyright Notice
  536.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  537.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  538.  *  (It is illegal to remove this copyright notice from this software or any
  539.  *  portion of it)
  540.  */
  541. /**************************************************************
  542.    FILENAME : MMItask.c
  543.    PURPOSE     : Protocol task functionality 
  544.    REMARKS     : nil
  545.    AUTHOR      : Neeraj Sharma
  546.    DATE     : Dec' 28, 2002
  547. **************************************************************/
  548. /***************************************************************************** 
  549. * Include
  550. *****************************************************************************/
  551. #if !defined(__MTK_TARGET__) || defined(MMI_ON_WIN32)
  552. #include <windows.h>
  553. #endif 
  554. #include "stdC.h"
  555. #include <string.h>
  556. #include "L4Dr1.h"
  557. #include "MMI_features.h"
  558. /* __CUSTPACK_MULTIBIN     Terry   BEGIN */
  559. #include "wgui_categories_inputs.h"
  560. #include "IMERes.h"
  561. /* __CUSTPACK_MULTIBIN     Terry   END */
  562. #include "GlobalConstants.h"
  563. #include "TaskInit.h"
  564. #include "MMItaskProt.h"
  565. #if defined(__MMI_RESOURCE_ENFB_SUPPORT__)
  566.     #include "ResMemMgrGprot.h"
  567. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  568. #include "ThrdOsInterface.h"
  569. #include "GlobalStruct.h"
  570. #include "DebugInitDef.h"
  571. #include "ProtocolEvents.h"
  572. #include "AsyncEventsGprot.h"
  573. #include "ATHandlerProt.h"
  574. #include "AlarmFrameWorkProt.h"
  575. #include "CallManagementGprot.h"
  576. #include "CallManagementStruct.h"
  577. #include "SettingProfile.h"
  578. #include "ProfileGprots.h"
  579. #include "Service.h"
  580. #include "SATGProts.h"
  581. #include "CPHSProtocolHandlers.h"
  582. #include "EngineerModeProt.h"
  583. #include "FactoryModeProt.h"
  584. #include "gpioInc.h"
  585. #include "PhoneBookGProt.h"
  586. #include "CallHistoryMain.h"
  587. #include "FunAndGamesProts.h"
  588. #include "MessagesResourceData.h"
  589. #include "OrganizerGprot.h"
  590. #include "AlarmGprot.h"
  591. #include "ScheduledPowerOnOffGprot.h"
  592. #include "Unicodedcl.h"
  593. #include "Unicodedef.h"
  594. #include "OrganizerGProt.h"
  595. #include "ExtraGProt.h"
  596. #include "IdleAppProt.h"
  597. #include "Conversions.h"
  598. #include "NVRAMProt.h"
  599. #include "datetimetype.h"
  600. #include "app_datetime.h"
  601. //KP Jerry add on 2007-2-15 start
  602. #ifdef __DUAL_SIM_SUPPORT__
  603. extern void LoadSIMSwitchAllData(void);
  604. #endif
  605. //KP Jerry add on 2007-2-15 end
  606. #ifdef __MMI_THEMES_V2_SUPPORT__
  607. #include "ThemeManager.h"
  608. #endif 
  609. #include "MessagesExDcl.h"
  610. #ifdef __MMI_USB_SUPPORT__
  611. #include "USBDeviceGprot.h"
  612. #ifndef MMI_ON_WIN32
  613. extern kal_bool INT_USBBoot(void);
  614. #endif 
  615. #endif /* __MMI_USB_SUPPORT__ */ 
  616. #ifdef __MMI_IRDA_SUPPORT__
  617. #include "IrdaMMIGprots.h"
  618. #endif 
  619. #ifdef __MMI_BT_HP_SUPPORT__
  620. #include "BTMMIHPGprots.h"
  621. #endif 
  622. #ifdef __MMI_BT_SUPPORT__
  623. #include "BTMMIScrGprots.h"
  624. #endif 
  625. #ifdef __MMI_FILE_MANAGER__
  626. #include "FileManagerGProt.h"
  627. #include "msdc_def.h"
  628. #endif /* __MMI_FILE_MANAGER__ */ 
  629. #ifdef __MMI_WEBCAM__
  630. #include "mdi_datatype.h"
  631. #include "mdi_webcam.h"
  632. #endif /* __MMI_WEBCAM__ */ 
  633. #include "SoundEffect.h"
  634. #include "vObjects.h"
  635. #include "vCalendar.h"
  636. #include "ShortcutsProts.h"
  637. #include "SubLCDHistoryGprot.h"
  638. #include "ToDoListDef.h"
  639. #include "DataAccountGProt.h"
  640. #include "WPSSProtos.h"
  641. #include "CallerIdGprot.h"
  642. #if defined(__MMI_STOPWATCH__)
  643. #include "StopwatchGprot.h"
  644. #endif 
  645. #if defined(__MMI_EMAIL__)
  646. #include "EmailAppGProt.h"
  647. #endif /* def __MMI_EMAIL__ */
  648. #include "OSThreadInterfaceGprot.h"
  649. #ifdef MMI_ON_WIN32
  650. extern BOOL flagMMIStart;
  651. #include "BUildCfg.h"
  652. #endif /* MMI_ON_WIN32 */ 
  653. #include "EventsGprot.h"
  654. #include "AllAppGprot.h"
  655. #include "WrapperGprot.h"
  656. #include "QueueGprot.h"
  657. #ifdef __MMI_EBOOK_READER__
  658. #include "EbookProt.h"
  659. #endif 
  660. #include "KeyBrd.h"
  661. #include "NVRAMExdcl.h"
  662. #include "SimDetectionGprot.h"
  663. #include "wgui_status_icons.h"
  664. #include "PowerOnChargerProt.h"
  665. #include "SettingGprots.h"
  666. #include "SimDetectionGexdcl.h"
  667. #include "PhoneSetupGprots.h"   /* PhnsetReadNvramCalibrationData */
  668. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  669. #include "SmsGuiInterfaceType.h"
  670. #endif 
  671. #ifdef __MMI_VOIP__
  672. #include "VoIPGProt.h"
  673. #endif
  674. #ifdef __MMI_POC__
  675. #include "PoCGProt.h"
  676. #endif 
  677. #ifdef __SYNCML_SUPPORT__
  678. #include "SyncMLGProt.h" /* mmi_syncml_init */
  679. #endif
  680. extern void InitAlarmHandler(void);
  681. #if defined(__MMI_THEMES_APPLICATION__)
  682. extern void InitThemes(void);
  683. #endif
  684. #ifdef __FLIGHT_MODE_SUPPORT__
  685. #include "WallpaperDefs.h"
  686. #include "DownloadDefs.h"
  687. #include "PhoneSetup.h"
  688. #endif /* __FLIGHT_MODE_SUPPORT__ */ 
  689. extern void ATHandlerInit(void);
  690. #if defined(__MMI_NITZ__)
  691. extern void NITZHandlerInit(void);
  692. #endif 
  693. extern void PhnsetInitSetTimeNDateNvram(void);
  694. extern void ReadValueCityNVRAM(void);
  695. #ifndef MMI_ON_WIN32
  696. #include "lcd_sw.h"
  697. #include "lcd_sw_inc.h"
  698. #include "sublcd.h"
  699. #else /* MMI_ON_WIN32 */ 
  700. #include "lcd_if.h"
  701. #endif /* MMI_ON_WIN32 */ 
  702. #include "ComposeRingToneProts.h"
  703. #ifdef __MMI_IMPS__
  704. #include "mmi_imps_gprot.h"
  705. #endif 
  706. /* Cylen */
  707. #include "gdi_include.h"
  708. //#include "gdi_lcd.h"
  709. //extern void gdi_init(void);
  710. //extern GDI_RESULT gdi_layer_clear(gdi_color bg_color);
  711. //extern gdi_color GDI_COLOR_BLACK;
  712. #ifdef __MMI_UNIFIED_MESSAGE__
  713. #include "UnifiedMessageGProt.h"
  714. #endif 
  715. #ifdef __MMI_UNIFIED_COMPOSER__
  716. #include "UnifiedComposerGProt.h"
  717. #endif 
  718. #ifdef __MMI_WLAN_FEATURES__
  719. #include "NetworkSetupDefs.h"
  720. #endif
  721. //U8 isIdleScreenReached=0;
  722. //U8 IsBeforePowerOn=1;
  723. U8 gInitAllAppFlag = 0;
  724. U8 gInsertSimAppFlag = 0;
  725. MYTIME StartUpTime, LastDuration;
  726. extern U8 isEarphonePlugged;
  727. extern U8 gMMIClamState;
  728. extern void goto_opening_screen(void);
  729. extern void InitNvramData(void);
  730. #ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
  731. extern void PmgInitExtMelodyStruct(void);
  732. #endif 
  733. extern void InitAllApplications(void);
  734. extern void InitDownloadNVRAM(void);
  735. extern void ReadThemesFromNVRAM(void);
  736. extern void initnvramprofapp(void);
  737. extern void InitializeChargingScr(void);
  738. extern void InitializeAll(void);
  739. extern void QuitSystemOperation(void);
  740. extern void mmi_pwron_entry_animation_screen(void);
  741. /* 
  742.  * for MDI 
  743.  */
  744. extern void mdi_audio_init(void);
  745. extern void mdi_audio_init_event_hdlrs(void);
  746. extern void setup_UI_wrappers(void);
  747. /* 
  748.  * For Input method
  749.  */
  750. #ifdef __MMI_T9__
  751. extern void InitInputMethod(void);
  752. #elif defined __MMI_ZI__
  753. extern void InitZiInputMethod(void);
  754. //KP Jerry add on 2007-3-8 start
  755. #elif defined __MMI_CSTAR__
  756. extern void InitCstarInputMethod(void);
  757. //KP Jerry add on 2007-3-8 end
  758. #elif defined(__MMI_KA__)
  759. extern void InitKonkaInputMethod(void);
  760. #elif defined(__MMI_ITAP__)
  761. /* under construction !*/
  762. #endif 
  763. /* __CUSTPACK_MULTIBIN     Terry   BEGIN */
  764. extern U8 MMI_english_input_mode_set[INPUT_MODE_MAX_NUM];
  765. extern U8 MMI_qsearch_input_mode_set[INPUT_MODE_MAX_NUM];
  766. extern U8 MMI_all_input_mode_set[INPUT_MODE_MAX_NUM];
  767. #ifdef __MMI_PREFER_INPUT_METHOD__
  768. extern U16 MMI_all_prefered_input_mode_set[INPUT_MODE_MAX_NUM];
  769. #endif 
  770. extern const sIMEModeDetails *gIMEModeArray;
  771. extern const sIMEModeDetails *gIMEQSearchModeArray;
  772. extern const U8 MMI_implement_input_mode_set[];
  773. /* __CUSTPACK_MULTIBIN     Terry   END */
  774. extern void mmiapi_init_engine(void);
  775. /* 
  776.  * Move InitPhoneSetupApp() to InitializeAll() for text encoding 
  777.  */
  778. extern void InitPhoneSetupApp(void);
  779. extern void InitPhoneSetupCntx(void);
  780. extern void InitAppMem(void);
  781. extern void CheckAndPrintMsgId(U16 Id);
  782. #if defined(__MMI_VRSD__)
  783. extern void mmi_vrsd_init(void);
  784. #endif 
  785. #if defined(__MMI_VRSI__)
  786. extern mmi_vrsi_init(void);
  787. #endif 
  788. #if defined(__MMI_SOUND_RECORDER__)
  789. extern void InitSoundRecorderApp(void);
  790. #endif 
  791. extern void mmi_phb_sos_list_init(void);
  792. #ifdef __MMI_MESSAGES_CHAT__
  793. extern void InitializeChatApp(void);
  794. #endif 
  795. #ifdef __MMI_IRDA_SUPPORT__
  796. extern void mmi_irda_init_menu_hdlr(void);
  797. #endif 
  798. #ifdef __MMI_BT_HP_SUPPORT__
  799. extern void mmi_bt_scr_init(void);
  800. extern void mmi_bt_init_menu_highlight_hdlr(void);
  801. #endif /* __MMI_BT_HP_SUPPORT__ */ 
  802. /* for PC simulator */
  803. #if !defined(__MMI_BT_SUPPORT__) && defined(MMI_ON_WIN32)
  804. extern void mmi_bt_init(void);
  805. #endif 
  806. #ifndef __DISABLE_SHORTCUTS_IMPL__
  807. extern void ShctInit(void);
  808. #endif 
  809. extern void SetDateTime(void *t);
  810. extern void mmi_frm_sms_init(void);
  811. /* diamond, 2005/07/05 Flight mode */
  812. #ifdef __FLIGHT_MODE_SUPPORT__
  813. extern void PowerOnFlightMode(void);
  814. extern void PowerOnNormalMode(void);
  815. extern void EntryQueryFlightModeScreen(void);
  816. extern void PhnsetFlightModeQueryBackground(void);  /* diamond, 2006/01/01 Force to draw the background */
  817. extern void PhnsetFlightModePowerOnException(void);
  818. extern void mmi_flight_mode_set_mode(U8 bFlightMode); /* send the mode to L4C ASAP to speed up the L4C startup time */
  819. extern PHNSET_CNTX g_phnset_cntx;
  820. #endif /* __FLIGHT_MODE_SUPPORT__ */ 
  821. /* end, diamond */
  822. #ifdef __MMI_BG_SOUND_EFFECT__
  823. extern void mmi_bgsnd_init(void);
  824. #endif 
  825. #if defined(__MMI_FM_RADIO_SCHEDULE_REC__)
  826. extern void mmi_fmsr_init_app(void);
  827. #endif 
  828. #if defined(__MMI_DOWNLOAD_AGENT__)
  829. extern void mmi_da_init_app(void);
  830. #endif 
  831. extern void mdi_audio_set_audio_mode(U8 mode);
  832. extern void PhnsetReadGPIOSetting(void);
  833. #ifdef __MMI_USER_CTRL_PLMN_SUPPORT__
  834. extern void mmi_netset_init_user_ctrl_plmn(void);
  835. #endif 
  836. #ifdef __MMI_SWFLASH__
  837. extern void mmi_swflash_init_app(void);
  838. #endif
  839. #ifdef __MMI_CCA_SUPPORT__
  840. extern void mmi_cca_init(void);
  841. #endif
  842. #ifndef MMI_ON_WIN32
  843. #include "l4dr.h"
  844. #include "MMITaskProt.h"
  845. /* 
  846.  * MTK added for two kinds of timer, one is for exactly time, another allow to delay.
  847.  */
  848. stack_timer_struct base_timer1; /* no alignment timer */
  849. stack_timer_struct base_timer2; /* allow alignment timer */
  850. event_scheduler *event_scheduler1_ptr, *event_scheduler2_ptr;
  851. oslMsgqid mmi_ext_qid;
  852. MMI_BOOL g_keypad_flag = MMI_FALSE;
  853. drv_get_key_func keypad_ptr;
  854. extern kal_mutexid mmi_mutex_trace;
  855. /*****************************************************************************
  856.  * FUNCTION
  857.  *  MMI_Init
  858.  * DESCRIPTION
  859.  *  MMI Init Function
  860.  * PARAMETERS
  861.  *  task_indx       [IN]        Index of task
  862.  * RETURNS
  863.  *  void
  864.  *****************************************************************************/
  865. MMI_BOOL MMI_Init(task_indx_type task_indx)
  866. {
  867.     /*----------------------------------------------------------------*/
  868.     /* Local Variables                                                */
  869.     /*----------------------------------------------------------------*/
  870.     /*----------------------------------------------------------------*/
  871.     /* Code Body                                                      */
  872.     /*----------------------------------------------------------------*/
  873. #ifndef MMI_ON_WIN32
  874.     mmi_mutex_trace = kal_create_mutex("mmi_trace");
  875. #endif 
  876.     mmi_frm_get_2step_keys();
  877.     /* 
  878.      * initial the system service timer 
  879.      */
  880.     L4InitTimer();
  881.     setup_UI_wrappers();
  882. #if defined(__MMI_RESOURCE_ENFB_SUPPORT__)
  883.     /* 
  884.      * Init Resource Memory Manamger  for E-NFB
  885.      */
  886. mmi_frm_resmem_init();
  887. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  888.     return MMI_TRUE;
  889. }
  890. /*****************************************************************************
  891.  * FUNCTION
  892.  *  EvshedMMITimerHandler
  893.  * DESCRIPTION
  894.  *  MMI Timer Event Scheduler
  895.  * PARAMETERS
  896.  *  dataPtr     [IN]        Data from L4
  897.  * RETURNS
  898.  *  void
  899.  *****************************************************************************/
  900. void EvshedMMITimerHandler(void *dataPtr)
  901. {
  902.     /*----------------------------------------------------------------*/
  903.     /* Local Variables                                                */
  904.     /*----------------------------------------------------------------*/
  905.     stack_timer_struct *stack_timer_ptr;
  906.     stack_timer_ptr = (stack_timer_struct*) dataPtr;
  907.     /*----------------------------------------------------------------*/
  908.     /* Code Body                                                      */
  909.     /*----------------------------------------------------------------*/
  910.     if (stack_timer_ptr == &base_timer1)
  911.     {
  912.         if (stack_is_time_out_valid(&base_timer1))
  913.         {
  914.             evshed_timer_handler(event_scheduler1_ptr);
  915.         }
  916.         stack_process_time_out(&base_timer1);
  917.     }
  918.     else if (stack_timer_ptr == &base_timer2)
  919.     {
  920.         if (stack_is_time_out_valid(&base_timer2))
  921.         {
  922.             evshed_timer_handler(event_scheduler2_ptr);
  923.         }
  924.         stack_process_time_out(&base_timer2);
  925.     }
  926. }
  927. #endif /* MMI_ON_WIN32 */ 
  928. /*****************************************************************************
  929.  * FUNCTION
  930.  *  FlightModeCheckBeforeAnimation
  931.  * DESCRIPTION
  932.  *  Flight mode query screen before animation
  933.  * PARAMETERS
  934.  *  void
  935.  * RETURNS
  936.  *  void
  937.  *****************************************************************************/
  938. /* static U8 gFlightModeFromCalibration; */
  939. void FlightModeCheckBeforeAnimation()
  940. {
  941.     /*----------------------------------------------------------------*/
  942.     /* Local Variables                                                */
  943.     /*----------------------------------------------------------------*/
  944.     /*----------------------------------------------------------------*/
  945.     /* Code Body                                                      */
  946.     /*----------------------------------------------------------------*/
  947.     /* diamond, 2005/07/05 Flight mode */
  948. #ifdef __FLIGHT_MODE_SUPPORT__
  949.     switch (g_phnset_cntx.curFlightMode)
  950.     {
  951.         case FLIGHTMODE_QUERY:
  952.             TurnOnBacklight(1);
  953.             PhnsetFlightModeQueryBackground();  /* diamond, 2006/01/01 Force to draw the background */
  954.             EntryQueryFlightModeScreen();
  955.             break;
  956.         case FLIGHTMODE_SILENT:
  957.         case FLIGHTMODE_OFF:
  958.             mmi_bootup_exit_flight_mode_query();
  959.             break;
  960.         default:
  961.             PowerOnNormalMode();
  962.             break;
  963.     }
  964. #else /* __FLIGHT_MODE_SUPPORT__ */ 
  965.     mmi_bootup_entry_animation();   /* not necessary to enter flight mode query screen if it is not supported */
  966. #endif /* __FLIGHT_MODE_SUPPORT__ */ 
  967.     /* end, diamond */
  968. }
  969. /*****************************************************************************
  970.  * FUNCTION
  971.  *  InitEventHandlersBeforePowerOn
  972.  * DESCRIPTION
  973.  *  Init event handlers before power on indication
  974.  * PARAMETERS
  975.  *  void
  976.  * RETURNS
  977.  *  void
  978.  *****************************************************************************/
  979. static void InitEventHandlersBeforePowerOn(void)
  980. {
  981.     /*----------------------------------------------------------------*/
  982.     /* Local Variables                                                */
  983.     /*----------------------------------------------------------------*/
  984.     /*----------------------------------------------------------------*/
  985.     /* Code Body                                                      */
  986.     /*----------------------------------------------------------------*/
  987.     InitEvents();
  988.     InitKeypadBeforePWRON();
  989. #ifndef MMI_ON_WIN32
  990.     SetProtocolEventHandler(GpioDetectInd, MSG_ID_MMI_EQ_GPIO_DETECT_IND);
  991.     SetProtocolEventHandler(BatteryStatusRsp, MSG_ID_MMI_EQ_BATTERY_STATUS_IND);
  992. #ifdef __MMI_USB_SUPPORT__
  993.     SetProtocolEventHandler(UsbDetectIndHdlr, PRT_EQ_USB_DETECT_IND);
  994. #endif 
  995.     InitAlarmHandler();
  996. #endif /* MMI_ON_WIN32 */ 
  997. #ifdef __MMI_TVOUT__
  998.     /* init tvout, since TV-out indication will come before poweron indication */
  999.     mmi_phnset_early_init_tvout_before_pwron();
  1000. #endif    
  1001. }
  1002. #ifndef MMI_ON_WIN32
  1003. /*****************************************************************************
  1004.  * FUNCTION
  1005.  *  mmi_frm_check_is_valid_msg
  1006.  * DESCRIPTION
  1007.  *  Check if the follow message is useful
  1008.  *  If the successive messages are MSG_ID_TIMER_EXPIRY,
  1009.  *  only one message will be usegful. We will keep only one
  1010.  *  MSG_ID_TIMER_EXPIRY in the queue
  1011.  * PARAMETERS
  1012.  *  base        [IN]     
  1013.  *  msg         [IN]     
  1014.  * RETURNS
  1015.  *  0 - the message is invalid, and discard the message
  1016.  *  1 - the message is vaild
  1017.  *****************************************************************************/
  1018. U8 mmi_frm_check_is_valid_msg(MYQUEUE *base, MYQUEUE *msg)
  1019. {
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Local Variables                                                */
  1022.     /*----------------------------------------------------------------*/
  1023.     /*----------------------------------------------------------------*/
  1024.     /* Code Body                                                      */
  1025.     /*----------------------------------------------------------------*/
  1026.     if ((base != NULL) && (msg != NULL) && (base->msg_id == msg->msg_id))
  1027.     {
  1028.         switch (base->msg_id)
  1029.         {
  1030.             case MSG_ID_TIMER_EXPIRY:
  1031.             {
  1032.                 kal_uint16 msg_len = 0;
  1033.                 stack_timer_struct *base_timer_ptr;
  1034.                 stack_timer_struct *timer_ptr;
  1035.                 base_timer_ptr = (stack_timer_struct*) get_local_para_ptr(base->oslDataPtr, &msg_len);
  1036.                 timer_ptr = (stack_timer_struct*) get_local_para_ptr(msg->oslDataPtr, &msg_len);
  1037.                 if (base_timer_ptr == timer_ptr)
  1038.                 {
  1039.                     stack_is_time_out_valid(base_timer_ptr);
  1040.                     stack_process_time_out(base_timer_ptr);
  1041.                     /* msg is invalid, can discard it */
  1042.                     return 0;
  1043.                 }
  1044.             }
  1045.                 break;
  1046.             default:
  1047.                 break;
  1048.         }
  1049.     }
  1050.     /* msg is valid, can't discard */
  1051.     return 1;
  1052. }
  1053. /*****************************************************************************
  1054.  * FUNCTION
  1055.  *  mmi_frm_fetch_msg_from_extQ_to_circularQ
  1056.  * DESCRIPTION
  1057.  *  fetch the message from external queue and put
  1058.  *  in the circular queue.
  1059.  *  (*) Need to set my_index & mmi_ext_qid before using
  1060.  *  this function
  1061.  * PARAMETERS
  1062.  *  void
  1063.  * RETURNS
  1064.  *  1 - the message is invalid, and discard the message
  1065.  *  0 - the message is vaild
  1066.  *****************************************************************************/
  1067. void mmi_frm_fetch_msg_from_extQ_to_circularQ(void)
  1068. {
  1069.     /*----------------------------------------------------------------*/
  1070.     /* Local Variables                                                */
  1071.     /*----------------------------------------------------------------*/
  1072.     MYQUEUE Message;
  1073.     U32 my_index;
  1074.     U32 queue_node_number = 0;
  1075.     MYQUEUE checkBaseNode = {0};
  1076.     U8 flag = 0;
  1077.     ilm_struct ilm_ptr;
  1078.     /*----------------------------------------------------------------*/
  1079.     /* Code Body                                                      */
  1080.     /*----------------------------------------------------------------*/
  1081.     if (IsInNVRAMProcedure() == MMI_FALSE)
  1082.     {
  1083.         /*
  1084.          * If not in NVRAM access procedure,
  1085.          * receive the message from MMI queue and put in circular queue 
  1086.          */
  1087.         msg_get_ext_queue_info(mmi_ext_qid, &queue_node_number);
  1088.         while ((queue_node_number > 0) && !OslIsCircularQFull())
  1089.         {
  1090.             OslReceiveMsgExtQ(mmi_ext_qid, &Message);
  1091.             OslGetMyTaskIndex(&my_index);
  1092.             OslStackSetActiveModuleID(my_index, MOD_MMI);
  1093.             OslLookUpLastCircularQMsg((void*)&checkBaseNode);
  1094.             if (mmi_frm_check_is_valid_msg(&checkBaseNode, &Message) == 1)
  1095.             {
  1096.                 /* put Message in circular queue */
  1097.                 ilm_ptr.src_mod_id = Message.src_mod_id;
  1098.                 ilm_ptr.dest_mod_id = Message.dest_mod_id;
  1099.                 ilm_ptr.msg_id = Message.msg_id;
  1100.                 ilm_ptr.sap_id = Message.sap_id;
  1101.                 ilm_ptr.local_para_ptr = Message.local_para_ptr;
  1102.                 ilm_ptr.peer_buff_ptr = Message.peer_buff_ptr;
  1103.                 flag = OslWriteCircularQ(&ilm_ptr);
  1104.                 MMI_ASSERT(flag == 1);
  1105.                 /* TIMER use special data in the local_para_ptr field. Can NOT treat as general ILM */
  1106.                 if (Message.src_mod_id != MOD_TIMER)
  1107.                 {
  1108.                     hold_local_para(ilm_ptr.local_para_ptr);
  1109.                     hold_peer_buff(ilm_ptr.peer_buff_ptr);
  1110.                 }
  1111.             }
  1112.             OslFreeInterTaskMsg(&Message);
  1113.             msg_get_ext_queue_info(mmi_ext_qid, &queue_node_number);
  1114.         }
  1115.     }
  1116. }
  1117. #endif /* MMI_ON_WIN32 */ 
  1118. /*****************************************************************************
  1119.  * FUNCTION
  1120.  *  mmi_frm_power_on_set_mode
  1121.  * DESCRIPTION
  1122.  *  Power on set flight mode before initializa all applications
  1123.  * PARAMETERS
  1124.  *  void
  1125.  * RETURNS
  1126.  *  void
  1127.  *****************************************************************************/
  1128. void mmi_frm_power_on_set_mode(void)
  1129. {
  1130.     /*----------------------------------------------------------------*/
  1131.     /* Local Variables                                                */
  1132.     /*----------------------------------------------------------------*/
  1133.     /*----------------------------------------------------------------*/
  1134.     /* Code Body                                                      */
  1135.     /*----------------------------------------------------------------*/
  1136. #ifdef __FLIGHT_MODE_SUPPORT__
  1137.     /* send the mode to L4C ASAP to speed up the L4C startup time */
  1138.     if (g_phnset_cntx.curFlightMode == FLIGHTMODE_SILENT)
  1139.     {
  1140.         mmi_flight_mode_set_mode(1);
  1141.     }
  1142.     else if (g_phnset_cntx.curFlightMode == FLIGHTMODE_OFF)
  1143.     {
  1144.     #ifdef __MMI_WLAN_FEATURES__
  1145.         if (mmi_netset_get_active_preferred_mode() == P_WLAN_ONLY)
  1146.             mmi_flight_mode_set_mode(1);
  1147. else
  1148.     #endif /* __MMI_WLAN_FEATURES__ */
  1149.         mmi_flight_mode_set_mode(0);
  1150.     }
  1151.     else
  1152.     {
  1153.         /* display qurey screen after InitializeAll */
  1154.     }
  1155. #endif /* __FLIGHT_MODE_SUPPORT__ */
  1156. }
  1157. /*****************************************************************************
  1158.  * FUNCTION
  1159.  *  mmi_frm_power_on_init_procedure
  1160.  * DESCRIPTION
  1161.  *  Power on initializations
  1162.  * PARAMETERS
  1163.  *  void
  1164.  * RETURNS
  1165.  *  void
  1166.  *****************************************************************************/
  1167. void mmi_frm_power_on_init_procedure(void)
  1168. {
  1169.     /*----------------------------------------------------------------*/
  1170.     /* Local Variables                                                */
  1171.     /*----------------------------------------------------------------*/
  1172.     static U8 bInit = 0;
  1173.     /*----------------------------------------------------------------*/
  1174.     /* Code Body                                                      */
  1175.     /*----------------------------------------------------------------*/
  1176.     if (!bInit)
  1177.     {
  1178.         InitializeAll();
  1179.         OslDumpDataInFile();
  1180.         InitNvramData();
  1181.         bInit = 1;
  1182.     }
  1183. }
  1184. /*****************************************************************************
  1185.  * FUNCTION
  1186.  *  MMI_task
  1187.  * DESCRIPTION
  1188.  *  Entry function for Protocol task
  1189.  *  
  1190.  *  This receives protocol task events from the stack and forwards it to
  1191.  *  MMI task.
  1192.  * PARAMETERS
  1193.  *  entry_param     [IN]        
  1194.  * RETURNS
  1195.  *  void
  1196.  *****************************************************************************/
  1197. void MMI_task(oslEntryType *entry_param)
  1198. {
  1199.     /*----------------------------------------------------------------*/
  1200.     /* Local Variables                                                */
  1201.     /*----------------------------------------------------------------*/
  1202.     MYQUEUE Message;
  1203.     oslMsgqid qid;
  1204. #ifndef MMI_ON_WIN32
  1205.     U32 my_index;
  1206.     U32 count = 0;
  1207.     U32 queue_node_number = 0;
  1208. #endif /* MMI_ON_WIN32 */ 
  1209.     /*----------------------------------------------------------------*/
  1210.     /* Code Body                                                      */
  1211.     /*----------------------------------------------------------------*/
  1212. #ifndef MMI_ON_WIN32
  1213.     qid = task_info_g[entry_param->task_indx].task_ext_qid;
  1214.     mmi_ext_qid = qid;
  1215.     InitEventHandlersBeforePowerOn();
  1216. #endif /* MMI_ON_WIN32 */ 
  1217.     while (1)
  1218.     {
  1219.     #ifndef MMI_ON_WIN32
  1220.         {
  1221.             if (g_keypad_flag == MMI_TRUE)
  1222.             {
  1223.                 L4KeyHandle(NULL);
  1224.             }
  1225.             /* Leo start 20050825 */
  1226. /********************************************************************
  1227. *   Check if number of events in queue increases.
  1228. *   If yes, clear more external queue events, else clear less external queue events.
  1229. *   At lease clear one external queue event.
  1230. ********************************************************************/
  1231.             /* Get Total count in external queue */
  1232.             msg_get_ext_queue_info(mmi_ext_qid, &queue_node_number);
  1233.             if ((queue_node_number == 0) && (OslNumOfCircularQMsgs() == 0) && (g_keypad_flag == MMI_FALSE))
  1234.             {
  1235.                 U8 flag = 0;
  1236.                 ilm_struct ilm_ptr;
  1237.                 /* MMI task suspends for the queue */
  1238.                 OslReceiveMsgExtQ(qid, &Message);
  1239.                 OslGetMyTaskIndex(&my_index);
  1240.                 OslStackSetActiveModuleID(my_index, MOD_MMI);
  1241.                 /* put Message in circular queue */
  1242.                 ilm_ptr.src_mod_id = Message.src_mod_id;
  1243.                 ilm_ptr.dest_mod_id = Message.dest_mod_id;
  1244.                 ilm_ptr.msg_id = Message.msg_id;
  1245.                 ilm_ptr.sap_id = Message.sap_id;
  1246.                 ilm_ptr.local_para_ptr = Message.local_para_ptr;
  1247.                 ilm_ptr.peer_buff_ptr = Message.peer_buff_ptr;
  1248.                 flag = OslWriteCircularQ(&ilm_ptr);
  1249.                 MMI_ASSERT(flag == 1);
  1250.                 /* TIMER use special data in the local_para_ptr field. Can NOT treat as general ILM */
  1251.                 if (Message.src_mod_id != MOD_TIMER)
  1252.                 {
  1253.                     hold_local_para(ilm_ptr.local_para_ptr);
  1254.                     hold_peer_buff(ilm_ptr.peer_buff_ptr);
  1255.                     OslFreeInterTaskMsg(&Message);
  1256.                 }
  1257.             }
  1258.             else
  1259.             {
  1260.                 mmi_frm_fetch_msg_from_extQ_to_circularQ();
  1261.             }
  1262.             count = OslNumOfCircularQMsgs();
  1263.             while (count > 0)
  1264.             {
  1265.                 OslGetMyTaskIndex(&my_index);
  1266.                 OslStackSetActiveModuleID(my_index, MOD_MMI);
  1267.                 if (OslReadCircularQ(&Message))
  1268.                 {
  1269.                     CheckAndPrintMsgId((U16) (Message.msg_id));
  1270.                     if (Message.dest_mod_id == MOD_WAP)
  1271.                     {
  1272.                     #ifdef JATAAYU_SUPPORT
  1273.                         extern void mmi_wap_handle_msg(void *msgPtr);
  1274.                         mmi_wap_handle_msg((void*)&Message);
  1275.                     #endif /* JATAAYU_SUPPORT */ 
  1276.                     }
  1277.                     else
  1278.                     {
  1279.                         switch (Message.msg_id)
  1280.                         {
  1281.                             case MSG_ID_TIMER_EXPIRY:
  1282.                             {
  1283.                                 kal_uint16 msg_len;
  1284.                                 EvshedMMITimerHandler(get_local_para_ptr(Message.oslDataPtr, &msg_len));
  1285.                             }
  1286.                                 break;
  1287.                             case MSG_ID_MMI_EQ_POWER_ON_IND:
  1288.                             {
  1289.                                 mmi_eq_power_on_ind_struct *p = (mmi_eq_power_on_ind_struct*) Message.oslDataPtr;
  1290.                                 /* To initialize data/time */
  1291.                                 SetDateTime((void*)&(p->rtc_time));
  1292.                                 gdi_init();
  1293.                                 g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_INDICATION;       /* 0x01: POWER_ON_KEYPAD indication */
  1294.                                 
  1295.                             #ifdef __MMI_TVOUT__
  1296.                                 mmi_phnset_tvout_check_pwron_start();
  1297.                             #endif
  1298.                                                             
  1299.                                 switch (p->poweron_mode)
  1300.                                 {
  1301.                                     case POWER_ON_KEYPAD:
  1302.                                         OslMemoryStart(TRUE);
  1303.                                         g_charbat_context.PowerOnCharger = 0;
  1304.                                         g_pwr_context.PowerOnMode = POWER_ON_KEYPAD;
  1305.                                         DTGetRTCTime(&StartUpTime);
  1306.                                         memset(&LastDuration, 0, sizeof(LastDuration));
  1307.                                         //KP Jerry add for reading correct SIM ID after 06B version when dual SIM support  on 2007-3-20 start
  1308.                                         #ifdef __DUAL_SIM_SUPPORT__
  1309.                                         mmi_frm_power_on_init_procedure();
  1310.      #endif 
  1311.      //KP Jerry add for reading correct SIM ID after 06B version when dual SIM support  on 2007-3-20 end
  1312.                                 #if (defined(MMI_ON_HARDWARE_P) && !defined(__MTK_TARGET__)) /* MoDIS only */
  1313.                                         mmi_netset_write_auto_test_result(MMI_FALSE);
  1314.                                 #endif
  1315.                                         /* disk check */
  1316.                                 #ifdef __FLIGHT_MODE_SUPPORT__
  1317.                                         g_phnset_cntx.curFlightMode = p->flightmode_state;
  1318.                                 #endif 
  1319. mmi_bootup_entry_disk_check();
  1320.                                         PRINT_INFORMATION((" NORMAL POWER ON SUCCESS!!!!"));
  1321.                                         break;
  1322.                                     case POWER_ON_PRECHARGE:
  1323.                                     case POWER_ON_CHARGER_IN:
  1324.                            /************************************** 
  1325.                             * Always send charger-in indication
  1326.                             * to avoid fast repeating charger 
  1327.                             * in-out b4 power-on completes
  1328.                             * Lisen 04/13/2004
  1329.                            ***************************************/
  1330.                                         g_pwr_context.PowerOnMode = p->poweron_mode;    /* Charger/Pre-charge Power On */
  1331.                                         InitializeChargingScr();
  1332.                                         if (!g_charbat_context.isChargerConnected)
  1333.                                         {
  1334.                                             QuitSystemOperation();
  1335.                                         }
  1336.                                         PRINT_INFORMATION((" CHARGER POWER ON SUCCESS!!!!"));
  1337.                                         break;
  1338.                                     case POWER_ON_ALARM:
  1339.                                         g_pwr_context.PowerOnMode = POWER_ON_ALARM;
  1340.                                     #ifdef __MMI_SUBLCD__
  1341.                                         gdi_lcd_set_active(GDI_LCD_SUB_LCD_HANDLE);
  1342.                                         gdi_layer_clear(GDI_COLOR_BLACK);
  1343.                                         gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);
  1344.                                     #endif /* __MMI_SUBLCD__ */ 
  1345.                                         gdi_layer_clear(GDI_COLOR_BLACK);
  1346.                                         AlmInitRTCPwron();
  1347.                                         PRINT_INFORMATION((" ALARM POWER ON SUCCESS!!!!"));
  1348.                                         break;
  1349.                                     case POWER_ON_EXCEPTION:
  1350.                                         g_pwr_context.PowerOnMode = POWER_ON_EXCEPTION;
  1351.                                     #ifdef __MMI_SUBLCD__
  1352.                                         gdi_lcd_set_active(GDI_LCD_SUB_LCD_HANDLE);
  1353.                                         gdi_layer_clear(GDI_COLOR_BLACK);
  1354.                                         gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);
  1355.                                     #endif /* __MMI_SUBLCD__ */ 
  1356.                                         gdi_layer_clear(GDI_COLOR_BLACK);
  1357.                                         OslMemoryStart(TRUE);
  1358.                                         SetAbnormalReset();
  1359.                                         InitializeAll();
  1360.                                         OslDumpDataInFile();
  1361.                                         PRINT_INFORMATION((" Exception POWER ON SUCCESS!!!!"));
  1362.                                         ClearInputEventHandler(MMI_DEVICE_ALL);
  1363.                                         ClearKeyHandler(KEY_END, KEY_LONG_PRESS);
  1364.                            /**************************************
  1365.                             * Please note that the order of the following actions matters. 
  1366.                             * NVRAM data must be read before InitAllApplications, or there might be 
  1367.                             * unexpected errors. 
  1368.                            ***************************************/
  1369.                                         InitNvramData();
  1370.                                         InitAllApplications();
  1371.                                     #ifdef __FLIGHT_MODE_SUPPORT__
  1372.                                         PhnsetFlightModePowerOnException();
  1373.                                     #endif 
  1374.                            /***************************************
  1375.                             * To check power on display if need restore 
  1376.                             ***************************************/
  1377.                                         mmi_pwron_exception_check_display();
  1378.                                         break;
  1379.                                     #ifdef __MMI_USB_SUPPORT__
  1380.                                     case POWER_ON_USB:
  1381.                                         g_pwr_context.PowerOnMode = POWER_ON_USB;
  1382.                            /***************************************
  1383.                             * Because Aux task will not init in USB boot mode 
  1384.                             * Interrupt service routine for clam detection CLAM_EINT_HISR() 
  1385.                             * is not register, force the clam state to open 
  1386.                             * If Aux task is necessary in USB mode, this tircky could be removed 
  1387.                             * Robin 1209 
  1388.                             ***************************************/
  1389.                                         gMMIClamState = 1;
  1390.                                         InitializeUsbScr();
  1391.                            /***************************************
  1392.                             * To disable keypad tone state 
  1393.                             ***************************************/
  1394.                                         mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_DISABLED);
  1395.                                         PRINT_INFORMATION((" USB POWER ON SUCCESS!!!!"));
  1396.                                         break;
  1397.                                     #endif /* __MMI_USB_SUPPORT__ */ 
  1398.                                     default:
  1399.                                         break;
  1400.                                 }
  1401.                             }
  1402.                                 break;
  1403.                             default:
  1404.                                 ProtocolEventHandler(
  1405.                                     (U16) Message.oslMsgId,
  1406.                                     (void*)Message.oslDataPtr,
  1407.                                     (int)Message.oslSrcId,
  1408.                                     (void*)&Message);
  1409.                                 break;
  1410.                         }
  1411.                     }
  1412.                     OslFreeInterTaskMsg(&Message);
  1413.                 }   /* OslReadCircularQ(&Message) */
  1414.                 msg_get_ext_queue_info(mmi_ext_qid, &queue_node_number);
  1415.                 count--;
  1416.             }
  1417.         }
  1418.     #else /* MMI_ON_WIN32 */
  1419.         {
  1420.             qid = task_info_g1[(U16) entry_param].task_ext_qid;
  1421.             OslReceiveMsgExtQ(qid, &Message);
  1422.             if (!ProcessPCKeyEvent(Message.oslMsgId, (KEYBRD_MESSAGE*) Message.oslDataPtr))
  1423.             {
  1424.                 switch (Message.oslMsgId)
  1425.                 {
  1426.                     case PRT_MMI_TIMER_IND:
  1427.                     {
  1428.                         oslTimerid timerid;
  1429.                         timerid = (oslTimerid)((TIMER_MESSAGE *) Message.oslDataPtr)->id;
  1430.                         timerid->tmr_callback(timerid->tmr_callback_arg);
  1431.                     }
  1432.                         break;
  1433.                     
  1434.                     case MMI_EQ_POWER_ON_IND:
  1435.                     {
  1436.                         mmi_eq_power_on_ind_struct *p = (mmi_eq_power_on_ind_struct*) Message.oslDataPtr;
  1437.                         gdi_init();
  1438.                         g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_INDICATION;       /* 0x01: POWER_ON_KEYPAD indication */
  1439.                         switch (p->poweron_mode)
  1440.                         {
  1441.                             case POWER_ON_KEYPAD:
  1442.                                 OslMemoryStart(TRUE);
  1443.                         #ifdef MMI_ON_WIN32
  1444.                                 if (flagMMIStart)
  1445.                                 {
  1446.                                     break;
  1447.                                 }
  1448.                                 flagMMIStart = TRUE;
  1449.                         #endif /* MMI_ON_WIN32 */ 
  1450.                                 g_charbat_context.PowerOnCharger = 0;
  1451.                                 InitializeAll();
  1452.                                 OslDumpDataInFile();
  1453.                         /***************************************
  1454.                          * To initialize nvram data
  1455.                          ***************************************/
  1456.                                 InitNvramData();
  1457.                                 /* diamond, 2005/07/05 Flight mode */
  1458.                                 //#ifdef __FLIGHT_MODE_SUPPORT__
  1459.                                 //EntryQueryFlightModeScreen();
  1460.                                 //#else
  1461.                                 mmi_pwron_entry_animation_screen();     /* to display power on animation */
  1462.                                 // #endif
  1463.                                 PRINT_INFORMATION((" NORMAL POWER ON SUCCESS!!!!"));
  1464.                                 break;
  1465.                             case POWER_ON_PRECHARGE:    /* Cylen, Precharge Power On */
  1466.                             case POWER_ON_CHARGER_IN:
  1467.                                 g_pwr_context.PowerOnMode = p->poweron_mode;    /* Cylen, Precharge Power On */
  1468.                                 InitializeChargingScr();
  1469.                                 break;
  1470.                             case POWER_ON_ALARM:
  1471.                                 AlmInitRTCPwron();
  1472.                                 break;
  1473.                      /***************************************
  1474.                       * For abnormal reset when invalid SIM 
  1475.                       ***************************************/
  1476.                             case POWER_ON_EXCEPTION:
  1477.                                 OslMemoryStart(TRUE);
  1478.                                 SetAbnormalReset();
  1479.                                 InitializeAll();
  1480.                                 OslDumpDataInFile();
  1481.                                 PRINT_INFORMATION((" Exception POWER ON SUCCESS!!!!"));
  1482.                                 /* goto_opening_screen(); */
  1483.                                 ClearInputEventHandler(MMI_DEVICE_ALL);
  1484.                                 ClearKeyHandler(KEY_END, KEY_LONG_PRESS);
  1485.                                 InitNvramData();
  1486.                                 AlmReInitialize();
  1487.                                 InitAllApplications();
  1488.                         /***************************************
  1489.                          * To check power on display if need restore 
  1490.                          ***************************************/
  1491.                                 mmi_pwron_exception_check_display();
  1492.                                 break;
  1493.                         }
  1494.                     }
  1495.                         break;
  1496.                     default:
  1497.                         ProtocolEventHandler(
  1498.                             (U16) Message.oslMsgId,
  1499.                             (void*)Message.oslDataPtr,
  1500.                             (int)Message.oslSrcId,
  1501.                             (void*)Message.oslPeerBuffPtr);
  1502.                         break;
  1503.                 }
  1504.             }
  1505.             OslFreeInterTaskMsg(&Message);
  1506.         }
  1507.     #endif /* MMI_ON_WIN32 */ 
  1508.     }
  1509. }
  1510. /* __CUSTPACK_MULTIBIN     Terry   BEGIN */
  1511. /*****************************************************************************
  1512.  * FUNCTION
  1513.  *  IMECheck
  1514.  * DESCRIPTION
  1515.  *  To Check IME,
  1516.  *  
  1517.  *  This is used to To Check IME,.
  1518.  * PARAMETERS
  1519.  *  IME_Mode                [IN]        
  1520.  *  all_implement_IME       [IN]        
  1521.  * RETURNS
  1522.  *  MMI_TRUE : if the IME_Mode is in
  1523.  *  MMI_FALSE : if the IME_Mode is not in
  1524.  *****************************************************************************/
  1525. BOOL IMECheck(U8 IME_Mode, const U8 all_implement_IME[])
  1526. {
  1527.     /*----------------------------------------------------------------*/
  1528.     /* Local Variables                                                */
  1529.     /*----------------------------------------------------------------*/
  1530.     int i = 0;
  1531.     /*----------------------------------------------------------------*/
  1532.     /* Code Body                                                      */
  1533.     /*----------------------------------------------------------------*/
  1534.     for (;;)
  1535.     {
  1536.         if ((0xff) != all_implement_IME[i])
  1537.         {
  1538.             if (IME_Mode == all_implement_IME[i])
  1539.             {
  1540.                 return MMI_TRUE;
  1541.             }
  1542.         }
  1543.         else
  1544.         {
  1545.             return MMI_FALSE;
  1546.         }
  1547.         i++;
  1548.         if (i > INPUT_MODE_MAX_NUM)
  1549.         {
  1550.             ASSERT(0);
  1551.         }
  1552.     }
  1553. }
  1554. /*****************************************************************************
  1555.  * FUNCTION
  1556.  *  InitIMESetting
  1557.  * DESCRIPTION
  1558.  *  To Initialize IME,
  1559.  *  
  1560.  *  This is used to To Initialize IME,.
  1561.  * PARAMETERS
  1562.  *  IMEArray            [IN]        
  1563.  *  allIME              [OUT]       
  1564.  *  englishOnlyIME      [OUT]       
  1565.  *  PreferedIME         [OUT]       
  1566.  * RETURNS
  1567.  *  void
  1568.  *****************************************************************************/
  1569. void InitIMESetting(const sIMEModeDetails *IMEArray, U8 *allIME, U8 *englishOnlyIME, U16 *PreferedIME)
  1570. {
  1571.     /*----------------------------------------------------------------*/
  1572.     /* Local Variables                                                */
  1573.     /*----------------------------------------------------------------*/
  1574.     int i = 0, j = 0, k = 0;
  1575.     /*----------------------------------------------------------------*/
  1576.     /* Code Body                                                      */
  1577.     /*----------------------------------------------------------------*/
  1578.     for (;;)
  1579.     {
  1580.         if ((0xff) != IMEArray[i].IME_Mode_ID)
  1581.         {
  1582.             /* W05.34 Fix Compile Warning */
  1583.             if (!IMECheck((U8) IMEArray[i].IME_Mode_ID, MMI_implement_input_mode_set))
  1584.             {
  1585.                 ASSERT(0);
  1586.             }
  1587.             allIME[i] = IMEArray[i].IME_Mode_ID;
  1588.         #ifdef __MMI_PREFER_INPUT_METHOD__
  1589.             if ((NULL != PreferedIME) && (0 != IMEArray[i].IME_Type_ID))
  1590.             {
  1591.                 PreferedIME[k] = IMEArray[i].IME_Type_ID;
  1592.                 k++;
  1593.             }
  1594.         #endif /* __MMI_PREFER_INPUT_METHOD__ */ 
  1595.             if (IMEArray[i].English_Only_Flag)
  1596.             {
  1597.                 englishOnlyIME[j] = IMEArray[i].IME_Mode_ID;
  1598.                 j++;
  1599.             }
  1600.             i++;
  1601.         }
  1602.         else
  1603.         {
  1604.             break;
  1605.         }
  1606.         if (i > INPUT_MODE_MAX_NUM)
  1607.         {
  1608.             ASSERT(0);
  1609.         }
  1610.     }
  1611.     allIME[i] = 0xff;
  1612.     PreferedIME[k] = 0xffff;
  1613.     englishOnlyIME[j] = 0xff;
  1614. }
  1615. /*****************************************************************************
  1616.  * FUNCTION
  1617.  *  InitIMEQSearch
  1618.  * DESCRIPTION
  1619.  *  To Initialize IME,
  1620.  *  
  1621.  *  This is used to To Initialize IME,.
  1622.  * PARAMETERS
  1623.  *  IMEQArray       [IN]        
  1624.  *  QuickIME        [OUT]       
  1625.  * RETURNS
  1626.  *  void
  1627.  *****************************************************************************/
  1628. void InitIMEQSearch(const sIMEModeDetails *IMEQArray, U8 *QuickIME)
  1629. {
  1630.     /*----------------------------------------------------------------*/
  1631.     /* Local Variables                                                */
  1632.     /*----------------------------------------------------------------*/
  1633.     int i = 0, j = 0;
  1634.     /*----------------------------------------------------------------*/
  1635.     /* Code Body                                                      */
  1636.     /*----------------------------------------------------------------*/
  1637.     for (;;)
  1638.     {
  1639.         if ((0xff) != IMEQArray[i].IME_Mode_ID)
  1640.         {
  1641.             i++;
  1642.             QuickIME[j] = IMEQArray[i - 1].IME_Mode_ID;
  1643.             j++;
  1644.         }
  1645.         else
  1646.         {
  1647.             break;
  1648.         }
  1649.         if (i > INPUT_MODE_MAX_NUM)
  1650.         {
  1651.             ASSERT(0);
  1652.         }
  1653.     }
  1654.     QuickIME[j] = 0xff;
  1655. }
  1656. /*****************************************************************************
  1657.  * FUNCTION
  1658.  *  InitIME
  1659.  * DESCRIPTION
  1660.  *  To Initialize IME,
  1661.  *  
  1662.  *  This is used to To Initialize IME,.
  1663.  * PARAMETERS
  1664.  *  void
  1665.  * RETURNS
  1666.  *  void
  1667.  *****************************************************************************/
  1668. void InitIME(void)
  1669. {
  1670.     /*----------------------------------------------------------------*/
  1671.     /* Local Variables                                                */
  1672.     /*----------------------------------------------------------------*/
  1673.     /*----------------------------------------------------------------*/
  1674.     /* Code Body                                                      */
  1675.     /*----------------------------------------------------------------*/
  1676.     // #if defined(__MMI_MULTIPLE_BIN_IME__)||defined(__MMI_MULTIPLE_BIN_LANG_PACK__)
  1677. #ifdef __MMI_PREFER_INPUT_METHOD__
  1678.     InitIMESetting(gIMEModeArray, MMI_all_input_mode_set, MMI_english_input_mode_set, MMI_all_prefered_input_mode_set);
  1679. #else 
  1680.     InitIMESetting(gIMEModeArray, MMI_all_input_mode_set, MMI_english_input_mode_set, NULL);
  1681. #endif 
  1682.     InitIMEQSearch(gIMEQSearchModeArray, MMI_qsearch_input_mode_set);
  1683.     // #endif
  1684. #ifdef __MMI_T9__
  1685.     InitInputMethod();
  1686. #elif defined __MMI_ZI__
  1687.     InitZiInputMethod();
  1688. //KP Jerry add on 2007-3-8 start
  1689. #elif defined __MMI_CSTAR__
  1690.     InitCstarInputMethod();
  1691. //KP Jerry add on 2007-3-8 end
  1692. #elif defined __MMI_KA__
  1693.     InitKonkaInputMethod();
  1694. #elif defined __MMI_ITAP__
  1695. /* under construction !*/
  1696. #endif 
  1697. }
  1698. /* __CUSTPACK_MULTIBIN     Terry   END */
  1699. /*****************************************************************************
  1700.  * FUNCTION
  1701.  *  InitFramework
  1702.  * DESCRIPTION
  1703.  *  To Initialize framework,
  1704.  *  
  1705.  *  This is used to To Initialize framework,.
  1706.  * PARAMETERS
  1707.  *  void
  1708.  * RETURNS
  1709.  *  void
  1710.  *****************************************************************************/
  1711. void InitFramework(void)
  1712. {
  1713.     /*----------------------------------------------------------------*/
  1714.     /* Local Variables                                                */
  1715.     /*----------------------------------------------------------------*/
  1716.     /*----------------------------------------------------------------*/
  1717.     /* Code Body                                                      */
  1718.     /*----------------------------------------------------------------*/
  1719.     /* 
  1720.      * Initialize events handler  
  1721.      */
  1722.     InitEvents();
  1723.     /* 
  1724.      * Initialize keyprocess 
  1725.      */
  1726.     InitProcessKeyEvent();
  1727.     /* 
  1728.      * Initialize history 
  1729.      */
  1730.     InitHistory(NULL, SubLCDIdleScreen);
  1731. }
  1732. /*****************************************************************************
  1733.  * FUNCTION
  1734.  *  mmi_enable_str_dump
  1735.  * DESCRIPTION
  1736.  *  The message handler of MSG_ID_MMI_EQ_STR_ENABLE_REQ_IND
  1737.  *  
  1738.  * PARAMETERS
  1739.  *  void*           [IN]
  1740.  * RETURNS
  1741.  *  void
  1742.  *****************************************************************************/
  1743. static void mmi_enable_str_dump(void *info)
  1744. {
  1745. #ifdef __MTK_TARGET__
  1746.     mmi_eq_str_enable_req_ind_struct *data = (mmi_eq_str_enable_req_ind_struct *)info;
  1747.     mmi_at_general_res_req_struct *rsp_msg;
  1748. #ifndef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  1749.     kal_bool ret = KAL_FALSE;
  1750. #else
  1751.     kal_bool ret = KAL_TRUE;
  1752.     
  1753.     g_mmi_frm_cntx.dump_screen_info.is_enable = (MMI_BOOL)(data->enable);
  1754.     g_mmi_frm_cntx.dump_screen_info.hightlight_type = 0;
  1755.     g_mmi_frm_cntx.dump_screen_info.backup_hightlight_type = 0;
  1756.     g_mmi_frm_cntx.dump_screen_info.y = 0;
  1757.     g_mmi_frm_cntx.dump_screen_info.backup_y = 0;
  1758.     g_mmi_frm_cntx.dump_screen_info.combined_chars_x = 0;
  1759.     g_mmi_frm_cntx.dump_screen_info.combined_chars_y = 0;
  1760.     memset(g_mmi_frm_cntx.dump_screen_info.backup_string, 0, MMI_SCREEN_STR_MAX_LENGTH);
  1761. #endif
  1762.     
  1763.     /* confirm the message */
  1764.     rsp_msg = (mmi_at_general_res_req_struct *) OslConstructDataPtr( sizeof(mmi_at_general_res_req_struct) );
  1765.     rsp_msg->result = ret;
  1766.     SendMsg2AT(MSG_ID_MMI_AT_GENERAL_RES_REQ, (void *)rsp_msg, NULL);
  1767. #endif
  1768. }
  1769. /*****************************************************************************
  1770.  * FUNCTION
  1771.  *  mmi_str_cmd_ind
  1772.  * DESCRIPTION
  1773.  *  The message handler of MSG_ID_MMI_EQ_STR_REQ_IND
  1774.  *  
  1775.  * PARAMETERS
  1776.  *  void*           [IN]
  1777.  * RETURNS
  1778.  *  void
  1779.  *****************************************************************************/
  1780. static void mmi_str_cmd_ind(void *info)
  1781. {
  1782. #ifdef __MTK_TARGET__
  1783.     mmi_eq_str_req_ind_struct *data = (mmi_eq_str_req_ind_struct *)info;
  1784.     mmi_at_general_res_req_struct *rsp_msg;
  1785.     MMI_ASSERT(data->length <= MMI_SCREEN_STR_MAX_LENGTH);
  1786.     /* process the string command here */
  1787.     /* confirm the message */
  1788.     rsp_msg = (mmi_at_general_res_req_struct *) OslConstructDataPtr( sizeof(mmi_at_general_res_req_struct) );
  1789.     rsp_msg->result = KAL_TRUE;
  1790.     SendMsg2AT(MSG_ID_MMI_AT_GENERAL_RES_REQ, (void *)rsp_msg, NULL);
  1791. #endif
  1792. }
  1793. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  1794. // #define ENABLE_DUMP_SCREEN_STRING_TRACE
  1795. extern MMI_BOOL mmi_trace_screen_string(S32 x, S32 y, U8 *str, S32 len, S32 Bordered);
  1796. /*****************************************************************************
  1797.  * FUNCTION
  1798.  *  mmi_no_more_str_hdlr
  1799.  * DESCRIPTION
  1800.  *  Sending the termination of dumpping screen string
  1801.  *  
  1802.  * PARAMETERS
  1803.  *  void
  1804.  * RETURNS
  1805.  *  void
  1806.  *****************************************************************************/
  1807. static void mmi_no_more_str_hdlr(void)
  1808. {
  1809.     mmi_eq_str_res_req_struct *rsp_msg;
  1810.     if (UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars))
  1811.     {
  1812.         mmi_trace_screen_string(
  1813.                 g_mmi_frm_cntx.dump_screen_info.combined_chars_x,
  1814.                 g_mmi_frm_cntx.dump_screen_info.combined_chars_y,
  1815.                 (U8*)g_mmi_frm_cntx.dump_screen_info.combined_chars,
  1816.                 UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars),
  1817.                 0);
  1818.     }
  1819.     memset(g_mmi_frm_cntx.dump_screen_info.combined_chars, 0, ENCODING_LENGTH);
  1820.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  1821.     g_mmi_frm_cntx.dump_screen_info.hightlight_type = 0;
  1822.     g_mmi_frm_cntx.dump_screen_info.backup_hightlight_type = 0;
  1823.     g_mmi_frm_cntx.dump_screen_info.y = 0;
  1824.     g_mmi_frm_cntx.dump_screen_info.backup_y = 0;
  1825.     g_mmi_frm_cntx.dump_screen_info.combined_chars_x = 0;
  1826.     g_mmi_frm_cntx.dump_screen_info.combined_chars_y = 0;
  1827. #ifdef __MTK_TARGET__
  1828.     rsp_msg = (mmi_eq_str_res_req_struct *) OslConstructDataPtr( sizeof(mmi_eq_str_res_req_struct) );
  1829.     kal_sprintf((char*)rsp_msg->data_string, "%d", MMI_SCREEN_NO_STR);
  1830.     rsp_msg->length = strlen((char*)rsp_msg->data_string);
  1831.     SendMsg2AT(MSG_ID_MMI_EQ_STR_RES_REQ, (void *)rsp_msg, NULL);
  1832. #elif !defined(MMI_ON_WIN32)
  1833. #ifdef ENABLE_DUMP_SCREEN_STRING_TRACE
  1834.     kal_printf("n <<END>> n");
  1835. #endif
  1836. #endif
  1837. }
  1838. /*****************************************************************************
  1839.  * FUNCTION
  1840.  *  mmi_trace_screen_string
  1841.  * DESCRIPTION
  1842.  *  Sending the screen string
  1843.  *  
  1844.  * PARAMETERS
  1845.  *  x           [IN]
  1846.  *  y           [IN]
  1847.  *  str         [IN]
  1848.  *  len         [IN]
  1849.  *  Bordered    [IN]
  1850.  * RETURNS
  1851.  *  MMI_BOOL
  1852.  *****************************************************************************/
  1853. MMI_BOOL mmi_trace_screen_string(S32 x, S32 y, U8 *str, S32 len, S32 Bordered)
  1854. {
  1855.     MMI_BOOL ret = MMI_FALSE;
  1856. #ifdef __MTK_TARGET__
  1857.     mmi_eq_str_res_req_struct *rsp_msg;
  1858. #elif !defined(MMI_ON_WIN32)
  1859.     U8 data_string[200];
  1860. #endif
  1861.     /* If having combined_chars, dump the string first */
  1862.     if (UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars))
  1863.     {
  1864.     #ifdef __MTK_TARGET__
  1865.         rsp_msg = (mmi_eq_str_res_req_struct *) OslConstructDataPtr( sizeof(mmi_eq_str_res_req_struct) );
  1866.         kal_sprintf((char*)rsp_msg->data_string, "%d,(%d,%d),%d,", 
  1867.                         1,  /* Normal string */
  1868.                         g_mmi_frm_cntx.dump_screen_info.combined_chars_x,
  1869.                         g_mmi_frm_cntx.dump_screen_info.combined_chars_y,
  1870.                         UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars));
  1871.         rsp_msg->length = strlen((char*)rsp_msg->data_string);
  1872.         UCS2Strncpy((S8*)(rsp_msg->data_string+rsp_msg->length), (S8*)g_mmi_frm_cntx.dump_screen_info.combined_chars, MMI_SCREEN_COMBINED_CHAR_MAX_LENGTH/ENCODING_LENGTH);
  1873.         rsp_msg->length += UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars)*ENCODING_LENGTH;
  1874.         MMI_ASSERT(rsp_msg->length <= MMI_SCREEN_STR_MAX_LENGTH);
  1875.         SendMsg2AT(MSG_ID_MMI_EQ_STR_RES_REQ, (void *)rsp_msg, NULL);
  1876.     #elif !defined(MMI_ON_WIN32)
  1877.         kal_sprintf((char*)data_string, "%d,(%d,%d),%d,", 
  1878.                         1,  /* Normal string */
  1879.                         g_mmi_frm_cntx.dump_screen_info.combined_chars_x,
  1880.                         g_mmi_frm_cntx.dump_screen_info.combined_chars_y,
  1881.                         UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars));
  1882.     #ifdef ENABLE_DUMP_SCREEN_STRING_TRACE
  1883.         kal_printf(data_string);
  1884.         kal_printf("%c%c%c%c%c ...",g_mmi_frm_cntx.dump_screen_info.combined_chars[0], g_mmi_frm_cntx.dump_screen_info.combined_chars[2], 
  1885.                                     g_mmi_frm_cntx.dump_screen_info.combined_chars[4], g_mmi_frm_cntx.dump_screen_info.combined_chars[6],
  1886.                                     g_mmi_frm_cntx.dump_screen_info.combined_chars[8]);
  1887.         kal_printf(" ++++ n");
  1888.     #endif /* ENABLE_DUMP_SCREEN_STRING_TRACE */
  1889.     #endif
  1890.     }
  1891.     /* Dump the screen string */
  1892.     if (g_mmi_frm_cntx.dump_screen_info.is_enable
  1893.         && (g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str
  1894.             || g_mmi_frm_cntx.dump_screen_info.allow_dump_dm_screen))
  1895.     {
  1896.         /* check if the string is the same */
  1897.         if (UCS2Strlen((S8*)str) && 
  1898.             (UCS2Strcmp((S8*)str, g_mmi_frm_cntx.dump_screen_info.backup_string) != 0 || g_mmi_frm_cntx.dump_screen_info.y != y))
  1899.         {
  1900.             UCS2Strncpy(g_mmi_frm_cntx.dump_screen_info.backup_string, (S8*)str, MMI_SCREEN_STR_MAX_LENGTH/ENCODING_LENGTH);
  1901.             g_mmi_frm_cntx.dump_screen_info.y = y;
  1902.             if (g_mmi_frm_cntx.dump_screen_info.backup_hightlight_type &&
  1903.                 g_mmi_frm_cntx.dump_screen_info.backup_y == y)
  1904.             {
  1905.                 g_mmi_frm_cntx.dump_screen_info.hightlight_type = g_mmi_frm_cntx.dump_screen_info.backup_hightlight_type;
  1906.             }
  1907.             /*
  1908.             else
  1909.             {
  1910.                 g_mmi_frm_cntx.dump_screen_info.backup_y = 0;
  1911.                 g_mmi_frm_cntx.dump_screen_info.hightlight_type = 0;
  1912.             }
  1913.             */
  1914.         #ifdef __MTK_TARGET__
  1915.             rsp_msg = (mmi_eq_str_res_req_struct *) OslConstructDataPtr( sizeof(mmi_eq_str_res_req_struct) );
  1916.             kal_sprintf((char*)rsp_msg->data_string, "%d,(%d,%d),%d,", 
  1917.                             (g_mmi_frm_cntx.dump_screen_info.hightlight_type>0)?MMI_SCREEN_HIGHLIGHT_STR:MMI_SCREEN_NORMAL_STR,
  1918.                             x, 
  1919.                             y,
  1920.                             UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.backup_string));
  1921.             rsp_msg->length = strlen((char*)rsp_msg->data_string);
  1922.             UCS2Strcpy((S8*)(rsp_msg->data_string+rsp_msg->length), g_mmi_frm_cntx.dump_screen_info.backup_string);
  1923.             rsp_msg->length += UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.backup_string)*ENCODING_LENGTH;
  1924.             MMI_ASSERT(rsp_msg->length <= MMI_SCREEN_STR_MAX_LENGTH);
  1925.             SendMsg2AT(MSG_ID_MMI_EQ_STR_RES_REQ, (void *)rsp_msg, NULL);
  1926.         #elif !defined(MMI_ON_WIN32)
  1927.             kal_sprintf((char*)data_string, "%d,(%d,%d),%d,", 
  1928.                             (g_mmi_frm_cntx.dump_screen_info.hightlight_type>0)?MMI_SCREEN_HIGHLIGHT_STR:MMI_SCREEN_NORMAL_STR,
  1929.                             x, 
  1930.                             y,
  1931.                             UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.backup_string));
  1932.         #ifdef ENABLE_DUMP_SCREEN_STRING_TRACE
  1933.             kal_printf(data_string);
  1934.             kal_printf("%c%c%c%c%c ...",str[0], str[2], str[4], str[6], str[8]);
  1935.             kal_printf(" ++++ n");
  1936.         #endif  /* ENABLE_DUMP_SCREEN_STRING_TRACE */
  1937.         #endif
  1938.             if (g_mmi_frm_cntx.dump_screen_info.hightlight_type)
  1939.             {
  1940.                 g_mmi_frm_cntx.dump_screen_info.backup_hightlight_type = g_mmi_frm_cntx.dump_screen_info.hightlight_type;
  1941.                 g_mmi_frm_cntx.dump_screen_info.backup_y = y;
  1942.             }
  1943.             gui_cancel_timer(mmi_no_more_str_hdlr);
  1944.             gui_start_timer(MMI_STR_DUMP_TIMEOUT, mmi_no_more_str_hdlr);
  1945.             ret = MMI_TRUE;
  1946.         }
  1947.     }
  1948.     g_mmi_frm_cntx.dump_screen_info.hightlight_type = 0;
  1949.     if (UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars))
  1950.     {
  1951.         memset(g_mmi_frm_cntx.dump_screen_info.combined_chars, 0, ENCODING_LENGTH);
  1952.         g_mmi_frm_cntx.dump_screen_info.combined_chars_x = 0;
  1953.         g_mmi_frm_cntx.dump_screen_info.combined_chars_y = 0;
  1954.     }
  1955.     return ret;
  1956. }
  1957. /*****************************************************************************
  1958.  * FUNCTION
  1959.  *  mmi_trace_screen_char
  1960.  * DESCRIPTION
  1961.  *  Sending the screen char
  1962.  *  
  1963.  * PARAMETERS
  1964.  *  x           [IN]
  1965.  *  y           [IN]
  1966.  *  unicode     [IN]
  1967.  *  len         [IN]
  1968.  *  Bordered    [IN]
  1969.  * RETURNS
  1970.  *  MMI_BOOL
  1971.  *****************************************************************************/
  1972. MMI_BOOL mmi_trace_screen_char(S32 x, S32 y, U16 unicode, S32 len, S32 Bordered)
  1973. {
  1974.     MMI_BOOL ret = MMI_FALSE;
  1975.     
  1976.     if (g_mmi_frm_cntx.dump_screen_info.is_enable
  1977.         && (g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str
  1978.             || g_mmi_frm_cntx.dump_screen_info.allow_dump_dm_screen))
  1979.     {
  1980.     #ifdef __COMBINE_CHAR_IN_DUMP_SCREEN_STRING__
  1981.         U8 dummy;
  1982.         S32 len;
  1983.         /* combine the separated chars to the string */
  1984.         len = UCS2Strlen(g_mmi_frm_cntx.dump_screen_info.combined_chars);
  1985.         if (g_mmi_frm_cntx.dump_screen_info.combined_chars_y == y)
  1986.         {
  1987.             /* chars are at The same column */
  1988.             UnicodeToUCS2Encoding(
  1989.                     unicode, 
  1990.                     &dummy, 
  1991.                     (U8*)g_mmi_frm_cntx.dump_screen_info.combined_chars + len * ENCODING_LENGTH);
  1992.             memset(g_mmi_frm_cntx.dump_screen_info.combined_chars + ((len + 1) * ENCODING_LENGTH),
  1993.                    0,
  1994.                    ENCODING_LENGTH);
  1995.         }
  1996.         else
  1997.         {
  1998.             /* chars are not at The same column */
  1999.             if (len)
  2000.             {
  2001.                 mmi_trace_screen_string(
  2002.                         g_mmi_frm_cntx.dump_screen_info.combined_chars_x,
  2003.                         g_mmi_frm_cntx.dump_screen_info.combined_chars_y,
  2004.                         (U8*)g_mmi_frm_cntx.dump_screen_info.combined_chars,
  2005.                         len,
  2006.                         0);
  2007.             }
  2008.             UnicodeToUCS2Encoding(
  2009.                     unicode, 
  2010.                     &dummy, 
  2011.                     (U8*)g_mmi_frm_cntx.dump_screen_info.combined_chars);
  2012.             memset(g_mmi_frm_cntx.dump_screen_info.combined_chars + ENCODING_LENGTH,
  2013.                    0,
  2014.                    ENCODING_LENGTH);
  2015.             g_mmi_frm_cntx.dump_screen_info.combined_chars_x = x;
  2016.             g_mmi_frm_cntx.dump_screen_info.combined_chars_y = y;
  2017.         }
  2018.     #else
  2019.         /* Dump the separated chars directly */
  2020.         #ifdef __MTK_TARGET__
  2021.         {
  2022.             mmi_eq_str_res_req_struct *rsp_msg;
  2023.             rsp_msg = (mmi_eq_str_res_req_struct *) OslConstructDataPtr( sizeof(mmi_eq_str_res_req_struct) );
  2024.             kal_sprintf((char*)rsp_msg->data_string, "%d,(%d,%d),1,", 0, x, y);
  2025.     
  2026.             rsp_msg->length = strlen((char*)rsp_msg->data_string);
  2027.             memcpy((S8*)(rsp_msg->data_string+rsp_msg->length), &unicode, ENCODING_LENGTH);
  2028.             rsp_msg->length += ENCODING_LENGTH;
  2029.     
  2030.             SendMsg2AT(MSG_ID_MMI_EQ_STR_RES_REQ, (void *)rsp_msg, NULL);
  2031.         }
  2032.         #elif !defined(MMI_ON_WIN32)
  2033.         {
  2034.             U8 data_string[200];
  2035.             kal_sprintf((char*)data_string, "%d,(%d,%d),1,", 0, x, y);
  2036.         #ifdef ENABLE_DUMP_SCREEN_STRING_TRACE
  2037.             kal_printf(data_string);
  2038.             kal_printf(" %c ", unicode>>8);
  2039.             kal_printf(" %c ", unicode&0x00FF);
  2040.             kal_printf(" --- n");
  2041.         #endif /* ENABLE_DUMP_SCREEN_STRING_TRACE */
  2042.         }
  2043.         #endif
  2044.     #endif
  2045.         gui_cancel_timer(mmi_no_more_str_hdlr);
  2046.         gui_start_timer(MMI_STR_DUMP_TIMEOUT, mmi_no_more_str_hdlr);
  2047.         ret = MMI_TRUE;
  2048.     }
  2049.     
  2050.     return ret;
  2051. }
  2052. #endif /* __MMI_SUPPORT_DUMP_SCREEN_STRING__ */
  2053. /*****************************************************************************
  2054.  * FUNCTION
  2055.  *  InitializeAll
  2056.  * DESCRIPTION
  2057.  *  This is used to To Initialize framework,.
  2058.  *
  2059.  *  Remark: Initialization functions may be executed more than one times for 
  2060.  *          special poweron mode (e.g. Alarm poweron, Charger poweron, USB poweron)
  2061.  * PARAMETERS
  2062.  *  void
  2063.  * RETURNS
  2064.  *  void
  2065.  *****************************************************************************/
  2066. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  2067. extern nsm_msg_struct g_nsm_msg_context;
  2068. #endif 
  2069. void InitializeAll()
  2070. {
  2071.     /*----------------------------------------------------------------*/
  2072.     /* Local Variables                                                */
  2073.     /*----------------------------------------------------------------*/
  2074.     /*----------------------------------------------------------------*/
  2075.     /* Code Body                                                      */
  2076.     /*----------------------------------------------------------------*/
  2077.     InitUnicodeSupport();
  2078.     /* 
  2079.      * Init graphic lib 
  2080.      */
  2081.     gdi_init();
  2082.     /* 
  2083.      * Init media driver lib 
  2084.      */
  2085.     mdi_audio_init();
  2086.     jdi_audio_init();
  2087. #ifdef __MMI_WEBCAM__
  2088.     mdi_webcam_init();
  2089. #endif 
  2090. #ifdef __MMI_USB_SUPPORT__
  2091.     {
  2092.         InitMMIUsbContext();
  2093.     }
  2094. #endif /* __MMI_USB_SUPPORT__ */ 
  2095. #ifdef __MMI_IRDA_SUPPORT__
  2096.     {
  2097.         mmi_irda_init_cntx();
  2098.         mmi_irda_set_recv_files_cnt(0);
  2099.     }
  2100. #endif /* __MMI_IRDA_SUPPORT__ */ 
  2101.     /* 
  2102.      * Initialize the ProtocolEvents 
  2103.      */
  2104.     InitProtocolEvents();
  2105.     /* 
  2106.      * Initialize framework 
  2107.      */
  2108.     InitFramework();
  2109.     InitHardwareEvents();
  2110.     InitTime();
  2111.     InitMMI_App();
  2112.     setup_UI_wrappers();
  2113.     PopulateResData();
  2114.     PopulateResGetBaseIDTable();
  2115.     PowerAndEndKeyHandler();
  2116. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  2117.     #ifdef MMI_ON_WIN32
  2118.     SetCurrentLanguage(0);
  2119.     #endif
  2120. #endif
  2121. #ifdef __MMI_UNIFIED_MESSAGE__
  2122.     mmi_um_init();
  2123. #endif 
  2124. #ifdef __MMI_UNIFIED_COMPOSER__
  2125.     mmi_uc_init();
  2126. #endif 
  2127. #ifdef __MOD_SMSAL__
  2128.     {
  2129.         InitMessageProtocolEventHandlers();
  2130.         mmi_frm_sms_init();
  2131.     }
  2132. #endif /* __MOD_SMSAL__ */ 
  2133.     /* 
  2134.      * Data Account Application 
  2135.      */
  2136. #ifdef __TCPIP__
  2137.     {
  2138.         InitDataAccountApp();
  2139.     }
  2140. #endif /* __TCPIP__ */ 
  2141.     /* 
  2142.      * Call manahement needs to be initialized here because of SOS calls concept
  2143.      */
  2144.     InitCallManagement();
  2145.     initialize_UI_demo();
  2146.     InitNetWorkBootUpEventsCallBack();
  2147.     InitProfileApp();
  2148.     InitSimDetection();
  2149.     InitService();
  2150.     InitCPHS();
  2151. //KP Jerry add on 2007-4-12 start
  2152. #ifdef __MMI_MESSAGES_SENDMSG_QUICKLY__
  2153.     IdleScreenDigit_Init();
  2154.     Mmi_Msg_Sendmsg_Init();
  2155.     CallLog_SendMsg_Init();
  2156. #endif
  2157. //KP Jerry add on 2007-4-12 end
  2158.     /* 
  2159.      * For engineer mode
  2160.      */
  2161. #ifdef __MMI_ENGINEER_MODE__    /* For saperate MMI feature by project */
  2162.     {
  2163.         InitEngineerMode();
  2164.     }
  2165. #endif /* __MMI_ENGINEER_MODE__ */ 
  2166. #ifdef __MMI_FACTORY_MODE__     /* For saperate MMI feature by project */
  2167.     {
  2168.         InitFactoryMode();
  2169.     }
  2170. #endif /* __MMI_FACTORY_MODE__ */ 
  2171. #ifdef __MMI_FILE_MANAGER__
  2172.     {
  2173.         mmi_fmgr_init();
  2174.     }
  2175. #endif /* __MMI_FILE_MANAGER__ */ 
  2176. #ifdef __MMI_SOUND_RECORDER__
  2177.     {
  2178.         InitSoundRecorderApp();
  2179.     }
  2180. #endif /* __MMI_SOUND_RECORDER__ */ 
  2181.     InitSoundEffect();
  2182.     mdi_audio_init_event_hdlrs();
  2183.     /* 
  2184.      * To initialize T9 before power on for To Do List
  2185.      */
  2186.     /* __CUSTPACK_MULTIBIN     Terry   BEGIN */
  2187.     InitIME();
  2188.     /* __CUSTPACK_MULTIBIN     Terry   END */
  2189.     /* 
  2190.      * Max: To add bacllight on/off interface for HW test 0925
  2191.      */
  2192.     InitHWBacklightTest();
  2193.     InitCallLogs();
  2194.     ATHandlerInit();
  2195. #ifndef MMI_ON_WIN32
  2196.     {
  2197.         mmi_chset_init();
  2198.     }
  2199. #endif /* MMI_ON_WIN32 */ 
  2200.     /*
  2201.      * Phonebook Protocol Initialization - Should be initialized before L4 PHB begin to read
  2202.      */
  2203.     mmi_phb_init_protocol();
  2204.     /* 
  2205.      * Move from InitSettingApp() for text encoding 
  2206.      */
  2207.     InitPhoneSetupCntx();
  2208.     InitPhoneSetupApp();
  2209. #ifdef __MMI_BT_HP_SUPPORT__
  2210.     {
  2211.         mmi_bt_init_cntx();
  2212.         mmi_bt_scr_init();
  2213.     }
  2214. #endif /* __MMI_BT_HP_SUPPORT__ */ 
  2215. #ifdef __MMI_BT_SUPPORT__
  2216.     {
  2217.         mmi_bt_init();
  2218.     }
  2219. #endif /* __MMI_BT_SUPPORT__ */ 
  2220.     /* for PC simulator */
  2221. #if !defined(__MMI_BT_SUPPORT__) && defined(MMI_ON_WIN32)
  2222.     {
  2223.         mmi_bt_init();
  2224.     }
  2225. #endif /* !defined(__MMI_BT_SUPPORT__) && defined(MMI_ON_WIN32) */ 
  2226. #ifdef __MMI_IRDA_SUPPORT__
  2227.     mmi_irda_init_menu_hdlr();
  2228. #endif /* __MMI_IRDA_SUPPORT__ */ 
  2229. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  2230.     {
  2231.         mmi_nsm2_init_nsm_msg_struct(&g_nsm_msg_context);
  2232.     }
  2233. #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  2234. #ifdef APPMEM_SUPPORT
  2235.     {
  2236.         InitAppMem();
  2237.     }
  2238. #endif /* APPMEM_SUPPORT */ 
  2239. #if defined(__MMI_FM_RADIO_SCHEDULE_REC__)
  2240.     mmi_fmsr_init_app();
  2241. #endif 
  2242. #ifdef __MMI_BG_SOUND_EFFECT__
  2243.     mmi_bgsnd_init();
  2244. #endif 
  2245. #ifndef MMI_ON_WIN32
  2246.     mmiapi_init_engine();
  2247. #endif
  2248. #if defined(JATAAYU_SUPPORT) && !defined(__MTK_TARGET__)
  2249.     {
  2250.         ilm_struct *ilm_ptr = NULL;
  2251.         ilm_ptr = allocate_ilm(MOD_MMI);
  2252.         ilm_ptr->local_para_ptr = NULL;
  2253.         ilm_ptr->msg_id = MSG_ID_MMI_EQ_POWER_ON_IND;
  2254.         ilm_ptr->peer_buff_ptr = NULL;
  2255.         ilm_ptr->src_mod_id = MOD_MMI;
  2256.         ilm_ptr->dest_mod_id = MOD_WAP;
  2257.         ilm_ptr->sap_id = WPS_APP_SAP;
  2258.         msg_send_ext_queue(ilm_ptr);
  2259.     }
  2260. #endif /* defined(JATAAYU_SUPPORT) && !defined(__MTK_TARGET__) */ 
  2261. #if defined(__MMI_NITZ__)
  2262.     NITZHandlerInit();
  2263. #endif 
  2264. #if defined(__FOTA_ENABLE__)
  2265.     mmi_dm_fwu_init();
  2266. #endif /* defined(__FOTA_ENABLE__) */
  2267. SetProtocolEventHandler(mmi_enable_str_dump, MSG_ID_MMI_EQ_STR_ENABLE_REQ_IND);
  2268. SetProtocolEventHandler(mmi_str_cmd_ind, MSG_ID_MMI_EQ_STR_REQ_IND);
  2269. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  2270. #if !defined(__MTK_TARGET__) && !defined(MMI_ON_WIN32)
  2271.     g_mmi_frm_cntx.dump_screen_info.is_enable = (MMI_BOOL)1;
  2272.     g_mmi_frm_cntx.dump_screen_info.hightlight_type = 0;
  2273.     g_mmi_frm_cntx.dump_screen_info.backup_hightlight_type = 0;
  2274.     g_mmi_frm_cntx.dump_screen_info.y = 0;
  2275.     g_mmi_frm_cntx.dump_screen_info.backup_y = 0;
  2276.     g_mmi_frm_cntx.dump_screen_info.combined_chars_x = 0;
  2277.     g_mmi_frm_cntx.dump_screen_info.combined_chars_y = 0;
  2278.     memset(g_mmi_frm_cntx.dump_screen_info.backup_string, 0, MMI_SCREEN_STR_MAX_LENGTH);
  2279. #endif
  2280. #endif /* __MMI_SUPPORT_DUMP_SCREEN_STRING__ */
  2281. }
  2282. /**************************br************************************
  2283.    FUNCTION NAME     : ProtocolEventHandler(PRT_MESSAGE*)
  2284.    PURPOSE           : To handle protocol events.
  2285.    INPUT PARAMETERS  : U16 eventID
  2286.    OUTPUT PARAMETERS : nil
  2287.    RETURNS           : static void
  2288.    REMARKS           : This is used to handle protocol events .
  2289. **************************************************************/
  2290. /*****************************************************************************
  2291.  * FUNCTION
  2292.  *  ProtocolEventHandler
  2293.  * DESCRIPTION
  2294.  *  
  2295.  * PARAMETERS
  2296.  *  eventID         [IN]        
  2297.  *  MsgStruct       [IN]         
  2298.  *  mod_src         [IN]        
  2299.  *  peerBuf         [IN]         
  2300.  * RETURNS
  2301.  *  void
  2302.  *****************************************************************************/
  2303. void ProtocolEventHandler(U16 eventID, void *MsgStruct, int mod_src, void *peerBuf)
  2304. {
  2305.     /*----------------------------------------------------------------*/
  2306.     /* Local Variables                                                */
  2307.     /*----------------------------------------------------------------*/
  2308.     /*----------------------------------------------------------------*/
  2309.     /* Code Body                                                      */
  2310.     /*----------------------------------------------------------------*/
  2311.     /* PRINT_INFORMATION(("n MMItask   -> protocol event <id %d>n",eventID)); */
  2312.     PRINT_INFORMATION_2((MMI_TRACE_G1_FRM, "<<protocol event %d>>n", eventID));
  2313.     ExecuteCurrProtocolHandler((U16) eventID, MsgStruct, mod_src, peerBuf);
  2314. }
  2315. /*****************************************************************************
  2316.  * FUNCTION
  2317.  *  InitUnicodeSupport
  2318.  * DESCRIPTION
  2319.  *  Initalizes string functions for UCS2 support
  2320.  * PARAMETERS
  2321.  *  void
  2322.  * RETURNS
  2323.  *  void
  2324.  *****************************************************************************/
  2325. void InitUnicodeSupport(void)
  2326. {
  2327.     /*----------------------------------------------------------------*/
  2328.     /* Local Variables                                                */
  2329.     /*----------------------------------------------------------------*/
  2330.     /*----------------------------------------------------------------*/
  2331.     /* Code Body                                                      */
  2332.     /*----------------------------------------------------------------*/
  2333. #ifdef __UCS2_ENCODING
  2334.     {
  2335.         pfnUnicodeToEncodingScheme = UnicodeToUCS2Encoding;
  2336.         pfnEncodingSchemeToUnicode = UCS2EncodingToUnicode;
  2337.         pfnUnicodeStrlen = UCS2Strlen;
  2338.         pfnUnicodeStrcpy = UCS2Strcpy;
  2339.         pfnUnicodeStrcmp = UCS2Strcmp;
  2340.         pfnUnicodeStrncpy = UCS2Strncpy;
  2341.         pfnUnicodeStrncmp = UCS2Strncmp;
  2342.         pfnUnicodeStrcat = UCS2Strcat;
  2343.         pfnUnicodeStrncat = UCS2Strncat;
  2344.     }
  2345. #endif /* __UCS2_ENCODING */ 
  2346. }
  2347. /*****************************************************************************
  2348.  * FUNCTION
  2349.  *  InitAllApplications
  2350.  * DESCRIPTION
  2351.  *  Initialize all application
  2352.  * PARAMETERS
  2353.  *  void
  2354.  * RETURNS
  2355.  *  void
  2356.  *****************************************************************************/
  2357. void InitAllApplications(void)
  2358. {
  2359.     /*----------------------------------------------------------------*/
  2360.     /* Local Variables                                                */
  2361.     /*----------------------------------------------------------------*/
  2362.     /*----------------------------------------------------------------*/
  2363.     /* Code Body                                                      */
  2364.     /*----------------------------------------------------------------*/
  2365.     gInitAllAppFlag = 1;
  2366.     gInsertSimAppFlag = 0;
  2367.     mmi_phb_sos_list_init();
  2368.     initalize_main_menu_application();
  2369.     /* 
  2370.      * Initialize Setting application 
  2371.      */
  2372.     InitSettingApp();
  2373.     /* 
  2374.      * init fun and game applcations 
  2375.      */
  2376.     mmi_fng_init_app();
  2377.     /* 
  2378.      * Initialize phone book aplication 
  2379.      */
  2380.     mmi_phb_init();
  2381. #ifdef __MOD_SMSAL__
  2382.         InitMessagesApp();  /* sms-code */
  2383.     #ifdef __MMI_MESSAGES_CHAT__
  2384.             InitializeChatApp();
  2385.     #endif
  2386. #endif /* __MOD_SMSAL__ */ 
  2387.     InitCallCost();
  2388.     InitCallHistory();
  2389. #ifdef __MMI_STOPWATCH__
  2390.     InitStopwatchApp();
  2391. #endif
  2392. #ifdef __MMI_WLAN_FEATURES__
  2393.     mmi_wlan_post_init();
  2394.     mmi_netset_init_wlan_setting();
  2395. #endif
  2396. #ifdef __MMI_VOIP__
  2397.     mmi_voip_init();
  2398. #endif
  2399. #ifdef __MMI_POC__
  2400.     mmi_poc_init();
  2401. #endif
  2402. #ifdef __MMI_EMAIL__
  2403.     mmi_email_init();
  2404. #endif
  2405.     OrgInit();
  2406.     ExtraInit();
  2407. #if (defined(__MMI_VCARD__) || defined(__MMI_VCALENDAR__))
  2408. #ifndef MMI_ON_WIN32
  2409.     mmi_vobj_init();    /* Initial after mmiapi */
  2410. #elif defined(__MMI_VCALENDAR__)
  2411.     mmi_vclndr_init();
  2412. #endif 
  2413. #endif /* (defined(__MMI_VCARD__) || defined(__MMI_VCALENDAR__)) */ 
  2414. #ifdef __MMI_VRSD__
  2415.     mmi_vrsd_init();
  2416. #endif 
  2417. #ifdef __MMI_VRSI__
  2418.     mmi_vrsi_init();
  2419. #endif 
  2420. #ifdef __MMI_IMPS__
  2421.     mmi_imps_init();
  2422. #endif 
  2423. #ifdef __MMI_DOWNLOAD_AGENT__
  2424.     mmi_da_init_app();
  2425. #endif
  2426. #ifdef __MMI_EBOOK_READER__
  2427.     InitEbookApp();
  2428. #endif 
  2429. #ifdef __MMI_SWFLASH__
  2430.     mmi_swflash_init_app();
  2431. #endif
  2432. #ifdef __SYNCML_SUPPORT__
  2433.     mmi_syncml_init();
  2434. #endif
  2435. #ifdef __MMI_CCA_SUPPORT__
  2436.     mmi_cca_init();
  2437. #endif
  2438.     /* 
  2439.      * Note: all applications shall be initialized before shortcut
  2440.      */
  2441. #ifndef __DISABLE_SHORTCUTS_IMPL__
  2442.     ShctInit();
  2443. #endif 
  2444. }
  2445. /*****************************************************************************
  2446.  * FUNCTION
  2447.  *  InitInsertSimApp
  2448.  * DESCRIPTION
  2449.  *  Initialize few applications which do not require SIM to be present
  2450.  * PARAMETERS
  2451.  *  void
  2452.  * RETURNS
  2453.  *  void
  2454.  *****************************************************************************/
  2455. void InitInsertSimApp(void)
  2456. {
  2457.     /*----------------------------------------------------------------*/
  2458.     /* Local Variables                                                */
  2459.     /*----------------------------------------------------------------*/
  2460.     /*----------------------------------------------------------------*/
  2461.     /* Code Body                                                      */
  2462.     /*----------------------------------------------------------------*/
  2463.     gInsertSimAppFlag = 1;
  2464.     DinitSubLCDHistory();
  2465. #ifdef __MMI_BT_HP_SUPPORT__
  2466.     mmi_bt_pwroff();    /* apply to handphone only */
  2467. #endif 
  2468.     /* diamond, 2006/03/31 Not re-init these applications if no sim indication is sent after successful power on with sim */
  2469.     if (!gInitAllAppFlag)
  2470.     {
  2471.         initalize_main_menu_application();
  2472.         mmi_fng_init_app();
  2473.         mmi_phb_init();
  2474.         OrgInit();
  2475.         ExtraInit();
  2476.         InitSettingApp();   /* diamond, 2005/12/23 Phone setup in option menu */
  2477.     #ifdef __MMI_STOPWATCH__
  2478.         InitStopwatchApp();
  2479.     #endif 
  2480.     #if (defined(__MMI_VCARD__) || defined(__MMI_VCALENDAR__))
  2481.     #ifndef MMI_ON_WIN32
  2482.         mmi_vobj_init();    /* Initial after mmiapi */
  2483.     #endif 
  2484.     #endif /* (defined(__MMI_VCARD__) || defined(__MMI_VCALENDAR__)) */ 
  2485.     #ifdef __MMI_DOWNLOAD_AGENT__
  2486.         mmi_da_init_app();
  2487.     #endif
  2488. #ifdef __MMI_WLAN_FEATURES__
  2489.     mmi_wlan_post_init();
  2490.     mmi_netset_init_wlan_setting();
  2491.     #ifdef __MMI_VOIP__
  2492.         mmi_voip_init();
  2493.     #endif
  2494.     #ifdef __MMI_POC__
  2495.         mmi_poc_init();
  2496.     #endif
  2497.     #ifdef __MMI_EMAIL__
  2498.         mmi_email_init();
  2499.     #endif
  2500.     #ifdef __MMI_IMPS__
  2501.         mmi_imps_init();
  2502.     #endif
  2503.     #ifdef __SYNCML_SUPPORT__
  2504.         mmi_syncml_init();
  2505.     #endif
  2506.     #ifndef __DISABLE_SHORTCUTS_IMPL__
  2507.         ShctInit();
  2508.     #endif
  2509. #else /* __MMI_WLAN_FEATURES__ */
  2510.     #ifdef __SYNCML_SUPPORT__
  2511.         mmi_syncml_read_settings_from_nvram();
  2512.     #endif
  2513. #endif /* __MMI_WLAN_FEATURES__ */
  2514.     /* AlarmInitNvRam(); */
  2515.     }
  2516. }
  2517. /*****************************************************************************
  2518.  * FUNCTION
  2519.  *  InitNvramData
  2520.  * DESCRIPTION
  2521.  *  Allows the applications to read their NVRAM data
  2522.  * PARAMETERS
  2523.  *  void
  2524.  * RETURNS
  2525.  *  void
  2526.  *****************************************************************************/
  2527. void InitNvramData(void)
  2528. {
  2529.     /*----------------------------------------------------------------*/
  2530.     /* Local Variables                                                */
  2531.     /*----------------------------------------------------------------*/
  2532.     /*----------------------------------------------------------------*/
  2533.     /* Code Body                                                      */
  2534.     /*----------------------------------------------------------------*/
  2535.     InitDownloadNVRAM();
  2536. #ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
  2537.     PmgInitExtMelodyStruct();
  2538. #endif 
  2539. //KP Jerry add on 2007-2-15 start
  2540. #ifdef __DUAL_SIM_SUPPORT__
  2541. LoadSIMSwitchAllData();
  2542. #endif
  2543. //KP Jerry add on 2007-2-15 end
  2544.     /* __USB_IN_NORMAL_MODE__ */
  2545.     PhnsetReadWallpaper();
  2546.     PhnsetReadGPIOSetting();
  2547. #if defined(__MMI_UI_TECHNO_IDLESCREEN_BAR__)
  2548.     PhnsetReadIdleClockType();
  2549. #endif 
  2550. #ifdef __MMI_POWER_ON_OFF_DISPLAY__
  2551.     PhnsetReadPwrOnOffDisp();
  2552. #endif 
  2553.     /* __USB_IN_NORMAL_MODE__ */
  2554. #ifdef __MMI_THEMES_V2_SUPPORT__
  2555.     mmi_theme_manager_init();
  2556. #endif 
  2557.     PhnsetInitSetTimeNDateNvram();
  2558.     PhnsetReadNvramScrSvrSettings();
  2559.     InitNvramCallerId();
  2560. #ifdef __IP_NUMBER__
  2561.     LoadIPNumbers();
  2562. #endif 
  2563.     /*
  2564.      * Call Management:load black list
  2565.      */
  2566. #ifdef __MMI_CM_BLACK_LIST__
  2567.     LoadBlackListNum();
  2568. #endif 
  2569.     initnvramprofapp();
  2570.     InitSettingNVRAM();
  2571.     ReadValueCityNVRAM();
  2572.     /*
  2573.      * MAX: for new alarm
  2574.      */
  2575.     InitAlarmFrameWork();
  2576. #if defined(__MMI_THEMES_APPLICATION__)
  2577.         InitThemes();
  2578. #endif
  2579.     SetModeSpeechVolume();
  2580. #ifdef __MOD_SMSAL__
  2581.         InitCBNVRAMData();
  2582.     #ifdef __MMI_MESSAGES_TEMPLATE__
  2583.             InitTemplates();
  2584.     #endif
  2585. #endif /* __MOD_SMSAL__ */ 
  2586. #if defined(__MMI_RING_COMPOSER__) && defined(__MMI_IMELODY_SUPPORT__)
  2587.         InitRingToneComposer();
  2588. #endif
  2589. #ifdef __MMI_STOPWATCH__
  2590.         InitStopwatchNVRAM();
  2591. #endif
  2592. #ifdef __MMI_IMPS__
  2593.         mmi_imps_init_nvram();
  2594. #endif
  2595. #ifdef __MMI_USER_CTRL_PLMN_SUPPORT__
  2596.     mmi_netset_init_user_ctrl_plmn();
  2597. #endif 
  2598. }
  2599. /*****************************************************************************
  2600.  * FUNCTION
  2601.  *  InitPCSimulatorBootup
  2602.  * DESCRIPTION
  2603.  *  Automatically bootup the PC simulator only if level1
  2604.  * PARAMETERS
  2605.  *  void
  2606.  * RETURNS
  2607.  *  void
  2608.  *****************************************************************************/
  2609. #if defined(MMI_ON_WIN32)
  2610. void InitPCSimulatorBootup(void)
  2611. {
  2612.     /*----------------------------------------------------------------*/
  2613.     /* Local Variables                                                */
  2614.     /*----------------------------------------------------------------*/
  2615.     /*----------------------------------------------------------------*/
  2616.     /* Code Body                                                      */
  2617.     /*----------------------------------------------------------------*/
  2618.     /* 
  2619.      * For level 1 auto bootup
  2620.      */
  2621.     {
  2622.         MYQUEUE Message;
  2623.         mmi_eq_power_on_ind_struct *BootupReq;
  2624.         BootupReq = OslConstructDataPtr(sizeof(mmi_eq_power_on_ind_struct));
  2625.         BootupReq->poweron_mode = (U8) 0;
  2626.         BootupReq->battery_level = (U8) 0;
  2627.         BootupReq->build_label = (U8) 0;
  2628.         BootupReq->rtc_time.rtc_sec = (U8) 253;
  2629.         BootupReq->rtc_time.rtc_min = (U8) 253;
  2630.         BootupReq->rtc_time.rtc_hour = (U8) 253;
  2631.         BootupReq->rtc_time.rtc_day = (U8) 253;
  2632.         BootupReq->rtc_time.rtc_mon = (U8) 253;
  2633.         BootupReq->rtc_time.rtc_wday = (U8) 253;
  2634.         BootupReq->rtc_time.rtc_year = (U8) 253;
  2635.         Message.oslMsgId = MMI_EQ_POWER_ON_IND;
  2636.         Message.oslDataPtr = (oslParaType*) BootupReq;
  2637.         Message.oslPeerBuffPtr = NULL;
  2638.         Message.oslSrcId = MOD_L4C;
  2639.         Message.oslDestId = MOD_MMI;
  2640.         OslMsgSendExtQueue(&Message);
  2641.     }
  2642.     {
  2643.         MYQUEUE Message;
  2644.         mmi_smu_password_required_ind_struct *SIMInd;
  2645.         SIMInd = OslConstructDataPtr(sizeof(mmi_smu_password_required_ind_struct));
  2646.         SIMInd->type = 0;
  2647.         SIMInd->is_sim_change = 0;
  2648.         SIMInd->chv_info.chv1_count = 13;
  2649.         SIMInd->chv_info.chv2_count = 240;
  2650.         SIMInd->chv_info.ubchv1_count = 173;
  2651.         SIMInd->chv_info.ubchv2_count = 186;
  2652.         SIMInd->chv_info.is_chv1_enabled = 171;
  2653.         SIMInd->chv_info.is_chv1_verified = 171;
  2654.         Message.oslMsgId = MSG_ID_GET_PIN_RES;
  2655.         Message.oslDataPtr = (oslParaType*) SIMInd;
  2656.         Message.oslPeerBuffPtr = NULL;
  2657.         Message.oslSrcId = MOD_L4C;
  2658.         Message.oslDestId = MOD_MMI;
  2659.         OslMsgSendExtQueue(&Message);
  2660.     }
  2661.     {
  2662.         MYQUEUE Message;
  2663.         mmi_nw_attach_ind_struct *NetworkInd;
  2664.         NetworkInd = OslConstructDataPtr(sizeof(mmi_nw_attach_ind_struct));
  2665.         NetworkInd->status = 0;
  2666.         sprintf(NetworkInd->plmn, "46688");
  2667.         NetworkInd->gsm_state = 0;
  2668.         NetworkInd->gprs_state = 0;
  2669.         Message.oslMsgId = PRT_NW_ATTACH_IND;
  2670.         Message.oslDataPtr = (oslParaType*) NetworkInd;
  2671.         Message.oslPeerBuffPtr = NULL;
  2672.         Message.oslSrcId = MOD_L4C;
  2673.         Message.oslDestId = MOD_MMI;
  2674.         OslMsgSendExtQueue(&Message);
  2675.     }
  2676. }
  2677. #endif /* defined(MMI_ON_WIN32) */