当前位置:网站首页>Analysis on the adaptation layer of openharmony UI framework (I)
Analysis on the adaptation layer of openharmony UI framework (I)
2022-04-21 17:24:00 【Openharmony technology community】
author : Liu Yongbao
Preface
Ark development framework ( abbreviation :ArkUI), It's a set UI Development framework , Provide developers for application UI The ability to develop . Provide cross platform capabilities , Integrated classes Web Development paradigm and declarative development paradigm . The framework is divided into application layers 、 Frame layer 、 Rendering engine 、 Platform adaptation and bridging layer . This paper mainly introduces some core classes of the adaptation layer , Through the relationship diagram and process interaction description of these core classes, we can see some features of the adaptation layer .
Introduction to core classes
Class diagram

- AceEngine: Globally unique , Provide an instance of door dog registration 、 Garbage collection capacity , At the same time as AceContainer The container of .
- AceContainer: seeing the name of a thing one thinks of its function , It's a container class , From the front end 、 Task executor 、 Explorer 、 Render pipeline 、 View, etc , Provides life cycle docking 、 Function scheduling interface and UI Rendering capabilities , It is a very important module in platform adaptation .
- AceAbility: The corresponding is FA In the model PageAbility, It is visible and interactive to users Ability example .
- Frontend: The abstraction of the front-end framework , from DeclarativeFrontend、JsFrontend and CardFrontend Inheritance to implement declarative 、 class WEB And Card The realization of the way .
- PlatformEventCallback: Abstraction of platform event callback , Different ability Implement their respective callback interfaces . Currently only supported OnFinish and OnStatusBarBgColorChanged Callback of two events .
- AssetManager: Abstract of resource manager , from FlutterAssetManager Realization , In the end by the FileAssetProvider Provide resource file loading .
- AceView: Rendering generates view nodes .
- TaskExecutor: Task manager .
- PipelineContext: Render pipeline .
- PlatformResRegister: Registration and management of platform resources , The rendering of platform layer is realized through interface callback .
Collaboration description
Here we take a typical APP The implementation process of window size changes to help you understand ACE How framework classes interact , See the sequence diagram :

Step-by-step instructions :
- WindowImpl The window object perceives changes in the window , Call the listener's OnSizeChange Method ;
- according to ability ID Get the corresponding AceContainer;
- from AceContainer In order to get TaskExecutor Task manager ;
- Create tasks through task manager ;
- from AceContainer Get the current View;
- call FlutterAceView::SurfaceChanged Deal with changes in the interface ;
- FlutterAceView Callback AceContainer Registered viewChangeCallback Method ;
- viewChangeCallback from PipelineContext Render pipeline objects TaskExecutor Task manager ;
- Create tasks through task manager ;
- The task method calls the rendering pipeline PipelineContext::OnSurfaceChanged Method treatment ;
- The rendering pipeline finally calls the front-end framework OnSurfaceChanged Deal with changes in the interface .
Key code implementation :
AceAbility Inherited from OHOS::Rosen::IWindowChangeListener, As a listener in OnStart When starting up, ask windows Object is registered
When the interface changes ,WindowImpl::UpdateRect Call the listener's OnSizeChange Handle
AceAbility::OnSizeChange()
Platform::FlutterAceView::SurfaceChanged()
viewChangeCallback() Callback function
PipelineContext::OnSurfaceChanged()
extend
OpenHarmony The development of user program is essentially the development of Ability.OpenHarmony The system is based on Ability Dispatch , Combined with the consistent scheduling contract provided by the system Ability Lifecycle management , So as to realize the scheduling of user programs .
Ability In the framework of API 8 And earlier versions FA Model .FA In the model Ability It is divided into PageAbility、ServiceAbility、DataAbility、FormAbility Several types . among :
- PageAbility Is to have ArkUI Realized Ability, It is visible and interactive to users Ability example .
- ServiceAbility It's also Ability A kind of , But no UI, Provide others Ability Call a custom service , Running in the background .
- DataAbility Also no UI Of Ability, Provide others Ability Add, delete and query data , Running in the background .
- FormAbility It's a card Ability, It is a form of interface display .
AceAbility The corresponding is FA In the model PageAbility, and AceContainer Container class collocation management . Others ability stay ACE The frame corresponds to AceDataAbility、AceFormAbility and AceServiceAbility, Use PaContainer Manage container classes , The relationship is as follows :

Summary
- AceAbility It's with UI Interface Ability, Not UI Interface ability yes AceDataAbility、AceFormAbility and AceServiceAbility.
- AceContainer It's a container , Aggregate the front end 、 Core functions such as rendering pipeline and task executor , Equivalent to a big manager ,ability The key processes of the system must be scheduled through it .
- adopt Frontend、PlatformEventCallback、AssetManager and AceView And so on , Provides an abstraction of the platform , By extension , Meet the adaptation of different platforms .
Reference link
Overview of ark development framework :
https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkui-overview.md
Ability The framework outlined :
https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/ability-brief.md
FA Model review :
https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/fa-brief.md
OpenHarmony Source code analysis ACE:
https://ost.51cto.com/posts/7908
For more original content, please pay attention to : Shenkaihong technical team
Beginner to master 、 Skills to cases , Systematic sharing HarmonyOS Development technology , Welcome to contribute and subscribe , Let's move forward hand in hand to build Hongmeng ecology .
Want to know more about Hongmeng , Please visit :
51CTO Hongmeng technology community jointly built with Huawei officials

版权声明
本文为[Openharmony technology community]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211631080006.html
边栏推荐
猜你喜欢

分分钟理解原型模式

Chapter 118 SQL function reverse

JVM 从入门到放弃之 ZGC 垃圾收集器

Mobile date plug-in (add your favorite)

Image Manipulation Detection by Multi-View Multi-Scale Supervision

第118章 SQL函数 REVERSE

Domain information query tool adfind

Precautions for MySQL aliasing database tables

Why can we use probability distribution density function to express probability?

169. Most elements
随机推荐
STM32 learning notes - sub second value calibration of RTC
R language uses the label function of hmisc package to add variable labels for specific variables (data columns) in dataframe, modify the data column name of dataframe to data description label, and a
MySQL create database SQL statement
MySQL sets 2 primary keys
【免费】某平台19860元编程课程资料下载,仅此1次
Why can we use probability distribution density function to express probability?
【ACM/webank】#491.递增子序列(使用HashSet来记录并防止重复子序列)
Image Manipulation Detection by Multi-View Multi-Scale Supervision
Golang binary analysis and reverse
"Method breakpoints may drastically slow down debugging" will be prompted during idea debugging
Wx open launch web app style problem
为什么可以用概率分布密度函数来表示概率?
Interpretation of a paper that points out the small errors in the classic RMS proof process
[free] download 19860 yuan programming course materials on a platform, only once
LS - Al meaning of each field
一个简单易用的文件上传方案
Redis三种模式——主从复制,哨兵模式,集群
jedis的基本使用
The R language uses the plot function to visualize the data scatter diagram, and uses the BG parameter in the par function to customize the background color in the wireframe of the visual image
Mobile date plug-in (add your favorite)