未验证 提交 2255c99f 编写于 作者: O openharmony_ci 提交者: Gitee

!2862 Done! 2597:修改Ability部分指导文档错误

Merge pull request !2862 from wusongqing/TR2597
...@@ -28,13 +28,13 @@ The ability assistant is pre-installed in the device environment. You can direct ...@@ -28,13 +28,13 @@ The ability assistant is pre-installed in the device environment. You can direct
Starts an ability. Starts an ability.
| Name | Description | | Name | Description |
| --------- | ---------------------- | | --------- | -------------------------- |
| -h/--help | Help information. | | -h/--help | Help information. |
| -d | Device ID. This parameter is optional. | | -d | Device ID. This parameter is optional. |
| -a | Ability name. This parameter is mandatory.| | -a | Ability name. This parameter is mandatory.|
| -b | Bundle name. This parameter is mandatory. | | -b | Bundle name. This parameter is mandatory. |
| -D | Debugging mode. This parameter is optional. | | -D | Debugging mode. This parameter is optional. |
**Return value** **Return value**
...@@ -82,13 +82,20 @@ The ability assistant is pre-installed in the device environment. You can direct ...@@ -82,13 +82,20 @@ The ability assistant is pre-installed in the device environment. You can direct
| -i/--ability | AbilityRecord ID | Prints detailed information about a specified ability. | | -i/--ability | AbilityRecord ID | Prints detailed information about a specified ability. |
| -c/--client | | Prints detailed ability information. This parameter must be used together with other parameters. Example commands: **aa dump -a -c** and **aa dump -i 21 -c**.| | -c/--client | | Prints detailed ability information. This parameter must be used together with other parameters. Example commands: **aa dump -a -c** and **aa dump -i 21 -c**.|
**Method** **Method**
``` ```
aa dump -a aa dump -a
``` ```
![aa-dump-a](figures/aa-dump-a.png)
```
aa dump -l
```
![aa-dump-l](figures/aa-dump-l.png)
```
aa dump -i 12
```
![aa-dump-i](figures/aa-dump-i.png)
- **force-stop** - **force-stop**
Forcibly stops a process based on the bundle name. Forcibly stops a process based on the bundle name.
......
...@@ -10,7 +10,11 @@ The APIs provided by the test framework can be used only in the test HAP. They t ...@@ -10,7 +10,11 @@ The APIs provided by the test framework can be used only in the test HAP. They t
## Starting the Test Framework ## Starting the Test Framework
The test framework can be started by running the **aa test** command or using the IDE. The test framework can be started using either of the following methods:
- Method 1: Run the **aa test** command.
- Method 2: Use the IDE.
### Running aa test ### Running aa test
You can run the **aa test** command to start the test framework. You can specify the **TestRunner** to be used and the package name or module name of the HAP where the **TestRunner** is located. You can run the **aa test** command to start the test framework. You can specify the **TestRunner** to be used and the package name or module name of the HAP where the **TestRunner** is located.
......
# FA Model Overview # FA Model Overview
## Overall Architecture ## Overall Architecture
The development of an OpenHarmony application is essentially the development of one or more abilities. By scheduling abilities and managing their lifecycle, OpenHarmony implements application scheduling. In the FA model, three types of abilities are provided: Page, Service, and Data. The Page ability has the ArkUI and therefore provides the capability of interacting with users. The Service ability does not have a UI. It runs in the background and provides custom services for other abilities to invoke. The Data ability does not have a UI. It also runs in the background and enables other abilities to insert, delete, and query data. The development of an OpenHarmony application is essentially the development of one or more abilities. By scheduling abilities and managing their lifecycle, OpenHarmony implements application scheduling.
The Feature Ability (FA) model applies to application development using API 8 and earlier versions. In this model, there are Page, Service, Data, and Form abilities.
- The Page ability implements the ArkUI and provides the capability of interacting with users.
- The Service ability does not have a UI. It runs in the background and provides custom services for other abilities to invoke.
- The Data ability does not have a UI. It also runs in the background and enables other abilities to insert, delete, and query data.
- The Form ability provides a widget, which is a UI display mode.
## Application Package Structure ## Application Package Structure
**The following figure shows the application package structure.** **The following figure shows the application package structure.**
![fa-package-info](figures/fa-package-info.png) ![fa-package-info](figures/fa-package-info.png)
For details about the application package structure, see [Description of the Application Package Structure Configuration File](../quick-start/package-structure.md).
## Lifecycle ## Lifecycle
Among all abilities, the Page ability has the most complex lifecycle, because it has a UI and is the interaction entry of applications.
**The following figure shows the lifecycle of the Page ability.** **The following figure shows the lifecycle of the Page ability.**
![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png)
You can override lifecycle functions in **app.js/app.ets** to process application logic. The other abilities do not involve the foreground/background switchover and the **onShow** callback.
You can override the lifecycle callbacks in **app.js/app.ets** to process application logic.
Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks.
## Process and Thread Model ## Process and Thread Model
......
...@@ -2,28 +2,30 @@ ...@@ -2,28 +2,30 @@
## Overview ## Overview
### Concepts ### Concepts
The Page ability implements the ArkUI and provides the capability of interacting with users. When you create an ability in the integrated development environment (IDE), the IDE automatically creates template code. The capabilities related to the Page ability are exposed through the singleton **featureAbility**, and the lifecycle callbacks are exposed through the callbacks in **app.js/app.ets**. The Page ability implements the ArkUI and provides the capability of interacting with users. When you create an ability in the integrated development environment (IDE), the IDE automatically creates template code. The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js/app.ets**.
### Page Ability Lifecycle ### Page Ability Lifecycle
**Ability Lifecycle** **Ability lifecycle**
The ability lifecycle is a general term for all states of an ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**. The following figure shows the lifecycle state transition of the Page ability. The Page ability lifecycle is a general term for all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**.
The following figure shows the lifecycle state transition of the Page ability.
![PageAbility-Lifecycle](figures/page-ability-lifecycle.png) ![PageAbility-Lifecycle](figures/page-ability-lifecycle.png)
Description of ability lifecycle states: Description of ability lifecycle states:
- **UNINITIALIZED**: The ability is not initialized. This is a temporary state. An ability changes directly to the **INITIAL** state upon its creation. - **UNINITIALIZED**: The Page ability is not initialized. This is a temporary state. A Page ability changes directly to the **INITIAL** state upon its creation.
- **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. - **INITIAL**: This state refers to the initial or stopped state. The Page ability in this state is not running. The Page ability enters the **INACTIVE** state after it is started.
- **INACTIVE**: The ability is visible but does not gain focus. - **INACTIVE**: The ability is visible but does not gain focus.
- **ACTIVE**: The ability runs in the foreground and gains focus. - **ACTIVE**: The ability runs in the foreground and gains focus.
- **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. - **BACKGROUND**: The Page ability returns to the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state.
**The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.** **The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.**
...@@ -100,6 +102,7 @@ You can override the lifecycle callbacks provided by the Page ability in the **a ...@@ -100,6 +102,7 @@ You can override the lifecycle callbacks provided by the Page ability in the **a
``` ```
You can also include **parameters** in the **want** parameter and set its value in the key-value format. You can also include **parameters** in the **want** parameter and set its value in the key-value format.
**Example** **Example**
```javascript ```javascript
...@@ -148,6 +151,7 @@ You can also include **parameters** in the **want** parameter and set its value ...@@ -148,6 +151,7 @@ You can also include **parameters** in the **want** parameter and set its value
``` ```
Obtain **deviceId** from **DeviceManager**. The sample code is as follows: Obtain **deviceId** from **DeviceManager**. The sample code is as follows:
```ts ```ts
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmClass; let dmClass;
...@@ -167,6 +171,7 @@ Obtain **deviceId** from **DeviceManager**. The sample code is as follows: ...@@ -167,6 +171,7 @@ Obtain **deviceId** from **DeviceManager**. The sample code is as follows:
``` ```
In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code is as follows: In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code is as follows:
```ts ```ts
import abilityAccessCtrl from "@ohos.abilityAccessCtrl"; import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
import bundle from '@ohos.bundle'; import bundle from '@ohos.bundle';
...@@ -204,6 +209,7 @@ In the cross-device scenario, the application must also apply for the data synch ...@@ -204,6 +209,7 @@ In the cross-device scenario, the application must also apply for the data synch
``` ```
### Lifecycle APIs ### Lifecycle APIs
**Table 2** Lifecycle callbacks **Table 2** Lifecycle callbacks
| API | Description | | API | Description |
...@@ -216,6 +222,7 @@ In the cross-device scenario, the application must also apply for the data synch ...@@ -216,6 +222,7 @@ In the cross-device scenario, the application must also apply for the data synch
| onActive() | Called when the ability is switched to the foreground and gains focus. | | onActive() | Called when the ability is switched to the foreground and gains focus. |
**Example** **Example**
You need to override the lifecycle callbacks in **app.js/app.ets**. The IDE template generates **onCreate()** and **onDestroy()** by default. You need to override the other callbacks. You need to override the lifecycle callbacks in **app.js/app.ets**. The IDE template generates **onCreate()** and **onDestroy()** by default. You need to override the other callbacks.
```javascript ```javascript
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册