Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | 17-Mar-2025 | - | ||||
figures/ | H | 17-Mar-2025 | - | |||
frameworks/ | H | 17-Mar-2025 | - | 6,452 | 4,673 | |
interfaces/ | H | 17-Mar-2025 | - | 3,195 | 1,451 | |
services/abilitymgr_lite/ | H | 17-Mar-2025 | - | 12,047 | 9,119 | |
LICENSE | H A D | 17-Mar-2025 | 10.1 KiB | 177 | 150 | |
OAT.xml | H A D | 17-Mar-2025 | 5.2 KiB | 79 | 32 | |
README.md | H A D | 17-Mar-2025 | 7.1 KiB | 95 | 64 | |
README_zh.md | H A D | 17-Mar-2025 | 5.9 KiB | 88 | 58 | |
ability_lite.gni | H A D | 17-Mar-2025 | 1.2 KiB | 26 | 24 | |
bundle.json | H A D | 17-Mar-2025 | 1.4 KiB | 50 | 49 |
README.md
1# Ability Management Framework<a name="EN-US_TOPIC_0000001062157546"></a> 2 3- [Introduction](#section11660541593) 4- [Directory Structure](#section1464106163817) 5- [Usage](#section1954314201620) 6- [Repositories Involved](#section93061357133720) 7 8## Introduction<a name="section11660541593"></a> 9 10The ability management framework is provided by OpenHarmony for you to develop OpenHarmony applications. The following figure shows the architecture of the ability management framework. 11 12**Figure 1** Ability management framework 13 14 15 16- **AbilityKit** is a development kit provided by the ability management framework. You can use this kit to develop applications based on the **Ability** component. There are two types of applications developed based on the **Ability** component: **JS Ability** developed using the JavaScript language and **Native Ability** developed using the C/C++ language. The **JS application development framework** encapsulates JavaScript UI components on the basis of the AbilityKit and is used to help you quickly develop JS Ability-based applications. 17- **Ability** is the minimum unit for the system to schedule applications. It is a component that can implement an independent functionality. An application can contain one or more **Ability** instances. There are two types of templates that you can use to create an **Ability** instance: Page and Service. 18 - An **Ability using the Page template** \(Page ability for short\) provides a UI for interacting with users. 19 - An **Ability using the Service template** \(Service ability for short\) does not have a UI and is used for running background tasks. 20 21- An **AbilitySlice** represents a single screen and its control logic. It is specific to Page abilities. A Page ability may contain one ability slice or multiple ability slices that provide highly relevant capabilities. The following figure shows the relationship between a Page ability and its ability slices. 22 23**Figure 2** Relationship between a Page ability and its ability slices 24 25 26 27- **Lifecycle** is a general term for all states of an ability, including **UNINITIALIZED**, **INITIAL**, **INACTIVE**, **ACTIVE**, and **BACKGROUND**. The following figure shows the lifecycle state transition of an ability. 28 29**Figure 3** Lifecycle state transition of a Page ability 30 31 32 33- Description of ability lifecycle states: 34 - **UNINITIALIZED**: The ability is not initialized. This state is a temporary state. An ability changes directly to the **INITIAL** state upon its creation. 35 36 - **INITIAL**: This state refers to the initial or stopped state. The ability in this state is not running. The ability enters the **INACTIVE** state after it is started. 37 38 - **INACTIVE**: The ability is visible but does not gain focus. 39 40 - **ACTIVE**: The ability is in the foreground and has focus. The ability changes from the **ACTIVE** state to the **INACTIVE** state before returning to the background. 41 42 - **BACKGROUND**: The ability returns to the background. After being re-activated, the ability enters the **ACTIVE** state. After being destroyed, the ability enters the **INITIAL** state. 43 44- **AbilityLoader** is used to register and load **Ability** classes. After creating an **Ability** class, you should first call the registration API defined in **AbilityLoader** to register the **Ability** class name with the ability management framework so that this **Ability** can be instantiated when being started. 45- **AbilityManager** enables inter-process communication \(IPC\) between the AbilityKit and the Ability Manager Service. 46- **EventHandler** is provided by the AbilityKit to enable inter-thread communication between abilities. 47- The **Ability Manager Service** is a system service used to coordinate the running relationships and lifecycle states of **Ability** instances. It consists of the following sub-modules: 48 - The **service startup** sub-module starts and registers the Ability Manager Service. 49 - The **service interface management** sub-module manages external capabilities provided by the Ability Manager Service. 50 - The **process management** sub-module starts and destroys processes where **Ability** instances are running, and maintains the process information. 51 - The **ability stack management** sub-module maintains the presentation sequence of abilities in the stack. 52 - The **lifecycle scheduling** sub-module changes an ability to a particular state based on the current operation of the system. 53 - The **connection management** sub-module manages connections to Service abilities. 54 55- **AppSpawn** is a system service used to create the process for running an ability. This service has high permissions. It sets permissions for **Ability** instances and pre-loads some common modules to accelerate application startup. 56 57## Directory Structure<a name="section1464106163817"></a> 58 59``` 60/foundation/ability/ability_lite 61 ├── frameworks 62 │ ├── ability_lite # Core implementation code of AbilityKit 63 │ ├── abilitymgr_lite # Client code used for communication between the AbilityKit and Ability Manager Service 64 │ └── want_lite # Implementation code of the information carrier for interaction between abilities 65 ├── interfaces 66 │ ├── kits 67 │ │ ├── ability_lite # AbilityKit APIs exposed externally 68 │ │ └── want_lite # External APIs of the information carrier for interaction between abilities 69 │ └── inner_api 70 │ └── abilitymgr_lite # Internal APIs provided by the Ability Manager Service for other subsystems 71 └── services 72 └── abilitymgr_lite # Implementation code of the Ability Manager Service 73``` 74 75## Usage<a name="section1954314201620"></a> 76 77- The Ability Manager Service is running in the foundation process. 78- The Ability Manager Service is registered with **sa\_manager**. **sa\_manager** runs in the foundation process and sets up a thread runtime environment for the service. For details about how to create and use the Ability Manager Service, see SA Framework. 79- The Ability Manager Service starts upon OS startup. 80 81- After the HAP installation is complete, you can use the aa tool to run the demo for starting the specified ability through the following command. \(Taking **hispark\_taurus** as an example, you can obtain the aa tool from the **out/hispark\_taurus/ipcamera\_hispark\_taurus/dev\_tools/bin** directory after the version building.\) 82 83``` 84./bin/aa start -p com.xxxxxx.hiability -n MainAbility 85``` 86 87## Repositories Involved<a name="section93061357133720"></a> 88 89[Ability framework](https://gitee.com/openharmony/docs/blob/master/en/readme/ability.md) 90 91**aafwk\_aafwk\_lite** 92 93[appexecfwk\_appexecfwk\_lite](https://gitee.com/openharmony/appexecfwk_appexecfwk_lite/blob/master/README.md) 94 95
README_zh.md
1# 元能力组件<a name="ZH-CN_TOPIC_0000001062157546"></a> 2 3- [简介](#section11660541593) 4- [目录](#section1464106163817) 5- [使用说明](#section1954314201620) 6- [相关仓](#section93061357133720) 7 8## 简介<a name="section11660541593"></a> 9 10**元能力组件**,是OpenHarmony为开发者提供的一套开发鸿蒙应用的开发框架。元能力组件由如下模块组成: 11 12**图1** 元能力组件框架图 13 14 15 16- **AbilityKit**是Ability框架提供给开发者的开发包,开发者基于该开发包可以开发出基于Ability组件的应用。基于Ability组件开发的应用有两种类型:基于Javascript语言开发的Ability(**JS Ability**)和基于C/C++语言开发的Ability(**Native Ability**)。**JS应用开发框架**是开发者开发JS Ability所用到框架,是在AbilityKit基础封装的包含JS UI组件的一套方便开发者能够迅速开发Ability应用的框架。 17- **Ability**是系统调度应用的最小单元,是能够完成一个独立功能的组件,一个应用可以包含一个或多个Ability。Ability分为两种类型:Page类型的Ability和Service类型的Ability 18 - **Page类型的Ability**:带有界面,为用户提供人机交互的能力。 19 - **Service类型的Ability**:不带界面,为用户提供后台任务机制。 20 21- **AbilitySlice**是单个页面及其控制逻辑的总和,是Page类型Ability特有的组件,一个Page类型的Ability可以包含多个AbilitySlice,此时,这些页面提供的业务能力应当是高度相关的。Page类型的Ability和AbilitySlice的关系如下图2所示: 22 23**图2** Ability与AbilitySlice的关系图 24 25 26 27- **生命周期**是Ability被调度到启动、激活、隐藏和退出等各个状态的的统称。Ability各生命周期流转如下图所示: 28 29**图3** Ability生命周期流转图 30 31 32 33- Ability生命周期各状态解析: 34 - **UNINITIALIZED**:未初始状态,为临时状态,Ability被创建后会由UNINITIALIZED状态进入INITIAL状态; 35 36 - **INITIAL**:初始化状态,也表示停止状态,表示当前Ability未运行,Ability被启动后由INITIAL态进入INACTIVE状态; 37 38 - **INACTIVE**:未激活状态,表示当前窗口已显示但是无焦点状态。 39 40 - **ACTIVE**:前台激活状态,表示当前窗口已显示,并获取焦点,Ability在退到后台之前先由ACTIVE状态进入INACTIVE状态; 41 42 - **BACKGROUND**: 后台状态,表示当前Ability退到后台,Ability在被销毁后由BACKGROUND状态进入INITIAL状态,或者重新被激活后由BACKGROUND状态进入ACTIVE状态。 43 44- **AbilityLoader**负责注册和加载开发者Ability的模块。开发者开发的Ability先要调用AbilityLoader的注册接口注册到框架中,接着Ability启动时会被实例化。 45- **AbilityManager**负责AbilityKit和Ability管理服务进行IPC的通信。 46- **EventHandler**是AbilityKit提供给开发者的用于在Ability中实现线程间通信的一个模块。 47- **Ability运行管理服务**是用于协调各Ability运行关系、及生命周期进行调度的系统服务。其中,**服务启动**模块负责Ability管理服务的启动、注册等。**服务接口管理模块**负责Ability管理服务对外能力的管理。**进程管理模块**负责Ability应用所在进程的启动和销毁、及其进程信息维护等功能。**Ability栈管理模块**负责维护各个Ability之间跳转的先后关系。**生命周期调度模块**是Ability管理服务根据系统当前的操作调度Ability进入相应的状态的模块。**连接管理模块**是Ability管理服务对Service类型Ability连接管理的模块。 48- **AppSpawn**是负责创建Ability应用所在进程的系统服务,该服务有较高的权限,为Ability应用设置相应的权限,并预加载一些通用的模块,加速应用的启动。 49 50## 目录<a name="section1464106163817"></a> 51 52``` 53/foundation/ability/ability_lite 54 ├── frameworks 55 │ ├── ability_lite # AbilityKit实现的核心代码 56 │ ├── abilitymgr_lite # 管理AbilityKit与Ability管理服务通信的客户端代码 57 │ └── want_lite # Ability之间交互的信息载体的实现代码 58 ├── interfaces 59 │ ├── kits 60 │ │ ├── ability_lite # AbilityKit为开发者提供的接口 61 │ │ └── want_lite # Ability之间交互的信息载体的对外接口 62 │ └── inner_api 63 │ └── abilitymgr_lite # Ability管理服务为其它子系统提供的接口 64 └── services 65 └── abilitymgr_lite # Ability管理服务的实现代码 66``` 67 68## 使用说明<a name="section1954314201620"></a> 69 70- 元能力运行管理服务为AbilityMs,服务运行于foudation进程中; 71- AbilityMs注册到sa\_manager中,sa\_manager运行于foundation进程中,sa\_manager为AbilityMs创建线程运行环境。具体创建AbilityMs服务的方式以及使用该服务的方式,可参考系统服务框架子系统; 72- 系统启动后,AbilityMs会随系统启动而启动; 73 74- 包安装完成后,通过如下命令(以hispark\_taurus为例,aa工具在系统构建后放置在out/hispark\_taurus/ipcamera\_hispark\_taurus/dev\_tools/bin下),运行Demo启动相应Ability: 75 76``` 77./bin/aa start -p com.xxxxxx.hiability -n MainAbility 78``` 79 80## 相关仓<a name="section93061357133720"></a> 81 82[元能力子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%85%83%E8%83%BD%E5%8A%9B%E5%AD%90%E7%B3%BB%E7%BB%9F.md) 83 84**aafwk\_aafwk\_lite** 85 86[appexecfwk\_appexecfwk\_lite](https://gitee.com/openharmony/appexecfwk_appexecfwk_lite/blob/master/README_zh.md) 87 88