提交 8a0df258 编写于 作者: E ester.zhou 提交者: Gitee

Merge branch 'OpenHarmony-3.2-Release' of gitee.com:openharmony/docs into C2-15989

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
...@@ -158,7 +158,7 @@ Go to the local installation path, choose **toolchains > 3.x.x.x** (the folder n ...@@ -158,7 +158,7 @@ Go to the local installation path, choose **toolchains > 3.x.x.x** (the folder n
> **NOTE**: Use the SDK of the latest version. The use of an earlier version may cause errors in some statements. > **NOTE**: Use the SDK of the latest version. The use of an earlier version may cause errors in some statements.
If the executable file does not exist, download the SDK package from the mirror as instructed in the [Release Notes](../../release-notes). The following uses the [3.2 Beta3](../../release-notes/OpenHarmony-v3.2-beta3.md#acquiring-source-code-from-mirrors) as an example. If the executable file does not exist, download the SDK package from the mirror as instructed in the [Release Notes](../../release-notes). The following uses the [3.2 Beta5]((../../release-notes/OpenHarmony-v3.2-beta5.md#acquiring-source-code-from-mirrors) as an example.
For details about how to replace the SDK package, see [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md). For details about how to replace the SDK package, see [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md).
......
...@@ -12,4 +12,4 @@ During application development based on the Feature Ability (FA) model, the foll ...@@ -12,4 +12,4 @@ During application development based on the Feature Ability (FA) model, the foll
| Inter-process communication (IPC)| Learn the process model and common IPC modes of the FA model.| [Common Events](common-event-fa.md)<br>[Background Services](rpc.md) | | Inter-process communication (IPC)| Learn the process model and common IPC modes of the FA model.| [Common Events](common-event-fa.md)<br>[Background Services](rpc.md) |
| Inter-thread communication| Learn the thread model and common inter-thread communication modes of the FA model.| [Inter-Thread Communication](itc-fa-overview.md)| | Inter-thread communication| Learn the thread model and common inter-thread communication modes of the FA model.| [Inter-Thread Communication](itc-fa-overview.md)|
| Mission management| Learn the basic concepts and typical scenarios of mission management in the FA model.| [Mission Management](mission-management-fa.md)| | Mission management| Learn the basic concepts and typical scenarios of mission management in the FA model.| [Mission Management](mission-management-fa.md)|
| Application configuration file| Learn the requirements for developing application configuration files in the FA model.| [Application Configuration File](config-file-fa.md) | | Application configuration file| Learn the requirements for developing application configuration files in the FA model.| [Application Configuration File](../quick-start/application-configuration-file-overview-fa.md) |
...@@ -47,18 +47,18 @@ On device A, touch the **Start** button provided by the initiator application to ...@@ -47,18 +47,18 @@ On device A, touch the **Start** button provided by the initiator application to
### How to Develop ### How to Develop
1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). 1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Applying for Permissions](../security/accesstoken-guidelines.md#stage-model).
2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows: 2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
```ts ```ts
requestPermission() { requestPermission() {
let context = this.context; let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']; let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
context.requestPermissionsFromUser(permissions).then((data) => { context.requestPermissionsFromUser(permissions).then((data) => {
console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); console.info("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); console.info("Failed to request permission from user with error: "+ JSON.stringify(error))
}) })
} }
``` ```
...@@ -129,18 +129,18 @@ On device A, touch the **Start** button provided by the initiator application to ...@@ -129,18 +129,18 @@ On device A, touch the **Start** button provided by the initiator application to
### How to Develop ### How to Develop
1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). 1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Applying for Permissions](../security/accesstoken-guidelines.md#stage-model).
2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows: 2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
```ts ```ts
requestPermission() { requestPermission() {
let context = this.context; let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']; let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
context.requestPermissionsFromUser(permissions).then((data) => { context.requestPermissionsFromUser(permissions).then((data) => {
console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); console.info("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); console.info("Failed to request permission from user with error: "+ JSON.stringify(error))
}) })
} }
``` ```
...@@ -218,18 +218,30 @@ A system application can connect to a service on another device by calling [conn ...@@ -218,18 +218,30 @@ A system application can connect to a service on another device by calling [conn
### How to Develop ### How to Develop
1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). 1. Configure the data synchronization permission in the **module.json5** file. The sample code is as follows:
```json
{
"module": {
"requestPermissions":[
{
"name" : "ohos.permission.DISTRIBUTED_DATASYNC",
}
]
}
}
```
2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows: 2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
```ts ```ts
requestPermission() { requestPermission() {
let context = this.context; let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']; let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
context.requestPermissionsFromUser(permissions).then((data) => { context.requestPermissionsFromUser(permissions).then((data) => {
console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); console.info("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); console.info("Failed to request permission from user with error: "+ JSON.stringify(error))
}) })
} }
``` ```
...@@ -279,10 +291,10 @@ A system application can connect to a service on another device by calling [conn ...@@ -279,10 +291,10 @@ A system application can connect to a service on another device by calling [conn
}); });
}, },
onDisconnect(elementName) { onDisconnect(elementName) {
console.info('onDisconnect callback'); console.info('onDisconnect callback')
}, },
onFailed(code) { onFailed(code) {
console.info('onFailed callback'); console.info('onFailed callback')
} }
} }
// The ID returned after the connection is set up must be saved. The ID will be passed for service disconnection. // The ID returned after the connection is set up must be saved. The ID will be passed for service disconnection.
...@@ -305,7 +317,7 @@ A system application can connect to a service on another device by calling [conn ...@@ -305,7 +317,7 @@ A system application can connect to a service on another device by calling [conn
## Using Cross-Device Ability Call ## Using Cross-Device Ability Call
The basic principle of cross-device ability call is the same as that of intra-device ability call. For details, see [Using Ability Call to Implement UIAbility Interaction](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction). The basic principle of cross-device ability call is the same as that of intra-device ability call. For details, see [Using Ability Call to Implement UIAbility Interaction (System Applications Only)](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction-system-applications-only).
The following describes how to implement multi-device collaboration through cross-device ability call. The following describes how to implement multi-device collaboration through cross-device ability call.
...@@ -319,26 +331,38 @@ The following describes how to implement multi-device collaboration through cros ...@@ -319,26 +331,38 @@ The following describes how to implement multi-device collaboration through cros
| startAbilityByCall(want: Want): Promise&lt;Caller&gt;; | Starts a UIAbility in the foreground or background and obtains the caller object for communicating with the UIAbility.| | startAbilityByCall(want: Want): Promise&lt;Caller&gt;; | Starts a UIAbility in the foreground or background and obtains the caller object for communicating with the UIAbility.|
| on(method: string, callback: CalleeCallBack): void | Callback invoked when the callee ability registers a method.| | on(method: string, callback: CalleeCallBack): void | Callback invoked when the callee ability registers a method.|
| off(method: string): void | Callback invoked when the callee ability deregisters a method.| | off(method: string): void | Callback invoked when the callee ability deregisters a method.|
| call(method: string, data: rpc.Sequenceable): Promise&lt;void&gt; | Sends agreed sequenceable data to the callee ability.| | call(method: string, data: rpc.Parcelable): Promise&lt;void&gt; | Sends agreed parcelable data to the callee ability.|
| callWithResult(method: string, data: rpc.Sequenceable): Promise&lt;rpc.MessageParcel&gt; | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.| | callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageSequence&gt; | Sends agreed parcelable data to the callee ability and obtains the agreed parcelable data returned by the callee ability.|
| release(): void | Releases the caller object.| | release(): void | Releases the caller object.|
| on(type:&nbsp;"release",&nbsp;callback:&nbsp;OnReleaseCallback):&nbsp;void | Callback invoked when the caller object is released.| | on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.|
### How to Develop ### How to Develop
1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). 1. Configure the data synchronization permission in the **module.json5** file. The sample code is as follows:
```json
{
"module": {
"requestPermissions":[
{
"name" : "ohos.permission.DISTRIBUTED_DATASYNC",
}
]
}
}
```
2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows: 2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
```ts ```ts
requestPermission() { requestPermission() {
let context = this.context; let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']; let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
context.requestPermissionsFromUser(permissions).then((data) => { context.requestPermissionsFromUser(permissions).then((data) => {
console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); console.info("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); console.info("Failed to request permission from user with error: "+ JSON.stringify(error))
}) })
} }
``` ```
...@@ -357,7 +381,6 @@ The following describes how to implement multi-device collaboration through cros ...@@ -357,7 +381,6 @@ The following describes how to implement multi-device collaboration through cros
An example of the UIAbility configuration is as follows: An example of the UIAbility configuration is as follows:
```json ```json
"abilities":[{ "abilities":[{
"name": ".CalleeAbility", "name": ".CalleeAbility",
...@@ -373,15 +396,15 @@ The following describes how to implement multi-device collaboration through cros ...@@ -373,15 +396,15 @@ The following describes how to implement multi-device collaboration through cros
2. Import the **UIAbility** module. 2. Import the **UIAbility** module.
```ts ```ts
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility'
``` ```
3. Define the agreed sequenceable data. 3. Define the agreed parcelable data.
The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string. The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string.
```ts ```ts
export default class MySequenceable { export default class MyParcelable {
num: number = 0 num: number = 0
str: string = "" str: string = ""
...@@ -390,15 +413,15 @@ The following describes how to implement multi-device collaboration through cros ...@@ -390,15 +413,15 @@ The following describes how to implement multi-device collaboration through cros
this.str = string this.str = string
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num) messageSequence.writeInt(this.num)
messageParcel.writeString(this.str) messageSequence.writeString(this.str)
return true return true
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt() this.num = messageSequence.readInt()
this.str = messageParcel.readString() this.str = messageSequence.readString()
return true return true
} }
} }
...@@ -406,7 +429,7 @@ The following describes how to implement multi-device collaboration through cros ...@@ -406,7 +429,7 @@ The following describes how to implement multi-device collaboration through cros
4. Implement **Callee.on** and **Callee.off**. 4. Implement **Callee.on** and **Callee.off**.
In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate()** of the ability and deregistered in **onDestroy()**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate()** of the ability and deregistered in **onDestroy()**. After receiving parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements.
```ts ```ts
const TAG: string = '[CalleeAbility]' const TAG: string = '[CalleeAbility]'
...@@ -415,14 +438,14 @@ The following describes how to implement multi-device collaboration through cros ...@@ -415,14 +438,14 @@ The following describes how to implement multi-device collaboration through cros
function sendMsgCallback(data) { function sendMsgCallback(data) {
console.info('CalleeSortFunc called') console.info('CalleeSortFunc called')
// Obtain the sequenceable data sent by the caller ability. // Obtain the parcelable data sent by the caller ability.
let receivedData = new MySequenceable(0, '') let receivedData = new MyParcelable(0, '')
data.readSequenceable(receivedData) data.readParcelable(receivedData)
console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`)
// Process the data. // Process the data.
// Return the sequenceable data result to the caller ability. // Return the parcelable data result to the caller ability.
return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`) return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`)
} }
export default class CalleeAbility extends Ability { export default class CalleeAbility extends Ability {
...@@ -448,14 +471,13 @@ The following describes how to implement multi-device collaboration through cros ...@@ -448,14 +471,13 @@ The following describes how to implement multi-device collaboration through cros
1. Import the **UIAbility** module. 1. Import the **UIAbility** module.
```ts ```ts
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility'
``` ```
2. Obtain the caller object. 2. Obtain the caller object.
The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller object for communication. The following example uses **this.context** to obtain the **context** attribute of the ability, uses **startAbilityByCall** to start the callee ability, obtain the caller object, and register the **onRelease** listener of the caller ability. You need to implement processing based on service requirements. The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller object for communication. The following example uses **this.context** to obtain the **context** attribute of the ability, uses **startAbilityByCall** to start the callee ability, obtain the caller object, and register the **onRelease** listener of the caller ability. You need to implement processing based on service requirements.
```ts ```ts
async onButtonGetRemoteCaller() { async onButtonGetRemoteCaller() {
var caller = undefined var caller = undefined
...@@ -469,7 +491,7 @@ The following describes how to implement multi-device collaboration through cros ...@@ -469,7 +491,7 @@ The following describes how to implement multi-device collaboration through cros
if (data != null) { if (data != null) {
caller = data caller = data
console.info('get remote caller success') console.info('get remote caller success')
// Register the onRelease() listener of the caller ability. // 注册caller的release监听
caller.onRelease((msg) => { caller.onRelease((msg) => {
console.info(`remote caller onRelease is called ${msg}`) console.info(`remote caller onRelease is called ${msg}`)
}) })
...@@ -483,38 +505,39 @@ The following describes how to implement multi-device collaboration through cros ...@@ -483,38 +505,39 @@ The following describes how to implement multi-device collaboration through cros
For details about how to implement **getRemoteDeviceId()**, see [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned). For details about how to implement **getRemoteDeviceId()**, see [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned).
5. Sends agreed sequenceable data to the callee ability. 5. Sends agreed parcelable data to the callee ability.
1. The sequenceable data can be sent to the callee ability with or without a return value. The method and sequenceable data must be consistent with those of the callee ability. The following example describes how to send data to the callee ability. 1. The parcelable data can be sent to the callee ability with or without a return value. The method and parcelable data must be consistent with those of the callee ability. The following example describes how to send data to the callee ability.
```ts ```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'; const MSG_SEND_METHOD: string = 'CallSendMsg'
async onButtonCall() { async onButtonCall() {
try { try {
let msg = new MySequenceable(1, 'origin_Msg'); let msg = new MyParcelable(1, 'origin_Msg')
await this.caller.call(MSG_SEND_METHOD, msg); await this.caller.call(MSG_SEND_METHOD, msg)
} catch (error) { } catch (error) {
console.info(`caller call failed with ${error}`); console.info(`caller call failed with ${error}`)
} }
} }
``` ```
2. In the following, **CallWithResult** is used to send data **originMsg** to the callee ability and assign the data processed by the **CallSendMsg** method to **backMsg**. 2. In the following, **CallWithResult** is used to send data **originMsg** to the callee ability and assign the data processed by the **CallSendMsg** method to **backMsg**.
```ts ```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'; const MSG_SEND_METHOD: string = 'CallSendMsg'
originMsg: string = ''; originMsg: string = ''
backMsg: string = ''; backMsg: string = ''
async onButtonCallWithResult(originMsg, backMsg) { async onButtonCallWithResult(originMsg, backMsg) {
try { try {
let msg = new MySequenceable(1, originMsg); let msg = new MyParcelable(1, originMsg)
const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg); const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg)
console.info('caller callWithResult succeed'); console.info('caller callWithResult succeed')
let result = new MySequenceable(0, ''); let result = new MyParcelable(0, '')
data.readSequenceable(result); data.readParcelable(result)
backMsg(result.str); backMsg(result.str)
console.info(`caller result is [${result.num}, ${result.str}]`); console.info(`caller result is [${result.num}, ${result.str}]`)
} catch (error) { } catch (error) {
console.info(`caller callWithResult failed with ${error}`); console.info(`caller callWithResult failed with ${error}`)
} }
} }
``` ```
...@@ -526,11 +549,11 @@ The following describes how to implement multi-device collaboration through cros ...@@ -526,11 +549,11 @@ The following describes how to implement multi-device collaboration through cros
```ts ```ts
releaseCall() { releaseCall() {
try { try {
this.caller.release(); this.caller.release()
this.caller = undefined this.caller = undefined
console.info('caller release succeed'); console.info('caller release succeed')
} catch (error) { } catch (error) {
console.info(`caller release failed with ${error}`); console.info(`caller release failed with ${error}`)
} }
} }
``` ```
\ No newline at end of file
...@@ -18,7 +18,7 @@ To develop the Worker mode, perform the following steps: ...@@ -18,7 +18,7 @@ To develop the Worker mode, perform the following steps:
} }
``` ```
2. Create the **worker.js** file based on the configuration in **build-profile.json5**. 2. Create the **worker.ts** file based on the configuration in **build-profile.json5**.
```ts ```ts
import worker from '@ohos.worker'; import worker from '@ohos.worker';
...@@ -58,7 +58,7 @@ To develop the Worker mode, perform the following steps: ...@@ -58,7 +58,7 @@ To develop the Worker mode, perform the following steps:
```ts ```ts
import worker from '@ohos.worker'; import worker from '@ohos.worker';
let wk = new worker.ThreadWorker("../workers/worker.js"); let wk = new worker.ThreadWorker("../workers/worker.ts");
// Send a message to the worker thread. // Send a message to the worker thread.
wk.postMessage("message from main thread.") wk.postMessage("message from main thread.")
...@@ -74,6 +74,6 @@ To develop the Worker mode, perform the following steps: ...@@ -74,6 +74,6 @@ To develop the Worker mode, perform the following steps:
> **NOTE** > **NOTE**
> >
> - If the relative path of **worker.ts** configured in **build-profile.json5** is **./src/main/ets/workers/worker.ts**, pass in the path **entry/ets/workers/worker.ts** when creating a worker thread in the stage model, and pass in the path **../workers/worker.js** when creating a worker thread in the FA model. > - If the relative path of **worker.ts** configured in **build-profile.json5** is **./src/main/ets/workers/worker.ts**, pass in the path **entry/ets/workers/worker.ts** when creating a worker thread in the stage model, and pass in the path **../workers/worker.ts** when creating a worker thread in the FA model.
> >
> - For details about the data types supported between the main thread and worker thread, see [Sequenceable Data Types](../reference/apis/js-apis-worker.md#sequenceable-data-types). > - For details about the data types supported between the main thread and worker thread, see [Sequenceable Data Types](../reference/apis/js-apis-worker.md#sequenceable-data-types).
...@@ -40,4 +40,4 @@ During application development based on the stage model, the following tasks are ...@@ -40,4 +40,4 @@ During application development based on the stage model, the following tasks are
| Inter-process communication (IPC)| Learn the process model and common IPC modes of the stage model.| - [Common Events](common-event-overview.md)<br>- [Background Services](background-services.md)| | Inter-process communication (IPC)| Learn the process model and common IPC modes of the stage model.| - [Common Events](common-event-overview.md)<br>- [Background Services](background-services.md)|
| Inter-thread communication| Learn the thread model and common inter-thread communication modes of the stage model.| - [Emitter](itc-with-emitter.md)<br>- [Worker](itc-with-worker.md)| | Inter-thread communication| Learn the thread model and common inter-thread communication modes of the stage model.| - [Emitter](itc-with-emitter.md)<br>- [Worker](itc-with-worker.md)|
| Mission management| Learn the basic concepts and typical scenarios of mission management in the stage model.| - [Mission Management Scenarios](mission-management-overview.md)<br>- [Mission Management and Launch Type](mission-management-launch-type.md)<br>- [Page Stack and Mission List](page-mission-stack.md)| | Mission management| Learn the basic concepts and typical scenarios of mission management in the stage model.| - [Mission Management Scenarios](mission-management-overview.md)<br>- [Mission Management and Launch Type](mission-management-launch-type.md)<br>- [Page Stack and Mission List](page-mission-stack.md)|
| Application configuration file| Learn the requirements for developing application configuration files in the stage model.| [Application Configuration File](config-file-stage.md)| | Application configuration file| Learn the requirements for developing application configuration files in the stage model.| [Application Configuration File](../quick-start/application-configuration-file-overview-stage.md)|
...@@ -50,7 +50,7 @@ Assume that your application has two UIAbility components: EntryAbility and Func ...@@ -50,7 +50,7 @@ Assume that your application has two UIAbility components: EntryAbility and Func
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window'; import Window from '@ohos.window';
export default class FuncAbility extends UIAbility { export default class FuncAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
...@@ -65,7 +65,7 @@ Assume that your application has two UIAbility components: EntryAbility and Func ...@@ -65,7 +65,7 @@ Assume that your application has two UIAbility components: EntryAbility and Func
3. To stop the **UIAbility** instance after the FuncAbility service is complete, call **terminateSelf()** in FuncAbility. 3. To stop the **UIAbility** instance after the FuncAbility service is complete, call **terminateSelf()** in FuncAbility.
```ts ```ts
// context is the ability context of the UIAbility instance to stop. // context is the ability-level context of the UIAbility instance to stop.
this.context.terminateSelf((err) => { this.context.terminateSelf((err) => {
// ... // ...
}); });
...@@ -111,7 +111,7 @@ When starting FuncAbility from EntryAbility, you want the result to be returned ...@@ -111,7 +111,7 @@ When starting FuncAbility from EntryAbility, you want the result to be returned
}, },
}, },
} }
// context is the ability context of the callee UIAbility. // context is the ability-level context of the callee UIAbility.
this.context.terminateSelfWithResult(abilityResult, (err) => { this.context.terminateSelfWithResult(abilityResult, (err) => {
// ... // ...
}); });
...@@ -202,7 +202,7 @@ This section describes how to start the UIAbility of another application through ...@@ -202,7 +202,7 @@ This section describes how to start the UIAbility of another application through
3. To stop the **UIAbility** instance after the document application is used, call **terminateSelf()**. 3. To stop the **UIAbility** instance after the document application is used, call **terminateSelf()**.
```ts ```ts
// context is the ability context of the UIAbility instance to stop. // context is the ability-level context of the UIAbility instance to stop.
this.context.terminateSelf((err) => { this.context.terminateSelf((err) => {
// ... // ...
}); });
...@@ -274,7 +274,7 @@ If you want to obtain the return result when using implicit Want to start the UI ...@@ -274,7 +274,7 @@ If you want to obtain the return result when using implicit Want to start the UI
}, },
}, },
} }
// context is the ability context of the callee UIAbility. // context is the ability-level context of the callee UIAbility.
this.context.terminateSelfWithResult(abilityResult, (err) => { this.context.terminateSelfWithResult(abilityResult, (err) => {
// ... // ...
}); });
...@@ -412,7 +412,6 @@ In summary, when a UIAbility instance of application A has been created and the ...@@ -412,7 +412,6 @@ In summary, when a UIAbility instance of application A has been created and the
``` ```
> **NOTE** > **NOTE**
>
> When the [launch type of the callee UIAbility](uiability-launch-type.md) is set to **standard**, a new instance is created each time the callee UIAbility is started. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback will not be invoked. > When the [launch type of the callee UIAbility](uiability-launch-type.md) is set to **standard**, a new instance is created each time the callee UIAbility is started. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback will not be invoked.
...@@ -432,7 +431,7 @@ Ability call is usually used in the following scenarios: ...@@ -432,7 +431,7 @@ Ability call is usually used in the following scenarios:
- Starting the callee ability in the background - Starting the callee ability in the background
**Table 1** Terms used in the ability call **Table 1** Terms used in the ability call
| **Term**| Description| | **Term**| Description|
| -------- | -------- | | -------- | -------- |
...@@ -443,9 +442,9 @@ Ability call is usually used in the following scenarios: ...@@ -443,9 +442,9 @@ Ability call is usually used in the following scenarios:
The following figure shows the ability call process. The following figure shows the ability call process.
**Figure 1** Ability call process Figure 1 Ability call process
![call](figures/call.png) ![call](figures/call.png)
- The caller ability uses **startAbilityByCall** to obtain a caller object and uses **call()** of the caller object to send data to the callee ability. - The caller ability uses **startAbilityByCall** to obtain a caller object and uses **call()** of the caller object to send data to the callee ability.
...@@ -463,15 +462,15 @@ The following figure shows the ability call process. ...@@ -463,15 +462,15 @@ The following figure shows the ability call process.
The following table describes the main APIs used for the ability call. For details, see [AbilityContext](../reference/apis/js-apis-app-ability-uiAbility.md#caller). The following table describes the main APIs used for the ability call. For details, see [AbilityContext](../reference/apis/js-apis-app-ability-uiAbility.md#caller).
**Table 2** Ability call APIs **Table 2** Ability call APIs
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| startAbilityByCall(want: Want): Promise&lt;Caller&gt; | Starts a UIAbility in the foreground (through the **want** configuration) or background (default) and obtains the caller object for communication with the UIAbility. For details, see [AbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextstartabilitybycall).| | startAbilityByCall(want: Want): Promise&lt;Caller&gt; | Starts a UIAbility in the foreground (through the **want** configuration) or background (default) and obtains the caller object for communication with the UIAbility. For details, see [AbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextstartabilitybycall).|
| on(method: string, callback: CalleeCallBack): void | Callback invoked when the callee ability registers a method.| | on(method: string, callback: CalleeCallBack): void | Callback invoked when the callee ability registers a method.|
| off(method: string): void | Callback invoked when the callee ability deregisters a method.| | off(method: string): void | Callback invoked when the callee ability deregisters a method.|
| call(method: string, data: rpc.Sequenceable): Promise&lt;void&gt; | Sends agreed sequenceable data to the callee ability.| | call(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Parcelable):&nbsp;Promise&lt;void&gt; | Sends agreed parcelable data to the callee ability.|
| callWithResult(method: string, data: rpc.Sequenceable): Promise&lt;rpc.MessageParcel&gt; | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.| | callWithResult(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Parcelable):&nbsp;Promise&lt;rpc.MessageSequence&gt; | Sends agreed parcelable data to the callee ability and obtains the agreed parcelable data returned by the callee ability.|
| release(): void | Releases the caller object.| | release(): void | Releases the caller object.|
| on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.| | on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.|
...@@ -487,14 +486,13 @@ The implementation of using the ability call for UIAbility interaction involves ...@@ -487,14 +486,13 @@ The implementation of using the ability call for UIAbility interaction involves
For the callee ability, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use **on()** to register a listener. When data does not need to be received, use **off()** to deregister the listener. For the callee ability, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use **on()** to register a listener. When data does not need to be received, use **off()** to deregister the listener.
1. Configure the ability launch type. 1. Configure the ability launch type.
Set **launchType** of the callee ability to **singleton** in the **module.json5** file. Set **launchType** of the callee ability to **singleton** in the **module.json5** file.
| JSON Field| Description| | JSON Field| Description|
| -------- | -------- | | -------- | -------- |
| "launchType" | Ability launch type. Set this parameter to **singleton**.| | "launchType" | Ability launch type. Set this parameter to **singleton**.|
An example of the ability configuration is as follows: An example of the ability configuration is as follows:
```json ```json
...@@ -515,13 +513,12 @@ An example of the ability configuration is as follows: ...@@ -515,13 +513,12 @@ An example of the ability configuration is as follows:
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
``` ```
3. Define the agreed sequenceable data. 3. Define the agreed parcelable data.
The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string. The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string.
```ts ```ts
export default class MySequenceable { export default class MyParcelable {
num: number = 0 num: number = 0
str: string = "" str: string = ""
...@@ -530,23 +527,22 @@ An example of the ability configuration is as follows: ...@@ -530,23 +527,22 @@ An example of the ability configuration is as follows:
this.str = string this.str = string
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num) messageSequence.writeInt(this.num)
messageParcel.writeString(this.str) messageSequence.writeString(this.str)
return true return true
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt() this.num = messageSequence.readInt()
this.str = messageParcel.readString() this.str = messageSequence.readString()
return true return true
} }
} }
``` ```
4. Implement **Callee.on** and **Callee.off**. 4. Implement **Callee.on** and **Callee.off**.
The time to register a listener for the callee ability depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows:
The time to register a listener for the callee ability depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows:
```ts ```ts
...@@ -556,14 +552,14 @@ An example of the ability configuration is as follows: ...@@ -556,14 +552,14 @@ An example of the ability configuration is as follows:
function sendMsgCallback(data) { function sendMsgCallback(data) {
console.info('CalleeSortFunc called'); console.info('CalleeSortFunc called');
// Obtain the sequenceable data sent by the caller ability. // Obtain the parcelable data sent by the caller ability.
let receivedData = new MySequenceable(0, ''); let receivedData = new MyParcelable(0, '');
data.readSequenceable(receivedData); data.readParcelable(receivedData);
console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`);
// Process the data. // Process the data.
// Return the sequenceable data result to the caller ability. // Return the parcelable data result to the caller ability.
return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`); return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`);
} }
export default class CalleeAbility extends Ability { export default class CalleeAbility extends Ability {
...@@ -595,7 +591,6 @@ An example of the ability configuration is as follows: ...@@ -595,7 +591,6 @@ An example of the ability configuration is as follows:
``` ```
2. Obtain the caller interface. 2. Obtain the caller interface.
The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller object for communication. The following example uses **this.context** to obtain the **context** attribute of the ability, uses **startAbilityByCall** to start the callee ability, obtain the caller object, and register the **onRelease** listener of the caller ability. You need to implement processing based on service requirements. The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller object for communication. The following example uses **this.context** to obtain the **context** attribute of the ability, uses **startAbilityByCall** to start the callee ability, obtain the caller object, and register the **onRelease** listener of the caller ability. You need to implement processing based on service requirements.
......
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
- [permissionDef](js-apis-bundleManager-permissionDef.md) - [permissionDef](js-apis-bundleManager-permissionDef.md)
- [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md) - [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundleManager-shortcutInfo.md) - [shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
- UI Page - UI Page
- [@ohos.animator (Animator)](js-apis-animator.md) - [@ohos.animator (Animator)](js-apis-animator.md)
- [@ohos.curves (Interpolation Calculation)](js-apis-curve.md) - [@ohos.curves (Interpolation Calculation)](js-apis-curve.md)
...@@ -182,16 +183,19 @@ ...@@ -182,16 +183,19 @@
- webgl - webgl
- [WebGL](js-apis-webgl.md) - [WebGL](js-apis-webgl.md)
- [WebGL2](js-apis-webgl2.md) - [WebGL2](js-apis-webgl2.md)
- Media - Media
- [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md) - [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md)
- [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md) - [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md)
- [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md) - [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md)
- [@ohos.multimedia.image (Image Processing)](js-apis-image.md) - [@ohos.multimedia.image (Image Processing)](js-apis-image.md)
- [@ohos.multimedia.media (Media)](js-apis-media.md) - [@ohos.multimedia.media (Media)](js-apis-media.md)
- Resource Management - Resource Management
- [@ohos.i18n (Internationalization)](js-apis-i18n.md) - [@ohos.i18n (Internationalization)](js-apis-i18n.md)
- [@ohos.intl (Internationalization)](js-apis-intl.md) - [@ohos.intl (Internationalization)](js-apis-intl.md)
- [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md) - [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md)
- Background Tasks - Background Tasks
- [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md) - [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md)
- [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md) - [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md)
...@@ -199,6 +203,7 @@ ...@@ -199,6 +203,7 @@
- [@ohos.resourceschedule.workScheduler (Work Scheduler)](js-apis-resourceschedule-workScheduler.md) - [@ohos.resourceschedule.workScheduler (Work Scheduler)](js-apis-resourceschedule-workScheduler.md)
- [@ohos.resourceschedule.usageStatistics (Device Usage Statistics)](js-apis-resourceschedule-deviceUsageStatistics.md) - [@ohos.resourceschedule.usageStatistics (Device Usage Statistics)](js-apis-resourceschedule-deviceUsageStatistics.md)
- [@ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)](js-apis-WorkSchedulerExtensionAbility.md) - [@ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)](js-apis-WorkSchedulerExtensionAbility.md)
- Security - Security
- [@ohos.abilityAccessCtrl (Ability Access Control)](js-apis-abilityAccessCtrl.md) - [@ohos.abilityAccessCtrl (Ability Access Control)](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager (Privacy Management)](js-apis-privacyManager.md) - [@ohos.privacyManager (Privacy Management)](js-apis-privacyManager.md)
...@@ -210,6 +215,7 @@ ...@@ -210,6 +215,7 @@
- [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md) - [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md)
- security - security
- [PermissionRequestResult](js-apis-permissionrequestresult.md) - [PermissionRequestResult](js-apis-permissionrequestresult.md)
- Data Management - Data Management
- [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md) - [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md)
- [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md) - [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md)
...@@ -222,12 +228,14 @@ ...@@ -222,12 +228,14 @@
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- data/rdb - data/rdb
- [resultSet](js-apis-data-resultset.md) - [resultSet](js-apis-data-resultset.md)
- File Management - File Management
- [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md) - [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md)
- [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md) - [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md)
- [@ohos.file.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md) - [@ohos.file.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md)
- [@ohos.file.fs (File Management)](js-apis-file-fs.md) - [@ohos.file.fs (File Management)](js-apis-file-fs.md)
- [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md) - [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md)
- [@ohos.file.picker (Picker)](js-apis-file-picker.md)
- [@ohos.file.securityLabel (Data Label)](js-apis-file-securityLabel.md) - [@ohos.file.securityLabel (Data Label)](js-apis-file-securityLabel.md)
- [@ohos.file.statvfs (File System Space Statistics)](js-apis-file-statvfs.md) - [@ohos.file.statvfs (File System Space Statistics)](js-apis-file-statvfs.md)
- [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md) - [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md)
...@@ -242,6 +250,7 @@ ...@@ -242,6 +250,7 @@
- [@ohos.telephony.radio (Network Search)](js-apis-radio.md) - [@ohos.telephony.radio (Network Search)](js-apis-radio.md)
- [@ohos.telephony.sim (SIM Management)](js-apis-sim.md) - [@ohos.telephony.sim (SIM Management)](js-apis-sim.md)
- [@ohos.telephony.sms (SMS)](js-apis-sms.md) - [@ohos.telephony.sms (SMS)](js-apis-sms.md)
- Network Management - Network Management
- [@ohos.net.connection (Network Connection Management)](js-apis-net-connection.md) - [@ohos.net.connection (Network Connection Management)](js-apis-net-connection.md)
- [@ohos.net.ethernet (Ethernet Connection Management)](js-apis-net-ethernet.md) - [@ohos.net.ethernet (Ethernet Connection Management)](js-apis-net-ethernet.md)
...@@ -250,6 +259,7 @@ ...@@ -250,6 +259,7 @@
- [@ohos.net.socket (Socket Connection)](js-apis-socket.md) - [@ohos.net.socket (Socket Connection)](js-apis-socket.md)
- [@ohos.net.webSocket (WebSocket Connection)](js-apis-webSocket.md) - [@ohos.net.webSocket (WebSocket Connection)](js-apis-webSocket.md)
- [@ohos.request (Upload and Download)](js-apis-request.md) - [@ohos.request (Upload and Download)](js-apis-request.md)
- Connectivity - Connectivity
- [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md) - [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md)
- [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md) - [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md)
...@@ -264,6 +274,7 @@ ...@@ -264,6 +274,7 @@
- tag - tag
- [nfctech (Standard NFC Technologies)](js-apis-nfctech.md) - [nfctech (Standard NFC Technologies)](js-apis-nfctech.md)
- [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md) - [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md)
- Basic Features - Basic Features
- [@ohos.accessibility (Accessibility)](js-apis-accessibility.md) - [@ohos.accessibility (Accessibility)](js-apis-accessibility.md)
- [@ohos.accessibility.config (System Accessibility Configuration)](js-apis-accessibility-config.md) - [@ohos.accessibility.config (System Accessibility Configuration)](js-apis-accessibility-config.md)
...@@ -322,10 +333,12 @@ ...@@ -322,10 +333,12 @@
- [@ohos.update (Update)](js-apis-update.md) - [@ohos.update (Update)](js-apis-update.md)
- [@ohos.usbManager (USB Manager)](js-apis-usbManager.md) - [@ohos.usbManager (USB Manager)](js-apis-usbManager.md)
- [@ohos.vibrator (Vibrator)](js-apis-vibrator.md) - [@ohos.vibrator (Vibrator)](js-apis-vibrator.md)
- Account Management - Account Management
- [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md) - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md)
- [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md) - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md)
- [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md)
- Custom Management - Custom Management
- [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md)
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md)
...@@ -356,9 +369,11 @@ ...@@ -356,9 +369,11 @@
- [@ohos.util.Vector (Linear Container Vector)](js-apis-vector.md) - [@ohos.util.Vector (Linear Container Vector)](js-apis-vector.md)
- [@ohos.worker (Worker Startup)](js-apis-worker.md) - [@ohos.worker (Worker Startup)](js-apis-worker.md)
- [@ohos.xml (XML Parsing and Generation)](js-apis-xml.md) - [@ohos.xml (XML Parsing and Generation)](js-apis-xml.md)
- Test - Test
- [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md) - [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md)
- [@ohos.uitest (UiTest)](js-apis-uitest.md) - [@ohos.uitest (UiTest)](js-apis-uitest.md)
- APIs No Longer Maintained - APIs No Longer Maintained
- [@ohos.backgroundTaskManager (Background Task Management)](js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager (Background Task Management)](js-apis-backgroundTaskManager.md)
- [@ohos.bundle (Bundle)](js-apis-Bundle.md) - [@ohos.bundle (Bundle)](js-apis-Bundle.md)
......
...@@ -365,7 +365,7 @@ featureAbility.terminateSelfWithResult( ...@@ -365,7 +365,7 @@ featureAbility.terminateSelfWithResult(
}); });
``` ```
## featureAbility.hasWindowFocus<sup>7+<sup> ## featureAbility.hasWindowFocus<sup>7+</sup>
hasWindowFocus(callback: AsyncCallback\<boolean>): void hasWindowFocus(callback: AsyncCallback\<boolean>): void
...@@ -388,7 +388,7 @@ featureAbility.hasWindowFocus((err, data) => { ...@@ -388,7 +388,7 @@ featureAbility.hasWindowFocus((err, data) => {
}); });
``` ```
## featureAbility.hasWindowFocus<sup>7+<sup> ## featureAbility.hasWindowFocus<sup>7+</sup>
hasWindowFocus(): Promise\<boolean> hasWindowFocus(): Promise\<boolean>
...@@ -812,6 +812,6 @@ Enumerates the flags that specify how the Want will be handled. ...@@ -812,6 +812,6 @@ Enumerates the flags that specify how the Want will be handled.
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.| | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the [Want](js-apis-application-want.md) object under [parameter](js-apis-inner-ability-startAbilityParameter.md) in the [startAbility](#featureabilitystartability) API passed to the **FeatureAbility** module and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on an existing mission stack. | | FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on an existing mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.| | FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.|
...@@ -84,6 +84,6 @@ Enumerates the flags that specify how the Want will be handled. ...@@ -84,6 +84,6 @@ Enumerates the flags that specify how the Want will be handled.
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.<br>**System API**: This is a system API and cannot be called by third-party applications. | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.| | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the [startAbility](js-apis-ability-featureAbility.md#startability) API passed to the **FeatureAbility** module and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the history mission stack. | | FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the history mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.| | FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.|
...@@ -35,8 +35,8 @@ Enumerates the initial ability launch reasons. You can use it together with [onC ...@@ -35,8 +35,8 @@ Enumerates the initial ability launch reasons. You can use it together with [onC
| Name | Value | Description | | Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.| | UNKNOWN | 0 | Unknown reason.|
| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-ability-context.md#abilitycontextstartability).| | START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability).|
| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-ability-context.md#abilitycontextstartabilitybycall).| | CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall).|
| CONTINUATION | 3 | The ability is started by means of cross-device migration.| | CONTINUATION | 3 | The ability is started by means of cross-device migration.|
| APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.| | APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.|
...@@ -124,8 +124,8 @@ Enumerates the window modes in which an ability can be displayed at startup. It ...@@ -124,8 +124,8 @@ Enumerates the window modes in which an ability can be displayed at startup. It
```ts ```ts
let want = { let want = {
bundleName: 'com.test.example', bundleName: 'com.example.myapplication',
abilityName: 'MainAbility' abilityName: 'EntryAbility'
}; };
let option = { let option = {
windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN
...@@ -135,7 +135,7 @@ let option = { ...@@ -135,7 +135,7 @@ let option = {
this.context.startAbility(want, option).then(()=>{ this.context.startAbility(want, option).then(()=>{
console.log('Succeed to start ability.'); console.log('Succeed to start ability.');
}).catch((error)=>{ }).catch((error)=>{
console.log('Failed to start ability with error: ' + JSON.stringify(error)); console.error('Failed to start ability with error: ${JSON.stringify(error)}');
}); });
``` ```
......
...@@ -24,8 +24,8 @@ import common from '@ohos.app.ability.common'; ...@@ -24,8 +24,8 @@ import common from '@ohos.app.ability.common';
| Context | [Context](js-apis-inner-application-context.md) | Level-2 module **Context**.| | Context | [Context](js-apis-inner-application-context.md) | Level-2 module **Context**.|
| ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Level-2 module **ExtensionContext**.| | ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Level-2 module **ExtensionContext**.|
| FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Level-2 module **FormExtensionContext**.| | FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Level-2 module **FormExtensionContext**.|
| ServiceExtensionContext | [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md) | Level-2 module **ServiceExtensionContext**.|
| EventHub | [EventHub](js-apis-inner-application-eventHub.md) | Level-2 module **EventHub**.| | EventHub | [EventHub](js-apis-inner-application-eventHub.md) | Level-2 module **EventHub**.|
| PermissionRequestResult | [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md) | Level-2 module **PermissionRequestResult**.|
| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | Level-2 module **PacMap**.| | PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | Level-2 module **PacMap**.|
| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.| | AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.|
| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.| | ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.|
...@@ -42,19 +42,7 @@ let context: common.Context; ...@@ -42,19 +42,7 @@ let context: common.Context;
let extensionContext: common.ExtensionContext; let extensionContext: common.ExtensionContext;
let formExtensionContext: common.FormExtensionContext; let formExtensionContext: common.FormExtensionContext;
let eventHub: common.EventHub; let eventHub: common.EventHub;
let permissionRequestResult: common.PermissionRequestResult;
let pacMap: common.PacMap; let pacMap: common.PacMap;
let abilityResult: common.AbilityResult; let abilityResult: common.AbilityResult;
let connectOptions: common.ConnectOptions; let connectOptions: common.ConnectOptions;
``` ```
## AreaMode
Enumerates the data encryption levels.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| --------------- | ---- | --------------- |
| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on. |
| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).|
# @ohos.app.ability.ExtensionAbility (ExtensionAbility Base Class) # @ohos.app.ability.ExtensionAbility (ExtensionAbility Base Class)
**ExtensionAbility** is the base class for scenario-specific ExtensionAbilities. It is inherited from [Ability](js-apis-app-ability-ability.md), with no attribute or method added. You cannot inherit from this base class. **ExtensionAbility** is the base class for scenario-specific ExtensionAbilities. It provides the callbacks for system configuration updates and memory level updates.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model. > The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import ExtensionAbility from '@ohos.app.ability.ExtensionAbility';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
class MyExtensionAbility extends ExtensionAbility {
onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
}
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
# @ohos.app.ability.ServiceExtensionAbility (ServiceExtensionAbility) # @ohos.app.ability.ServiceExtensionAbility (ServiceExtensionAbility)
The **ServiceExtensionAbility** module provides APIs for ServiceExtensionAbilities. The **ServiceExtensionAbility** module provides lifecycle callbacks when a ServiceExtensionAbility (background service) is created, destroyed, connected, or disconnected.
> **NOTE** > **NOTE**
> >
...@@ -150,7 +150,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal ...@@ -150,7 +150,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
onDisconnect(want: Want): void | Promise<void>; onDisconnect(want: Want): void | Promise<void>;
Called when this ServiceExtensionAbility is disconnected. Called when a client is disconnected from this ServiceExtensionAbility.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -176,7 +176,7 @@ Called when this ServiceExtensionAbility is disconnected. ...@@ -176,7 +176,7 @@ Called when this ServiceExtensionAbility is disconnected.
onReconnect(want: Want): void; onReconnect(want: Want): void;
Called when this ServiceExtensionAbility is reconnected. Called when a new client attempts to connect to this ServiceExtensionAbility after all previous clients are disconnected. This capability is reserved.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
# @ohos.app.ability.StartOptions (StartOptions) # @ohos.app.ability.StartOptions (StartOptions)
The **StartOptions** module implements ability startup options. **StartOptions** is used as an input parameter of [startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1) to specify the window mode of an ability.
> **NOTE** > **NOTE**
> >
......
# @ohos.app.ability.UIAbility (UIAbility) # @ohos.app.ability.UIAbility (UIAbility)
The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information. UIAbility is an application component that has the UI. The **UIAbility** module provides lifecycle callback such as component creation, destruction, and foreground/background switching. It also provides the following capabilities related to component collaboration:
This module provides the following common ability-related functions: - [Caller](#caller): an object returned by [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall). The CallerAbility (caller) uses this object to communicate with the CalleeAbility (callee).
- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability). - [Callee](#callee): an internal object of UIAbility. The CalleeAbility (callee) uses this object to communicate with the CallerAbility (caller).
- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
> **NOTE** > **NOTE**
> >
...@@ -23,12 +22,12 @@ import Ability from '@ohos.app.ability.UIAbility'; ...@@ -23,12 +22,12 @@ import Ability from '@ohos.app.ability.UIAbility';
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of the ability.| | context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of the UIAbility.|
| launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the ability.| | launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the UIAbility.|
| lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the ability was started last time.| | lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the UIAbility was started last time.|
| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.| | callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
## Ability.onCreate ## UIAbility.onCreate
onCreate(want: Want, param: AbilityConstant.LaunchParam): void; onCreate(want: Want, param: AbilityConstant.LaunchParam): void;
...@@ -40,7 +39,7 @@ Called to initialize the service logic when an ability is created. ...@@ -40,7 +39,7 @@ Called to initialize the service logic when an ability is created.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this ability, including the ability name and bundle name.| | want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this UIAbility, including the ability name and bundle name.|
| param | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| | param | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example** **Example**
...@@ -54,11 +53,11 @@ Called to initialize the service logic when an ability is created. ...@@ -54,11 +53,11 @@ Called to initialize the service logic when an ability is created.
``` ```
## Ability.onWindowStageCreate ## UIAbility.onWindowStageCreate
onWindowStageCreate(windowStage: window.WindowStage): void onWindowStageCreate(windowStage: window.WindowStage): void
Called when a **WindowStage** is created for this ability. Called when a **WindowStage** is created for this UIAbility.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -79,11 +78,11 @@ Called when a **WindowStage** is created for this ability. ...@@ -79,11 +78,11 @@ Called when a **WindowStage** is created for this ability.
``` ```
## Ability.onWindowStageDestroy ## UIAbility.onWindowStageDestroy
onWindowStageDestroy(): void onWindowStageDestroy(): void
Called when the **WindowStage** is destroyed for this ability. Called when the **WindowStage** is destroyed for this UIAbility.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -98,11 +97,11 @@ Called when the **WindowStage** is destroyed for this ability. ...@@ -98,11 +97,11 @@ Called when the **WindowStage** is destroyed for this ability.
``` ```
## Ability.onWindowStageRestore ## UIAbility.onWindowStageRestore
onWindowStageRestore(windowStage: window.WindowStage): void onWindowStageRestore(windowStage: window.WindowStage): void
Called when the **WindowStage** is restored during the migration of this ability, which is a multi-instance ability. Called when the **WindowStage** is restored during the migration of this UIAbility, which is a multi-instance ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -123,7 +122,7 @@ Called when the **WindowStage** is restored during the migration of this ability ...@@ -123,7 +122,7 @@ Called when the **WindowStage** is restored during the migration of this ability
``` ```
## Ability.onDestroy ## UIAbility.onDestroy
onDestroy(): void | Promise&lt;void&gt;; onDestroy(): void | Promise&lt;void&gt;;
...@@ -142,7 +141,7 @@ Called when this ability is destroyed to clear resources. ...@@ -142,7 +141,7 @@ Called when this ability is destroyed to clear resources.
``` ```
## Ability.onForeground ## UIAbility.onForeground
onForeground(): void; onForeground(): void;
...@@ -161,7 +160,7 @@ Called when this ability is switched from the background to the foreground. ...@@ -161,7 +160,7 @@ Called when this ability is switched from the background to the foreground.
``` ```
## Ability.onBackground ## UIAbility.onBackground
onBackground(): void; onBackground(): void;
...@@ -180,7 +179,7 @@ Called when this ability is switched from the foreground to the background. ...@@ -180,7 +179,7 @@ Called when this ability is switched from the foreground to the background.
``` ```
## Ability.onContinue ## UIAbility.onContinue
onContinue(wantParam: { [key: string]: Object }): AbilityConstant.OnContinueResult; onContinue(wantParam: { [key: string]: Object }): AbilityConstant.OnContinueResult;
...@@ -214,11 +213,11 @@ Called to save data during the ability migration preparation process. ...@@ -214,11 +213,11 @@ Called to save data during the ability migration preparation process.
``` ```
## Ability.onNewWant ## UIAbility.onNewWant
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
Called when a new Want is passed in and this ability is started again. Called when a new Want is passed in and this UIAbility is started again.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -227,7 +226,7 @@ Called when a new Want is passed in and this ability is started again. ...@@ -227,7 +226,7 @@ Called when a new Want is passed in and this ability is started again.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.| | want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.|
| launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the ability startup and the last abnormal exit.| | launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the UIAbility startup and the last abnormal exit.|
**Example** **Example**
...@@ -240,7 +239,7 @@ Called when a new Want is passed in and this ability is started again. ...@@ -240,7 +239,7 @@ Called when a new Want is passed in and this ability is started again.
} }
``` ```
## Ability.onDump ## UIAbility.onDump
onDump(params: Array\<string>): Array\<string>; onDump(params: Array\<string>): Array\<string>;
...@@ -266,11 +265,11 @@ Dumps client information. ...@@ -266,11 +265,11 @@ Dumps client information.
``` ```
## Ability.onSaveState ## UIAbility.onSaveState
onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult; onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult;
Called when the framework automatically saves the ability state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this ability. Called when the framework automatically saves the UIAbility state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -278,7 +277,7 @@ Called when the framework automatically saves the ability state in the case of a ...@@ -278,7 +277,7 @@ Called when the framework automatically saves the ability state in the case of a
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reason | [AbilityConstant.StateType](js-apis-application-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the ability state.| | reason | [AbilityConstant.StateType](js-apis-app-ability-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the UIAbility state.|
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.| | wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
**Return value** **Return value**
...@@ -305,22 +304,22 @@ class MyUIAbility extends Ability { ...@@ -305,22 +304,22 @@ class MyUIAbility extends Ability {
## Caller ## Caller
Implements sending of sequenceable data to the target ability when the CallerAbility invokes the target ability (CalleeAbility). Implements sending of parcelable data to the target ability when the CallerAbility invokes the target ability (CalleeAbility).
## Caller.call ## Caller.call
call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
Sends sequenceable data to the target ability. Sends parcelable data to the target ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the parcelable data.|
| data | [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | Yes| Sequenceable data. You need to customize the data.| | data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.|
**Return value** **Return value**
...@@ -333,13 +332,12 @@ Sends sequenceable data to the target ability. ...@@ -333,13 +332,12 @@ Sends sequenceable data to the target ability.
| ID| Error Message| | ID| Error Message|
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
class MyMessageAble{ // Custom sequenceable data structure. class MyMessageAble{ // Custom parcelable data structure.
name:'' name:''
str:'' str:''
num: 1 num: 1
...@@ -347,15 +345,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -347,15 +345,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
this.name = name; this.name = name;
this.str = str; this.str = str;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
...@@ -370,7 +368,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -370,7 +368,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
deviceId: '' deviceId: ''
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
let msg = new MyMessageAble('msg', 'world'); // See the definition of Sequenceable. let msg = new MyMessageAble('msg', 'world'); // See the definition of Parcelable.
caller.call(method, msg) caller.call(method, msg)
.then(() => { .then(() => {
console.log('Caller call() called'); console.log('Caller call() called');
...@@ -390,31 +388,30 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -390,31 +388,30 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## Caller.callWithResult ## Caller.callWithResult
callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParcel&gt;; callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageSequence&gt;;
Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability. Sends parcelable data to the target ability and obtains the parcelable data returned by the target ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the parcelable data.|
| data | [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | Yes| Sequenceable data. You need to customize the data.| | data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)&gt; | Promise used to return the sequenceable data from the target ability.| | Promise&lt;[rpc.MessageSequence](js-apis-rpc.md#messagesequence9)&gt; | Promise used to return the parcelable data from the target ability.|
**Error codes** **Error codes**
| ID| Error Message| | ID| Error Message|
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
...@@ -428,15 +425,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -428,15 +425,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
this.name = name; this.name = name;
this.str = str; this.str = str;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
...@@ -456,7 +453,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -456,7 +453,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
.then((data) => { .then((data) => {
console.log('Caller callWithResult() called'); console.log('Caller callWithResult() called');
let retmsg = new MyMessageAble(0, ''); let retmsg = new MyMessageAble(0, '');
data.readSequenceable(retmsg); data.readParcelable(retmsg);
}) })
.catch((callErr) => { .catch((callErr) => {
console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) + console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) +
...@@ -477,7 +474,7 @@ release(): void; ...@@ -477,7 +474,7 @@ release(): void;
Releases the caller interface of the target ability. Releases the caller interface of the target ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.UIAbility.UIAbilityRuntime.UIAbilityCore
**Error codes** **Error codes**
...@@ -576,7 +573,6 @@ Registers a callback that is invoked when the stub on the target ability is disc ...@@ -576,7 +573,6 @@ Registers a callback that is invoked when the stub on the target ability is disc
| ID| Error Message| | ID| Error Message|
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
...@@ -627,7 +623,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di ...@@ -627,7 +623,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di
| ID| Error Message| | ID| Error Message|
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md). For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
...@@ -678,7 +674,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di ...@@ -678,7 +674,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di
| ID| Error Message| | ID| Error Message|
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md). For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
...@@ -724,17 +720,16 @@ Registers a caller notification callback, which is invoked when the target abili ...@@ -724,17 +720,16 @@ Registers a caller notification callback, which is invoked when the target abili
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.| | method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.| | callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageSequence](js-apis-rpc.md#messagesequence9) type. The callback must return at least one empty [rpc.Parcelable](js-apis-rpc.md#parcelable9) object. Otherwise, the function execution fails.|
**Error codes** **Error codes**
| ID| Error Message| | ID| Error Message|
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
...@@ -748,15 +743,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -748,15 +743,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
this.name = name; this.name = name;
this.str = str; this.str = str;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
...@@ -765,7 +760,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -765,7 +760,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
function funcCallBack(pdata) { function funcCallBack(pdata) {
console.log('Callee funcCallBack is called ' + pdata); console.log('Callee funcCallBack is called ' + pdata);
let msg = new MyMessageAble('test', ''); let msg = new MyMessageAble('test', '');
pdata.readSequenceable(msg); pdata.readParcelable(msg);
return new MyMessageAble('test1', 'Callee test'); return new MyMessageAble('test1', 'Callee test');
} }
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
...@@ -787,7 +782,7 @@ off(method: string): void; ...@@ -787,7 +782,7 @@ off(method: string): void;
Deregisters a caller notification callback, which is invoked when the target ability registers a function. Deregisters a caller notification callback, which is invoked when the target ability registers a function.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.UIAbility.UIAbilityRuntime.UIAbilityCore
**Parameters** **Parameters**
...@@ -800,7 +795,6 @@ Deregisters a caller notification callback, which is invoked when the target abi ...@@ -800,7 +795,6 @@ Deregisters a caller notification callback, which is invoked when the target abi
| ID| Error Message| | ID| Error Message|
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
...@@ -833,10 +827,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -833,10 +827,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## CalleeCallback ## CalleeCallback
(indata: rpc.MessageParcel): rpc.Parcelable; (indata: rpc.MessageSequence): rpc.Parcelable;
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Readable| Writable| Type| Description| | Name| Readable| Writable| Type| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| (indata: [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)) | Yes| No| [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | Prototype of the listener function registered by the callee.| | (indata: [rpc.MessageSequence](js-apis-rpc.md#messagesequence9)) | Yes| No| [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Prototype of the listener function registered by the callee.|
# @ohos.app.form.FormExtensionAbility (FormExtensionAbility) # @ohos.app.form.FormExtensionAbility (FormExtensionAbility)
The **FormExtensionAbility** module provides APIs related to FormExtensionAbilities. The **FormExtensionAbility** module provides lifecycle callbacks invoked when a widget is created, destroyed, or updated.
> **NOTE** > **NOTE**
> >
...@@ -19,7 +19,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; ...@@ -19,7 +19,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| context | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Yes | No | Context of the FormExtensionAbility. This context is inherited from **ExtensionContext**.| | context | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Yes | No | Context of the FormExtensionAbility. This context is inherited from [ExtensionContext](js-apis-inner-application-extensionContext.md).|
## onAddForm ## onAddForm
...@@ -33,7 +33,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -33,7 +33,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Want information related to the ExtensionAbility, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| | want | [Want](js-apis-application-want.md) | Yes | Want information related to the FormExtensionAbility, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
**Return value** **Return value**
...@@ -145,7 +145,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility { ...@@ -145,7 +145,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
console.error('Operation updateForm failed. Cause: ' + error);}); console.error('Operation updateForm failed. Cause: ' + error);});
} }
} }
} };
``` ```
## onFormEvent ## onFormEvent
......
...@@ -161,7 +161,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba ...@@ -161,7 +161,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | | bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
...@@ -253,7 +253,7 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -253,7 +253,7 @@ Requests a continuous task from the system. This API uses a promise to return th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | | bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
...@@ -339,7 +339,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to ...@@ -339,7 +339,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------- | ---- | ---------------------------------------- |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -395,7 +395,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu ...@@ -395,7 +395,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------- | ---- | ---------------------------------------- | | ------- | ------- | ---- | ---------------------------------------- |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
**Return value** **Return value**
......
...@@ -160,9 +160,9 @@ bundle.getBundleInstaller().then(installer => { ...@@ -160,9 +160,9 @@ bundle.getBundleInstaller().then(installer => {
Describes the parameters required for bundle installation, recovery, or uninstall. Describes the parameters required for bundle installation, recovery, or uninstall.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------- | ------- | ---- | ---- | ------------------ | | ----------- | ------- | ---- | ---- | ------------------ |
...@@ -174,17 +174,17 @@ Describes the parameters required for bundle installation, recovery, or uninstal ...@@ -174,17 +174,17 @@ Describes the parameters required for bundle installation, recovery, or uninstal
Describes the bundle installation or uninstall status. Describes the bundle installation or uninstall status.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ | | ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ |
| status | bundle.[InstallErrorCode](js-apis-Bundle.md#installerrorcode) | Yes | No | Installation or uninstall error code. The value must be defined in [InstallErrorCode](js-apis-Bundle.md#installerrorcode). | | status | bundle.[InstallErrorCode](js-apis-Bundle.md#installerrorcode) | Yes | No | Installation or uninstall error code. The value must be defined in [InstallErrorCode](js-apis-Bundle.md#installerrorcode)|
| statusMessage | string | Yes | No | Installation or uninstall status message. <br>**SUCCESS**: install_succeed<br>**STATUS_INSTALL_FAILURE**: Installation failed (no installation file exists).<br>**STATUS_INSTALL_FAILURE_ABORTED**: Installation aborted.<br>**STATUS_INSTALL_FAILURE_INVALID**: Invalid installation parameter.<br>**STATUS_INSTALL_FAILURE_CONFLICT**: Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.)<br>**STATUS_INSTALL_FAILURE_STORAGE**: Failed to store the bundle information.<br>**STATUS_INSTALL_FAILURE_INCOMPATIBLE**: Installation incompatibility. (A downgrade occurs or the signature information is incorrect.)<br>**STATUS_UNINSTALL_FAILURE**: Uninstallation failed. (The application to be uninstalled is not found.)<br>**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation aborted. (This error code is not in use.)<br>**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation conflict. (Failed to uninstall a system application or end the application process.)<br>**STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT**: Installation failed. (Download timed out.)<br>**STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED**: Installation failed. (Download failed.)<br>**STATUS_RECOVER_FAILURE_INVALID**: Failed to restore the pre-installed application.<br>**STATUS_ABILITY_NOT_FOUND**: Ability not found.<br>**STATUS_BMS_SERVICE_ERROR**: BMS service error.<br>**STATUS_FAILED_NO_SPACE_LEFT**: Insufficient device space.<br>**STATUS_GRANT_REQUEST_PERMISSIONS_FAILED**: Application authorization failed.<br>**STATUS_INSTALL_PERMISSION_DENIED**: No installation permission.<br>**STATUS_UNINSTALL_PERMISSION_DENIED**: No uninstallation permission. | | statusMessage | string | Yes | No | Installation or uninstall status message. <br>**SUCCESS**: install_succeed<br>**STATUS_INSTALL_FAILURE**: Installation failed (no installation file exists).<br>**STATUS_INSTALL_FAILURE_ABORTED**: Installation aborted.<br>**STATUS_INSTALL_FAILURE_INVALID**: Invalid installation parameter.<br>**STATUS_INSTALL_FAILURE_CONFLICT**: Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.)<br>**STATUS_INSTALL_FAILURE_STORAGE**: Failed to store the bundle information.<br>**STATUS_INSTALL_FAILURE_INCOMPATIBLE**: Installation incompatibility. (A downgrade occurs or the signature information is incorrect.)<br>**STATUS_UNINSTALL_FAILURE**: Uninstallation failed. (The application to be uninstalled is not found.)<br>**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation aborted. (This error code is not in use.)<br>**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation conflict. (Failed to uninstall a system application or end the application process.)<br>**STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT**: Installation failed. (Download timed out.)<br>**STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED**: Installation failed. (Download failed.)<br>**STATUS_RECOVER_FAILURE_INVALID**: Failed to restore the pre-installed application.<br>**STATUS_ABILITY_NOT_FOUND**: Ability not found.<br>**STATUS_BMS_SERVICE_ERROR**: BMS service error.<br>**STATUS_FAILED_NO_SPACE_LEFT**: Insufficient device space.<br>**STATUS_GRANT_REQUEST_PERMISSIONS_FAILED**: Application authorization failed.<br>**STATUS_INSTALL_PERMISSION_DENIED**: No installation permission.<br>**STATUS_UNINSTALL_PERMISSION_DENIED**: No uninstallation permission. |
## Obtaining the Sandbox Path ## Obtaining the Sandbox Path
For the FA model, the sandbox path of a bundle can be obtained using the APIs in [Context](js-apis-inner-app-context.md). For the stage model, the sandbox path can be obtained using the attribute in [Context](js-apis-ability-context.md#abilitycontext). The following describes how to obtain the sandbox path. For the FA model, the sandbox path of a bundle can be obtained using the APIs in [Context](js-apis-inner-app-context.md). For the stage model, the sandbox path can be obtained using the attribute in [Context](js-apis-inner-application-uiAbilityContext.md#abilitycontext). The following describes how to obtain the sandbox path.
**Example** **Example**
``` ts ``` ts
......
...@@ -2142,7 +2142,7 @@ Provides APIs for certificate chain validator operations. ...@@ -2142,7 +2142,7 @@ Provides APIs for certificate chain validator operations.
validate(certChain : CertChainData, callback : AsyncCallback\<void>) : void validate(certChain : CertChainData, callback : AsyncCallback\<void>) : void
Validates the X.509 certificate chain. This API uses an asynchronous callback to return the result. Validates the X.509 certificate chain. This API uses an asynchronous callback to return the result.
The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](./../security/cert-overview.md#certificate-specifications). The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](../../security/cert-overview.md#certificate-specifications).
**System capability**: SystemCapability.Security.Cert **System capability**: SystemCapability.Security.Cert
...@@ -2197,7 +2197,7 @@ validator.validate(certChainData, function (error, data) { ...@@ -2197,7 +2197,7 @@ validator.validate(certChainData, function (error, data) {
validate(certChain : CertChainData) : Promise\<void> validate(certChain : CertChainData) : Promise\<void>
Validates the X.509 certificate chain. This API uses a promise to return the result. Validates the X.509 certificate chain. This API uses a promise to return the result.
The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](./../security/cert-overview.md#certificate-specifications). The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](../../security/cert-overview.md#certificate-specifications).
**System capability**: SystemCapability.Security.Cert **System capability**: SystemCapability.Security.Cert
......
...@@ -1632,7 +1632,7 @@ For details about the supported specifications, see [Encryption and Decryption S ...@@ -1632,7 +1632,7 @@ For details about the supported specifications, see [Encryption and Decryption S
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ------------------------------------------------------------ | | -------------- | ------ | ---- | ------------------------------------------------------------ |
| transformation | string | Yes | Combination of the algorithm name (including the key length), encryption mode, and padding algorithm of the **Cipher** instance to create.<br>For details, see **Algorithm String** in [Encryption and Decryption Specifications](../../security/cryptoFramework-overview.md#encryption-and- decryption-specifications). | | transformation | string | Yes | Combination of the algorithm name (including the key length), encryption mode, and padding algorithm of the **Cipher** instance to create.<br>For details, see **Algorithm String** in [Encryption and Decryption Specifications](../../security/cryptoFramework-overview.md#encryption-and-decryption-specifications). |
> **NOTE** > **NOTE**
> - In symmetric encryption and decryption, the implementation of PKCS #5 is the same as that of PKCS #7. PKCS #5 and PKCS #7 use the same padding length and block length. That is, data is padded with 8 bytes in 3DES and 16 bytes in AES. **noPadding** indicates that no padding is performed. <br>You need to understand the differences between different block cipher modes and set parameter correctly. For example, padding is required for ECB and CBC. Otherwise, the plaintext length must be an integer multiple of the block size. No padding is recommended for other modes. In this case, the ciphertext length is the same as the plaintext length. > - In symmetric encryption and decryption, the implementation of PKCS #5 is the same as that of PKCS #7. PKCS #5 and PKCS #7 use the same padding length and block length. That is, data is padded with 8 bytes in 3DES and 16 bytes in AES. **noPadding** indicates that no padding is performed. <br>You need to understand the differences between different block cipher modes and set parameter correctly. For example, padding is required for ECB and CBC. Otherwise, the plaintext length must be an integer multiple of the block size. No padding is recommended for other modes. In this case, the ciphertext length is the same as the plaintext length.
...@@ -2174,7 +2174,7 @@ update(data : DataBlob, callback : AsyncCallback\<void>) : void ...@@ -2174,7 +2174,7 @@ update(data : DataBlob, callback : AsyncCallback\<void>) : void
Updates the data to be signed. This API uses an asynchronous callback to return the result. Updates the data to be signed. This API uses an asynchronous callback to return the result.
> **NOTE**<br> > **NOTE**<br>
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures). > For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework **System capability**: SystemCapability.Security.CryptoFramework
...@@ -2200,7 +2200,7 @@ update(data : DataBlob) : Promise\<void>; ...@@ -2200,7 +2200,7 @@ update(data : DataBlob) : Promise\<void>;
Updates the data to be signed. This API uses a promise to return the result. Updates the data to be signed. This API uses a promise to return the result.
> **NOTE**<br> > **NOTE**<br>
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures). > For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework **System capability**: SystemCapability.Security.CryptoFramework
...@@ -2467,7 +2467,7 @@ update(data : DataBlob, callback : AsyncCallback\<void>) : void ...@@ -2467,7 +2467,7 @@ update(data : DataBlob, callback : AsyncCallback\<void>) : void
Updates the data for signature verification. This API uses an asynchronous callback to return the result. Updates the data for signature verification. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures). > For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework **System capability**: SystemCapability.Security.CryptoFramework
...@@ -2493,7 +2493,7 @@ update(data : DataBlob) : Promise\<void>; ...@@ -2493,7 +2493,7 @@ update(data : DataBlob) : Promise\<void>;
Updates the data for signature verification. This API uses a promise to return the result. Updates the data for signature verification. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures). > For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework **System capability**: SystemCapability.Security.CryptoFramework
......
...@@ -234,7 +234,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba ...@@ -234,7 +234,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | ---- | ---------------------------------------- | | --------- | ---------------------------------- | ---- | ---------------------------------------- |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. | | bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
...@@ -312,7 +312,7 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -312,7 +312,7 @@ Requests a continuous task from the system. This API uses a promise to return th
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | ---- | ---------------------------------------- | | --------- | ---------------------------------- | ---- | ---------------------------------------- |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. | | bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
...@@ -389,7 +389,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to ...@@ -389,7 +389,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------- | ---- | ---------------------------------------- |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -445,7 +445,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu ...@@ -445,7 +445,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------- | ---- | ---------------------------------------- | | ------- | ------- | ---- | ---------------------------------------- |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
**Return value** **Return value**
......
...@@ -346,6 +346,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes ...@@ -346,6 +346,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
| 9700001 | Memory operation failed. | | 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. | | 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. | | 9700003 | System service operation failed. |
| 9700004 | Check workInfo failed. |
**Example** **Example**
...@@ -391,6 +392,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes ...@@ -391,6 +392,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
| 9700001 | Memory operation failed. | | 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. | | 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. | | 9700003 | System service operation failed. |
| 9700004 | Check workInfo failed. |
**Example** **Example**
......
# @system.app (Application Context) # @system.app (Application Context)
> **NOTE** > **NOTE**
>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use the new APIs. > - The APIs of this module are no longer maintained since API version 7. You are advised to use the new APIs.
> >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -9,8 +10,8 @@ ...@@ -9,8 +10,8 @@
## Modules to Import ## Modules to Import
```ts ```
import app from '@system.app' import app from '@system.app';
``` ```
...@@ -34,13 +35,13 @@ Obtains the declared information in the **config.json** file of an application. ...@@ -34,13 +35,13 @@ Obtains the declared information in the **config.json** file of an application.
**Example** **Example**
```ts ```
export default { export default {
getInfo() { getInfo(){
let info = app.getInfo() var info = app.getInfo();
console.log(JSON.stringify(info)) console.log(JSON.stringify(info));
}
} }
}
``` ```
## app.terminate ## app.terminate
...@@ -57,12 +58,11 @@ Terminates the current ability. ...@@ -57,12 +58,11 @@ Terminates the current ability.
**Example** **Example**
```ts ```
export default { export default {
terminate() { terminate(){
app.terminate() app.terminate();
} }}
}
``` ```
## app.requestFullWindow ## app.requestFullWindow
...@@ -70,8 +70,6 @@ requestFullWindow(options?: RequestFullWindowOptions): void ...@@ -70,8 +70,6 @@ requestFullWindow(options?: RequestFullWindowOptions): void
Requests the application to run in full window. You can call this API when the FA runs in a non-full window, for example, semi-modal FA. This API is invalid for an application already in full-window mode. Requests the application to run in full window. You can call this API when the FA runs in a non-full window, for example, semi-modal FA. This API is invalid for an application already in full-window mode.
This is a system API and cannot be called by third-party applications.
> **NOTE** > **NOTE**
> >
> You are advised to use [@ohos.window](js-apis-window.md) since API version 7. > You are advised to use [@ohos.window](js-apis-window.md) since API version 7.
...@@ -79,20 +77,20 @@ This is a system API and cannot be called by third-party applications. ...@@ -79,20 +77,20 @@ This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [RequestFullWindowOptions](#requestfullwindowoptions) | No| Duration for transition from the non-full window to the full window, in milliseconds. By default, the value is in direct proportion to the distance between the non-full window and the full window.| | options | [RequestFullWindowOptions](#requestfullwindowoptions) | No| Duration for transition from the non-full window to the full window, in milliseconds. By default, the value is in direct proportion to the distance between the non-full window and the full window.|
**Example** **Example**
```ts ```
export default { export default {
requestFullWindow() { requestFullWindow(){
app.requestFullWindow({ app.requestFullWindow({
duration: 200 duration: 200});
}) }
} }
}
``` ```
## app.setImageCacheCount<sup>7+</sup> ## app.setImageCacheCount<sup>7+</sup>
...@@ -104,17 +102,18 @@ Sets the maximum number of decoded images that can be cached in the memory to sp ...@@ -104,17 +102,18 @@ Sets the maximum number of decoded images that can be cached in the memory to sp
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | No| Number of decoded images that are cached in the memory.| | value | number | Yes| Number of decoded images that are cached in the memory.|
**Example** **Example**
```ts ```
// app.ets // app.ets
import app from '@system.app' import app from '@system.app';
export default { export default {
onCreate() { onCreate() {
app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100.
console.info('Application onCreate') console.info('Application onCreate')
...@@ -122,7 +121,7 @@ export default { ...@@ -122,7 +121,7 @@ export default {
onDestroy() { onDestroy() {
console.info('Application onDestroy') console.info('Application onDestroy')
}, },
} }
``` ```
## app.setImageRawDataCacheSize<sup>7+</sup> ## app.setImageRawDataCacheSize<sup>7+</sup>
...@@ -134,17 +133,18 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d ...@@ -134,17 +133,18 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | No| Size of the image data cached before decoding, in bytes.| | value | number | Yes| Size of the image data cached before decoding, in bytes.|
**Example** **Example**
```ts ```
// app.ets // app.ets
import app from '@system.app' import app from '@system.app';
export default { export default {
onCreate() { onCreate() {
app.setImageRawDataCacheSize(104857600) app.setImageRawDataCacheSize(104857600)
// Set the upper limit of the memory for caching image data before decoding to 100 MB. (100 x 1024 x 1024 B =104857600 B = 100 MB). // Set the upper limit of the memory for caching image data before decoding to 100 MB. (100 x 1024 x 1024 B =104857600 B = 100 MB).
...@@ -153,7 +153,7 @@ export default { ...@@ -153,7 +153,7 @@ export default {
onDestroy() { onDestroy() {
console.info('Application onDestroy') console.info('Application onDestroy')
}, },
} }
``` ```
## app.setImageFileCacheSize<sup>7+</sup> ## app.setImageFileCacheSize<sup>7+</sup>
...@@ -165,17 +165,18 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading ...@@ -165,17 +165,18 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | No| Size of the image file cache, in bytes.| | value | number | Yes| Size of the image file cache, in bytes.|
**Example** **Example**
```ts ```
// app.ets // app.ets
import app from '@system.app' import app from '@system.app';
export default { export default {
onCreate() { onCreate() {
app.setImageFileCacheSize(209715200) app.setImageFileCacheSize(209715200)
// Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB). // Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB).
...@@ -184,7 +185,7 @@ export default { ...@@ -184,7 +185,7 @@ export default {
onDestroy() { onDestroy() {
console.info('Application onDestroy') console.info('Application onDestroy')
}, },
} }
``` ```
## AppResponse ## AppResponse
...@@ -200,6 +201,22 @@ Defines the application response information. ...@@ -200,6 +201,22 @@ Defines the application response information.
| versionName | string | Yes| Application version name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| | versionName | string | Yes| Application version name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite|
| versionCode | number | Yes| Application version number.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| | versionCode | number | Yes| Application version number.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite|
## ScreenOnVisible<sup>(deprecated)</sup>
screenOnVisible(options?: ScreenOnVisibleOptions):&nbsp;void
Defines whether to keep the application visible when the screen is woken up.
> **NOTE**
>
> This API is deprecated since API Version 8.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- |-------- |
| options | ScreenOnVisibleOptions | No| With keep-alive, the system is prevented from returning to the home screen when the screen is locked, so that the application is visible when the screen is woken up. |
## ScreenOnVisibleOptions ## ScreenOnVisibleOptions
Defines the options of the visible interface on the screen. Defines the options of the visible interface on the screen.
......
# @system.bluetooth (Bluetooth) # @system.bluetooth (Bluetooth)
> **NOTE**<br/> > **NOTE**
> >
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.bluetooth`](js-apis-bluetooth.md). > - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.bluetooth`](js-apis-bluetooth.md).
> >
...@@ -19,11 +19,10 @@ import bluetooth from '@system.bluetooth'; ...@@ -19,11 +19,10 @@ import bluetooth from '@system.bluetooth';
Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes system resources. Call [bluetooth.stopBLEScan](#bluetoothstopblescanobject) to stop the scan after a BLE device is detected and connected. Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes system resources. Call [bluetooth.stopBLEScan](#bluetoothstopblescanobject) to stop the scan after a BLE device is detected and connected.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite **System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters** **Parameters**
**Table 1** StartBLEScanOptions **Table 1** StartBLEScanOptions
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -42,7 +41,7 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys ...@@ -42,7 +41,7 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys
console.log('call bluetooth.startBLEScan success.'); console.log('call bluetooth.startBLEScan success.');
}, },
fail(code, data) { fail(code, data) {
console.log('call bluetooth.startBLEScan failed, code: ${code}, data: ${data}.'); console.log('call bluetooth.startBLEScan failed, code:' + code + ', data:' + data);
}, },
complete() { complete() {
console.log('call bluetooth.startBLEScan complete.'); console.log('call bluetooth.startBLEScan complete.');
...@@ -55,11 +54,10 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys ...@@ -55,11 +54,10 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys
Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLEScan(OBJECT)](#bluetoothstartblescanobject) in pairs. Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLEScan(OBJECT)](#bluetoothstartblescanobject) in pairs.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite **System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters** **Parameters**
**Table 2** StopBLEScanOptions **Table 2** StopBLEScanOptions
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -76,7 +74,7 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE ...@@ -76,7 +74,7 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE
console.log('call bluetooth.stopBLEScan success.'); console.log('call bluetooth.stopBLEScan success.');
}, },
fail(data, code) { fail(data, code) {
console.log('call bluethooth.stopBLEScan fail, code: ${code}, data: ${data}.'); console.log('call bluethooth.stopBLEScan fail, code:' + code + ', data:' + data);
}, },
complete() { complete() {
console.log('call bluethooth.stopBLEScan complete.'); console.log('call bluethooth.stopBLEScan complete.');
...@@ -89,8 +87,6 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE ...@@ -89,8 +87,6 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE
Subscribes to the newly detected BLE device. If this API is called multiple times, the last call takes effect. Subscribes to the newly detected BLE device. If this API is called multiple times, the last call takes effect.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite **System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters** **Parameters**
...@@ -122,10 +118,10 @@ Subscribes to the newly detected BLE device. If this API is called multiple time ...@@ -122,10 +118,10 @@ Subscribes to the newly detected BLE device. If this API is called multiple time
``` ```
bluetooth.subscribeBLEFound({ bluetooth.subscribeBLEFound({
success(data) { success(data) {
console.log('Called bluetooth.subscribeBLEFound successsully, data: ${data}.'); console.log('call bluetooth.subscribeBLEFound success, data: ${data}.');
}, },
fail(data, code) { fail(data, code) {
console.log('Failed to call bluetooth.startBLEScan, data: ${data}, code: ${code}.'); console.log('call bluetooth.startBLEScan failed, code:' + code + ', data:' + data);
} }
}); });
``` ```
...@@ -135,8 +131,6 @@ Subscribes to the newly detected BLE device. If this API is called multiple time ...@@ -135,8 +131,6 @@ Subscribes to the newly detected BLE device. If this API is called multiple time
Unsubscribes from the newly detected devices. Unsubscribes from the newly detected devices.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite **System capability**: SystemCapability.Communication.Bluetooth.Lite
**Example** **Example**
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The APIs provided by this module are deprecated since API version 9. You are advised to use [cryptoFramework-Cipher](js-apis-cryptoFramework.md#Cipher).
## Modules to Import ## Modules to Import
...@@ -18,9 +18,10 @@ Defines the response to the cipher interface called. ...@@ -18,9 +18,10 @@ Defines the response to the cipher interface called.
**System capability**: SystemCapability.Security.Cipher **System capability**: SystemCapability.Security.Cipher
| Name| Type | Mandatory| Description | | Name| Type | Readable| Writable|Description |
| ------ | ------ | ---- | ------------ | | ------ | ------ | ---- | ---- | ------------ |
| text | string | Yes | Response content.| | text | string | Yes | No | Response content.|
## CipherRsaOptions ## CipherRsaOptions
...@@ -88,10 +89,10 @@ export default { ...@@ -88,10 +89,10 @@ export default {
'+Enz0RzmVFh/4yk6lmqRzuEFQqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBw\n' + '+Enz0RzmVFh/4yk6lmqRzuEFQqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBw\n' +
'jBpApTJ3TeneOo6Z5QIDAQAB', 'jBpApTJ3TeneOo6Z5QIDAQAB',
success: function(data) { success: function(data) {
console.log(`Handling successful:${data.text}`); console.log(`handling success:${data.text}`);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log(`### cipher.rsa encryption failed ### ${code}:${data}`); console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`);
}, },
complete: function() { complete: function() {
console.log(`operation complete!`); console.log(`operation complete!`);
...@@ -121,10 +122,10 @@ export default { ...@@ -121,10 +122,10 @@ export default {
'M9TORIgdH8MjIbWsGnndAkEAw9yURDaorE8IYPLF2IEn09g1uzvWPs3phDb6smVx\n' + 'M9TORIgdH8MjIbWsGnndAkEAw9yURDaorE8IYPLF2IEn09g1uzvWPs3phDb6smVx\n' +
'8GfqIdUNf+aCG5TZK/kXBF1sqcsi7jXMAf4jBlejVbSVZg==', '8GfqIdUNf+aCG5TZK/kXBF1sqcsi7jXMAf4jBlejVbSVZg==',
success: function(data) { success: function(data) {
console.log(`Handling successful:${data.text}`); console.log(`handling success:${data.text}`);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log(`### cipher.rsa encryption failed ### ${code}:${data}`); console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`);
}, },
complete: function() { complete: function() {
console.log(`operation complete!`); console.log(`operation complete!`);
...@@ -165,10 +166,10 @@ export default { ...@@ -165,10 +166,10 @@ export default {
ivOffset: '0', ivOffset: '0',
ivLen: '16', ivLen: '16',
success: function(data) { success: function(data) {
console.log(`Handling successful:${data.text}`); console.log(`handling success:${data.text}`);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log(`### cipher.rsa encryption failed ### ${code}:${data}`); console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`);
}, },
complete: function() { complete: function() {
console.log(`operation complete!`); console.log(`operation complete!`);
...@@ -185,10 +186,10 @@ export default { ...@@ -185,10 +186,10 @@ export default {
ivOffset: '0', ivOffset: '0',
ivLen: '16', ivLen: '16',
success: function(data) { success: function(data) {
console.log(`Handling successful:${data.text}`); console.log(`handling success:${data.text}`);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log(`### cipher.aes encryption failed ### ${code}:${data}`); console.log(`### cipher.aes encrypt fail ### ${code}:${data}`);
}, },
complete: function() { complete: function() {
console.log(`operation complete!`); console.log(`operation complete!`);
......
# @system.vibrator (Vibrator) # @system.vibrator (Vibrator)
The **Vibrator** module provides APIs for controlling LED lights and vibrators. You can use the APIs to query the LED light list, turn on and off the LED light, query the vibrator list, query the vibrator effect, and trigger and turn off the vibrator. The **Vibrator** module provides APIs for controlling LED lights and vibrators. You can use the APIs to query the LED light list, turn on and off the LED light, query the vibrator list, query the vibrator effect, and trigger and turn off the vibrator.
Misc devices refer to LED lights and vibrators on devices. LED lights are mainly used for indication (for example, indicating the charging state) and blinking (such as tri-colored lights). Vibrators are mainly used in scenarios such as the alarm clock, power-on/off, and incoming call vibration. Misc devices refer to LED lights and vibrators on devices. LED lights are mainly used for indication (for example, indicating the charging state) and blinking (such as tri-colored lights). Vibrators are mainly used in scenarios such as the alarm clock, power-on/off, and incoming call vibration.
> **NOTE** > **NOTE**
> - The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.vibrator`](js-apis-vibrator.md) instead. > - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.vibrator`](js-apis-vibrator.md) instead.
> - This module requires hardware support and can only be debugged on real devices. > - This module requires hardware support and can only be debugged on real devices.
...@@ -21,26 +20,23 @@ import vibrator from '@system.vibrator'; ...@@ -21,26 +20,23 @@ import vibrator from '@system.vibrator';
## vibrator.vibrate ## vibrator.vibrate
vibrate(Object): void vibrate(options?: VibrateOptions): void
Triggers device vibration. Triggers device vibration.
**System capability**: SystemCapability.Sensors.MiscDevice **Required permissions**: ohos.permission.VIBRATE
**Required permissions**: ohos.permission.VIBRATE (a system permission) **System capability**: SystemCapability.Sensors.MiscDevice
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------- | --------------------------------- | ---- | ---------- |
| mode | string | No| Vibration mode. The value **long** indicates long vibration, and **short** indicates short vibration. The default value is **long**.| | options | [VibrateOptions](#vibrateoptions) | No | Vibration options.|
| success | Function | Yes| Called when the vibrator data changes.|
| fail | Function | No| Called when the API call fails.|
| complete | Function | No| Called when the API call is complete.|
**Example** **Example**
``` ```js
vibrator.vibrate({ vibrator.vibrate({
mode: 'short', mode: 'short',
success: function() { success: function() {
...@@ -54,3 +50,18 @@ vibrator.vibrate({ ...@@ -54,3 +50,18 @@ vibrator.vibrate({
} }
}); });
``` ```
## VibrateOptions
Defines the vibration options.
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| mode | string | No | Vibration mode. The value **long** indicates long vibration, and **short** indicates short vibration. The default value is **long**.|
| success | Function | No | Called when the vibrator data changes. |
| fail | Function | No | Called when the API call fails. |
| complete | Function | No | Called when the API call is complete. |
...@@ -345,7 +345,7 @@ For details about the stage model, see [Stage Model Development Overview](../app ...@@ -345,7 +345,7 @@ For details about the stage model, see [Stage Model Development Overview](../app
} }
} }
class MySequenceable { class MyParcelable {
num: number = 0; num: number = 0;
str: String = ""; str: String = "";
...@@ -354,31 +354,31 @@ For details about the stage model, see [Stage Model Development Overview](../app ...@@ -354,31 +354,31 @@ For details about the stage model, see [Stage Model Development Overview](../app
this.str = string; this.str = string;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
return true; return true;
} }
} }
function sendMsgCallback(data) { function sendMsgCallback(data) {
console.info('BgTaskAbility funcCallBack is called ' + data) console.info('BgTaskAbility funcCallBack is called ' + data)
let receivedData = new MySequenceable(0, "") let receivedData = new MyParcelable(0, "")
data.readSequenceable(receivedData) data.readParcelable(receivedData)
console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`)
// You can execute different methods based on the str value in the sequenceable data sent by the caller. // You can execute different methods based on the str value in the parcelable data sent by the caller.
if (receivedData.str === 'start_bgtask') { if (receivedData.str === 'start_bgtask') {
startContinuousTask() startContinuousTask()
} else if (receivedData.str === 'stop_bgtask') { } else if (receivedData.str === 'stop_bgtask') {
stopContinuousTask(); stopContinuousTask();
} }
return new MySequenceable(10, "Callee test"); return new MyParcelable(10, "Callee test");
} }
export default class BgTaskAbility extends Ability { export default class BgTaskAbility extends Ability {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册