MTK widget development and debug

Source: Internet
Author: User

MTK widget development and debug

 

1 goal
This document describes how to develop MTK widgets Based on MTK freature phone modification and customization.

Range 2
This document can be used as an example for beginners of MTK development engineers. As I have learned a little, the following is not necessarily correct. Therefore, if you discover any omissions or errors, you can consider it yourself. I am very grateful for this.

3widget Introduction
3.1widget Overview
From mtk10a code base, MTK has added the idle screen widget module. This module is different from the plutommi module, and the code is written in C ++. Its widget control no longer uses the plutommi control. Instead, a set of controls is rewritten based on C ++. To help engineers who are familiar with C development quickly get started, they are familiar with the venusmmi module. The following describes the key points of widget development and modification in detail.
3.2widget Structure
The widget framework structure can be roughly divided into the application layer, framework layer, service layer, adaptation layer, and view layer. The widget framework is as follows:

Figure 1

1. Application Layer
Code structure:
Venusmmi \ app \ shellapp \ Panel \ homescreen
The widget application layer is responsible for building, displaying, and operating the widget interface. Each widget is an independent file. You can write all the widgets in a single file, but the code is too large for maintenance. Therefore, each widget is an independent file for easy maintenance.
Example of writing several widgets in a file:
Vapp_hs_widget_nollec_widget.h
Vapp_hs_widget_nollec_widget.cpp
There are many examples of writing a widget in a file, such:
Vapp_hs_widget_wireless_manager.h
Vapp_hs_widget_wireless_manager.cpp

2. Framework Layer
Code structure:
Venusmmi \ framework
The widget framework layer is responsible for building the entire widget. Few items need to be modified. I don't know much about them here.

3. Service Layer
Code structure:
Venusmmi \ service \ data
The widget service layer is responsible for processing module information in plutommi. For example, when the network signal is changed or the battery power is changed, the service layer is responsible for handling changes in the module status of the plutommi layer.

4. Adaptation Layer
Code structure:
Venusmmi \ pluto_adapter \ shellapp \ Panel \ homescreen
The widget adaptation layer is equivalent to a bridge connecting plutommi and venusmmi. Of course, venusmmi cannot directly call the interface of the plutommi layer module. The widget Adaptation Layer acts as a adapter.

5. View Layer
Code structure:
Venusmmi \ visual \ CP
The widget view layer provides various widgets for widgets, such as buttons, menus, lists, calendars, pages, and dialogs.
The following figure shows the code structure of the Widget:

Figure 2

4widget Development
4.1 Add the compilation path
1. plutommi compilation path
If files are added to the adaptation layer and service layer of venusmmi, add the adaptation layer and service layer path of venusmmi to the make \ plutommi \ mmi_framework \ mmi_framework.inc file:
Venusmmi \ pluto_adapter
Venusmmi \ service \ data

2. venusmmi compilation path
Add the application code path to make \ venusmmi. Inc:
Venusmmi \ app \ shellapp \ Panel \ homescreen \ vapp_hs_widget_nollec_widget.cpp
Venusmmi \ app \ shellapp \ Panel \ homescreen \ vapp_hs_widget_wireless_manager.cpp

4.2 Add Resource Capacity
1. Define the resource file capacity in plutommi \ MMI \ Inc \ mmi_res_range_def.h:

RESOURCE_BASE_RANGE(APP_VENUS_HOMESCREEN_WG_NOLLEC_WIDGET,       100),    RESOURCE_BASE_RANGE(APP_VENUS_HOMESCREEN_WG_WIRELESS_MANAGER,  40),

2. Define the resource path:

/***************************************************************************** Venus Homescreen Widget Nollec Widget******************************************************************************/#define VENUS_HOMESCREEN_WIDGET_NOLLEC_WIDGET_BASE ((U16) GET_RESOURCE_BASE(APP_VENUS_HOMESCREEN_WG_NOLLEC_WIDGET))#define VENUS_HOMESCREEN_WIDGET_NOLLEC_WIDGET_BASE_MAX     ((U16) GET_RESOURCE_MAX(APP_VENUS_HOMESCREEN_WG_NOLLEC_WIDGET))RESOURCE_BASE_TABLE_ITEM_PATH(APP_VENUS_HOMESCREEN_WG_NOLLEC_WIDGET, "..\\venusmmi\\app\\ShellApp\\panel\\HomeScreen\\res\\")/***************************************************************************** Venus Homescreen Widget Wireless Manager******************************************************************************/#define VENUS_HOMESCREEN_WIDGET_WIRELESS_MGR_BASE           ((U16) GET_RESOURCE_BASE(APP_VENUS_HOMESCREEN_WG_WIRELESS_MANAGER))#define VENUS_HOMESCREEN_WIDGET_WIRELESS_MGR_BASE_MAX      ((U16) GET_RESOURCE_MAX(APP_VENUS_HOMESCREEN_WG_WIRELESS_MANAGER))RESOURCE_BASE_TABLE_ITEM_PATH(APP_VENUS_HOMESCREEN_WG_WIRELESS_MANAGER, "..\\venusmmi\\app\\ShellApp\\panel\\HomeScreen\\res\\")

 

4.3 Add a resource header file
Define the application resource header file in venusmmi \ pluto_adapter \ interface \ res \ vapp_hs_res.h. Generally, if the application name you define is xxxx_xxxx, the generated header file is generally:
Mmi_rp_app_venus_homescreen_wg_xxxx_xxxx_def.h
For example:

#include "mmi_rp_app_venus_homescreen_wg_nollec_widget_def.h"#include "mmi_rp_app_venus_homescreen_wg_wireless_manager_def.h"

4.4 Add application Definitions
Add the application definition in venusmmi \ app \ shellapp \ Panel \ homescreen \ vapp_hs_widget_cfg.h:

VAPP_HS_NEW_WIDGET(        VappHsWidgetWirelessManager,        VAPP_HS_IMG_WG_ICON_WIRELESS_MANAGER,        VAPP_HS_STR_WG_WIRELESS_MANAGER,        VAPP_HS_WIDGET_ATTR_NULL),

Vapphswidgetwirelessmanager is the class definition of wireless manager, vapp_hs_img_wg_icon_wireless_manager is the icon of the widget, and vapp_hs_str_wg_wireless_manager is the string definition of the widget.

4.5 Add an application
Add a resource file to venusmmi \ app \ shellapp \ Panel \ homescreen \ Res:
Vapp_hs_widget_wireless_manager.res
Vapp_hs_widget_nollec_widget.res
Add the. h and. cpp files to the venusmmi \ app \ shellapp \ Panel \ homescreen file:
Vapp_hs_widget_nollec_widget.h
Vapp_hs_widget_nollec_widget.cpp
Vapp_hs_widget_wireless_manager.h
Vapp_hs_widget_wireless_manager.cpp

Taking torch of nollec widget as an example, the nollec widget is the simplest application. It mainly implements link widgets such as torch, battery manager, Facebook, Gtalk, and Twitter.

Figure 3

1. Define torch class:

Class authorization: Public vapphswidget {callback (vapphswidgettorch); // constructor/destructor public: vapphswidgettorch (); // overridepublic: Virtual vfx2010geticon (); // obtain the icon virtual vfx2010getname (); // obtain the widget string name virtual void oncreateview (); // create the widget view virtual void onreleaseview () in idle (); // release (destroy) widget view virtual vfxbool oncreateiconview (); // create an icon view virtual void onreleaseiconview () in the widget bar; // release protected: Virtual void ondirectlaunch (); // click widget operation # If 0 virtual vfxbool oncontainpoint (// click a widget or control operation const vfxpoint & point // [in] Point) const; # endifprivate: void updatetorchicon (vfxu32 status); void updatetorch (vfxu32 status); Private: vfximageframe * m_torchimg; // vfxtextframe * m_textonoff; vfximage * m_imageicon ;};

 

Oncreateview () and onreleaseview () are mandatory. They are responsible for building and destroying widgets. Oncreateiconview () and onreleaseiconview () can be rewritten only when the widget bar is dynamically refreshed or displayed. For example, the second-hand rotation of the Dynamic Display clock, for example, the torch is still on the background, and the display status should also be on.
2. Implement torch class
For specific implementation classes, refer to the rink project or the code based on the mt6236 project.

4.6 add an Application Service
Add the widget service program to venusmmi \ service \ data:
Vdat_nollec_widget.h
Vdat_nollec_widget.cpp
The role of this service program is to listen to changes in the data status of the same module of plutommi. For example, if a flashlight is enabled in the torch module of plutommi, return to the idle interface, the corresponding torch widget should also be on. For example, if I modified the time, the idle clock widget time should also be modified accordingly. The service layer serves as a listener.

5widget modification and debug
5.1 how to add a third-party widget
1. Add a third-party Executable File
Add a third-party widget executable file to vendor \ widget \ google \ gadgets \ romized, for example:
Mobilestock. WGT. HEX

2. Add the import file to the code.
Add the import file to the custom \ common \ custom_gadget_config.c file:

static const unsigned char rom_wgt_03[] = {  #include "MobileStock.wgt.hex"};

Add the widget Rom variable to the const widget_mgr_pre_install_wgt_struct g_gadget_mgr_pre_install_wgt_table [] struct:
{Rom_wgt_03, sizeof (rom_wgt_03), widget_mgr_drive_public, 0, 0, 0, 0 },

To delete a third-party widget, you only need to unregister the above two pieces of code.

5.2 widget icon arrangement in widget bar
The sorting rules are arranged horizontally as required by the project, and vertically as needed. You can modify the following functions:
Void vapphsshortcutbar: arrange (vfxs32 crossidx)

5.3 how to adjust the default position of the idle screen widget
First adjust the widget location in the simulator, and then in the vfxu8 * vapphswidgetmgr: readnvram (vfxu8 * Buf, vfxs16 size) function in the vapp_hs_widget_mgr.cpp file, the author adds the following section to obtain the memory hexadecimal data. Save the hexadecimal data as the default value in the default value settings of NV.
For specific code, see the vapp_hs_widget_mgr.cpp file of the kirby2 project. The code snippet is as follows:

FILE *fp;VfxU8 ch;VfxU8 ch2[8];int i;fp = fopen("D:\\data.txt","w+");if(fp!=NULL){for(i=0; i<size; i++){putc('0',fp);putc('x',fp);ch = *(buf+i);sprintf((char*)ch2,"%02x",ch);fputc(ch2[0],fp);fputc(ch2[1],fp);fputc(',',fp);}fclose(fp);}

Save the hexadecimal data of drive d to the nv default value in the nvram_common_config.c file. It is very convenient and practical to add this code to obtain the hexadecimal data, So you no longer need to read the memory value from the VC and convert it to the hexadecimal data using other conversion tools. This greatly improves work efficiency.

6. Conclusion
The conclusion above is that due to the rush of time, there are inevitable omissions. Many practical skills and methods are also forgotten because they have not been using feature phone for a long time. I hope that the summary provided above will provide readers with a little bit of convenience. If you encounter problems in actual development, you only need to debug the code carefully and trace the code. All problems are not difficult. I believe the readers share the same feeling.
May Buddha bless you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.