📄 event_handler.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* Event_handler.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* This file is intends for protocol/keypad/interrupt event handler .
*
* Author:
* -------
* Xiaodong Wang (mbj06019)
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Log$
*
* removed!
* removed!
* call mmi_frm_clear_all_slave_protocol_event_handler() in mmi_frm_clear_all_protocol_event_handler()
*
* removed!
* removed!
* Remove duplicated interfaces
*
* removed!
* removed!
* Change the mechanism in mmi_frm_execute_current_protocol_handler()
*
* removed!
* removed!
* created by clearfsimport
*
* removed!
* removed!
*
*
* removed!
* removed!
* created by clearfsimport
*
* removed!
* removed!
* Add event handler trace
*
* removed!
* removed!
* Add compile option for filemanage message
*
* removed!
* removed!
* New file for processing event handlers
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#include "mmi_include.h"
#include "FrameworkGprot.h"
#include "FrameworkProt.h"
#include "ProtocolEvents.h"
#include "CommonScreens.h"
#include "Wapadp.h"
#include "BTMMIOppGprots.h"
/*****************************************************************************
* Define
*****************************************************************************/
#define MMI_EVENT_INVALID 0
#define INTERRUPT_EVENT_GREOUP_SIZE (4)
#define IS_INTERRUPT_EVENT_GROUP(x) (((x)&MMI_INT_EVENT_GROUP_MASK) == MMI_INT_EVENT_GROUP_MASK)
#define MMI_FRM_PRE_INT_HDLR 1
#define MMI_FRM_POST_INT_HDLR 2
/*****************************************************************************
* Typedef
*****************************************************************************/
#ifdef MMI_FRM_BACKWARD_COMPATIBLE_EVENTS
typedef struct
{
U16 groupID;
U16 eventID[INTERRUPT_EVENT_GREOUP_SIZE];
} InterruptGroupInfo;
#endif /* MMI_FRM_BACKWARD_COMPATIBLE_EVENTS */
typedef struct _mmi_frm_int_mask_hdlr_struct
{
mmi_frm_int_event_type event_mask;
interrupt_event_hdlr int_func_ptr;
interrupt_event_hdlr post_int_func_ptr;
} mmi_frm_int_mask_hdlr_struct;
typedef struct
{
U16 event_id;
mmi_frm_int_event_type int_event_macro;
} mmi_frm_int_event_convert_struct;
typedef enum
{
MMI_FRM_INT_EVENT_SPECIFIC,
MMI_FRM_INT_EVENT_GENERAL,
MMI_FRM_INT_EVENT_TYPE_NUM
} mmi_frm_int_event_type_list_enum;
/*****************************************************************************
* Global Variable
*****************************************************************************/
U16 maxProtocolEvent;
U16 usedProtocolEvent;
PseventInfo protocolEventHandler[MAX_PROTOCOL_EVENT];
#ifdef __MMI_DUAL_SIM__
U16 maxSlaveProtocolEvent;
U16 usedSlaveProtocolEvent;
PseventInfo SlaveProtocolEventHandler[MAX_SLAVE_PROTOCOL_EVENT];
#endif /* __MMI_DUAL_SIM__ */
#ifdef MMI_FRM_BACKWARD_COMPATIBLE_EVENTS
U16 maxInterruptEvent;
PsInteventInfo interruptEventHandler[MAX_INTERRUPT_EVENT];
#endif /* MMI_FRM_BACKWARD_COMPATIBLE_EVENTS */
/*****************************************************************************
* Local Variable
*****************************************************************************/
static mmi_frm_int_mask_hdlr_struct mmi_frm_int_mask_hdlr[MMI_FRM_INT_EVENT_TYPE_NUM];
#ifdef MMI_FRM_BACKWARD_COMPATIBLE_EVENTS
static const InterruptGroupInfo interruptGroupEventTable[] =
{
{MMI_SMS_INT_EVENT_GROUP,
{PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND,
PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND,
PRT_MSG_ID_MMI_SMS_MSG_WAITING_IND,
0 /* end at 0 */
}
}
#if defined(__MMI_FILE_MANAGER__)
,{MMI_CARD_PLUG_EVENT_GROUP,
{PRT_MMI_FMGR_CARD_PLUG_IN_IND,
PRT_MMI_FMGR_CARD_PLUG_OUT_IND,
0 /* end at 0 */
}
}
#endif /* __MMI_FILE_MANAGER__ */
};
#endif /* MMI_FRM_BACKWARD_COMPATIBLE_EVENTS */
static const mmi_frm_int_event_convert_struct mmi_frm_int_event_battery_table[] =
{
{PMIC_CHARGER_IN, MMI_FRM_INT_CHARGER_IN},
{PMIC_CHARGER_OUT, MMI_FRM_INT_CHARGER_OUT},
{PMIC_CHARGE_COMPLETE, MMI_FRM_INT_CHARGE_COMPLETE},
{PMIC_USB_CHARGER_IN, MMI_FRM_INT_USB_CHARGER_IN},
{PMIC_USB_CHARGER_OUT, MMI_FRM_INT_USB_CHARGER_OUT},
{PMIC_USB_NO_CHARGER_IN, MMI_FRM_INT_USB_NO_CHARGER_IN},
{PMIC_USB_NO_CHARGER_OUT, MMI_FRM_INT_USB_NO_CHARGER_OUT}
};
static const mmi_frm_int_event_convert_struct mmi_frm_int_event_convert_table[] =
{
{PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND, MMI_FRM_INT_SMS_DELIVER},
{PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND, MMI_FRM_INT_SMS_STATUS_REPORT},
{PRT_MSG_ID_MMI_SMS_MSG_WAITING_IND, MMI_FRM_INT_SMS_MSG_WAITING},
{PRT_MSG_ID_MMI_SMS_APP_DATA_IND, MMI_FRM_INT_SMS_APP_DATA},
#if defined(__MMI_FILE_MANAGER__)
{PRT_MMI_FMGR_CARD_PLUG_IN_IND, MMI_FRM_INT_FMGR_CARD_PLUG_IN},
{PRT_MMI_FMGR_CARD_PLUG_OUT_IND, MMI_FRM_INT_FMGR_CARD_PLUG_OUT},
#endif /* __MMI_FILE_MANAGER__ */
{MSG_ID_MMI_VOIP_CALL_RING_IND, MMI_FRM_INT_VOIP_CALL_RING},
{MSG_ID_MMI_CC_CALL_RING_IND, MMI_FRM_INT_CC_CALL_RING},
{PRT_L4AUD_AUDIO_PLAY_FINISH_IND, MMI_FRM_INT_AUDIO_PLAY_FINISH}
};
static MMI_BOOL mmi_frm_process_non_mmi_task = MMI_FALSE;
/*****************************************************************************
* Local Function
*****************************************************************************/
/* New interrupt event internal function */
static MMI_BOOL mmi_frm_query_interrupt_event_information(mmi_frm_int_event_type frm_int_event, interrupt_event_hdlr *int_func, interrupt_event_hdlr *post_int_func);
static mmi_frm_int_event_type mmi_frm_interrupt_event_converter(U16 event_id, void *msg);
#ifdef MMI_FRM_BACKWARD_COMPATIBLE_EVENTS
static MMI_BOOL mmi_frm_query_interrupt_handler(U16 event_id, PsIntFuncPtr *func_ptr, PsIntFuncPtr *post_func_ptr);
#endif
/*****************************************************************************
* Extern data and function
*****************************************************************************/
/*****************************************************************************
* FUNCTION
* mmi_frm_execute_current_protocol_handler
* DESCRIPTION
* This function is used for executes current protocol func handler.
* PARAMETERS
* eventID [IN] Unique Protocol/System EventID
* MsgStruct [IN] The pointer to the message.
* mod_src [IN] Source module ID.
* peerBuf [IN] The pointer to the peer buffe.
* RETURNS
* void
*****************************************************************************/
void mmi_frm_execute_current_protocol_handler(U16 eventID, void *MsgStruct, int mod_src, void *peerBuf)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 count = 0;
/* PsExtFuncPtr currFuncPtr = NULL; */
PsExtPeerFuncPtr currFuncPtr = NULL;
#ifdef MMI_FRM_BACKWARD_COMPATIBLE_EVENTS
PsIntFuncPtr IntFunc = NULL, PostIntFunc = NULL;
PsExtPeerIntFuncPtr currInterruptFuncPtr = NULL, currPostInterruptFuncPtr = NULL;
#endif /* MMI_FRM_BACKWARD_COMPATIBLE_EVENTS */
U8 interrup_result = MMI_FALSE; /* False not handle interrupt, True will handle */
/* new interrupt event mechanism */
MMI_BOOL query_result = MMI_FALSE, execute_result = MMI_FALSE;
interrupt_event_hdlr int_func = NULL, post_int_func = NULL;
mmi_frm_int_event_type current_frm_int_event;
#if defined (MMI_EVENT_PROFILING)
kal_uint32 start_tick, end_tick;
static kal_uint32 accu_ticks = 0;
static U32 accu_count = 0;
#endif /* defined (MMI_EVENT_PROFILING) */
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
#ifdef __XHC_APPLICATION__ //xhc start 网络消息钩子,防止与其它第三方应用在网络协议方面冲突
//此处修改只针对07B及以后的版本,07A及更早版本此处将移到了文件Events.c中
if (XHC_execute_protocol_handler(eventID, MsgStruct) == TRUE)
{
return;
}
#endif //__XHC_APPLICATION__ //xhc end
#if defined (MMI_EVENT_PROFILING)
kal_get_time(&start_tick);
#endif
#ifdef __MMI_DUAL_SIM__
if (mod_src == MOD_L4C_2)
{
/* Search events in slave protocol event handler table */
for (count = 0; count < maxSlaveProtocolEvent; count++)
{
if (SlaveProtocolEventHandler[count].eventID == eventID)
{
currFuncPtr = (PsExtPeerFuncPtr) SlaveProtocolEventHandler[count].entryFuncPtr;
if (count > 0)
{ /* improve the search efficiently */
SlaveProtocolEventHandler[count].eventID = SlaveProtocolEventHandler[count - 1].eventID;
SlaveProtocolEventHandler[count].entryFuncPtr = SlaveProtocolEventHandler[count - 1].entryFuncPtr;
SlaveProtocolEventHandler[count - 1].eventID = eventID;
SlaveProtocolEventHandler[count - 1].entryFuncPtr = (PsFuncPtr) currFuncPtr;
}
break;
}
}
}
else
#endif /* __MMI_DUAL_SIM__ */
{
/* Search events in protocol event handler table */
for (count = 0; count < maxProtocolEvent; count++)
{
if (protocolEventHandler[count].eventID == eventID)
{
currFuncPtr = (PsExtPeerFuncPtr) protocolEventHandler[count].entryFuncPtr;
if (count > 0)
{ /* improve the search efficiently */
protocolEventHandler[count].eventID = protocolEventHandler[count - 1].eventID;
protocolEventHandler[count].entryFuncPtr = protocolEventHandler[count - 1].entryFuncPtr;
protocolEventHandler[count - 1].eventID = eventID;
protocolEventHandler[count - 1].entryFuncPtr = (PsFuncPtr) currFuncPtr;
}
break;
}
}
}
#if defined (MMI_EVENT_PROFILING)
PRINT_INFORMATION_2(MMI_FW_TRC_G1_FRM, "ExecuteCurrProtocolHandler count = %d", count);
accu_count += count;
#endif /* defined (MMI_EVENT_PROFILING) */
#ifdef MMI_FRM_BACKWARD_COMPATIBLE_EVENTS
/* Old Search events in interrupt event handler table */
mmi_frm_query_interrupt_handler(eventID, &IntFunc, &PostIntFunc);
currInterruptFuncPtr = (PsExtPeerIntFuncPtr) IntFunc;
currPostInterruptFuncPtr = (PsExtPeerIntFuncPtr) PostIntFunc;
/* Old interruption mechanism */
if (currInterruptFuncPtr)
{
MMI_TRACE(MMI_FW_TRC_G1_FRM, MMI_FRM_INFO_EVENT_EXECURPTO_INTP_HDLR, eventID);
interrup_result = (*currInterruptFuncPtr) (MsgStruct, mod_src, peerBuf);
}
#endif /* MMI_FRM_BACKWARD_COMPATIBLE_EVENTS */
/* New Search events in interrupt event handler mask table */
current_frm_int_event = mmi_frm_interrupt_event_converter(eventID, MsgStruct);
if (current_frm_int_event > 0)
{
query_result = mmi_frm_query_interrupt_event_information(current_frm_int_event, &int_func, &post_int_func);
}
if (query_result && int_func)
{
/* New interruption mechanism */
execute_result = (*int_func)(current_frm_int_event);
}
/* if(currFuncPtr) */
if ((currFuncPtr) && (!interrup_result) && (!execute_result))
{
MMI_TRACE(MMI_FW_TRC_G1_FRM, MMI_FRM_INFO_EVENT_EXECURPTO_HDLR, eventID);
/* (*currFuncPtr)(MsgStruct,mod_src); */
(*currFuncPtr) (MsgStruct, mod_src, peerBuf);
}
else
{
MMI_TRACE(MMI_TRACE_WARNING, MMI_FRM_INFO_EVENT_EXECURPTO_NO_HDLR, eventID);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -