⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmitask.c

📁 MTK手机平台的MMI部分的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
extern void mmi_phb_sos_list_init(void);

#ifdef __MMI_MESSAGES_CHAT__
extern void InitializeChatApp(void);
#endif 
#ifdef __MMI_IRDA_SUPPORT__
extern void mmi_irda_init_menu_hdlr(void);
#endif 
#ifdef __MMI_BT_HP_SUPPORT__
extern void mmi_bt_scr_init(void);
extern void mmi_bt_init_menu_highlight_hdlr(void);
#endif /* __MMI_BT_HP_SUPPORT__ */ 
/* for PC simulator */
#if !defined(__MMI_BT_SUPPORT__) && defined(MMI_ON_WIN32)
extern void mmi_bt_init(void);
#endif 
#ifndef __DISABLE_SHORTCUTS_IMPL__
extern void ShctInit(void);
#endif 
extern void SetDateTime(void *t);
extern void mmi_frm_sms_init(void);

/* diamond, 2005/07/05 Flight mode */
#ifdef __FLIGHT_MODE_SUPPORT__
extern void PowerOnFlightMode(void);
extern void PowerOnNormalMode(void);
extern void EntryQueryFlightModeScreen(void);
extern void PhnsetFlightModeQueryBackground(void);  /* diamond, 2006/01/01 Force to draw the background */
extern void PhnsetFlightModePowerOnException(void);
extern void mmi_flight_mode_set_mode(U8 bFlightMode); /* send the mode to L4C ASAP to speed up the L4C startup time */
extern PHNSET_CNTX g_phnset_cntx;
#endif /* __FLIGHT_MODE_SUPPORT__ */ 
/* end, diamond */

#ifdef __MMI_BG_SOUND_EFFECT__
extern void mmi_bgsnd_init(void);
#endif 

#if defined(__MMI_FM_RADIO_SCHEDULE_REC__)
extern void mmi_fmsr_init_app(void);
#endif 
#if defined(__MMI_DOWNLOAD_AGENT__)
extern void mmi_da_init_app(void);
#endif 

extern void mdi_audio_set_audio_mode(U8 mode);

extern void PhnsetReadGPIOSetting(void);


#ifdef __MMI_USER_CTRL_PLMN_SUPPORT__
extern void mmi_netset_init_user_ctrl_plmn(void);
#endif 

#ifdef __MMI_SWFLASH__
extern void mmi_swflash_init_app(void);
#endif

#ifdef __MMI_CCA_SUPPORT__
extern void mmi_cca_init(void);
#endif

#ifndef MMI_ON_WIN32
#include "l4dr.h"
#include "MMITaskProt.h"
/* 
 * MTK added for two kinds of timer, one is for exactly time, another allow to delay.
 */
stack_timer_struct base_timer1; /* no alignment timer */
stack_timer_struct base_timer2; /* allow alignment timer */
event_scheduler *event_scheduler1_ptr, *event_scheduler2_ptr;
oslMsgqid mmi_ext_qid;
MMI_BOOL g_keypad_flag = MMI_FALSE;
drv_get_key_func keypad_ptr;
extern kal_mutexid mmi_mutex_trace;


/*****************************************************************************
 * FUNCTION
 *  MMI_Init
 * DESCRIPTION
 *  MMI Init Function
 * PARAMETERS
 *  task_indx       [IN]        Index of task
 * RETURNS
 *  void
 *****************************************************************************/
MMI_BOOL MMI_Init(task_indx_type task_indx)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifndef MMI_ON_WIN32
    mmi_mutex_trace = kal_create_mutex("mmi_trace");
#endif 

    mmi_frm_get_2step_keys();

    /* 
     * initial the system service timer 
     */
    L4InitTimer();
    setup_UI_wrappers();

#if defined(__MMI_RESOURCE_ENFB_SUPPORT__)
    /* 
     * Init Resource Memory Manamger  for E-NFB
     */
	mmi_frm_resmem_init();
#endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */

    return MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  EvshedMMITimerHandler
 * DESCRIPTION
 *  MMI Timer Event Scheduler
 * PARAMETERS
 *  dataPtr     [IN]        Data from L4
 * RETURNS
 *  void
 *****************************************************************************/
void EvshedMMITimerHandler(void *dataPtr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    stack_timer_struct *stack_timer_ptr;

    stack_timer_ptr = (stack_timer_struct*) dataPtr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (stack_timer_ptr == &base_timer1)
    {
        if (stack_is_time_out_valid(&base_timer1))
        {
            evshed_timer_handler(event_scheduler1_ptr);
        }
        stack_process_time_out(&base_timer1);
    }
    else if (stack_timer_ptr == &base_timer2)
    {
        if (stack_is_time_out_valid(&base_timer2))
        {
            evshed_timer_handler(event_scheduler2_ptr);
        }
        stack_process_time_out(&base_timer2);
    }
}
#endif /* MMI_ON_WIN32 */ 


/*****************************************************************************
 * FUNCTION
 *  FlightModeCheckBeforeAnimation
 * DESCRIPTION
 *  Flight mode query screen before animation
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
/* static U8 gFlightModeFromCalibration; */
void FlightModeCheckBeforeAnimation()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* diamond, 2005/07/05 Flight mode */
#ifdef __FLIGHT_MODE_SUPPORT__
    switch (g_phnset_cntx.curFlightMode)
    {
        case FLIGHTMODE_QUERY:
            TurnOnBacklight(1);
            PhnsetFlightModeQueryBackground();  /* diamond, 2006/01/01 Force to draw the background */
            EntryQueryFlightModeScreen();
            break;

        case FLIGHTMODE_SILENT:
        case FLIGHTMODE_OFF:
            mmi_bootup_exit_flight_mode_query();
            break;

        default:
            PowerOnNormalMode();
            break;
    }
#else /* __FLIGHT_MODE_SUPPORT__ */ 
    mmi_bootup_entry_animation();   /* not necessary to enter flight mode query screen if it is not supported */
#endif /* __FLIGHT_MODE_SUPPORT__ */ 
    /* end, diamond */
}


/*****************************************************************************
 * FUNCTION
 *  InitEventHandlersBeforePowerOn
 * DESCRIPTION
 *  Init event handlers before power on indication
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void InitEventHandlersBeforePowerOn(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    InitEvents();
    InitKeypadBeforePWRON();
#ifndef MMI_ON_WIN32
    SetProtocolEventHandler(GpioDetectInd, MSG_ID_MMI_EQ_GPIO_DETECT_IND);
    SetProtocolEventHandler(BatteryStatusRsp, MSG_ID_MMI_EQ_BATTERY_STATUS_IND);
#ifdef __MMI_USB_SUPPORT__
    SetProtocolEventHandler(UsbDetectIndHdlr, PRT_EQ_USB_DETECT_IND);
#endif 
    InitAlarmHandler();
#endif /* MMI_ON_WIN32 */ 

#ifdef __MMI_TVOUT__
    /* init tvout, since TV-out indication will come before poweron indication */
    mmi_phnset_early_init_tvout_before_pwron();
#endif    
}

#ifndef MMI_ON_WIN32


/*****************************************************************************
 * FUNCTION
 *  mmi_frm_check_is_valid_msg
 * DESCRIPTION
 *  Check if the follow message is useful
 *  If the successive messages are MSG_ID_TIMER_EXPIRY,
 *  only one message will be usegful. We will keep only one
 *  MSG_ID_TIMER_EXPIRY in the queue
 * PARAMETERS
 *  base        [IN]     
 *  msg         [IN]     
 * RETURNS
 *  0 - the message is invalid, and discard the message
 *  1 - the message is vaild
 *****************************************************************************/
U8 mmi_frm_check_is_valid_msg(MYQUEUE *base, MYQUEUE *msg)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if ((base != NULL) && (msg != NULL) && (base->msg_id == msg->msg_id))
    {
        switch (base->msg_id)
        {
            case MSG_ID_TIMER_EXPIRY:
            {
                kal_uint16 msg_len = 0;
                stack_timer_struct *base_timer_ptr;
                stack_timer_struct *timer_ptr;

                base_timer_ptr = (stack_timer_struct*) get_local_para_ptr(base->oslDataPtr, &msg_len);
                timer_ptr = (stack_timer_struct*) get_local_para_ptr(msg->oslDataPtr, &msg_len);
                if (base_timer_ptr == timer_ptr)
                {
                    stack_is_time_out_valid(base_timer_ptr);
                    stack_process_time_out(base_timer_ptr);
                    /* msg is invalid, can discard it */
                    return 0;
                }
            }
                break;

            default:
                break;
        }
    }
    /* msg is valid, can't discard */
    return 1;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_frm_fetch_msg_from_extQ_to_circularQ
 * DESCRIPTION
 *  fetch the message from external queue and put
 *  in the circular queue.
 *  (*) Need to set my_index & mmi_ext_qid before using
 *  this function
 * PARAMETERS
 *  void
 * RETURNS
 *  1 - the message is invalid, and discard the message
 *  0 - the message is vaild
 *****************************************************************************/
void mmi_frm_fetch_msg_from_extQ_to_circularQ(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    MYQUEUE Message;
    U32 my_index;
    U32 queue_node_number = 0;
    MYQUEUE checkBaseNode = {0};
    U8 flag = 0;
    ilm_struct ilm_ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (IsInNVRAMProcedure() == MMI_FALSE)
    {
        /*
         * If not in NVRAM access procedure,
         * receive the message from MMI queue and put in circular queue 
         */
        msg_get_ext_queue_info(mmi_ext_qid, &queue_node_number);
        while ((queue_node_number > 0) && !OslIsCircularQFull())
        {
            OslReceiveMsgExtQ(mmi_ext_qid, &Message);
            OslGetMyTaskIndex(&my_index);
            OslStackSetActiveModuleID(my_index, MOD_MMI);
            OslLookUpLastCircularQMsg((void*)&checkBaseNode);

            if (mmi_frm_check_is_valid_msg(&checkBaseNode, &Message) == 1)
            {
                /* put Message in circular queue */
                ilm_ptr.src_mod_id = Message.src_mod_id;
                ilm_ptr.dest_mod_id = Message.dest_mod_id;
                ilm_ptr.msg_id = Message.msg_id;
                ilm_ptr.sap_id = Message.sap_id;
                ilm_ptr.local_para_ptr = Message.local_para_ptr;
                ilm_ptr.peer_buff_ptr = Message.peer_buff_ptr;

                flag = OslWriteCircularQ(&ilm_ptr);
                MMI_ASSERT(flag == 1);
                /* TIMER use special data in the local_para_ptr field. Can NOT treat as general ILM */
                if (Message.src_mod_id != MOD_TIMER)
                {
                    hold_local_para(ilm_ptr.local_para_ptr);
                    hold_peer_buff(ilm_ptr.peer_buff_ptr);
                }
            }
            OslFreeInterTaskMsg(&Message);

            msg_get_ext_queue_info(mmi_ext_qid, &queue_node_number);
        }
    }
}

#endif /* MMI_ON_WIN32 */ 


/*****************************************************************************
 * FUNCTION
 *  mmi_frm_power_on_set_mode
 * DESCRIPTION
 *  Power on set flight mode before initializa all applications
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_frm_power_on_set_mode(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifdef __FLIGHT_MODE_SUPPORT__
    /* send the mode to L4C ASAP to speed up the L4C startup time */
    if (g_phnset_cntx.curFlightMode == FLIGHTMODE_SILENT)
    {
        mmi_flight_mode_set_mode(1);
    }
    else if (g_phnset_cntx.curFlightMode == FLIGHTMODE_OFF)
    {
    #ifdef __MMI_WLAN_FEATURES__
        if (mmi_netset_get_active_preferred_mode() == P_WLAN_ONLY)
            mmi_flight_mode_set_mode(1);
	else
    #endif /* __MMI_WLAN_FEATURES__ */
        mmi_flight_mode_set_mode(0);
    }
    else
    {
        /* display qurey screen after InitializeAll */
    }
#endif /* __FLIGHT_MODE_SUPPORT__ */
}


/*****************************************************************************
 * FUNCTION
 *  mmi_frm_power_on_init_procedure
 * DESCRIPTION
 *  Power on initializations
 * PARAMETERS
 *  void
 * RETURNS
 *  void

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -