diff --git a/zh-cn/application-dev/ability/ability-assistant-guidelines.md b/zh-cn/application-dev/ability/ability-assistant-guidelines.md index 2c7ad62bc8b8af6639c9cfe31185ef60eca31dcf..a4fb42bab0c54b8c3b0fa8243624246f8ccb9495 100644 --- a/zh-cn/application-dev/ability/ability-assistant-guidelines.md +++ b/zh-cn/application-dev/ability/ability-assistant-guidelines.md @@ -78,7 +78,7 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服 | -s/--stack \ | 打印指定mission stack内的Ability。 | | -m/--mission \ | 打印指定mission内的Ability。 | | -l/--stack-list | 打印每个mission stack内的mission列表。 | - | -u/--ui | 打印system ui Ability。 | + | -u/--ui | 打印system UI Ability。 | | -e/--serv | 打印Service Ability。 | | -d/--data | 打印Data Ability。 | diff --git a/zh-cn/application-dev/ability/fa-brief.md b/zh-cn/application-dev/ability/fa-brief.md index 5fcef0a959160ad924f1fe4b5589b094e3837f1a..783010a4bbe9281c1306484b0d0e53f9c2af91ff 100644 --- a/zh-cn/application-dev/ability/fa-brief.md +++ b/zh-cn/application-dev/ability/fa-brief.md @@ -1 +1,21 @@ -# FA模型综述 \ No newline at end of file +# FA模型综述 + +## 整体架构 +鸿蒙用户程序的开发本质上就是开发Ability,OpenHarmony系统也是通过调度Ability,通过系统提供的一致性调度契约对Ability进行生命周期管理,从而实现对用户程序的调度。FA模型中Ability分为PageAbility、ServiceAbility和DataAbility三种类型。其中PageAbility具备ArkUI的Ability,是用户具体可见并可以交互的Ability实例;ServiceAbility也是Ability一种,但是没有UI,提供其他Ability调用自定义的服务,在后台运行;DataAbility也是没有UI,提供其他Ability进行数据的增删查服务,在后台运行。 + +## 应用包结构 +**应用包结构如下图所示:** +![fa-package-info](figures/fa-package-info.png) + +## 生命周期 + +**pageAbility生命周期回调如下图所示:** + +![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) +开发者可以在 app.js/app.ets 中重写生命周期函数,在对应的生命周期函数内处理应用相应逻辑。 + + +## 进程线程模型 +应用独享独立进程,Ability独享独立线程,应用进程在Ability第一次启动时创建,并为启动的Ability创建线程,应启动后再启动应用内其他Ability,会创建相应的线程。每个Ability独享一个JSRuntime,因此Ability之间是隔离的。 + +![fa-threading-nodel](figures/fa-threading-model.png) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-pageability.md b/zh-cn/application-dev/ability/fa-pageability.md index ba42ed13dcbd273b82aa6d3bd5b00d19f94a20f1..8433c7604ef2fd9250d976c972a0bdaa431c8f2e 100644 --- a/zh-cn/application-dev/ability/fa-pageability.md +++ b/zh-cn/application-dev/ability/fa-pageability.md @@ -27,19 +27,19 @@ Page模板(以下简称“Page”)是FA唯一支持的模板,用于提供 **PageAbility类型Ability生命周期回调如下图所示:** -![PageAbility-Lifecycel-Callbacks](figures/page-ability-lifecycle-callbacks.png) +![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) ## 启动本地PageAbility - 导入模块 + * 导入模块 ``` import featureAbility from '@ohos.ability.featureAbility' ``` ``` - FeatureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback) + featureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback) ``` * 接口说明 @@ -50,61 +50,75 @@ import featureAbility from '@ohos.ability.featureAbility' ```javascript import featureAbility from '@ohos.ability.featureAbility' -featureAbility.startAbility( - { - want: - { - action: "", - entities: [""], - type: "", - options: { - // indicates the grant to perform read operations on the URI - authReadUriPermission: true, - // indicates the grant to perform write operations on the URI - authWriteUriPermission: true, - // support forward intent result to origin ability - abilityForwardResult: true, - // used for marking the ability start-up is triggered by continuation - abilityContinuation: true, - // specifies whether a component does not belong to ohos - notOhosComponent: true, - // specifies whether an ability is started - abilityFormEnabled: true, - // indicates the grant for possible persisting on the URI. - authPersistableUriPermission: true, - // indicates the grant for possible persisting on the URI. - authPrefixUriPermission: true, - // support distributed scheduling system start up multiple devices - abilitySliceMultiDevice: true, - // indicates that an ability using the service template is started regardless of whether the - // host application has been started. - startForegroundAbility: true, - // install the specified ability if it's not installed. - installOnDemand: true, - // return result to origin ability slice - abilitySliceForwardResult: true, - // install the specified ability with background mode if it's not installed. - installWithBackgroundMode: true - }, - deviceId: "", - bundleName: "com.example.startability", - abilityName: "com.example.startability.MainAbility", - uri: "" - }, +featureAbility.startAbility({ + want: + { + action: "", + entities: [""], + type: "", + options: { + // indicates the grant to perform read operations on the URI + authReadUriPermission: true, + // indicates the grant to perform write operations on the URI + authWriteUriPermission: true, + // support forward intent result to origin ability + abilityForwardResult: true, + // used for marking the ability start-up is triggered by continuation + abilityContinuation: true, + // specifies whether a component does not belong to ohos + notOhosComponent: true, + // specifies whether an ability is started + abilityFormEnabled: true, + // indicates the grant for possible persisting on the URI. + authPersistableUriPermission: true, + // indicates the grant for possible persisting on the URI. + authPrefixUriPermission: true, + // support distributed scheduling system start up multiple devices + abilitySliceMultiDevice: true, + // indicates that an ability using the service template is started regardless of whether the + // host application has been started. + startForegroundAbility: true, + // install the specified ability if it's not installed. + installOnDemand: true, + // return result to origin ability slice + abilitySliceForwardResult: true, + // install the specified ability with background mode if it's not installed. + installWithBackgroundMode: true }, - ); -) + deviceId: "", + bundleName: "com.example.startability", + abilityName: "com.example.startability.MainAbility", + uri: "" + }, +}, +); +``` +want参数也可以使用parameters参数,使用key-value的方式输入。 +* 示例 +```javascript +import featureAbility from '@ohos.ability.featureAbility' +featureAbility.startAbility({ + want: + { + bundleName: "com.example.startability", + uri: "", + parameters: { + abilityName: "com.example.startability.MainAbility" + } + }, +}, +); ``` ## 启动远程PageAbility - 导入模块 +* 导入模块 ``` import featureAbility from '@ohos.ability.featureAbility' ``` ``` -FeatureAbility.startAbility(parameter: StartAbilityParameter) +featureAbility.startAbility(parameter: StartAbilityParameter) ``` * 接口说明 @@ -114,14 +128,13 @@ FeatureAbility.startAbility(parameter: StartAbilityParameter) * 示例 ```javascript - var promise = await ability.startAbility( - { - want: - { - deviceId: this.deviceId, - bundleName: "com.example.test", - abilityName: "com.example.test.MainAbility", - }, - } - ); +var promise = await featureAbility.startAbility({ + want: + { + deviceId: this.deviceId, + bundleName: "com.example.test", + abilityName: "com.example.test.MainAbility", + }, +} +); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/ability/figures/fa-package-info.png b/zh-cn/application-dev/ability/figures/fa-package-info.png new file mode 100755 index 0000000000000000000000000000000000000000..7b660dce47e3873279f9bdf587b1bd290384843b Binary files /dev/null and b/zh-cn/application-dev/ability/figures/fa-package-info.png differ diff --git a/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png b/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png new file mode 100755 index 0000000000000000000000000000000000000000..269d06b73dde7c952b56cd76f1842a856dde3c01 Binary files /dev/null and b/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png differ diff --git a/zh-cn/application-dev/ability/figures/fa-threading-model.png b/zh-cn/application-dev/ability/figures/fa-threading-model.png new file mode 100755 index 0000000000000000000000000000000000000000..db1102837790330e536bd43062852bf04d505ee1 Binary files /dev/null and b/zh-cn/application-dev/ability/figures/fa-threading-model.png differ