📄 appmemmgr.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:
* ---------
* AppMemMgr.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* App-Based Shared Memory Manager
*
* App-based shared memory is allocated before entering an application, and
* released when exiting an application.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*****************************************************************************
* Include
*****************************************************************************/
#include "MMI_features.h"
#include "stdC.h"
#include "L4Dr1.h"
#include "GlobalDefs.h"
#include "DebugInitDef.h"
#include "AppMemMgrGprot.h"
#include "CommonScreensEnum.h"
#include "CommonScreens.h"
#include "SettingProfile.h" /* for tone ID */
#include "wgui_categories_fmgr.h" /* Category 212 */
#ifndef MMI_ON_WIN32
#include "mmiapi_func.h"
#endif
#include "kal_non_specific_general_types.h"
#include "app_mem.h"
/*****************************************************************************
* Define
*****************************************************************************/
/*****************************************************************************
* Typedef
*****************************************************************************/
/* States of mmi_frm_appmem_stop_confirm_screen_yes() */
typedef enum
{
/* Normal case */
MMI_FRM_APPMEM_STOP_STATE_IGNORE,
/* Inside mmi_frm_appmem_stop_confirm_screen_yes() */
MMI_FRM_APPMEM_STOP_STATE_WAITING,
/* Stop operation finished inside mmi_frm_appmem_stop_confirm_screen_yes() */
MMI_FRM_APPMEM_STOP_STATE_FINISHED
} mmi_frm_appmem_stop_state_enum;
/* Context of the prompt screen */
typedef struct
{
/* Properties of the application requesting to free up more memory */
MMI_ID_TYPE app_name;
MMI_ID_TYPE app_icon;
/* Requested memory size */
U32 required_size;
MMI_BOOL require_full_pool;
/* Used inside mmi_frm_appmem_stop_confirm_screen_yes() */
mmi_frm_appmem_stop_state_enum stop_state;
kal_uint32 app_id_confirm_to_stop;
/* Keep SCR_APPMEM_STOP_PROMPT & SCR_APPMEM_STOP_PROGRESSING in history
at its exit function. */
MMI_BOOL keep_prompt_screen_in_history;
void (*success_callback)(void);
} mmi_frm_appmem_prompt_struct;
typedef struct
{
/* Number of applications using App-based ASM */
S32 num_app;
/* Detailed information */
applib_mem_ap_usage_struct applist[MMI_FRM_APPMEM_MAX_APP_PROMPTED];
} mmi_frm_appmem_prompt_screen_struct;
/*****************************************************************************
* Local Variable
*****************************************************************************/
/* Life cycle: prompt user to stop applications -> successfully get the memory or cancelled */
static mmi_frm_appmem_prompt_struct g_mmi_frm_appmem_prompt;
/* Life cycle: inside the prompt screen only (SCR_APPMEM_STOP_PROMPT) */
static mmi_frm_appmem_prompt_screen_struct *g_mmi_frm_appmem_prompt_screen = NULL;
/*****************************************************************************
* Local Function
*****************************************************************************/
/* Prototype declarations: */
static void mmi_frm_appmem_entry_prompt_screen(void);
static void mmi_frm_appmem_entry_progressing_screen(void);
static void mmi_frm_appmem_invoke_release_mem_success_callback(void);
static void mmi_frm_appmem_stop_finished_handler(kal_uint32 app_id, kal_uint32 string_id, kal_bool result);
/*****************************************************************************
* FUNCTION
* mmi_frm_appmem_is_in_prompt_screens
* DESCRIPTION
* Whether MMI is inside prompt screens (SCR_APPMEM_STOP_PROMPT and SCR_APPMEM_STOP_PROGRESSING)
* PARAMETERS
* void
* RETURNS
* MMI_BOOL
*****************************************************************************/
static MMI_BOOL mmi_frm_appmem_is_in_prompt_screens(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 curr_scr_id;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
curr_scr_id = GetExitScrnID();
return curr_scr_id == SCR_APPMEM_STOP_PROMPT ||
curr_scr_id == SCR_APPMEM_STOP_PROGRESSING;
}
/*****************************************************************************
* FUNCTION
* mmi_frm_appmem_is_prompt_screens_in_history
* DESCRIPTION
* Whether a prompt screen (SCR_APPMEM_STOP_PROMPT or SCR_APPMEM_STOP_PROGRESSING)
* is inside history.
* PARAMETERS
* void
* RETURNS
* MMI_BOOL
*****************************************************************************/
static MMI_BOOL mmi_frm_appmem_is_prompt_screens_in_history(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return IsScreenPresent(SCR_APPMEM_STOP_PROMPT) ||
IsScreenPresent(SCR_APPMEM_STOP_PROGRESSING);
}
/*****************************************************************************
* FUNCTION
* mmi_frm_appmem_jump_to_prompt_screen
* DESCRIPTION
* Go back to the prompt screen
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_frm_appmem_jump_to_prompt_screen(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_ASSERT(IsScreenPresent(SCR_APPMEM_STOP_PROMPT));
GoBackToHistory(SCR_APPMEM_STOP_PROMPT);
}
/*****************************************************************************
* FUNCTION
* mmi_frm_appmem_exit_progressing_screen
* DESCRIPTION
* Exit function of progressing screen
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_frm_appmem_exit_progressing_screen(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
history h;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_mmi_frm_appmem_prompt.keep_prompt_screen_in_history)
{
h.scrnID = SCR_APPMEM_STOP_PROGRESSING;
h.entryFuncPtr = mmi_frm_appmem_entry_progressing_screen;
pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) L"");
GetCategoryHistory(h.guiBuffer);
AddHistory(h);
}
}
/*****************************************************************************
* FUNCTION
* mmi_frm_appmem_check_enough_memory
* DESCRIPTION
* Check if the free memory is enough
* PARAMETERS
* void
* RETURNS
* MMI_BOOL
*****************************************************************************/
static MMI_BOOL mmi_frm_appmem_check_enough_memory(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_mmi_frm_appmem_prompt.require_full_pool && applib_mem_ap_get_alloc_count() == 0)
{
return MMI_TRUE;
}
if (!g_mmi_frm_appmem_prompt.require_full_pool &&
applib_mem_ap_get_max_alloc_size() >= g_mmi_frm_appmem_prompt.required_size)
{
return MMI_TRUE;
}
return MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_frm_appmem_entry_progressing_screen
* DESCRIPTION
* Entry function of progressing screen when an application has not finished stopping
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_frm_appmem_entry_progressing_screen(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *guiBuffer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -