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

📄 mmimain.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/*******************************************************************************

          CONDAT (UK)

********************************************************************************

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.

********************************************************************************

 $Project name: Basic MMI
 $Project code: BMI (6349)
 $Module:   MMI
 $File:       MmiMain.c
 $Revision:   1.0

 $Author:   Condat(UK)
 $Date:       22/02/01

********************************************************************************

 Description:



********************************************************************************

 $History: MmiMain.c

  * *****************  Version 02 *****************
 * zgz,2002.06.24
 * editEventKey() changed. if not nessary, Screen don't be updated.
 * 


  25/10/00      Original Condat(UK) BMI version.
  04/08/02      zy Mobile Innovation change the maininit()
  12/08/02      zym changed get language before in charging win
  14/08/02      zym modify mainInit() function
  15/08/02      gdy modified mainInit()
  15/08/02       xsf modified for "extern gtVibrator"
  15/08/02      zy add  control backlight and lcd
  26/08/02		hxl add for charger
  27/08/02		hxl changed for charger and ffs file
 //zym added
  * zgz,2002.08.26 change the code for timedate.
  2003/11/10    sunsj modify the method of get string length in displayAlignedPrompt function
/********************************************************************************

 $History: mmimain.c

  Date                  Modification        Author                   Describtion                                           
  -------------------------------------------------------------                                                 
  04/08/2002       1.1                    zym                       add two times 
                                                                                function MMiKeyactionpressed
                                                                                revised:showgoodbye,globalflashbattery

 $End

*******************************************************************************/
//zym added


/*******************************************************************************/

#include <stdio.h>
#define ENTITY_MFW
#undef _ResetProtectionEnabled_    //enable  auto reset function

/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>


#if defined (NEW_FRAME)

    #include "typedefs.h"
    #include "vsi.h"
    #include "pei.h"
    #include "custom.h"
    #include "gsm.h"

#else

    #include "stddefs.h"
    #include "custom.h"
    #include "gsm.h"
    #include "vsi.h"

#endif
//#include "Uart.h"
#include "mfw_sys.h"

#include "mfw_mfw.h"
#include "mfw_kbd.h"
#include "mfw_tim.h"
#include "mfw_lng.h"
#include "mfw_win.h"
#include "mfw_icn.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_edt.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_ffs.h"
#ifdef SIM_TOOLKIT
    #include "mfw_sat.h"
#endif
#include "dspl.h"

#include "fieldtest.h"

#include "p_mmi.h"
#include "aci_cmh.h"
#include "gaci_cmh.h" /* include types declared in GACI  zy 2003-03-19           */
#include "mfw_mme.h"
//#include "Sys_types.h"

#ifndef _SIMULATION_
    #include "Sys_types.h"
#endif

#include "MmiMmi.h"

#include "MmiIcons.h"
#include "MmiPins.h"
#include "MmiMain.h"
#include "MmiDialogs.h"
#include "MmiIdle.h"
#include "MmiStart.h"
#include "MmiCall.h"
#include "MmiSimToolkit.h"
#include "gdi.h"
#include "Audio.h"
#include "MmiLists.h"
#include "MmiSounds.h"
#include "MmiResources.h"
#include "MmiTimeDate.h"
#include "Mmicharging.h"//hxl add for charging win

#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "rtc_api.h"
//#include "spi_drv.h"
#include "pwr.h"
//#include "BmiEastApi.h"
#include "td.h"
#include "Mmibookshared.h"
#include "mmiQQSwitch.h" //hxl add for check qq func

/*2003/12/24,talcon add*/
#include "mmiouteridle.h"

//2004.08.02 Added by Cathy for Camera
#ifdef CAMERA_ENABLED
#include "mmicamera.h"
#endif


//#define TDTRACE 1
#include "mmiutilapi.h"

extern short singleCall;/*2004/4/14, wangyan add*/
extern int   g_kpdnum  ;   ///zym added 10/18
extern int   g_kpdtim ;  ///zym added 10/18
extern UINT32 driverFlag;//wms added 02/12/29
extern UINT8 g_HandsetPcsycMode ;   ///zy 2003-03-19 judge if modem is plug in
extern int g_switchon;
extern T_call call_data;//zy 2003-02-14 add for if lowvoltage is on and the before win is call scratched win We must destroy it
extern MfwHnd call_get_window(void);
extern void CheckNetWork();

static MfwHnd times;          /* clock via software timer */
MfwHnd timer_Hnd=NULL;//gdy add 03/04/03
//joker
MfwHnd gtVibator; //XSF 08.14 static MfwHnd gtVibator;
//int g_tmp;
//zym added
static MfwHnd times_switchoff;          /* timer switch off (GB)*/

// 2004.4.1 WYJ call no win
MfwHnd    hRingVibStartTimer;   /* timeout for vibrator then start of melody */
extern int stopvib2playmelody( MfwEvt e, MfwTim *tc );

int g_lcd_game_flag =0;    /* backlight on/off switch tangyan0418 add */
extern int game_win_focussed(void);/* adjust the game win is focused tangyan0418 add */
//Will have to be stored in PCN eventually
static uint8    ffsNeedWrite=1;//hxl add for write ffs file,when power lower,2003-5-6

/* GLOBAL CONTROL DATA      */
LngInfo mainLngInfo;                    /* language control block   */
MfwHnd mainMmiLng;                      /* global language handler  */

MMI_NM_SERVICE    g_nmService=NM_UNDEFINED;  /* actual registered nm service */
MMI_SIM_STATUS    g_simStatus;      /* actual sim status        */
T_MFW_NETWORK_STRUCT        g_plmnIdent;    /* registered plmn */

#ifndef _SIMULATION_
extern void AI_Power(SYS_UWORD8 power);
#endif

static int keyAction (MfwEvt e, MfwKbd *res);
static int key (MfwEvt e, MfwKbd *kc);
static int timer (MfwEvt e, MfwTim *t);
static void backlight (void);
static int timesEvent (MfwEvt e, MfwTim *t);
static int smsphkchecktimeEvent (MfwEvt e, MfwTim *t);
static void setWriteflag(uint8  iswrite);
static uint8 getWriteflag(void);
///joker
static int  vibratorEvent(MfwEvt e, MfwTim * t);
///zym added
void showGoodBye (T_MFW_HND win);
void goodbye_cb (void);

// this needs a additional keypress for switch on
//static MfwHnd kbd;                      /* the main keyboard        */

// nm15.02.01
// this timer is used for backlight
// the B-Sample dont support backlight
//static MfwHnd tim;                      /* the main Timer           */

//nm 15.02.01
//the power off timer is not specified
//nm static MfwHnd timdown;                /* our timer manager power down */

static MfwHnd mme;                              /* our MME manager           */

U32 GlobalIconStatus;
UBYTE globalMobileMode;
int MmiModule;

extern UBYTE  IsShowGoodbye; //2004-04-23 Sunny add

/* batterie and signal    start  */
int globalBatteryUpdate(U8 value);
int globalSignalUpdate(U8 value);

void globalFlashBattery (void);

UBYTE globalSignalPicNumber;
/* 2004/07/09 sunsj add for forbidden hall off */
int HallOffForbid = FALSE;

UBYTE globalBatteryMode; /*  */
//USHORT settingsStatus=0;
int globalMme(MfwEvt e, void *para);
/* batterie and signal     end  */

CLOCK currclock;
Date currdate;
T_RTC_DATE_TIME timedate;//zhonghz,globel var

static LONG second;

//char stringTrace[50];//2004/04/05,talcon delete */
static U8 deregis = FALSE;            /* status deregistration       */
static int lcdOffControl;//zy 08/12
extern T_idle idle_data;//zy add for gprs attach in period 11/29
extern unsigned char no_wait;            //yq added for set the phbkwiatflag
extern USHORT IsPcsyncRemove(void);//hxl add for check if pcsync line is taken out,2003-2-13
extern UINT8 g_pcsyncstatus ;//hxl add ,if  pcsync run ,return,2003-2-13

int LineControl=0;

// sbh 6/03/02 - HUPKeyOrigin is 1 if POWER_KEY is pressed in idle screen, 0 otherwise
// Means that long press of HUP key will go to idle screen, not just shut down
UBYTE HUPKeyOrigin;
/* SPR877 - SH - set to TRUE if welcome animation has finished */
extern UBYTE animation_complete;
T_MFW_CFLAG_STATUS DivertStatus = MFW_CFLAG_NOTSet;
#define TIME_MINUTE     30000//every 30seconds read rtc,zhonghz

/* 2004/06/02 sunsj modify */
#define TIME_VIBRATOR     5000
///zym added
#define TIMEDOWN        120000L         /* time for powerdown 2min  */
#define TIME_SWITCH_OFF 3000         /* switch off time delay */
#define UPLINKPGAVALUE     0x06   ///-12db--12db 0x10  0x17-0x1b  0x0-0xc  0x11- 0x16 
#define VOLUMECONTROLVALUE   6
///zym added

extern FlashData FFS_flashData;
extern *RAMValue;
#ifdef QQFUNC//hxl add for qq func switch,2003-3-24
extern int  QQReadNewSms;//hxl add for qq check sms,2003-3-14
#endif
/* Amounts to: 128 (format mode) + 8 (overwrite mode) */

/*******************************************************************************

 $Function:

 $Description:  general editor control

 $Returns:    none.

 $Arguments:

*******************************************************************************/

static MfwHnd myHandle = 0;             /* editors handle           */
static MfwHnd editTim = 0;              /* the editor timer         */
static char *formatHandle;        // SH - pointer to format string, so that editEventKey can see it
static int *formatIndex;        // SH - pointer to format index
static int *fieldIndex;         // SH - pointer to field position
static char *tmpBuf;          // SH - pointer to temporary buffer for hidden alphanumeric entry

#define KEY_PAD_MAX 5

UBYTE editControls [KCD_MAX] =      /* edit control keys:       */
{
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    '*', '#', ecNone, ecNone, ecUp, ecDown, ecLeft, ecRight,
    ecNone, ecNone, ecEnter, ecNone, ecNone, ecNone,
    ecNone, ecNone, ecEnter
};


static UBYTE editAlphaMode;                /* alpha mode flag          */
static UBYTE editCalcMode;                /* calculator mode flag          */
static UBYTE editFormatMode;      /* format mode flag */
static UBYTE editHiddenMode;      /* hidden alphanumeric mode */
static UBYTE editAlphaLevel;               /* alpha level selected     */
static UBYTE editAlphaKey;                 /* alpha mode current key   */



static UBYTE editAlpha [12][KEY_PAD_MAX] =           /* alpha mode characters    */
{
    {'.','+','-','=','0'},              //0 key
    {' ','?','!','1',':'}, {'a','b','c','2',')'}, {'d','e','f','3','('},     // 1 2 3
    {'g','h','i','4','$'}, {'j','k','l','5',' '}, {'m','n','o','6',','},     // 4 5 6
    {'p','q','r','s','7'}, {'t','u','v','8',';'}, {'w','x','y','z','9'},    // 7 8 9
    {'*','#','%','&',' '}, {' ','\'','\"','@','/'}  // star and hash keys
};

static UBYTE editAlphaU [12][KEY_PAD_MAX] =       /* upCase alpha mode characters*/
{
    {'.','+','-','=','0'},              //0 key
    {' ','?','!','1',':'}, {'A','B','C','2',')'}, {'D','E','F','3','('},    // 1 2 3
    {'G','H','I','4','$'}, {'J','K','L','5',' '}, {'M','N','O','6',','},   // 4 5 6
    {'P','Q','R','S','7'}, {'T','U','V','8',';'}, {'W','X','Y','Z','9'}, // 7 8 9
    {'*','#','%','&',' '}, {' ','\'','\"','@','/'}                // star and hash keys
};


int upCase= TRUE;
extern UINT8    Gu8_Envio_num;//enter which enviroment flag 
static int editEventTim (MfwEvt e, MfwTim *t);
static void editShowHeader (void);

extern void  JavaTaskSetup( void );   //zym added
extern void GetTimeDate(int year,short month,short day,TIMEDATE *today);  //xsf add 12.06

//hxl add 09/02,for low voltage warning--------------------------
MfwHnd timlowvoltage=0;          
int MMIStart_completed = 0;

void LowVol_Warning(void);
void LowVol_Poweroff(void);
void bat_info_init(void);
static int tim_LowVoltage_cb (MfwEvt e, MfwTim *t);
extern TffsfileCmd  ffsfileCmd;//ffs file cmd storage
extern T_MFW_CB timer_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc);

/*2003/12/23,talcon add*/
extern U8 isLcdOff();

#ifdef SEVEN_COLORS_LED
MfwHnd ColorLedBlinkTimer;
extern void ColorLedBlinkEvent( MfwEvt e, MfwTim *tc );
/* 2004/06/10 sunsj modify */
MfwHnd ServiceLedTimer;
extern void ServiceLedEvent( MfwEvt e, MfwTim *tc );
MfwHnd ServiceLedDelay;
extern void ServiceLedDelayEvent( MfwEvt e, MfwTim *tc );
#ifdef SEVEN_COLORS_LED_YAMAHA
UINT8 led_switch_on = 1;
#else
UINT8 led_switch_on = 0;
#endif

#else
UINT8 led_switch_on = 0;
#endif



//end of hxl add 09/02---------------------------------------------
/*******************************************************************************

 $Function:  mainInit

 $Description:   init MMI main module

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void mainInit (UBYTE InitCause)
{
    effs_t ffs_ret=0;//hxl add for trace flash error,2003-1-13
    uint8   nloop=0;//hxl add for check flash error,2003-2-13
    char err[50];
    //    TraceMMI("maininit");

/**the initialize must be front of all malloc dynamic memory,for example,MMS_Net_Init**/
	MI_mmimem_Init();
	
    /*clrobert */
    memset(&timedate,0,sizeof(timedate));//zhonghz,set the timedate mem
    RTC_GetDateTime(&timedate);//zhonghz,maininit read rtc
    mfwSetSignallingMethod(1);
    winAutoFocus(TRUE);
    mfwFocus = 0;                       /* reset focus              */

    memset(&ffsfileCmd,0,sizeof(TffsfileCmd));//initialise the ffs file cmd storage


    // this is called to use:
    // power driver;fieldstrength driver; audio driver
    //mmeInit();	// sbh - moved this to mmistart, as rxInit crashes mobile on startup

    //nm  mmeRtcInit(0, 0);

    HUPKeyOrigin = 0;  // sbh
    animation_complete = FALSE;    
    kbdAlways((MfwCb)keyAction);        /* global ke yboard access   */
	/* 2004/04/16 sunsj change long time from 2000 to 1500 */
    kbdTime(1200,1000,400);             /* long / repeat timeouts   */

⌨️ 快捷键说明

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