提交 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
......
...@@ -28,7 +28,7 @@ Provides the **KVManager** instance configuration, including the bundle name of ...@@ -28,7 +28,7 @@ Provides the **KVManager** instance configuration, including the bundle name of
| 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 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-uiAbilityContext.md).|
| bundleName | string | Yes | Bundle name. | | bundleName | string | Yes | Bundle name. |
## Constants ## Constants
...@@ -272,7 +272,6 @@ Stage model: ...@@ -272,7 +272,6 @@ Stage model:
```js ```js
import UIAbility from '@ohos.app.ability.UIAbility' import UIAbility from '@ohos.app.ability.UIAbility'
let kvManager; let kvManager;
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onCreate() { onCreate() {
...@@ -358,7 +357,7 @@ try { ...@@ -358,7 +357,7 @@ try {
console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log("Obtained the KVStore successfully."); console.log("Succeeded in getting KVStore");
kvStore = store; kvStore = store;
}); });
} catch (e) { } catch (e) {
...@@ -411,7 +410,7 @@ try { ...@@ -411,7 +410,7 @@ try {
securityLevel: distributedKVStore.SecurityLevel.S2, securityLevel: distributedKVStore.SecurityLevel.S2,
}; };
kvManager.getKVStore('storeId', options).then((store) => { kvManager.getKVStore('storeId', options).then((store) => {
console.log("Obtained the KVStore successfully."); console.log("Succeeded in getting KVStore");
kvStore = store; kvStore = store;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`);
...@@ -453,14 +452,14 @@ const options = { ...@@ -453,14 +452,14 @@ const options = {
} }
try { try {
kvManager.getKVStore('storeId', options, async function (err, store) { kvManager.getKVStore('storeId', options, async function (err, store) {
console.log('Obtained the KVStore successfully.'); console.log('Succeeded in getting KVStore');
kvStore = store; kvStore = store;
kvManager.closeKVStore('appId', 'storeId', function (err, data) { kvManager.closeKVStore('appId', 'storeId', function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`); console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the KVStore successfully.'); console.log('Succeeded in closing KVStore');
}); });
}); });
} catch (e) { } catch (e) {
...@@ -505,10 +504,10 @@ const options = { ...@@ -505,10 +504,10 @@ const options = {
} }
try { try {
kvManager.getKVStore('storeId', options).then(async (store) => { kvManager.getKVStore('storeId', options).then(async (store) => {
console.log('Obtained the KVStore successfully.'); console.log('Succeeded in getting KVStore');
kvStore = store; kvStore = store;
kvManager.closeKVStore('appId', 'storeId').then(() => { kvManager.closeKVStore('appId', 'storeId').then(() => {
console.log('Closed the KVStore successfully.'); console.log('Succeeded in closing KVStore');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`); console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`);
}); });
...@@ -564,14 +563,14 @@ try { ...@@ -564,14 +563,14 @@ try {
console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the KVStore successfully.'); console.log('Succeeded in getting KVStore');
kvStore = store; kvStore = store;
kvManager.deleteKVStore('appId', 'storeId', function (err, data) { kvManager.deleteKVStore('appId', 'storeId', function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log(`Deleted the KVStore successfully.`); console.log(`Succeeded in deleting KVStore`);
}); });
}); });
} catch (e) { } catch (e) {
...@@ -624,10 +623,10 @@ const options = { ...@@ -624,10 +623,10 @@ const options = {
} }
try { try {
kvManager.getKVStore('storeId', options).then(async (store) => { kvManager.getKVStore('storeId', options).then(async (store) => {
console.log('Obtained the KVStore successfully.'); console.log('Succeeded in getting KVStore');
kvStore = store; kvStore = store;
kvManager.deleteKVStore('appId', 'storeId').then(() => { kvManager.deleteKVStore('appId', 'storeId').then(() => {
console.log('Deleted the KVStore successfully.'); console.log('Succeeded in deleting KVStore');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`);
}); });
...@@ -664,7 +663,7 @@ try { ...@@ -664,7 +663,7 @@ try {
console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`); console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained all KV store IDs successfully.'); console.log('Succeeded in getting AllKVStoreId');
console.log(`GetAllKVStoreId size = ${data.length}`); console.log(`GetAllKVStoreId size = ${data.length}`);
}); });
} catch (e) { } catch (e) {
...@@ -699,7 +698,7 @@ let kvManager; ...@@ -699,7 +698,7 @@ let kvManager;
try { try {
console.log('GetAllKVStoreId'); console.log('GetAllKVStoreId');
kvManager.getAllKVStoreId('appId').then((data) => { kvManager.getAllKVStoreId('appId').then((data) => {
console.log('Obtained all KV store IDs successfully.'); console.log('Succeeded in getting AllKVStoreId');
console.log(`GetAllKVStoreId size = ${data.length}`); console.log(`GetAllKVStoreId size = ${data.length}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`); console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`);
...@@ -829,7 +828,7 @@ let kvStore; ...@@ -829,7 +828,7 @@ let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('Obtained the result set successfully.'); console.log('getResultSet succeeded.');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.log('getResultSet failed: ' + err); console.log('getResultSet failed: ' + err);
...@@ -1000,7 +999,7 @@ let kvStore; ...@@ -1000,7 +999,7 @@ let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('Obtained the result set successfully.'); console.log('Succeeded in getting resultSet');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`);
...@@ -1039,7 +1038,7 @@ let kvStore; ...@@ -1039,7 +1038,7 @@ let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('Obtained the result set successfully.'); console.log('Succeeded in getting resultSet');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`);
...@@ -1242,7 +1241,7 @@ Resets the **Query** object. ...@@ -1242,7 +1241,7 @@ Resets the **Query** object.
| Type | Description | | Type | Description |
| -------------- | --------------------- | | -------------- | --------------------- |
| [Query](query) | **Query** object reset.| | [Query](#query) | **Query** object reset.|
**Example** **Example**
...@@ -1278,7 +1277,7 @@ Creates a **Query** object to match the specified field whose value is equal to ...@@ -1278,7 +1277,7 @@ Creates a **Query** object to match the specified field whose value is equal to
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1312,7 +1311,7 @@ Creates a **Query** object to match the specified field whose value is not equal ...@@ -1312,7 +1311,7 @@ Creates a **Query** object to match the specified field whose value is not equal
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1345,7 +1344,7 @@ Creates a **Query** object to match the specified field whose value is greater t ...@@ -1345,7 +1344,7 @@ Creates a **Query** object to match the specified field whose value is greater t
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1380,7 +1379,7 @@ Creates a **Query** object to match the specified field whose value is less than ...@@ -1380,7 +1379,7 @@ Creates a **Query** object to match the specified field whose value is less than
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1415,7 +1414,7 @@ Creates a **Query** object to match the specified field whose value is greater t ...@@ -1415,7 +1414,7 @@ Creates a **Query** object to match the specified field whose value is greater t
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1450,7 +1449,7 @@ Creates a **Query** object to match the specified field whose value is less than ...@@ -1450,7 +1449,7 @@ Creates a **Query** object to match the specified field whose value is less than
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1483,7 +1482,7 @@ Creates a **Query** object to match the specified field whose value is **null**. ...@@ -1483,7 +1482,7 @@ Creates a **Query** object to match the specified field whose value is **null**.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1517,7 +1516,7 @@ Creates a **Query** object to match the specified field whose value is within th ...@@ -1517,7 +1516,7 @@ Creates a **Query** object to match the specified field whose value is within th
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1551,7 +1550,7 @@ Creates a **Query** object to match the specified field whose value is within th ...@@ -1551,7 +1550,7 @@ Creates a **Query** object to match the specified field whose value is within th
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1585,7 +1584,7 @@ Creates a **Query** object to match the specified field whose value is not withi ...@@ -1585,7 +1584,7 @@ Creates a **Query** object to match the specified field whose value is not withi
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1619,7 +1618,7 @@ Creates a **Query** object to match the specified field whose value is not withi ...@@ -1619,7 +1618,7 @@ Creates a **Query** object to match the specified field whose value is not withi
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1653,7 +1652,7 @@ Creates a **Query** object to match the specified field whose value is similar t ...@@ -1653,7 +1652,7 @@ Creates a **Query** object to match the specified field whose value is similar t
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1687,7 +1686,7 @@ Creates a **Query** object to match the specified field whose value is not simil ...@@ -1687,7 +1686,7 @@ Creates a **Query** object to match the specified field whose value is not simil
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1714,7 +1713,7 @@ Creates a **Query** object with the AND condition. ...@@ -1714,7 +1713,7 @@ Creates a **Query** object with the AND condition.
| Type | Description | | Type | Description |
| -------------- | -------------- | | -------------- | -------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1743,7 +1742,7 @@ Creates a **Query** object with the OR condition. ...@@ -1743,7 +1742,7 @@ Creates a **Query** object with the OR condition.
| Type | Description | | Type | Description |
| -------------- | -------------- | | -------------- | -------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1778,7 +1777,7 @@ Creates a **Query** object to sort the query results in ascending order. ...@@ -1778,7 +1777,7 @@ Creates a **Query** object to sort the query results in ascending order.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1812,7 +1811,7 @@ Creates a **Query** object to sort the query results in descending order. ...@@ -1812,7 +1811,7 @@ Creates a **Query** object to sort the query results in descending order.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1847,7 +1846,7 @@ Creates a **Query** object to specify the number of results and where to start. ...@@ -1847,7 +1846,7 @@ Creates a **Query** object to specify the number of results and where to start.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1883,7 +1882,7 @@ Creates a **Query** object to match the specified field whose value is not **nul ...@@ -1883,7 +1882,7 @@ Creates a **Query** object to match the specified field whose value is not **nul
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1910,7 +1909,7 @@ Creates a **Query** object for a query condition group with a left parenthesis. ...@@ -1910,7 +1909,7 @@ Creates a **Query** object for a query condition group with a left parenthesis.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1939,7 +1938,7 @@ Creates a **Query** object for a query condition group with a right parenthesis. ...@@ -1939,7 +1938,7 @@ Creates a **Query** object for a query condition group with a right parenthesis.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -1974,7 +1973,7 @@ Creates a **Query** object with a specified key prefix. ...@@ -1974,7 +1973,7 @@ Creates a **Query** object with a specified key prefix.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -2008,7 +2007,7 @@ Creates a **Query** object with an index preferentially used for query. ...@@ -2008,7 +2007,7 @@ Creates a **Query** object with an index preferentially used for query.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -2042,7 +2041,7 @@ Creates a **Query** object with the device ID as the key prefix. ...@@ -2042,7 +2041,7 @@ Creates a **Query** object with the device ID as the key prefix.
| Type | Description | | Type | Description |
| -------------- | --------------- | | -------------- | --------------- |
| [Query](query) | **Query** object created.| | [Query](#query) | **Query** object created.|
**Example** **Example**
...@@ -2125,7 +2124,7 @@ try { ...@@ -2125,7 +2124,7 @@ try {
console.error(`Fail to put.code is ${err.code},message is ${err.message}`); console.error(`Fail to put.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log("Put data successfully."); console.log("Succeeded in putting");
}); });
} catch (e) { } catch (e) {
console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`);
...@@ -2170,7 +2169,7 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string'; ...@@ -2170,7 +2169,7 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
console.log(`Put data successfully. data=${data}`); console.log(`Succeeded in putting.data=${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put.code is ${err.code},message is ${err.message}`); console.error(`Fail to put.code is ${err.code},message is ${err.message}`);
}); });
...@@ -2226,12 +2225,12 @@ try { ...@@ -2226,12 +2225,12 @@ try {
console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.getEntries('batch_test_string_key', function (err, entries) { kvStore.getEntries('batch_test_string_key', function (err, entries) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
} }
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
}); });
...@@ -2289,9 +2288,9 @@ try { ...@@ -2289,9 +2288,9 @@ try {
} }
console.log(`entries: ${entries}`); console.log(`entries: ${entries}`);
kvStore.putBatch(entries).then(async (entries) => { kvStore.putBatch(entries).then(async (entries) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.getEntries('batch_test_string_key').then((entries) => { kvStore.getEntries('batch_test_string_key').then((entries) => {
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`PutBatch ${entries}`); console.log(`PutBatch ${entries}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
...@@ -2349,7 +2348,7 @@ try { ...@@ -2349,7 +2348,7 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}) })
} catch (e) { } catch (e) {
console.error(`Fail to put batch.code is ${e.code},message is ${e.message}`); console.error(`Fail to put batch.code is ${e.code},message is ${e.message}`);
...@@ -2402,7 +2401,7 @@ try { ...@@ -2402,7 +2401,7 @@ try {
v8Arr.push(vb2); v8Arr.push(vb2);
v8Arr.push(vb3); v8Arr.push(vb3);
kvStore.putBatch(v8Arr).then(async (data) => { kvStore.putBatch(v8Arr).then(async (data) => {
console.log(`Batch put data successfully.`); console.log(`Succeeded in putting patch`);
}).catch((err) => { }).catch((err) => {
console.error(`putBatch fail.code is ${err.code},message is ${err.message}`); console.error(`putBatch fail.code is ${err.code},message is ${err.message}`);
}); });
...@@ -2447,13 +2446,13 @@ try { ...@@ -2447,13 +2446,13 @@ try {
console.error(`Fail to put.code is ${err.code},message is ${err.message}`); console.error(`Fail to put.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Put data successfully.'); console.log('Succeeded in putting');
kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err, data) { kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Deleted data successfully.'); console.log('Succeeded in deleting');
}); });
}); });
} catch (e) { } catch (e) {
...@@ -2498,9 +2497,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string'; ...@@ -2498,9 +2497,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
console.log(`Put data successfully: ${data}`); console.log(`Succeeded in putting: ${data}`);
kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
console.log('Deleted data successfully.'); console.log('Succeeded in deleting');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete.code is ${err.code},message is ${err.message}`);
}); });
...@@ -2547,7 +2546,7 @@ try { ...@@ -2547,7 +2546,7 @@ try {
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
kvStore.delete(predicates, function (err, data) { kvStore.delete(predicates, function (err, data) {
if (err == undefined) { if (err == undefined) {
console.log('Deleted data successfully.'); console.log('Succeeded in deleting');
} else { } else {
console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete.code is ${err.code},message is ${err.message}`);
} }
...@@ -2599,9 +2598,9 @@ try { ...@@ -2599,9 +2598,9 @@ try {
let arr = ["name"]; let arr = ["name"];
predicates.inKeys(arr); predicates.inKeys(arr);
kvStore.put("name", "bob").then((data) => { kvStore.put("name", "bob").then((data) => {
console.log(`Put data successfully: ${data}`); console.log(`Succeeded in putting: ${data}`);
kvStore.delete(predicates).then((data) => { kvStore.delete(predicates).then((data) => {
console.log('Deleted data successfully.'); console.log('Succeeded in deleting');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete.code is ${err.code},message is ${err.message}`);
}); });
...@@ -2662,13 +2661,13 @@ try { ...@@ -2662,13 +2661,13 @@ try {
console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.deleteBatch(keys, async function (err, data) { kvStore.deleteBatch(keys, async function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to delete Batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete Batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch deleted data successfully.'); console.log('Succeeded in deleting Batch');
}); });
}); });
} catch (e) { } catch (e) {
...@@ -2726,9 +2725,9 @@ try { ...@@ -2726,9 +2725,9 @@ try {
} }
console.log(`entries: ${entries}`); console.log(`entries: ${entries}`);
kvStore.putBatch(entries).then(async (data) => { kvStore.putBatch(entries).then(async (data) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.deleteBatch(keys).then((err) => { kvStore.deleteBatch(keys).then((err) => {
console.log('Batch deleted data successfully.'); console.log('Succeeded in deleting Batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to delete Batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete Batch.code is ${err.code},message is ${err.message}`);
}); });
...@@ -2771,15 +2770,15 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; ...@@ -2771,15 +2770,15 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) {
console.log('Put data successfully.'); console.log('Succeeded in putting data');
const deviceid = 'no_exist_device_id'; const deviceid = 'no_exist_device_id';
kvStore.removeDeviceData(deviceid, async function (err, data) { kvStore.removeDeviceData(deviceid, async function (err, data) {
if (err == undefined) { if (err == undefined) {
console.log('Removed device data successfully.'); console.log('succeeded in removing device data');
} else { } else {
console.error(`Fail to remove device data.code is ${err.code},message is ${err.message} `); console.error(`Fail to remove device data.code is ${err.code},message is ${err.message} `);
kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err, data) { kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err, data) {
console.log('Obtained data successfully.'); console.log('Succeeded in getting data');
}); });
} }
}); });
...@@ -2825,18 +2824,18 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; ...@@ -2825,18 +2824,18 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => {
console.log('Put data successfully.'); console.log('Succeeded in putting data');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put data.code is ${err.code},message is ${err.message} `); console.error(`Fail to put data.code is ${err.code},message is ${err.message} `);
}); });
const deviceid = 'no_exist_device_id'; const deviceid = 'no_exist_device_id';
kvStore.removeDeviceData(deviceid).then((err) => { kvStore.removeDeviceData(deviceid).then((err) => {
console.log('Removed device data successfully.'); console.log('succeeded in removing device data');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to remove device data.code is ${err.code},message is ${err.message} `); console.error(`Fail to remove device data.code is ${err.code},message is ${err.message} `);
}); });
kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
console.log('Obtained data successfully.'); console.log('Succeeded in getting data');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get data.code is ${err.code},message is ${err.message} `); console.error(`Fail to get data.code is ${err.code},message is ${err.message} `);
}); });
...@@ -2882,13 +2881,13 @@ try { ...@@ -2882,13 +2881,13 @@ try {
console.error(`Fail to put.code is ${err.code},message is ${err.message}`); console.error(`Fail to put.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log("Put data successfully."); console.log("Succeeded in putting");
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get.code is ${err.code},message is ${err.message}`); console.error(`Fail to get.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log(`Obtained data successfully. data=${data}`); console.log(`Succeeded in getting data.data=${data}`);
}); });
}); });
} catch (e) { } catch (e) {
...@@ -2934,9 +2933,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string'; ...@@ -2934,9 +2933,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
console.log(`Put data successfully. data=${data}`); console.log(`Succeeded in putting data.data=${data}`);
kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
console.log(`Obtained data successfully. data=${data}`); console.log(`Succeeded in getting data.data=${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get.code is ${err.code},message is ${err.message}`); console.error(`Fail to get.code is ${err.code},message is ${err.message}`);
}); });
...@@ -2995,13 +2994,13 @@ try { ...@@ -2995,13 +2994,13 @@ try {
console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.getEntries('batch_test_string_key', function (err, entries) { kvStore.getEntries('batch_test_string_key', function (err, entries) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
}); });
...@@ -3059,9 +3058,9 @@ try { ...@@ -3059,9 +3058,9 @@ try {
} }
console.log(`entries: ${entries}`); console.log(`entries: ${entries}`);
kvStore.putBatch(entries).then(async (entries) => { kvStore.putBatch(entries).then(async (entries) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.getEntries('batch_test_string_key').then((entries) => { kvStore.getEntries('batch_test_string_key').then((entries) => {
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`PutBatch ${entries}`); console.log(`PutBatch ${entries}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
...@@ -3086,7 +3085,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an ...@@ -3086,7 +3085,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ----------------------------------------------- | | -------- | -------------------------------------- | ---- | ----------------------------------------------- |
| query | [Query](query) | Yes | Key prefix to match. | | query | [Query](#query) | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.|
**Error codes** **Error codes**
...@@ -3118,7 +3117,7 @@ try { ...@@ -3118,7 +3117,7 @@ try {
} }
console.log(`entries: {entries}`); console.log(`entries: {entries}`);
kvStore.putBatch(entries, async function (err, data) { kvStore.putBatch(entries, async function (err, data) {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getEntries(query, function (err, entries) { kvStore.getEntries(query, function (err, entries) {
...@@ -3126,7 +3125,7 @@ try { ...@@ -3126,7 +3125,7 @@ try {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
}); });
...@@ -3148,7 +3147,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a ...@@ -3148,7 +3147,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | -------------- | | ------ | -------------- | ---- | -------------- |
| query | [Query](query) | Yes | **Query** object to match.| | query | [Query](#query) | Yes | **Query** object to match.|
**Return value** **Return value**
...@@ -3185,18 +3184,18 @@ try { ...@@ -3185,18 +3184,18 @@ try {
} }
console.log(`entries: {entries}`); console.log(`entries: {entries}`);
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getEntries(query).then((entries) => { kvStore.getEntries(query).then((entries) => {
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
}); });
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`) console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`)
}); });
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
} catch (e) { } catch (e) {
console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`); console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`);
} }
...@@ -3249,20 +3248,20 @@ try { ...@@ -3249,20 +3248,20 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
kvStore.getResultSet('batch_test_string_key', async function (err, result) { kvStore.getResultSet('batch_test_string_key', async function (err, result) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}) })
}); });
}); });
...@@ -3319,18 +3318,18 @@ try { ...@@ -3319,18 +3318,18 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
}); });
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
}); });
...@@ -3386,7 +3385,7 @@ try { ...@@ -3386,7 +3385,7 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSet(query, async function (err, result) { kvStore.getResultSet(query, async function (err, result) {
...@@ -3394,7 +3393,7 @@ try { ...@@ -3394,7 +3393,7 @@ try {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
}); });
}); });
} catch (e) { } catch (e) {
...@@ -3414,7 +3413,7 @@ Obtains a **KVStoreResultSet** object that matches the specified **Query** objec ...@@ -3414,7 +3413,7 @@ Obtains a **KVStoreResultSet** object that matches the specified **Query** objec
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | -------------- | | ------ | -------------- | ---- | -------------- |
| query | [Query](query) | Yes | **Query** object to match.| | query | [Query](#query) | Yes | **Query** object to match.|
**Return value** **Return value**
...@@ -3450,14 +3449,14 @@ try { ...@@ -3450,14 +3449,14 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSet(query).then((result) => { kvStore.getResultSet(query).then((result) => {
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
...@@ -3508,14 +3507,14 @@ try { ...@@ -3508,14 +3507,14 @@ try {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}) })
}); });
} catch (e) { } catch (e) {
...@@ -3565,13 +3564,13 @@ try { ...@@ -3565,13 +3564,13 @@ try {
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.prefixKey("batch_test_string_key"); predicates.prefixKey("batch_test_string_key");
kvStore.getResultSet(predicates).then((result) => { kvStore.getResultSet(predicates).then((result) => {
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
}); });
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
}); });
...@@ -3603,7 +3602,7 @@ try { ...@@ -3603,7 +3602,7 @@ try {
let resultSet = null; let resultSet = null;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err == undefined) { if (err == undefined) {
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
} else { } else {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
} }
...@@ -3640,7 +3639,7 @@ let kvStore; ...@@ -3640,7 +3639,7 @@ let kvStore;
try { try {
let resultSet = null; let resultSet = null;
kvStore.closeResultSet(resultSet).then(() => { kvStore.closeResultSet(resultSet).then(() => {
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
}); });
...@@ -3661,7 +3660,7 @@ Obtains the number of results that matches the specified **Query** object. This ...@@ -3661,7 +3660,7 @@ Obtains the number of results that matches the specified **Query** object. This
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------- | | -------- | --------------------------- | ---- | ------------------------------------------- |
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results obtained.|
**Error codes** **Error codes**
...@@ -3691,7 +3690,7 @@ try { ...@@ -3691,7 +3690,7 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries, async function (err, data) { kvStore.putBatch(entries, async function (err, data) {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSize(query, async function (err, resultSize) { kvStore.getResultSize(query, async function (err, resultSize) {
...@@ -3699,7 +3698,7 @@ try { ...@@ -3699,7 +3698,7 @@ try {
console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set size successfully'); console.log('Succeeded in getting result set size');
}); });
}); });
} catch (e) { } catch (e) {
...@@ -3719,7 +3718,7 @@ Obtains the number of results that matches the specified **Query** object. This ...@@ -3719,7 +3718,7 @@ Obtains the number of results that matches the specified **Query** object. This
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | -------------- | | ------ | -------------- | ---- | -------------- |
| query | [Query](query) | Yes | **Query** object to match.| | query | [Query](#query) | Yes | **Query** object to match.|
**Return value** **Return value**
...@@ -3754,14 +3753,14 @@ try { ...@@ -3754,14 +3753,14 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSize(query).then((resultSize) => { kvStore.getResultSize(query).then((resultSize) => {
console.log('Obtained the result set size successfully'); console.log('Succeeded in getting result set size');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`);
}); });
...@@ -3803,7 +3802,7 @@ try { ...@@ -3803,7 +3802,7 @@ try {
if (err) { if (err) {
console.error(`Fail to backup.code is ${err.code},message is ${err.message} `); console.error(`Fail to backup.code is ${err.code},message is ${err.message} `);
} else { } else {
console.info(`Backed up data successfully. data=${data}`); console.info(`Succeeded in backupping data.data=${data}`);
} }
}); });
} catch (e) { } catch (e) {
...@@ -3846,7 +3845,7 @@ let kvStore; ...@@ -3846,7 +3845,7 @@ let kvStore;
let file = "BK001"; let file = "BK001";
try { try {
kvStore.backup(file).then((data) => { kvStore.backup(file).then((data) => {
console.info(`Backed up data successfully. data=${data}`); console.info(`Succeeded in backupping data.data=${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to backup.code is ${err.code},message is ${err.message}`); console.error(`Fail to backup.code is ${err.code},message is ${err.message}`);
}); });
...@@ -3888,7 +3887,7 @@ try { ...@@ -3888,7 +3887,7 @@ try {
if (err) { if (err) {
console.error(`Fail to restore.code is ${err.code},message is ${err.message}`); console.error(`Fail to restore.code is ${err.code},message is ${err.message}`);
} else { } else {
console.info(`Restored data successfully. data=${data}`); console.info(`Succeeded in restoring data.data=${data}`);
} }
}); });
} catch (e) { } catch (e) {
...@@ -3931,7 +3930,7 @@ let kvStore; ...@@ -3931,7 +3930,7 @@ let kvStore;
let file = "BK001"; let file = "BK001";
try { try {
kvStore.restore(file).then((data) => { kvStore.restore(file).then((data) => {
console.info(`Restored data successfully. data=${data}`); console.info(`Succeeded in restoring data.data=${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to restore.code is ${err.code},message is ${err.message}`); console.error(`Fail to restore.code is ${err.code},message is ${err.message}`);
}); });
...@@ -3965,7 +3964,7 @@ try { ...@@ -3965,7 +3964,7 @@ try {
if (err) { if (err) {
console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`);
} else { } else {
console.info(`Deleted the backup file successfully. data=${data}`); console.info(`Succeed in deleting Backup.data=${data}`);
} }
}); });
} catch (e) { } catch (e) {
...@@ -4000,7 +3999,7 @@ let kvStore; ...@@ -4000,7 +3999,7 @@ let kvStore;
let files = ["BK001", "BK002"]; let files = ["BK001", "BK002"];
try { try {
kvStore.deleteBackup(files).then((data) => { kvStore.deleteBackup(files).then((data) => {
console.info(`Deleted the backup file successfully. data=${data}`); console.info(`Succeed in deleting Backup.data=${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`); console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`);
}) })
...@@ -4061,7 +4060,7 @@ try { ...@@ -4061,7 +4060,7 @@ try {
console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`); console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Started the transaction successfully.'); console.log('Succeeded in starting Transaction');
let entries = putBatchString(10, 'batch_test_string_key'); let entries = putBatchString(10, 'batch_test_string_key');
console.log(`entries: ${entries}`); console.log(`entries: ${entries}`);
kvStore.putBatch(entries, async function (err, data) { kvStore.putBatch(entries, async function (err, data) {
...@@ -4069,7 +4068,7 @@ try { ...@@ -4069,7 +4068,7 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
}); });
}); });
} catch (e) { } catch (e) {
...@@ -4110,7 +4109,7 @@ try { ...@@ -4110,7 +4109,7 @@ try {
count++; count++;
}); });
kvStore.startTransaction().then(async (err) => { kvStore.startTransaction().then(async (err) => {
console.log('Started the transaction successfully.'); console.log('Succeeded in starting Transaction');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`); console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4148,7 +4147,7 @@ let kvStore; ...@@ -4148,7 +4147,7 @@ let kvStore;
try { try {
kvStore.commit(function (err, data) { kvStore.commit(function (err, data) {
if (err == undefined) { if (err == undefined) {
console.log('Committed the transaction successfully.'); console.log('Succeeded in committing');
} else { } else {
console.error(`Fail to commit.code is ${err.code},message is ${err.message}`); console.error(`Fail to commit.code is ${err.code},message is ${err.message}`);
} }
...@@ -4186,7 +4185,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ...@@ -4186,7 +4185,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
let kvStore; let kvStore;
try { try {
kvStore.commit().then(async (err) => { kvStore.commit().then(async (err) => {
console.log('Committed the transaction successfully.'); console.log('Succeeded in committing');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to commit.code is ${err.code},message is ${err.message}`); console.error(`Fail to commit.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4224,7 +4223,7 @@ let kvStore; ...@@ -4224,7 +4223,7 @@ let kvStore;
try { try {
kvStore.rollback(function (err,data) { kvStore.rollback(function (err,data) {
if (err == undefined) { if (err == undefined) {
console.log('Rolled back the transaction successfully'); console.log('Succeeded in rolling back');
} else { } else {
console.error(`Fail to rollback.code is ${err.code},message is ${err.message}`); console.error(`Fail to rollback.code is ${err.code},message is ${err.message}`);
} }
...@@ -4262,7 +4261,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ...@@ -4262,7 +4261,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
let kvStore; let kvStore;
try { try {
kvStore.rollback().then(async (err) => { kvStore.rollback().then(async (err) => {
console.log('Rolled back the transaction successfully'); console.log('Succeeded in rolling back');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to rollback.code is ${err.code},message is ${err.message}`); console.error(`Fail to rollback.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4293,7 +4292,7 @@ let kvStore; ...@@ -4293,7 +4292,7 @@ let kvStore;
try { try {
kvStore.enableSync(true, function (err, data) { kvStore.enableSync(true, function (err, data) {
if (err == undefined) { if (err == undefined) {
console.log('Enabled sync successfully.'); console.log('Succeeded in enabling sync');
} else { } else {
console.error(`Fail to enable sync.code is ${err.code},message is ${err.message}`); console.error(`Fail to enable sync.code is ${err.code},message is ${err.message}`);
} }
...@@ -4329,7 +4328,7 @@ Sets data synchronization, which can be enabled or disabled. This API uses a pro ...@@ -4329,7 +4328,7 @@ Sets data synchronization, which can be enabled or disabled. This API uses a pro
let kvStore; let kvStore;
try { try {
kvStore.enableSync(true).then((err) => { kvStore.enableSync(true).then((err) => {
console.log('Enabled sync successfully.'); console.log('Succeeded in enabling sync');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to enable sync.code is ${err.code},message is ${err.message}`); console.error(`Fail to enable sync.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4366,7 +4365,7 @@ try { ...@@ -4366,7 +4365,7 @@ try {
console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`); console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Set syncRange successfully.'); console.log('Succeeded in setting syncRange');
}); });
} catch (e) { } catch (e) {
console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`); console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`);
...@@ -4402,7 +4401,7 @@ try { ...@@ -4402,7 +4401,7 @@ try {
const localLabels = ['A', 'B']; const localLabels = ['A', 'B'];
const remoteSupportLabels = ['C', 'D']; const remoteSupportLabels = ['C', 'D'];
kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
console.log('Set syncRange successfully.'); console.log('Succeeded in setting syncRange');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`); console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4437,7 +4436,7 @@ try { ...@@ -4437,7 +4436,7 @@ try {
console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`); console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Set syncParam successfully'); console.log('Succeeded in setting syncParam');
}); });
} catch (e) { } catch (e) {
console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`); console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`);
...@@ -4471,7 +4470,7 @@ let kvStore; ...@@ -4471,7 +4470,7 @@ let kvStore;
try { try {
const defaultAllowedDelayMs = 500; const defaultAllowedDelayMs = 500;
kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => {
console.log('Set syncParam successfully'); console.log('Succeeded in setting syncParam');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`); console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4522,7 +4521,7 @@ try { ...@@ -4522,7 +4521,7 @@ try {
console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); console.error(`Fail to sync.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Put data successfully.'); console.log('Succeeded in putting data');
const devices = ['deviceList']; const devices = ['deviceList'];
const mode = distributedKVStore.SyncMode.PULL_ONLY; const mode = distributedKVStore.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 1000); kvStore.sync(devices, mode, 1000);
...@@ -4548,7 +4547,7 @@ Synchronizes the KV store manually. This API returns the result synchronously. F ...@@ -4548,7 +4547,7 @@ Synchronizes the KV store manually. This API returns the result synchronously. F
| --------- | --------------------- | ---- | ---------------------------------------------- | | --------- | --------------------- | ---- | ---------------------------------------------- |
| deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.| | deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.|
| mode | [SyncMode](#syncmode) | Yes | Synchronization mode. | | mode | [SyncMode](#syncmode) | Yes | Synchronization mode. |
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| delayMs | number | No | Allowed synchronization delay time, in ms. | | delayMs | number | No | Allowed synchronization delay time, in ms. |
**Error codes** **Error codes**
...@@ -4575,7 +4574,7 @@ try { ...@@ -4575,7 +4574,7 @@ try {
console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); console.error(`Fail to sync.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Put data successfully.'); console.log('Succeeded in putting data');
const devices = ['deviceList']; const devices = ['deviceList'];
const mode = distributedKVStore.SyncMode.PULL_ONLY; const mode = distributedKVStore.SyncMode.PULL_ONLY;
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
...@@ -4652,7 +4651,7 @@ try { ...@@ -4652,7 +4651,7 @@ try {
console.log(`syncComplete ${data}`); console.log(`syncComplete ${data}`);
}); });
kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
console.log('Put data successfully.'); console.log('succeeded in putting');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put.code is ${err.code},message is ${err.message}`); console.error(`Fail to put.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4793,7 +4792,7 @@ try { ...@@ -4793,7 +4792,7 @@ try {
console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`); console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained securityLevel successfully'); console.log('Succeeded in getting securityLevel');
}); });
} catch (e) { } catch (e) {
console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`); console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`);
...@@ -4828,7 +4827,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ...@@ -4828,7 +4827,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
let kvStore; let kvStore;
try { try {
kvStore.getSecurityLevel().then((data) => { kvStore.getSecurityLevel().then((data) => {
console.log('Obtained securityLevel successfully'); console.log('Succeeded in getting securityLevel');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`); console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4884,13 +4883,13 @@ try { ...@@ -4884,13 +4883,13 @@ try {
console.error(`Fail to put.code is ${err.code},message is ${err.message}`); console.error(`Fail to put.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log("Put data successfully."); console.log("Succeeded in putting");
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get.code is ${err.code},message is ${err.message}`); console.error(`Fail to get.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log(`Obtained data successfully. data=${data}`); console.log(`Succeeded in getting data.data=${data}`);
}); });
}); });
} catch (e) { } catch (e) {
...@@ -4936,9 +4935,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string'; ...@@ -4936,9 +4935,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
console.log(`Put data successfully. data=${data}`); console.log(`Succeeded in putting data.data=${data}`);
kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
console.log(`Obtained data successfully. data=${data}`); console.log(`Succeeded in getting data.data=${data}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get.code is ${err.code},message is ${err.message}`); console.error(`Fail to get.code is ${err.code},message is ${err.message}`);
}); });
...@@ -4988,13 +4987,13 @@ try { ...@@ -4988,13 +4987,13 @@ try {
console.error(`Fail to put.code is ${err.code},message is ${err.message}`); console.error(`Fail to put.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Put data successfully.'); console.log('Succeeded in putting');
kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err, data) { kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get.code is ${err.code},message is ${err.message}`); console.error(`Fail to get.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained data successfully'); console.log('Succeeded in getting');
}); });
}) })
} catch (e) { } catch (e) {
...@@ -5041,9 +5040,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; ...@@ -5041,9 +5040,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => {
console.log('Put data successfully.'); console.log('Succeeded in putting');
kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => {
console.log('Obtained data successfully'); console.log('Succeeded in getting');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get.code is ${err.code},message is ${err.message}`); console.error(`Fail to get.code is ${err.code},message is ${err.message}`);
}); });
...@@ -5102,13 +5101,13 @@ try { ...@@ -5102,13 +5101,13 @@ try {
console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.getEntries('batch_test_string_key', function (err, entries) { kvStore.getEntries('batch_test_string_key', function (err, entries) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
}); });
...@@ -5166,9 +5165,9 @@ try { ...@@ -5166,9 +5165,9 @@ try {
} }
console.log(`entries: ${entries}`); console.log(`entries: ${entries}`);
kvStore.putBatch(entries).then(async (entries) => { kvStore.putBatch(entries).then(async (entries) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
kvStore.getEntries('batch_test_string_key').then((entries) => { kvStore.getEntries('batch_test_string_key').then((entries) => {
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`PutBatch ${entries}`); console.log(`PutBatch ${entries}`);
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
...@@ -5229,13 +5228,13 @@ try { ...@@ -5229,13 +5228,13 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err, entries) { kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err, entries) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
}); });
...@@ -5294,9 +5293,9 @@ try { ...@@ -5294,9 +5293,9 @@ try {
} }
console.log(`entries: ${entries}`); console.log(`entries: ${entries}`);
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entries) => { kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entries) => {
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
console.log(`entries[0].value: ${entries[0].value}`); console.log(`entries[0].value: ${entries[0].value}`);
...@@ -5324,7 +5323,7 @@ Obtains all KV pairs that match the specified **Query** object for this device. ...@@ -5324,7 +5323,7 @@ Obtains all KV pairs that match the specified **Query** object for this device.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ----------------------------------------------------- | | -------- | -------------------------------------- | ---- | ----------------------------------------------------- |
| query | [Query](query) | Yes | Key prefix to match. | | query | [Query](#query) | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.|
**Error codes** **Error codes**
...@@ -5356,7 +5355,7 @@ try { ...@@ -5356,7 +5355,7 @@ try {
} }
console.log(`entries: {entries}`); console.log(`entries: {entries}`);
kvStore.putBatch(entries, async function (err, data) { kvStore.putBatch(entries, async function (err, data) {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getEntries(query, function (err, entries) { kvStore.getEntries(query, function (err, entries) {
...@@ -5364,7 +5363,7 @@ try { ...@@ -5364,7 +5363,7 @@ try {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
}); });
...@@ -5386,7 +5385,7 @@ Obtains all KV pairs that match the specified **Query** object for this device. ...@@ -5386,7 +5385,7 @@ Obtains all KV pairs that match the specified **Query** object for this device.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | -------------- | | ------ | -------------- | ---- | -------------- |
| query | [Query](query) | Yes | **Query** object to match.| | query | [Query](#query) | Yes | **Query** object to match.|
**Return value** **Return value**
...@@ -5423,18 +5422,18 @@ try { ...@@ -5423,18 +5422,18 @@ try {
} }
console.log(`entries: {entries}`); console.log(`entries: {entries}`);
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting Batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getEntries(query).then((entries) => { kvStore.getEntries(query).then((entries) => {
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`);
}); });
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`) console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`)
}); });
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting Entries');
} catch (e) { } catch (e) {
console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`); console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`);
} }
...@@ -5453,7 +5452,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th ...@@ -5453,7 +5452,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------- | | -------- | -------------------------------------- | ---- | ------------------------------------------------------- |
| deviceId | string | Yes | ID of the target device. | | deviceId | string | Yes | ID of the target device. |
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.|
**Error codes** **Error codes**
...@@ -5489,7 +5488,7 @@ try { ...@@ -5489,7 +5488,7 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
var query = new distributedKVStore.Query(); var query = new distributedKVStore.Query();
query.deviceId('localDeviceId'); query.deviceId('localDeviceId');
query.prefixKey("batch_test"); query.prefixKey("batch_test");
...@@ -5498,12 +5497,12 @@ try { ...@@ -5498,12 +5497,12 @@ try {
console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting entries');
console.log(`entries.length: ${entries.length}`); console.log(`entries.length: ${entries.length}`);
console.log(`entries[0]: ${entries[0]}`); console.log(`entries[0]: ${entries[0]}`);
}) })
}); });
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting entries');
} catch (e) { } catch (e) {
console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`); console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`);
} }
...@@ -5522,7 +5521,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th ...@@ -5522,7 +5521,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------- | ---- | -------------------- | | -------- | -------------- | ---- | -------------------- |
| deviceId | string | Yes | ID of the target device.| | deviceId | string | Yes | ID of the target device.|
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
**Return value** **Return value**
...@@ -5559,19 +5558,19 @@ try { ...@@ -5559,19 +5558,19 @@ try {
} }
console.log(`entries: ${entries}`); console.log(`entries: ${entries}`);
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
var query = new distributedKVStore.Query(); var query = new distributedKVStore.Query();
query.deviceId('localDeviceId'); query.deviceId('localDeviceId');
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getEntries('localDeviceId', query).then((entries) => { kvStore.getEntries('localDeviceId', query).then((entries) => {
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting entries');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`);
}); });
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
console.log('Obtained the entries successfully.'); console.log('Succeeded in getting entries');
} catch (e) { } catch (e) {
console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`); console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`);
} }
...@@ -5624,20 +5623,20 @@ try { ...@@ -5624,20 +5623,20 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
kvStore.getResultSet('batch_test_string_key', async function (err, result) { kvStore.getResultSet('batch_test_string_key', async function (err, result) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}) })
}); });
}); });
...@@ -5694,18 +5693,18 @@ try { ...@@ -5694,18 +5693,18 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
}); });
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
}); });
...@@ -5750,14 +5749,14 @@ try { ...@@ -5750,14 +5749,14 @@ try {
console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully.'); console.log('Succeeded in getting resultSet');
resultSet = result; resultSet = result;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the result set successfully.'); console.log('Succeeded in closing resultSet');
}) })
}); });
} catch (e) { } catch (e) {
...@@ -5802,13 +5801,13 @@ let kvStore; ...@@ -5802,13 +5801,13 @@ let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => {
console.log('Obtained the result set successfully.'); console.log('Succeeded in getting resultSet');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`);
}); });
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully.'); console.log('Succeeded in closing resultSet');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`);
}); });
...@@ -5830,7 +5829,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and * ...@@ -5830,7 +5829,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and *
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. | | deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. |
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the **KVStoreResultSet** object obtained.| | callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the **KVStoreResultSet** object obtained.|
**Error codes** **Error codes**
...@@ -5865,7 +5864,7 @@ try { ...@@ -5865,7 +5864,7 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSet('localDeviceId', query, async function (err, result) { kvStore.getResultSet('localDeviceId', query, async function (err, result) {
...@@ -5873,14 +5872,14 @@ try { ...@@ -5873,14 +5872,14 @@ try {
console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully.'); console.log('Succeeded in getting resultSet');
resultSet = result; resultSet = result;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the result set successfully.'); console.log('Succeeded in closing resultSet');
}) })
}); });
}); });
...@@ -5902,7 +5901,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and * ...@@ -5902,7 +5901,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and *
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------- | ---- | ---------------------------------- | | -------- | -------------- | ---- | ---------------------------------- |
| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs.| | deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs.|
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
**Return value** **Return value**
...@@ -5938,14 +5937,14 @@ try { ...@@ -5938,14 +5937,14 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSet('localDeviceId', query).then((result) => { kvStore.getResultSet('localDeviceId', query).then((result) => {
console.log('Obtained the result set successfully.'); console.log('Succeeded in getting resultSet');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`);
...@@ -5953,7 +5952,7 @@ try { ...@@ -5953,7 +5952,7 @@ try {
query.deviceId('localDeviceId'); query.deviceId('localDeviceId');
console.log("GetResultSet " + query.getSqlLike()); console.log("GetResultSet " + query.getSqlLike());
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully.'); console.log('Succeeded in closing resultSet');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`);
}); });
...@@ -5975,7 +5974,7 @@ Obtains a **KVStoreResultSet** object that matches the specified **Query** objec ...@@ -5975,7 +5974,7 @@ Obtains a **KVStoreResultSet** object that matches the specified **Query** objec
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | -------------- | | ------ | -------------- | ---- | -------------- |
| query | [Query](query) | Yes | **Query** object to match.| | query | [Query](#query) | Yes | **Query** object to match.|
**Return value** **Return value**
...@@ -6011,14 +6010,14 @@ try { ...@@ -6011,14 +6010,14 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSet(query).then((result) => { kvStore.getResultSet(query).then((result) => {
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
...@@ -6041,7 +6040,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and * ...@@ -6041,7 +6040,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and *
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------- | ---- | ---------------------------------- | | -------- | -------------- | ---- | ---------------------------------- |
| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs.| | deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs.|
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
**Return value** **Return value**
...@@ -6077,14 +6076,14 @@ try { ...@@ -6077,14 +6076,14 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSet('localDeviceId', query).then((result) => { kvStore.getResultSet('localDeviceId', query).then((result) => {
console.log('Obtained the result set successfully.'); console.log('Succeeded in getting resultSet');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`);
...@@ -6092,7 +6091,7 @@ try { ...@@ -6092,7 +6091,7 @@ try {
query.deviceId('localDeviceId'); query.deviceId('localDeviceId');
console.log("GetResultSet " + query.getSqlLike()); console.log("GetResultSet " + query.getSqlLike());
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully.'); console.log('Succeeded in closing resultSet');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`);
}); });
...@@ -6143,14 +6142,14 @@ try { ...@@ -6143,14 +6142,14 @@ try {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}) })
}); });
} catch (e) { } catch (e) {
...@@ -6200,13 +6199,13 @@ try { ...@@ -6200,13 +6199,13 @@ try {
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.prefixKey("batch_test_string_key"); predicates.prefixKey("batch_test_string_key");
kvStore.getResultSet(predicates).then((result) => { kvStore.getResultSet(predicates).then((result) => {
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
}); });
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
}); });
...@@ -6257,14 +6256,14 @@ try { ...@@ -6257,14 +6256,14 @@ try {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}) })
}); });
} catch (e) { } catch (e) {
...@@ -6314,13 +6313,13 @@ try { ...@@ -6314,13 +6313,13 @@ try {
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.prefixKey("batch_test_string_key"); predicates.prefixKey("batch_test_string_key");
kvStore.getResultSet('localDeviceId', predicates).then((result) => { kvStore.getResultSet('localDeviceId', predicates).then((result) => {
console.log('Obtained the result set successfully'); console.log('Succeeded in getting result set');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`);
}); });
kvStore.closeResultSet(resultSet).then((err) => { kvStore.closeResultSet(resultSet).then((err) => {
console.log('Closed the result set successfully'); console.log('Succeeded in closing result set');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`);
}); });
...@@ -6341,7 +6340,7 @@ Obtains the number of results that match the specified **Query** object for this ...@@ -6341,7 +6340,7 @@ Obtains the number of results that match the specified **Query** object for this
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------- | | -------- | --------------------------- | ---- | ------------------------------------------------- |
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results that match the specified **Query** object.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results that match the specified **Query** object.|
**Error codes** **Error codes**
...@@ -6371,7 +6370,7 @@ try { ...@@ -6371,7 +6370,7 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries, async function (err, data) { kvStore.putBatch(entries, async function (err, data) {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSize(query, async function (err, resultSize) { kvStore.getResultSize(query, async function (err, resultSize) {
...@@ -6379,7 +6378,7 @@ try { ...@@ -6379,7 +6378,7 @@ try {
console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained the result set size successfully'); console.log('Succeeded in getting result set size');
}); });
}); });
} catch (e) { } catch (e) {
...@@ -6399,7 +6398,7 @@ Obtains the number of results that match the specified **Query** object for this ...@@ -6399,7 +6398,7 @@ Obtains the number of results that match the specified **Query** object for this
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | -------------- | | ------ | -------------- | ---- | -------------- |
| query | [Query](query) | Yes | **Query** object to match.| | query | [Query](#query) | Yes | **Query** object to match.|
**Return value** **Return value**
...@@ -6434,14 +6433,14 @@ try { ...@@ -6434,14 +6433,14 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSize(query).then((resultSize) => { kvStore.getResultSize(query).then((resultSize) => {
console.log('Obtained the result set size successfully'); console.log('Succeeded in getting result set size');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`);
}); });
...@@ -6463,7 +6462,7 @@ Obtains the number of results that matches the specified device ID and **Query** ...@@ -6463,7 +6462,7 @@ Obtains the number of results that matches the specified device ID and **Query**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | --------------------------------------------------- | | -------- | --------------------------- | ---- | --------------------------------------------------- |
| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. | | deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. |
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results obtained.|
**Error codes** **Error codes**
...@@ -6497,7 +6496,7 @@ try { ...@@ -6497,7 +6496,7 @@ try {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) {
...@@ -6505,7 +6504,7 @@ try { ...@@ -6505,7 +6504,7 @@ try {
console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Obtained resultSize successfully'); console.log('Succeeded in getting resultSize');
; ;
}); });
}); });
...@@ -6527,7 +6526,7 @@ Obtains the number of results that matches the specified device ID and **Query** ...@@ -6527,7 +6526,7 @@ Obtains the number of results that matches the specified device ID and **Query**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------- | ---- | ---------------------------------- | | -------- | -------------- | ---- | ---------------------------------- |
| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs.| | deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs.|
| query | [Query](query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
**Return value** **Return value**
...@@ -6562,14 +6561,14 @@ try { ...@@ -6562,14 +6561,14 @@ try {
entries.push(entry); entries.push(entry);
} }
kvStore.putBatch(entries).then(async (err) => { kvStore.putBatch(entries).then(async (err) => {
console.log('Batch put data successfully.'); console.log('Succeeded in putting batch');
}).catch((err) => { }).catch((err) => {
console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`);
}); });
var query = new distributedKVStore.Query(); var query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
kvStore.getResultSize('localDeviceId', query).then((resultSize) => { kvStore.getResultSize('localDeviceId', query).then((resultSize) => {
console.log('Obtained resultSize successfully'); console.log('Succeeded in getting resultSize');
; ;
}).catch((err) => { }).catch((err) => {
console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`); console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`);
......
# @ohos.file.picker (Picker)
> **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.
**Picker** encapsulates system applications, such as **PhotoViewPicker**, **DocumentViewPicker**, and **AudioViewPicker**, and provides capabilities of selecting and saving images, videos, documents, and audio clips. The application can select the picker as required.
## Modules to Import
```js
import picker from '@ohos.file.picker';
```
## PhotoViewPicker
Provides APIs for selecting and saving images and videos. Before using the APIs of **PhotoViewPicker**, you need to create a **PhotoViewPicker** instance.
**System capability**: SystemCapability.FileManagement.UserFileService
**Example**
```ts
let photoPicker = new picker.PhotoViewPicker();
```
### select
select(option?: PhotoSelectOptions) : Promise&lt;PhotoSelectResult&gt;
Selects one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSelectOptions** to specify the media type and the maximum number of files to select.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [PhotoSelectOptions](#photoselectoptions) | No | Options for selecting images or videos.|
**Return value**
| Type | Description |
| ----------------------------- | :---- |
| Promise&lt;[PhotoSelectResult](#photoselectresult)&gt; | Promise used to return information about the images or videos selected.|
**Example**
```ts
async function example() {
try {
let PhotoSelectOptions = new picker.PhotoSelectOptions();
PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
PhotoSelectOptions.maxSelectNumber = 5;
let photoPicker = new picker.PhotoViewPicker();
photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult) => {
console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
}).catch((err) => {
console.error('PhotoViewPicker.select failed with err: ' + err);
});
} catch (err) {
console.error('PhotoViewPicker failed with err: ' + err);
}
}
```
### select
select(option: PhotoSelectOptions, callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
Selects one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSelectOptions** to specify the media type and the maximum number of files to select.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [PhotoSelectOptions](#photoselectoptions) | Yes | Options for selecting images or videos.|
| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt; | Yes | Callback invoked to return information about the images or videos selected.|
**Example**
```ts
async function example() {
try {
let PhotoSelectOptions = new picker.PhotoSelectOptions();
PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
PhotoSelectOptions.maxSelectNumber = 5;
let photoPicker = new picker.PhotoViewPicker();
photoPicker.select(PhotoSelectOptions, (err, PhotoSelectResult) => {
if (err) {
console.error('PhotoViewPicker.select failed with err: ' + err);
return;
}
console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
});
} catch (err) {
console.error('PhotoViewPicker failed with err: ' + err);
}
}
```
### select
select(callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
Selects one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt; | Yes | Callback invoked to return information about the images or videos selected.|
**Example**
```ts
async function example() {
try {
let photoPicker = new picker.PhotoViewPicker();
photoPicker.select((err, PhotoSelectResult) => {
if (err) {
console.error('PhotoViewPicker.select failed with err: ' + err);
return;
}
console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
});
} catch (err) {
console.error('PhotoViewPicker failed with err: ' + err);
}
}
```
### save
save(option?: PhotoSaveOptions) : Promise&lt;Array&lt;string&gt;&gt;
Saves one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [PhotoSaveOptions](#photosaveoptions) | No | Options for saving images or videos.|
**Return value**
| Type | Description |
| ----------------------------- | :---- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the files saved.|
**Example**
```ts
async function example() {
try {
let PhotoSaveOptions = new picker.PhotoSaveOptions();
PhotoSaveOptions.newFileNames = ['PhotoViewPicker01.jpg', 'PhotoViewPicker01.mp4'];
let photoPicker = new picker.PhotoViewPicker();
photoPicker.save(PhotoSaveOptions).then((PhotoSaveResult) => {
console.info('PhotoViewPicker.save successfully, PhotoSaveResult uri: ' + JSON.stringify(PhotoSaveResult));
}).catch((err) => {
console.error('PhotoViewPicker.save failed with err: ' + err);
});
} catch (err) {
console.error('PhotoViewPicker failed with err: ' + err);
}
}
```
### save
save(option: PhotoSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [PhotoSaveOptions](#photosaveoptions) | Yes | Options for saving images or videos.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the files saved.|
**Example**
```ts
async function example() {
try {
let PhotoSaveOptions = new picker.PhotoSaveOptions();
PhotoSaveOptions.newFileNames = ['PhotoViewPicker02.jpg','PhotoViewPicker02.mp4'];
let photoPicker = new picker.PhotoViewPicker();
photoPicker.save(PhotoSaveOptions, (err, PhotoSaveResult) => {
if (err) {
console.error('PhotoViewPicker.save failed with err: ' + err);
return;
}
console.info('PhotoViewPicker.save successfully, PhotoSaveResult uri: ' + JSON.stringify(PhotoSaveResult));
});
} catch (err) {
console.error('PhotoViewPicker failed with err: ' + err);
}
}
```
### save
save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the files saved.|
**Example**
```ts
async function example() {
try {
let photoPicker = new picker.PhotoViewPicker();
photoPicker.save((err, PhotoSaveResult) => {
if (err) {
console.error('PhotoViewPicker.save failed with err: ' + err);
return;
}
console.info('PhotoViewPicker.save successfully, PhotoSaveResult uri: ' + JSON.stringify(PhotoSaveResult));
});
} catch (err) {
console.error('PhotoViewPicker failed with err: ' + err);
}
}
```
## DocumentViewPicker
Provides APIs for selecting and saving non-media files, for example, documents in a variety of formats. Before using the APIs of **DocumentViewPicker**, you need to create a **DocumentViewPicker** instance.
**System capability**: SystemCapability.FileManagement.UserFileService
**Example**
```ts
let documentPicker = new picker.DocumentViewPicker();
```
### select
select(option?: DocumentSelectOptions) : Promise&lt;Array&lt;string&gt;&gt;
Selects one or more documents in a **documentPicker** page. This API uses a promise to return the result. You can pass in **DocumentSelectOptions**.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [DocumentSelectOptions](#documentselectoptions) | No | Options for selecting documents.|
**Return value**
| Type | Description |
| ----------------------------- | :---- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the documents selected.|
**Example**
```ts
async function example() {
try {
let DocumentSelectOptions = new picker.DocumentSelectOptions();
let documentPicker = new picker.DocumentViewPicker();
documentPicker.select(DocumentSelectOptions).then((DocumentSelectResult) => {
console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult));
}).catch((err) => {
console.error('DocumentViewPicker.select failed with err: ' + err);
});
} catch (err) {
console.error('DocumentViewPicker failed with err: ' + err);
}
}
```
### select
select(option: DocumentSelectOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Selects one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result. You can pass in **DocumentSelectOptions**.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [DocumentSelectOptions](#documentselectoptions) | Yes | Options for selecting documents.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the documents selected.|
**Example**
```ts
async function example() {
try {
let DocumentSelectOptions = new picker.DocumentSelectOptions();
let documentPicker = new picker.DocumentViewPicker();
documentPicker.select(DocumentSelectOptions, (err, DocumentSelectResult) => {
if (err) {
console.error('DocumentViewPicker.select failed with err: ' + err);
return;
}
console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult));
});
} catch (err) {
console.error('DocumentViewPicker failed with err: ' + err);
}
}
```
### select
select(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Selects one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the documents selected.|
**Example**
```ts
async function example() {
try {
let documentPicker = new picker.DocumentViewPicker();
documentPicker.select((err, DocumentSelectResult) => {
if (err) {
console.error('DocumentViewPicker.select failed with err: ' + err);
return;
}
console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult));
});
} catch (err) {
console.error('DocumentViewPicker failed with err: ' + err);
}
}
```
### save
save(option?: DocumentSaveOptions) : Promise&lt;Array&lt;string&gt;&gt;
Saves one or more documents in a **documentPicker** page. This API uses a promise to return the result. You can pass in **DocumentSaveOptions** to specify the file names to save.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [DocumentSaveOptions](#documentsaveoptions) | No | Options for saving the documents.|
**Return value**
| Type | Description |
| ----------------------------- | :---- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the documents saved.|
**Example**
```ts
async function example() {
try {
let DocumentSaveOptions = new picker.DocumentSaveOptions();
DocumentSaveOptions.newFileNames = ['DocumentViewPicker01.txt'];
let documentPicker = new picker.DocumentViewPicker();
documentPicker.save(DocumentSaveOptions).then((DocumentSaveResult) => {
console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult));
}).catch((err) => {
console.error('DocumentViewPicker.save failed with err: ' + err);
});
} catch (err) {
console.error('DocumentViewPicker failed with err: ' + err);
}
}
```
### save
save(option: DocumentSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result. You can pass in **DocumentSaveOptions** to specify the file names to save.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [DocumentSaveOptions](#documentsaveoptions) | Yes | Options for saving the documents.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the documents saved.|
**Example**
```ts
async function example() {
try {
let DocumentSaveOptions = new picker.DocumentSaveOptions();
DocumentSaveOptions.newFileNames = ['DocumentViewPicker02.txt'];
let documentPicker = new picker.DocumentViewPicker();
documentPicker.save(DocumentSaveOptions, (err, DocumentSaveResult) => {
if (err) {
console.error('DocumentViewPicker.save failed with err: ' + err);
return;
}
console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult));
});
} catch (err) {
console.error('DocumentViewPicker failed with err: ' + err);
}
}
```
### save
save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the documents saved.|
**Example**
```ts
async function example() {
try {
let documentPicker = new picker.DocumentViewPicker();
documentPicker.save((err, DocumentSaveResult) => {
if (err) {
console.error('DocumentViewPicker.save failed with err: ' + err);
return;
}
console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult));
});
} catch (err) {
console.error('DocumentViewPicker failed with err: ' + err);
}
}
```
## AudioViewPicker
Provides APIs for selecting and saving audio files. Before using the APIs of **AudioViewPicker**, you need to create an **AudioViewPicker** instance.
**System capability**: SystemCapability.FileManagement.UserFileService
**Example**
```ts
let audioPicker = new picker.AudioViewPicker();
```
### select
select(option?: AudioSelectOptions) : Promise&lt;Array&lt;string&gt;&gt;
Selects one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses a promise to return the result. You can pass in **AudioSelectOptions**.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [AudioSelectOptions](#audioselectoptions) | No | Options for selecting audio files.|
**Return value**
| Type | Description |
| ----------------------------- | :---- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the audio files selected.|
**Example**
```ts
async function example() {
try {
let AudioSelectOptions = new picker.AudioSelectOptions();
let audioPicker = new picker.AudioViewPicker();
audioPicker.select(AudioSelectOptions).then((AudioSelectResult) => {
console.info('AudioViewPicker.select successfully, AudioSelectResult uri: ' + JSON.stringify(AudioSelectResult));
}).catch((err) => {
console.error('AudioViewPicker.select failed with err: ' + err);
});
} catch (err) {
console.error('AudioViewPicker failed with err: ' + err);
}
}
```
### select
select(option: AudioSelectOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Selects one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result. You can pass in **AudioSelectOptions**.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [AudioSelectOptions](#audioselectoptions) | Yes | Options for selecting audio files.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the audio files selected.|
**Example**
```ts
async function example() {
try {
let AudioSelectOptions = new picker.AudioSelectOptions();
let audioPicker = new picker.AudioViewPicker();
audioPicker.select(AudioSelectOptions, (err, AudioSelectResult) => {
if (err) {
console.error('AudioViewPicker.select failed with err: ' + err);
return;
}
console.info('AudioViewPicker.select successfully, AudioSelectResult uri: ' + JSON.stringify(AudioSelectResult));
});
} catch (err) {
console.error('AudioViewPicker failed with err: ' + err);
}
}
```
### select
select(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Selects one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the audio files selected.|
**Example**
```ts
async function example() {
try {
let audioPicker = new picker.AudioViewPicker();
audioPicker.select((err, AudioSelectResult) => {
if (err) {
console.error('AudioViewPicker.select failed with err: ' + err);
return;
}
console.info('AudioViewPicker.select successfully, AudioSelectResult uri: ' + JSON.stringify(AudioSelectResult));
});
} catch (err) {
console.error('AudioViewPicker failed with err: ' + err);
}
}
```
### save
save(option?: AudioSaveOptions) : Promise&lt;Array&lt;string&gt;&gt;
Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses a promise to return the result. You can pass in **AudioSaveOptions** to specify the file names of the audio clips to save.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [AudioSaveOptions](#audiosaveoptions) | No | Options for saving audio files.|
**Return value**
| Type | Description |
| ----------------------------- | ---- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the audio files saved.|
**Example**
```ts
async function example() {
try {
let AudioSaveOptions = new picker.AudioSaveOptions();
AudioSaveOptions.newFileNames = ['AudioViewPicker01.mp3'];
let audioPicker = new picker.AudioViewPicker();
audioPicker.save(AudioSaveOptions).then((AudioSaveResult) => {
console.info('AudioViewPicker.save successfully, AudioSaveResult uri: ' + JSON.stringify(AudioSaveResult))
}).catch((err) => {
console.error('AudioViewPicker.save failed with err: ' + err);
});
} catch (err) {
console.error('AudioViewPicker failed with err: ' + err);
}
}
```
### save
save(option: AudioSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result. You can pass in **AudioSaveOptions** to specify the file names of the audio clips to save.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| option | [AudioSaveOptions](#audiosaveoptions) | Yes | Options for saving audio files.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the audio files saved.|
**Example**
```ts
async function example() {
try {
let AudioSaveOptions = new picker.AudioSaveOptions();
AudioSaveOptions.newFileNames = ['AudioViewPicker02.mp3'];
let audioPicker = new picker.AudioViewPicker();
audioPicker.save(AudioSaveOptions, (err, AudioSaveResult) => {
if (err) {
console.error('AudioViewPicker.save failed with err: ' + err);
return;
}
console.info('AudioViewPicker.save successfully, AudioSaveResult uri: ' + JSON.stringify(AudioSaveResult));
});
} catch (err) {
console.error('AudioViewPicker failed with err: ' + err);
}
}
```
### save
save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) : void
Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the URIs of the audio files saved.|
**Example**
```ts
async function example() {
try {
let audioPicker = new picker.AudioViewPicker();
audioPicker.save((err, AudioSaveResult) => {
if (err) {
console.error('AudioViewPicker.save failed with err: ' + err);
return;
}
console.info('AudioViewPicker.save successfully, AudioSaveResult uri: ' + JSON.stringify(AudioSaveResult));
});
} catch (err) {
console.error('AudioViewPicker failed with err: ' + err);
}
}
```
## PhotoViewMIMETypes
Enumerates the media file types that can be selected.
**System capability**: SystemCapability.FileManagement.UserFileService
| Name | Value| Description|
| ----- | ---- | ---- |
| IMAGE_TYPE | 'image/*' | Image.|
| VIDEO_TYPE | 'video/*' | Video.|
| IMAGE_VIDEO_TYPE | '\*/*' | Image and video.|
## PhotoSelectOptions
Defines the options for selecting images or videos.
**System capability**: SystemCapability.FileManagement.UserFileService
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | -------------------------------- |
| MIMEType? | [PhotoViewMIMETypes](#photoviewmimetypes) | No | Media file types to select.|
| maxSelectNumber? | number | No | Maximum number of media files to select. The default value is **50**, and the maximum value is **500**. |
## PhotoSelectResult
Defines information about the images or videos selected.
**System capability**: SystemCapability.FileManagement.UserFileService
| Name | Type | Readable| Writable| Description |
| ----------------------- | ------------------- | ---- | ---- | ------------------------------ |
| photoUris | Array&lt;string&gt; | Yes | Yes | URIs of the media files selected.|
| isOriginalPhoto | boolean | Yes | Yes | Whether the selected media file is the original image.|
## PhotoSaveOptions
Defines the options for saving images or videos.
**System capability**: SystemCapability.FileManagement.UserFileService
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ---------------------------- |
| newFileNames? | Array&lt;string&gt; | No | Files names of the images or videos to save.|
## DocumentSelectOptions
Defines the options for selecting documents. Currently, this parameter cannot be configured.
**System capability**: SystemCapability.FileManagement.UserFileService
## DocumentSaveOptions
Defines the options for saving documents.
**System capability**: SystemCapability.FileManagement.UserFileService
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ---------------------------- |
| newFileNames? | Array&lt;string&gt; | No | File names of the documents to save.|
## AudioSelectOptions
Defines the options for selecting audio clips. Currently, this parameter cannot be configured.
**System capability**: SystemCapability.FileManagement.UserFileService
## AudioSaveOptions
Defines the options for saving audio files.
**System capability**: SystemCapability.FileManagement.UserFileService
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ---------------------------- |
| newFileNames? | Array&lt;string&gt; | No | File names of the audio clips to save.|
...@@ -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!`);
......
...@@ -8,7 +8,7 @@ The sensors are classified into the following categories based on their function ...@@ -8,7 +8,7 @@ The sensors are classified into the following categories based on their function
> **NOTE** > **NOTE**
> >
> - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.sensor`](js-apis-sensor.md) instead. > - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.sensor`](js-apis-sensor.md) instead.
> - 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.
> - 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.
...@@ -19,15 +19,9 @@ The sensors are classified into the following categories based on their function ...@@ -19,15 +19,9 @@ The sensors are classified into the following categories based on their function
import sensor from '@system.sensor'; import sensor from '@system.sensor';
``` ```
## Error Codes
| Error Code | Description |
| ---- | -------------- |
| 900 | The current device does not support the corresponding sensor.|
## sensor.subscribeAccelerometer ## sensor.subscribeAccelerometer
subscribeAccelerometer(Object): void subscribeAccelerometer(options: subscribeAccelerometerOptions): void
Subscribes to data changes of the acceleration sensor. If this API is called multiple times for the same application, the last call takes effect. Subscribes to data changes of the acceleration sensor. If this API is called multiple times for the same application, the last call takes effect.
...@@ -37,23 +31,13 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul ...@@ -37,23 +31,13 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ---------------------------------------- | | ------- | ------------------------------------------------------------ | ---- | ------------------------------------------ |
| interval | string | Yes | Execution frequency of the callback for returning the acceleration sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| | options | [subscribeAccelerometerOptions](#subscribeaccelerometeroptions) | Yes | Type of data to return.|
| success | Function | Yes | Called when the acceleration sensor data changes. |
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| ---- | ------ | ------- |
| x | number | Acceleration on the x-axis.|
| y | number | Acceleration on the y-axis.|
| z | number | Acceleration on the z-axis.|
**Example** **Example**
``` ```js
sensor.subscribeAccelerometer({ sensor.subscribeAccelerometer({
interval: 'normal', interval: 'normal',
success: function(ret) { success: function(ret) {
...@@ -82,13 +66,13 @@ Unsubscribes from data changes of the acceleration sensor. ...@@ -82,13 +66,13 @@ Unsubscribes from data changes of the acceleration sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeAccelerometer(); sensor.unsubscribeAccelerometer();
``` ```
## sensor.subscribeCompass ## sensor.subscribeCompass
subscribeCompass(Object): void subscribeCompass(options: SubscribeCompassOptions): void
Subscribes to data changes of the compass sensor. If this API is called multiple times for the same application, the last call takes effect. Subscribes to data changes of the compass sensor. If this API is called multiple times for the same application, the last call takes effect.
...@@ -96,20 +80,13 @@ Subscribes to data changes of the compass sensor. If this API is called multiple ...@@ -96,20 +80,13 @@ Subscribes to data changes of the compass sensor. If this API is called multiple
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | --------------- | | ------- | --------------------------------------------------- | ---- | -------------------------------- |
| success | Function | Yes | Called when the compass sensor data changes.| | options | [SubscribeCompassOptions](#subscribecompassoptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| --------- | ------ | ---------- |
| direction | number | Direction of the device, in degrees.|
**Example** **Example**
``` ```js
sensor.subscribeCompass({ sensor.subscribeCompass({
success: function(ret) { success: function(ret) {
console.log('get data direction:' + ret.direction); console.log('get data direction:' + ret.direction);
...@@ -133,13 +110,13 @@ Unsubscribes from data changes of the compass sensor. ...@@ -133,13 +110,13 @@ Unsubscribes from data changes of the compass sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeCompass(); sensor.unsubscribeCompass();
``` ```
## sensor.subscribeProximity ## sensor.subscribeProximity
subscribeProximity(Object): void subscribeProximity(options: SubscribeProximityOptions): void
Subscribes to data changes of the proximity sensor. If this API is called multiple times for the same application, the last call takes effect. Subscribes to data changes of the proximity sensor. If this API is called multiple times for the same application, the last call takes effect.
...@@ -147,20 +124,13 @@ Subscribes to data changes of the proximity sensor. If this API is called multip ...@@ -147,20 +124,13 @@ Subscribes to data changes of the proximity sensor. If this API is called multip
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------- | | ------- | ------------------------------------------------------- | ---- | -------------------------------- |
| success | Function | Yes | Called when the proximity sensor data changes.| | options | [SubscribeProximityOptions](#subscribeproximityoptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| -------- | ------ | --------------------- |
| distance | number | Distance between a visible object and the device screen.|
**Example** **Example**
``` ```js
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function(ret) { success: function(ret) {
console.log('get data distance:' + ret.distance); console.log('get data distance:' + ret.distance);
...@@ -184,13 +154,13 @@ Unsubscribes from data changes of the proximity sensor. ...@@ -184,13 +154,13 @@ Unsubscribes from data changes of the proximity sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeProximity(); sensor.unsubscribeProximity();
``` ```
## sensor.subscribeLight ## sensor.subscribeLight
sensor.subscribeLight(Object): void subscribeLight(options: SubscribeLightOptions): void
Subscribes to data changes of the ambient light sensor. If this API is called multiple times, the last call takes effect. Subscribes to data changes of the ambient light sensor. If this API is called multiple times, the last call takes effect.
...@@ -198,20 +168,13 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu ...@@ -198,20 +168,13 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | --------------- | | ------- | ----------------------------------------------- | ---- | ---------------------------------- |
| success | Function | Yes | Called when the ambient light sensor data changes| | options | [SubscribeLightOptions](#subscribelightoptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| --------- | ------ | ------------ |
| intensity | number | Light intensity, in lux.|
**Example** **Example**
``` ```js
sensor.subscribeLight({ sensor.subscribeLight({
success: function(ret) { success: function(ret) {
console.log('get data intensity:' + ret.intensity); console.log('get data intensity:' + ret.intensity);
...@@ -235,13 +198,13 @@ Unsubscribes from data changes of the ambient light sensor. ...@@ -235,13 +198,13 @@ Unsubscribes from data changes of the ambient light sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeLight(); sensor.unsubscribeLight();
``` ```
## sensor.subscribeStepCounter ## sensor.subscribeStepCounter
subscribeStepCounter(Object): void subscribeStepCounter(options: SubscribeStepCounterOptions): void
Subscribes to data changes of the step counter sensor. If this API is called multiple times for the same application, the last call takes effect. Subscribes to data changes of the step counter sensor. If this API is called multiple times for the same application, the last call takes effect.
...@@ -251,20 +214,13 @@ Subscribes to data changes of the step counter sensor. If this API is called mul ...@@ -251,20 +214,13 @@ Subscribes to data changes of the step counter sensor. If this API is called mul
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ---------------- | | ------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
| success | Function | Yes | Called when the step counter sensor data changes.| | options | [SubscribeStepCounterOptions](#subscribestepcounteroptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| ----- | ------ | --------------------- |
| steps | number | Number of counted steps after the sensor is restarted.<br>|
**Example** **Example**
``` ```js
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function(ret) { success: function(ret) {
console.log('get step value:' + ret.steps); console.log('get step value:' + ret.steps);
...@@ -290,14 +246,14 @@ Unsubscribes from data changes of the step counter sensor. ...@@ -290,14 +246,14 @@ Unsubscribes from data changes of the step counter sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeStepCounter(); sensor.unsubscribeStepCounter();
``` ```
## sensor.subscribeBarometer ## sensor.subscribeBarometer
subscribeBarometer(Object): void subscribeBarometer(options: SubscribeBarometerOptions): void
Subscribes to data changes of the barometer sensor. If this API is called multiple times for the same application, the last call takes effect. Subscribes to data changes of the barometer sensor. If this API is called multiple times for the same application, the last call takes effect.
...@@ -305,20 +261,13 @@ Subscribes to data changes of the barometer sensor. If this API is called multip ...@@ -305,20 +261,13 @@ Subscribes to data changes of the barometer sensor. If this API is called multip
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ---------------- | | ------- | ------------------------------------------------------- | ---- | ---------------------------------- |
| success | Function | Yes | Called when the barometer sensor data changes.| | options | [SubscribeBarometerOptions](#subscribebarometeroptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| -------- | ------ | ----------- |
| pressure | number | Pressure, in pascal.|
**Example** **Example**
``` ```js
sensor.subscribeBarometer({ sensor.subscribeBarometer({
success: function(ret) { success: function(ret) {
console.log('get data value:' + ret.pressure); console.log('get data value:' + ret.pressure);
...@@ -343,14 +292,14 @@ Unsubscribes from data changes of the barometer sensor. ...@@ -343,14 +292,14 @@ Unsubscribes from data changes of the barometer sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeBarometer(); sensor.unsubscribeBarometer();
``` ```
## sensor.subscribeHeartRate ## sensor.subscribeHeartRate
subscribeHeartRate(Object): void subscribeHeartRate(options: SubscribeHeartRateOptions): void
Subscribes to data changes of the heart rate sensor. If this API is called multiple times for the same application, the last call takes effect. Subscribes to data changes of the heart rate sensor. If this API is called multiple times for the same application, the last call takes effect.
...@@ -360,20 +309,13 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi ...@@ -360,20 +309,13 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ------------------------- | | ------- | ------------------------------------------------------- | ---- | -------------------------------- |
| success | Function | Yes | Called when the heart rate sensor data changes. This callback is invoked every five seconds.| | options | [SubscribeHeartRateOptions](#subscribeheartrateoptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| --------- | ------ | ---- |
| heartRate | number | Heart rate.|
**Example** **Example**
``` ```js
sensor.subscribeHeartRate({ sensor.subscribeHeartRate({
success: function(ret) { success: function(ret) {
console.log('get heartrate value:' + ret.heartRate); console.log('get heartrate value:' + ret.heartRate);
...@@ -400,13 +342,13 @@ Unsubscribes from data changes of the heart rate sensor. ...@@ -400,13 +342,13 @@ Unsubscribes from data changes of the heart rate sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeHeartRate(); sensor.unsubscribeHeartRate();
``` ```
## sensor.subscribeOnBodyState ## sensor.subscribeOnBodyState
subscribeOnBodyState(Object): void subscribeOnBodyState(options: SubscribeOnBodyStateOptions): void
Subscribes to changes of the wearing state of a wearable device. If this API is called multiple times for the same application, the last call takes effect. Subscribes to changes of the wearing state of a wearable device. If this API is called multiple times for the same application, the last call takes effect.
...@@ -414,20 +356,13 @@ Subscribes to changes of the wearing state of a wearable device. If this API is ...@@ -414,20 +356,13 @@ Subscribes to changes of the wearing state of a wearable device. If this API is
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ------------- | | ------- | ----------------------------------------------------------- | ---- | ---------------------- |
| success | Function | Yes | Called when the wearing state changes.| | options | [SubscribeOnBodyStateOptions](#subscribeonbodystateoptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| ----- | ------- | ------ |
| value | boolean | Whether the wearable device is worn.|
**Example** **Example**
``` ```js
sensor.subscribeOnBodyState({ sensor.subscribeOnBodyState({
success: function(ret) { success: function(ret) {
console.log('get on-body state value:' + ret.value); console.log('get on-body state value:' + ret.value);
...@@ -451,13 +386,13 @@ Unsubscribes from changes of the wearing state of a wearable device. ...@@ -451,13 +386,13 @@ Unsubscribes from changes of the wearing state of a wearable device.
**Example** **Example**
``` ```js
sensor.unsubscribeOnBodyState(); sensor.unsubscribeOnBodyState();
``` ```
## sensor.getOnBodyState ## sensor.getOnBodyState
getOnBodyState(Object): void getOnBodyState(options: GetOnBodyStateOptions): void
Obtains the wearing state of a wearable device. Obtains the wearing state of a wearable device.
...@@ -465,21 +400,13 @@ Obtains the wearing state of a wearable device. ...@@ -465,21 +400,13 @@ Obtains the wearing state of a wearable device.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------ | | ------- | ----------------------------------------------- | ---- | -------------------------- |
| success | Function | No | Callback upon success.| | options | [GetOnBodyStateOptions](#getonbodystateoptions) | Yes | Type of data to return.|
| fail | Function | No | Callback upon failure.|
| complete | Function | No | Called when the execution is complete.|
Return values of the success callback
| Name | Type | Description |
| ----- | ------- | ------ |
| value | boolean | Whether the wearable device is worn.|
**Example** **Example**
``` ```js
sensor.getOnBodyState({ sensor.getOnBodyState({
success: function(ret) { success: function(ret) {
console.log('on body state: ' + ret.value); console.log('on body state: ' + ret.value);
...@@ -492,7 +419,7 @@ sensor.getOnBodyState({ ...@@ -492,7 +419,7 @@ sensor.getOnBodyState({
## sensor.subscribeDeviceOrientation<sup>6+</sup> ## sensor.subscribeDeviceOrientation<sup>6+</sup>
subscribeDeviceOrientation(interval: string, success: (data: DeviceOrientationResponse), fail?: (data: string, code: number)): void subscribeDeviceOrientation(options: SubscribeDeviceOrientationOptions): void
Subscribes to data changes of the device orientation sensor. Subscribes to data changes of the device orientation sensor.
...@@ -502,22 +429,13 @@ If this API is called multiple times for the same application, the last call tak ...@@ -502,22 +429,13 @@ If this API is called multiple times for the same application, the last call tak
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ---------------------------------------- | | ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ |
| interval | string | Yes | Interval at which the callback is invoked to return the device orientation sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| | options | [SubscribeDeviceOrientationOptions](#subscribedeviceorientationoptions) | Yes | Type of data to return.|
| success | Function | Yes | Called when the device orientation sensor data changes. |
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| ----- | ------ | ---------------------------------------- |
| alpha | number | Rotation angle around the Z axis when the X/Y axis of the device coincides with the X/Y axis of the earth.|
| beta | number | Rotation angle around the X axis when the Y/Z axis of the device coincides with the Y/Z axis of the earth.|
| gamma | number | Rotation angle around the Y axis when the X/Z axis of the device coincides with the X/Z axis of the earth.|
**Example** **Example**
``` ```js
sensor.subscribeDeviceOrientation({ sensor.subscribeDeviceOrientation({
interval: 'normal', interval: 'normal',
success: function(ret) { success: function(ret) {
...@@ -544,13 +462,13 @@ Unsubscribes from data changes of the device orientation sensor. ...@@ -544,13 +462,13 @@ Unsubscribes from data changes of the device orientation sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeDeviceOrientation(); sensor.unsubscribeDeviceOrientation();
``` ```
## sensor.subscribeGyroscope<sup>6+</sup> ## sensor.subscribeGyroscope<sup>6+</sup>
subscribeGyroscope(interval: string, success: (data: GyroscopeResponse), fail?: (data: string, code: number)): void subscribeGyroscope(options: SubscribeGyroscopeOptions): void
Subscribes to data changes of the gyroscope sensor. Subscribes to data changes of the gyroscope sensor.
...@@ -562,23 +480,13 @@ If this API is called multiple times for the same application, the last call tak ...@@ -562,23 +480,13 @@ If this API is called multiple times for the same application, the last call tak
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ---------------------------------------- | | ------- | ------------------------------------------------------- | ---- | ---------------------------------------------- |
| interval | string | Yes | Interval at which the callback is invoked to return the gyroscope sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| | options | [SubscribeGyroscopeOptions](#subscribegyroscopeoptions) | Yes | Type of data to return.|
| success | Function | Yes | Called when the gyroscope sensor data changes. |
| fail | Function | No | Callback upon failure. |
Return values of the success callback
| Name | Type | Description |
| ---- | ------ | --------- |
| x | number | Rotation angular velocity of the X axis.|
| y | number | Rotation angular velocity of the Y axis.|
| z | number | Rotation angular velocity of the Z axis.|
**Example** **Example**
``` ```js
sensor.subscribeGyroscope({ sensor.subscribeGyroscope({
interval: 'normal', interval: 'normal',
success: function(ret) { success: function(ret) {
...@@ -607,6 +515,253 @@ Unsubscribes from data changes of the gyroscope sensor. ...@@ -607,6 +515,253 @@ Unsubscribes from data changes of the gyroscope sensor.
**Example** **Example**
``` ```js
sensor.unsubscribeGyroscope(); sensor.unsubscribeGyroscope();
``` ```
## subscribeAccelerometerOptions
Defines the type of data to return for a subscription to the acceleration sensor data.
**Required permissions**: ohos.permission.ACCELEROMETER
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| interval | string | Yes | Execution frequency of the callback for returning the acceleration sensor data. The default value is **normal**. The options are as follows: - **game**: called at an interval of 20 ms, which is applicable to gaming scenarios. - **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios. - **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.|
| success | [AccelerometerResponse](#accelerometerresponse) | Yes | Called when the acceleration sensor data changes. |
| fail | Function | No | Callback upon an API call failure. |
## AccelerometerResponse
Defines the type of data to include in an **AccelerometerResponse** object.
**Required permissions**: ohos.permission.ACCELEROMETER
**System capability**: SystemCapability.Sensors.Sensor
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------- |
| x | number | Yes | Acceleration on the x-axis.|
| y | number | Yes | Acceleration on the y-axis.|
| z | number | Yes | Acceleration on the z-axis.|
## SubscribeCompassOptions
Defines the type of data to return for a subscription to the compass sensor data.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------- | ---- | ------------------------------ |
| success | [CompassResponse](#compassresponse) | Yes | Called when the compass sensor data changes.|
| fail | Function | No | Callback upon an API call failure. |
## CompassResponse
Defines the type of data to include in a **CompassResponse** object.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | -------------------- |
| direction | number | Yes | Direction of the device, in degrees.|
## SubscribeProximityOptions
Defines the type of data to return for a subscription to the proximity sensor data.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ---------------------------------- |
| success | [ProximityResponse](#proximityresponse) | Yes | Called when the proximity sensor data changes.|
| fail | Function | No | Callback upon an API call failure. |
## ProximityResponse
Defines the type of data to include in a **ProximityResponse** object.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------ |
| distance | number | Yes | Distance between a visible object and the device screen.|
## SubscribeLightOptions
Defines the type of data to return for a subscription to the ambient light sensor data.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ------------------------------ |
| success | [LightResponse](#lightresponse) | Yes | Called when the ambient light sensor data changes|
| fail | Function | No | Callback upon an API call failure. |
## LightResponse
Defines the type of data to include in a **LightResponse** object.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | --------------------- |
| intensity | number | Yes | Light intensity, in lux.|
## SubscribeStepCounterOptions
Defines the type of data to return for a subscription to the step counter sensor data.
**Required permissions**: ohos.permission.ACTIVITY_MOTION
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------- | ---- | -------------------------------- |
| success | [StepCounterResponse](#stepcounterresponse) | Yes | Called when the step counter sensor data changes.|
| fail | Function | No | Callback upon an API call failure. |
## StepCounterResponse
Defines the type of data to include in a **StepCounterResponse** object.
**Required permissions**: ohos.permission.ACTIVITY_MOTION
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ----- | ------ | ---- | -------------------------------- |
| steps | number | Yes | Number of counted steps after the sensor is restarted.|
## SubscribeBarometerOptions
Defines the type of data to return for a subscription to the barometer sensor data.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | -------------------------------- |
| success | [BarometerResponse](#barometerresponse) | Yes | Called when the barometer sensor data changes.|
| fail | Function | No | Callback upon an API call failure. |
## BarometerResponse
Defines the type of data to include in a **BarometerResponse** object.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------- |
| pressure | number | Yes | Pressure, in pascal.|
## SubscribeHeartRateOptions
Defines the type of data to return for a subscription to the heart rate sensor data.
**Required permissions**: ohos.permission.READ_HEALTH_DATA
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ----------------------------------------------- |
| success | [HeartRateResponse](#heartrateresponse) | Yes | Called when the heart rate sensor data changes. This callback is invoked every five seconds.|
| fail | Function | No | Callback upon an API call failure. |
## HeartRateResponse
Defines the type of data to include in a **HeartRateResponse** object.
**Required permissions**: ohos.permission.READ_HEALTH_DATA
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | -------- |
| heartRate | number | Yes | Heart rate.|
## SubscribeOnBodyStateOptions
Defines the type of data to return for a subscription to the wearing state changes.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------- | ---- | -------------------------- |
| success | [OnBodyStateResponse](#onbodystateresponse) | Yes | Called when the wearing state changes.|
| fail | Function | No | Callback upon an API call failure. |
## OnBodyStateResponse
Defines the wearing state.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ----- | ------- | ---- | ------------ |
| value | boolean | Yes | Whether the wearable device is worn.|
## GetOnBodyStateOptions
Defines the type of data to return for obtaining the wearing state.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------ |
| success | [OnBodyStateResponse](#onbodystateresponse) | No | Callback upon a successful API call.|
| fail | Function | No | Callback upon an API call failure.|
| complete | Function | No | Called when the API call is complete.|
## SubscribeDeviceOrientationOptions<sup>6+</sup>
Defines the type of data to return for a subscription to the device orientation sensor data.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| interval | string | Yes | Interval at which the callback is invoked to return the device orientation sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.|
| success | [DeviceOrientationResponse](#deviceorientationresponse) | Yes | Called when the device orientation sensor data changes. |
| fail | Function | No | Callback upon an API call failure. |
## DeviceOrientationResponse<sup>6+</sup>
Defines the type of data to include in a **DeviceOrientationResponse** object.
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| ----- | ------ | ---- | ------------------------------------------------------------ |
| alpha | number | Yes | Rotation angle around the Z axis when the X/Y axis of the device coincides with the X/Y axis of the earth.|
| beta | number | Yes | Rotation angle around the X axis when the Y/Z axis of the device coincides with the Y/Z axis of the earth.|
| gamma | number | Yes | Rotation angle around the Y axis when the X/Z axis of the device coincides with the X/Z axis of the earth.|
## SubscribeGyroscopeOptions<sup>6+</sup>
Defines the type of data to return for a subscription to the gyroscope sensor data.
**Required permissions**: ohos.permission.GYROSCOPE
**System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| interval | string | Yes | Interval at which the callback is invoked to return the gyroscope sensor data.<br>The default value is **normal**. The options are as follows:<br>- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.<br>- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.<br>- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.|
| success | [GyroscopeResponse](#gyroscoperesponse) | Yes | Called when the gyroscope sensor data changes. |
| fail | Function | No | Callback upon an API call failure. |
## GyroscopeResponse<sup>6+</sup>
Defines the type of data to include in a **GyroscopeResponse** object.
**Required permissions**: ohos.permission.GYROSCOPE
**System capability**: SystemCapability.Sensors.Sensor
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ----------------- |
| x | number | Yes | Rotation angular velocity of the X axis.|
| y | number | Yes | Rotation angular velocity of the Y axis.|
| z | number | Yes | Rotation angular velocity of the Z axis.|
# @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. |
# SystemCapability List # SystemCapability List
SystemCapability (SysCap in short) refers to a standalone feature in the operating system. SysCap, short for System Capability, refers to a standalone feature in the OpenHarmony system.
Before using an API for development, you are advised to familiarize yourself with [SysCap](syscap.md), and then consult the following tables to see whether the SysCap set required for the API is supported by the target device type. Before using an API for development, you are advised to familiarize yourself with [SysCap](syscap.md), and then consult the following tables to see whether the SysCap set required for the API is supported by the target device type.
...@@ -437,7 +437,7 @@ Basic media capabilities ...@@ -437,7 +437,7 @@ Basic media capabilities
## SystemCapability.Multimedia.Media.AudioPlayer ## SystemCapability.Multimedia.Media.AudioPlayer
Media audio player capability Audio player capability
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
...@@ -461,7 +461,7 @@ Media video player capability ...@@ -461,7 +461,7 @@ Media video player capability
## SystemCapability.Multimedia.Media.VideoRecorder ## SystemCapability.Multimedia.Media.VideoRecorder
Media video recorder capability Video recorder capability
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
...@@ -1125,7 +1125,7 @@ Environment-related interfaces ...@@ -1125,7 +1125,7 @@ Environment-related interfaces
## SystemCapability.FileManagement.File.DistributedFile ## SystemCapability.FileManagement.File.DistributedFile
Distributed file extension interfaces Distributed file extension
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
...@@ -1253,7 +1253,7 @@ Basic capabilities of cross-process data sharing ...@@ -1253,7 +1253,7 @@ Basic capabilities of cross-process data sharing
## SystemCapability.DistributedDataManager.DataShare.Consumer ## SystemCapability.DistributedDataManager.DataShare.Consumer
Data conumser of cross-process data sharing Data consumer of cross-process data sharing
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
...@@ -1285,7 +1285,7 @@ Core basic functional modules for component runtime, including application initi ...@@ -1285,7 +1285,7 @@ Core basic functional modules for component runtime, including application initi
## SystemCapability.Ability.AbilityRuntime.FAModel ## SystemCapability.Ability.AbilityRuntime.FAModel
Feature ability (FA) model Feature Ability (FA) model
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
...@@ -1394,3 +1394,267 @@ VAID management service ...@@ -1394,3 +1394,267 @@ VAID management service
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
## SystemCapability.Security.CertificateManager
Certificate management
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | Yes | Yes | No | No |
## SystemCapability.Security.CryptoFramework
Cryptographic framework – basic encryption and decryption capabilities
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.Core
Core services of bundle management, including bundle information query, bundle installation, and bundle uninstallation
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.FreeInstall
Installation-free features provided by the bundle manager
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.Resource
Icon and label acquisition provided by the bundle manager
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.DefaultApp
Default application management feature provided by the bundle manager
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.Launcher
Query feature provided by the bundle manager for Launcher
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.SandboxApp
Sandbox application features provided by the bundle manager
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.QuickFix
Quick fix provided by the bundle manager
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.AppControl
Application control features provided by the bundle manager
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Graphic.Graphic2D.ColorManager.Core
Wide color gamut management
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | No | Yes | No | No |
## SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
Efficiency resource application
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Multimedia.Media.AVPlayer
Audio and video player capability
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Multimedia.Media.AVRecorder
Audio and video recorder capability
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Security.Cert
Cryptographic framework – certificate capability
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | Yes | Yes | No | No |
## SystemCapability.Security.DataLossPrevention
Data leakage prevention
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | No | No | No | No |
## SystemCapability.Communication.NFC.Tag
NFC tag service
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| No | No | No | No | No | No | No | No |
## SystemCapability.Communication.NFC.CardEmulation
NFC card emulation service
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| No | No | No | No | No | No | No | No |
## SystemCapability.Multimedia.Image.ImageCreator
Image creation capability
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Developtools.Syscap
System capability encoding and decoding
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | Yes | Yes | Yes | Yes | Yes | Yes | No |
## SystemCapability.Communication.NetManager.Ethernet
Ethernet connectivity
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| No | No | No | Yes | Yes | Yes | No | No |
## SystemCapability.Communication.NetManager.NetSharing
Network sharing
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | No | Yes | No | No |
## SystemCapability.Communication.NetManager.MDNS
mDNS service
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Communication.NetManager.Vpn
VPN
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | No | Yes | No | No |
## SystemCapability.XTS.DeviceAttest
Device attestation
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.XTS.DeviceAttestLite
Lightweight device attestation
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| No | Yes | No | No | No | No | Yes | Yes |
## SystemCapability.FileManagement.UserFileManager.Core
Basic capabilities of public user file management
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.FileManagement.UserFileManager.DistributedCore
Distributed capabilities of public user file management
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.DistributedDataManager.UDMF.Core
Distributed data management – core capabilities of the Unified Data Management Framework (UDMF)
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | No | Yes | Yes | Yes | No | No |
## SystemCapability.BundleManager.BundleFramework.Overlay
Overlay feature provided by the bundle manager
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Cloud.Push
Push management service
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | Yes | No |
## SystemCapability.Multimedia.SystemSound.Core
System sound management, covering ringtones, notifications, alarms, and more
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
## SystemCapability.Ability.AbilityRuntime.QuickFix
Quick fix
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | Yes | Yes | No | No |
...@@ -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.
先完成此消息的编辑!
想要评论请 注册