diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md index f165215bad4d663b794c249f8029d33aeeda5863..b770a7bb881b780ff7b231f04fe02bc18aa3026e 100644 --- a/en/application-dev/IDL/idl-guidelines.md +++ b/en/application-dev/IDL/idl-guidelines.md @@ -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. -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). diff --git a/en/application-dev/application-models/fa-model-development-overview.md b/en/application-dev/application-models/fa-model-development-overview.md index 07e7ef8a0bdaea927762c15e4123ae728c026cb7..b717de91538d4369881cb5c62bdc52f56a11b62c 100644 --- a/en/application-dev/application-models/fa-model-development-overview.md +++ b/en/application-dev/application-models/fa-model-development-overview.md @@ -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)
[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)| | 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) | diff --git a/en/application-dev/application-models/hop-multi-device-collaboration.md b/en/application-dev/application-models/hop-multi-device-collaboration.md index 50fa38b975f137a508063869ac2760beb2dbbcdb..1bea57d43a5b3a3284a1a20a0abc6f888c8a6c33 100644 --- a/en/application-dev/application-models/hop-multi-device-collaboration.md +++ b/en/application-dev/application-models/hop-multi-device-collaboration.md @@ -47,19 +47,19 @@ On device A, touch the **Start** button provided by the initiator application to ### 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: ```ts requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) + let context = this.context + let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] + context.requestPermissionsFromUser(permissions).then((data) => { + console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)) + }).catch((error) => { + console.info("Failed to request permission from user with error: "+ JSON.stringify(error)) + }) } ``` @@ -129,19 +129,19 @@ On device A, touch the **Start** button provided by the initiator application to ### 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: ```ts requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) + let context = this.context + let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] + context.requestPermissionsFromUser(permissions).then((data) => { + console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)) + }).catch((error) => { + console.info("Failed to request permission from user with error: "+ JSON.stringify(error)) + }) } ``` @@ -218,19 +218,31 @@ A system application can connect to a service on another device by calling [conn ### 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: ```ts requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) + let context = this.context + let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] + context.requestPermissionsFromUser(permissions).then((data) => { + console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)) + }).catch((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 }); }, onDisconnect(elementName) { - console.info('onDisconnect callback'); + console.info('onDisconnect callback') }, 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. @@ -305,7 +317,7 @@ A system application can connect to a service on another device by calling [conn ## 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. @@ -319,45 +331,56 @@ The following describes how to implement multi-device collaboration through cros | startAbilityByCall(want: Want): Promise<Caller>; | 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.| | off(method: string): void | Callback invoked when the callee ability deregisters a method.| -| call(method: string, data: rpc.Sequenceable): Promise<void> | Sends agreed sequenceable data to the callee ability.| -| callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel> | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.| +| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the callee ability.| +| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence> | 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.| -| 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.| ### 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: ```ts requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) + let context = this.context + let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] + context.requestPermissionsFromUser(permissions).then((data) => { + console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)) + }).catch((error) => { + console.info("Failed to request permission from user with error: "+ JSON.stringify(error)) + }) } ``` 3. Create the callee ability. - - 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 launch type of the UIAbility. Set **launchType** of the callee ability to **singleton** in the **module.json5** file. | 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 UIAbility configuration is as follows: - ```json "abilities":[{ "name": ".CalleeAbility", @@ -371,17 +394,17 @@ The following describes how to implement multi-device collaboration through cros ``` 2. Import the **UIAbility** module. - + ```ts - import Ability from '@ohos.app.ability.UIAbility'; + import Ability from '@ohos.app.ability.UIAbility' ``` + + 3. Define the agreed parcelable data. - 3. Define the agreed sequenceable 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 - export default class MySequenceable { + export default class MyParcelable { num: number = 0 str: string = "" @@ -390,24 +413,24 @@ The following describes how to implement multi-device collaboration through cros this.str = string } - marshalling(messageParcel) { - messageParcel.writeInt(this.num) - messageParcel.writeString(this.str) + marshalling(messageSequence) { + messageSequence.writeInt(this.num) + messageSequence.writeString(this.str) return true } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt() - this.str = messageParcel.readString() + unmarshalling(messageSequence) { + this.num = messageSequence.readInt() + this.str = messageSequence.readString() return true } } ``` - - 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. - + 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 parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. + ```ts const TAG: string = '[CalleeAbility]' const MSG_SEND_METHOD: string = 'CallSendMsg' @@ -415,14 +438,14 @@ The following describes how to implement multi-device collaboration through cros function sendMsgCallback(data) { console.info('CalleeSortFunc called') - // Obtain the sequenceable data sent by the caller ability. - let receivedData = new MySequenceable(0, '') - data.readSequenceable(receivedData) + // Obtain the parcelable data sent by the caller ability. + let receivedData = new MyParcelable(0, '') + data.readParcelable(receivedData) console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) // Process the data. - // Return the sequenceable data result to the caller ability. - return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`) + // Return the parcelable data result to the caller ability. + return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`) } export default class CalleeAbility extends Ability { @@ -436,7 +459,7 @@ The following describes how to implement multi-device collaboration through cros onDestroy() { try { - this.callee.off(MSG_SEND_METHOD) + this.callee.off(MSG_SEND_METHOD) } catch (error) { console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`) } @@ -448,14 +471,13 @@ The following describes how to implement multi-device collaboration through cros 1. Import the **UIAbility** module. ```ts - import Ability from '@ohos.app.ability.UIAbility'; + import Ability from '@ohos.app.ability.UIAbility' ``` 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. - - + ```ts async onButtonGetRemoteCaller() { var caller = undefined @@ -469,7 +491,7 @@ The following describes how to implement multi-device collaboration through cros if (data != null) { caller = data console.info('get remote caller success') - // Register the onRelease() listener of the caller ability. + // 注册caller的release监听 caller.onRelease((msg) => { console.info(`remote caller onRelease is called ${msg}`) }) @@ -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). -5. Sends agreed sequenceable 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. +5. Sends agreed parcelable 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 - const MSG_SEND_METHOD: string = 'CallSendMsg'; + const MSG_SEND_METHOD: string = 'CallSendMsg' async onButtonCall() { try { - let msg = new MySequenceable(1, 'origin_Msg'); - await this.caller.call(MSG_SEND_METHOD, msg); + let msg = new MyParcelable(1, 'origin_Msg') + await this.caller.call(MSG_SEND_METHOD, msg) } 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**. ```ts - const MSG_SEND_METHOD: string = 'CallSendMsg'; - originMsg: string = ''; - backMsg: string = ''; + const MSG_SEND_METHOD: string = 'CallSendMsg' + originMsg: string = '' + backMsg: string = '' async onButtonCallWithResult(originMsg, backMsg) { try { - let msg = new MySequenceable(1, originMsg); - const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg); - console.info('caller callWithResult succeed'); + let msg = new MyParcelable(1, originMsg) + const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg) + console.info('caller callWithResult succeed') - let result = new MySequenceable(0, ''); - data.readSequenceable(result); - backMsg(result.str); - console.info(`caller result is [${result.num}, ${result.str}]`); + let result = new MyParcelable(0, '') + data.readParcelable(result) + backMsg(result.str) + console.info(`caller result is [${result.num}, ${result.str}]`) } 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 ```ts releaseCall() { try { - this.caller.release(); + this.caller.release() this.caller = undefined - console.info('caller release succeed'); + console.info('caller release succeed') } catch (error) { - console.info(`caller release failed with ${error}`); + console.info(`caller release failed with ${error}`) } } - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/application-models/itc-with-worker.md b/en/application-dev/application-models/itc-with-worker.md index 8cbe53eeea067ae1875a8ff4b73bc4cde7bdd629..996ab941b0244571dff6116a45ab5e2165cf1184 100644 --- a/en/application-dev/application-models/itc-with-worker.md +++ b/en/application-dev/application-models/itc-with-worker.md @@ -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 import worker from '@ohos.worker'; @@ -58,7 +58,7 @@ To develop the Worker mode, perform the following steps: ```ts 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. wk.postMessage("message from main thread.") @@ -74,6 +74,6 @@ To develop the Worker mode, perform the following steps: > **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). diff --git a/en/application-dev/application-models/stage-model-development-overview.md b/en/application-dev/application-models/stage-model-development-overview.md index 6fbf06baa44d4c0f2196fa3c1b00a0761a71a161..3436d29e5816cbe5b1ed30eba10e2435c34777e2 100644 --- a/en/application-dev/application-models/stage-model-development-overview.md +++ b/en/application-dev/application-models/stage-model-development-overview.md @@ -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)
- [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)
- [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)
- [Mission Management and Launch Type](mission-management-launch-type.md)
- [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)| diff --git a/en/application-dev/application-models/uiability-intra-device-interaction.md b/en/application-dev/application-models/uiability-intra-device-interaction.md index 4ec507ae7043e9b95f47a2ec954f1e95c52d53cb..065cd62fa005e91747b0ca2e1ef0e6657d333f73 100644 --- a/en/application-dev/application-models/uiability-intra-device-interaction.md +++ b/en/application-dev/application-models/uiability-intra-device-interaction.md @@ -50,7 +50,7 @@ Assume that your application has two UIAbility components: EntryAbility and Func ```ts import UIAbility from '@ohos.app.ability.UIAbility'; - import window from '@ohos.window'; + import Window from '@ohos.window'; export default class FuncAbility extends UIAbility { onCreate(want, launchParam) { @@ -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. ```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) => { // ... }); @@ -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) => { // ... }); @@ -196,13 +196,13 @@ This section describes how to start the UIAbility of another application through ``` The following figure shows the effect. When you click **Open PDF**, a dialog box is displayed for you to select. - - ![uiability-intra-device-interaction](figures/uiability-intra-device-interaction.png) + + ![uiability-intra-device-interaction](figures/uiability-intra-device-interaction.png) 3. To stop the **UIAbility** instance after the document application is used, call **terminateSelf()**. ```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) => { // ... }); @@ -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) => { // ... }); @@ -412,7 +412,6 @@ In summary, when a UIAbility instance of application A has been created and the ``` > **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. @@ -432,7 +431,7 @@ Ability call is usually used in the following scenarios: - 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| | -------- | -------- | @@ -443,9 +442,9 @@ Ability call is usually used in the following scenarios: 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. @@ -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). -**Table 2** Ability call APIs + **Table 2** Ability call APIs | API| Description| | -------- | -------- | | startAbilityByCall(want: Want): Promise<Caller> | 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.| | off(method: string): void | Callback invoked when the callee ability deregisters a method.| -| call(method: string, data: rpc.Sequenceable): Promise<void> | Sends agreed sequenceable data to the callee ability.| -| callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel> | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.| +| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the callee ability.| +| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence> | 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.| | on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.| @@ -487,16 +486,15 @@ 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. 1. Configure the ability launch type. - Set **launchType** of the callee ability to **singleton** in the **module.json5** file. -| JSON Field| Description| -| -------- | -------- | -| "launchType" | Ability launch type. Set this parameter to **singleton**.| - -An example of the ability configuration is as follows: + | JSON Field| Description| + | -------- | -------- | + | "launchType" | Ability launch type. Set this parameter to **singleton**.| + An example of the ability configuration is as follows: + ```json "abilities":[{ "name": ".CalleeAbility", @@ -510,18 +508,17 @@ An example of the ability configuration is as follows: ``` 2. Import the **UIAbility** module. - + ```ts 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. - + ```ts - export default class MySequenceable { + export default class MyParcelable { num: number = 0 str: string = "" @@ -530,25 +527,24 @@ An example of the ability configuration is as follows: this.str = string } - marshalling(messageParcel) { - messageParcel.writeInt(this.num) - messageParcel.writeString(this.str) + marshalling(messageSequence) { + messageSequence.writeInt(this.num) + messageSequence.writeString(this.str) return true } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt() - this.str = messageParcel.readString() + unmarshalling(messageSequence) { + this.num = messageSequence.readInt() + this.str = messageSequence.readString() return true } } ``` 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 const TAG: string = '[CalleeAbility]'; const MSG_SEND_METHOD: string = 'CallSendMsg'; @@ -556,14 +552,14 @@ An example of the ability configuration is as follows: function sendMsgCallback(data) { console.info('CalleeSortFunc called'); - // Obtain the sequenceable data sent by the caller ability. - let receivedData = new MySequenceable(0, ''); - data.readSequenceable(receivedData); + // Obtain the parcelable data sent by the caller ability. + let receivedData = new MyParcelable(0, ''); + data.readParcelable(receivedData); console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); // Process the data. - // Return the sequenceable data result to the caller ability. - return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`); + // Return the parcelable data result to the caller ability. + return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`); } export default class CalleeAbility extends Ability { @@ -595,10 +591,9 @@ An example of the ability configuration is as follows: ``` 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. - + ```ts // Register the onRelease() listener of the caller ability. private regOnRelease(caller) { diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 95a4a3831ed79e8290868cb8f967545f4e944800..63a81861741788db2e27d5d0f6d887fc570837ce 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -161,6 +161,7 @@ - [permissionDef](js-apis-bundleManager-permissionDef.md) - [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md) - [shortcutInfo](js-apis-bundleManager-shortcutInfo.md) + - UI Page - [@ohos.animator (Animator)](js-apis-animator.md) - [@ohos.curves (Interpolation Calculation)](js-apis-curve.md) @@ -182,16 +183,19 @@ - webgl - [WebGL](js-apis-webgl.md) - [WebGL2](js-apis-webgl2.md) + - Media - [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md) - [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md) - [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md) - [@ohos.multimedia.image (Image Processing)](js-apis-image.md) - [@ohos.multimedia.media (Media)](js-apis-media.md) + - Resource Management - [@ohos.i18n (Internationalization)](js-apis-i18n.md) - [@ohos.intl (Internationalization)](js-apis-intl.md) - [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md) + - Background Tasks - [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md) - [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md) @@ -199,6 +203,7 @@ - [@ohos.resourceschedule.workScheduler (Work Scheduler)](js-apis-resourceschedule-workScheduler.md) - [@ohos.resourceschedule.usageStatistics (Device Usage Statistics)](js-apis-resourceschedule-deviceUsageStatistics.md) - [@ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)](js-apis-WorkSchedulerExtensionAbility.md) + - Security - [@ohos.abilityAccessCtrl (Ability Access Control)](js-apis-abilityAccessCtrl.md) - [@ohos.privacyManager (Privacy Management)](js-apis-privacyManager.md) @@ -210,6 +215,7 @@ - [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md) - security - [PermissionRequestResult](js-apis-permissionrequestresult.md) + - Data Management - [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md) - [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md) @@ -222,12 +228,14 @@ - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - data/rdb - [resultSet](js-apis-data-resultset.md) + - File Management - [@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.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md) - [@ohos.file.fs (File Management)](js-apis-file-fs.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.statvfs (File System Space Statistics)](js-apis-file-statvfs.md) - [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md) @@ -242,6 +250,7 @@ - [@ohos.telephony.radio (Network Search)](js-apis-radio.md) - [@ohos.telephony.sim (SIM Management)](js-apis-sim.md) - [@ohos.telephony.sms (SMS)](js-apis-sms.md) + - Network Management - [@ohos.net.connection (Network Connection Management)](js-apis-net-connection.md) - [@ohos.net.ethernet (Ethernet Connection Management)](js-apis-net-ethernet.md) @@ -250,6 +259,7 @@ - [@ohos.net.socket (Socket Connection)](js-apis-socket.md) - [@ohos.net.webSocket (WebSocket Connection)](js-apis-webSocket.md) - [@ohos.request (Upload and Download)](js-apis-request.md) + - Connectivity - [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md) - [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md) @@ -264,6 +274,7 @@ - tag - [nfctech (Standard NFC Technologies)](js-apis-nfctech.md) - [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md) + - Basic Features - [@ohos.accessibility (Accessibility)](js-apis-accessibility.md) - [@ohos.accessibility.config (System Accessibility Configuration)](js-apis-accessibility-config.md) @@ -322,10 +333,12 @@ - [@ohos.update (Update)](js-apis-update.md) - [@ohos.usbManager (USB Manager)](js-apis-usbManager.md) - [@ohos.vibrator (Vibrator)](js-apis-vibrator.md) + - Account Management - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md) - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) + - Custom Management - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) @@ -356,9 +369,11 @@ - [@ohos.util.Vector (Linear Container Vector)](js-apis-vector.md) - [@ohos.worker (Worker Startup)](js-apis-worker.md) - [@ohos.xml (XML Parsing and Generation)](js-apis-xml.md) + - Test - [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md) - [@ohos.uitest (UiTest)](js-apis-uitest.md) + - APIs No Longer Maintained - [@ohos.backgroundTaskManager (Background Task Management)](js-apis-backgroundTaskManager.md) - [@ohos.bundle (Bundle)](js-apis-Bundle.md) diff --git a/en/application-dev/reference/apis/js-apis-ability-featureAbility.md b/en/application-dev/reference/apis/js-apis-ability-featureAbility.md index 476e721fbdc1437a706a882ba38e0a39c369793c..06a12e5a27300dd5683fd7e4c6154033c00fcb3d 100644 --- a/en/application-dev/reference/apis/js-apis-ability-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-ability-featureAbility.md @@ -365,7 +365,7 @@ featureAbility.terminateSelfWithResult( }); ``` -## featureAbility.hasWindowFocus7+ +## featureAbility.hasWindowFocus7+ hasWindowFocus(callback: AsyncCallback\): void @@ -388,7 +388,7 @@ featureAbility.hasWindowFocus((err, data) => { }); ``` -## featureAbility.hasWindowFocus7+ +## featureAbility.hasWindowFocus7+ hasWindowFocus(): Promise\ @@ -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_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_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_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.| diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md index b30cb6fd73a6a78613a6beab3e9f320bc78a59aa..b3e7045d414d247acd5f6658f688de7fbd2db700 100644 --- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md +++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -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.
**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_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_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.| diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md index d4419f96f9177cd2f1ba169f0c84a1caaf57abb1..ff1bbfa2187c2a5ad868e28e11e08ae1a77ed705 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md @@ -35,8 +35,8 @@ Enumerates the initial ability launch reasons. You can use it together with [onC | Name | Value | Description | | ----------------------------- | ---- | ------------------------------------------------------------ | | UNKNOWN | 0 | Unknown reason.| -| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-ability-context.md#abilitycontextstartability).| -| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-ability-context.md#abilitycontextstartabilitybycall).| +| 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-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall).| | 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.| @@ -124,8 +124,8 @@ Enumerates the window modes in which an ability can be displayed at startup. It ```ts let want = { - bundleName: 'com.test.example', - abilityName: 'MainAbility' + bundleName: 'com.example.myapplication', + abilityName: 'EntryAbility' }; let option = { windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN @@ -135,7 +135,7 @@ let option = { this.context.startAbility(want, option).then(()=>{ console.log('Succeed to start ability.'); }).catch((error)=>{ - console.log('Failed to start ability with error: ' + JSON.stringify(error)); + console.error('Failed to start ability with error: ${JSON.stringify(error)}'); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-app-ability-common.md b/en/application-dev/reference/apis/js-apis-app-ability-common.md index 44e7922bd5004e27e994dc61f8e473d3b02209d1..497867de9df35f93bc04b818a305e32b3a5dee3a 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-common.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-common.md @@ -24,8 +24,8 @@ import common from '@ohos.app.ability.common'; | Context | [Context](js-apis-inner-application-context.md) | Level-2 module **Context**.| | ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Level-2 module **ExtensionContext**.| | 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**.| -| 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**.| | AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.| | ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.| @@ -42,19 +42,7 @@ let context: common.Context; let extensionContext: common.ExtensionContext; let formExtensionContext: common.FormExtensionContext; let eventHub: common.EventHub; -let permissionRequestResult: common.PermissionRequestResult; let pacMap: common.PacMap; let abilityResult: common.AbilityResult; 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).| diff --git a/en/application-dev/reference/apis/js-apis-app-ability-extensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-extensionAbility.md index d532723b43a1c31f2b01b35799747ec689df5099..14d3eb1c084173646eeec6ece05ada654a45ac84 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-extensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-extensionAbility.md @@ -1,10 +1,31 @@ # @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** > > 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. +## Modules to Import + +```ts +import ExtensionAbility from '@ohos.app.ability.ExtensionAbility'; +``` + **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)); + } + } + ``` + diff --git a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md index eca749eef4accc20828572a8a85466f23b6b9c1b..d9d9db6fdfe71ed60275638085b17c314233882c 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md @@ -1,6 +1,6 @@ # @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** > @@ -150,7 +150,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal onDisconnect(want: Want): void | Promise; -Called when this ServiceExtensionAbility is disconnected. +Called when a client is disconnected from this ServiceExtensionAbility. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -176,7 +176,7 @@ Called when this ServiceExtensionAbility is disconnected. 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 diff --git a/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md b/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md index b750094435503f6b54a5826fcab9995ca5aa33be..aceabe2bece920ca9034689c2425f4d34b5a69c7 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md @@ -1,6 +1,6 @@ # @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** > diff --git a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md index 72114bd58c0b28ad1411780e4e78ef6053d8b4e6..2c0fa34611d102078e71cc83e25c3a45ac1a1beb 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md @@ -1,10 +1,9 @@ # @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): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability). -- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications. +- [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). +- [Callee](#callee): an internal object of UIAbility. The CalleeAbility (callee) uses this object to communicate with the CallerAbility (caller). > **NOTE** > @@ -23,12 +22,12 @@ import Ability from '@ohos.app.ability.UIAbility'; | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of the ability.| -| launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the ability.| -| lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the ability was started last time.| +| 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 UIAbility.| +| 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.| -## Ability.onCreate +## UIAbility.onCreate onCreate(want: Want, param: AbilityConstant.LaunchParam): void; @@ -40,7 +39,7 @@ Called to initialize the service logic when an ability is created. | 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.| **Example** @@ -54,11 +53,11 @@ Called to initialize the service logic when an ability is created. ``` -## Ability.onWindowStageCreate +## UIAbility.onWindowStageCreate 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 @@ -79,11 +78,11 @@ Called when a **WindowStage** is created for this ability. ``` -## Ability.onWindowStageDestroy +## UIAbility.onWindowStageDestroy 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 @@ -98,11 +97,11 @@ Called when the **WindowStage** is destroyed for this ability. ``` -## Ability.onWindowStageRestore +## UIAbility.onWindowStageRestore 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 @@ -123,7 +122,7 @@ Called when the **WindowStage** is restored during the migration of this ability ``` -## Ability.onDestroy +## UIAbility.onDestroy onDestroy(): void | Promise<void>; @@ -142,7 +141,7 @@ Called when this ability is destroyed to clear resources. ``` -## Ability.onForeground +## UIAbility.onForeground onForeground(): void; @@ -161,7 +160,7 @@ Called when this ability is switched from the background to the foreground. ``` -## Ability.onBackground +## UIAbility.onBackground onBackground(): void; @@ -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; @@ -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; -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 @@ -227,7 +226,7 @@ Called when a new Want is passed in and this ability is started again. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | 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** @@ -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\): Array\; @@ -266,11 +265,11 @@ Dumps client information. ``` -## Ability.onSaveState +## UIAbility.onSaveState 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 @@ -278,7 +277,7 @@ Called when the framework automatically saves the ability state in the case of a | 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: string]: any} | Yes| **want** parameter.| **Return value** @@ -305,22 +304,22 @@ class MyUIAbility extends Ability { ## 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 call(method: string, data: rpc.Parcelable): Promise<void>; -Sends sequenceable data to the target ability. +Sends parcelable data to the target ability. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **Parameters** -| 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.| -| data | [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | Yes| Sequenceable data. You need to customize the data.| + | 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 parcelable data.| + | data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.| **Return value** @@ -333,13 +332,12 @@ Sends sequenceable data to the target ability. | ID| Error Message| | ------- | -------------------------------- | | 401 | If the input parameter is not valid parameter. | - For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). **Example** ```ts - class MyMessageAble{ // Custom sequenceable data structure. + class MyMessageAble{ // Custom parcelable data structure. name:'' str:'' num: 1 @@ -347,15 +345,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error this.name = name; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); return true; } @@ -370,7 +368,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error deviceId: '' }).then((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) .then(() => { console.log('Caller call() called'); @@ -390,31 +388,30 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ## Caller.callWithResult -callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageParcel>; +callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>; -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 **Parameters** -| 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.| -| data | [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | Yes| Sequenceable data. You need to customize the data.| + | 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 parcelable data.| + | data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)> | Promise used to return the sequenceable data from the target ability.| + | Type| Description| + | -------- | -------- | + | Promise<[rpc.MessageSequence](js-apis-rpc.md#messagesequence9)> | Promise used to return the parcelable data from the target ability.| **Error codes** | ID| Error Message| | ------- | -------------------------------- | | 401 | If the input parameter is not valid parameter. | - For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). **Example** @@ -428,15 +425,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error this.name = name; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); return true; } @@ -456,7 +453,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error .then((data) => { console.log('Caller callWithResult() called'); let retmsg = new MyMessageAble(0, ''); - data.readSequenceable(retmsg); + data.readParcelable(retmsg); }) .catch((callErr) => { console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) + @@ -477,7 +474,7 @@ release(): void; Releases the caller interface of the target ability. -**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore +**System capability**: SystemCapability.UIAbility.UIAbilityRuntime.UIAbilityCore **Error codes** @@ -576,7 +573,6 @@ Registers a callback that is invoked when the stub on the target ability is disc | ID| Error Message| | ------- | -------------------------------- | | 401 | If the input parameter is not valid parameter. | - For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). **Example** @@ -627,7 +623,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di | ID| Error Message| | ------- | -------------------------------- | | 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** @@ -678,7 +674,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di | ID| Error Message| | ------- | -------------------------------- | | 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** @@ -724,17 +720,16 @@ Registers a caller notification callback, which is invoked when the target abili **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| 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.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | method | string | Yes| Notification message string negotiated between the two abilities.| + | 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** | ID| Error Message| | ------- | -------------------------------- | | 401 | If the input parameter is not valid parameter. | - For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). **Example** @@ -748,15 +743,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error this.name = name; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); return true; } @@ -765,7 +760,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error function funcCallBack(pdata) { console.log('Callee funcCallBack is called ' + pdata); let msg = new MyMessageAble('test', ''); - pdata.readSequenceable(msg); + pdata.readParcelable(msg); return new MyMessageAble('test1', 'Callee test'); } export default class MainAbility extends Ability { @@ -787,7 +782,7 @@ off(method: string): void; 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** @@ -800,7 +795,6 @@ Deregisters a caller notification callback, which is invoked when the target abi | ID| Error Message| | ------- | -------------------------------- | | 401 | If the input parameter is not valid parameter. | - 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 ## CalleeCallback -(indata: rpc.MessageParcel): rpc.Parcelable; +(indata: rpc.MessageSequence): rpc.Parcelable; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore | 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.| diff --git a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md index 80677a5b42a89bf8fba1aa543e811babdfcd396a..137c59a9765655de7c1b727e9769977897f6c2ca 100644 --- a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md @@ -1,6 +1,6 @@ # @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** > @@ -19,7 +19,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; | 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 @@ -33,7 +33,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been | 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** @@ -145,7 +145,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility { console.error('Operation updateForm failed. Cause: ' + error);}); } } -} +}; ``` ## onFormEvent diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md index c05f331ad7f1fa1a9db31080bd1cc06ad9767054..68dbb2a9b09191de76d68cb42ac76977ee50f824 100644 --- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -161,7 +161,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | | 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<void> | 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 | Name | Type | Mandatory| Description | | --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | | 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 | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -395,7 +395,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu | Name | Type | Mandatory | Description | | ------- | ------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md index 7523cde56562a53a6129d810dff30ba95a718a64..ff1c5faec320b9c7deb874eee5f8329df524a735 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md +++ b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @@ -160,9 +160,9 @@ bundle.getBundleInstaller().then(installer => { 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 | | ----------- | ------- | ---- | ---- | ------------------ | @@ -174,17 +174,17 @@ Describes the parameters required for bundle installation, recovery, or uninstal 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 | | ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ | -| 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.
**SUCCESS**: install_succeed
**STATUS_INSTALL_FAILURE**: Installation failed (no installation file exists).
**STATUS_INSTALL_FAILURE_ABORTED**: Installation aborted.
**STATUS_INSTALL_FAILURE_INVALID**: Invalid installation parameter.
**STATUS_INSTALL_FAILURE_CONFLICT**: Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.)
**STATUS_INSTALL_FAILURE_STORAGE**: Failed to store the bundle information.
**STATUS_INSTALL_FAILURE_INCOMPATIBLE**: Installation incompatibility. (A downgrade occurs or the signature information is incorrect.)
**STATUS_UNINSTALL_FAILURE**: Uninstallation failed. (The application to be uninstalled is not found.)
**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation aborted. (This error code is not in use.)
**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation conflict. (Failed to uninstall a system application or end the application process.)
**STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT**: Installation failed. (Download timed out.)
**STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED**: Installation failed. (Download failed.)
**STATUS_RECOVER_FAILURE_INVALID**: Failed to restore the pre-installed application.
**STATUS_ABILITY_NOT_FOUND**: Ability not found.
**STATUS_BMS_SERVICE_ERROR**: BMS service error.
**STATUS_FAILED_NO_SPACE_LEFT**: Insufficient device space.
**STATUS_GRANT_REQUEST_PERMISSIONS_FAILED**: Application authorization failed.
**STATUS_INSTALL_PERMISSION_DENIED**: No installation permission.
**STATUS_UNINSTALL_PERMISSION_DENIED**: No uninstallation permission. | ## 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** ``` ts diff --git a/en/application-dev/reference/apis/js-apis-cert.md b/en/application-dev/reference/apis/js-apis-cert.md index fa3aa58c0907c2eb941f4b7485c59e659c99e692..9b4aac5ba2690b202ed83cf6386fff3394017ca3 100644 --- a/en/application-dev/reference/apis/js-apis-cert.md +++ b/en/application-dev/reference/apis/js-apis-cert.md @@ -2142,7 +2142,7 @@ Provides APIs for certificate chain validator operations. validate(certChain : CertChainData, callback : AsyncCallback\) : void 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 @@ -2197,7 +2197,7 @@ validator.validate(certChainData, function (error, data) { validate(certChain : CertChainData) : Promise\ 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 diff --git a/en/application-dev/reference/apis/js-apis-cryptoFramework.md b/en/application-dev/reference/apis/js-apis-cryptoFramework.md index 6060ed463fda76643a1c3d04aedefe765ab80a3f..afb1bd3f8d80a74415c359af492492286364008c 100644 --- a/en/application-dev/reference/apis/js-apis-cryptoFramework.md +++ b/en/application-dev/reference/apis/js-apis-cryptoFramework.md @@ -1632,7 +1632,7 @@ For details about the supported specifications, see [Encryption and Decryption S | 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.
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.
For details, see **Algorithm String** in [Encryption and Decryption Specifications](../../security/cryptoFramework-overview.md#encryption-and-decryption-specifications). | > **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.
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 Updates the data to be signed. This API uses an asynchronous callback to return the result. > **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 @@ -2200,7 +2200,7 @@ update(data : DataBlob) : Promise\; Updates the data to be signed. This API uses a promise to return the result. > **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 @@ -2467,7 +2467,7 @@ update(data : DataBlob, callback : AsyncCallback\) : void Updates the data for signature verification. This API uses an asynchronous callback to return the result. > **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 @@ -2493,7 +2493,7 @@ update(data : DataBlob) : Promise\; Updates the data for signature verification. This API uses a promise to return the result. > **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 diff --git a/en/application-dev/reference/apis/js-apis-distributedKVStore.md b/en/application-dev/reference/apis/js-apis-distributedKVStore.md index 11b7053bbd4ed6e0ebcf6c65fc9d7576d8a080f5..eeb86b5c6411b05acd86dff265cafbbc8cf362db 100644 --- a/en/application-dev/reference/apis/js-apis-distributedKVStore.md +++ b/en/application-dev/reference/apis/js-apis-distributedKVStore.md @@ -28,7 +28,7 @@ Provides the **KVManager** instance configuration, including the bundle name of | Name | Type | Mandatory| Description | | ---------- | --------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes |Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes |Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| | bundleName | string | Yes | Bundle name. | ## Constants @@ -272,7 +272,6 @@ Stage model: ```js import UIAbility from '@ohos.app.ability.UIAbility' - let kvManager; export default class EntryAbility extends UIAbility { onCreate() { @@ -358,7 +357,7 @@ try { console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log("Obtained the KVStore successfully."); + console.log("Succeeded in getting KVStore"); kvStore = store; }); } catch (e) { @@ -411,7 +410,7 @@ try { securityLevel: distributedKVStore.SecurityLevel.S2, }; kvManager.getKVStore('storeId', options).then((store) => { - console.log("Obtained the KVStore successfully."); + console.log("Succeeded in getting KVStore"); kvStore = store; }).catch((err) => { console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); @@ -453,14 +452,14 @@ const options = { } try { kvManager.getKVStore('storeId', options, async function (err, store) { - console.log('Obtained the KVStore successfully.'); + console.log('Succeeded in getting KVStore'); kvStore = store; kvManager.closeKVStore('appId', 'storeId', function (err, data) { if (err != undefined) { console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log('Closed the KVStore successfully.'); + console.log('Succeeded in closing KVStore'); }); }); } catch (e) { @@ -505,10 +504,10 @@ const options = { } try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('Obtained the KVStore successfully.'); + console.log('Succeeded in getting KVStore'); kvStore = store; kvManager.closeKVStore('appId', 'storeId').then(() => { - console.log('Closed the KVStore successfully.'); + console.log('Succeeded in closing KVStore'); }).catch((err) => { console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`); }); @@ -564,14 +563,14 @@ try { console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the KVStore successfully.'); + console.log('Succeeded in getting KVStore'); kvStore = store; kvManager.deleteKVStore('appId', 'storeId', function (err, data) { if (err != undefined) { console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log(`Deleted the KVStore successfully.`); + console.log(`Succeeded in deleting KVStore`); }); }); } catch (e) { @@ -624,10 +623,10 @@ const options = { } try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('Obtained the KVStore successfully.'); + console.log('Succeeded in getting KVStore'); kvStore = store; kvManager.deleteKVStore('appId', 'storeId').then(() => { - console.log('Deleted the KVStore successfully.'); + console.log('Succeeded in deleting KVStore'); }).catch((err) => { console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`); }); @@ -664,7 +663,7 @@ try { console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained all KV store IDs successfully.'); + console.log('Succeeded in getting AllKVStoreId'); console.log(`GetAllKVStoreId size = ${data.length}`); }); } catch (e) { @@ -699,7 +698,7 @@ let kvManager; try { console.log('GetAllKVStoreId'); 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}`); }).catch((err) => { console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`); @@ -829,7 +828,7 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Obtained the result set successfully.'); + console.log('getResultSet succeeded.'); resultSet = result; }).catch((err) => { console.log('getResultSet failed: ' + err); @@ -1000,7 +999,7 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Obtained the result set successfully.'); + console.log('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); @@ -1039,7 +1038,7 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Obtained the result set successfully.'); + console.log('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); @@ -1242,7 +1241,7 @@ Resets the **Query** object. | Type | Description | | -------------- | --------------------- | -| [Query](query) | **Query** object reset.| +| [Query](#query) | **Query** object reset.| **Example** @@ -1278,7 +1277,7 @@ Creates a **Query** object to match the specified field whose value is equal to | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1312,7 +1311,7 @@ Creates a **Query** object to match the specified field whose value is not equal | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1345,7 +1344,7 @@ Creates a **Query** object to match the specified field whose value is greater t | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1380,7 +1379,7 @@ Creates a **Query** object to match the specified field whose value is less than | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1415,7 +1414,7 @@ Creates a **Query** object to match the specified field whose value is greater t | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1450,7 +1449,7 @@ Creates a **Query** object to match the specified field whose value is less than | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1483,7 +1482,7 @@ Creates a **Query** object to match the specified field whose value is **null**. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1517,7 +1516,7 @@ Creates a **Query** object to match the specified field whose value is within th | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1551,7 +1550,7 @@ Creates a **Query** object to match the specified field whose value is within th | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1585,7 +1584,7 @@ Creates a **Query** object to match the specified field whose value is not withi | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1619,7 +1618,7 @@ Creates a **Query** object to match the specified field whose value is not withi | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1653,7 +1652,7 @@ Creates a **Query** object to match the specified field whose value is similar t | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1687,7 +1686,7 @@ Creates a **Query** object to match the specified field whose value is not simil | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1714,7 +1713,7 @@ Creates a **Query** object with the AND condition. | Type | Description | | -------------- | -------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1743,7 +1742,7 @@ Creates a **Query** object with the OR condition. | Type | Description | | -------------- | -------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1778,7 +1777,7 @@ Creates a **Query** object to sort the query results in ascending order. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1812,7 +1811,7 @@ Creates a **Query** object to sort the query results in descending order. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1847,7 +1846,7 @@ Creates a **Query** object to specify the number of results and where to start. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1883,7 +1882,7 @@ Creates a **Query** object to match the specified field whose value is not **nul | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1910,7 +1909,7 @@ Creates a **Query** object for a query condition group with a left parenthesis. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1939,7 +1938,7 @@ Creates a **Query** object for a query condition group with a right parenthesis. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -1974,7 +1973,7 @@ Creates a **Query** object with a specified key prefix. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -2008,7 +2007,7 @@ Creates a **Query** object with an index preferentially used for query. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -2042,7 +2041,7 @@ Creates a **Query** object with the device ID as the key prefix. | Type | Description | | -------------- | --------------- | -| [Query](query) | **Query** object created.| +| [Query](#query) | **Query** object created.| **Example** @@ -2125,7 +2124,7 @@ try { console.error(`Fail to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Put data successfully."); + console.log("Succeeded in putting"); }); } catch (e) { 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'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { 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) => { console.error(`Fail to put.code is ${err.code},message is ${err.message}`); }); @@ -2226,12 +2225,12 @@ try { console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { 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[0]: ${entries[0]}`); }); @@ -2289,9 +2288,9 @@ try { } console.log(`entries: ${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) => { - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); console.log(`PutBatch ${entries}`); }).catch((err) => { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); @@ -2349,7 +2348,7 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }) } catch (e) { console.error(`Fail to put batch.code is ${e.code},message is ${e.message}`); @@ -2402,7 +2401,7 @@ try { v8Arr.push(vb2); v8Arr.push(vb3); kvStore.putBatch(v8Arr).then(async (data) => { - console.log(`Batch put data successfully.`); + console.log(`Succeeded in putting patch`); }).catch((err) => { console.error(`putBatch fail.code is ${err.code},message is ${err.message}`); }); @@ -2447,13 +2446,13 @@ try { console.error(`Fail to put.code is ${err.code},message is ${err.message}`); return; } - console.log('Put data successfully.'); + console.log('Succeeded in putting'); kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); return; } - console.log('Deleted data successfully.'); + console.log('Succeeded in deleting'); }); }); } catch (e) { @@ -2498,9 +2497,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { 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) => { - console.log('Deleted data successfully.'); + console.log('Succeeded in deleting'); }).catch((err) => { console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); }); @@ -2547,7 +2546,7 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); kvStore.delete(predicates, function (err, data) { if (err == undefined) { - console.log('Deleted data successfully.'); + console.log('Succeeded in deleting'); } else { console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); } @@ -2599,9 +2598,9 @@ try { let arr = ["name"]; predicates.inKeys(arr); kvStore.put("name", "bob").then((data) => { - console.log(`Put data successfully: ${data}`); + console.log(`Succeeded in putting: ${data}`); kvStore.delete(predicates).then((data) => { - console.log('Deleted data successfully.'); + console.log('Succeeded in deleting'); }).catch((err) => { console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); }); @@ -2662,13 +2661,13 @@ try { console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); kvStore.deleteBatch(keys, async function (err, data) { if (err != undefined) { console.error(`Fail to delete Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch deleted data successfully.'); + console.log('Succeeded in deleting Batch'); }); }); } catch (e) { @@ -2726,9 +2725,9 @@ try { } console.log(`entries: ${entries}`); kvStore.putBatch(entries).then(async (data) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); kvStore.deleteBatch(keys).then((err) => { - console.log('Batch deleted data successfully.'); + console.log('Succeeded in deleting Batch'); }).catch((err) => { 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'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { 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'; kvStore.removeDeviceData(deviceid, async function (err, data) { if (err == undefined) { - console.log('Removed device data successfully.'); + console.log('succeeded in removing device data'); } else { 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) { - console.log('Obtained data successfully.'); + console.log('Succeeded in getting data'); }); } }); @@ -2825,18 +2824,18 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; try { 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) => { console.error(`Fail to put data.code is ${err.code},message is ${err.message} `); }); const deviceid = 'no_exist_device_id'; kvStore.removeDeviceData(deviceid).then((err) => { - console.log('Removed device data successfully.'); + console.log('succeeded in removing device data'); }).catch((err) => { console.error(`Fail to remove device data.code is ${err.code},message is ${err.message} `); }); kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('Obtained data successfully.'); + console.log('Succeeded in getting data'); }).catch((err) => { console.error(`Fail to get data.code is ${err.code},message is ${err.message} `); }); @@ -2882,13 +2881,13 @@ try { console.error(`Fail to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Put data successfully."); + console.log("Succeeded in putting"); kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.error(`Fail to get.code is ${err.code},message is ${err.message}`); return; } - console.log(`Obtained data successfully. data=${data}`); + console.log(`Succeeded in getting data.data=${data}`); }); }); } catch (e) { @@ -2934,9 +2933,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { 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) => { - console.log(`Obtained data successfully. data=${data}`); + console.log(`Succeeded in getting data.data=${data}`); }).catch((err) => { console.error(`Fail to get.code is ${err.code},message is ${err.message}`); }); @@ -2995,13 +2994,13 @@ try { console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); console.log(`entries.length: ${entries.length}`); console.log(`entries[0]: ${entries[0]}`); }); @@ -3059,9 +3058,9 @@ try { } console.log(`entries: ${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) => { - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); console.log(`PutBatch ${entries}`); }).catch((err) => { 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 | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | ----------------------------------------------- | -| query | [Query](query) | Yes | Key prefix to match. | +| query | [Query](#query) | Yes | Key prefix to match. | | callback | AsyncCallback<[Entry](#entry)[]> | Yes | Callback invoked to return the KV pairs obtained.| **Error codes** @@ -3118,7 +3117,7 @@ try { } console.log(`entries: {entries}`); kvStore.putBatch(entries, async function (err, data) { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query, function (err, entries) { @@ -3126,7 +3125,7 @@ try { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); console.log(`entries.length: ${entries.length}`); console.log(`entries[0]: ${entries[0]}`); }); @@ -3148,7 +3147,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a | Name| Type | Mandatory| Description | | ------ | -------------- | ---- | -------------- | -| query | [Query](query) | Yes | **Query** object to match.| +| query | [Query](#query) | Yes | **Query** object to match.| **Return value** @@ -3185,18 +3184,18 @@ try { } console.log(`entries: {entries}`); kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query).then((entries) => { - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); }).catch((err) => { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { 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) { console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`); } @@ -3249,20 +3248,20 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); kvStore.getResultSet('batch_test_string_key', async function (err, result) { if (err != undefined) { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { if (err != undefined) { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }) }); }); @@ -3319,18 +3318,18 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); }); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }).catch((err) => { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -3386,7 +3385,7 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query, async function (err, result) { @@ -3394,7 +3393,7 @@ try { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); }); }); } catch (e) { @@ -3414,7 +3413,7 @@ Obtains a **KVStoreResultSet** object that matches the specified **Query** objec | Name| Type | Mandatory| Description | | ------ | -------------- | ---- | -------------- | -| query | [Query](query) | Yes | **Query** object to match.| +| query | [Query](#query) | Yes | **Query** object to match.| **Return value** @@ -3450,14 +3449,14 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query).then((result) => { - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); @@ -3508,14 +3507,14 @@ try { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { if (err != undefined) { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }) }); } catch (e) { @@ -3565,13 +3564,13 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates).then((result) => { - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); }); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }).catch((err) => { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -3603,7 +3602,7 @@ try { let resultSet = null; kvStore.closeResultSet(resultSet, function (err, data) { if (err == undefined) { - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); } else { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); } @@ -3640,7 +3639,7 @@ let kvStore; try { let resultSet = null; kvStore.closeResultSet(resultSet).then(() => { - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }).catch((err) => { 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 | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------------------------- | -| query | [Query](query) | Yes | **Query** object to match. | +| query | [Query](#query) | Yes | **Query** object to match. | | callback | AsyncCallback<number> | Yes | Callback invoked to return the number of results obtained.| **Error codes** @@ -3691,7 +3690,7 @@ try { entries.push(entry); } kvStore.putBatch(entries, async function (err, data) { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query, async function (err, resultSize) { @@ -3699,7 +3698,7 @@ try { console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set size successfully'); + console.log('Succeeded in getting result set size'); }); }); } catch (e) { @@ -3719,7 +3718,7 @@ Obtains the number of results that matches the specified **Query** object. This | Name| Type | Mandatory| Description | | ------ | -------------- | ---- | -------------- | -| query | [Query](query) | Yes | **Query** object to match.| +| query | [Query](#query) | Yes | **Query** object to match.| **Return value** @@ -3754,14 +3753,14 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query).then((resultSize) => { - console.log('Obtained the result set size successfully'); + console.log('Succeeded in getting result set size'); }).catch((err) => { console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); }); @@ -3803,7 +3802,7 @@ try { if (err) { console.error(`Fail to backup.code is ${err.code},message is ${err.message} `); } else { - console.info(`Backed up data successfully. data=${data}`); + console.info(`Succeeded in backupping data.data=${data}`); } }); } catch (e) { @@ -3846,7 +3845,7 @@ let kvStore; let file = "BK001"; try { kvStore.backup(file).then((data) => { - console.info(`Backed up data successfully. data=${data}`); + console.info(`Succeeded in backupping data.data=${data}`); }).catch((err) => { console.error(`Fail to backup.code is ${err.code},message is ${err.message}`); }); @@ -3888,7 +3887,7 @@ try { if (err) { console.error(`Fail to restore.code is ${err.code},message is ${err.message}`); } else { - console.info(`Restored data successfully. data=${data}`); + console.info(`Succeeded in restoring data.data=${data}`); } }); } catch (e) { @@ -3931,7 +3930,7 @@ let kvStore; let file = "BK001"; try { kvStore.restore(file).then((data) => { - console.info(`Restored data successfully. data=${data}`); + console.info(`Succeeded in restoring data.data=${data}`); }).catch((err) => { console.error(`Fail to restore.code is ${err.code},message is ${err.message}`); }); @@ -3965,7 +3964,7 @@ try { if (err) { console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`); } else { - console.info(`Deleted the backup file successfully. data=${data}`); + console.info(`Succeed in deleting Backup.data=${data}`); } }); } catch (e) { @@ -4000,7 +3999,7 @@ let kvStore; let files = ["BK001", "BK002"]; try { kvStore.deleteBackup(files).then((data) => { - console.info(`Deleted the backup file successfully. data=${data}`); + console.info(`Succeed in deleting Backup.data=${data}`); }).catch((err) => { console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`); }) @@ -4061,7 +4060,7 @@ try { console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`); return; } - console.log('Started the transaction successfully.'); + console.log('Succeeded in starting Transaction'); let entries = putBatchString(10, 'batch_test_string_key'); console.log(`entries: ${entries}`); kvStore.putBatch(entries, async function (err, data) { @@ -4069,7 +4068,7 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); }); }); } catch (e) { @@ -4110,7 +4109,7 @@ try { count++; }); kvStore.startTransaction().then(async (err) => { - console.log('Started the transaction successfully.'); + console.log('Succeeded in starting Transaction'); }).catch((err) => { console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`); }); @@ -4148,7 +4147,7 @@ let kvStore; try { kvStore.commit(function (err, data) { if (err == undefined) { - console.log('Committed the transaction successfully.'); + console.log('Succeeded in committing'); } else { 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 let kvStore; try { kvStore.commit().then(async (err) => { - console.log('Committed the transaction successfully.'); + console.log('Succeeded in committing'); }).catch((err) => { console.error(`Fail to commit.code is ${err.code},message is ${err.message}`); }); @@ -4224,7 +4223,7 @@ let kvStore; try { kvStore.rollback(function (err,data) { if (err == undefined) { - console.log('Rolled back the transaction successfully'); + console.log('Succeeded in rolling back'); } else { 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 let kvStore; try { kvStore.rollback().then(async (err) => { - console.log('Rolled back the transaction successfully'); + console.log('Succeeded in rolling back'); }).catch((err) => { console.error(`Fail to rollback.code is ${err.code},message is ${err.message}`); }); @@ -4293,7 +4292,7 @@ let kvStore; try { kvStore.enableSync(true, function (err, data) { if (err == undefined) { - console.log('Enabled sync successfully.'); + console.log('Succeeded in enabling sync'); } else { 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 let kvStore; try { kvStore.enableSync(true).then((err) => { - console.log('Enabled sync successfully.'); + console.log('Succeeded in enabling sync'); }).catch((err) => { console.error(`Fail to enable sync.code is ${err.code},message is ${err.message}`); }); @@ -4366,7 +4365,7 @@ try { console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`); return; } - console.log('Set syncRange successfully.'); + console.log('Succeeded in setting syncRange'); }); } catch (e) { console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`); @@ -4402,7 +4401,7 @@ try { const localLabels = ['A', 'B']; const remoteSupportLabels = ['C', 'D']; kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { - console.log('Set syncRange successfully.'); + console.log('Succeeded in setting syncRange'); }).catch((err) => { console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`); }); @@ -4437,7 +4436,7 @@ try { console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`); return; } - console.log('Set syncParam successfully'); + console.log('Succeeded in setting syncParam'); }); } catch (e) { console.error(`An unexpected error occured.code is ${e.code},message is ${e.message}`); @@ -4471,7 +4470,7 @@ let kvStore; try { const defaultAllowedDelayMs = 500; kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { - console.log('Set syncParam successfully'); + console.log('Succeeded in setting syncParam'); }).catch((err) => { console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`); }); @@ -4522,7 +4521,7 @@ try { console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); return; } - console.log('Put data successfully.'); + console.log('Succeeded in putting data'); const devices = ['deviceList']; const mode = distributedKVStore.SyncMode.PULL_ONLY; kvStore.sync(devices, mode, 1000); @@ -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.| | 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. | **Error codes** @@ -4575,7 +4574,7 @@ try { console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); return; } - console.log('Put data successfully.'); + console.log('Succeeded in putting data'); const devices = ['deviceList']; const mode = distributedKVStore.SyncMode.PULL_ONLY; const query = new distributedKVStore.Query(); @@ -4652,7 +4651,7 @@ try { console.log(`syncComplete ${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) => { console.error(`Fail to put.code is ${err.code},message is ${err.message}`); }); @@ -4793,7 +4792,7 @@ try { console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained securityLevel successfully'); + console.log('Succeeded in getting securityLevel'); }); } catch (e) { 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 let kvStore; try { kvStore.getSecurityLevel().then((data) => { - console.log('Obtained securityLevel successfully'); + console.log('Succeeded in getting securityLevel'); }).catch((err) => { console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`); }); @@ -4884,13 +4883,13 @@ try { console.error(`Fail to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Put data successfully."); + console.log("Succeeded in putting"); kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.error(`Fail to get.code is ${err.code},message is ${err.message}`); return; } - console.log(`Obtained data successfully. data=${data}`); + console.log(`Succeeded in getting data.data=${data}`); }); }); } catch (e) { @@ -4936,9 +4935,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { 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) => { - console.log(`Obtained data successfully. data=${data}`); + console.log(`Succeeded in getting data.data=${data}`); }).catch((err) => { console.error(`Fail to get.code is ${err.code},message is ${err.message}`); }); @@ -4988,13 +4987,13 @@ try { console.error(`Fail to put.code is ${err.code},message is ${err.message}`); return; } - console.log('Put data successfully.'); + console.log('Succeeded in putting'); kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.error(`Fail to get.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained data successfully'); + console.log('Succeeded in getting'); }); }) } catch (e) { @@ -5041,9 +5040,9 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { 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) => { - console.log('Obtained data successfully'); + console.log('Succeeded in getting'); }).catch((err) => { console.error(`Fail to get.code is ${err.code},message is ${err.message}`); }); @@ -5102,13 +5101,13 @@ try { console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); console.log(`entries.length: ${entries.length}`); console.log(`entries[0]: ${entries[0]}`); }); @@ -5166,9 +5165,9 @@ try { } console.log(`entries: ${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) => { - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); console.log(`PutBatch ${entries}`); }).catch((err) => { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); @@ -5229,13 +5228,13 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err, entries) { if (err != undefined) { console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting entries'); console.log(`entries.length: ${entries.length}`); console.log(`entries[0]: ${entries[0]}`); }); @@ -5294,9 +5293,9 @@ try { } console.log(`entries: ${entries}`); 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) => { - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting entries'); console.log(`entries.length: ${entries.length}`); console.log(`entries[0]: ${entries[0]}`); 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. | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | ----------------------------------------------------- | -| query | [Query](query) | Yes | Key prefix to match. | +| query | [Query](#query) | Yes | Key prefix to match. | | callback | AsyncCallback<[Entry](#entry)[]> | Yes | Callback invoked to return the KV pairs obtained.| **Error codes** @@ -5356,7 +5355,7 @@ try { } console.log(`entries: {entries}`); kvStore.putBatch(entries, async function (err, data) { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query, function (err, entries) { @@ -5364,7 +5363,7 @@ try { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); console.log(`entries.length: ${entries.length}`); console.log(`entries[0]: ${entries[0]}`); }); @@ -5386,7 +5385,7 @@ Obtains all KV pairs that match the specified **Query** object for this device. | Name| Type | Mandatory| Description | | ------ | -------------- | ---- | -------------- | -| query | [Query](query) | Yes | **Query** object to match.| +| query | [Query](#query) | Yes | **Query** object to match.| **Return value** @@ -5423,18 +5422,18 @@ try { } console.log(`entries: {entries}`); kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query).then((entries) => { - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting Entries'); }).catch((err) => { console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { 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) { 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 | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | ------------------------------------------------------- | | 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<[Entry](#entry)[]> | Yes | Callback invoked to return the KV pairs obtained.| **Error codes** @@ -5489,7 +5488,7 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); var query = new distributedKVStore.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); @@ -5498,12 +5497,12 @@ try { console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting entries'); console.log(`entries.length: ${entries.length}`); console.log(`entries[0]: ${entries[0]}`); }) }); - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting entries'); } catch (e) { 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 | Name | Type | Mandatory| Description | | -------- | -------------- | ---- | -------------------- | | 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** @@ -5559,19 +5558,19 @@ try { } console.log(`entries: ${entries}`); kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); var query = new distributedKVStore.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); kvStore.getEntries('localDeviceId', query).then((entries) => { - console.log('Obtained the entries successfully.'); + console.log('Succeeded in getting entries'); }).catch((err) => { console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { 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) { console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`); } @@ -5624,20 +5623,20 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); kvStore.getResultSet('batch_test_string_key', async function (err, result) { if (err != undefined) { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { if (err != undefined) { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }) }); }); @@ -5694,18 +5693,18 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); }); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }).catch((err) => { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -5750,14 +5749,14 @@ try { console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully.'); + console.log('Succeeded in getting resultSet'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { if (err != undefined) { console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Closed the result set successfully.'); + console.log('Succeeded in closing resultSet'); }) }); } catch (e) { @@ -5802,13 +5801,13 @@ let kvStore; try { let resultSet; kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { - console.log('Obtained the result set successfully.'); + console.log('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); }); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully.'); + console.log('Succeeded in closing resultSet'); }).catch((err) => { 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 * | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | 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<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KVStoreResultSet** object obtained.| **Error codes** @@ -5865,7 +5864,7 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query, async function (err, result) { @@ -5873,14 +5872,14 @@ try { console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully.'); + console.log('Succeeded in getting resultSet'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { if (err != undefined) { console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); 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 * | Name | Type | Mandatory| Description | | -------- | -------------- | ---- | ---------------------------------- | | 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** @@ -5938,14 +5937,14 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('Obtained the result set successfully.'); + console.log('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); @@ -5953,7 +5952,7 @@ try { query.deviceId('localDeviceId'); console.log("GetResultSet " + query.getSqlLike()); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully.'); + console.log('Succeeded in closing resultSet'); }).catch((err) => { 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 | Name| Type | Mandatory| Description | | ------ | -------------- | ---- | -------------- | -| query | [Query](query) | Yes | **Query** object to match.| +| query | [Query](#query) | Yes | **Query** object to match.| **Return value** @@ -6011,14 +6010,14 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query).then((result) => { - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; }).catch((err) => { 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 * | Name | Type | Mandatory| Description | | -------- | -------------- | ---- | ---------------------------------- | | 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** @@ -6077,14 +6076,14 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('Obtained the result set successfully.'); + console.log('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); @@ -6092,7 +6091,7 @@ try { query.deviceId('localDeviceId'); console.log("GetResultSet " + query.getSqlLike()); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully.'); + console.log('Succeeded in closing resultSet'); }).catch((err) => { console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); }); @@ -6143,14 +6142,14 @@ try { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { if (err != undefined) { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }) }); } catch (e) { @@ -6200,13 +6199,13 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates).then((result) => { - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); }); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }).catch((err) => { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -6257,14 +6256,14 @@ try { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { if (err != undefined) { console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }) }); } catch (e) { @@ -6314,13 +6313,13 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet('localDeviceId', predicates).then((result) => { - console.log('Obtained the result set successfully'); + console.log('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); }); kvStore.closeResultSet(resultSet).then((err) => { - console.log('Closed the result set successfully'); + console.log('Succeeded in closing result set'); }).catch((err) => { 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 | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------------------------------- | -| query | [Query](query) | Yes | **Query** object to match. | +| query | [Query](#query) | Yes | **Query** object to match. | | callback | AsyncCallback<number> | Yes | Callback invoked to return the number of results that match the specified **Query** object.| **Error codes** @@ -6371,7 +6370,7 @@ try { entries.push(entry); } kvStore.putBatch(entries, async function (err, data) { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query, async function (err, resultSize) { @@ -6379,7 +6378,7 @@ try { console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); return; } - console.log('Obtained the result set size successfully'); + console.log('Succeeded in getting result set size'); }); }); } catch (e) { @@ -6399,7 +6398,7 @@ Obtains the number of results that match the specified **Query** object for this | Name| Type | Mandatory| Description | | ------ | -------------- | ---- | -------------- | -| query | [Query](query) | Yes | **Query** object to match.| +| query | [Query](#query) | Yes | **Query** object to match.| **Return value** @@ -6434,14 +6433,14 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query).then((resultSize) => { - console.log('Obtained the result set size successfully'); + console.log('Succeeded in getting result set size'); }).catch((err) => { 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** | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | --------------------------------------------------- | | 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<number> | Yes | Callback invoked to return the number of results obtained.| **Error codes** @@ -6497,7 +6496,7 @@ try { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { @@ -6505,7 +6504,7 @@ try { console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`); 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** | Name | Type | Mandatory| Description | | -------- | -------------- | ---- | ---------------------------------- | | 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** @@ -6562,14 +6561,14 @@ try { entries.push(entry); } kvStore.putBatch(entries).then(async (err) => { - console.log('Batch put data successfully.'); + console.log('Succeeded in putting batch'); }).catch((err) => { console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); }); var query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize('localDeviceId', query).then((resultSize) => { - console.log('Obtained resultSize successfully'); + console.log('Succeeded in getting resultSize'); ; }).catch((err) => { console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`); diff --git a/en/application-dev/reference/apis/js-apis-file-picker.md b/en/application-dev/reference/apis/js-apis-file-picker.md new file mode 100644 index 0000000000000000000000000000000000000000..44e38fa5f4ef0b9b6af861ceb2ceeb1a8d126906 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-file-picker.md @@ -0,0 +1,771 @@ +# @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<PhotoSelectResult> + +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<[PhotoSelectResult](#photoselectresult)> | 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<PhotoSelectResult>) : 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<[PhotoSelectResult](#photoselectresult)> | 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<PhotoSelectResult>) : 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<[PhotoSelectResult](#photoselectresult)> | 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<Array<string>> + +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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>> + +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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>> + +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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>> + +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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>> + +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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<Array<string>>) : 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<Array<string>> | 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<string> | 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<string> | 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<string> | 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<string> | No | File names of the audio clips to save.| diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md index 9ff197787fb1ce1eaaab9f26f993edef2f364ea3..3479e06ffebf2cc53b2a9d40248bc632e9f01a82 100644 --- a/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @@ -234,7 +234,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba | Name | Type | Mandatory | Description | | --------- | ---------------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | | 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<void> | 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 | Name | Type | Mandatory | Description | | --------- | ---------------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | | 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 | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** @@ -445,7 +445,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu | Name | Type | Mandatory | Description | | ------- | ------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md b/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md index 3db5bc33dc4e62a5562fc9a3de4b01c6476c586e..3bc7d33f43bb947212cc25a94f69f02f56e430ec 100644 --- a/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @@ -346,6 +346,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | +| 9700004 | Check workInfo failed. | **Example** @@ -391,6 +392,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes | 9700001 | Memory operation failed. | | 9700002 | Parcel operation failed. | | 9700003 | System service operation failed. | +| 9700004 | Check workInfo failed. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-system-app.md b/en/application-dev/reference/apis/js-apis-system-app.md index b48e4a8f6233b11ffdef0361280dba6322c9f959..2088e0ebed7ad7a21bbeccd79b210cdd537cde15 100644 --- a/en/application-dev/reference/apis/js-apis-system-app.md +++ b/en/application-dev/reference/apis/js-apis-system-app.md @@ -1,6 +1,7 @@ # @system.app (Application Context) > **NOTE** +> > - 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. @@ -9,8 +10,8 @@ ## Modules to Import -```ts -import app from '@system.app' +``` +import app from '@system.app'; ``` @@ -20,8 +21,8 @@ getInfo(): AppResponse Obtains the declared information in the **config.json** file of an application. -> **NOTE** -> +> **NOTE** +> > You are advised to use [@ohos.bundle](js-apis-Bundle.md) since API version 7. **System capability**: SystemCapability.ArkUI.ArkUI.Lite @@ -34,13 +35,13 @@ Obtains the declared information in the **config.json** file of an application. **Example** - ```ts -export default { - getInfo() { - let info = app.getInfo() - console.log(JSON.stringify(info)) + ``` + export default { + getInfo(){ + var info = app.getInfo(); + console.log(JSON.stringify(info)); + } } -} ``` ## app.terminate @@ -49,20 +50,19 @@ terminate(): void Terminates the current ability. -> **NOTE** -> +> **NOTE** +> > You are advised to use [@ohos.ability.featureAbility](js-apis-ability-featureAbility.md) since API version 7. **System capability**: SystemCapability.ArkUI.ArkUI.Lite **Example** - ```ts -export default { - terminate() { - app.terminate() - } -} + ``` + export default { + terminate(){ + app.terminate(); + }} ``` ## app.requestFullWindow @@ -70,29 +70,27 @@ 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. -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. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | 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.| **Example** - ```ts -export default { - requestFullWindow() { - app.requestFullWindow({ - duration: 200 - }) + ``` + export default { + requestFullWindow(){ + app.requestFullWindow({ + duration: 200}); + } } -} ``` ## app.setImageCacheCount7+ @@ -104,25 +102,26 @@ Sets the maximum number of decoded images that can be cached in the memory to sp **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | 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** - ```ts -// app.ets -import app from '@system.app' - -export default { - onCreate() { - app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, -} + ``` + // app.ets + import app from '@system.app'; + + export default { + onCreate() { + app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + } ``` ## app.setImageRawDataCacheSize7+ @@ -134,26 +133,27 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | 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** - ```ts -// app.ets -import app from '@system.app' - -export default { - onCreate() { - 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). - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, -} + ``` + // app.ets + import app from '@system.app'; + + export default { + onCreate() { + 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). + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + } ``` ## app.setImageFileCacheSize7+ @@ -165,26 +165,27 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | 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** - ```ts -// app.ets -import app from '@system.app' - -export default { - onCreate() { - 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). - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, -} + ``` + // app.ets + import app from '@system.app'; + + export default { + onCreate() { + 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). + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + } ``` ## AppResponse @@ -200,6 +201,22 @@ Defines the application response information. | versionName | string | Yes| Application version name.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite| | versionCode | number | Yes| Application version number.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite| +## ScreenOnVisible(deprecated) + +screenOnVisible(options?: ScreenOnVisibleOptions): 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 Defines the options of the visible interface on the screen. diff --git a/en/application-dev/reference/apis/js-apis-system-bluetooth.md b/en/application-dev/reference/apis/js-apis-system-bluetooth.md index c65aef6079cb393917d7f8a44ef9d62de5e49478..ff04cbb9845aa63f7a5bb7ac12104e485e5991e9 100644 --- a/en/application-dev/reference/apis/js-apis-system-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-system-bluetooth.md @@ -1,7 +1,7 @@ # @system.bluetooth (Bluetooth) -> **NOTE**
+> **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). > @@ -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. -**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION - **System capability**: SystemCapability.Communication.Bluetooth.Lite **Parameters** + **Table 1** StartBLEScanOptions | Name| Type| Mandatory| Description| @@ -42,7 +41,7 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys console.log('call bluetooth.startBLEScan success.'); }, fail(code, data) { - console.log('call bluetooth.startBLEScan failed, code: ${code}, data: ${data}.'); + console.log('call bluetooth.startBLEScan failed, code:' + code + ', data:' + data); }, complete() { console.log('call bluetooth.startBLEScan complete.'); @@ -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. -**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION - **System capability**: SystemCapability.Communication.Bluetooth.Lite **Parameters** + **Table 2** StopBLEScanOptions | Name| Type| Mandatory| Description| @@ -76,7 +74,7 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE console.log('call bluetooth.stopBLEScan success.'); }, fail(data, code) { - console.log('call bluethooth.stopBLEScan fail, code: ${code}, data: ${data}.'); + console.log('call bluethooth.stopBLEScan fail, code:' + code + ', data:' + data); }, complete() { console.log('call bluethooth.stopBLEScan complete.'); @@ -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. -**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION - **System capability**: SystemCapability.Communication.Bluetooth.Lite **Parameters** @@ -122,10 +118,10 @@ Subscribes to the newly detected BLE device. If this API is called multiple time ``` bluetooth.subscribeBLEFound({ success(data) { - console.log('Called bluetooth.subscribeBLEFound successsully, data: ${data}.'); + console.log('call bluetooth.subscribeBLEFound success, data: ${data}.'); }, 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 Unsubscribes from the newly detected devices. -**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION - **System capability**: SystemCapability.Communication.Bluetooth.Lite **Example** diff --git a/en/application-dev/reference/apis/js-apis-system-cipher.md b/en/application-dev/reference/apis/js-apis-system-cipher.md index dddb6a685f00a8a5a1829e489d43af4a198bdffa..b99f72e1fb59bd6af33a0bd5f7cc090fc6fc1222 100644 --- a/en/application-dev/reference/apis/js-apis-system-cipher.md +++ b/en/application-dev/reference/apis/js-apis-system-cipher.md @@ -1,9 +1,9 @@ -# @system.cipher (Cipher Algorithm) +# @system.cipher (Cipher Algorithm) > **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 @@ -18,9 +18,10 @@ Defines the response to the cipher interface called. **System capability**: SystemCapability.Security.Cipher -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------ | -| text | string | Yes | Response content.| +| Name| Type | Readable| Writable|Description | +| ------ | ------ | ---- | ---- | ------------ | +| text | string | Yes | No | Response content.| + ## CipherRsaOptions @@ -74,39 +75,39 @@ Encrypts or decrypts data using RSA. **Example** ```js -export default { - rsa() { - cipher.rsa({ - // Encrypt data. - action: 'encrypt', - // Text to be encrypted. - text: 'hello', - // Base64-encoded public key used for encryption. - key: - 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx414QSP3RsYWYzf9mkBMiBAXo\n' + - '6S7Lpva1fKlcuVxjoFC1iMnzD4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ\n' + +export default { + rsa() { + cipher.rsa({ + // Encrypt data. + action: 'encrypt', + // Text to be encrypted. + text: 'hello', + // Base64-encoded public key used for encryption. + key: + 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx414QSP3RsYWYzf9mkBMiBAXo\n' + + '6S7Lpva1fKlcuVxjoFC1iMnzD4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ\n' + '+Enz0RzmVFh/4yk6lmqRzuEFQqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBw\n' + - 'jBpApTJ3TeneOo6Z5QIDAQAB', - success: function(data) { - console.log(`Handling successful:${data.text}`); - }, - fail: function(data, code) { - console.log(`### cipher.rsa encryption failed ### ${code}:${data}`); + 'jBpApTJ3TeneOo6Z5QIDAQAB', + success: function(data) { + console.log(`handling success:${data.text}`); + }, + fail: function(data, code) { + console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`); }, complete: function() { console.log(`operation complete!`); } - }); - cipher.rsa({ - // Decrypt data. - action: 'decrypt', - // Text to be decrypted, which is binary text encoded in Base64. The decrypted text is "hello". - text: + }); + cipher.rsa({ + // Decrypt data. + action: 'decrypt', + // Text to be decrypted, which is binary text encoded in Base64. The decrypted text is "hello". + text: 'EPeCFPib6ayKbA0M6oSywARvFZ8dFYfjQv3nY8ikZGtS9UHq2sLPvAfpeIzggSiCxqbWeCftP1XQ\n' + 'Sa+jEpzFlT1qoSTunBbrYzugPTajIJDTg6R1IRsF/J+mmakn0POVPvi4jCo9wqavB324Bx0Wipnc\n' + - 'EU5WO0oBHo5l4x6dTpU=', - // Base64-encoded private key used for decryption. - key: + 'EU5WO0oBHo5l4x6dTpU=', + // Base64-encoded private key used for decryption. + key: 'MIICXgIBAAKBgQCx414QSP3RsYWYzf9mkBMiBAXo6S7Lpva1fKlcuVxjoFC1iMnz\n' + 'D4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ+Enz0RzmVFh/4yk6lmqRzuEF\n' + 'QqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBwjBpApTJ3TeneOo6Z5QIDAQAB\n' + @@ -118,18 +119,18 @@ export default { 'PKoljdXmJeS6rGgzGibstuHLrP3tcIho4+0CQD3ZFWzF/xq0jxKlrpWhnJuNCRfE\n' + 'oO6e9yNvVA8J/5oEDSOcmqSNIp4+RhbUx8InUxnCG6Ryv5aSFu71pYcKrPkCQQCL\n' + 'RUGcm3ZGTnslduB0knNF+V2ndwzDUQ7P74UXT+PjurTPhujFYiuxCEd6ORVnEOzG\n' + - 'M9TORIgdH8MjIbWsGnndAkEAw9yURDaorE8IYPLF2IEn09g1uzvWPs3phDb6smVx\n' + + 'M9TORIgdH8MjIbWsGnndAkEAw9yURDaorE8IYPLF2IEn09g1uzvWPs3phDb6smVx\n' + '8GfqIdUNf+aCG5TZK/kXBF1sqcsi7jXMAf4jBlejVbSVZg==', - success: function(data) { - console.log(`Handling successful:${data.text}`); - }, - fail: function(data, code) { - console.log(`### cipher.rsa encryption failed ### ${code}:${data}`); + success: function(data) { + console.log(`handling success:${data.text}`); + }, + fail: function(data, code) { + console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`); }, complete: function() { console.log(`operation complete!`); - } - }); + } + }); } } ``` @@ -152,48 +153,48 @@ Encrypts or decrypts data using AES. **Example** ```js -export default { - aes() { - cipher.aes({ - // Encrypt data. - action: 'encrypt', - // Text to be encrypted. - text: 'hello', +export default { + aes() { + cipher.aes({ + // Encrypt data. + action: 'encrypt', + // Text to be encrypted. + text: 'hello', // Base64-encoded key. - key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=', - transformation: 'AES/CBC/PKCS5Padding', - ivOffset: '0', - ivLen: '16', - success: function(data) { - console.log(`Handling successful:${data.text}`); - }, - fail: function(data, code) { - console.log(`### cipher.rsa encryption failed ### ${code}:${data}`); + key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=', + transformation: 'AES/CBC/PKCS5Padding', + ivOffset: '0', + ivLen: '16', + success: function(data) { + console.log(`handling success:${data.text}`); + }, + fail: function(data, code) { + console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`); }, complete: function() { console.log(`operation complete!`); } - }); - cipher.aes({ - // Decrypt data. - action: 'decrypt', - // Text to be decrypted, which is binary text encoded in Base64. - text: '1o0kf2HXwLxHkSh5W5NhzA==', + }); + cipher.aes({ + // Decrypt data. + action: 'decrypt', + // Text to be decrypted, which is binary text encoded in Base64. + text: '1o0kf2HXwLxHkSh5W5NhzA==', // Base64-encoded key. - key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=', - transformation: 'AES/CBC/PKCS5Padding', - ivOffset: '0', - ivLen: '16', - success: function(data) { - console.log(`Handling successful:${data.text}`); - }, - fail: function(data, code) { - console.log(`### cipher.aes encryption failed ### ${code}:${data}`); + key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=', + transformation: 'AES/CBC/PKCS5Padding', + ivOffset: '0', + ivLen: '16', + success: function(data) { + console.log(`handling success:${data.text}`); + }, + fail: function(data, code) { + console.log(`### cipher.aes encrypt fail ### ${code}:${data}`); }, complete: function() { console.log(`operation complete!`); } - }); + }); } } diff --git a/en/application-dev/reference/apis/js-apis-system-sensor.md b/en/application-dev/reference/apis/js-apis-system-sensor.md index 30bfc60e3339b8102fbe6f4a6c5fc1202015da11..ccf4be2ce7e5a660ef1622e90bce2c204634906e 100644 --- a/en/application-dev/reference/apis/js-apis-system-sensor.md +++ b/en/application-dev/reference/apis/js-apis-system-sensor.md @@ -8,7 +8,7 @@ The sensors are classified into the following categories based on their function > **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 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. @@ -19,15 +19,9 @@ The sensors are classified into the following categories based on their function import sensor from '@system.sensor'; ``` -## Error Codes - -| Error Code | Description | -| ---- | -------------- | -| 900 | The current device does not support the corresponding sensor.| - ## 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. @@ -37,23 +31,13 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul **Parameters** -| 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 | 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.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | +| options | [subscribeAccelerometerOptions](#subscribeaccelerometeroptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeAccelerometer({ interval: 'normal', success: function(ret) { @@ -82,13 +66,13 @@ Unsubscribes from data changes of the acceleration sensor. **Example** -``` +```js sensor.unsubscribeAccelerometer(); ``` ## 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. @@ -96,20 +80,13 @@ Subscribes to data changes of the compass sensor. If this API is called multiple **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | --------------- | -| success | Function | Yes | Called when the compass sensor data changes.| -| fail | Function | No | Callback upon failure. | - -Return values of the success callback - -| Name | Type | Description | -| --------- | ------ | ---------- | -| direction | number | Direction of the device, in degrees.| +| Name | Type | Mandatory| Description | +| ------- | --------------------------------------------------- | ---- | -------------------------------- | +| options | [SubscribeCompassOptions](#subscribecompassoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeCompass({ success: function(ret) { console.log('get data direction:' + ret.direction); @@ -133,13 +110,13 @@ Unsubscribes from data changes of the compass sensor. **Example** -``` +```js sensor.unsubscribeCompass(); ``` ## 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. @@ -147,20 +124,13 @@ Subscribes to data changes of the proximity sensor. If this API is called multip **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ----------------- | -| success | Function | Yes | Called when the proximity sensor data changes.| -| 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.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------- | ---- | -------------------------------- | +| options | [SubscribeProximityOptions](#subscribeproximityoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeProximity({ success: function(ret) { console.log('get data distance:' + ret.distance); @@ -184,13 +154,13 @@ Unsubscribes from data changes of the proximity sensor. **Example** -``` +```js sensor.unsubscribeProximity(); ``` ## 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. @@ -198,20 +168,13 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | --------------- | -| success | Function | Yes | Called when the ambient light sensor data changes| -| fail | Function | No | Callback upon failure. | - -Return values of the success callback - -| Name | Type | Description | -| --------- | ------ | ------------ | -| intensity | number | Light intensity, in lux.| +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------------------- | ---- | ---------------------------------- | +| options | [SubscribeLightOptions](#subscribelightoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeLight({ success: function(ret) { console.log('get data intensity:' + ret.intensity); @@ -235,13 +198,13 @@ Unsubscribes from data changes of the ambient light sensor. **Example** -``` +```js sensor.unsubscribeLight(); ``` ## 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. @@ -251,20 +214,13 @@ Subscribes to data changes of the step counter sensor. If this API is called mul **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ---------------- | -| success | Function | Yes | Called when the step counter sensor data changes.| -| 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.
| +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------------------------------- | ---- | -------------------------------------- | +| options | [SubscribeStepCounterOptions](#subscribestepcounteroptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeStepCounter({ success: function(ret) { console.log('get step value:' + ret.steps); @@ -290,14 +246,14 @@ Unsubscribes from data changes of the step counter sensor. **Example** -``` +```js sensor.unsubscribeStepCounter(); ``` ## 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. @@ -305,20 +261,13 @@ Subscribes to data changes of the barometer sensor. If this API is called multip **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ---------------- | -| success | Function | Yes | Called when the barometer sensor data changes.| -| fail | Function | No | Callback upon failure. | - -Return values of the success callback - -| Name | Type | Description | -| -------- | ------ | ----------- | -| pressure | number | Pressure, in pascal.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------- | ---- | ---------------------------------- | +| options | [SubscribeBarometerOptions](#subscribebarometeroptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeBarometer({ success: function(ret) { console.log('get data value:' + ret.pressure); @@ -343,14 +292,14 @@ Unsubscribes from data changes of the barometer sensor. **Example** -``` +```js sensor.unsubscribeBarometer(); ``` ## 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. @@ -360,20 +309,13 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ------------------------- | -| success | Function | Yes | Called when the heart rate sensor data changes. This callback is invoked every five seconds.| -| fail | Function | No | Callback upon failure. | - -Return values of the success callback - -| Name | Type | Description | -| --------- | ------ | ---- | -| heartRate | number | Heart rate.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------- | ---- | -------------------------------- | +| options | [SubscribeHeartRateOptions](#subscribeheartrateoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeHeartRate({ success: function(ret) { console.log('get heartrate value:' + ret.heartRate); @@ -400,13 +342,13 @@ Unsubscribes from data changes of the heart rate sensor. **Example** -``` +```js sensor.unsubscribeHeartRate(); ``` ## 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. @@ -414,20 +356,13 @@ Subscribes to changes of the wearing state of a wearable device. If this API is **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ------------- | -| success | Function | Yes | Called when the wearing state changes.| -| fail | Function | No | Callback upon failure. | - -Return values of the success callback - -| Name | Type | Description | -| ----- | ------- | ------ | -| value | boolean | Whether the wearable device is worn.| +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------------------------------- | ---- | ---------------------- | +| options | [SubscribeOnBodyStateOptions](#subscribeonbodystateoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeOnBodyState({ success: function(ret) { console.log('get on-body state value:' + ret.value); @@ -451,13 +386,13 @@ Unsubscribes from changes of the wearing state of a wearable device. **Example** -``` +```js sensor.unsubscribeOnBodyState(); ``` ## sensor.getOnBodyState -getOnBodyState(Object): void + getOnBodyState(options: GetOnBodyStateOptions): void Obtains the wearing state of a wearable device. @@ -465,21 +400,13 @@ Obtains the wearing state of a wearable device. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ------------ | -| success | Function | No | Callback upon success.| -| 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.| +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------------------- | ---- | -------------------------- | +| options | [GetOnBodyStateOptions](#getonbodystateoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.getOnBodyState({ success: function(ret) { console.log('on body state: ' + ret.value); @@ -492,7 +419,7 @@ sensor.getOnBodyState({ ## sensor.subscribeDeviceOrientation6+ -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. @@ -502,22 +429,13 @@ If this API is called multiple times for the same application, the last call tak **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ---------------------------------------- | -| interval | string | Yes | Interval at which the callback is invoked to return the device orientation 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 | 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.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ | +| options | [SubscribeDeviceOrientationOptions](#subscribedeviceorientationoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeDeviceOrientation({ interval: 'normal', success: function(ret) { @@ -544,13 +462,13 @@ Unsubscribes from data changes of the device orientation sensor. **Example** -``` +```js sensor.unsubscribeDeviceOrientation(); ``` ## sensor.subscribeGyroscope6+ -subscribeGyroscope(interval: string, success: (data: GyroscopeResponse), fail?: (data: string, code: number)): void + subscribeGyroscope(options: SubscribeGyroscopeOptions): void 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 **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ---------------------------------------- | -| interval | string | Yes | Interval at which the callback is invoked to return the gyroscope 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 | 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.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------- | ---- | ---------------------------------------------- | +| options | [SubscribeGyroscopeOptions](#subscribegyroscopeoptions) | Yes | Type of data to return.| **Example** -``` +```js sensor.subscribeGyroscope({ interval: 'normal', success: function(ret) { @@ -607,6 +515,253 @@ Unsubscribes from data changes of the gyroscope sensor. **Example** -``` +```js 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.| + +## SubscribeDeviceOrientationOptions6+ + +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.
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 | [DeviceOrientationResponse](#deviceorientationresponse) | Yes | Called when the device orientation sensor data changes. | +| fail | Function | No | Callback upon an API call failure. | + +## DeviceOrientationResponse6+ + +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.| + +## SubscribeGyroscopeOptions6+ + +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.
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 | [GyroscopeResponse](#gyroscoperesponse) | Yes | Called when the gyroscope sensor data changes. | +| fail | Function | No | Callback upon an API call failure. | + +## GyroscopeResponse6+ + +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.| diff --git a/en/application-dev/reference/apis/js-apis-system-vibrate.md b/en/application-dev/reference/apis/js-apis-system-vibrate.md index 90dc19e2ffb0c8817f7cc2096dc792d252f8996f..a48f2f453f5c1de2d55e23f7005ea5a28b941684 100644 --- a/en/application-dev/reference/apis/js-apis-system-vibrate.md +++ b/en/application-dev/reference/apis/js-apis-system-vibrate.md @@ -1,13 +1,12 @@ # @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. 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** -> - 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. > - This module requires hardware support and can only be debugged on real devices. @@ -21,26 +20,23 @@ import vibrator from '@system.vibrator'; ## vibrator.vibrate -vibrate(Object): void + vibrate(options?: VibrateOptions): void 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** -| 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 | 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.| +| Name | Type | Mandatory| Description | +| ------- | --------------------------------- | ---- | ---------- | +| options | [VibrateOptions](#vibrateoptions) | No | Vibration options.| **Example** -``` +```js vibrator.vibrate({ mode: 'short', success: function() { @@ -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. | diff --git a/en/application-dev/reference/syscap-list.md b/en/application-dev/reference/syscap-list.md index adede69fe1d7cd8c400d056d6588c9faab441513..a51200c0fdb7e0ac0ef1e68c7bb44ab7cea33a0b 100644 --- a/en/application-dev/reference/syscap-list.md +++ b/en/application-dev/reference/syscap-list.md @@ -1,6 +1,6 @@ # 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. @@ -437,7 +437,7 @@ Basic media capabilities ## SystemCapability.Multimedia.Media.AudioPlayer -Media audio player capability +Audio player capability | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | @@ -461,7 +461,7 @@ Media video player capability ## SystemCapability.Multimedia.Media.VideoRecorder -Media video recorder capability +Video recorder capability | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | @@ -1125,7 +1125,7 @@ Environment-related interfaces ## SystemCapability.FileManagement.File.DistributedFile -Distributed file extension interfaces +Distributed file extension | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | @@ -1253,7 +1253,7 @@ Basic capabilities of cross-process data sharing ## 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 | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | @@ -1285,7 +1285,7 @@ Core basic functional modules for component runtime, including application initi ## 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 | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | @@ -1394,3 +1394,267 @@ VAID management service | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | 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 | diff --git a/en/application-dev/task-management/continuous-task-dev-guide.md b/en/application-dev/task-management/continuous-task-dev-guide.md index 79280f8d301f75f45fbe2f0eb0724c17e7576e67..ff3ff065c3eacea69898cea1c280eb73b910f355 100644 --- a/en/application-dev/task-management/continuous-task-dev-guide.md +++ b/en/application-dev/task-management/continuous-task-dev-guide.md @@ -58,7 +58,7 @@ If an application needs to interact with a continuous task in the background (fo ], "reqPermissions": [ { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" // Continuous task permission + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" // Continuous task permission } ] } @@ -345,7 +345,7 @@ For details about the stage model, see [Stage Model Development Overview](../app } } - class MySequenceable { + class MyParcelable { num: number = 0; str: String = ""; @@ -354,31 +354,31 @@ For details about the stage model, see [Stage Model Development Overview](../app this.str = string; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); return true; } } function sendMsgCallback(data) { console.info('BgTaskAbility funcCallBack is called ' + data) - let receivedData = new MySequenceable(0, "") - data.readSequenceable(receivedData) + let receivedData = new MyParcelable(0, "") + data.readParcelable(receivedData) 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') { startContinuousTask() } else if (receivedData.str === 'stop_bgtask') { stopContinuousTask(); } - return new MySequenceable(10, "Callee test"); + return new MyParcelable(10, "Callee test"); } export default class BgTaskAbility extends Ability {