1e41f4b71Sopenharmony_ci# Ability Framework
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Overview
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciThe **ability framework** (also called the ability management framework) is used to centrally schedule and manage the running and lifecycle of abilities. An application process can support multiple abilities, and an ability can be called either within a process or across processes. The Ability Manager Service provided in the framework schedules and manages abilities in an application and manages the lifecycle changes of these abilities.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci![](figures/aafwk.png)
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci**Architecture Description**
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci- **Ability Kit** provides basic running environment for an ability to run. **Ability** is the minimum unit for the system to schedule an application. It is a component that can implement an independent functionality. An application can contain one or more **Ability** instances. There are two types of abilities: Feature Ability (FA) and Particle Ability (PA). FAs use the Page template, and PAs use the Service and Data templates. (The abilities implemented using the Page, Service, or Data template are referred to as the Page, Service, or Data abilities for short, respectively.)
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci- **AbilityManagerService** is a system service used to coordinate the running relationships and lifecycle states of **Ability** instances.
14e41f4b71Sopenharmony_ci  - The AbilityStackManager sub-module maintains the presentation sequence of abilities in the stack.
15e41f4b71Sopenharmony_ci  - The AbilityConnectManager sub-module manages connections to Service abilities.
16e41f4b71Sopenharmony_ci  - The DataAbilityManager sub-module manages Data abilities.
17e41f4b71Sopenharmony_ci  - The AppScheduler sub-module schedules and manages the App Manager Service.
18e41f4b71Sopenharmony_ci  - The AbilityScheduler sub-module schedules and manages abilities.
19e41f4b71Sopenharmony_ci  - The LifecycleDeal sub-module schedules and manages ability lifecycle events.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciThe **ability lifecycle** is a general term for all states of an ability (either a Page or a Service ability), such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci  - The following figure shows the transitions between different states in a Page ability's lifecycle.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci![PageAbility-Lifecycle](figures/page-ability-lifecycle.png)
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci  - The following figure shows the transitions between different states in a Service ability's lifecycle.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci![ServiceAbility-Lifecycle](figures/service-ability-lifecycle.png)
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Description of ability lifecycle states:**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci  - **UNINITIALIZED**: The ability is not initialized. This state is a temporary state. An ability changes directly to the **INITIAL** state upon its creation.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci  - **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.
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci  - **INACTIVE**: The ability is visible but does not gain focus. This state is the same as the **ACTIVE** state because the concept of window focus is not supported currently.
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci  - **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.
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci  - **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.
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ciThe following figure shows the callbacks to be invoked during the transitions between different lifecycle states of a Page ability.
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci![PageAbility-Lifecycle-Callbacks](figures/page-ability-lifecycle-callbacks.png)
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ciThe following figure shows the callbacks to be invoked during the transitions between different lifecycle states of a Service ability.
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci![Service-Ability-Lifecycle-Callbacks](figures/service-ability-lifecycle-callbacks.jpg)
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci## Directory Structure
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci```
60e41f4b71Sopenharmony_cifoundation/
61e41f4b71Sopenharmony_ci└──foundation/aafwk/standard
62e41f4b71Sopenharmony_ci   ├── frameworks
63e41f4b71Sopenharmony_ci   │   └── kits
64e41f4b71Sopenharmony_ci   │       └── ability						# Core code for AbilityKit
65e41f4b71Sopenharmony_ci   ├── interfaces
66e41f4b71Sopenharmony_ci   │   └── innerkits
67e41f4b71Sopenharmony_ci   │        └── want						# External APIs of the information carrier used for interaction between abilities
68e41f4b71Sopenharmony_ci   └── services
69e41f4b71Sopenharmony_ci       ├── abilitymgr						# Framework code of the Ability Manager Service
70e41f4b71Sopenharmony_ci       ├── common							# Log component
71e41f4b71Sopenharmony_ci       ├── test								# Testing
72e41f4b71Sopenharmony_ci       └── tools							# aa command code
73e41f4b71Sopenharmony_ci```
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci## Usage Guidelines
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ciThe application framework does not have the permission management capability.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ciIn the current version, the JavaScript APIs of the following modules are provided only for the system applications Launcher, Settings, and SystemUI. Significant changes may be provided in later versions.
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci- @ohos.feature_ability.d.ts
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci- @ohos.napi_ability_manager.d.ts
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci- abilityinfo.d.ts
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci- abilitymissioninfo.d.ts
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci- applicationinfo.d.ts
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci- appprocessstate.ts
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci- common.d.ts
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci- elementname.d.ts
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci- moduleinfo.d.ts
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci- processinfo.d.ts
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci- want.d.ts
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci## **aa Commands**
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci**aa help**
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci| Command   | Description              |
108e41f4b71Sopenharmony_ci| ------- | ------------------ |
109e41f4b71Sopenharmony_ci| aa help | Displays the command help information.|
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**aa start**
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci| Command                                                     | Description                    |
114e41f4b71Sopenharmony_ci| --------------------------------------------------------- | ------------------------ |
115e41f4b71Sopenharmony_ci| aa start [-d <device>] -a <ability-name> -b <bundle-name> | Starts an ability. The device ID can be empty.|
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ciExample:
118e41f4b71Sopenharmony_ci```
119e41f4b71Sopenharmony_ciaa start -d 12345 -a com.ohos.app.MainAbility -b com.ohos.app
120e41f4b71Sopenharmony_ci```
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci**aa dump**
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci| Command      | Description                 |
125e41f4b71Sopenharmony_ci| ---------- | --------------------- |
126e41f4b71Sopenharmony_ci| aa dump -a | Displays the ability information in the stack.|
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci## Repositories Involved
129e41f4b71Sopenharmony_ciAbility framework
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci[ability_base](https://gitee.com/openharmony/ability_ability_base)
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci[ability_runtime](https://gitee.com/openharmony/ability_ability_runtime)
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci[form_fwk](https://gitee.com/openharmony/ability_form_fwk)
136