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

📄 mmitask.c

📁 MTK平台QQ移植
💻 C
📖 第 1 页 / 共 5 页
字号:

#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

#if defined(__MMI_LANGLN__)
extern mmi_langln_init(void);
#endif 

#ifdef OBIGO_Q05A
extern void wap_task_init(void);
#endif
#ifdef __MMI_MMS_BGSR_SUPPORT__
extern void mmi_mms_bgsr_init(void);
#endif /*__MMI_MMS_BGSR_SUPPORT__*/

#ifdef __MMI_DUAL_SIM_MASTER__ 
extern void MMI_MTPNP_master_init(void);
#endif	/* __MMI_DUAL_SIM_MASTER__  */

#ifdef __MMI_DUAL_SIM_DUAL_CALL_SLAVE__
extern void MMI_MTPNP_slave_init(void);
#endif	/* __MMI_DUAL_SIM_DUAL_CALL_SLAVE__ */


#ifdef __MMI_BOOTUP_SCALE__
#define MMI_APP_INIT(func) {U32 start_time, end_time;\
                            S8 func_name[] = #func;\
                            kal_get_time(&start_time);\
                            func;\
                            kal_get_time(&end_time);\
                            kal_sleep_task(50);\
                            Trace2(TRACE_FUNC, "[BOOTUP SCALE]Function: %s Time: %d", func_name, (end_time-start_time));\
                           }
#else
#define MMI_APP_INIT(func)  func
#endif

/*****************************************************************************
 * 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                                                      */
    /*----------------------------------------------------------------*/
    mmi_mutex_trace = kal_create_mutex("mmi_trace");

    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
 *  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 */
#if defined(__MMI_DUAL_SIM_MASTER__) || defined(__MMI_DUAL_SIM_DUAL_CALL_SLAVE__)
#ifdef __QUERY_PSN_SUPPORT__
	EntryQueryRegisterSW();
#else	/* __QUERY_PSN_SUPPORT__ */
	MTPNP_AD_Bootup();
#endif	/* __QUERY_PSN_SUPPORT__ */
#else	/* __MMI_DUAL_SIM_MASTER__ || __MMI_DUAL_SIM_DUAL_CALL_SLAVE__ */
#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__ */ 
#endif	/* __MMI_DUAL_SIM_MASTER__  || __MMI_DUAL_SIM_DUAL_CALL_SLAVE__ */
    /* end, diamond */
}


/*****************************************************************************
 * 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);
        }
    }
}


/*****************************************************************************
 * 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
 *****************************************************************************/
void mmi_frm_power_on_init_procedure(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    static U8 bInit = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (!bInit)
    {
        MMI_APP_INIT(InitializeAll());
        OslDumpDataInFile();
        MMI_APP_INIT(InitNvramData());

        bInit = 1;
    }
}


/*****************************************************************************
 * FUNCTION
 *  MMI_task
 * DESCRIPTION
 *  Entry function for Protocol task
 *  
 *  This receives protocol task events from the stack and forwards it to
 *  MMI task.
 * PARAMETERS
 *  entry_param     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void MMI_task(oslEntryType *entry_param)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    MYQUEUE Message;
    oslMsgqid qid;

    U32 my_index;
    U32 count = 0;
    U32 queue_node_number = 0;


    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    qid = task_info_g[entry_param->task_indx].task_ext_qid;
    mmi_ext_qid = qid;
    InitEventHandlersBeforePowerOn();

#if defined (__MMI_DUAL_SIM_MASTER__)
    MMI_MTPNP_master_init();
#endif

#ifdef __MMI_DUAL_SIM_DUAL_CALL_SLAVE__
    MMI_MTPNP_slave_init();
#endif	/* __MMI_DUAL_SIM_DUAL_CALL_SLAVE__ */

    while (1)
    {
        {

            if (g_keypad_flag == MMI_TRUE)
            {
                mmi_frm_key_handle(NULL);
            }

            /* Leo start 20050825 */
/********************************************************************
*   Check if number of events in queue increases.
*   If yes, clear more external queue events, else clear less external queue events.
*   At lease clear one external queue event.
********************************************************************/
            /* Get Total count in external queue */
            msg_get_ext_queue_info(mmi_ext_qid, &queue_node_number);

            if ((queue_node_number == 0) && (OslNumOfCircularQMsgs() == 0) && (g_keypad_flag == MMI_FALSE))
            {
                U8 flag = 0;
                ilm_struct ilm_ptr;

                /* MMI task suspends for the queue */
                OslReceiveMsgExtQ(qid, &Message);
                OslGetMyTaskIndex(&my_index);
                OslStackSetActiveModuleID(my_index, MOD_MMI);

                /* 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);
                }
            }
            else
            {
                mmi_frm_fetch_msg_from_extQ_to_circularQ();
            }

            count = OslNumOfCircularQMsgs();
            while (count > 0)
            {
                OslGetMyTaskIndex(&my_index);
                OslStackSetActiveModuleID(my_index, MOD_MMI);

                if (OslReadCircularQ(&Message))
                {
                    CheckAndPrintMsgId((U16) (Message.msg_id));

                    if (Message.dest_mod_id == MOD_WAP)
                    {
                    #if defined(JATAAYU_SUPPORT) || defined(OBIGO_Q05A)
                        extern void mmi_wap_handle_msg(void *msgPtr);

                        mmi_wap_handle_msg((void*)&Message);
                    #endif /* JATAAYU_SUPPORT */ 
                    }
                    else
                    {
                        switch (Message.msg_id)
                        {
                     #if (defined(__MMI_DUAL_SIM_MASTER__) || defined(__MMI_DUAL_SIM_DUAL_CALL_SLAVE__)) && !defined (__MMI_DUAL_SIM_SINGLE_CALL__)
                            case MSG_ID_MTPNP:
                                {
                                MTPNP_AD_EventHandler((void *)Message.oslDataPtr);
                                }
                                break;
			        #endif	/* defined(__MMI_DUAL_SIM_MASTER__) || defined(__MMI_DUAL_SIM_DUAL_CALL_SLAVE__) */
                    #ifdef __MMI_DUAL_SIM_DUAL_CALL_SLAVE__
                            case MSG_ID_SLAVE_STARTUP_REQ:
                                MTPNP_PFAL_slave_MMI_task_boot();
                                break;
                            case MSG_ID_VEINT:
                                MTPNP_Send_VEINT();
                                break;
                    #endif	/* __MMI_DUAL_SIM_DUAL_CALL_SLAVE__ */
                            case MSG_ID_TIMER_EXPIRY:
                            {
                                kal_uint16 msg_len;

                                EvshedMMITimerHandler(get_local_para_ptr(Message.oslDataPtr, &msg_len));
                            }
                                break;

                        #ifdef __MMI_DUAL_SIM_SINGLE_CALL__
                            case MSG_ID_MMI_EQ_PWNON_DUAL_SIM_IND:
                                MTPNP_AD_Pwnon_Dual_SIM();
                                break;
                        #endif /* __MMI_DUAL_SIM_SINGLE_CALL__ */

                            case MSG_ID_MMI_EQ_POWER_ON_IND:
                            {
                                mmi_eq_power_on_ind_struct *p = (mmi_eq_power_on_ind_struct*) Message.oslDataPtr;

                                /* To initialize data/time */
                                SetDateTime((void*)&(p->rtc_time));
                                gdi_init();

                                g_pwr_context.PowerOnMMIStatus = MMI_POWER_ON_INDICATION;       /* 0x01: POWER_ON_KEYPAD indication */
                            #ifdef __MMI_DUAL_SIM_SINGLE_CALL__                            
                                g_pwr_context_2.PowerOnMMIStatus = MMI_POWER_ON_INDICATION;
                            #endif

                            #ifdef __MMI_TVOUT__
                                mmi_phnset_tvout_check_pwron_start();
                            #endif

                                switch (p->poweron_mode)
                                {
                                    case POWER_ON_KEYPAD:

⌨️ 快捷键说明

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