123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578 |
- /*****************************************************************************
- ** File: main_app_external.c
- **
- ** Description:
- **
- ** Copyright(c) 2008 Sunmedia Technologies - All Rights Reserved
- **
- ** Author : qin.he
- **
- ** $Id: $
- *****************************************************************************/
- /*header file*/
- #include <sys/ioctl.h>
- #include "umf_debug.h"
- #include "main_app.h"
- #include "app_event.h"
- #include "sysapp_table.h"
- #include "sysapp_if.h"
- #include "app_msg_filter.h"
- #include "app_msg_filter_tbl.h"
- #include "sysapp_timer.h"
- #include "gobj_datastruct.h"
- #include "al_fw.h"
- #include "kmf_ioctl.h"
- #include "ap_extern.h"
- #include "util_ioctl.h"
- #include "drv_blt_interface.h"
- #include "osd_lib.h"
- #ifdef CONFIG_ATV_SUPPORT
- #include "atv_guiobj_table.h"
- #endif
- #include "app_menumgr.h"
- #include "app_audio.h"
- #include "app_video.h"
- #include "app_global.h"
- #include "app_gui.h"
- #include "app_power_control.h"
- #include "app_systime.h"
- #include "app_data_setting.h"
- #include "main_guiobj_table.h"
- #include "app_guiobj_source.h"
- #include "app_guiobj_adjust.h"
- #include "app_guiobj_mainmenupop.h"
- //#include "app_guiobj_mainmenu.h"
- //#include "app_guiobj_fm_factory.h"
- #include "app_guiobj_sleeptimer.h"
- #include "pin_config.h"
- #ifdef CONFIG_SUPPORT_MEDIA_AUTO_PLAY
- #include <dirent.h> // DIR need
- #include "MM_media_auto_play.h"
- #endif
- #ifdef SUPPORT_CEC_TV
- #include "umf_cec.h"
- #endif
- #include "app_usb_upgrade.h"
- #ifdef SUPPORT_WAKEUP_TIMER_IN_STANDBY
- //#include "app_guiobj_channel.h"
- #endif
- #include "app_factory.h"
- #include "atv_app.h"
- #ifdef CONFIG_MEDIA_ENABLE
- #include "MM_popmsg_gui.h"
- #endif
- /*----------------Net------------------*/
- #ifdef CONFIG_NET_SUPPORT
- #include "net_daemon.h"
- #include "net/net_app/net_config.h"
- #include "app_net_instance.h"
- #ifdef SUPPORT_NET_TESTING
- #include "net/net_app/net_test.h"
- #endif
- #ifdef CONFIG_NET_ET_SUPPORT
- #include "cbk_event.h"
- #include "net_daemon.h"
- #include "net/et/libet.h"
- #endif
- #ifdef SAMBA_SUPPORT
- #include "app_network.h"
- #endif
- #ifdef CONFIG_NET_N32_SUPPORT
- #include "net/dlmgr/dlmgr_if.h"
- #include "net/net_app/net_config.h"
- #endif
- #ifdef NET_WIFI_SUPPORT
- #include "dvb_gui_object_wifi_list.h"
- #endif
- /*+++++++++++++++++NET++++++++++++++++++++*/
- #include "platform_venc.h"
- #include "net/net_app/net_config.h"
- #include "net_daemon.h"
- #ifdef SUPPORT_NET_TESTING
- #include "net/net_app/net_test.h"
- #endif
- #include "network_app.h"
- #endif
- #include "app_clone_data.h"
- #include "main_app_external.h"
- #ifdef SUPPORT_FACTORY_AUTO_TEST
- //#include "Debug_msg.h"
- #endif
- #ifdef SUPPORT_SHOP_DEMO_MODE
- #include "app_guiobj_picture.h"
- #endif
- #ifdef SUPPORT_LED_FLASH
- #include "app_led_control.h"
- #endif
- #include "mid_partition_list.h"
- #include "app_guiobj_hdmilink.h"
- #include "customize.h"
- #if defined(CONFIG_AUTO_USB_STORE_IRSEQ) && defined(CONFIG_QSD_AUTOIR)
- #include "umf_automation.h"
- #endif
- #ifdef CONFIG_BLUETOOTH_SUPPORT
- #include "al_bluetooth.h"
- #endif
- #if defined(CONFIG_BT_RDA5856)||defined(CONFIG_BT_POL6556)
- #include "app_bt.h"
- #endif
- #define MAIN_APP_DEBUG
- #ifdef MAIN_APP_DEBUG
- #undef mainapp_printf
- #define mainapp_printf(fmt, arg...) UMFDBG(0,"[MAINAPP]:"fmt, ##arg)
- #else
- #define mainapp_printf(fmt, arg...) ((void) 0)
- #endif
- #define NUM_RESEND_MESSAGE_TYPE (DMN_EVENT_DEVICE_DETECT_MAX-DMN_EVENT_DEVICE_DETECT_MIN-1)
- #define NUM_RESEND_MESSAGE_OF_TYPE (10)
- #ifdef CONFIG_SUPPORT_MEDIA_AUTO_PLAY
- #define MAX_COM_BUF_SIZE 2048
- #define INTERNAL_COM_DISK_NAME_LEN (15)
- #ifdef CONFIG_SUPPORT_PARTITIONNUM_MAX
- #define MAX_COM_PARTITION_NUM (20)
- #else
- #define MAX_COM_PARTITION_NUM (8)
- #endif
- #define MM_COMMON_AUTO_PLAY "AutoPlay"
- static char PlayComFilePath[MAX_COM_BUF_SIZE];
- static UINT8 gb_NeedAutoPlay = FALSE;
- #endif
- #ifdef CONFIG_NET_SUPPORT
- extern Common_SysSet_NetETConfigStorage_t stNetConfigStorage;
- #endif
- #ifdef SUPPORT_WAKEUP_TIMER_IN_STANDBY
- extern Boolean g_fRecorderNeedEntryStandby;
- #endif
- #ifdef AC_ON_AUTO_GET_TIME
- extern Boolean g_fBackgroundGetTime;
- #endif
- #if defined(CONFIG_BT_RDA5856)
- extern Boolean g_SystemPowerOnReadyNeedReconnectBT;
- extern UINT8 g_BT_HasHeart;
- #endif
- #ifdef CONFIG_NET_SUPPORT
- extern int gMsgHandle;
- #ifdef CONFIG_NET_ET_SUPPORT
- static void _MAINAPP_EtMountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum);
- static void _MAINAPP_EtUnmountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum);
- #endif
- #ifdef CONFIG_NET_N32_SUPPORT
- static void _MAINAPP_N32MountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum);
- static void _MAINAPP_N32UnmountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum);
- #endif
- #ifdef CONFIG_NET_ET_SUPPORT
- MainAppUIEventHandlerInfo_t stUIEventHandlerInfo =
- {
- STATUS_NULL,
- UI_EVENT_NULL,
- TOTAL_SYS_APP_SIZE
- };
- #endif
- #endif
- GUI_Object_Definition_t* MAIN_APP_GUI_Obj_List[MAINAPP_GUIOBJ_MAX] =
- {
- };
- /* global variables */
- static Boolean g_bPowerOffFlag = FALSE;
- static UINT32 gdResentMessage[NUM_RESEND_MESSAGE_TYPE][NUM_RESEND_MESSAGE_OF_TYPE] = {{0}};
- static UINT32 gdResentParam[NUM_RESEND_MESSAGE_TYPE][NUM_RESEND_MESSAGE_OF_TYPE] = {{0}};
- extern Boolean gUSBUpgradeBinIsSupperBin;
- static Boolean g_CheckUpgrade = FALSE;//for mantis 0164559 @20120204
- #ifdef SUPPORT_FACTORY_AUTO_TEST
- typedef struct{
- UINT32 dResendMessage;
- UINT32 dResendMessageParm;
- }sFACResentMessage;
- static sFACResentMessage gFACTESTResentMessage = {0,0};
- static Boolean AcPowerOnNoRomBinFlag = FALSE;
- #endif
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- extern UINT8 IsKeypadPowerOnPressRepeat;
- UINT32 USB_ATTACHED = FALSE;
- #endif
- static void _MAINAPP_ResendEventInTransition(void)
- {
- UINT32 dActiveSysApp = 0;
- UINT8 u8Count1 = 0;
- UINT8 u8Count2 = 0;
- switch (MAINAPP_GetActiveSystemAppIndex(&dActiveSysApp))
- {
- case MAIN_APP_IN_TRANSITION:
- mainapp_printf(" In Transition State, wait and retry.\n");
- break;
- case MAIN_APP_SUCCESS:
- for (u8Count1 = 0; u8Count1 < NUM_RESEND_MESSAGE_TYPE; u8Count1++)
- {
- for (u8Count2 = 0; u8Count2 < NUM_RESEND_MESSAGE_OF_TYPE; u8Count2++)
- {
- if (gdResentMessage[u8Count1][u8Count2] > 0)
- {
- MSG_FILTER_DispatchMessage(gdResentMessage[u8Count1][u8Count2], gdResentParam[u8Count1][u8Count2]);
- }
- }
- }
- break;
- default:
- mainapp_printf("[%s] In Invalid State\n",__FUNCTION__);
- for (u8Count1 = 0; u8Count1 < NUM_RESEND_MESSAGE_TYPE; u8Count1++)
- {
- for (u8Count2 = 0; u8Count2 < NUM_RESEND_MESSAGE_OF_TYPE; u8Count2++)
- {
- gdResentMessage[u8Count1][u8Count2] = 0;
- gdResentParam[u8Count1][u8Count2] = 0;
- }
- }
- break;
- }
- }
- static void _MAINAPP_SetEventInTransition(UINT32 dMessage, UINT32 dParam)
- {
- UINT8 u8Count = 0;
- if (((dMessage-DMN_EVENT_DEVICE_DETECT_MIN) > 0)
- && ((dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1) < NUM_RESEND_MESSAGE_TYPE))
- {
- for (u8Count = 0; u8Count < NUM_RESEND_MESSAGE_OF_TYPE; u8Count++)
- {
- //zhongbaoxing added @20120313. no need to record the exist messages
- if((gdResentMessage[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] == dMessage)
- &&(gdResentParam[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] == dParam))
- {
- break;
- }
- if (gdResentMessage[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] == 0)
- {
- gdResentMessage[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] = dMessage;
- gdResentParam[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] = dParam;
- break;
- }
- }
- }
- }
- static void _MAINAPP_ClearEventInTransition(UINT32 dMessage, UINT32 dParam)
- {
- UINT8 u8Count = 0;
- if (((dMessage-DMN_EVENT_DEVICE_DETECT_MIN) > 0)
- && ((dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1) < NUM_RESEND_MESSAGE_TYPE))
- {
- for (u8Count = 0; u8Count < NUM_RESEND_MESSAGE_OF_TYPE; u8Count++)
- {
- if ((gdResentMessage[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] == dMessage)
- &&(gdResentParam[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] == dParam))
- {
- gdResentMessage[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] = 0;
- gdResentParam[dMessage-DMN_EVENT_DEVICE_DETECT_MIN-1][u8Count] = 0;
- break;
- }
- }
- }
- }
- /*****************************************************************************
- ** FUNCTION : _MAINAPP_GUIFeedbackEventHandler
- **
- ** DESCRIPTION :
- ** main app feedback event handler
- **
- ** PARAMETERS :
- ** dMessage: feadback message
- ** dParam: feadback message's paramter
- **
- ** RETURN VALUES:
- ** None
- *****************************************************************************/
- void _MAINAPP_GUIFeedbackEventHandler(UINT32 dMessage, UINT32 dParam)
- {
- switch(dMessage)
- {
- default:
- mainapp_printf(" Unknown GUI feedback message received.\n");
- break;
- }
- return;
- }
- /*****************************************************************************
- ** FUNCTION : _MAINAPP_UIEventHandler
- **
- ** DESCRIPTION :
- ** main app UI event handler
- **
- ** PARAMETERS :
- ** dMessage: UI message
- ** dParam: UI message's paramter
- **
- ** RETURN VALUES:
- ** None
- *****************************************************************************/
- int _MAINAPP_UIEventHandler(UINT32 dMessage, UINT32 dParam)
- {
- UINT32 dIndex = 0;
- APP_Source_Type_t eSourceType;
- eSourceType = APP_SOURCE_MAX;
- if (MAIN_APP_SUCCESS == MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- if((dMessage == UI_EVENT_POWER)||(dMessage == UI_EVENT_KEYPAD_POWER))
- {
- if (SYSAPP_GOBJ_GUIObjectExist(dIndex, APP_GUIOBJ_SLEEP_INFO))//close sleeptimer menu
- {
- APP_GUIOBJ_SleepTimer_Reset();
- SYSAPP_GOBJ_DestroyGUIObject(dIndex, APP_GUIOBJ_SLEEP_INFO);
- return MAIN_APP_SUCCESS;
- }
- #ifdef SUPPORT_POWERAGAIN_CONFIRM_POWEROFF
- if ((!SYSAPP_GOBJ_GUIObjectExist(dIndex, APP_GUIOBJ_MAINMENUPOP)
- || APP_GUIOBJ_MainPopMsg_GetPopType() != MAINPOPMSG_SHOW_CONFIRM_POWER)
- && (dParam == AL_POWER_STATE_CONFIRM))//no auto power off or reset power
- {
- SYSAPP_IF_SendGlobalEventWithIndex(dIndex, APP_GLOBAL_EVENT_CONFIRM_POWER|PASS_TO_SYSAPP, 0);
- return MAIN_APP_SUCCESS;
- }
- #endif
- }
- APP_GUIOBJ_Source_GetCurrSource(&eSourceType);
- }
- if (MAIN_APP_SUCCESS == MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- #ifdef CONFIG_SUPPORT_OTA_UPGRADE
- if (SYS_APP_DVB == dIndex)
- {
- if (SYSAPP_GOBJ_GUIObjectExist(dIndex, DVB_GUIOBJ_OTA_UPGRADE_PROGRESS) && (AL_POWER_STATE_MAX != dParam))
- {
- return MAIN_APP_SUCCESS;
- }
- }
- #endif
- #ifdef CONFIG_SUPPORT_USB_UPGRADE
- if (SYSAPP_GOBJ_GUIObjectExist(dIndex, APP_GUIOBJ_SOFTWARE_UPGRADE))
- {
- return MAIN_APP_SUCCESS;
- }
- #endif
- }
- switch (dMessage)
- {
- case UI_EVENT_POWER:
- #if defined(CONFIG_BT_RDA5856)||defined(CONFIG_BT_POL6556)
- APP_BT_DisConnect_CurrentBT();
- #endif
- #ifdef SUPPORT_WAKEUP_TIMER_IN_STANDBY
- if (APP_WAKEUP_GetBootFlag() == TRUE)
- {
- #ifdef AC_ON_AUTO_GET_TIME
- if (g_fBackgroundGetTime == TRUE)
- {
- g_fBackgroundGetTime = FALSE;
- }
- #endif
- g_fRecorderNeedEntryStandby = FALSE;
- /*< light backlight */
- APP_WAKEUP_RealPowerUp();
- return MAIN_APP_SUCCESS;
- }
- else
- #endif
- {
- #ifdef CHECK_USB_FOR_SLEEP_AND_STANDBY
- /*
- * if the POWER event is from handset, check usb status for schedruler rec
- */
- if (APP_IsUIMessageType())
- {
- USB_PvrSt_t USB_ST = USB_MSG_SUCCESS;
- UINT32 dActiveSysApp = 0;
- USB_ST = APP_CheckUSBStatus();
- if (MAINAPP_GetActiveSystemAppIndex(&dActiveSysApp) == MAIN_APP_SUCCESS)
- {
- UINT32 u32PopMsgName = POPMSG_PROMPT_NO_PROG;
- #ifdef CONFIG_MEDIA_ENABLE
- UINT32 u32MMPopName = FILE_POP_PLAYBACK_NONE;
- if (SYS_APP_FILE_PLAYER == dActiveSysApp)
- {
- u32MMPopName = MM_PopMsg_GetCurrentPopup();
- }
- else
- #endif
- if ((SYS_APP_ATV== dActiveSysApp)
- || (SYS_APP_DVB== dActiveSysApp))
- {
- APP_GUIOBJ_PopMsg_GetMsgDialogType(&u32PopMsgName);
- }
- if ((u32PopMsgName != POPMSG_CONFIRM_INSERT_USB)
- && (u32PopMsgName != POPMSG_CONFIRM_INVALID_USB)
- #ifdef CONFIG_MEDIA_ENABLE
- && (u32MMPopName != FILE_POP_PVR_INSERT_USB_CONFIRM)
- && (u32MMPopName != FILE_POP_PVR_INVALID_USB_CONFIRM)
- #endif
- )
- {
- switch(USB_ST)
- {
- case USB_MSG_SUCCESS:
- break;
- case USB_MSG_FAIL_NO_STORAGE:
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, APP_GLOBAL_EVENT_PVR_INSERT_USB_CONFIRM|PASS_TO_SYSAPP, 0);
- return MAIN_APP_SUCCESS;
- default:
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, APP_GLOBAL_EVENT_PVR_INVALID_USB_CONFIRM|PASS_TO_SYSAPP, 0);
- return MAIN_APP_SUCCESS;
- }
- }
- }
- }
- #endif
- AL_Setting_Read(APP_Data_UserSetting_Handle(), SYS_SET_ID_FACTUSER, 0,
- sizeof(APP_SETTING_FactoryUser_t), &(g_stFactoryUserData));
- if (g_stFactoryUserData.n_FactSet_BurningMode == 1)
- {
- return MAIN_APP_SUCCESS;
- }
- mainapp_printf(" UI_EVENT_POWER received.\n");
- #ifdef CONFIG_AUTO_USB_STORE_IRSEQ
- extern int AUTO_IF_Stop(void);
- AUTO_IF_Stop();
- #endif
- #ifdef SUPPORT_WAKEUP_TIMER_IN_STANDBY
- #ifdef CONFIG_SUPPORT_USB_UPGRADE
- extern bool g_bUpgradeForceStandby;
- #endif
- if((APP_WAKEUP_CheckTimer() == FALSE)
- #ifdef CONFIG_SUPPORT_USB_UPGRADE
- || (g_bUpgradeForceStandby == TRUE)
- #endif
- )
- #endif
- {
- //zhongbaoxing added to mute the video for mantis 0166639 @20120224
- #ifdef CONFIG_SUPPORT_SUBTITLE
- if (MAIN_APP_SUCCESS == MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- if (dIndex == SYS_APP_DVB)
- {
- DVBApp_DataApplicationSwitch(OSD2CTRLMDL_DISABLE|OSD2CTRLMDL_SUB);
- }
- }
- #endif
- #ifdef CONFIG_SUPPORT_TTX
- if (MAIN_APP_SUCCESS == MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- #ifdef CONFIG_ATV_SUPPORT
- if(SYS_APP_ATV == dIndex)
- {
- if (SYSAPP_GOBJ_GUIObjectExist(dIndex, ATV_GUIOBJ_TTX))
- {
- SYSAPP_GOBJ_DestroyGUIObject(dIndex, ATV_GUIOBJ_TTX);
- }
- }
- #endif
- }
- #endif
- #ifdef CONFIG_CC_SUPPORT
- if (MAIN_APP_SUCCESS == MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- if(dIndex == SYS_APP_ATV)
- {
- if(SYSAPP_GOBJ_GUIObjectExist(SYS_APP_ATV, ATV_GUIOBJ_CC))
- {
- SYSAPP_GOBJ_DestroyGUIObject(SYS_APP_ATV, ATV_GUIOBJ_CC);
- }
- }
- }
- #endif
- #ifdef SUPPORT_CEC_TV
- AL_Setting_Read(APP_Data_UserSetting_Handle(), SYS_SET_ID_FEATURE, 0,
- sizeof(APP_SETTING_Feature_t), &(g_stFeatureData));
- if (( APP_SWITCH_ON == g_stFeatureData.Enable_HDMILink)
- &&(APP_SWITCH_ON == g_stFeatureData.HDMI_AutoStandby))
- {
- if (CECTV_GetCECEnable()==CECTV_ENABLE)
- {
- CECTV_SendCmd(CECTV_SINGLE_ACT_CMD_STANDBY, 0);
- /*mainapp_printf("[%s]:Waiting for CECTV_SINGLE_ACT_CMD_STANDBY Send Complete !!!!!\n\n", __FUNCTION__);
- UINT8 i=0;
- while(CECTV_GetCECTaskStatus()!=CEC_TASK_Standby)//Waiting for CEC Message Send complete
- {
- i++;
- GL_TaskSleep(10);
- if (i > 50)
- {
- break;
- }
- }*/
- }
- }
- #endif
- #ifdef CONFIG_SUPPORT_USB_MCAST
- if (MAIN_APP_SUCCESS == MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- #ifdef CONFIG_SUPPORT_NETAPP
- if(dIndex == SYS_APP_NETWORK)
- {
- if(SYSAPP_GOBJ_GUIObjectExist(SYS_APP_NETWORK, NET_GUIOBJ_USB_MCAST_PAGE))
- {
- SYSAPP_GOBJ_DestroyGUIObject(SYS_APP_NETWORK, NET_GUIOBJ_USB_MCAST_PAGE);
- }
- }
- #endif
- }
- #endif
- #ifdef CONFIG_BLUETOOTH_SUPPORT
- Al_Bluetooth_Disable();
- GL_TaskSleep(50);
- Al_Bluetooth_Destory();
- #endif
- Cmd_gpio_WriteOnLevel(GPIO_AUDIO_CTL);
- Cmd_gpio_WriteOffLevel(GPIO_12V_EN);
- AL_Power_SetPowerState(dParam);
- /* g_stUserInfoData.PowerStatus = APP_SWITCH_OFF; // power off
- AL_Setting_Write(APP_Data_UserSetting_Handle(), SYS_SET_ID_USERINFO,
- ITEM_OFFSET(APP_SETTING_UserInfo_t, PowerStatus),
- sizeof(g_stUserInfoData.PowerStatus), &(g_stUserInfoData.PowerStatus));
- AL_Setting_Store(APP_Data_UserSetting_Handle(), SYS_SET_ID_USERINFO,
- ITEM_OFFSET(APP_SETTING_UserInfo_t, PowerStatus), sizeof(g_stUserInfoData.PowerStatus));*/
- #ifdef AC_ON_AUTO_GET_TIME
- if (g_fBackgroundGetTime == TRUE)
- {
- /* keep the latest source if get time over */
- g_fBackgroundGetTime = FALSE;
- APP_Source_Type_t SourceIndex;
- SourceIndex = APP_GUIOBJ_Source_GetStandbySource();
- g_stUserInfoData.SourceIndex = SourceIndex;
- AL_Setting_Write(APP_Data_UserSetting_Handle(), SYS_SET_ID_USERINFO,
- ITEM_OFFSET(APP_SETTING_UserInfo_t, SourceIndex),
- sizeof(g_stUserInfoData.SourceIndex),&(g_stUserInfoData.SourceIndex));
- AL_Setting_Store(APP_Data_UserSetting_Handle(), SYS_SET_ID_USERINFO,
- ITEM_OFFSET(APP_SETTING_UserInfo_t, SourceIndex),
- sizeof(g_stUserInfoData.SourceIndex));
- }
- #endif
- #ifdef CONFIG_SUPPORT_MIRACAST
- WriteP2pConfigToFlash();
- #endif
- MAINAPP_FinalizeFlow(dParam);
- }
- }
- break;
- case UI_EVENT_MUTE:
- if (MAINAPP_GetActiveSystemAppIndex(&dIndex) == MAIN_APP_SUCCESS)
- {
- SYSAPP_IF_SendGlobalEventWithIndex(dIndex,(dMessage | PASS_TO_SYSAPP), dParam);
- }
- break;
- case UI_EVENT_SOURCE:
- mainapp_printf("[%s]: UI_EVENT_SOURCE!!!!!\n\n", __FUNCTION__);
- break;
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- case UI_EVENT_KEYPAD_POWER_UPGRADE:
- if (MAINAPP_GetActiveSystemAppIndex(&dIndex) == MAIN_APP_SUCCESS)
- {
- dMessage = APP_GLOBAL_EVENT_USB_UPGRADE | PASS_TO_SYSAPP;
- SYSAPP_IF_SendGlobalEventWithIndex(dIndex, dMessage, 0); // 1:EraseAll,0:not EraseAll
- g_CheckUpgrade = TRUE;
- }
- break;
- #endif
- case APP_GLOBAL_EVENT_OSD_CAPTURE:
- {
- mainapp_printf("\n\n%s APP_GLOBAL_EVENT_OSD_CAPTURE\n", __FUNCTION__);
- //extern int app_capture_osd_handler(void);
- //app_capture_osd_handler();
- //mainapp_printf("capture OK! \n");
- char szMountName[20];
- char szTempName[20] = {0};
- char fileNameStringtemp[50] = {0};
- char fileNameString[200] = {0};
- struct stat stStat;
- memset(fileNameStringtemp, 0, 50);
- memset(fileNameString, 0, 200);
- memset(szMountName, 0, sizeof(szMountName));
- MID_PartitionList_GetMountName(0, szMountName);
- if(strcmp(szMountName, szTempName))
- {
- sprintf(fileNameStringtemp,"%s/%s", szMountName,"SPOSD");
- if (stat(fileNameStringtemp, &stStat) < 0)
- {
- if (mkdir(fileNameStringtemp, O_WRONLY | O_CREAT) < 0)
- {
- mainapp_printf("%s mkdir failed\n", __FUNCTION__);
- break;
- }
- }
- static int fn = 0;
- fn++;
- sprintf(fileNameString,"%s/%s%d_%.3d%.2d.bmp", fileNameStringtemp,"OSD_",fn,rand()%1000,rand()%100);
- mainapp_printf("\nfileNameString:%s\n",fileNameString);
- OSD_ChangeIntoBitmap(fileNameString);
- mainapp_printf("\n\n%s capture ok!\n", __FUNCTION__);
- }
- break;
- }
-
- case FW_DB_LOAD_DEFAULT:
- #ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
- if (AL_DBTYPE_DVB_S == APP_DVB_Playback_GetCurrentNetType())
- {
- /* wait for DVB-S becomes acticve */
- while(AL_FW_CheckActiveDBModule(AL_DBTYPE_DVB_S) != al_true);
-
- DVBApp_LoadCustomerDB(AL_DBTYPE_DVB_S);
- AL_DB_Sync(AL_DBTYPE_DVB_S, al_true);
- }
- #endif
- break;
- default:
- mainapp_printf(" Un-handled UI Eventid: 0x%x.\n", dMessage);
- break;
- }
- return MAIN_APP_SUCCESS;
- }
- #ifdef CONFIG_SUPPORT_MEDIA_AUTO_PLAY
- /******************************************************************************/
- /**
- * @brief Check Folder Path Exist
- * @param char* const Folder_Path : Folder Path
- * @return TRUE : Folder is exist\n
- * FALSE : Folder is not exist
- *
- ******************************************************************************/
- static BOOL FileSystem_Lib_Com_IsFolderExist(char* const Folder_Path)
- {
- if (Folder_Path == NULL)
- {
- mainapp_printf("Folder_Path = NULL\n");
- return FALSE;
- }
- DIR* dir;
- dir = opendir(Folder_Path);
- if (dir == NULL)
- {
- mainapp_printf("Folder Path = %s is not exist!\n", Folder_Path);
- return FALSE;
- }
- if (closedir(dir) != 0)
- {
- mainapp_printf("call closedir fail\n");
- return FALSE;
- }
- dir = NULL;
- return TRUE;
- }
- static UINT16 FileSystem_Lib_Com_GetTotalSupportedPartitionNumber(void)
- {
- int MountedCount = MID_PartitionList_GetMountedCount();
- if (MountedCount > MAX_COM_PARTITION_NUM)
- {
- mainapp_printf("Partition Num = %d is more than %d\n", MountedCount, MAX_COM_PARTITION_NUM);
- MountedCount = MAX_COM_PARTITION_NUM;
- }
- return MountedCount;
- }
- static BOOLEAN MM_AutoPlay_Com_SetFlag(void)
- {
- UINT16 TotalPartition = FileSystem_Lib_Com_GetTotalSupportedPartitionNumber();
- UINT16 i = 0;
- char Name[INTERNAL_COM_DISK_NAME_LEN + 1];
- for (i = 0; i < TotalPartition; i++)
- {
- MID_PartitionList_GetMountName(i, Name);
- memset(PlayComFilePath, 0, MAX_COM_BUF_SIZE);
- snprintf(PlayComFilePath, MAX_COM_BUF_SIZE, "%s/%s", Name, MM_COMMON_AUTO_PLAY);
- mainapp_printf("[%s:%d] FilePath = %s \n", __FUNCTION__, __LINE__, PlayComFilePath);
- if (FileSystem_Lib_Com_IsFolderExist(PlayComFilePath))
- {
- mainapp_printf("[%s:%d]i = [%d] folder exist \n", __FUNCTION__, __LINE__, i);
- return TRUE;
- }
- }
- //mainapp_printf("[%s:%d]: bAutoPlay = %d \n", __FUNCTION__, __LINE__, bAutoPlay);
- return FALSE;
- }
- #endif
- /*****************************************************************************
- ** FUNCTION : _MAINAPP_DaemonEventHandler
- **
- ** DESCRIPTION :
- ** main app daemon event handler
- **
- ** PARAMETERS :
- ** dMessage: daemon message
- ** dParam: daemon message's paramter
- **
- ** RETURN VALUES:
- ** None
- *****************************************************************************/
- void _MAINAPP_DaemonEventHandler(UINT32 dMessage, UINT32 dParam)
- {
- #ifdef CONFIG_NET_SUPPORT
- #ifdef NET_APP_SUPPORT
- UINT8 i;
- UINT8 bFlag = 0;
- char *pcMountName = NULL;
- int iPtnHandle = 0;
- #endif
- #endif
- UINT32 dActiveSysApp = 0;
- int sdPtIdx = -1;
- INT32 iRet = AL_FAILURE;
- #if defined(CONFIG_SUPPORT_USB_AUTO_UPGRADE)
- app_data_keyupgrade_status_e updateCI = APP_DATA_KEYUPGRADE_NOT_UPGRADE;
- app_data_keyupgrade_status_e updateHDCP = APP_DATA_KEYUPGRADE_NOT_UPGRADE;
- #ifdef CONFIG_SUPPORT_STORE_HDCP2X_TO_FLASH
- app_data_keyupgrade_status_e updateHDCP2X = APP_DATA_KEYUPGRADE_NOT_UPGRADE;
- #endif
- UINT32 dKeyparam = 0;
- UINT32 dKeyUpgradeEvent = 0;
- #endif
- #if defined(CONFIG_NET_ET_SUPPORT) || defined (CONFIG_NET_N32_SUPPORT)
- MainAppUIEventHandlerInfo_t *pstEventInfo = &stUIEventHandlerInfo;
- #endif
- switch (dMessage)
- {
- case DMN_EVENT_BD_VIDEO_DISC_INSERTED:
- case DMN_EVENT_DVD_VIDEO_DISC_INSERTED:
- case DMN_EVENT_VCD_DISC_INSERTED:
- case DMN_EVENT_TEMPTEST_START_USB_DVD:
- break;
- case DMN_EVENT_USB_HDD_ATTACHED:
- case DMN_EVENT_USB_LOADER_ATTACHED:
- case DMN_EVENT_CARD_DEV_ATTACHED:
- case DMN_EVENT_IDE_HDD_ATTACHED:
- case DMN_EVENT_IDE_LOADER_ATTACHED:
- case DMN_EVENT_NAND_ATTACHED:
- {
- #if defined(CONFIG_AUTO_USB_STORE_IRSEQ) && defined(CONFIG_QSD_AUTOIR)
- AUTO_IF_Start(SEQUENTIAL_TEST, 0)
- #endif
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- if(dMessage == DMN_EVENT_USB_HDD_ATTACHED)
- {
- USB_ATTACHED = TRUE;
- }
- #endif
- #ifdef CONFIG_STORE_MSG_TO_USB
- {
- UINT8 isEnablePrintToUSB = 1;
- ioctl(kmfdev, KMF_IOC_PRINTOFILEENABLE, &isEnablePrintToUSB);
- }
- #endif
- iRet = APP_Data_USB_Upgrade_ChecFileAndBuildTime();
- //mainapp_printf("[L%d] DEV_ATTACHED(%d) received.\n", __LINE__,dMessage);
- switch (MAINAPP_GetActiveSystemAppIndex(&dActiveSysApp))
- {
- case MAIN_APP_IN_TRANSITION:
- //mainapp_printf("[L%d] In Transition State, wait and retry.\n",__LINE__);
- _MAINAPP_SetEventInTransition(dMessage, dParam);
- return;
- case MAIN_APP_SUCCESS:
- //mainapp_printf("[L%d] MAIN_APP_SUCCESS!!!\n",__LINE__);
- break;
- default:
- mainapp_printf("[%s %d] In Invalid State\n",__FUNCTION__,__LINE__);
- return;
- }
- _MAINAPP_ClearEventInTransition(dMessage, dParam);
- #if defined(CONFIG_SUPPORT_USB_AUTO_UPGRADE)
- #ifdef CONFIG_SUPPORT_STORE_HDCP2X_TO_FLASH
- updateHDCP = APP_Data_HDCPKey_Upgrade_AutoStart(iRet);
- updateHDCP2X = APP_Data_HDCP2XKey_Upgrade_AutoStart(iRet);
- updateHDCP = (updateHDCP || updateHDCP2X);
- #else
- updateHDCP = APP_Data_HDCPKey_Upgrade_AutoStart(iRet);
- #endif
- dKeyparam = (updateHDCP<<4) | updateCI;
- dKeyUpgradeEvent = APP_GLOBAL_EVENT_CIHDCPKEY_RESULT | PASS_TO_SYSAPP;
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dKeyUpgradeEvent, dKeyparam);
- #endif
- #ifdef CONFIG_NET_SUPPORT
- MID_PartitionList_Mount(sdPtIdx, MntModule_Network);
- #ifdef CONFIG_NET_ET_SUPPORT
- _MAINAPP_EtMountHandle(pstEventInfo, dParam);
- #endif
- #ifdef CONFIG_NET_N32_SUPPORT
- _MAINAPP_N32MountHandle(pstEventInfo, dParam);
- #endif
- #endif
- #ifdef CONFIG_NET_SUPPORT
- #ifdef NET_APP_SUPPORT
- pcMountName = (char *)GL_MemAlloc(_SPAL_PARTITION_NAME_MAX_LENGTH);
- memset(pcMountName, 0, _SPAL_PARTITION_NAME_MAX_LENGTH2);
- iPtnHandle = MID_PartitionList_FindItem(dParam);
- if (iPtnHandle == -1)
- {
- mainapp_printf("get ptn handle\n");
- }
- if (MID_PartitionList_GetMountName(iPtnHandle, pcMountName) == NULL)
- {
- mainapp_printf("Get Mount Name\n");
- }
- if (strcmp(pcMountName, stNetConfigStorage.stParName) == 0)
- {
- Net_Cfg_SetDlPath(stNetConfigStorage.stParName);
- }
- if (NULL != pcMountName)
- {
- GL_MemFree(pcMountName);
- }
- if (stNetConfigStorage.u8IsSetNetConfigStorage == 0)
- {
- stNetConfigStorage.u8IsSetNetConfigStorage = 1;
- stNetConfigStorage.u8NetConfigStorage = 0;
- MID_PartitionList_GetMountName((int)stNetConfigStorage.u8NetConfigStorage, stNetConfigStorage.stParName);
- Net_Cfg_SetDlPath(stNetConfigStorage.stParName);
- }
- #endif
- #endif
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dMessage, (UINT32)sdPtIdx);
- #if (defined(SUPPORT_FACTORY_AUTO_TEST)||defined(SUPPORT_FACTORY_AUTO_TEST_MODE2))
- if (APP_Factory_GetAutoTestOnOff() == TRUE)
- {
- Cmd_SetPanelBacklightPower(1);
- }
- #endif
- #ifdef SUPPORT_FACTORY_AUTO_TEST
- if ((APP_Factory_GetAutoTestOnOff() == TRUE)&&(iRet == AL_FAILURE))
- {
- extern void Enable_Debug_Message(UINT32 DBGStatus);
- Enable_Debug_Message(1<<MODULEID_UMF);
- //mainapp_printf("Test Start\n");
- Enable_Debug_Message(0);
- if(AcPowerOnNoRomBinFlag== FALSE)
- AcPowerOnNoRomBinFlag= TRUE;
- }
- #endif
- if(g_CheckUpgrade)
- {
- break;
- }
- if((iRet == AL_SUCCESS)
- #ifdef SUPPORT_WAKEUP_TIMER_IN_STANDBY
- && (APP_WAKEUP_GetBootFlag() == FALSE)
- #endif
- )
- {
- mainapp_printf("[L%d] APP_Data_USB_Upgrade_ChecFileAndBuildTime() Success!!!\n",__LINE__);
- #ifdef SUPPORT_FACTORY_AUTO_TEST
- extern int APP_Factory_GetAutoTestOnOff(void);
- extern int APP_Factory_GetUpgradeandAutoTestFlag(void);
- extern void APP_Factory_SetUpgradeandAutoTestFlag(Boolean Flag);
- if(AcPowerOnNoRomBinFlag == TRUE)
- {
- mainapp_printf("In AutoTest Factory mode\n");
- }
- else if((APP_Factory_GetAutoTestOnOff() == TRUE)&&(APP_Factory_GetUpgradeandAutoTestFlag() == FALSE))
- {
- dMessage = APP_GLOBAL_EVENT_USB_UPGRADE | PASS_TO_SYSAPP;
- gFACTESTResentMessage.dResendMessage = dMessage;
- gFACTESTResentMessage.dResendMessageParm = 0;
- //SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dMessage, 0); // 1:EraseAll,0:not EraseAll
- //APP_Factory_SetAutoTestOnOff(FALSE);
- //APP_Factory_SetUpgradeandAutoTestFlag(TRUE);
- //g_CheckUpgrade = TRUE;
- }
- else if((APP_Factory_GetAutoTestOnOff() == TRUE)&&(APP_Factory_GetUpgradeandAutoTestFlag() == TRUE))
- {
- mainapp_printf("In AutoTest Factory mode\n");
- }
- else
- {
- #ifndef CONFIG_SUPPORT_USB_AUTO_UPGRADE
- if(FALSE == gUSBUpgradeBinIsSupperBin)
- {
- break;
- }
- #endif
- dMessage = APP_GLOBAL_EVENT_USB_UPGRADE | PASS_TO_SYSAPP;
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dMessage, 0);
- g_CheckUpgrade = TRUE;
- }
- #else
- #ifndef CONFIG_SUPPORT_USB_AUTO_UPGRADE
- if(FALSE == gUSBUpgradeBinIsSupperBin)
- {
- break;
- }
- #endif
- dMessage = APP_GLOBAL_EVENT_USB_UPGRADE | PASS_TO_SYSAPP;
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dMessage, 0);
- g_CheckUpgrade = TRUE;
- #endif
- }
- else
- if(dMessage == DMN_EVENT_USB_HDD_ATTACHED)
- {
- }
- #ifdef CONFIG_SUPPORT_MEDIA_AUTO_PLAY
- //BOOLEAN MM_AutoPlay_SetFlag(void);
- if(MM_AutoPlay_Com_SetFlag())
- {
- if (APP_GUIOBJ_Source_GetSourceTransState() == TRUE)
- {
- gb_NeedAutoPlay = TRUE;
- }
- else
- {
- APP_GUIOBJ_Source_SetAppSource(APP_SOURCE_MEDIA);
- }
- }
- #endif
- }
- break;
- case DMN_EVENT_USB_HDD_DETACHED:
- case DMN_EVENT_USB_LOADER_DETACHED:
- case DMN_EVENT_CARD_DEV_DETACHED:
- case DMN_EVENT_IDE_HDD_DETACHED:
- case DMN_EVENT_IDE_LOADER_DETACHED:
- case DMN_EVENT_NAND_DETACHED:
- mainapp_printf(" DEV_DETACHED(%d) received.\n", dMessage);
- switch (MAINAPP_GetActiveSystemAppIndex(&dActiveSysApp))
- {
- case MAIN_APP_IN_TRANSITION:
- //mainapp_printf("[L%d] In Transition State, wait and retry.\n",__LINE__);
- _MAINAPP_SetEventInTransition(dMessage, dParam);
- return;
- case MAIN_APP_SUCCESS:
- //mainapp_printf("[L%d] MAIN_APP_SUCCESS!!!\n",__LINE__);
- break;
- default:
- mainapp_printf("[%s %d] In Invalid State\n",__FUNCTION__,__LINE__);
- return;
- }
- _MAINAPP_ClearEventInTransition(dMessage, dParam);
- if(dMessage == DMN_EVENT_USB_HDD_DETACHED)
- {
- g_CheckUpgrade = FALSE;
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- USB_ATTACHED = FALSE;
- #endif
- }
- #ifdef CONFIG_CONFIRM_AUTO_UPGRADE
- UINT32 u32PopMsgName;
- APP_GUIOBJ_PopMsg_GetMsgDialogType(&u32PopMsgName);
- if(u32PopMsgName == POPMSG_CONFIRM_START_AUTO_UPGRADE)
- {
- AutoUpgrade = FALSE;
- if(SYS_APP_ATV == dActiveSysApp)
- {
- ATVApp_ClosePopup(POPMSG_CONFIRM_START_AUTO_UPGRADE, UI_EVENT_NULL);
- }
- }
- #endif
- #ifdef CONFIG_NET_ET_SUPPORT
- _MAINAPP_EtUnmountHandle(pstEventInfo, dParam);
- #endif
- #ifdef CONFIG_NET_N32_SUPPORT
- _MAINAPP_N32UnmountHandle(pstEventInfo, dParam);
- #endif
- #ifdef CONFIG_NET_SUPPORT
- #ifdef NET_APP_SUPPORT
- #if defined(CONFIG_DVB_SYSTEM_DVBC_SUPPORT)
- Dvb_GUIOBJ_Networking_PartitionInfoUpdate();
- #endif
- pcMountName = (char *)GL_MemAlloc(_SPAL_PARTITION_NAME_MAX_LENGTH);
- memset(pcMountName, 0, _SPAL_PARTITION_NAME_MAX_LENGTH2);
- for (i = 0; i < MID_PartitionList_GetMountedCount(); i++)
- {
- MID_PartitionList_GetMountName(i, pcMountName);
- if (strcmp(pcMountName, stNetConfigStorage.stParName) == 0)
- {
- bFlag++;
- }
- }
- if (NULL != pcMountName)
- {
- GL_MemFree(pcMountName);
- }
- if (bFlag == 0)
- {
- if (MID_PartitionList_GetMountedCount() == 0)
- {
- memset(stNetConfigStorage.stParName, 0, sizeof(char)*_SPAL_PARTITION_NAME_MAX_LENGTH);
- stNetConfigStorage.u8IsSetNetConfigStorage = 0;
- stNetConfigStorage.u8NetConfigStorage = 0;
- }
- else
- {
- stNetConfigStorage.u8IsSetNetConfigStorage = 1;
- stNetConfigStorage.u8NetConfigStorage = 0;
- MID_PartitionList_GetMountName((int)stNetConfigStorage.u8NetConfigStorage, stNetConfigStorage.stParName);
- }
- }
- Net_Cfg_SetDlPath(stNetConfigStorage.stParName);
- #endif
- #endif
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dMessage, (UINT32)sdPtIdx);
- break;
- case DMN_EVENT_SCREEN_SAVER_ON:
- mainapp_printf(" DMN_EVENT_SCREEN_SAVER_ON received.\n");
- break;
- case DMN_EVENT_SCREEN_SAVER_OFF:
- mainapp_printf(" DMN_EVENT_SCREEN_SAVER_OFF received.\n");
- break;
- #ifdef CONFIG_NET_SUPPORT
- case DMN_EVENT_NET_LINKER_DETACHED:
- mainapp_printf("DMN_EVENT_NET_LINKER_DETACHED received.\n");
- #if defined( SAMBA_SUPPORT ) && defined( SUPPORT_ETHERNET )
- DVB_Network_UnMountSmbFs();
- #endif
- pstEventInfo->stNetDriveCtrlInfo.eState = NET_DRIVE_STATE_SHUT_DOWN;
- if (MAINAPP_GetActiveSystemAppIndex(&dActiveSysApp) == MAIN_APP_SUCCESS)
- {
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dMessage, dParam);
- }
- break;
- case DMN_EVENT_NET_LINKER_ATTACHED:
- mainapp_printf("DMN_EVENT_NET_LINKER_ATTACHED received.\n");
- #if defined( SAMBA_SUPPORT ) && defined( SUPPORT_ETHERNET )
- DVB_Network_MountSmbFs();
- #endif
- pstEventInfo->stNetDriveCtrlInfo.eState = NET_DRIVE_STATE_BOOTUP;
- if (MAINAPP_GetActiveSystemAppIndex(&dActiveSysApp) == MAIN_APP_SUCCESS)
- {
- SYSAPP_IF_SendGlobalEventWithIndex(dActiveSysApp, dMessage, dParam);
- }
- break;
- #endif
- case DMN_EVENT_MAINAPP_STARTS:
- mainapp_printf(" DMN_EVENT_MAINAPP_STARTS received.\n");
- #ifdef CONFIG_NET_SUPPORT
- MAINAPP_NetAPInit();
- #endif
- break;
- default:
- mainapp_printf(" Un-handled Daemon Eventid: 0x%x.\n", dMessage);
- break;
- }
- return;
- }
- /*****************************************************************************
- ** FUNCTION : MAINAPP_OnTimerUpdate
- **
- ** DESCRIPTION :
- ** main app 100ms message handler
- **
- ** PARAMETERS :
- ** None
- **
- ** RETURN VALUES:
- ** None
- *****************************************************************************/
- int MAINAPP_OnTimerUpdate(void)
- {
- UINT32 dIndex = 0;
- /*mark for S2tek */
- #ifdef SUPPORT_FACTORY_AUTO_TEST
- if((APP_Factory_GetAutoTestOnOff() == TRUE) && (APP_Factory_GetUpgradeandAutoTestFlag() == FALSE))
- {
- static UINT8 CheckCount = 0;
- //100ms * 50
- CheckCount++;
- CheckCount %= 255;
- if(CheckCount >= 50 && gFACTESTResentMessage.dResendMessage != 0)
- {
- APP_Factory_SetAutoTestOnOff(FALSE);
- APP_Factory_SetUpgradeandAutoTestFlag(TRUE);
- MSG_FILTER_DispatchMessage(gFACTESTResentMessage.dResendMessage, gFACTESTResentMessage.dResendMessageParm);
- g_CheckUpgrade = TRUE;
- gFACTESTResentMessage.dResendMessage = 0;
- gFACTESTResentMessage.dResendMessageParm= 0;
- }
- }
- #endif
- _MAINAPP_ResendEventInTransition();
- AL_Time_Timeout();
- if (APP_SleepTimer_GetDetectFlag())
- {
- if(!(APP_MenuMgr_Exist_Factory_Menu()))
- {
- if (APP_GUIOBJ_SleepTimer_Timeout())
- {
- if(MAIN_APP_SUCCESS != MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- printf("GetActiveSystemApp faile\n");
- }
- if(SYSAPP_GOBJ_GUIObjectExist(dIndex, APP_GUIOBJ_SLEEP_INFO))
- {
- APP_GUIOBJ_SleepTimer_SetSleepPopConflict(TRUE);
- }
- SYSAPP_IF_SendGlobalEventWithIndex(dIndex,
- (APP_GLOBAL_EVENT_SLEEP_TIMER_INFO | PASS_TO_SYSAPP), APP_POWERDOWN_SLEEP);
- APP_SleepTimer_SetDetectFlag(FALSE);
- }
- }
- }
- if (APP_AutoPowerOff_Timeout() || APP_2Hours_PowerOff_Timeout())
- {
- if(MAIN_APP_SUCCESS != MAINAPP_GetActiveSystemAppIndex(&dIndex))
- {
- printf("GetActiveSystemApp faile\n");
- }
- if (SYSAPP_GOBJ_GUIObjectExist(dIndex, APP_GUIOBJ_SLEEP_INFO) && (APP_GUIOBJ_SleepTimer_GetStandbyPopConflict() == FALSE))
- {
- APP_GUIOBJ_SleepTimer_SetStandbyPopConflict(TRUE);
- }
- SYSAPP_IF_SendGlobalEventWithIndex(dIndex,
- (APP_GLOBAL_EVENT_SLEEP_TIMER_INFO | PASS_TO_SYSAPP), APP_POWERDOWN_AUTOPOWEROFF);
- #if 0
- while(!SYSAPP_GOBJ_GUIObjectExist(SYS_APP_DVB, APP_GUIOBJ_SLEEP_INFO))
- {
- MAINAPP_SendGlobalEvent(UI_EVENT_POWER, AL_POWER_STATE_OFF);
- }
- #endif
- }
-
- #ifdef SUPPORT_SHOP_DEMO_MODE
- if (APP_ShopDemo_Timeout())
- {
- APP_GUIOBJ_Picture_SetPictureMode(TV_IDS_String_Picture_dynamic);
- APP_GUIOBJ_Picture_SetColourTemp(TV_IDS_String_Standard);
- APP_Video_OSD_PQSet(APP_VIDEO_OSD_ITEM_BACKLIGHT, 100);
- }
- #endif
- #if defined(CONFIG_SUPPORT_SET_CLOCK_ONOFFTIME)|| defined (TEAC_ONOFF_TIMER_SUPPORT)
- APP_OffTimer_Check();
- #ifdef TEAC_ONOFF_TIMER_SUPPORT
- APP_OnTimer_Check_WhenPanelOff();
- #endif
- #endif
- #if defined(CONFIG_BT_RDA5856)
- if(APP_BT_GetHeartTimer() >= 50)
- {
- if(APP_BT_GetHeartTimer()!= 0xff)
- {
- APP_BT_SetHeartTimer(0xff);
- MSG_FILTER_DispatchMessage(DMN_EVENT_BLUETOOTH_WAITCONNECT,0);
- }
- }
- else
- {
- APP_BT_SetHeartTimer(APP_BT_GetHeartTimer()+1);
- }
- if(g_SystemPowerOnReadyNeedReconnectBT == TRUE)
- {
- APP_Source_Type_t getCurrSourType = APP_SOURCE_MAX;
- APP_GUIOBJ_Source_GetCurrSource(&getCurrSourType);
- if(getCurrSourType != APP_SOURCE_BLUETOOTH)
- {
- AL_Setting_Read(APP_Data_UserSetting_Handle(), SYS_SET_ID_SETUP,0,
- sizeof(APP_SETTING_Setup_t), &(g_stSetupData));
- UINT8 NULLADDR[6] = "";
-
- if(APP_BT_GetBTIsReady() == TRUE)
- {
- g_SystemPowerOnReadyNeedReconnectBT = FALSE;
- if((g_stSetupData.BTMode != BT_MODE_SEND)
- ||(memcmp((const void *)g_stSetupData.BTAddrs,(const void *)NULLADDR,sizeof(t_bdaddr)) == 0))
- {
- ;//do nothing
- }
- else
- {
- APP_BT_Auto_ReconnectBTDevice();
- }
- }
- }
- else
- {
- g_SystemPowerOnReadyNeedReconnectBT = FALSE;
- }
- }
-
- #endif
- #ifdef CONFIG_SUPPORT_MEDIA_AUTO_PLAY
- if (gb_NeedAutoPlay && APP_GUIOBJ_Source_GetSourceTransState() == FALSE && MM_AutoPlay_Com_SetFlag())
- {
- APP_GUIOBJ_Source_SetAppSource(APP_SOURCE_MEDIA);
- gb_NeedAutoPlay = FALSE;
- }
- #endif
- #ifdef CONFIG_SKIP_AC_POWERKEY
- UINT8 key0State = GPIO_LEVEL_LOW;
- static UINT8 checkHighTimes = 0;
- Cmd_gpio_Read(GPIO_KEY0_PIN,&key0State);
- if(GPIO_LEVEL_HIGH == key0State)
- {
- checkHighTimes++;
- if(checkHighTimes >= 10)
- {
- MAINAPP_SendGlobalEvent(UI_EVENT_POWER, AL_POWER_STATE_OFF);
- }
- }
- #endif
- return SP_SUCCESS;
- }
- /*****************************************************************************
- ** FUNCTION : MAINAPP_OnEvent
- **
- ** DESCRIPTION :
- ** main app external event handler
- **
- ** PARAMETERS :
- ** dMessage : message
- ** dParam : the parameter for dMessage
- **
- ** RETURN VALUES:
- ** None
- *****************************************************************************/
- int MAINAPP_OnEvent(UINT32 dMessage, UINT32 dParam)
- {
- if((dMessage < UI_EVENT_NULL)
- || ((dMessage > APP_GLOBAL_EVENT_MIN) && (dMessage < APP_GLOBAL_EVENT_MAX)))
- {
- //mainapp_printf("==================_MAINAPP_UIEventHandler()=================\n");
- _MAINAPP_UIEventHandler(dMessage, dParam);
- }
- else if ((dMessage > DMN_EVENT_MIN && dMessage < DMN_EVENT_MAX)
- || (dMessage > DMN_EVENT_DEVICE_DETECT_MIN && dMessage < DMN_EVENT_DEVICE_DETECT_MAX))
- {
- //mainapp_printf("==================_MAINAPP_DaemonEventHandler()=================\n");
- _MAINAPP_DaemonEventHandler(dMessage, dParam);
- }
- else if (dMessage > GUI_RESPOND_MIN && dMessage < GUI_RESPOND_MAX)
- {
- //mainapp_printf("==================_MAINAPP_GUIFeedbackEventHandler()=================\n");
- _MAINAPP_GUIFeedbackEventHandler(dMessage, dParam);
- }
- return SP_SUCCESS;
- }
- /*****************************************************************************
- ** FUNCTION : MAINAPP_GetPowerOffState
- **
- ** DESCRIPTION :
- ** Get power off state
- **
- ** PARAMETERS :
- ** None
- **
- ** RETURN VALUES:
- ** g_bPowerOffFlag: power off state
- *****************************************************************************/
- Boolean MAINAPP_GetPowerOffState(void)
- {
- return g_bPowerOffFlag;
- }
- /*****************************************************************************
- ** FUNCTION : MAINAPP_SetPowerOffState
- **
- ** DESCRIPTION :
- ** Set power off state
- **
- ** PARAMETERS :
- ** PowerOffFlag - power off state
- **
- ** RETURN VALUES:
- ** None
- *****************************************************************************/
- void MAINAPP_SetPowerOffState(Boolean PowerOffFlag)
- {
- g_bPowerOffFlag = PowerOffFlag;
- }
- #ifdef CONFIG_NET_ET_SUPPORT
- static void MAINAPP_NetAPInit(void)
- {
- NetDaemonCfg_t stNetDaemon;
- stNetDaemon.pfEventCallBack = NetDaemon_callback;
- #ifdef NET_WIFI_SUPPORT
- Net_WifiFlashiInit();
- #endif
- if (NET_IF_Initialize(&stNetDaemon) != NET_DAEMON_IF_SUCCESSFUL)
- {
- mainapp_printf("ERROR: init net daemon\n");
- }
- if (APP_NET_Initialize() != APP_NET_IF_SUCCESSFUL)
- {
- mainapp_printf("ERROR: app init net daemon\n");
- }
- #ifdef SUPPORT_NET_TESTING
- if (NetTest_Init(1) != 0)
- {
- mainapp_printf("ERROR: Init Net Testing Thread\n");
- }
- #endif
- }
- MainAppUIEventHandlerInfo_t *MAINAPP_GetNetHandlerInfo(void)
- {
- return &stUIEventHandlerInfo;
- }
- static void _MAINAPP_EtMountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum)
- {
- int iPtnHandle = 0;
- char *pszMountPonit = NULL;
- if (!pstEventInfo)
- {
- mainapp_printf("%s\n", __FUNCTION__);
- return;
- }
- pszMountPonit = GL_MemAlloc(ET_PATH_NAME_MAX_LENTH);
- if (!pszMountPonit)
- {
- mainapp_printf("alloc et new path name\n");
- return;
- }
- memset(pszMountPonit, 0, ET_PATH_NAME_MAX_LENTH);
- do
- {
- iPtnHandle = MID_PartitionList_FindItem(dDevNum);
- if (iPtnHandle == -1)
- {
- mainapp_printf("invalidate ptn handle\n");
- break;
- }
- if (MID_PartitionList_GetMountName(iPtnHandle, pszMountPonit) == NULL)
- {
- mainapp_printf("get ptn mount point error!\n");
- break;
- }
- pstEventInfo->stSysDriveCtrlInfo.iSysCurPtnHnd = iPtnHandle;
- }
- while (0);
- GL_MemFree(pszMountPonit);
- }
- static void _MAINAPP_EtUnmountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum)
- {
- int iPtnHandle = 0;
- char *pszMountPonit = NULL;
- if (!pstEventInfo)
- {
- mainapp_printf("%s\n", __FUNCTION__);
- return;
- }
- pszMountPonit = GL_MemAlloc(ET_PATH_NAME_MAX_LENTH);
- if (!pszMountPonit)
- {
- mainapp_printf("alloc et new path name\n");
- return;
- }
- memset(pszMountPonit, 0, ET_PATH_NAME_MAX_LENTH);
- do
- {
- iPtnHandle = MID_PartitionList_FindItem(dDevNum);
- if (iPtnHandle == -1)
- {
- mainapp_printf("invalidate ptn handle\n");
- break;
- }
- if (MID_PartitionList_GetMountName(iPtnHandle, pszMountPonit) == NULL)
- {
- mainapp_printf("get ptn mount point error!\n");
- break;
- }
- #if 0
- sdReturnValue = NET_IF_InstOps(NET_DAEMON_INST_ET, NET_DAEMON_INST_OPS_UNMOUNT_CHECK, (UINT32)pszMountPonit);
- if (sdReturnValue < NET_DAEMON_IF_SUCCESSFUL)
- {
- mainapp_printf("boot up check et download\n");
- break;
- }
- #endif
- pstEventInfo->stSysDriveCtrlInfo.iSysCurPtnHnd = iPtnHandle;
- }
- while (0);
- GL_MemFree(pszMountPonit);
- }
- #endif
- #ifdef CONFIG_NET_N32_SUPPORT
- static void _MAINAPP_N32MountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum)
- {
- INT32 sdReturnValue = MAIN_APP_SUCCESS;
- int iPtnHandle = 0;
- char *pszMountPonit = NULL;
- if (!pstEventInfo)
- {
- mainapp_printf("%s\n", __FUNCTION__);
- return;
- }
- pszMountPonit = GL_MemAlloc(DLMGR_IF_FILEPATH_MAX_LEN);
- if (!pszMountPonit)
- {
- mainapp_printf("alloc et new path name\n");
- return;
- }
- memset(pszMountPonit, 0, DLMGR_IF_FILEPATH_MAX_LEN);
- do
- {
- iPtnHandle = MID_PartitionList_FindItem(dDevNum);
- if (iPtnHandle == -1)
- {
- mainapp_printf("get ptn handle\n");
- break;
- }
- if (MID_PartitionList_GetMountName(iPtnHandle, pszMountPonit) == NULL)
- {
- mainapp_printf("get ptn mount point error!\n");
- break;
- }
- //add by ztli 2010/08/04 for mantis bug 96324 start {
- if (iPtnHandle == 0)
- {
- Net_Cfg_SetDlPath(pszMountPonit);
- }
- //add by ztli end }
- //sdReturnValue = NET_IF_InstOps(NET_DAEMON_INST_N32,NET_DAEMON_N32_INST_OPS_MOUNT_CHECK,(UINT32)pszMountPonit);
- //if(sdReturnValue < NET_DAEMON_IF_SUCCESSFUL)
- sdReturnValue = APP_NET_InstCtrl(APP_NET_INST_N32, APP_NET_INST_OPS_MOUNT, (UINT32)pszMountPonit);
- if (sdReturnValue < APP_NET_IF_SUCCESSFUL)
- {
- mainapp_printf("boot up check et download\n");
- break;
- }
- }
- while (0);
- GL_MemFree(pszMountPonit);
- }
- static void _MAINAPP_N32UnmountHandle(MainAppUIEventHandlerInfo_t *pstEventInfo, UINT32 dDevNum)
- {
- INT32 sdReturnValue = MAIN_APP_SUCCESS;
- int iPtnHandle = 0;
- char *pszMountPonit = NULL;
- if (!pstEventInfo)
- {
- mainapp_printf("%s\n", __FUNCTION__);
- return;
- }
- pszMountPonit = GL_MemAlloc(DLMGR_IF_FILEPATH_MAX_LEN);
- if (!pszMountPonit)
- {
- mainapp_printf("alloc et new path name\n");
- return;
- }
- memset(pszMountPonit, 0, DLMGR_IF_FILEPATH_MAX_LEN);
- do
- {
- iPtnHandle = MID_PartitionList_FindItem(dDevNum);
- if (iPtnHandle == -1)
- {
- mainapp_printf("invalidate ptn handle\n");
- break;
- }
- if (MID_PartitionList_GetMountName(iPtnHandle, pszMountPonit) == NULL)
- {
- mainapp_printf("get ptn mount point error!\n");
- break;
- }
- //sdReturnValue = NET_IF_InstOps(NET_DAEMON_INST_N32,NET_DAEMON_N32_INST_OPS_UNMOUNT_CHECK,(UINT32)pszMountPonit);
- //if(sdReturnValue < NET_DAEMON_IF_SUCCESSFUL)
- sdReturnValue = APP_NET_InstCtrl(APP_NET_INST_N32, APP_NET_INST_OPS_UNMOUNT, (UINT32)pszMountPonit);
- if (sdReturnValue < APP_NET_IF_SUCCESSFUL)
- {
- mainapp_printf("boot up check et download\n");
- break;
- }
- }
- while (0);
- GL_MemFree(pszMountPonit);
- }
- #endif
|