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

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.  * PoweronCharger.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for Power On when Charger connects 
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * removed!
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * removed!
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * removed!
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * removed!
  178.  *
  179.  * removed!
  180.  * removed!
  181.  * removed!
  182.  *
  183.  * removed!
  184.  * removed!
  185.  * removed!
  186.  *
  187.  * removed!
  188.  * removed!
  189.  * removed!
  190.  *
  191.  * removed!
  192.  * removed!
  193.  * removed!
  194.  *
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  *
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  *
  231.  *------------------------------------------------------------------------------
  232.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  233.  *============================================================================
  234.  ****************************************************************************/
  235. /***************************************************************************** 
  236. * Include
  237. *****************************************************************************/
  238. #include "stdC.h"
  239. #include "L4Dr1.h"
  240. #ifdef FIRST_PASS
  241. #include "BuildCfg.h"
  242. #endif 
  243. #include "MMI_features.h"
  244. #include "statusIconRes.h"
  245. #include "CustDataRes.h"
  246. #include "wgui_categories.h"
  247. #include "wgui_categories_popup.h"
  248. #include "EventsGprot.h"
  249. #include "QueueGProt.h"
  250. #include "taskinit.h"
  251. #include "BootUp.h"
  252. #include "KeyBrd.h"
  253. #include "ProtocolEvents.h"
  254. #include "AllAppGprot.h"
  255. #include "MMITaskProt.h"
  256. #include "AsyncEventsgprot.h"
  257. #include "DebugInitDef.h"
  258. #include "PowerOnChargerProt.h"
  259. #include "wgui_status_icons.h"
  260. #include "CommonScreens.h"
  261. #include "TimerEvents.h"
  262. #include "HistoryGprot.h"
  263. #include "NVRAMProt.h"
  264. #include "AudioInc.h"
  265. #include "IdleAppprot.h"
  266. #include "SimDetectionGexdcl.h"
  267. #include "SimDetectionGprot.h"
  268. #include "gpioInc.h"
  269. #include "SettingGprots.h"
  270. #include "ProfileGprots.h"
  271. #include "GlobalDefs.h"
  272. #include "GlobalScrEnum.h"
  273. #include "AlarmGprot.h"
  274. #include "ProfileGprots.h"
  275. #include "CallManagementGprot.h"
  276. #include "SubLCDHistoryGprot.h"
  277. #include "AlarmFrameWorkProt.h"
  278. #include "ProfileGprots.h"
  279. #include "ScheduledPowerOnOffGprot.h"
  280. #include "gdi_include.h"        /* include for graphic lib */
  281. #include "lcd_if.h"
  282. #ifdef __MMI_USB_SUPPORT__
  283. #include "USBDeviceGprot.h"
  284. #include "USBDeviceDefs.h"
  285. #endif /* __MMI_USB_SUPPORT__ */ 
  286. #ifdef MMI_ON_HARDWARE_P
  287. #include "lcd_sw.h"
  288. #include "L4Dr.h"
  289. #include "lcd_sw.h"
  290. #include "lcd_sw_inc.h"
  291. #include "gpioInc.h"
  292. #endif /* MMI_ON_HARDWARE_P */ 
  293. #include "ComposeRingToneProts.h"
  294. #ifdef __MMI_THEMES_APPLICATION__
  295. #include "MMIThemes.h"
  296. #endif 
  297. #include "DownloadProtos.h"
  298. #ifndef MMI_ON_WIN32
  299. #include "datetimetype.h"
  300. #include "app_datetime.h"
  301. #else
  302. #include "DateTimeGprot.h"
  303. #endif
  304. /***************************************************************************** 
  305. * Global Variable
  306. *****************************************************************************/
  307. charbat_context_struct g_charbat_context = 
  308. {
  309.     0,                  /* g_charbat_context.PowerOnCharger */
  310.     0,                  /* g_charbat_context.PowerOnChargingPeriod */
  311.     0,                  /* g_charbat_context.ChargingAbnormal */
  312.     0,                  /* g_charbat_context.ChargingComplete */
  313.     0,                  /* g_charbat_context.LowBatteryFlag */
  314.     0,                  /* g_charbat_context.LowBatteryTxProhibitFlag */
  315.     BATTERY_LEVEL_0,    /* g_charbat_context.chargerLevel */
  316.     PMIC_VBAT_STATUS,   /* g_charbat_context.batteryStatus */
  317.     0,                  /* g_charbat_context.isChargerConnected */
  318.     0                   /* g_charbat_context.LowBatteryCutOffCallCnt */
  319. };
  320. /***************************************************************************** 
  321. * Local Variable
  322. *****************************************************************************/
  323. /* Tells how  many times Battery low ind has been received. after 10 count it reset to -1 */
  324. static U8 batteryLowCount = 0;
  325. static U8 lowBatteryAlarmThreshold = LBAT_IDLE_DURCNT_NORMAL;
  326. /***************************************************************************** 
  327. * Local Function
  328. *****************************************************************************/
  329. static void mmi_devmgr_send_msg(U16 msg_id, void *local_param_ptr, void *peer_buf_ptr);
  330. /***************************************************************************** 
  331. * External Function
  332. *****************************************************************************/
  333. extern void QuitSystemOperation(void);
  334. #ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
  335. extern void PmgInitExtMelodyStruct(void);
  336. #endif 
  337. extern void ShutdownSystemOperation(void);
  338. extern void PhnsetReadGPIOSetting(void);
  339. extern void InitDownloadNVRAM(void);
  340. #ifdef MMI_ON_HARDWARE_P
  341. /*****************************************************************************
  342.  * FUNCTION
  343.  *  PreChargeEnd
  344.  * DESCRIPTION
  345.  *  Leave pre-charge stage.
  346.  * PARAMETERS
  347.  *  msg     [IN]        Leaving pre-charge indication
  348.  * RETURNS
  349.  *  void
  350.  *****************************************************************************/
  351. static void PreChargeEnd(void *msg)
  352. {
  353.     /*----------------------------------------------------------------*/
  354.     /* Local Variables                                                */
  355.     /*----------------------------------------------------------------*/
  356.     /*----------------------------------------------------------------*/
  357.     /* Code Body                                                      */
  358.     /*----------------------------------------------------------------*/
  359.     ClearInputEventHandler(MMI_DEVICE_ALL);
  360. }
  361. /*****************************************************************************
  362.  * FUNCTION
  363.  *  PreChrKeyPadDummyHdlr
  364.  * DESCRIPTION
  365.  *  Keypad dummy function when pre-charge stage.
  366.  * PARAMETERS
  367.  *  void
  368.  * RETURNS
  369.  *  void
  370.  *****************************************************************************/
  371. static void PreChrKeyPadDummyHdlr(void)
  372. {
  373.     /*----------------------------------------------------------------*/
  374.     /* Local Variables                                                */
  375.     /*----------------------------------------------------------------*/
  376.     /*----------------------------------------------------------------*/
  377.     /* Code Body                                                      */
  378.     /*----------------------------------------------------------------*/
  379.     DisplayPopup((U8*) GetString(STR_LOW_BATTERY), IMG_GLOBAL_WARNING, 0, UI_POPUP_NOTIFYDURATION_TIME, WARNING_TONE);
  380.     return;
  381. }
  382. #endif /* MMI_ON_HARDWARE_P */ 
  383. /*****************************************************************************
  384.  * FUNCTION
  385.  *  InitializeChargingScr
  386.  * DESCRIPTION
  387.  *  Initialization for power on charger.
  388.  * PARAMETERS
  389.  *  void
  390.  * RETURNS
  391.  *  void
  392.  *****************************************************************************/
  393. void InitializeChargingScr(void)
  394. {
  395.     /*----------------------------------------------------------------*/
  396.     /* Local Variables                                                */
  397.     /*----------------------------------------------------------------*/
  398.     /*----------------------------------------------------------------*/
  399.     /* Code Body                                                      */
  400.     /*----------------------------------------------------------------*/
  401.     InitUnicodeSupport();
  402.     gdi_init();
  403.     PhnsetReadGPIOSetting();
  404. #ifdef __MMI_USB_SUPPORT__
  405.     InitMMIUsbContext();
  406. #endif 
  407.     InitFramework();
  408.     InitHardwareEvents();
  409.     InitTime();
  410.     InitMMI_App();
  411.     setup_UI_wrappers();
  412.     PopulateResData();
  413.     initialize_UI_demo();
  414.     ShowChargingScr();
  415.     InitProfileApp();
  416.     /* Precharge Power On */
  417. #ifdef MMI_ON_HARDWARE_P
  418.     if (g_pwr_context.PowerOnMode == POWER_ON_PRECHARGE)
  419.     {
  420.         SetProtocolEventHandler(PreChargeEnd, MSG_ID_MMI_EQ_LEAVE_PRECHARGE_IND);
  421.     }
  422. #endif /* MMI_ON_HARDWARE_P */ 
  423.     TurnOnBacklight(1);
  424.     InitDownloadNVRAM();
  425.     initnvramprofapp();
  426.     InitSettingNVRAM();
  427. #if defined(__MMI_RING_COMPOSER__) && defined(__MMI_IMELODY_SUPPORT__)
  428.     InitRingToneComposer();
  429. #endif 
  430. #ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
  431.     PmgInitExtMelodyStruct();
  432. #endif 
  433.     InitAlarmFrameWork();
  434.     StartLEDPatternCharging();
  435.     g_charbat_context.PowerOnCharger = 1;
  436.     AnimateStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  437.     UpdateStatusIcons();
  438.     InitChargerPwrOn();
  439. #ifdef MMI_ON_HARDWARE_P
  440.     /* To wake up pending alarm */
  441.     PendingAlarmReminder();
  442. #endif /* MMI_ON_HARDWARE_P */ 
  443. }
  444. /*****************************************************************************
  445.  * FUNCTION
  446.  *  AlarmDisplayCharging
  447.  * DESCRIPTION
  448.  *  Handling of Charger connected on Power on Alarm screen.
  449.  * PARAMETERS
  450.  *  void
  451.  * RETURNS
  452.  *  void
  453.  *****************************************************************************/
  454. void AlarmDisplayCharging(void)
  455. {
  456.     /*----------------------------------------------------------------*/
  457.     /* Local Variables                                                */
  458.     /*----------------------------------------------------------------*/
  459.     /*----------------------------------------------------------------*/
  460.     /* Code Body                                                      */
  461.     /*----------------------------------------------------------------*/
  462.     g_charbat_context.PowerOnCharger = 1;
  463.     g_charbat_context.isChargerConnected = 1;
  464.     StartLEDPatternCharging();
  465.     ShowChargingScr();
  466.     if (g_charbat_context.ChargingComplete)
  467.     {
  468.         HideStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  469.         ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  470.     }
  471.     else
  472.     {
  473.         AnimateStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  474.     }
  475.     UpdateStatusIcons();
  476.     InitChargerPwrOn();
  477. }
  478. /*****************************************************************************
  479.  * FUNCTION
  480.  *  ShowChargingScr
  481.  * DESCRIPTION
  482.  *  Show charging screen when phone bootup bcos of charger.
  483.  * PARAMETERS
  484.  *  void
  485.  * RETURNS
  486.  *  void
  487.  *****************************************************************************/
  488. void ShowChargingScr(void)
  489. {
  490.     /*----------------------------------------------------------------*/
  491.     /* Local Variables                                                */
  492.     /*----------------------------------------------------------------*/
  493.     U8 *guiBuffer;
  494.     /*----------------------------------------------------------------*/
  495.     /* Code Body                                                      */
  496.     /*----------------------------------------------------------------*/
  497.     guiBuffer = GetCurrGuiBuffer(SCR_CHARGER_POWER_ON);
  498.     EntryNewScreen(SCR_CHARGER_POWER_ON, ExitChargingScr, NULL, NULL);
  499.     entry_full_screen();
  500.     DinitHistory();
  501. #ifdef MMI_ON_HARDWARE_P
  502.     if (g_pwr_context.PowerOnMode == POWER_ON_PRECHARGE)
  503.     {
  504.         ShowCategory9Screen(0, IMG_CHARGER_POWER_ON, NULL);
  505.     #ifndef __MMI_POWER_ON_OFF_BY_POWER_KEY__
  506.         SetKeyHandler(PreChrKeyPadDummyHdlr, KEY_END, KEY_LONG_PRESS);
  507.     #endif
  508.         SetKeyHandler(PreChrKeyPadDummyHdlr, KEY_POWER, KEY_LONG_PRESS);    
  509.         SetProtocolEventHandler(PreChargeEnd, MSG_ID_MMI_EQ_LEAVE_PRECHARGE_IND);
  510.     }
  511.     else
  512. #endif /* MMI_ON_HARDWARE_P */ 
  513.     {
  514.         ShowCategory9Screen(0, IMG_CHARGER_POWER_ON, NULL);
  515.     #ifndef __MMI_POWER_ON_OFF_BY_POWER_KEY__
  516.         SetKeyHandler(ChargingPwnOnThanPwnOn, KEY_END, KEY_LONG_PRESS);
  517.     #endif
  518.         SetKeyHandler(ChargingPwnOnThanPwnOn, KEY_POWER, KEY_LONG_PRESS);            
  519.     }
  520.     ShowSubLCDScreen(ShowSubLCDChargingScr);
  521. #ifndef __MMI_SUBLCD_CHARGING_HIDE_STATUS_BAR__
  522.     ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  523.     UpdateStatusIcons();
  524. #endif /* __MMI_SUBLCD_CHARGING_HIDE_STATUS_BAR__ */ 
  525.     g_charbat_context.PowerOnChargingPeriod = 1;
  526. }
  527. /*****************************************************************************
  528.  * FUNCTION
  529.  *  ExitChargingScr
  530.  * DESCRIPTION
  531.  *  Exit power on charging screen.
  532.  * PARAMETERS
  533.  *  void
  534.  * RETURNS
  535.  *  void
  536.  *****************************************************************************/
  537. void ExitChargingScr(void)
  538. {
  539.     /*----------------------------------------------------------------*/
  540.     /* Local Variables                                                */
  541.     /*----------------------------------------------------------------*/
  542.     history Scr;    /* Variable to hold the history data */
  543.     S16 nHistory = 0;
  544.     /*----------------------------------------------------------------*/
  545.     /* Code Body                                                      */
  546.     /*----------------------------------------------------------------*/
  547.     Scr.scrnID = SCR_CHARGER_POWER_ON;
  548.     Scr.entryFuncPtr = ShowChargingScr;
  549.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
  550.     AddHistory(Scr);
  551.     leave_full_screen();
  552.     g_charbat_context.PowerOnChargingPeriod = 0;
  553. }
  554. /*****************************************************************************
  555.  * FUNCTION
  556.  *  ShowSubLCDChargingScr
  557.  * DESCRIPTION
  558.  *  Show power on charging screen on SUBLCD.
  559.  * PARAMETERS
  560.  *  void
  561.  * RETURNS
  562.  *  void
  563.  *****************************************************************************/
  564. void ShowSubLCDChargingScr(void)
  565. {
  566. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  567.     /*----------------------------------------------------------------*/
  568.     /* Local Variables                                                */
  569.     /*----------------------------------------------------------------*/
  570.     /*----------------------------------------------------------------*/
  571.     /* Code Body                                                      */
  572.     /*----------------------------------------------------------------*/
  573.     if (!IsClamClose())
  574.     {
  575.         ExecSubLCDCurrExitHandler();
  576.         ShowCategory310Screen(get_string(STR_GLOBAL_LOGO));
  577.         SetSubLCDExitHandler(ExitSubLCDChargingScr);
  578.     }
  579.     else
  580.     {
  581.         ExecSubLCDCurrExitHandler();
  582.         ShowCategory304Screen(IMG_SUBLCD_CHARGER_POWER_ON, 0);
  583.         SetSubLCDExitHandler(ExitSubLCDChargingScr);
  584.     }
  585. #else /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  586.     ExecSubLCDCurrExitHandler();
  587.     ShowCategory304Screen(IMG_SUBLCD_CHARGER_POWER_ON, 0);
  588.     SetSubLCDExitHandler(ExitSubLCDChargingScr);
  589. #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  590. }
  591. /*****************************************************************************
  592.  * FUNCTION
  593.  *  ExitSubLCDChargingScr
  594.  * DESCRIPTION
  595.  *  Exit power on charging screen from sublcd.
  596.  * PARAMETERS
  597.  *  void
  598.  * RETURNS
  599.  *  void
  600.  *****************************************************************************/
  601. void ExitSubLCDChargingScr(void)
  602. {
  603.     /*----------------------------------------------------------------*/
  604.     /* Local Variables                                                */
  605.     /*----------------------------------------------------------------*/
  606.     /*----------------------------------------------------------------*/
  607.     /* Code Body                                                      */
  608.     /*----------------------------------------------------------------*/
  609.     SubLCDHistoryNode SubLCDHistory;
  610.     SubLCDHistory.entryFuncPtr = ShowSubLCDChargingScr;
  611.     AddSubLCDHistory(&SubLCDHistory);
  612. }
  613. /*****************************************************************************
  614.  * FUNCTION
  615.  *  InitChargerPwrOn
  616.  * DESCRIPTION
  617.  *  Initialise protocol handlers for power on charger.
  618.  * PARAMETERS
  619.  *  void
  620.  * RETURNS
  621.  *  void
  622.  *****************************************************************************/
  623. void InitChargerPwrOn()
  624. {
  625.     /*----------------------------------------------------------------*/
  626.     /* Local Variables                                                */
  627.     /*----------------------------------------------------------------*/
  628.     /*----------------------------------------------------------------*/
  629.     /* Code Body                                                      */
  630.     /*----------------------------------------------------------------*/
  631.     SetProtocolEventHandler(BatteryStatusRsp, PRT_BATTERY_STATUS_IND);
  632. #ifdef MMI_ON_HARDWARE_P
  633.     SetProtocolEventHandler(PowerOffRsp, MSG_ID_MMI_EQ_POWER_OFF_RSP);
  634. #endif 
  635. }
  636. /*****************************************************************************
  637.  * FUNCTION
  638.  *  ChargingPwnOnThanPwnOn
  639.  * DESCRIPTION
  640.  *  Fn to be called to power on the phone for long press of End key during power
  641.  *  on charger.
  642.  * PARAMETERS
  643.  *  void
  644.  * RETURNS
  645.  *  void
  646.  *****************************************************************************/
  647. void ChargingPwnOnThanPwnOn()
  648. {
  649.     /*----------------------------------------------------------------*/
  650.     /* Local Variables                                                */
  651.     /*----------------------------------------------------------------*/
  652.     /*----------------------------------------------------------------*/
  653.     /* Code Body                                                      */
  654.     /*----------------------------------------------------------------*/
  655.     /* MMI should detect keypad power on itself when charging */
  656.     MYQUEUE Message;
  657.     mmi_eq_power_on_req_struct *myMsgPtr;
  658. #if (defined(__MMI_SUBLCD__) && defined(MMI_ON_HARDWARE_P))
  659.     lcd_power_on(SUB_LCD, 0);
  660. #endif 
  661.     LCDBackLightOff();
  662.     myMsgPtr = (mmi_eq_power_on_req_struct*) OslConstructDataPtr(sizeof(mmi_eq_power_on_req_struct));
  663.     myMsgPtr->fun = 1;
  664.     myMsgPtr->rst = 0;
  665.     PRINT_INFORMATION(("[DevMngr-PMIC] CHARGER POWERKEY_ON"));
  666.     Message.oslSrcId = MOD_MMI;
  667.     Message.oslDestId = MOD_L4C;
  668.     Message.oslMsgId = MSG_ID_MMI_EQ_POWER_ON_REQ;
  669.     Message.oslDataPtr = (oslParaType*) myMsgPtr;
  670.     Message.oslPeerBuffPtr = NULL;
  671.     OslMsgSendExtQueue(&Message);
  672.     g_charbat_context.PowerOnCharger = 0;
  673. }
  674. /*****************************************************************************
  675.  * FUNCTION
  676.  *  BatteryStatusRsp
  677.  * DESCRIPTION
  678.  *  Call back function for battery status indication.
  679.  * PARAMETERS
  680.  *  info        [?]     
  681.  * RETURNS
  682.  *  void
  683.  *****************************************************************************/
  684. void BatteryStatusRsp(void *info)
  685. {
  686.     /*----------------------------------------------------------------*/
  687.     /* Local Variables                                                */
  688.     /*----------------------------------------------------------------*/
  689.     MYQUEUE Message;
  690.     mmi_eq_battery_status_ind_struct *p = (mmi_eq_battery_status_ind_struct*) info;
  691.     U16 string_id = 0;
  692.     /*----------------------------------------------------------------*/
  693.     /* Code Body                                                      */
  694.     /*----------------------------------------------------------------*/
  695.     g_charbat_context.batteryStatus = p->battery_status;
  696. #ifdef __MTK_TARGET__
  697.     g_charbat_context.chargerLevel = p->battery_voltage;
  698. #endif 
  699.     mmi_devmgr_charger_send_ack(p->battery_status);
  700.     switch (p->battery_status)
  701.     {
  702.     #ifdef __MMI_USB_SUPPORT__
  703.         case PMIC_USB_CHARGER_IN:
  704.             string_id = STR_USB_CHARGER_CONNECTED;
  705.             /* PASS */
  706.     #endif /* __MMI_USB_SUPPORT__ */ 
  707.         case PMIC_CHARGER_IN:
  708.         {
  709.             if (!string_id)
  710.             {
  711.                 string_id = STR_CHARGER_CONNECTED;
  712.             }
  713.             g_charbat_context.isChargerConnected = 1;
  714.         #ifdef __MMI_USB_SUPPORT__
  715.             mmi_usb_set_background_still(MMI_FALSE);
  716.         #endif 
  717.             if (mmi_bootup_is_before_power_on() == MMI_TRUE)
  718.             {
  719.                 PRINT_INFORMATION(("[DevMngr-PMIC] CHARGER IN before power on indication"));
  720.             }
  721.             else
  722.             {
  723.                 if (mmi_bootup_is_in_power_on_period() == MMI_TRUE)
  724.                 {
  725.                     IdleScreenChargerConnected(KAL_TRUE);
  726.                 }
  727.                 else
  728.                 {
  729.                     g_charbat_context.ChargingComplete = 0; /* To prevent reentrence of charging complete screen */
  730.                     TurnOnBacklight(1);
  731.                     if (!g_charbat_context.PowerOnCharger && mmi_bootup_is_in_power_on_period() == MMI_FALSE)
  732.                     {
  733.                         BatteryIndicationPopup(string_id);
  734.                         IdleScreenChargerConnected(KAL_FALSE);   /* swap for sublcd display */
  735.                     }
  736.                     if (g_charbat_context.LowBatteryFlag)   /* Charger plug in shall stop low battery LED pattern */
  737.                     {
  738.                         g_charbat_context.LowBatteryFlag = 0;
  739.                         StopLEDPatternBatteryWarning(); /* disconnect charger, the abnormal led pattern shall stop */
  740.                     }
  741.                 }
  742.             }
  743.             break;
  744.         }
  745.     #ifdef __MMI_USB_SUPPORT__
  746.         case PMIC_USB_CHARGER_OUT:
  747.             string_id = STR_USB_CHARGER_REMOVED;
  748.             /* PASS */
  749.     #endif /* __MMI_USB_SUPPORT__ */ 
  750.         case PMIC_CHARGER_OUT:
  751.         {
  752.             if (!string_id)
  753.             {
  754.                 string_id = STR_CHARGER_REMOVED;
  755.             }
  756.             g_charbat_context.ChargingComplete = 0; /* to prevent reentrence of charging complete screen */
  757.             g_charbat_context.isChargerConnected = 0;
  758.         #ifdef __MMI_USB_SUPPORT__
  759.             mmi_usb_set_background_still(MMI_TRUE);
  760.         #endif 
  761.             if (mmi_bootup_is_before_power_on() == MMI_TRUE)
  762.             {
  763.                 PRINT_INFORMATION(("[DevMngr-PMIC] CHARGER OUT before power on indication"));
  764.             }
  765.             else
  766.             {
  767.                 StopLEDPatternBatteryWarning();
  768.                 if (g_charbat_context.PowerOnCharger &&
  769.                     mmi_alm_is_in_alarm() == 0 && g_pwr_context.PowerOnMode != POWER_ON_USB)
  770.                 {
  771.                     Message.oslSrcId = MOD_MMI;
  772.                     Message.oslDestId = MOD_L4C;
  773.                     Message.oslMsgId = MSG_ID_MMI_EQ_POWER_OFF_REQ;
  774.                     Message.oslDataPtr = NULL;
  775.                     Message.oslPeerBuffPtr = NULL;
  776.                     OslMsgSendExtQueue(&Message);
  777.                 }
  778.                 else
  779.                 {
  780.                     if (mmi_bootup_is_in_power_on_period() == MMI_FALSE)
  781.                     {
  782.                         TurnOnBacklight(1);
  783.                     #ifdef __USB_IN_NORMAL_MODE__
  784.                         /* check is in mass storage mode */
  785.                         if (!mmi_usb_is_in_mass_storage_mode())
  786.                     #endif /* __USB_IN_NORMAL_MODE__ */                        
  787.                         {
  788.                             /* not in mass storage, can show the plug-out prompt */                        
  789.                         BatteryIndicationPopup(string_id);
  790.                         }
  791.                         DeleteScreenIfPresent(SCR_CHARGER_POWER_ON);
  792.                         StopLEDPatternCharging();
  793.                     }
  794.                     IdleScreenChargerDisconnected();
  795.                     if (g_charbat_context.ChargingAbnormal)
  796.                     {
  797.                         g_charbat_context.ChargingAbnormal = 0;
  798.                     }
  799.                 }
  800.             }
  801.             g_charbat_context.PowerOnCharger = 0;
  802.             break;
  803.         }
  804.         case PMIC_CHARGE_COMPLETE:  /* battery full charged. */
  805.         {
  806.         #ifndef __MTK_TARGET__
  807.             g_charbat_context.chargerLevel = BATTERY_LEVEL_3;
  808.         #endif 
  809.             if (mmi_bootup_is_before_power_on() == MMI_TRUE)
  810.             {
  811.                 BatteryStatusIndication(BATTERY_LEVEL_3);
  812.             }
  813.             else
  814.             {
  815.                 if (g_charbat_context.PowerOnCharger)
  816.                 {
  817.                     /* To prevent reentrence of charging complete screen */
  818.                     if (g_charbat_context.ChargingComplete == 0 && (AlmIsRTCPwron() == 0))
  819.                     {
  820.                         g_charbat_context.ChargingComplete = 1;
  821.                     #ifdef __MMI_USB_SUPPORT__
  822.                         if (g_pwr_context.PowerOnMode == POWER_ON_USB)
  823.                         {
  824.                             ShowUsbChgCmpltScr();
  825.                         }
  826.                         else
  827.                     #endif /* __MMI_USB_SUPPORT__ */ 
  828.                         {
  829.                             ShowChargingCompleteScr();
  830.                             StartLEDPatternFullCharging();
  831.                             HideStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  832.                             ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  833.                             ChangeStatusIconLevel(STATUS_ICON_BATTERY_STRENGTH, 100);
  834.                             ChangeStatusIconLevel(STATUS_ICON_SUBLCD_BATTERY_STRENGTH, 100);
  835.                             UpdateStatusIcons();
  836.                         }
  837.                     }
  838.                 }
  839.                 /* Message for Power off Device;Deepali */
  840.                 else
  841.                 {
  842.                 #ifdef __MMI_LED_POWERON_CHARGEFULL__
  843.                     g_charbat_context.ChargingComplete = 1;
  844.                     StartLEDPatternFullCharging();
  845.                 #endif /* __MMI_LED_POWERON_CHARGEFULL__ */ 
  846.                     IdleScreenBatteryFullCharged();
  847.                 }
  848.             }
  849.             break;
  850.         }
  851.         case PMIC_VBAT_STATUS:
  852.         {
  853.         #ifndef __MTK_TARGET__
  854.             g_charbat_context.chargerLevel = p->battery_voltage;
  855.         #endif 
  856.             BatteryStatusLowBatteryHandler(p->battery_voltage);
  857.             BatteryStatusIndication(p->battery_voltage);
  858.             break;
  859.         }
  860.         case PMIC_INVALID_BATTERY:
  861.             ChargingAbnormalHandler(STR_INVALID_BATTERY);
  862.             break;
  863.         case PMIC_OVERBATTEMP:
  864.             ChargingAbnormalHandler(STR_OVER_TEMP_BATTERY);
  865.             break;
  866.         case PMIC_OVERVOLPROTECT:
  867.             ChargingAbnormalHandler(STR_OVER_VOLTAGE_BATTERY);
  868.             break;
  869.         case PMIC_OVERCHARGECURRENT:
  870.             ChargingAbnormalHandler(STR_OVER_CURRENT_BATTERY);
  871.             break;
  872.         case PMIC_LOWBATTEMP:
  873.             ChargingAbnormalHandler(STR_LOW_TEMP_BATTERY);
  874.             break;
  875.         case PMIC_CHARGING_TIMEOUT:
  876.             ChargingAbnormalHandler(STR_CHARGING_TIMEOUT);
  877.             break;
  878.         case PMIC_INVALID_CHARGER:
  879.             ChargingAbnormalHandler(STR_INVALID_CHARGER);
  880.             break;
  881.         case PMIC_LOWCHARGECURRENT:
  882.             ChargingAbnormalHandler(STR_CHARGE_BAD_CONTACT);
  883.             break;
  884.         case PMIC_CHARGE_BAD_CONTACT:
  885.             ChargingAbnormalHandler(STR_CHARGE_BAD_CONTACT);
  886.             break;
  887.         case PMIC_BATTERY_BAD_CONTACT:
  888.             ChargingAbnormalHandler(STR_BATTERY_BAD_CONTACT);
  889.             break;
  890.         default:
  891.             break;
  892.     }
  893.     /* Shall reset this flag in the end of msg handler func */
  894.     SetInterruptPopupDisplay(POPUP_ALL_ON);
  895. }
  896. /*****************************************************************************
  897.  * FUNCTION
  898.  *  LowBatteryCommonAction
  899.  * DESCRIPTION
  900.  *  Handles the common action for low battery.
  901.  * PARAMETERS
  902.  *  void
  903.  * RETURNS
  904.  *  void
  905.  *****************************************************************************/
  906. void LowBatteryCommonAction(void)
  907. {
  908.     /*----------------------------------------------------------------*/
  909.     /* Local Variables                                                */
  910.     /*----------------------------------------------------------------*/
  911.     /*----------------------------------------------------------------*/
  912.     /* Code Body                                                      */
  913.     /*----------------------------------------------------------------*/
  914.     if (mmi_bootup_is_in_power_on_period() == MMI_TRUE)
  915.     {
  916.         /* Reset low battery alarm counter,  low battery will alert right after finish power on procedure  */
  917.         RESET_LOW_BATTERY_ALARM_CNT();
  918.     }
  919.     else
  920.     {
  921.         if (!g_charbat_context.isChargerConnected && batteryLowCount >= lowBatteryAlarmThreshold)
  922.         {
  923.             batteryLowCount = 0;
  924.             BatteryIndicationPopup(STR_LOW_BATTERY);
  925.             StartLEDPatternBatteryLow();
  926.             ChgrPlayLowBatTone();
  927.             BatteryStatusIndication(BATTERY_LOW_WARNING);
  928.             PRINT_INFORMATION(("[DevMngr-PMIC] PMIC_LOW_BATTERY"));
  929.         }
  930.         if (GetTotalCallCount() > 0 && g_charbat_context.LowBatteryTxProhibitFlag)
  931.         {
  932.             g_charbat_context.LowBatteryCutOffCallCnt++;
  933.             if (g_charbat_context.LowBatteryCutOffCallCnt >= LBAT_CALLDROP_CNT)
  934.             {
  935.                 g_charbat_context.LowBatteryCutOffCallCnt = 0;
  936.                 DeInitCM();
  937.             }
  938.         }
  939.         else
  940.         {
  941.             g_charbat_context.LowBatteryCutOffCallCnt = 0;
  942.         }
  943.     }
  944.     g_charbat_context.LowBatteryFlag = 1;   /* for led pattern history */
  945.     batteryLowCount++;
  946. }
  947. /*****************************************************************************
  948.  * FUNCTION
  949.  *  BatteryStatusLowBatteryHandler
  950.  * DESCRIPTION
  951.  *  his function handle low battery case.
  952.  * PARAMETERS
  953.  *  battery_voltage     [IN]        Battery level
  954.  * RETURNS
  955.  *  void
  956.  *****************************************************************************/
  957. void BatteryStatusLowBatteryHandler(U8 battery_voltage)
  958. {
  959.     /*----------------------------------------------------------------*/
  960.     /* Local Variables                                                */
  961.     /*----------------------------------------------------------------*/
  962.     /*----------------------------------------------------------------*/
  963.     /* Code Body                                                      */
  964.     /*----------------------------------------------------------------*/
  965. #ifdef MMI_ON_HARDWARE_P
  966.     kal_prompt_trace(
  967.         MOD_MMI,
  968.         "=LOWBAT=[Thre %d] [Cnt %d] [LBflag %d] [Txflag %d]",
  969.         lowBatteryAlarmThreshold,
  970.         batteryLowCount,
  971.         g_charbat_context.LowBatteryFlag,
  972.         g_charbat_context.LowBatteryTxProhibitFlag);
  973. #endif /* MMI_ON_HARDWARE_P */ 
  974.     switch (battery_voltage)
  975.     {
  976.             /*  
  977.              * 1. After power on animation, will check the battery level again, if too low, will shutdown as well.
  978.              * 2. When charger connected, shall ignore low battery indication  
  979.              */
  980.         case BATTERY_LOW_POWEROFF:  /* shutdown bcos of low battery */
  981.         {
  982.             if (!g_charbat_context.isChargerConnected && mmi_bootup_is_in_power_on_period() == MMI_FALSE)
  983.             {
  984.                 PRINT_INFORMATION(("[DevMngr-PMIC] LOW_BATTERY_POWER_OFF"));
  985.                 ShowLowPowerShutdownScr();
  986.             }
  987.             break;
  988.         }
  989.         case BATTERY_LOW_TX_PROHIBIT:
  990.         {
  991.             if (g_charbat_context.LowBatteryTxProhibitFlag == 0)
  992.             {
  993.                 /* Battery level changer, Change alert Threshold */
  994.                 g_charbat_context.LowBatteryTxProhibitFlag = 1; /* BATTERY_LOW_TX_PROHIBIT is a kind of low battery indication */
  995.                 if (GetTotalCallCount() == 0)
  996.                 {
  997.                     SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_IDLE_DURCNT_PROHIBIT);
  998.                     RESET_LOW_BATTERY_ALARM_CNT();
  999.                 }
  1000.                 else
  1001.                 {
  1002.                     SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_TALK_DURCNT_PROHIBIT);
  1003.                     RESET_LOW_BATTERY_ALARM_CNT();
  1004.                 }
  1005.             }
  1006.             LowBatteryCommonAction();
  1007.             break;
  1008.         }
  1009.         case BATTERY_LOW_WARNING:
  1010.         {
  1011.             if (g_charbat_context.LowBatteryFlag == 0 || g_charbat_context.LowBatteryTxProhibitFlag == 1)
  1012.             {
  1013.                 /* Battery level changer, Change alert Threshold */
  1014.                 /* Battery level coming up from BATTERY_LOW_TX_PROHIBIT, reset flag */
  1015.                 g_charbat_context.LowBatteryTxProhibitFlag = 0;
  1016.                 if (GetTotalCallCount() == 0)
  1017.                 {
  1018.                     SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_IDLE_DURCNT_NORMAL);
  1019.                     RESET_LOW_BATTERY_ALARM_CNT();
  1020.                 }
  1021.                 else
  1022.                 {
  1023.                     SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_TALK_DURCNT_NORMAL);
  1024.                     RESET_LOW_BATTERY_ALARM_CNT();
  1025.                 }
  1026.             }
  1027.             LowBatteryCommonAction();
  1028.             break;
  1029.         }
  1030.         case BATTERY_LEVEL_0:   /* pass */
  1031.         case BATTERY_LEVEL_1:   /* pass */
  1032.         case BATTERY_LEVEL_2:   /* pass */
  1033.         case BATTERY_LEVEL_3:   /* pass */
  1034.         default:
  1035.         {
  1036.             batteryLowCount = 0;                    /* reset low battery ind count */
  1037.             g_charbat_context.LowBatteryFlag = 0;   /* MTK added, Robin 1009 for status led history */
  1038.             g_charbat_context.LowBatteryTxProhibitFlag = 0;
  1039.             break;
  1040.         }
  1041.     }
  1042. }
  1043. /*****************************************************************************
  1044.  * FUNCTION
  1045.  *  BatteryStatusIndication
  1046.  * DESCRIPTION
  1047.  *  This function shows the level on status icons of mainlcd nad sublcd.
  1048.  * PARAMETERS
  1049.  *  battery_voltage     [IN]        Battery level
  1050.  * RETURNS
  1051.  *  void
  1052.  *****************************************************************************/
  1053. void BatteryStatusIndication(U8 battery_voltage)
  1054. {
  1055.     /*----------------------------------------------------------------*/
  1056.     /* Local Variables                                                */
  1057.     /*----------------------------------------------------------------*/
  1058.     /*----------------------------------------------------------------*/
  1059.     /* Code Body                                                      */
  1060.     /*----------------------------------------------------------------*/
  1061.     switch (battery_voltage)
  1062.     {
  1063.         case BATTERY_LOW_POWEROFF:      /* pass */
  1064.         case BATTERY_LOW_TX_PROHIBIT:   /* pass */
  1065.         case BATTERY_LOW_WARNING:       /* pass */
  1066.         case BATTERY_LEVEL_0:
  1067.         {
  1068.             PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[DevMngr-PMIC] Low Battery Warning: level = %d", battery_voltage));
  1069.             ChangeStatusIconLevel(STATUS_ICON_BATTERY_STRENGTH, 0);
  1070.         #ifdef __MMI_SUBLCD__
  1071.             ChangeStatusIconLevel(STATUS_ICON_SUBLCD_BATTERY_STRENGTH, 0);
  1072.         #endif 
  1073.             break;
  1074.         }
  1075.         case BATTERY_LEVEL_1:   /* pass */
  1076.         case BATTERY_LEVEL_2:   /* pass */
  1077.         case BATTERY_LEVEL_3:   /* pass */
  1078.         {
  1079.             PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[DevMngr-PMIC] Battery Level = %d", battery_voltage));
  1080.             ChangeStatusIconLevel((S16) STATUS_ICON_BATTERY_STRENGTH, (U8) (33 * (battery_voltage - BATTERY_LEVEL_0)));
  1081.         #ifdef __MMI_SUBLCD__
  1082.             ChangeStatusIconLevel(
  1083.                 (S16) STATUS_ICON_SUBLCD_BATTERY_STRENGTH,
  1084.                 (U8) (33 * (battery_voltage - BATTERY_LEVEL_0)));
  1085.         #endif /* __MMI_SUBLCD__ */ 
  1086.             break;
  1087.         }
  1088.         default:
  1089.         {
  1090.             PRINT_INFORMATION(("Battery Status Indication unknown voltage "));
  1091.             ChangeStatusIconLevel(STATUS_ICON_BATTERY_STRENGTH, 33);
  1092.         #ifdef __MMI_SUBLCD__
  1093.             ChangeStatusIconLevel(STATUS_ICON_SUBLCD_BATTERY_STRENGTH, 33);
  1094.         #endif 
  1095.             break;
  1096.         }
  1097.     }
  1098. }
  1099. /*****************************************************************************
  1100.  * FUNCTION
  1101.  *  CHECK_MO_ALLOW
  1102.  * DESCRIPTION
  1103.  *  This function checks if outgoing call is allowed or not.
  1104.  * PARAMETERS
  1105.  *  void
  1106.  * RETURNS
  1107.  *  MMI_TRUE:  MO allowed
  1108.  *  MMI_FALSE: MO not allowed
  1109.  *****************************************************************************/
  1110. BOOL CHECK_MO_ALLOW(void)
  1111. {
  1112.     /*----------------------------------------------------------------*/
  1113.     /* Local Variables                                                */
  1114.     /*----------------------------------------------------------------*/
  1115.     /*----------------------------------------------------------------*/
  1116.     /* Code Body                                                      */
  1117.     /*----------------------------------------------------------------*/
  1118.     if (g_charbat_context.LowBatteryTxProhibitFlag == 0)
  1119.     {
  1120.         return MMI_TRUE;    /* allow MO call */
  1121.     }
  1122.     else
  1123.     {
  1124.         return MMI_FALSE;   /* prohibit MO call */
  1125.     }
  1126. }
  1127. /*****************************************************************************
  1128.  * FUNCTION
  1129.  *  IS_LOW_BATTERY
  1130.  * DESCRIPTION
  1131.  *  This function checks if battery is low.
  1132.  * PARAMETERS
  1133.  *  void
  1134.  * RETURNS
  1135.  *  MMI_TRUE:  voltage low
  1136.  *  MMI_FALSE: noe voltage low
  1137.  *****************************************************************************/
  1138. BOOL IS_LOW_BATTERY(void)
  1139. {
  1140.     /*----------------------------------------------------------------*/
  1141.     /* Local Variables                                                */
  1142.     /*----------------------------------------------------------------*/
  1143.     /*----------------------------------------------------------------*/
  1144.     /* Code Body                                                      */
  1145.     /*----------------------------------------------------------------*/
  1146.     if (g_charbat_context.LowBatteryFlag == 1)
  1147.     {
  1148.         return MMI_TRUE;    /* Low battery */
  1149.     }
  1150.     else
  1151.     {
  1152.         return MMI_FALSE;
  1153.     }
  1154. }
  1155. /*****************************************************************************
  1156.  * FUNCTION
  1157.  *  SET_LOW_BATTERY_ALARM_THRESHOLD
  1158.  * DESCRIPTION
  1159.  *  TThis function sets the thresh hold for low battery alarm.
  1160.  * PARAMETERS
  1161.  *  cnt     [IN]        The thresh
  1162.  * RETURNS
  1163.  *  void
  1164.  *****************************************************************************/
  1165. void SET_LOW_BATTERY_ALARM_THRESHOLD(U8 cnt)
  1166. {
  1167.     /*----------------------------------------------------------------*/
  1168.     /* Local Variables                                                */
  1169.     /*----------------------------------------------------------------*/
  1170.     /*----------------------------------------------------------------*/
  1171.     /* Code Body                                                      */
  1172.     /*----------------------------------------------------------------*/
  1173.     /*********************************************************/
  1174.     /***** The threshold will be changed when:*****/
  1175.     /*********************************************************/
  1176.     /* 1. MT Call Accepted */
  1177.     /* 2. Call END */
  1178.     /* 3. Make MO Call */
  1179.     /* 4. SAT Call setup */
  1180.     /*********************************************************/
  1181.     if (lowBatteryAlarmThreshold == cnt)
  1182.     {
  1183.         return;
  1184.     }
  1185.     lowBatteryAlarmThreshold = cnt;
  1186.     batteryLowCount = lowBatteryAlarmThreshold;
  1187. }
  1188. /*****************************************************************************
  1189.  * FUNCTION
  1190.  *  RESET_LOW_BATTERY_ALARM_CNT
  1191.  * DESCRIPTION
  1192.  *  This function reset battery low alert count.
  1193.  * PARAMETERS
  1194.  *  void
  1195.  * RETURNS
  1196.  *  void
  1197.  *****************************************************************************/
  1198. void RESET_LOW_BATTERY_ALARM_CNT(void)
  1199. {
  1200.     /*----------------------------------------------------------------*/
  1201.     /* Local Variables                                                */
  1202.     /*----------------------------------------------------------------*/
  1203.     /*----------------------------------------------------------------*/
  1204.     /* Code Body                                                      */
  1205.     /*----------------------------------------------------------------*/
  1206.     /* 
  1207.      * Set counter to threshold value so that MMI will alert at next indication
  1208.      * (the indication will comes to MMI by 1 minute ( depends on custom setting) 
  1209.      */
  1210.     batteryLowCount = lowBatteryAlarmThreshold;
  1211. }
  1212. /*****************************************************************************
  1213.  * FUNCTION
  1214.  *  BatteryIndicationPopup
  1215.  * DESCRIPTION
  1216.  *  General popup fn for charger events.
  1217.  * PARAMETERS
  1218.  *  stringId        [IN]        String shows in the popup screen
  1219.  * RETURNS
  1220.  *  void
  1221.  *****************************************************************************/
  1222. void BatteryIndicationPopup(U16 stringId)
  1223. {
  1224.     /*----------------------------------------------------------------*/
  1225.     /* Local Variables                                                */
  1226.     /*----------------------------------------------------------------*/
  1227.     U8 pp_flag, tone_id = 0;
  1228.     /*----------------------------------------------------------------*/
  1229.     /* Code Body                                                      */
  1230.     /*----------------------------------------------------------------*/
  1231.     /*
  1232.      * Popup screen display permisstion flag
  1233.      * * Framework support Popup display permisstion flag
  1234.      * * Application who wanna stop popup has to intercept related messages and set the flag 
  1235.      */
  1236.     pp_flag = GetInterruptPopupDisplay();
  1237.     if ((pp_flag & POPUP_DSPL_ON) == 0 ||
  1238.         (pp_flag & POPUP_PMIC_ON) == 0)
  1239.     {
  1240.         return;
  1241.     }
  1242.     if (pp_flag & POPUP_TONE_ON)
  1243.     {
  1244.         tone_id = AUX_TONE;
  1245.     }
  1246.     /* Call End Transition, not allow to dispaly popup */
  1247.     if (GetTransitionToActiveFlag() == TRUE)
  1248.     {
  1249.         return;
  1250.     }
  1251.     DisplayPopup((U8*) GetString(stringId), IMG_GLOBAL_WARNING, 0, UI_POPUP_NOTIFYDURATION_TIME, tone_id);
  1252. }
  1253. /*****************************************************************************
  1254.  * FUNCTION
  1255.  *  ExitChargerPopUpScr
  1256.  * DESCRIPTION
  1257.  *  Exit Charger pop up screen.
  1258.  * PARAMETERS
  1259.  *  void
  1260.  * RETURNS
  1261.  *  void
  1262.  *****************************************************************************/
  1263. void ExitChargerPopUpScr(void)
  1264. {
  1265.     /*----------------------------------------------------------------*/
  1266.     /* Local Variables                                                */
  1267.     /*----------------------------------------------------------------*/
  1268.     /*----------------------------------------------------------------*/
  1269.     /* Code Body                                                      */
  1270.     /*----------------------------------------------------------------*/
  1271.     StopTimer(LOW_BATTERY_SCR_TIMER);
  1272. }
  1273. /*****************************************************************************
  1274.  * FUNCTION
  1275.  *  ChargingAbnormalHandler
  1276.  * DESCRIPTION
  1277.  *  Handle General Abnormal battery ind.
  1278.  * PARAMETERS
  1279.  *  stringId        [IN]        String shows in the popup screen
  1280.  * RETURNS
  1281.  *  void
  1282.  *****************************************************************************/
  1283. void ChargingAbnormalHandler(U16 stringId)
  1284. {
  1285.     /*----------------------------------------------------------------*/
  1286.     /* Local Variables                                                */
  1287.     /*----------------------------------------------------------------*/
  1288.     /*----------------------------------------------------------------*/
  1289.     /* Code Body                                                      */
  1290.     /*----------------------------------------------------------------*/
  1291.     if (g_charbat_context.isChargerConnected && mmi_bootup_is_in_power_on_period() == MMI_FALSE)
  1292.     {
  1293.         AbnormalBatteryIndPopup(stringId);
  1294.         StartLEDPatternBatteryWarning();
  1295.         playRequestedTone(BATTERY_WARNING_TONE);
  1296.     }
  1297. }
  1298. /*****************************************************************************
  1299.  * FUNCTION
  1300.  *  AbnormalBatteryIndPopup
  1301.  * DESCRIPTION
  1302.  *  Exit General Abnormal battery ind popup.
  1303.  * PARAMETERS
  1304.  *  stringId        [IN]        String shows in the popup screen
  1305.  * RETURNS
  1306.  *  void
  1307.  *****************************************************************************/
  1308. void AbnormalBatteryIndPopup(U16 stringId)
  1309. {
  1310.     /*----------------------------------------------------------------*/
  1311.     /* Local Variables                                                */
  1312.     /*----------------------------------------------------------------*/
  1313.     static U16 LocalStringId;
  1314.     /*----------------------------------------------------------------*/
  1315.     /* Code Body                                                      */
  1316.     /*----------------------------------------------------------------*/
  1317.     g_charbat_context.ChargingAbnormal = 1;
  1318.     EntryNewScreen(SCR_ABNORMAL_CHARGING, ExitAbnormalBatteryIndPopup, NULL, NULL);
  1319.     ClearKeyEvents();
  1320.     if (stringId != 0)
  1321.     {
  1322.         LocalStringId = stringId;
  1323.     }
  1324.     ShowCategory64Screen(LocalStringId, IMG_GLOBAL_WARNING, 0);
  1325.     ShowSubLCDScreen(ShowSubLCDAbnormalPopup);
  1326.     HideStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1327.     ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1328.     ClearInputEventHandler(MMI_DEVICE_KEY);
  1329.     if (g_charbat_context.PowerOnCharger == 0)
  1330.     {
  1331.         HideStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1332.         ShowStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1333.     }
  1334.     else
  1335.     {
  1336.         ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1337.         ClearKeyHandler(KEY_END, KEY_LONG_PRESS);   /* Abnormal case */
  1338.         ClearKeyHandler(KEY_POWER, KEY_LONG_PRESS);   /* Abnormal case */
  1339.     }
  1340.     UpdateStatusIcons();
  1341. }
  1342. /*****************************************************************************
  1343.  * FUNCTION
  1344.  *  ExitAbnormalBatteryIndPopup
  1345.  * DESCRIPTION
  1346.  *  Exit General Abnormal battery ind popup.
  1347.  * PARAMETERS
  1348.  *  void
  1349.  * RETURNS
  1350.  *  void
  1351.  *****************************************************************************/
  1352. void ExitAbnormalBatteryIndPopup(void)
  1353. {
  1354.     /*----------------------------------------------------------------*/
  1355.     /* Local Variables                                                */
  1356.     /*----------------------------------------------------------------*/
  1357.     /*----------------------------------------------------------------*/
  1358.     /* Code Body                                                      */
  1359.     /*----------------------------------------------------------------*/
  1360.     if (GetInterruptPopupDisplay() == POPUP_ALL_ON)
  1361.     {
  1362.         GoBackSubLCDHistory();
  1363.     }
  1364. }
  1365. /*****************************************************************************
  1366.  * FUNCTION
  1367.  *  ShowSubLCDAbnormalPopup
  1368.  * DESCRIPTION
  1369.  *  General Abnormal battery ind popup for sublcd.
  1370.  * PARAMETERS
  1371.  *  void
  1372.  * RETURNS
  1373.  *  void
  1374.  *****************************************************************************/
  1375. void ShowSubLCDAbnormalPopup(void)
  1376. {
  1377.     /*----------------------------------------------------------------*/
  1378.     /* Local Variables                                                */
  1379.     /*----------------------------------------------------------------*/
  1380.     /*----------------------------------------------------------------*/
  1381.     /* Code Body                                                      */
  1382.     /*----------------------------------------------------------------*/
  1383.     ExecSubLCDCurrExitHandler();
  1384.     ShowCategory304Screen(IMG_SUBLCD_ABNORMAL_BATTERY, 0);
  1385. }
  1386. /*****************************************************************************
  1387.  * FUNCTION
  1388.  *  ShowLowPowerShutdownScr
  1389.  * DESCRIPTION
  1390.  *  Show Low power shutdown screen.
  1391.  * PARAMETERS
  1392.  *  void
  1393.  * RETURNS
  1394.  *  void
  1395.  *****************************************************************************/
  1396. void ShowLowPowerShutdownScr(void)
  1397. {
  1398.     /*----------------------------------------------------------------*/
  1399.     /* Local Variables                                                */
  1400.     /*----------------------------------------------------------------*/
  1401.     /*----------------------------------------------------------------*/
  1402.     /* Code Body                                                      */
  1403.     /*----------------------------------------------------------------*/
  1404.     EntryNewScreen(GLOBAL_SCR_DUMMY, NULL, NULL, NULL);
  1405.     DeInitFramework_KeyAndEventHandler();
  1406.     ShowCategory64Screen(STR_LOW_BATTERY_SHUTDOWN, IMG_GLOBAL_WARNING, NULL);
  1407.     BatteryStatusIndication(0);
  1408.     StartTimer(LOW_BATTERY_SCR_TIMER, LBAT_SHUTDOWN_SCR_TIMER_DUR, LowBatteryShutDownScrTimeout);
  1409.     ChgrPlayLowBatTone();
  1410. }
  1411. /*****************************************************************************
  1412.  * FUNCTION
  1413.  *  LowBatteryShutDownScrTimeout
  1414.  * DESCRIPTION
  1415.  *  Call back fn when Low Battery shutdown timer expired.
  1416.  * PARAMETERS
  1417.  *  void
  1418.  * RETURNS
  1419.  *  void
  1420.  *****************************************************************************/
  1421. void LowBatteryShutDownScrTimeout(void)
  1422. {
  1423.     /*----------------------------------------------------------------*/
  1424.     /* Local Variables                                                */
  1425.     /*----------------------------------------------------------------*/
  1426.     /*----------------------------------------------------------------*/
  1427.     /* Code Body                                                      */
  1428.     /*----------------------------------------------------------------*/
  1429.     StopTimer(LOW_BATTERY_SCR_TIMER);
  1430. #ifdef __MMI_LOW_BATTERY_SHUTDOWN_NO_ANIMATION__
  1431.     QuitSystemOperation();
  1432. #else /* __MMI_LOW_BATTERY_SHUTDOWN_NO_ANIMATION__ */ 
  1433.     /* if low battery shutdown at power on, do no play power off animation */
  1434.     if (mmi_bootup_is_in_power_on_period() == MMI_TRUE)
  1435.     {
  1436.         QuitSystemOperation();
  1437.     }
  1438.     else
  1439.     {
  1440.         ShutdownSystemOperation();
  1441.     }
  1442. #endif /* __MMI_LOW_BATTERY_SHUTDOWN_NO_ANIMATION__ */ 
  1443. }
  1444. /*****************************************************************************
  1445.  * FUNCTION
  1446.  *  IdleScreenChargerConnected
  1447.  * DESCRIPTION
  1448.  *  Update status icon display.
  1449.  * PARAMETERS
  1450.  *  playtone        [IN]        True/False
  1451.  * RETURNS
  1452.  *  void
  1453.  *****************************************************************************/
  1454. void IdleScreenChargerConnected(U8 playtone)
  1455. {
  1456.     /*----------------------------------------------------------------*/
  1457.     /* Local Variables                                                */
  1458.     /*----------------------------------------------------------------*/
  1459.     /*----------------------------------------------------------------*/
  1460.     /* Code Body                                                      */
  1461.     /*----------------------------------------------------------------*/
  1462.     if (playtone == KAL_TRUE)
  1463.     {
  1464.         playRequestedTone(AUX_TONE);
  1465.     }
  1466.     ShowStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1467.     ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1468.     AnimateStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1469.     AnimateStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1470.     UpdateStatusIcons();
  1471.     PRINT_INFORMATION(("[DevMngr-PMIC] CHARGER IN"));
  1472. }
  1473. /*****************************************************************************
  1474.  * FUNCTION
  1475.  *  IdleScreenChargerDisconnected
  1476.  * DESCRIPTION
  1477.  *  Update status icon display.
  1478.  * PARAMETERS
  1479.  *  void
  1480.  * RETURNS
  1481.  *  void
  1482.  *****************************************************************************/
  1483. void IdleScreenChargerDisconnected(void)
  1484. {
  1485.     /*----------------------------------------------------------------*/
  1486.     /* Local Variables                                                */
  1487.     /*----------------------------------------------------------------*/
  1488.     U8 pp_flag = 0;
  1489.     
  1490.     /*----------------------------------------------------------------*/
  1491.     /* Code Body                                                      */
  1492.     /*----------------------------------------------------------------*/
  1493.     pp_flag = GetInterruptPopupDisplay();
  1494.     if (pp_flag & POPUP_TONE_ON)
  1495.     {
  1496.         playRequestedTone(AUX_TONE);
  1497.     }
  1498.     HideStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1499.     HideStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1500.     ShowStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1501.     ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1502.     UpdateStatusIcons();
  1503.     BatteryStatusIndication(g_charbat_context.chargerLevel);
  1504.     PRINT_INFORMATION(("[DevMngr-PMIC] CHARGER OUT"));
  1505. }
  1506. /*****************************************************************************
  1507.  * FUNCTION
  1508.  *  IdleScreenBatteryFullCharged
  1509.  * DESCRIPTION
  1510.  *  Update status icon display.
  1511.  * PARAMETERS
  1512.  *  void
  1513.  * RETURNS
  1514.  *  void
  1515.  *****************************************************************************/
  1516. void IdleScreenBatteryFullCharged(void)
  1517. {
  1518.     /*----------------------------------------------------------------*/
  1519.     /* Local Variables                                                */
  1520.     /*----------------------------------------------------------------*/
  1521.     /*----------------------------------------------------------------*/
  1522.     /* Code Body                                                      */
  1523.     /*----------------------------------------------------------------*/
  1524.     HideStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1525.     HideStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1526.     ShowStatusIcon(STATUS_ICON_BATTERY_STRENGTH);
  1527.     ShowStatusIcon(STATUS_ICON_SUBLCD_BATTERY_STRENGTH);
  1528.     ChangeStatusIconLevel(STATUS_ICON_BATTERY_STRENGTH, 100);
  1529.     ChangeStatusIconLevel(STATUS_ICON_SUBLCD_BATTERY_STRENGTH, 100);
  1530.     UpdateStatusIcons();
  1531.     PRINT_INFORMATION(("[DevMngr-PMIC] BATTERY FULL CHARGED"));
  1532. }
  1533. /*****************************************************************************
  1534.  * FUNCTION
  1535.  *  ShowChargingCompleteScr
  1536.  * DESCRIPTION
  1537.  *  Show Charging Complete screen.
  1538.  * PARAMETERS
  1539.  *  void
  1540.  * RETURNS
  1541.  *  void
  1542.  *****************************************************************************/
  1543. void ShowChargingCompleteScr(void)
  1544. {
  1545.     /*----------------------------------------------------------------*/
  1546.     /* Local Variables                                                */
  1547.     /*----------------------------------------------------------------*/
  1548.     /*----------------------------------------------------------------*/
  1549.     /* Code Body                                                      */
  1550.     /*----------------------------------------------------------------*/
  1551.     EntryNewScreen(SCR_CHARGING_COMPLETE, NULL, ShowChargingCompleteScr, NULL);
  1552.     DinitHistory();
  1553.     ShowCategory9Screen(0, IMG_BATTERY_FULL_CHARGED, NULL);
  1554.     ShowSubLCDScreen(ShowSubLCDChargingCompleteScr);
  1555.     ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1556. #ifndef __MMI_POWER_ON_OFF_BY_POWER_KEY__
  1557.     SetKeyHandler(ChargingPwnOnThanPwnOn, KEY_END, KEY_LONG_PRESS);
  1558. #endif
  1559.     SetKeyHandler(ChargingPwnOnThanPwnOn, KEY_POWER, KEY_LONG_PRESS);    
  1560. }
  1561. /*****************************************************************************
  1562.  * FUNCTION
  1563.  *  ShowSubLCDChargingCompleteScr
  1564.  * DESCRIPTION
  1565.  *  Show sublcd charging complete screen.
  1566.  * PARAMETERS
  1567.  *  void
  1568.  * RETURNS
  1569.  *  void
  1570.  *****************************************************************************/
  1571. void ShowSubLCDChargingCompleteScr(void)
  1572. {
  1573.     /*----------------------------------------------------------------*/
  1574.     /* Local Variables                                                */
  1575.     /*----------------------------------------------------------------*/
  1576.     /*----------------------------------------------------------------*/
  1577.     /* Code Body                                                      */
  1578.     /*----------------------------------------------------------------*/
  1579.     ExecSubLCDCurrExitHandler();
  1580. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  1581.     if (!IsClamClose())
  1582.     {
  1583.         ShowCategory310Screen(get_string(STR_GLOBAL_LOGO));
  1584.     }
  1585.     else
  1586. #endif /* __MMI_SUBLCD_SHOW_ANALOG_CLOCK__ */ 
  1587.     {
  1588.         ShowCategory304Screen(IMG_SUBLCD_CHARGING_COMPLETE, 0);
  1589.     }
  1590.     SetSubLCDExitHandler(ExitSubLCDChargingCompleteScr);
  1591. }
  1592. /*****************************************************************************
  1593.  * FUNCTION
  1594.  *  ExitSubLCDChargingCompleteScr
  1595.  * DESCRIPTION
  1596.  *  Exit from sublcd charging complete screen.
  1597.  * PARAMETERS
  1598.  *  void
  1599.  * RETURNS
  1600.  *  void
  1601.  *****************************************************************************/
  1602. void ExitSubLCDChargingCompleteScr(void)
  1603. {
  1604.     /*----------------------------------------------------------------*/
  1605.     /* Local Variables                                                */
  1606.     /*----------------------------------------------------------------*/
  1607.     SubLCDHistoryNode SubLCDHistory;
  1608.     /*----------------------------------------------------------------*/
  1609.     /* Code Body                                                      */
  1610.     /*----------------------------------------------------------------*/
  1611.     SubLCDHistory.entryFuncPtr = ShowSubLCDChargingCompleteScr;
  1612.     AddSubLCDHistory(&SubLCDHistory);
  1613. }
  1614. /*****************************************************************************
  1615.  * FUNCTION
  1616.  *  ChargerDetectTimeoutHdlr
  1617.  * DESCRIPTION
  1618.  *  Display Charger status after power on enter idle screen.
  1619.  * PARAMETERS
  1620.  *  void
  1621.  * RETURNS
  1622.  *  void
  1623.  *****************************************************************************/
  1624. void ChargerDetectTimeoutHdlr(void)
  1625. {
  1626.     /*----------------------------------------------------------------*/
  1627.     /* Local Variables                                                */
  1628.     /*----------------------------------------------------------------*/
  1629.     /*----------------------------------------------------------------*/
  1630.     /* Code Body                                                      */
  1631.     /*----------------------------------------------------------------*/
  1632.     StopTimer(BOOTUP_CHARGER_DETECT_TIMER);
  1633.     if (g_charbat_context.isChargerConnected == 1)
  1634.     {
  1635.         IdleScreenChargerConnected(KAL_TRUE);
  1636.     }
  1637. }
  1638. /*****************************************************************************
  1639.  * FUNCTION
  1640.  *  ChgrPlayLowBatTone
  1641.  * DESCRIPTION
  1642.  *  Display Charger status after power on enter idle screen.
  1643.  * PARAMETERS
  1644.  *  void
  1645.  * RETURNS
  1646.  *  void
  1647.  *****************************************************************************/
  1648. void ChgrPlayLowBatTone(void)
  1649. {
  1650.     /*----------------------------------------------------------------*/
  1651.     /* Local Variables                                                */
  1652.     /*----------------------------------------------------------------*/
  1653.     /*----------------------------------------------------------------*/
  1654.     /* Code Body                                                      */
  1655.     /*----------------------------------------------------------------*/
  1656.     if (g_charbat_context.isChargerConnected == 0)
  1657.     {
  1658.         playRequestedTone(BATTERY_LOW_TONE);
  1659.     }
  1660. }
  1661. /*****************************************************************************
  1662.  * FUNCTION
  1663.  *  mmi_devmgr_charger_send_ack
  1664.  * DESCRIPTION
  1665.  *  send ack to PS
  1666.  * PARAMETERS
  1667.  *  action          [IN]        
  1668.  *  Action(?)       [IN]        Battery_sttus
  1669.  * RETURNS
  1670.  *  void
  1671.  *****************************************************************************/
  1672. void mmi_devmgr_charger_send_ack(U8 action)
  1673. {
  1674. #ifdef MMI_ON_HARDWARE_P
  1675.     /*----------------------------------------------------------------*/
  1676.     /* Local Variables                                                */
  1677.     /*----------------------------------------------------------------*/
  1678.     /*----------------------------------------------------------------*/
  1679.     /* Code Body                                                      */
  1680.     /*----------------------------------------------------------------*/
  1681.     if (action == PMIC_CHARGER_IN ||
  1682.         action == PMIC_CHARGER_OUT || 
  1683.         action == PMIC_USB_CHARGER_IN  || 
  1684.         action == PMIC_USB_CHARGER_OUT ||
  1685.         action == PMIC_USB_NO_CHARGER_OUT ||
  1686.         action == PMIC_USB_NO_CHARGER_IN   )
  1687.     {
  1688.         mmi_eq_battery_status_res_req_struct *param_ack;
  1689.         param_ack = OslConstructDataPtr(sizeof(mmi_eq_battery_status_res_req_struct));
  1690.         param_ack->status_type = action;
  1691.         PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[DevMngr-PMIC] Send Ack to PS: Action = %d", param_ack->status_type));
  1692.         mmi_devmgr_send_msg(MSG_ID_MMI_EQ_BATTERY_STATUS_RES_REQ, param_ack, NULL);
  1693.     }
  1694. #endif /* MMI_ON_HARDWARE_P */ 
  1695. }
  1696. /*****************************************************************************
  1697.  * FUNCTION
  1698.  *  mmi_devmgr_send_msg
  1699.  * DESCRIPTION
  1700.  *  send message to PS
  1701.  * PARAMETERS
  1702.  *  msg_id              [IN]        Message id
  1703.  *  local_param_ptr     [IN]        Local parameter
  1704.  *  peer_buf_ptr        [IN]        Peer buffer
  1705.  * RETURNS
  1706.  *  void
  1707.  *****************************************************************************/
  1708. static void mmi_devmgr_send_msg(U16 msg_id, void *local_param_ptr, void *peer_buf_ptr)
  1709. {
  1710. #ifdef MMI_ON_HARDWARE_P
  1711.     /*----------------------------------------------------------------*/
  1712.     /* Local Variables                                                */
  1713.     /*----------------------------------------------------------------*/
  1714.     MYQUEUE Message;
  1715.     /*----------------------------------------------------------------*/
  1716.     /* Code Body                                                      */
  1717.     /*----------------------------------------------------------------*/
  1718.     Message.oslMsgId = msg_id;
  1719.     Message.oslDataPtr = (oslParaType*) local_param_ptr;
  1720.     Message.oslPeerBuffPtr = peer_buf_ptr;
  1721.     Message.oslSrcId = MOD_MMI;
  1722.     Message.oslDestId = MOD_L4C;
  1723.     OslMsgSendExtQueue(&Message);
  1724. #endif /* MMI_ON_HARDWARE_P */ 
  1725. }