H_WIN app_root_wincreate(Activity *activity)
{
H_WIN hManWin;
__gui_manwincreate_para_t create_info;
eLIBs_memset(&create_info, 0, sizeof(__gui_manwincreate_para_t));
create_info.attr = activity;
create_info.hParent = activity_get_root_win(activity) ;
create_info.hHosting = NULL;
create_info.ManWindowProc = (__pGUI_WIN_CB)esKRNL_GetCallBack((__pCBK_t)app_root_win_proc);
create_info.name = APP_ROOT;
hManWin = GUI_ManWinCreate(&create_info);
__msg("root win = %x\n", hManWin);
if(hManWin == NULL)
{
__wrn("home: create movie windows failed!\n");
return NULL;
}
return hManWin;
}
__s32 app_root_win_proc(__gui_msg_t *msg)
{
__msg("app_root_win_proc msg->id=%d, msg->h_deswin=%x, msg->dwAddData1=%d, msg->dwAddData2=%d\n"
,msg->id, msg->h_deswin, msg->dwAddData1, msg->dwAddData2);
switch(msg->id)
{
case GUI_MSG_CREATE:
{
root_para_t *root_para;
root_ctrl_t *root_ctrl;
reg_system_para_t* sys_reg_para=NULL;
__s32 ret=EPDK_FAIL;
root_para = esMEMS_Balloc(sizeof(root_para_t));
if(!root_para)
{
return EPDK_FAIL;
}
eLIBs_memset(root_para, 0, sizeof(root_para_t));
root_ctrl = esMEMS_Balloc(sizeof(root_ctrl_t));
if(!root_ctrl)
{
esMEMS_Bfree(root_para, sizeof(root_para_t));
return EPDK_FAIL;
}
eLIBs_memset(root_ctrl, 0, sizeof(root_ctrl_t));
root_para->h_parent = msg->h_deswin;
root_para->font = SWFFont;
root_para->root_type = 0;
//root_ctrl->h_app_home = app_home_create(root_para);
// __msg("root_ctrl->h_app_home = %x\n", root_ctrl->h_app_home);
//GUI_WinSetFocusChild(root_ctrl->h_app_home);
root_ctrl->root_para = root_para;
GUI_WinSetAddData(msg->h_deswin, (__u32)root_ctrl);
#if 1//wqx 20130802
sys_reg_para = (reg_system_para_t*)dsk_reg_get_para_by_app(REG_APP_SYSTEM);
if(sys_reg_para)
{
if(sys_reg_para->default_work_mode==5) //calendar
{
delete_all_app(root_ctrl);
gscene_hbar_set_state(HBAR_ST_HIDE);
root_ctrl->root_para->h_parent= msg->h_deswin;
root_ctrl->h_app_calendar= app_calendar_create(root_para);
GUI_WinSetFocusChild(root_ctrl->h_app_calendar);
ret=EPDK_OK;
}
}
if(EPDK_FAIL == ret)
{
root_ctrl->h_app_home = app_home_create(root_para);
__wrn("root_ctrl->h_app_home = %x\n", root_ctrl->h_app_home);
GUI_WinSetFocusChild(root_ctrl->h_app_home);
}
#endif
__root_scene_sem_init();
root_ctrl->root_para->amplify_open_delay_cnt = 0;
if(1)
{
ES_FILE * p_disp;
/*open display driver handle*/
p_disp = eLIBs_fopen("b:\\DISP\\DISPLAY", "r+");
if(p_disp)
{
/*start hardware cache layer*/
eLIBs_fioctrl(p_disp, DISP_CMD_EXECUTE_CMD_AND_STOP_CACHE, SEL_SCREEN, 0);
eLIBs_fclose(p_disp);
}
}
}
return EPDK_OK;
#if 1//wqx 20130406
case GUI_MSG_TIMER:
{
root_ctrl_t *root_ctrl;
root_ctrl = (root_ctrl_t *)GUI_WinGetAddData(msg->h_deswin);
if (!root_ctrl)
{
__err("root_ctrl is null...\n");
return EPDK_OK;
}
if(LOWORD(msg->dwAddData1) == AMPLIFER_CHECK_TIMMER_ID)
{
__s32 mic_in;
__s32 earphone_in;
__s32 playing;
__s32 mute;
__s32 sta;
__s32 amplifer_onoff;
__s32 is_fm_searching;
__s32 btv_out;
do
{
amplifer_onoff = 0;
//mic
/*
sta = get_gpio_status(5, 2); //PIN62=Y1=PE2
__wrn("sta=%d\n", sta);
if(0 == sta)
{
mic_in = 1;
}
else
{
mic_in = 0;
}
*/
mic_in = 0;//硬件mic没有做,默认没有插入
__wrn("mic_in=%d\n", mic_in);
//耳机
/*
sta = get_gpio_status(3, 13); //PIN12=ND5=PC13
if(0 == sta)
{
earphone_in = 1;
}
else
{
earphone_in = 0;
}
*/
earphone_in = 0;
__wrn("earphone_in=%d\n", earphone_in);
__wrn("root_ctrl->h_app_movie=0x%x\n", root_ctrl->h_app_movie);
if(root_ctrl->h_app_movie)
{
btv_out = app_movie_is_tv_out(root_ctrl->h_app_movie);
}
else
{
btv_out = 0;
}
__wrn("btv_out=%d\n", btv_out);
if(1 == btv_out)
{
amplifer_onoff = 0;
break;
}
//mute
mute = g_is_mute;
__wrn("mute=%d\n", mute);
if(1 == mute)
{
amplifer_onoff = 0;
break;
}
if(1 == mic_in)
{
amplifer_onoff = 1;
break;
}
//playing
playing = 0;
if(0 == playing)
{
__here__;
if(root_ctrl->h_app_fm)
{
__here__;
playing = 1;
}
}
if(0 == playing)
{
__here__;
if(root_ctrl->h_app_linin)
{
__here__;
playing = 1;
}
}
if(1)
{
is_fm_searching = app_fm_get_auto_search_state();
if(1 == is_fm_searching)
{
amplifer_onoff = 0;
break;
}
}
if(0 == playing)
{
__here__;
if(root_ctrl->h_app_movie)
{
__cedar_status_t sta;
sta = robin_get_fsm_status();
__wrn("sta=%d\n", sta);
if(CEDAR_STAT_PLAY == sta)
{
__here__;
playing = 1;
}
}
}
if(0 == playing)
{
__here__;
if(root_ctrl->h_app_record)
{
__cedar_status_t sta;
sta = robin_get_fsm_status();
__wrn("sta=%d\n", sta);
if(CEDAR_STAT_PLAY == sta)
{
__here__;
playing = 1;
}
}
}
if(0 == playing)
{
__here__;
if(root_ctrl->h_app_music)
{
__cedar_status_t sta;
sta = robin_get_fsm_status();
__wrn("sta=%d\n", sta);
if(CEDAR_STAT_PLAY == sta)
{
__here__;
playing = 1;
}
}
}
__wrn("playing=%d\n", playing);
__wrn("earphone_in=%d\n", earphone_in);
if(1 == playing && 0 == earphone_in)
{
amplifer_onoff = 1;
break;
}
amplifer_onoff = 0;
break;
}while(0);
__wrn("amplifer_onoff=%d\n", amplifer_onoff);
if(1 == amplifer_onoff)
{
root_ctrl->root_para->amplify_open_delay_cnt++;
if(root_ctrl->root_para->amplify_open_delay_cnt >= 2)
{
root_ctrl->root_para->amplify_open_delay_cnt = 2;
}
if(root_ctrl->root_para->amplify_open_delay_cnt >= 2)
{
dsk_amplifier_onoff(1);
}
}
else
{
dsk_amplifier_onoff(0);
root_ctrl->root_para->amplify_open_delay_cnt = 0;
}
return EPDK_OK;
}
break;
}
#endif
case GUI_MSG_CLOSE:
{
GUI_ManWinDelete(msg->h_deswin);
}
return EPDK_OK;
case GUI_MSG_DESTROY:
{
root_para_t *root_para;
root_ctrl_t *root_ctrl;
root_ctrl = (root_ctrl_t *)GUI_WinGetAddData(msg->h_deswin);
if (!root_ctrl)
{
__msg("******err****\n");
return EPDK_OK;
}
root_para = (root_para_t *)root_ctrl->root_para;
if (!root_para)
{
__msg("******err****\n");
return EPDK_OK;
}
dsk_amplifier_onoff(0);
esMEMS_Bfree(root_para, sizeof(root_para_t));
esMEMS_Bfree(root_ctrl, sizeof(root_ctrl_t));
__root_scene_sem_deinit();
}
return EPDK_OK;
case GUI_MSG_COMMAND:
{
app_root_command_proc(msg);
return EPDK_OK;
}
case GUI_MSG_KEY:
{
__bool audio_engine_is_open;
__msg("**********************before app_root_win_proc GUI_MSG_KEY**************************\n");
__msg("key = %08x\n",msg->dwAddData1);
audio_engine_is_open = 0;
if(!audio_engine_is_open)
{
__here__;
if(EPDK_TRUE == dsk_radio_rcv_is_open())
{
__here__;
audio_engine_is_open = 1;
}
}
//测试deflicker
if(0)//112350
{
static __bool bup = 1;
if(KEY_UP_ACTION == msg->dwAddData2
&&GUI_MSG_KEY_VADD == msg->dwAddData1)
{
ES_FILE* fp;
fp = eLIBs_fopen("b:\\disp\\display", "r+");
if(fp)
{
__u32 args[3]={0};
args[0] = bup?1:0;
__msg("DISP_CMD_SET_DE_FLICKER, args[0]=%d\n", args[0]);
eLIBs_fioctrl(fp, DISP_CMD_SET_DE_FLICKER, 0, args);
eLIBs_fclose(fp);
bup = !bup;
}
else
{
__msg("open disp drv fail...\n");
}
}
}
//测试PE口作为gpio输出,拉高拉低
if(0)//112350
{
if(KEY_UP_ACTION == msg->dwAddData2
&&GUI_MSG_KEY_VADD == msg->dwAddData1)
{
static __bool bfirst = 1;
static __bool bup = 1;
if(bfirst)
{
__app_request_pins();
bfirst = 0;
}
if(bup)
{
__app_pullup_pe();
}
else
{
__app_pulldown_pe();
}
bup = !bup;
}
}
__here__;
if(!audio_engine_is_open)
{
__here__;
if(EPDK_TRUE == robin_is_open())
{
//__cedar_status_t status;
//__here__;
//status = robin_get_fsm_status();
//__msg("status = %d\n", status);
//if(CEDAR_STAT_PAUSE != status && CEDAR_STAT_STOP != status)
{
__here__;
audio_engine_is_open = 1;
}
}
}
__here__;
if(!audio_engine_is_open)
{
if(EPDK_TRUE == dsk_wkm_is_open())
{
//__cedar_status_t status;
//status = dsk_wkm_get_fsm_state();
//if(CEDAR_STAT_PAUSE != status && CEDAR_STAT_STOP != status)
{
audio_engine_is_open = 1;
}
}
}
__here__;
if(!audio_engine_is_open)
{
__u32 key_type;
__here__;
key_type = dsk_keytone_get_key_type();
if(KEY_DOWN_ACTION == msg->dwAddData2)
{
__here__;
if(KEYTONE_KEY_TYPE_DOWN & key_type)
{
__here__;
dsk_keytone_on();
__here__;
}
}
else if(KEY_UP_ACTION == msg->dwAddData2)
{
__here__;
if(KEYTONE_KEY_TYPE_UP & key_type)
{
__here__;
dsk_keytone_on();
__here__;
}
}
else if(KEY_REPEAT_ACTION == msg->dwAddData2)
{
__here__;
if(KEYTONE_KEY_TYPE_REPEAT& key_type)
{
__here__;
dsk_keytone_on();
__here__;
}
}
}
#if 1
__here__;
if(cmd_to_app_key_proc(msg) == EPDK_OK) //应用程序快捷键响应
{
return EPDK_OK; //响应app_key 则不再向下发送消息
}
#endif
if((msg->dwAddData1 == GUI_MSG_KEY_IR_POWER || msg->dwAddData1 == GUI_MSG_KEY_LONGIR_POWER)
&& msg->dwAddData2 == KEY_UP_ACTION) //在此处添加遥控的power键处理//进入主界面后在进入待机模式
{
root_ctrl_t *root_ctrl;
root_ctrl = (root_ctrl_t *)GUI_WinGetAddData(msg->h_deswin);
delete_all_app(root_ctrl);
// delete_all_app_except_home(root_ctrl);
if(root_ctrl->h_app_home == NULL)
__app_home_restore(msg);
g_close_screen();
return EPDK_OK;
}
/*
switch(msg->dwAddData1)//在此处添加红外遥控音量键处理
{
case GUI_MSG_KEY_VADD:
case GUI_MSG_KEY_LONGVADD:
{
if(msg->dwAddData2 != KEY_UP_ACTION)
{
dsk_volume_inc();
}
return EPDK_OK;
}
case GUI_MSG_KEY_VDEC:
case GUI_MSG_KEY_LONGVDEC:
{
if(msg->dwAddData2 != KEY_UP_ACTION)
{
dsk_volume_dec();
}
return EPDK_OK;
}
default:
break;
}
*/
if(app_root_mute_key_proc(msg) == EPDK_OK)
{
return EPDK_OK;
}
__msg("after app_root_win_proc GUI_MSG_KEY\n");
break;
}
case GUI_MSG_TOUCH:
{
__msg("app_root_win_proc GUI_MSG_TOUCH\n");
break;
}
case DSK_MSG_FS_PART_PLUGOUT:
{
root_ctrl_t *root_ctrl;
H_WIN root, child, next_child;
char winname[256];
// eLIBs_printf("**************app_root_win_proc, DSK_MSG_FS_PART_PLUGOUT**************\n");
if(('D' == msg->dwAddData2)&&('E' == msg->dwAddData2)&&('Z' == msg->dwAddData2))
{
// eLIBs_printf("internal disk, not need kill apps, msg->dwAddData1=%d\n", msg->dwAddData2);
__root_scene_sem_post();
return EPDK_OK;
}
__msg("app_root_broadcast_msg, msg->dwAddData2=%d\n", msg->dwAddData2);
__app_root_broadcast_msg(msg);
__msg("********before __app_do_async***********\n");
__msg("rat_clear_all_list_by_root=%x,msg->dwAddData2=%x\n", (__u32)rat_clear_all_list_by_root, msg->dwAddData2);
///__app_do_async(msg->h_deswin, APP_ROOT_MSG_DO_ASYNC, rat_clear_all_list_by_root, (void*)(msg->dwAddData2));
///rat_clear_all_list();
__msg("********after __app_do_async***********\n");
root_check_fs_device(msg); //cai++
//return EPDK_OK;
break;
}
case DSK_MSG_FS_PART_PLUGIN:
{
root_ctrl_t *root_ctrl;
root_ctrl = (root_ctrl_t *)GUI_WinGetAddData(msg->h_deswin);
//eLIBs_printf("app_root_win_proc, DSK_MSG_FS_PART_PLUGIN\n");
if(('D' == msg->dwAddData1)&&('E' == msg->dwAddData1)&&('Z' == msg->dwAddData1))
{
//eLIBs_printf("internal disk, not need notify home app, msg->dwAddData1=%d\n", msg->dwAddData1);
return EPDK_OK;
}
__msg("app_root_broadcast_msg, msg->dwAddData1=%d\n", msg->dwAddData1);
__app_root_broadcast_msg(msg);
root_check_fs_device(msg); //add by libaiao,2011.7.13 //cai++
///return EPDK_OK;
break;
}
case DSK_MSG_VOLTAGE_CHANGE:
{
__msg("app_root_broadcast_msg, msg->dwAddData1=%d\n", msg->dwAddData1);
__app_root_broadcast_msg(msg);
return EPDK_OK;
}
case DSK_MSG_TVDAC_PLUGOUT:
case DSK_MSG_HDMI_PLUGOUT:
{
__msg("__app_root_broadcast_msg, msg->dwAddData1=%d\n", msg->dwAddData1);
__app_root_broadcast_msg(msg);
return EPDK_OK;
}
case APP_ROOT_MSG_DO_ASYNC:
{
p_app_root_fun pfun;
__msg("msg->dwAddData1=%x, msg->dwAddData2=%x\n",
msg->dwAddData1, msg->dwAddData2);
if(!msg->dwAddData1)
{
return EPDK_OK;
}
pfun = (p_app_root_fun)(msg->dwAddData1);
__msg("pfun=%x, msg->dwAddData2=%x\n", pfun, msg->dwAddData2);
__here__;
pfun((void*)(msg->dwAddData2));
__here__;
return EPDK_OK;
}
}
return GUI_ManWinDefaultProc(msg);
}