MSTAR XMMI 高级编程.ppt_第1页
MSTAR XMMI 高级编程.ppt_第2页
MSTAR XMMI 高级编程.ppt_第3页
MSTAR XMMI 高级编程.ppt_第4页
MSTAR XMMI 高级编程.ppt_第5页
已阅读5页,还剩43页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Advance Programming of XMMI,Steve Hsu, 2020/10/12,2020/10/12,2,MStar Confidential,Agenda,Basic principle Basic concept of XMMI State machine Design pattern Life cycle Communication policy Context switch Watch dog Resource management System limitation Others,2020/10/12,3,MStar Confidential,Basic prin

2、ciple,SW development process,2020/10/12,4,MStar Confidential,Basic principle,SW development process Clarify what you want to do Are requirements clear? Are requirements locked down? SRS (Software Requirement Specification) and UIS (UI flow Specification) Clarify what kind of components you need Iden

3、tify what kind of components are already supported in platform Identify what kind of components are supported but need to be extended Identify what kind of components are not supported that need to be created Look up relative documents or header files. SDD (Software Design Document) Implement accord

4、ing to your SDD Test Unit Test Integration Test System Test,2020/10/12,5,MStar Confidential,Basic concept of XMMI,View, data and logic View Defined in VDF (XRG tool) Customization Data Define menu item in VDF (Menu model) (XRG tool) Customization Predefined Text/Image/Melody (XRG tool) Customization

5、 User defined Stored in DB like Text/Image/Melody in SD and Alarm events Logic Control flows/scenarios Control state machine and event flow (XFSM tool) Control communication (Request/Response) between APs, SRVs and Widgets Control interrupt behavior Support various compile option. Customization,2020

6、/10/12,6,MStar Confidential,State machine,State machine can help to control flows or states. Not only AP uses state machine but also SRV can use state machine if necessary. Reference “State Machine and AP Designer” document,2020/10/12,7,MStar Confidential,State machine,State machine of AP Normal cas

7、e Init state The beginning state of AP Can allocate global resources here Active state AP is top AP Contain various children to control AP flow Suspend state AP is suspended and it is not top AP Can release resources which are useless at this state Stop state Shell wants to close AP Need to release

8、all resources,2020/10/12,8,MStar Confidential,State machine,State machine of AP Can not interrupt top AP AP receives Suspend event instead of Start event This Suspend event has the same param1 and param2 as Start event Keep param1 and param2 if necessary AP receives Resume event when top AP is inter

9、rupted or closed In this case, (Suspend event + Resume event) = Start event,2020/10/12,9,MStar Confidential,State machine,State machine of AP Shell closes AP before it is started AP receives Stop event when it is still at Init state,2020/10/12,10,MStar Confidential,State machine,State machine of AP

10、Combination Blue line is “Normal case” Green line is “Can not interrupt top AP” Red line is “Shell closes AP before it is started”,2020/10/12,11,MStar Confidential,State machine,Deep transition Re-entry to last active child Usually used when AP is resumed.,1. Default active mode,2. A to B2b, Default

11、,3. B2b to C, Default,4. C to B, Deep,Last active child,2020/10/12,12,MStar Confidential,State machine,Get current processing event (internal/external) during transition boolean MAE_SM_GetCurrentEvent(void* pSM, MAE_EventId* outputEvt, u32* outputParam1, u32* outputParam2); Get event parameters Chec

12、k if mode active boolean MAE_SM_IsModeActive(SM_Mao_t* app, SM_ModeId_t mode); Create condition by active mode Get active leaf mode id SM_ModeId_t MAE_SM_GetActiveLeafMode(SM_Mao_t* app);,2020/10/12,13,MStar Confidential,Design pattern,Pair Singleton Stack and Queue Show view and dialog function Sta

13、rt Applet Set applet attributes and confirm state Stop Applet Flush applet stack Allow Interrupt or not,2020/10/12,14,MStar Confidential,Design pattern,Pair It is very important concept in XMMI platform. Object create and release Make sure reference count is correct Object will not release memory if

14、 reference count is not 0 Shell will assert (debug version) when power off if there are still some objects are not released Memory allocate and free Make sure no memory leak Dont free a freed memory,2020/10/12,15,MStar Confidential,Design pattern,Pair Command request and response Make sure request a

15、nd response are in pair for any interface communication. Response is necessary unless it gets return value from request function directly. It may cause blocking (phone hang) or serious error (reset) if doesnt receive response. Error recovery for no response. Usually using a waiting timer. When timeo

16、ut Treat request fail Ignore response if it comes later,2020/10/12,16,MStar Confidential,Design pattern,Pair Command request and response Normal case Request and response of AP, SRV and Other Task are in pair.,2020/10/12,17,MStar Confidential,Design pattern,Pair Command request and response Miss res

17、ponse SRV doesnt receive Resp A from Other Task SRV needs to have error handling like response AP when timeout Make sure SRV state is still correct and be able to handle other requests,2020/10/12,18,MStar Confidential,Design pattern,Pair Command request and response Request queue Need to be able to

18、handle many requests happening at the same time Ignore requests Response fail immediately Queue requests Make sure all requests can be processed,2020/10/12,19,MStar Confidential,Design pattern,Pair Command request and response Cancel request Sometimes need to cancel request due to users command If t

19、he request is not processed like in queue, can remove it from queue and response. If the request is already processing, Send cancel request if support cancel during processing Send cancel request after receiving previous response if not support cancel during processing,2020/10/12,20,MStar Confidenti

20、al,Design pattern,Singleton We can define the AP or SRV is singleton or not by enable or disable #define _xxx_SINGLETON_ compile option Not Singleton object like PhbAp, / #define _PHBAP_SINGLETON_ Singleton object like PhbSrv, #define _PHBSRV_SINGLETON_ Singleton object System only create one and on

21、ly one Singleton object Everyone who wants to use this object adds reference count of this object Share data of this object Not Singleton object System create multiple objects Everyone who wants to use this object has its own object Data of objects is independent,2020/10/12,21,MStar Confidential,Des

22、ign pattern,Stack and Queue Use Vector Model Stack Push IVECTORMODEL_Add / IVECTORMODEL_InsertAt(VECTOR_LAST) Pop IVECTORMODEL_DeleteAt(IVECTORMODEL_Size()-1) Queue Add IVECTORMODEL_Add / IVECTORMODEL_InsertAt(VECTOR_LAST) Remove IVECTORMODEL_DeleteAt(0),2020/10/12,22,MStar Confidential,Design patte

23、rn,Show view and dialog function Normally, an Application needs to create many views and dialogs. It is better to create a XXX_ShowView() and XXX_ShowDialog(). Reduce code size More readable,2020/10/12,23,MStar Confidential,Design pattern,Start Applet Normal Mode (APM_LAUNCH_NORMAL) Only active (top

24、) applet can start an applet with normal mode. Shell will suspend active applet A directly and then start applet B Embedded Mode (APM_LAUNCH_EMBEDDED) Only active (top) applet can start an applet with embedded mode. Applet B is a child of applet A. Applet A and applet B are grouped and scheduled tog

25、ether by APM,2020/10/12,24,MStar Confidential,Design pattern,Start Applet Interruptive Mode (APM_LAUNCH_INTERRUPTIVE) Any applet or service can start an applet with interrupt mode Shell will try to suspend active applet by query its property (APM_PROP_INTERRUPTIBLE),2020/10/12,25,MStar Confidential,

26、Design pattern,Set applet attributes and confirm state SH_SetAppletAttribs(u32 Attribs, boolean bEnabled) Set base applet SH_SetAppletAttribs(APMF_BASE_APPLET, TRUE); Normally base applet is the beginner of other applets like IdleApp or MainmenuApp. Set async stop and suspend SH_SetAppletAttribs(APM

27、F_ASYNC_STOP | APMF_ASYNC_SUSPEND, TRUE); Shell will not stop or suspend the applet until applet confirms stopped or suspended. Normally used when applet has to do something before stopped or suspended. Ex. Ask user to save SMS to draft or not before SMS editor applet is suspended.,2020/10/12,26,MSt

28、ar Confidential,Design pattern,Set applet attributes and confirm state SH_ConfirmAppletState(APM_AppletConfirm_t State) Ex: SH_ConfirmAppletState(APM_CFM_STOPPED);,2020/10/12,27,MStar Confidential,Design pattern,Stop Applet Close by self SH_CloseApplet(boolean bBackToHome) MAE_EVT_APP_STOP Close by

29、shell MAE_EVT_APP_STOP If SH_SetAppletAttribs(APMF_ASYNC_STOP, TRUE); Have to SH_ConfirmAppletState(APM_CFM_STOPPED);,2020/10/12,28,MStar Confidential,Design pattern,Flush Applet stack SH_FlushAppletStack(pfnFlushCallback_t fnCallback) All applets above Base applet will be closed.,2020/10/12,29,MSta

30、r Confidential,Design pattern,Allow Interrupt or not When there is a new application is created, Shell will query top application if it can be interrupted by _XXX_GetProperty() case APM_PROP_INTERRUPTIBLE: (APM_IntQuery_Ptr)(outVal)-Allowed = Condition;,2020/10/12,30,MStar Confidential,Design patter

31、n,Allow Interrupt or not (APM_IntQuery_Ptr)(outVal)-Allowed = Condition; Condition can be TRUE; /allow to be interrupted. FALSE; /Not allow to be interrupted. (TRUE = MAE_SM_IsModeActive(,2020/10/12,31,MStar Confidential,Life Cycle,Normal Create object - Release object Dont release object if you wil

32、l use it later. Ex. Cancel model listener when object is released to make sure object can listener model changed during its life cycle. Extend objects life cycle if you use it quite often. Avoid memory fragment Static SRV Most SRVs are created when MMI task is init and released when MMI is shutdown.

33、 Add this static SRV in _xmmi_StaticObjectClsIds table.,2020/10/12,32,MStar Confidential,Communication policy,Interface function of object Event Notify Listener Callback function,2020/10/12,33,MStar Confidential,Communication policy,Interface function of object Use API to access objects variable or

34、ask object to process something Common utility functions (mmi_common_util) Global variables are not allowed Only can access variables through APIs,2020/10/12,34,MStar Confidential,Communication policy,Event SH_PostEvent(IHandler_it *pDest, MAEEvent_t Evt, u32 lParam, u32 dParam) Process in next even

35、t cycle Have destination which has direct relation to source object. Ex. SourceObj owns/creates DestObj. If Obj_A creates Obj_B, Obj_B creates Obj_C and Obj_A posts a event to Obj_C, can Obj_C receives the event?,2020/10/12,35,MStar Confidential,Communication policy,Notify When something is interest

36、ed by many APs or SRVs, send notify when something happens. Ex. SIM status changed. PhbSRV needs to sync SIM phonebook. Process in next event cycle (use post event) Normally used in SRVs Mapping event to mask. INOTIFIER_Register(pINotifier, instance, mask) INOTIFIER_DeRegister(pINotifier, instance,

37、mask) INOTIFIER_DoNotify(pINotifier, mask, eventId, param1, param2),2020/10/12,36,MStar Confidential,Communication policy,Listener Can add listener on Widget View Model or Data Model Add widget view model Get model IWIDGET_GetViewModel(IWidget *IWidgetPtr, IModel* ppModel,IBase* pOwner) Get data mod

38、el pointer. Create a listener MDLLISTENER_INIT(pMdlLsn, pfn, pData) Add listener IMODEL_AddMdlListener(IModel *pIModel, ModelListener_t *pMdlLsn) Cancel listener MDLLISTENER_CANCEL(pLsn) Use callback function, not in next event cycle. When data changed in model, call pfn (callback function) immediat

39、ely.,2020/10/12,37,MStar Confidential,Communication policy,Callback function Pass callback function to DestObj and let DestObj call callback function when something happens. Direct function call, not in next event cycle. Ex. SH_StartAppletEx(MAEClsId_t ClsId, u32 Mode, IApplet_it *ppApplet, u32 Para

40、m, pfnStartParamCleanup_t fnClean),2020/10/12,38,MStar Confidential,Context switch,Obj_B adds model listener of Obj_A. Obj_A has no relation to Obj_C. Can post event to Obj_C in CBFunc directly? No. Current context is still Obj_A, Obj_A can not post event to Obj_C.,2020/10/12,39,MStar Confidential,C

41、ontext switch,Context switch from Obj_A to Obj_B In CBFunc() SH_ResumeEx(IBase *pIssuer, IBase *pDest, pfnResumeCallbackEx_t fnCb, u32 Param) Shell will call fnCb in next event cycle. Post event to Obj_C in fnCb. SH_PostEvent(IHandler_it *pObj_B, MAEEvent_t Evt, u32 lParam, u32 dParam) Post Evt to s

42、elf first. When receive Evt, post event to Obj_C. SH_CreateTimer(s32 MSecs, MAE_PFNNOTIFY fnCallback, void *pOwner) When time expired, fnCallback,2020/10/12,40,MStar Confidential,Watch dog,Watch dog is 4 seconds (6 seconds in MP SW) If a command or loop executes over 4 seconds, it caused watch dog t

43、imeout exception. Usually happens while database access, for-loop, while-loop and recursive function call. Reset watch dog to prevent watch dog timeout vm_sysDelayWatchDogReset();,2020/10/12,41,MStar Confidential,Resource management,Resource can be memory, view, media, audio path, or something which

44、 is shared for everyone. Principle Dont keep the resource if you dont need it anymore or will not use it for a while. Ex. When AP is suspended, pop view and release resource. Create view and re-get resource again when AP is resumed. Some resources have priority policy Ex. Play ring tone (Media resou

45、rce) for Incoming call, Media player, or new SMS. If you can not get the resource, check if resource is occupied by higher priority instance.,2020/10/12,42,MStar Confidential,System limitation,Memory Pool Pool 0 Pool 5, each pool has its own size and total number Dual Pool (System and MMI) Reduce po

46、ol number usage Allocate large one memory instead of many small ones if necessary Ex. Group parameters as a Structure Ex. Use ArrayModel instead of VectoryModel System Timer Total 50 timers for all system Event Queue Size Shell max event queue size is 256 Dont post events in for-loop or while-loop, because it might cause event queue full,2020/10/12,43,MStar Confidential,Others,Define API (Interface) API includes

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论