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

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.  *  MiscFunctions.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *  MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Misc Functions
  48.  *  (1) Power On/Off
  49.  *  (2) Analog clock 
  50.  *  (3) Others - UI
  51.  *
  52.  * Author:
  53.  * -------
  54.  * -------
  55.  *
  56.  *============================================================================
  57.  *             HISTORY
  58.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  59.  *------------------------------------------------------------------------------
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  * removed!
  143.  * removed!
  144.  * removed!
  145.  *
  146.  * removed!
  147.  * removed!
  148.  * removed!
  149.  *
  150.  * removed!
  151.  * removed!
  152.  * removed!
  153.  *
  154.  * removed!
  155.  * removed!
  156.  * removed!
  157.  *
  158.  * removed!
  159.  * removed!
  160.  * removed!
  161.  *
  162.  * removed!
  163.  * removed!
  164.  * removed!
  165.  *
  166.  * removed!
  167.  * removed!
  168.  * removed!
  169.  *
  170.  * removed!
  171.  * removed!
  172.  * removed!
  173.  *
  174.  * removed!
  175.  * removed!
  176.  * removed!
  177.  *
  178.  * removed!
  179.  * removed!
  180.  * removed!
  181.  *
  182.  * removed!
  183.  * removed!
  184.  * removed!
  185.  *
  186.  * removed!
  187.  * removed!
  188.  * removed!
  189.  *
  190.  * removed!
  191.  * removed!
  192.  * removed!
  193.  *
  194.  * removed!
  195.  * removed!
  196.  * removed!
  197.  *
  198.  * removed!
  199.  * removed!
  200.  * removed!
  201.  *
  202.  * removed!
  203.  * removed!
  204.  * removed!
  205.  *
  206.  * removed!
  207.  * removed!
  208.  * removed!
  209.  *
  210.  * removed!
  211.  * removed!
  212.  * removed!
  213.  *
  214.  * removed!
  215.  * removed!
  216.  * removed!
  217.  *
  218.  * removed!
  219.  * removed!
  220.  * removed!
  221.  *
  222.  * removed!
  223.  * removed!
  224.  * removed!
  225.  *
  226.  * removed!
  227.  * removed!
  228.  * removed!
  229.  *
  230.  * removed!
  231.  * removed!
  232.  * removed!
  233.  *
  234.  * removed!
  235.  * removed!
  236.  * removed!
  237.  *
  238.  *------------------------------------------------------------------------------
  239.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  240.  *============================================================================
  241.  ****************************************************************************/
  242. /****************************************************************************
  243. * Include Files                                                                
  244. *****************************************************************************/
  245. #include "MMI_features.h"
  246. #include "EventsGprot.h"
  247. #include "FontRes.h"
  248. #include "CSP.h"
  249. #include "gdi_include.h"
  250. #include "gui_setting.h"
  251. #include "CustDataProts.h"
  252. #include "AlarmFrameWorkProt.h"
  253. #include "IdleAppDef.h"
  254. #include "HistoryGprot.h"
  255. #include "MiscFunctions.h"
  256. #include "SimDetectionGprot.h"
  257. #include "Unicodexdcl.h"
  258. #include "Globaldefs.h"
  259. #include "gpioInc.h"
  260. #include "SimDetectionGexdcl.h"
  261. #include "TimerEvents.h"
  262. #include "IdleAppProt.h"
  263. #include "ProfileGprots.h"
  264. #include "Fat_fs.h"
  265. #include "FileSystemDef.h"      /* file function */
  266. #include "FileManagerGProt.h"   /* file path / file error  */
  267. #include "FileManagerDef.h"     /* error string id */
  268. #include "FileMgr.h"
  269. #include "WPSSProtos.h" /* phone setup interface */
  270. #include "DebugInitDef.h"       /* MMI_ASSERT */
  271. #include "NVRAMType.h"  /* NVRAM data type */
  272. #include "NVRAMProt.h"  /* NVRAM access fucntions */
  273. #include "NVRAMEnum.h"  /* NVRAM ID define */
  274. #include "CallManagementIdDef.h"        /* for MT screen id */
  275. #include "CustResDef.h"
  276. #include "PhoneSetup.h" /* Cylen 0926, customize display char */
  277. #ifdef MMI_ON_HARDWARE_P
  278. #include "GpioInc.h"
  279. #endif 
  280. #include "wgui_status_icons.h"
  281. #include "wgui_categories_defs.h"
  282. #include "wgui_categories_sublcd.h"
  283. #include "wgui_categories_multimedia.h"
  284. #include "SubLCDHistoryGprot.h" /* for ForceSubLCDScreen() */
  285. #include "ProfilesGexdcl.h"     /* for profile global var */
  286. #include "StatusIconRes.h"
  287. #include "AppMemMgrGprot.h"
  288. #include "ScrMemMgrGprot.h"
  289. #include "SettingGprots.h"
  290. #if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
  291. #include "kal_non_specific_general_types.h"
  292. #include "TouchScreenGprot.h"
  293. #endif /* defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__) */ 
  294. #include "mmi_trc.h"
  295. #ifdef __DRM_SUPPORT__
  296. #include "Drm_gprot.h"  /* DRM support */
  297. #endif 
  298. #include "datetimetype.h"
  299. #include "app_datetime.h"
  300. /***************************************************************************** 
  301. * Define
  302. *****************************************************************************/
  303. /***************************************************************************** 
  304. * Typedef 
  305. *****************************************************************************/
  306. /*****************************************************************************
  307. * Global Variabl                                                          
  308. *****************************************************************************/
  309. #if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
  310. BOOL DirectMode = FALSE;
  311. #endif 
  312. BOOL g_pwron_is_terminate_diplay = FALSE;
  313. BOOL g_pwron_is_image = FALSE;
  314. BOOL g_pwron_is_successful_play = FALSE;
  315. BOOL g_pwron_is_entered = FALSE;
  316. /*****************************************************************************
  317. * Global Function                                                           
  318. *****************************************************************************/
  319. extern void ShowLowPowerShutdownScr(void);
  320. extern void EntryFMMenu(void);
  321. extern void ReqReadDailNum(void);
  322. extern void wgui_set_animation(S32 x, S32 y, MMI_ID_TYPE img);
  323. extern void InitAllApplications(void);
  324. extern void CallBackPowerOnAnimationComplete(GDI_RESULT ret);
  325. extern void RegisterCategory166AnimationCompleteCallback(void (*f) (S32 result));
  326. extern void PowerOnBatteryIndicationComplete(void);
  327. extern BOOL IsClamClose(void);
  328. extern void ShowCategory310Screen(UI_string_type string);
  329. /***************************************************************************** 
  330. * Local Variable
  331. *****************************************************************************/
  332. #if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
  333. U8 FMPatternBuffer[20];
  334. S8 *ssc_fm_string = SSC_FACTORY_MODE;
  335. #endif /* defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__) */ 
  336. /*****************************************************************************
  337. * Local Function 
  338. *****************************************************************************/
  339. void mmi_pwron_exit_animation_screen(void);
  340. void exit_custom_startup_screen(void);
  341. /*****************************************************************************
  342. *
  343. *  Power On
  344. *
  345. *****************************************************************************/
  346. /*****************************************************************************
  347.  * FUNCTION
  348.  *  goto_opening_screen
  349.  * DESCRIPTION
  350.  *  go to opening screen
  351.  * PARAMETERS
  352.  *  void
  353.  * RETURNS
  354.  *  void
  355.  *****************************************************************************/
  356. void goto_opening_screen(void)
  357. {
  358.     /*----------------------------------------------------------------*/
  359.     /* Local Variables                                                */
  360.     /*----------------------------------------------------------------*/
  361.     /*----------------------------------------------------------------*/
  362.     /* Code Body                                                      */
  363.     /*----------------------------------------------------------------*/
  364.     if (GetAbnormalReset() == 1)    /* abnormal reset */
  365.     {
  366.         TurnOnBacklight(1);
  367.         ResetAbnormalReset();
  368.         /*  to initialize SMS/CPHS after abnormal reset */
  369.         CSPModifyHiliteHandlers();
  370.         BeforeEntryIdleScr();
  371.     }
  372.     else
  373.     {
  374.         TurnOnBacklight(1);
  375.         ClearInputEventHandler(MMI_DEVICE_ALL);
  376.         ClearKeyHandler(KEY_END, KEY_LONG_PRESS);
  377.         InitAllApplications();
  378.         exit_custom_startup_screen();
  379.     }
  380.     GetPhoneLock(); /* diamond, 2006/02/27 Move this function call here because smu is not initialized in exception power on */
  381. }
  382. /*****************************************************************************
  383.  * FUNCTION
  384.  *  exit_custom_startup_screen
  385.  * DESCRIPTION
  386.  *  exit power on animation screen
  387.  * PARAMETERS
  388.  *  void
  389.  * RETURNS
  390.  *  void
  391.  *****************************************************************************/
  392. void exit_custom_startup_screen(void)
  393. {
  394.     /*----------------------------------------------------------------*/
  395.     /* Local Variables                                                */
  396.     /*----------------------------------------------------------------*/
  397.     /*----------------------------------------------------------------*/
  398.     /* Code Body                                                      */
  399.     /*----------------------------------------------------------------*/
  400.     if (GetAbnormalReset() == 0)
  401.     {
  402.         gui_hide_animations();
  403.         CSPModifyHiliteHandlers();      /* CSP Functionality needs to be here after all
  404.                                            applications have initialised */
  405.         ShowWelcomeScr();
  406.         ShowIdleAppSubLcd();
  407.     }
  408. }
  409. #if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
  410. /*****************************************************************************
  411.  * FUNCTION
  412.  *  CallBackPowerOnAnimationCompleteWrapper
  413.  * DESCRIPTION
  414.  *  wrapper function to enumate poweron animation play finish
  415.  * PARAMETERS
  416.  *  void
  417.  * RETURNS
  418.  *  void
  419.  *****************************************************************************/
  420. void CallBackPowerOnAnimationCompleteWrapper(void)
  421. {
  422.     /*----------------------------------------------------------------*/
  423.     /* Local Variables                                                */
  424.     /*----------------------------------------------------------------*/
  425.     /*----------------------------------------------------------------*/
  426.     /* Code Body                                                      */
  427.     /*----------------------------------------------------------------*/
  428.     CallBackPowerOnAnimationComplete(0);
  429. }
  430. /*****************************************************************************
  431.  * FUNCTION
  432.  *  DirectModeToFM
  433.  * DESCRIPTION
  434.  *  Direct entry factory mode
  435.  * PARAMETERS
  436.  *  void
  437.  * RETURNS
  438.  *  void
  439.  *****************************************************************************/
  440. static void DirectModeToFM(void)
  441. {
  442.     /*----------------------------------------------------------------*/
  443.     /* Local Variables                                                */
  444.     /*----------------------------------------------------------------*/
  445.     /*----------------------------------------------------------------*/
  446.     /* Code Body                                                      */
  447.     /*----------------------------------------------------------------*/
  448.     DirectMode = TRUE;
  449.     /* Low battery shutdown */
  450.     if (((g_charbat_context.batteryStatus == PMIC_VBAT_STATUS ||        /* Battery Status */
  451.           g_charbat_context.batteryStatus == PMIC_CHARGER_OUT) && g_charbat_context.isChargerConnected == 0) && (g_charbat_context.chargerLevel == BATTERY_LOW_POWEROFF))       /* Battery Level */
  452.     {
  453.         ShowLowPowerShutdownScr();
  454.         return;
  455.     }
  456.     gui_hide_animations();
  457.     EntryFMMenu();
  458. }
  459. /*****************************************************************************
  460.  * FUNCTION
  461.  *  KeyPatternIdentifier
  462.  * DESCRIPTION
  463.  *  Key Pattern Identifier
  464.  * PARAMETERS
  465.  *  void
  466.  * RETURNS
  467.  *  void
  468.  *****************************************************************************/
  469. static void KeyPatternIdentifier(void)
  470. {
  471.     /*----------------------------------------------------------------*/
  472.     /* Local Variables                                                */
  473.     /*----------------------------------------------------------------*/
  474.     U16 Keycode, Keytype;
  475.     /* Avoid compile warning because KEY_0 is 0 for now, 
  476.        but it might be changed to non-zero value in the future. */
  477.     S16 Keycode_signed;     
  478.     static U8 index = 0;
  479.     U8 *pTemp;
  480.     U8 len;
  481.     /*----------------------------------------------------------------*/
  482.     /* Code Body                                                      */
  483.     /*----------------------------------------------------------------*/
  484.     GetkeyInfo(&Keycode, &Keytype);
  485.     Keycode_signed = (S16) Keycode;
  486.     len = (strlen((char*)(ssc_fm_string)));
  487.     if (index < len)
  488.     {
  489.         /* Only accept '#' , '*', '0' ~ '9' */
  490.         if (Keycode == KEY_POUND)
  491.         {
  492.             FMPatternBuffer[index] = '#';
  493.         }
  494.         else if (Keycode == KEY_STAR)
  495.         {
  496.             FMPatternBuffer[index] = '*';
  497.         }
  498.         else if ((Keycode_signed >= KEY_0) && (Keycode <= KEY_9))  /* 0 ~ 9 */
  499.         {
  500.             FMPatternBuffer[index] = Keycode + '0';
  501.         }
  502.         index++;
  503.     }
  504.     if (index == len)
  505.     {
  506.         pTemp = (U8*) ssc_fm_string;
  507.         if (strcmp((S8*) pTemp, (S8*) FMPatternBuffer) == 0)
  508.         {
  509.             ClearKeyHandler(KEY_POUND, KEY_EVENT_DOWN);
  510.             ClearKeyHandler(KEY_STAR, KEY_EVENT_DOWN);
  511.             ClearKeyHandler(KEY_0, KEY_EVENT_DOWN);
  512.             ClearKeyHandler(KEY_1, KEY_EVENT_DOWN);
  513.             ClearKeyHandler(KEY_2, KEY_EVENT_DOWN);
  514.             ClearKeyHandler(KEY_3, KEY_EVENT_DOWN);
  515.             ClearKeyHandler(KEY_4, KEY_EVENT_DOWN);
  516.             ClearKeyHandler(KEY_5, KEY_EVENT_DOWN);
  517.             ClearKeyHandler(KEY_6, KEY_EVENT_DOWN);
  518.             ClearKeyHandler(KEY_7, KEY_EVENT_DOWN);
  519.             ClearKeyHandler(KEY_8, KEY_EVENT_DOWN);
  520.             ClearKeyHandler(KEY_9, KEY_EVENT_DOWN);
  521.             DirectModeToFM();
  522.         }
  523.     }
  524. }
  525. #endif /* defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__) */ 
  526. /*****************************************************************************
  527.  * FUNCTION
  528.  *  mmi_pwron_play_video_callback
  529.  * DESCRIPTION
  530.  *  play power on video result callback function
  531.  * PARAMETERS
  532.  *  result      [IN]        Play video's reult
  533.  * RETURNS
  534.  *  void
  535.  *****************************************************************************/
  536. void mmi_pwron_play_video_callback(MDI_RESULT result)
  537. {
  538.     /*----------------------------------------------------------------*/
  539.     /* Local Variables                                                */
  540.     /*----------------------------------------------------------------*/
  541.     /*----------------------------------------------------------------*/
  542.     /* Code Body                                                      */
  543.     /*----------------------------------------------------------------*/
  544.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_ANIMATION_FINISH));
  545.     if (g_pwron_is_terminate_diplay)
  546.     {
  547.         /* means already terminated by time out, shall skip this callback */
  548.         return;
  549.     }
  550.     /* treat as gif animation */
  551.     /* change to GIF's return */
  552.     if (result < 0)
  553.     {
  554.         /* return false, will force to enter the next procedure of power on */
  555.         CallBackPowerOnAnimationComplete(-1);
  556.     }
  557.     else
  558.     {
  559.         /* play finish successfully - reset flag to PWRON_DISPLAY_SUCCESS */
  560.         g_pwron_is_successful_play = TRUE;
  561.         /* call before access NVRAM */
  562.         CallBackPowerOnAnimationComplete(GDI_GIF_LAST_FRAME);
  563.     }
  564. }
  565. /*****************************************************************************
  566.  * FUNCTION
  567.  *  mmi_pwron_show_image_callback
  568.  * DESCRIPTION
  569.  *  show power on image result callback function
  570.  * PARAMETERS
  571.  *  result      [IN]        Play video's reult
  572.  * RETURNS
  573.  *  void
  574.  *****************************************************************************/
  575. void mmi_pwron_show_image_callback(GDI_RESULT result)
  576. {
  577.     /*----------------------------------------------------------------*/
  578.     /* Local Variables                                                */
  579.     /*----------------------------------------------------------------*/
  580.     /*----------------------------------------------------------------*/
  581.     /* Code Body                                                      */
  582.     /*----------------------------------------------------------------*/
  583.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_IMAGE_FINISH));
  584.     if (g_pwron_is_terminate_diplay)
  585.     {
  586.         /* means already terminated by time out, shall skip this callback */
  587.         return;
  588.     }
  589.     if (result < 0 && result != GDI_IMAGE_IS_STILL_IMAGE)
  590.     {
  591.         /* return false, will force to enter the next procedure of power on */
  592.         CallBackPowerOnAnimationComplete(result);
  593.     }
  594.     /* diamond, 2005/08/28 fix still image cannot enter idle screen issue */
  595.     else if (result == GDI_IMAGE_IS_STILL_IMAGE)
  596.     {
  597.         g_pwron_is_successful_play = TRUE;
  598.         CallBackPowerOnAnimationComplete(result);
  599.     }
  600.     /* end, diamond */
  601.     else
  602.     {
  603.         /* play finish successfully */
  604.         g_pwron_is_successful_play = TRUE;
  605.         /* call before access NVRAM */
  606.         CallBackPowerOnAnimationComplete(GDI_SUCCEED);
  607.     }
  608. }
  609. /*****************************************************************************
  610.  * FUNCTION
  611.  *  mmi_pwron_froce_terminate_display
  612.  * DESCRIPTION
  613.  *  force terminate power on display
  614.  * PARAMETERS
  615.  *  void
  616.  * RETURNS
  617.  *  void
  618.  *****************************************************************************/
  619. static void mmi_pwron_froce_terminate_display(void)
  620. {
  621.     /*----------------------------------------------------------------*/
  622.     /* Local Variables                                                */
  623.     /*----------------------------------------------------------------*/
  624.     /*----------------------------------------------------------------*/
  625.     /* Code Body                                                      */
  626.     /*----------------------------------------------------------------*/
  627.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_ANIMATION_TIMEOUT));
  628.     /* if never successfully play once, force stop */
  629.     if (!g_pwron_is_successful_play)
  630.     {
  631.         g_pwron_is_terminate_diplay = TRUE;
  632.         g_pwron_is_successful_play = TRUE;
  633.         /* mimic gif last frame callback */
  634.         CallBackPowerOnAnimationComplete(GDI_GIF_LAST_FRAME);
  635.         /* start another timer to try */
  636.         gui_start_timer(200, mmi_pwron_froce_terminate_display);
  637.     }
  638. }
  639. /*****************************************************************************
  640.  * FUNCTION
  641.  *  mmi_pwron_stop_animation
  642.  * DESCRIPTION
  643.  *  this function is used to stop power on animation screen, called when ready
  644.  *  to enter idle screen, it is used to solve NVRAM & timer interlace problem
  645.  *  
  646.  *  [Note]
  647.  *  when ready to enter power on screen, it will enter goto_opening_screen(),
  648.  *  in this function, it will call InitAllApplications(), there are NVRAM access
  649.  *  in this function, which will cause NVRAM & timer interlace problem.
  650.  *  
  651.  *  we have to stop all animation timer when we are sure poweron procdure success.
  652.  *  we may call this function in mmi_ready_to_idle_screen_ind.
  653.  * PARAMETERS
  654.  *  void
  655.  * RETURNS
  656.  *  void
  657.  *****************************************************************************/
  658. void mmi_pwron_stop_animation(void)
  659. {
  660.     /*----------------------------------------------------------------*/
  661.     /* Local Variables                                                */
  662.     /*----------------------------------------------------------------*/
  663.     U16 pwron_flag;
  664.     S16 error;
  665.     /*----------------------------------------------------------------*/
  666.     /* Code Body                                                      */
  667.     /*----------------------------------------------------------------*/
  668.     if (GetExitScrnID() != SCR_OPEN_SCREEN_ID)
  669.     {
  670.         return;
  671.     }
  672.     /* stop force teminate timer */
  673.     gui_cancel_timer(mmi_pwron_froce_terminate_display);
  674.     if (g_pwron_is_image)
  675.     {
  676.         /* stop image playing */
  677.         StopCategory166Animation();
  678.     }
  679.     else
  680.     {
  681.     #if defined(__MMI_VIDEO_PLAYER__)
  682.         /* stop video playing */
  683.         StopCategory224Video();
  684.     #endif /* defined(__MMI_VIDEO_PLAYER__) */ 
  685.     }
  686.     /* write proper value to NVRAM */
  687.     if (!g_pwron_is_successful_play)
  688.     {
  689.     #if defined(__MMI_POWER_ON_OFF_DISPLAY__)
  690.         /* restore default */
  691.         PhnsetRstPwrOnDisplayDefault();
  692.     #endif /* defined(__MMI_POWER_ON_OFF_DISPLAY__) */ 
  693.     }
  694.     pwron_flag = PWRON_DISPLAY_SUCCESS;
  695.     WriteValue(NVRAM_POWER_ON_DISPLAY_SUCCESS, &pwron_flag, DS_SHORT, &error);
  696. }
  697. /*****************************************************************************
  698.  * FUNCTION
  699.  *  mmi_pwron_pause_video
  700.  * DESCRIPTION
  701.  *  pause video, this funcion will be used by TV-Out
  702.  * PARAMETERS
  703.  *  void
  704.  * RETURNS
  705.  *  void
  706.  *****************************************************************************/
  707. #if defined(__MMI_VIDEO_PLAYER__)
  708. void mmi_pwron_pause_video(void)
  709. {
  710.     /*----------------------------------------------------------------*/
  711.     /* Local Variables                                                */
  712.     /*----------------------------------------------------------------*/
  713.     /*----------------------------------------------------------------*/
  714.     /* Code Body                                                      */
  715.     /*----------------------------------------------------------------*/
  716.     if (!g_pwron_is_image)
  717.     {
  718.         PauseCategory224Video();
  719.     }
  720. }
  721. #endif /* defined(__MMI_VIDEO_PLAYER__) */ 
  722. /*****************************************************************************
  723.  * FUNCTION
  724.  *  mmi_pwron_resume_video
  725.  * DESCRIPTION
  726.  *  resume video, this funcion will be used by TV-Out
  727.  * PARAMETERS
  728.  *  void
  729.  * RETURNS
  730.  *  void
  731.  *****************************************************************************/
  732. #if defined(__MMI_VIDEO_PLAYER__)
  733. void mmi_pwron_resume_video(void)
  734. {
  735.     /*----------------------------------------------------------------*/
  736.     /* Local Variables                                                */
  737.     /*----------------------------------------------------------------*/
  738.     /*----------------------------------------------------------------*/
  739.     /* Code Body                                                      */
  740.     /*----------------------------------------------------------------*/
  741.     if (!g_pwron_is_image)
  742.     {
  743.         ResumeCategory224Video();
  744.     }
  745. }
  746. #endif /* defined(__MMI_VIDEO_PLAYER__) */ 
  747. /*****************************************************************************
  748.  * FUNCTION
  749.  *  mmi_pwron_draw_sublcd_dummy_screen
  750.  * DESCRIPTION
  751.  *  dummy screen
  752.  * PARAMETERS
  753.  *  void
  754.  * RETURNS
  755.  *  void
  756.  *****************************************************************************/
  757. #if defined(__MMI_VIDEO_PLAYER__)
  758. static void mmi_pwron_draw_sublcd_dummy_screen(void)
  759. {
  760.     /*----------------------------------------------------------------*/
  761.     /* Local Variables                                                */
  762.     /*----------------------------------------------------------------*/
  763.     /*----------------------------------------------------------------*/
  764.     /* Code Body                                                      */
  765.     /*----------------------------------------------------------------*/
  766.     /* draw nothing, just for category224's sublcd screen have a screen to goback. */
  767. }
  768. #endif /* defined(__MMI_VIDEO_PLAYER__) */ 
  769. /*****************************************************************************
  770.  * FUNCTION
  771.  *  mmi_pwron_entry_animation_screen
  772.  * DESCRIPTION
  773.  *  start play poweron animation
  774.  *  (1) GIF animation
  775.  *  (2) Still image
  776.  *  (3) Video clip
  777.  * PARAMETERS
  778.  *  void
  779.  * RETURNS
  780.  *  void
  781.  *****************************************************************************/
  782. void mmi_pwron_entry_animation_screen(void)
  783. {
  784.     /*----------------------------------------------------------------*/
  785.     /* Local Variables                                                */
  786.     /*----------------------------------------------------------------*/
  787.     U16 disp_id;
  788.     PS8 filename_ptr;
  789.     S16 error;
  790.     U16 pwron_flag;
  791.     U16 force_stop_time;
  792. #if defined(__MMI_VIDEO_PLAYER__)
  793.     SubLCDHistoryNode sub_history;
  794.     BOOL play_audio;
  795. #endif /* defined(__MMI_VIDEO_PLAYER__) */ 
  796. #if defined(__MMI_POWER_ON_OFF_DISPLAY__)
  797.     FS_HANDLE fs_handle;
  798. #endif /* defined(__MMI_POWER_ON_OFF_DISPLAY__) */ 
  799.     U16 res_type;
  800.     /*----------------------------------------------------------------*/
  801.     /* Code Body                                                      */
  802.     /*----------------------------------------------------------------*/
  803.     /* 
  804.      * 
  805.      * Power On Procedure
  806.      * 
  807.      * Power On Display      NAND       SIM        Net Search    Idle Scr
  808.      * #----------------------#----------#----------#-------------#-----------# 
  809.      * (option)    (option)    (option)
  810.      * 
  811.      * 
  812.      */
  813.     /* if is entered before, means back from interrupt while playing power on display */
  814.     if (g_pwron_is_entered)
  815.     {
  816.         MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_BACK2_ANIMATION));
  817.         ClearInputEventHandler(MMI_DEVICE_ALL); /* Prevent from END key is pre-registered by call management */
  818.         ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  819.         /* MT/SMS/USSD or other inetrrupt happened during poweron display, some initialzation need to be done afterward */
  820.         PowerOnBatteryIndicationComplete();
  821.         return;
  822.     }
  823.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_START_ANIMATION));
  824.     /* init */
  825.     filename_ptr = NULL;
  826.     disp_id = 0;
  827.     g_pwron_is_entered = TRUE;
  828.     g_pwron_is_image = TRUE;
  829.     g_pwron_is_successful_play = FALSE;
  830.     if (mmi_bootup_is_sim_failure_received() == MMI_TRUE)
  831.     {
  832.         g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_ANIMATION_SIM_FAIL;
  833.     }
  834.     else if (mmi_bootup_is_sim_need_security_check() == MMI_TRUE)
  835.     {
  836.         g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_ANIMATION_PSWD_REQ;
  837.     }
  838.     else
  839.     {
  840.         g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_ANIMATION;        /* 0x04: Power on animation */
  841.     }
  842.     TurnOnBacklight(0);
  843.    /*******************************************/
  844.     /* Valid power on display checking         */
  845.    /*******************************************/
  846.     /* Valid power on display restoration checking */
  847.     ReadValue(NVRAM_POWER_ON_DISPLAY_SUCCESS, &pwron_flag, DS_SHORT, &error);
  848.     /* 
  849.      * 0xff is the default value, each time power on display play successfully, 
  850.      * it will set to 0xff as well.
  851.      */
  852. #if defined(__MMI_POWER_ON_OFF_DISPLAY__)
  853.     if (pwron_flag == PWRON_DISPLAY_FAILED)
  854.     {
  855.         /* if flag is PWRON_DISPLAY_FAILED, means something wrong happened during playing power on display */
  856.         /* we will restore power on display to default settings */
  857.         PhnsetRstPwrOnDisplayDefault();
  858.     }
  859. #endif /* defined(__MMI_POWER_ON_OFF_DISPLAY__) */ 
  860.     /* set the flag to 0x01 , if play successfully to end, will reset back to 0xff */
  861.     pwron_flag = PWRON_DISPLAY_PLAYING;
  862.     WriteValue(NVRAM_POWER_ON_DISPLAY_SUCCESS, &pwron_flag, DS_SHORT, &error);
  863. #if defined(__MMI_POWER_ON_OFF_DISPLAY__)
  864.    /*******************************************/
  865.     /* Get animation resource from phone setup */
  866.    /*******************************************/
  867.     PhnsetGetPwrOnDisp(&disp_id);
  868.     if (disp_id == 0xff)    /* invalid format */
  869.     {
  870.         /* reset as default */
  871.         PhnsetRstPwrOnDisplayDefault();
  872.         /* this id must be a valid id */
  873.         PhnsetGetPwrOnDisp(&disp_id);
  874.     }
  875.     else if (disp_id == 0x00 || /* source from file */
  876.              disp_id == 0x01)   /* short file name */
  877.     {
  878.         PS8 error;
  879.         disp_id = 0x00;
  880.         /* filename buffer is allocated in phnset */
  881.         filename_ptr = PhnsetGetPwrOnFileName();
  882.         if (!mmi_fmgr_util_file_limit_check(FMGR_LIMIT_POWER_ON_OFF_DSPL, filename_ptr, &error))
  883.         {
  884.             /* limit check failed */
  885.             /* reset to default */
  886.             PhnsetRstPwrOnDisplayDefault();
  887.             /* this id must be a valid id */
  888.             PhnsetGetPwrOnDisp(&disp_id);
  889.             filename_ptr = NULL;
  890.         }
  891.     }
  892.     else
  893.     {
  894.         /* source from intenal resource */
  895.         filename_ptr = NULL;
  896.     }
  897.    /*******************************************/
  898.     /* Check if is image or video              */
  899.    /*******************************************/
  900.     /* get file resource type */
  901.     if (filename_ptr != NULL)
  902.     {
  903.         /* source from file */
  904.         res_type = mmi_fmgr_get_file_group(filename_ptr);
  905.         if (res_type == FMGR_GROUP_IMAGE)
  906.         {
  907.             g_pwron_is_image = TRUE;
  908.         }
  909.     #if !defined (MMI_ON_WIN32)
  910.         else if (res_type == FMGR_GROUP_VIDEO)
  911.         {
  912.             g_pwron_is_image = FALSE;
  913.         }
  914.     #endif /* !defined (MMI_ON_WIN32) */ 
  915.   #ifdef __MMI_SWFLASH__
  916.         else if (res_type == FMGR_GROUP_SWFLASH)
  917.         {
  918.             g_pwron_is_image = TRUE;
  919.         }
  920.     #endif /* __MMI_SWFLASH__ */
  921.         else
  922.         {
  923.             /* unsupported file format ext */
  924.             PhnsetRstPwrOnDisplayDefault();
  925.             /* this id must be a valid id */
  926.             PhnsetGetPwrOnDisp(&disp_id);
  927.             filename_ptr = NULL;
  928.         }
  929.     #ifdef __DRM_SUPPORT__
  930.         /* DRM permission check */
  931.         if ((fs_handle = DRM_open_file((PU16) filename_ptr, FS_READ_ONLY, DRM_PERMISSION_NONE)) >= FS_NO_ERROR)
  932.         {
  933.             if (res_type == FMGR_GROUP_IMAGE && DRM_validate_permission(fs_handle, DRM_PERMISSION_DISPLAY))
  934.             {
  935.                 DRM_consume_rights(fs_handle, DRM_PERMISSION_DISPLAY);
  936.             }
  937.         #ifdef __MMI_SWFLASH__
  938.             else if (res_type == FMGR_GROUP_SWFLASH && DRM_validate_permission(fs_handle, DRM_PERMISSION_DISPLAY))
  939.             {
  940.                 DRM_consume_rights(fs_handle, DRM_PERMISSION_DISPLAY);
  941.             }
  942.         #endif                        
  943.             else if (res_type == FMGR_GROUP_VIDEO && DRM_validate_permission(fs_handle, DRM_PERMISSION_PLAY))
  944.             {
  945.                 DRM_consume_rights(fs_handle, DRM_PERMISSION_PLAY);
  946.             }
  947.             DRM_close_file(fs_handle);
  948.         }
  949.     #else /* __DRM_SUPPORT__ */ 
  950.         fs_handle = FS_Open((U16*) filename_ptr, FS_READ_ONLY);
  951.     #endif /* __DRM_SUPPORT__ */ 
  952.         if (fs_handle < FS_NO_ERROR)
  953.         {
  954.             /* open file failed */
  955.             /* reset as default */
  956.             PhnsetRstPwrOnDisplayDefault();
  957.             /* this id must be a valid id */
  958.             PhnsetGetPwrOnDisp(&disp_id);
  959.             filename_ptr = NULL;
  960.         }
  961.         else
  962.         {
  963.             /* open file successful */
  964.             FS_Close(fs_handle);
  965.         }
  966.         
  967.     }
  968.     /* check internal resource type */
  969.     if (filename_ptr == NULL)
  970.     {
  971.         res_type = PhnsetGetDisplayType(disp_id);
  972.         if (res_type == PHNSET_TYPE_DISP_IMAGE)
  973.         {
  974.             g_pwron_is_image = TRUE;
  975.             res_type = FMGR_GROUP_IMAGE;
  976.         }
  977.     #if !defined (MMI_ON_WIN32)
  978.         else if (res_type == PHNSET_TYPE_DISP_VIDEO)
  979.         {
  980.             g_pwron_is_image = FALSE;
  981.             res_type = FMGR_GROUP_VIDEO;
  982.         }
  983.     #endif /* !defined (MMI_ON_WIN32) */ 
  984.     #ifdef __MMI_SWFLASH__
  985.         else if (res_type == PHNSET_TYPE_DISP_SWFLASH)
  986.         {
  987.             g_pwron_is_image = TRUE;
  988.             res_type = FMGR_GROUP_SWFLASH;
  989.         }
  990.     #endif /* __MMI_SWFLASH__ */
  991.         else
  992.         {
  993.             MMI_ASSERT(0);
  994.         }
  995.     }
  996. #else /* defined(__MMI_POWER_ON_OFF_DISPLAY__) */ 
  997.     /* play from internal build in resource */
  998.     g_pwron_is_image = TRUE;
  999. #ifdef __MMI_POWER_ON_OFF_DISPLAY__     /* Cylen 0926, customize display char */
  1000.     disp_id = IMG_ID_PHNSET_ON_0;
  1001. #else 
  1002.     disp_id = IMG_ID_PHNSET_ON_ANIMATION_DEFAULT;
  1003. #endif 
  1004.     filename_ptr = NULL;
  1005. #endif /* defined(__MMI_POWER_ON_OFF_DISPLAY__) */ 
  1006.    /*******************************************/
  1007.     /* Start to play                           */
  1008.    /*******************************************/
  1009.     if (res_type == FMGR_GROUP_IMAGE)
  1010.     {
  1011.         /* Play GIF animation or still image */
  1012.         if (ExitCategoryFunction != NULL)
  1013.         {
  1014.             ExitCategoryFunction();
  1015.         }
  1016.         ShowCategory166Screen(disp_id, filename_ptr, mmi_pwron_show_image_callback);
  1017.     #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1018.         if (!IsClamClose())
  1019.         {
  1020.             ShowCategory310Screen(get_string(STR_GLOBAL_LOGO));
  1021.         }
  1022.         else
  1023.     #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1024.             ShowCategory313Screen(IMG_SUBLCD_POWER_ON_SCR, NULL);
  1025.         /* play power on tone */
  1026.         playRequestedTone(POWER_ON_TONE);
  1027. //KP Jerry add for changing the style of message tone list on 2007-4-10 start
  1028. #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
  1029.  gui_start_timer(10000, StopExtPowerOnTone);
  1030. #endif
  1031. //KP Jerry add for changing the style of message tone list on 2007-4-10 end
  1032.     }
  1033.     else if (res_type == FMGR_GROUP_VIDEO)
  1034.     {
  1035.         /* Play video clip */
  1036.     #if defined(__MMI_VIDEO_PLAYER__)
  1037.         /* check silent mode */
  1038.         play_audio = (gcurrentprofile.toneSetup.powerOnTone != POWERON_SILENT) ? TRUE : FALSE;
  1039.         /* set volume as ring tone volume */
  1040.         mdi_audio_set_volume(MDI_VOLUME_MEDIA, GetRingVolumeLevel());
  1041.         /* add sublcd screen in history */
  1042.         /* 
  1043.          * this is when Categry224 play finish, it's sublcd will go back history,
  1044.          * If we go back to root sublcd screen, sometimes it might draw an empty 
  1045.          * screen due to sim or network not ready.
  1046.          * So we have to let it back to a dummy screen, whihc will draw nothing .
  1047.          */
  1048.         sub_history.entryFuncPtr = mmi_pwron_draw_sublcd_dummy_screen;
  1049.         AddSubLCDHistory(&sub_history);
  1050.         /* entry video play screen */
  1051.         ShowCategory224Screen(
  1052.             disp_id,                        /* video id */
  1053.             filename_ptr,                   /* filename */
  1054.             0,                              /* repeat_count *//* 0 means infinite */
  1055.             TRUE,                           /* is_visaul_update */
  1056.             play_audio,                     /* is_play_audio */
  1057.             FALSE,                          /* is_lcd_sleep *//* already in non-sleep mode */
  1058.             GDI_COLOR_BLACK,                /* bg_color */
  1059.             mmi_pwron_play_video_callback,  /* (*play_finish_callback)(S16) */
  1060.             NULL);                          /* gui_buffer */
  1061.     #else /* defined(__MMI_VIDEO_PLAYER__) */ 
  1062.         MMI_ASSERT(0);
  1063.     #endif /* defined(__MMI_VIDEO_PLAYER__) */ 
  1064.     }
  1065. #ifdef __MMI_SWFLASH__
  1066.     else if (res_type == FMGR_GROUP_SWFLASH)
  1067.     {
  1068.         ShowCategory229Screen(
  1069.             0,                      /* title_str */
  1070.             0,            /* title_icon */
  1071.             0,                      /* lsk_str */
  1072.             0,                      /* lsk_icon */
  1073.             0,                    /* rsk_str */
  1074.             0,                    /* rsk_icon */
  1075.             disp_id,                        /* resource_id */
  1076.             filename_ptr,                               /* resource_filename */
  1077.             1,                                  /* repeat_count */
  1078.             MMI_TRUE,                          /* is_play_audio */
  1079.             0,                          /* is_vibrate_on */
  1080.             0,                          /* is_interaction_on */
  1081.             0,                           /* is_lcd_no_sleep */
  1082.             MMI_TRUE,                          /* is_full_screen */
  1083.             GDI_COLOR_WHITE,                    /* bg_color */
  1084.             mmi_pwron_show_image_callback,
  1085.             NULL);
  1086.         
  1087.     }
  1088. #endif
  1089. #if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
  1090.     SetKeyHandler(KeyPatternIdentifier, KEY_POUND, KEY_EVENT_DOWN);
  1091.     SetKeyHandler(KeyPatternIdentifier, KEY_STAR, KEY_EVENT_DOWN);
  1092.     SetKeyHandler(KeyPatternIdentifier, KEY_0, KEY_EVENT_DOWN);
  1093.     SetKeyHandler(KeyPatternIdentifier, KEY_1, KEY_EVENT_DOWN);
  1094.     SetKeyHandler(KeyPatternIdentifier, KEY_2, KEY_EVENT_DOWN);
  1095.     SetKeyHandler(KeyPatternIdentifier, KEY_3, KEY_EVENT_DOWN);
  1096.     SetKeyHandler(KeyPatternIdentifier, KEY_4, KEY_EVENT_DOWN);
  1097.     SetKeyHandler(KeyPatternIdentifier, KEY_5, KEY_EVENT_DOWN);
  1098.     SetKeyHandler(KeyPatternIdentifier, KEY_6, KEY_EVENT_DOWN);
  1099.     SetKeyHandler(KeyPatternIdentifier, KEY_7, KEY_EVENT_DOWN);
  1100.     SetKeyHandler(KeyPatternIdentifier, KEY_8, KEY_EVENT_DOWN);
  1101.     SetKeyHandler(KeyPatternIdentifier, KEY_9, KEY_EVENT_DOWN);
  1102. #endif /* defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__) */ 
  1103.     StartLEDPatternPowerOn();
  1104.     ReplaceNewScreenHandler(SCR_OPEN_SCREEN_ID, mmi_pwron_exit_animation_screen, mmi_pwron_entry_animation_screen);
  1105.     /* this timer is used to avoid gif/video play too long, will force to enter idle */
  1106.     ReadValue(NVRAM_POWER_ON_FORCE_STOP_TIME, &force_stop_time, DS_SHORT, &error);
  1107.     /* not set in NVRAM, use defulat 20 sec limit */
  1108.     if (force_stop_time == 0xffff)
  1109.     {
  1110.         force_stop_time = 20000;
  1111.     }
  1112.     /* POWER ON time have NVRAM-timer interlace problem, so put time at last to eliminate this problem */
  1113.     gui_start_timer(force_stop_time, mmi_pwron_froce_terminate_display);
  1114.     g_pwron_is_terminate_diplay = FALSE;
  1115. }
  1116. /*****************************************************************************
  1117.  * FUNCTION
  1118.  *  mmi_pwron_exception_check_display
  1119.  * DESCRIPTION
  1120.  *  this function is for exception power on to check wether need to restore
  1121.  *  power on diplay to default or not.
  1122.  *  we cant 100% guarantee decoder will work for all image/video from file, we
  1123.  *  use this method to restore back if decoder has assert or fatal error.
  1124.  * PARAMETERS
  1125.  *  void
  1126.  * RETURNS
  1127.  *  void
  1128.  *****************************************************************************/
  1129. void mmi_pwron_exception_check_display(void)
  1130. {
  1131.     /*----------------------------------------------------------------*/
  1132.     /* Local Variables                                                */
  1133.     /*----------------------------------------------------------------*/
  1134.     S16 error;
  1135.     U16 pwron_flag;
  1136.     /*----------------------------------------------------------------*/
  1137.     /* Code Body                                                      */
  1138.     /*----------------------------------------------------------------*/
  1139.     /* Valid power on display restoration checking */
  1140.     ReadValue(NVRAM_POWER_ON_DISPLAY_SUCCESS, &pwron_flag, DS_SHORT, &error);
  1141.     /* this means exception happened during previous decoding process */
  1142.     if (pwron_flag == PWRON_DISPLAY_PLAYING)
  1143.     {
  1144.     #if defined(__MMI_POWER_ON_OFF_DISPLAY__)
  1145.         PhnsetRstPwrOnDisplayDefault();
  1146.     #endif 
  1147.     }
  1148. }
  1149. /*****************************************************************************
  1150.  * FUNCTION
  1151.  *  mmi_pwron_exit_animation_screen
  1152.  * DESCRIPTION
  1153.  *  exit power on animation screen
  1154.  * PARAMETERS
  1155.  *  void
  1156.  * RETURNS
  1157.  *  void
  1158.  *****************************************************************************/
  1159. void mmi_pwron_exit_animation_screen(void)
  1160. {
  1161.     /*----------------------------------------------------------------*/
  1162.     /* Local Variables                                                */
  1163.     /*----------------------------------------------------------------*/
  1164.     U16 pwron_flag;
  1165.     S16 error;
  1166.     /*----------------------------------------------------------------*/
  1167.     /* Code Body                                                      */
  1168.     /*----------------------------------------------------------------*/
  1169.     MMI_TRACE((MMI_TRACE_G7_MISC, MMI_POWER_ON_LEAVE_ANIMATION));
  1170.     TurnOffBacklight(); /* To start backlight timer */
  1171.     ExitSubLCDIdleScr();    /* Add idle screen to sub-lcd history if power on animation is interrupted */
  1172.     /* if is force stopped by MT call, treat this recource as play successfully */
  1173.     if (GetActiveScreenId() == ITEMSCR_INCOMING_CALL)
  1174.     {
  1175.         pwron_flag = PWRON_DISPLAY_SUCCESS;
  1176.         WriteValue(NVRAM_POWER_ON_DISPLAY_SUCCESS, &pwron_flag, DS_SHORT, &error);
  1177.     }
  1178.     gui_cancel_timer(mmi_pwron_froce_terminate_display);
  1179. }
  1180. /***************************************************************************
  1181. *
  1182. *  Analog Clock
  1183. *
  1184. ***************************************************************************/
  1185. /* Analog clock implementation: Must be moved to a different file later */
  1186. #define ANALOG_CLOCK_DRAW_POLYGON_HANDS      1
  1187. #define ANALOG_CLOCK_SMOOTHEN_LINES          1
  1188. /* PMT HIMANSHU START 20050625 */
  1189. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  1190. /* PMT HIMANSHU START 20050721 */
  1191. #if defined(__MMI_MAINLCD_176X220__)
  1192. /* PMT HIMANSHU END 20050721 */
  1193. #define ANALOG_CLOCK_HOURS_HAND_LENGTH       12
  1194. #define ANALOG_CLOCK_MINUTES_HAND_LENGTH     16
  1195. /* PMT HIMANSHU START 20050721 */
  1196. #elif defined(__MMI_MAINLCD_240X320__)
  1197. #define ANALOG_CLOCK_HOURS_HAND_LENGTH       15
  1198. #define ANALOG_CLOCK_MINUTES_HAND_LENGTH     20
  1199. #endif 
  1200. /* PMT HIMANSHU END 20050721 */
  1201. #else /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1202. #define ANALOG_CLOCK_HOURS_HAND_LENGTH       (MAIN_LCD_DEVICE_HEIGHT/6) /* 20 */
  1203. #define ANALOG_CLOCK_MINUTES_HAND_LENGTH     (ANALOG_CLOCK_HOURS_HAND_LENGTH+8) /* 28 */
  1204. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1205. /* PMT HIMANSHU END */
  1206. #define ANALOG_CLOCK_SECONDS_HAND_LENGTH     (ANALOG_CLOCK_HOURS_HAND_LENGTH+12)        /* 32 */
  1207. /* PMT HIMANSHU START 20050721 */
  1208. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  1209. #define ANALOG_CLOCK_HOURS_HAND_COLOR  {  255,255,255,100      }
  1210. #define ANALOG_CLOCK_MINUTES_HAND_COLOR   {  255,255,255,100      }
  1211. #define ANALOG_CLOCK_SECONDS_HAND_COLOR   {  255,255,255,100      }
  1212. #else /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1213. #if defined(__MMI_SUBLCD_COLOR__)
  1214. #define ANALOG_CLOCK_HOURS_HAND_COLOR     {  0,0,93,100     }
  1215. #define ANALOG_CLOCK_MINUTES_HAND_COLOR   {  0,0,93,100     }
  1216. #define ANALOG_CLOCK_SECONDS_HAND_COLOR   {  255,0,0,100    }
  1217. #else /* defined(__MMI_SUBLCD_COLOR__) */ 
  1218. #define ANALOG_CLOCK_HOURS_HAND_COLOR     {  0,0,0,100      }
  1219. #define ANALOG_CLOCK_MINUTES_HAND_COLOR   {  0,0,0,100      }
  1220. #define ANALOG_CLOCK_SECONDS_HAND_COLOR   {  0,0,0,100      }
  1221. #endif /* defined(__MMI_SUBLCD_COLOR__) */ 
  1222. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1223. /* PMT HIMANSHU END 20050721 */
  1224. /*
  1225.  * Moved to MiscFunctions.h
  1226.  * #define ANALOG_CLOCK_DIAL_WIDTH              77
  1227.  * #define ANALOG_CLOCK_DIAL_HEIGHT          77
  1228.  */
  1229. S32 ANALOG_CLOCK_DIAL_X = 26;
  1230. S32 ANALOG_CLOCK_DIAL_Y = 26;
  1231. S32 ANALOG_CLOCK_CENTER_X = 64;
  1232. S32 ANALOG_CLOCK_CENTER_Y = 64;
  1233. #define ANALOG_CLOCK_DRAW_POLYGON_HANDS         1
  1234. #define ANALOG_CLOCK_SMOOTHEN_LINES             1
  1235. #define SUB_ANALOG_CLOCK_HOURS_HAND_LENGTH      (SUB_LCD_DEVICE_WIDTH/4)
  1236. #define SUB_ANALOG_CLOCK_MINUTES_HAND_LENGTH    (SUB_ANALOG_CLOCK_HOURS_HAND_LENGTH+4)
  1237. #define SUB_ANALOG_CLOCK_SECONDS_HAND_LENGTH    (SUB_ANALOG_CLOCK_HOURS_HAND_LENGTH+6)
  1238. #define SUB_ANALOG_CLOCK_DIAL_WIDTH             SUB_LCD_DEVICE_WIDTH
  1239. #define SUB_ANALOG_CLOCK_DIAL_HEIGHT            SUB_LCD_DEVICE_HEIGHT
  1240. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1241. S32 SUB_ANALOG_CLOCK_DIAL_X = 2;
  1242. S32 SUB_ANALOG_CLOCK_DIAL_Y = 2;
  1243. S32 SUB_ANALOG_CLOCK_CENTER_X = SUB_LCD_DEVICE_WIDTH >> 1;
  1244. S32 SUB_ANALOG_CLOCK_CENTER_Y = SUB_LCD_DEVICE_HEIGHT >> 1;
  1245. #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1246. PU8 analog_clock_background_image = NULL;
  1247. const float acm_sine_table[] = 
  1248. {
  1249.     (float)-0.99999820, (float)-0.99431727, (float)-0.97773360, (float)-0.95042917, (float)-0.91270313,
  1250.         (float)-0.86496924, (float)-0.80775119, (float)-0.74167587,
  1251.     (float)-0.66746803, (float)-0.58594175, (float)-0.49799022, (float)-0.40457821, (float)-0.30673042,
  1252.         (float)-0.20551889, (float)-0.10205382, (float)0.00000000,
  1253.     (float)0.10457040, (float)0.20799418, (float)0.30913729, (float)0.40689072, (float)0.50018258, (float)0.58798990,
  1254.         (float)0.66934994, (float)0.74337050,
  1255.     (float)0.80923998, (float)0.86623616, (float)0.91373403, (float)0.95121274, (float)0.97826142, (float)0.99458343,
  1256.         (float)0.99999980, (float)0.99445115,
  1257.     (float)0.97799831, (float)0.95082172, (float)0.91321931, (float)0.86560342, (float)0.80849624, (float)0.74252372,
  1258.         (float)0.66840956, (float)0.58696629,
  1259.     (float)0.49908672, (float)0.40573486, (float)0.30793410, (float)0.20675662, (float)0.10331227, (float)-0.00126490,
  1260.         (float)-0.10582843, (float)-0.20923132,
  1261.     (float)-0.31033998, (float)-0.40804598, (float)-0.50127753, (float)-0.58901256, (float)-0.67028925,
  1262.         (float)-0.74421601, (float)-0.80998244, (float)-0.86686752,
  1263.     (float)-0.91424734, (float)-0.95160225, (float)-0.97852297, (float)-0.99471414,
  1264. };
  1265. const float acm_cosine_table[] = 
  1266. {
  1267.     (float)0.00189735, (float)0.10645731, (float)0.20984996, (float)0.31094114, (float)0.40862330, (float)0.50182489,
  1268.         (float)0.58952354, (float)0.67075845,
  1269.     (float)0.74463846, (float)0.81035318, (float)0.86718264, (float)0.91450340, (float)0.95179643, (float)0.97865315,
  1270.         (float)0.99477888, (float)1.00000000,
  1271.     (float)0.99451749, (float)0.97813006, (float)0.95101742, (float)0.91347684, (float)0.86591997, (float)0.80886827,
  1272.         (float)0.74294728, (float)0.66887989,
  1273.     (float)0.58747821, (float)0.49963478, (float)0.40631283, (float)0.30853576, (float)0.20737548, (float)0.10394131,
  1274.         (float)-0.00063245, (float)-0.10519940,
  1275.     (float)-0.20861283, (float)-0.30973870, (float)-0.40746839, (float)-0.50073018, (float)-0.58850135,
  1276.         (float)-0.66981977, (float)-0.74379342, (float)-0.80961137,
  1277.     (float)-0.86655204, (float)-0.91399082, (float)-0.95140769, (float)-0.97839241, (float)-0.99464897,
  1278.         (float)-0.99999920, (float)-0.99438440, (float)-0.97786617,
  1279.     (float)-0.95062563, (float)-0.91296138, (float)-0.86528656, (float)-0.80812388, (float)-0.74209994,
  1280.         (float)-0.66793902, (float)-0.58645414, (float)-0.49853857,
  1281.     (float)-0.40515651, (float)-0.30733233, (float)-0.20613779, (float)-0.10268295,
  1282. };
  1283. #if(ANALOG_CLOCK_DRAW_POLYGON_HANDS)
  1284. const U8 analog_clock_center_dot_image[] = 
  1285. {
  1286.     0x04, 0x00, 0x8D, 0x00, 0x00, 0x00,
  1287.     0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0C, 0x10, 0x00, 0x00, 0x00,
  1288.     0x34, 0x12, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x34, 0x12,
  1289.     0x34, 0x12, 0x00, 0x00, 0x04, 0x30, 0x05, 0xF7, 0x05, 0xF7, 0x04, 0x30, 0x00, 0x00, 0x34, 0x12,
  1290.     0x00, 0x00, 0x04, 0x30, 0xFF, 0xFF, 0x05, 0xF7, 0x05, 0xF7, 0x05, 0xF7, 0x04, 0x30, 0x00, 0x00,
  1291.     0x00, 0x00, 0x04, 0x30, 0xFF, 0xFF, 0x05, 0xF7, 0x05, 0xF7, 0x05, 0xF7, 0x04, 0x30, 0x00, 0x00,
  1292.     0x00, 0x00, 0x04, 0x30, 0x05, 0xF7, 0x05, 0xF7, 0x05, 0xF7, 0x05, 0xF7, 0x04, 0x30, 0x00, 0x00,
  1293.     0x00, 0x00, 0x04, 0x30, 0x04, 0x30, 0x05, 0xF7, 0x05, 0xF7, 0x04, 0x30, 0x04, 0x30, 0x00, 0x00,
  1294.     0x34, 0x12, 0x00, 0x00, 0x04, 0x30, 0x04, 0x30, 0x04, 0x30, 0x04, 0x30, 0x00, 0x00, 0x34, 0x12,
  1295.     0x34, 0x12, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x34, 0x12,
  1296. };
  1297. extern void flat_triangle_fill(polygon_vertex vertices[], color c);
  1298. void polygon_draw(polygon_vertex vertices[], S32 n_vertices, color c);
  1299. #elif(ANALOG_CLOCK_SMOOTHEN_LINES)
  1300. extern void UI_antialiased_line(S32 x1, S32 y1, S32 x2, S32 y2, color c);
  1301. #endif 
  1302. /* PMT HIMANSHU START 20050625 */
  1303. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  1304. /* PMT HIMANSHU START 20050721 */
  1305. #if defined(__MMI_MAINLCD_176X220__)
  1306. /* PMT HIMANSHU END 20050721 */
  1307. /* offset to (0,0)   */
  1308. polygon_vertex analog_clock_hour_hand_vertices[] = { {-0, 0},
  1309. {+0, 0},
  1310. {0, -ANALOG_CLOCK_HOURS_HAND_LENGTH},
  1311. };
  1312. /* offset to (0,0)   */
  1313. polygon_vertex analog_clock_minute_hand_vertices[] = { {-0, 0},
  1314. {+0, 0},
  1315. {0, -ANALOG_CLOCK_MINUTES_HAND_LENGTH},
  1316. };
  1317. /* PMT HIMANSHU START 20050721 */
  1318. #elif defined(__MMI_MAINLCD_240X320__)
  1319. /* offset to (0,0)   */
  1320. polygon_vertex analog_clock_hour_hand_vertices[] = { {-2, 0},
  1321. {+2, 0},
  1322. {0, -ANALOG_CLOCK_HOURS_HAND_LENGTH},
  1323. };
  1324. /* offset to (0,0)   */
  1325. polygon_vertex analog_clock_minute_hand_vertices[] = { {-1, 0},
  1326. {+1, 0},
  1327. {0, -ANALOG_CLOCK_MINUTES_HAND_LENGTH},
  1328. };
  1329. #endif 
  1330. /* PMT HIMANSHU END 20050721 */
  1331. #else /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1332. /* PMT HIMANSHU END */
  1333. /* offset to (0,0)   */
  1334. polygon_vertex analog_clock_hour_hand_vertices[] = 
  1335. {
  1336.     {-3, 0},
  1337.     {+3, 0},
  1338.     {0, -ANALOG_CLOCK_HOURS_HAND_LENGTH},
  1339. };
  1340. /* offset to (0,0)   */
  1341. polygon_vertex analog_clock_minute_hand_vertices[] = 
  1342. {
  1343.     {-2, 0},
  1344.     {+2, 0},
  1345.     {0, -ANALOG_CLOCK_MINUTES_HAND_LENGTH},
  1346. };
  1347. /* PMT HIMANSHU START 20050625 */
  1348. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1349. /* PMT HIMANSHU END */
  1350. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1351. /* offset to (0,0)   */
  1352. polygon_vertex sub_analog_clock_hour_hand_vertices[] = 
  1353. {
  1354.     {-2, +1},
  1355.     {+2, +1},
  1356.     {0, -SUB_ANALOG_CLOCK_HOURS_HAND_LENGTH},
  1357. };
  1358. /* offset to (0,0)   */
  1359. polygon_vertex sub_analog_clock_minute_hand_vertices[] = 
  1360. {
  1361.     {-2, 0},
  1362.     {+2, 0},
  1363.     {0, -SUB_ANALOG_CLOCK_MINUTES_HAND_LENGTH},
  1364. };
  1365. #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1366. /* Rotate about (0,0)   */
  1367. /*****************************************************************************
  1368.  * FUNCTION
  1369.  *  rotate_analog_clock_hand
  1370.  * DESCRIPTION
  1371.  *  
  1372.  * PARAMETERS
  1373.  *  vertices        [?]         
  1374.  *  minute          [IN]        
  1375.  * RETURNS
  1376.  *  void
  1377.  *****************************************************************************/
  1378. void rotate_analog_clock_hand(polygon_vertex vertices[], S32 minute)
  1379. {
  1380.     /*----------------------------------------------------------------*/
  1381.     /* Local Variables                                                */
  1382.     /*----------------------------------------------------------------*/
  1383.     float cosa, sina, x, y;
  1384.     /*----------------------------------------------------------------*/
  1385.     /* Code Body                                                      */
  1386.     /*----------------------------------------------------------------*/
  1387.     minute += 15;
  1388.     if (minute >= 60)
  1389.     {
  1390.         minute = minute - 60;
  1391.     }
  1392.     cosa = (float)acm_cosine_table[minute];
  1393.     sina = (float)acm_sine_table[minute];
  1394.     x = (float)vertices[0].x;
  1395.     y = (float)vertices[0].y;
  1396.     vertices[0].x = (S32) (x * cosa - y * sina);
  1397.     vertices[0].y = (S32) (x * sina + y * cosa);
  1398.     x = (float)vertices[1].x;
  1399.     y = (float)vertices[1].y;
  1400.     vertices[1].x = (S32) (x * cosa - y * sina);
  1401.     vertices[1].y = (S32) (x * sina + y * cosa);
  1402.     x = (float)vertices[2].x;
  1403.     y = (float)vertices[2].y;
  1404.     vertices[2].x = (S32) (x * cosa - y * sina);
  1405.     vertices[2].y = (S32) (x * sina + y * cosa);
  1406. }
  1407. /*****************************************************************************
  1408.  * FUNCTION
  1409.  *  analog_clock_draw_hand
  1410.  * DESCRIPTION
  1411.  *  
  1412.  * PARAMETERS
  1413.  *  type        [IN]        
  1414.  *  minute      [IN]        
  1415.  * RETURNS
  1416.  *  void
  1417.  *****************************************************************************/
  1418. void analog_clock_draw_hand(S32 type, S32 minute)
  1419. {
  1420.     /*----------------------------------------------------------------*/
  1421.     /* Local Variables                                                */
  1422.     /*----------------------------------------------------------------*/
  1423.     S32 radius;
  1424.     S32 x1 = ANALOG_CLOCK_CENTER_X;
  1425.     S32 y1 = ANALOG_CLOCK_CENTER_Y;
  1426.     S32 x2, y2;
  1427. #if(ANALOG_CLOCK_DRAW_POLYGON_HANDS)
  1428.     polygon_vertex vertices[3];
  1429. #endif 
  1430.     /*----------------------------------------------------------------*/
  1431.     /* Code Body                                                      */
  1432.     /*----------------------------------------------------------------*/
  1433. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1434.     if (GDI_LCD->act_handle == GDI_LCD_SUB_LCD_HANDLE)
  1435.     {
  1436.         x1 = SUB_ANALOG_CLOCK_CENTER_X;
  1437.         y1 = SUB_ANALOG_CLOCK_CENTER_Y;
  1438.         radius = SUB_ANALOG_CLOCK_HOURS_HAND_LENGTH;
  1439.     }
  1440.     else
  1441. #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1442.     {
  1443.         x1 = ANALOG_CLOCK_CENTER_X;
  1444.         y1 = ANALOG_CLOCK_CENTER_Y;
  1445.         radius = ANALOG_CLOCK_HOURS_HAND_LENGTH;
  1446.     }
  1447.     switch (type)
  1448.     {
  1449.         case 0:
  1450.         {
  1451.             color c = ANALOG_CLOCK_HOURS_HAND_COLOR;
  1452.         #if(ANALOG_CLOCK_DRAW_POLYGON_HANDS)
  1453.         #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1454.             if (GDI_LCD->act_handle == GDI_LCD_SUB_LCD_HANDLE)
  1455.             {
  1456.                 vertices[0] = sub_analog_clock_hour_hand_vertices[0];
  1457.                 vertices[1] = sub_analog_clock_hour_hand_vertices[1];
  1458.                 vertices[2] = sub_analog_clock_hour_hand_vertices[2];
  1459.             }
  1460.             else
  1461.         #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1462.             {
  1463.                 vertices[0] = analog_clock_hour_hand_vertices[0];
  1464.                 vertices[1] = analog_clock_hour_hand_vertices[1];
  1465.                 vertices[2] = analog_clock_hour_hand_vertices[2];
  1466.             }
  1467.             rotate_analog_clock_hand(vertices, minute);
  1468.             vertices[0].x += x1;
  1469.             vertices[0].y += y1;
  1470.             vertices[1].x += x1;
  1471.             vertices[1].y += y1;
  1472.             vertices[2].x += x1;
  1473.             vertices[2].y += y1;
  1474.             flat_triangle_fill(vertices, c);
  1475.             polygon_draw(vertices, 3, c);
  1476.         #elif(ANALOG_CLOCK_SMOOTHEN_LINES)
  1477.             x2 = x1 + (S32) ((float)radius * acm_cosine_table[minute]);
  1478.             y2 = y1 + (S32) ((float)radius * acm_sine_table[minute]);
  1479.             UI_antialiased_line(x1, y1, x2, y2, c);
  1480.             UI_antialiased_line(x1 + 1, y1 + 1, x2 + 1, y2 + 1, c);
  1481.         #else 
  1482.             x2 = x1 + (S32) ((float)radius * acm_cosine_table[minute]);
  1483.             y2 = y1 + (S32) ((float)radius * acm_sine_table[minute]);
  1484.             gui_wline(x1, y1, x2, y2, c, 3);
  1485.         #endif 
  1486.         }
  1487.             break;
  1488.         case 1:
  1489.         {
  1490.             color c = ANALOG_CLOCK_MINUTES_HAND_COLOR;
  1491.         #if(ANALOG_CLOCK_DRAW_POLYGON_HANDS)
  1492.         #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1493.             if (GDI_LCD->act_handle == GDI_LCD_SUB_LCD_HANDLE)
  1494.             {
  1495.                 vertices[0] = sub_analog_clock_minute_hand_vertices[0];
  1496.                 vertices[1] = sub_analog_clock_minute_hand_vertices[1];
  1497.                 vertices[2] = sub_analog_clock_minute_hand_vertices[2];
  1498.             }
  1499.             else
  1500.         #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1501.             {
  1502.                 vertices[0] = analog_clock_minute_hand_vertices[0];
  1503.                 vertices[1] = analog_clock_minute_hand_vertices[1];
  1504.                 vertices[2] = analog_clock_minute_hand_vertices[2];
  1505.             }
  1506.             rotate_analog_clock_hand(vertices, minute);
  1507.             vertices[0].x += x1;
  1508.             vertices[0].y += y1;
  1509.             vertices[1].x += x1;
  1510.             vertices[1].y += y1;
  1511.             vertices[2].x += x1;
  1512.             vertices[2].y += y1;
  1513.             flat_triangle_fill(vertices, c);
  1514.             polygon_draw(vertices, 3, c);
  1515.         #elif(ANALOG_CLOCK_SMOOTHEN_LINES)
  1516.             x2 = x1 + (S32) ((float)radius * acm_cosine_table[minute]);
  1517.             y2 = y1 + (S32) ((float)radius * acm_sine_table[minute]);
  1518.             UI_antialiased_line(x1, y1, x2, y2, c);
  1519.         #else 
  1520.             x2 = x1 + (S32) ((float)radius * acm_cosine_table[minute]);
  1521.             y2 = y1 + (S32) ((float)radius * acm_sine_table[minute]);
  1522.             gui_wline(x1, y1, x2, y2, c, 1);
  1523.         #endif 
  1524.         }
  1525.             break;
  1526.         case 2:
  1527.         {
  1528.             color c = ANALOG_CLOCK_SECONDS_HAND_COLOR;
  1529.         #if(ANALOG_CLOCK_DRAW_POLYGON_HANDS)
  1530.             x2 = x1 + (S32) ((float)radius * acm_cosine_table[minute]);
  1531.             y2 = y1 + (S32) ((float)radius * acm_sine_table[minute]);
  1532.             gui_line(x1, y1, x2, y2, c);
  1533.         #elif(ANALOG_CLOCK_SMOOTHEN_LINES)
  1534.             x2 = x1 + (S32) ((float)radius * acm_cosine_table[minute]);
  1535.             y2 = y1 + (S32) ((float)radius * acm_sine_table[minute]);
  1536.             UI_antialiased_line(x1, y1, x2, y2, c);
  1537.         #else 
  1538.             x2 = x1 + (S32) ((float)radius * acm_cosine_table[minute]);
  1539.             y2 = y1 + (S32) ((float)radius * acm_sine_table[minute]);
  1540.             gui_line(x1, y1, x2, y2, c);
  1541.         #endif 
  1542.         }
  1543.             break;
  1544.     }
  1545. }
  1546. S32 analog_clock_hours_hand_counter = 0;
  1547. S32 analog_clock_minutes_hand_counter = 0;
  1548. /*****************************************************************************
  1549.  * FUNCTION
  1550.  *  show_analog_clock_dial
  1551.  * DESCRIPTION
  1552.  *  
  1553.  * PARAMETERS
  1554.  *  void
  1555.  * RETURNS
  1556.  *  void
  1557.  *****************************************************************************/
  1558. void show_analog_clock_dial(void)
  1559. {   /* For removing warning
  1560.        S32   x1=ANALOG_CLOCK_DIAL_X;
  1561.        S32 y1=ANALOG_CLOCK_DIAL_Y;
  1562.        S32   x2=ANALOG_CLOCK_DIAL_X+ANALOG_CLOCK_DIAL_WIDTH-1;
  1563.        S32 y2=ANALOG_CLOCK_DIAL_Y+ANALOG_CLOCK_DIAL_HEIGHT-1; */
  1564.     /*----------------------------------------------------------------*/
  1565.     /* Local Variables                                                */
  1566.     /*----------------------------------------------------------------*/
  1567.     /*----------------------------------------------------------------*/
  1568.     /* Code Body                                                      */
  1569.     /*----------------------------------------------------------------*/
  1570.     /* PMT HIMANSHU START 20050625 */
  1571. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  1572.     gui_push_clip();
  1573.     gui_set_clip(
  1574.         ANALOG_BACKGROUND_X,
  1575.         ANALOG_BACKGROUND_Y,
  1576.         ANALOG_BACKGROUND_X + ANALOG_BACKGROUND_WIDTH - 1,
  1577.         ANALOG_BACKGROUND_Y + MMI_IDLESCREEN_BAR_HEIGHT - 1);
  1578.     //gui_show_image((ANALOG_CLOCK_DIAL_X), (ANALOG_CLOCK_DIAL_Y), get_image(IMG_TECHNO_ANALOG_CLOCK));
  1579.     gui_show_image((ANALOG_BACKGROUND_X), (ANALOG_BACKGROUND_Y), get_image(IMG_TECHNO_ANALOG_CLOCK));     //Old:gui_show_image(0, (ANALOG_BACKGROUND_Y), get_image(IMG_TECHNO_ANALOG_CLOCK));    //KP Jerry modify on 2007-3-8
  1580. #else /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1581.     gui_reset_clip();
  1582. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1583.     /* PMT HIMANSHU END */
  1584. #if(ANALOG_CLOCK_DRAW_POLYGON_HANDS)
  1585.     if (GDI_LCD->act_handle == GDI_LCD_MAIN_LCD_HANDLE)
  1586.         /* PMT HIMANSHU START 20050625 */
  1587. #ifndef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  1588.         gui_show_transparent_image(
  1589.             ANALOG_CLOCK_CENTER_X - 4,
  1590.             ANALOG_CLOCK_CENTER_Y - 4,
  1591.             (U8*) analog_clock_center_dot_image,
  1592.             0);
  1593. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1594.     /* PMT HIMANSHU END */
  1595. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1596.     else
  1597. #if defined(__MMI_SUBLCD_COLOR__)
  1598.         gui_show_transparent_image(
  1599.             SUB_ANALOG_CLOCK_CENTER_X - 4,
  1600.             SUB_ANALOG_CLOCK_CENTER_Y - 4,
  1601.             (U8*) analog_clock_center_dot_image,
  1602.             0);
  1603. #else /* defined(__MMI_SUBLCD_COLOR__) */ 
  1604.         gdi_draw_round_rect(
  1605.             SUB_ANALOG_CLOCK_CENTER_X - 3,
  1606.             SUB_ANALOG_CLOCK_CENTER_Y - 3,
  1607.             SUB_ANALOG_CLOCK_CENTER_X + 3,
  1608.             SUB_ANALOG_CLOCK_CENTER_Y + 3,
  1609.             GDI_COLOR_BLACK,
  1610.             GDI_COLOR_BLACK,
  1611.             2);
  1612. #endif /* defined(__MMI_SUBLCD_COLOR__) */ 
  1613. #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1614. #endif /* (ANALOG_CLOCK_DRAW_POLYGON_HANDS) */ 
  1615.     analog_clock_draw_hand(0, analog_clock_hours_hand_counter);
  1616.     analog_clock_draw_hand(1, analog_clock_minutes_hand_counter);
  1617.     /* PMT HIMANSHU START 20050625 */
  1618. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  1619.     gui_pop_clip();
  1620. #endif 
  1621.     /* PMT HIMANSHU END */
  1622. #if 0
  1623. /* under construction !*/
  1624. #endif /* 0 */ 
  1625. }
  1626. /*****************************************************************************
  1627.  * FUNCTION
  1628.  *  show_analog_clock
  1629.  * DESCRIPTION
  1630.  *  
  1631.  * PARAMETERS
  1632.  *  void
  1633.  * RETURNS
  1634.  *  void
  1635.  *****************************************************************************/
  1636. void show_analog_clock(void)
  1637. {
  1638.     /*----------------------------------------------------------------*/
  1639.     /* Local Variables                                                */
  1640.     /*----------------------------------------------------------------*/
  1641.     /*----------------------------------------------------------------*/
  1642.     /* Code Body                                                      */
  1643.     /*----------------------------------------------------------------*/
  1644.     show_analog_clock_dial();
  1645. }
  1646. /*****************************************************************************
  1647.  * FUNCTION
  1648.  *  analog_clock_initialize
  1649.  * DESCRIPTION
  1650.  *  
  1651.  * PARAMETERS
  1652.  *  void
  1653.  * RETURNS
  1654.  *  void
  1655.  *****************************************************************************/
  1656. void analog_clock_initialize(void)
  1657. {
  1658.     /*----------------------------------------------------------------*/
  1659.     /* Local Variables                                                */
  1660.     /*----------------------------------------------------------------*/
  1661.     MYTIME t;
  1662.     S32 h, m;
  1663.     /*----------------------------------------------------------------*/
  1664.     /* Code Body                                                      */
  1665.     /*----------------------------------------------------------------*/
  1666.     /* PMT HIMANSHU START 20050625 */
  1667. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  1668.     ANALOG_CLOCK_CENTER_X = (MMI_SIGNAL_WIDTH + (ANALOG_BACKGROUND_WIDTH >> 1));
  1669.     ANALOG_CLOCK_DIAL_X = (MMI_SIGNAL_WIDTH);
  1670.     ANALOG_CLOCK_CENTER_Y = (MMI_status_bar_height + (MMI_IDLESCREEN_BAR_HEIGHT >> 1));
  1671.     ANALOG_CLOCK_DIAL_Y = (MMI_status_bar_height);
  1672. #else /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1673.     ANALOG_CLOCK_DIAL_X = (UI_device_width >> 1) - (ANALOG_CLOCK_DIAL_WIDTH >> 1);
  1674.     ANALOG_CLOCK_DIAL_Y = (UI_device_height >> 1) - (ANALOG_CLOCK_DIAL_HEIGHT >> 1);
  1675.     ANALOG_CLOCK_CENTER_X = (UI_device_width >> 1);
  1676.     ANALOG_CLOCK_CENTER_Y = (UI_device_height >> 1);
  1677. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  1678.     /* PMT HIMANSHU END */
  1679.     GetDateTime(&t);
  1680.     m = t.nMin;
  1681.     analog_clock_minutes_hand_counter = m;
  1682.     h = t.nHour;
  1683.     h++;
  1684.     if (h > 12)
  1685.     {
  1686.         h -= 12;
  1687.     }
  1688.     analog_clock_hours_hand_counter = (h - 1) * 5;
  1689.     analog_clock_hours_hand_counter += m / 12;
  1690. }
  1691. /*****************************************************************************
  1692.  * FUNCTION
  1693.  *  analog_clock_minute_tick
  1694.  * DESCRIPTION
  1695.  *  
  1696.  * PARAMETERS
  1697.  *  void
  1698.  * RETURNS
  1699.  *  void
  1700.  *****************************************************************************/
  1701. void analog_clock_minute_tick(void)
  1702. {
  1703.     /*----------------------------------------------------------------*/
  1704.     /* Local Variables                                                */
  1705.     /*----------------------------------------------------------------*/
  1706.     MYTIME t;
  1707.     S32 h, m;
  1708.     /*----------------------------------------------------------------*/
  1709.     /* Code Body                                                      */
  1710.     /*----------------------------------------------------------------*/
  1711.     GetDateTime(&t);
  1712.     m = t.nMin;
  1713.     analog_clock_minutes_hand_counter = m;
  1714.     h = t.nHour;
  1715.     h++;
  1716.     if (h > 12)
  1717.     {
  1718.         h -= 12;
  1719.     }
  1720.     analog_clock_hours_hand_counter = (h - 1) * 5;
  1721.     analog_clock_hours_hand_counter += m / 12;
  1722.     if (analog_clock_minutes_hand_counter >= 60)
  1723.     {
  1724.         analog_clock_minutes_hand_counter = 0;
  1725.     }
  1726.     if ((analog_clock_minutes_hand_counter % 12) == 0)
  1727.     {   /* analog_clock_hours_hand_counter++; */
  1728.         if (analog_clock_hours_hand_counter >= 60)
  1729.         {
  1730.             analog_clock_hours_hand_counter = 0;
  1731.         }
  1732.     }
  1733. }
  1734. /*****************************************************************************
  1735.  * FUNCTION
  1736.  *  analog_clock_demo_timer
  1737.  * DESCRIPTION
  1738.  *  
  1739.  * PARAMETERS
  1740.  *  void
  1741.  * RETURNS
  1742.  *  void
  1743.  *****************************************************************************/
  1744. void analog_clock_demo_timer(void)
  1745. {
  1746.     /*----------------------------------------------------------------*/
  1747.     /* Local Variables                                                */
  1748.     /*----------------------------------------------------------------*/
  1749.     color c = gui_color(255, 255, 255);
  1750.     /*----------------------------------------------------------------*/
  1751.     /* Code Body                                                      */
  1752.     /*----------------------------------------------------------------*/
  1753.     analog_clock_minutes_hand_counter++;
  1754.     if (analog_clock_minutes_hand_counter >= 60)
  1755.     {
  1756.         analog_clock_minutes_hand_counter = 0;
  1757.     }
  1758.     if ((analog_clock_minutes_hand_counter % 12) == 0)
  1759.     {
  1760.         analog_clock_hours_hand_counter++;
  1761.         if (analog_clock_hours_hand_counter >= 60)
  1762.         {
  1763.             analog_clock_hours_hand_counter = 0;
  1764.         }
  1765.     }
  1766.     gui_reset_clip();
  1767.     gui_fill_rectangle(0, 0, UI_device_width - 1, UI_device_height - 1, c);
  1768.     show_analog_clock_dial();
  1769. #if(UI_DOUBLE_BUFFER_SUPPORT)
  1770.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  1771. #endif 
  1772.     gui_start_timer(200, analog_clock_demo_timer);
  1773. }
  1774. extern void PB_test_demo(void);
  1775. /*****************************************************************************
  1776.  * FUNCTION
  1777.  *  initialize_UI_demo
  1778.  * DESCRIPTION
  1779.  *  Initialize UI environment
  1780.  *
  1781.  *  Remark: this function may be executed more than one times for special poweron
  1782.  *          mode (e.g. Alarm poweron, Charger poweron, USB poweron)
  1783.  * PARAMETERS
  1784.  *  void
  1785.  * RETURNS
  1786.  *  void
  1787.  *****************************************************************************/
  1788. void initialize_UI_demo(void)
  1789. {
  1790.     /*----------------------------------------------------------------*/
  1791.     /* Local Variables                                                */
  1792.     /*----------------------------------------------------------------*/
  1793.     /*----------------------------------------------------------------*/
  1794.     /* Code Body                                                      */
  1795.     /*----------------------------------------------------------------*/
  1796.     mmi_frm_appmem_init();
  1797.     mmi_frm_scrmem_init();
  1798.     dm_init();
  1799.     wgui_init();
  1800.     initialize_category_screens();
  1801. #if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
  1802.     /*
  1803.      * We do not enable touch screen in certain cases like charger poweron 
  1804.      * * because some related tasks are not running.
  1805.      */
  1806.     if (g_pwr_context.PowerOnMode == POWER_ON_KEYPAD || g_pwr_context.PowerOnMode == POWER_ON_EXCEPTION ||
  1807. #if defined(__NVRAM_IN_USB_MS__)        /* for alarm in usb boot mode */
  1808.         g_pwr_context.PowerOnMode == POWER_ON_USB ||
  1809. #endif 
  1810.         g_pwr_context.PowerOnMode == POWER_ON_ALARM || g_pwr_context.PowerOnMode == POWER_ON_CHARGER_IN)
  1811.     {
  1812.         mmi_pen_init();
  1813.         mmi_pen_enable();
  1814.     }
  1815. #endif /* defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__) */ 
  1816.     /* Temporary: Must be moved to boot up application */
  1817.     ShowStatusIcon(STATUS_ICON_SIGNAL_STRENGTH);
  1818.     ShowStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1819.     ShowStatusIcon(STATUS_ICON_SUBLCD_SIGNAL_STRENGTH);
  1820.     ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1821. #ifdef __MMI_TOUCH_SCREEN__
  1822.     ChangeStatusIconImage(STATUS_ICON_KEYPAD_LOCK, IMG_SI_KEYPAD_UNLOCK);
  1823.     UpdateStatusIcons();    /* 101805 ChangeStatusIconImage Calvin: ChangeStatusIconImage will not call UpdateStatusIcon */
  1824.     ShowStatusIcon(STATUS_ICON_KEYPAD_LOCK);
  1825. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1826.     UpdateStatusIcons();
  1827. }
  1828. /*****************************************************************************
  1829.  * FUNCTION
  1830.  *  redraw_custom_startup_screen
  1831.  * DESCRIPTION
  1832.  *  
  1833.  * PARAMETERS
  1834.  *  void
  1835.  * RETURNS
  1836.  *  void
  1837.  *****************************************************************************/
  1838. void redraw_custom_startup_screen(void)
  1839. {
  1840.     /*----------------------------------------------------------------*/
  1841.     /* Local Variables                                                */
  1842.     /*----------------------------------------------------------------*/
  1843.     color c;
  1844.     S32 iwidth, iheight;
  1845.     /*----------------------------------------------------------------*/
  1846.     /* Code Body                                                      */
  1847.     /*----------------------------------------------------------------*/
  1848.     gui_lock_double_buffer();
  1849.     c.r = 255;
  1850.     c.b = 255;
  1851.     c.g = 255;
  1852.     c.alpha = 100;
  1853.     gui_set_clip(0, 0, UI_device_width - 1, UI_device_height - 1);
  1854.     gui_fill_rectangle(0, 0, UI_device_width - 1, UI_device_height - 1, c);
  1855.     gui_measure_image(get_image(CUSTOM_LOGO_IMAGE_ID), &iwidth, &iheight);
  1856.     gui_show_image(
  1857.         (UI_device_width >> 1) - (iwidth >> 1),
  1858.         (UI_device_height >> 1) - (iheight >> 1),
  1859.         get_image(CUSTOM_LOGO_IMAGE_ID));
  1860.     gui_unlock_double_buffer();
  1861.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  1862. }
  1863. /*****************************************************************************
  1864.  * FUNCTION
  1865.  *  goto_custom_startup_screen
  1866.  * DESCRIPTION
  1867.  *  
  1868.  * PARAMETERS
  1869.  *  void
  1870.  * RETURNS
  1871.  *  void
  1872.  *****************************************************************************/
  1873. void goto_custom_startup_screen(void)
  1874. {
  1875.     /*----------------------------------------------------------------*/
  1876.     /* Local Variables                                                */
  1877.     /*----------------------------------------------------------------*/
  1878.     /*----------------------------------------------------------------*/
  1879.     /* Code Body                                                      */
  1880.     /*----------------------------------------------------------------*/
  1881.     redraw_custom_startup_screen();
  1882.     gui_start_timer(DEMO_OPENING_CUSTOM_LOGO_TIMEOUT, exit_custom_startup_screen);
  1883. }
  1884. /*****************************************************************************
  1885.  * FUNCTION
  1886.  *  UI_update
  1887.  * DESCRIPTION
  1888.  *  
  1889.  * PARAMETERS
  1890.  *  void
  1891.  * RETURNS
  1892.  *  void
  1893.  *****************************************************************************/
  1894. void UI_update(void)
  1895. {
  1896. #if(!BUILD_TYPE_X86WIN32_DISABLE_REDRAW)
  1897.     /*----------------------------------------------------------------*/
  1898.     /* Local Variables                                                */
  1899.     /*----------------------------------------------------------------*/
  1900.     /*----------------------------------------------------------------*/
  1901.     /* Code Body                                                      */
  1902.     /*----------------------------------------------------------------*/
  1903.     if (RedrawCategoryFunction != NULL)
  1904.     {
  1905.         RedrawCategoryFunction();
  1906.     }
  1907.     if (SUBLCD_RedrawCategoryFunction != NULL)
  1908.     {
  1909.         SUBLCD_RedrawCategoryFunction();
  1910.     }
  1911. #endif /* (!BUILD_TYPE_X86WIN32_DISABLE_REDRAW) */ 
  1912. }
  1913. /*****************************************************************************
  1914.  * FUNCTION
  1915.  *  terminate_UI_demo
  1916.  * DESCRIPTION
  1917.  *  
  1918.  * PARAMETERS
  1919.  *  void
  1920.  * RETURNS
  1921.  *  void
  1922.  *****************************************************************************/
  1923. void terminate_UI_demo(void)
  1924. {
  1925.     /*----------------------------------------------------------------*/
  1926.     /* Local Variables                                                */
  1927.     /*----------------------------------------------------------------*/
  1928.     /*----------------------------------------------------------------*/
  1929.     /* Code Body                                                      */
  1930.     /*----------------------------------------------------------------*/
  1931.     if (ExitCategoryFunction != NULL)
  1932.     {
  1933.         ExitCategoryFunction();
  1934.     }
  1935.     if (SUBLCD_ExitCategoryFunction != NULL)
  1936.     {
  1937.         SUBLCD_ExitCategoryFunction();
  1938.     }
  1939.     gui_hide_animations();
  1940. }
  1941. U8 temp_sublcd_display_flag = 0;
  1942. /*****************************************************************************
  1943.  * FUNCTION
  1944.  *  toggle_temp_sublcd_display
  1945.  * DESCRIPTION
  1946.  *  
  1947.  * PARAMETERS
  1948.  *  void
  1949.  * RETURNS
  1950.  *  void
  1951.  *****************************************************************************/
  1952. void toggle_temp_sublcd_display(void)
  1953. {
  1954.     /*----------------------------------------------------------------*/
  1955.     /* Local Variables                                                */
  1956.     /*----------------------------------------------------------------*/
  1957.     /*----------------------------------------------------------------*/
  1958.     /* Code Body                                                      */
  1959.     /*----------------------------------------------------------------*/
  1960.     if (temp_sublcd_display_flag)
  1961.     {
  1962.         temp_sublcd_display_flag = 0;
  1963.         ShowCategory302Screen(NULL);
  1964.     }
  1965.     else
  1966.     {
  1967.         temp_sublcd_display_flag = 1;
  1968.         ShowCategory301Screen((U8*) GetString(TEMP_SUBLCD_ANIMATION_STR_ID), TEMP_SUBLCD_ANIMATION_IMAGE_ID, NULL);
  1969.     }
  1970. }