diff --git a/CODEOWNERS b/CODEOWNERS index f395d69420381a4e61268211787acd0cff417ec5..f8b1c4f0347f1c29fb82ddabd0778d4ca38c7543 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -85,6 +85,7 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-security-huks-guide.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23 @@ -348,4 +349,7 @@ zh-cn/application-dev/napi/napi-guidelines.md @RayShih zh-cn/application-dev/napi/drawing-guidelines.md @ge-yafang zh-cn/application-dev/napi/rawfile-guidelines.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen -zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease \ No newline at end of file +zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease +zh-cn/application-dev/website.md @zengyawen +zh-cn/application-dev/faqs/ @zengyawen +zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen \ No newline at end of file diff --git a/docker/LICENSE b/docker/LICENSE deleted file mode 100755 index 261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64..0000000000000000000000000000000000000000 --- a/docker/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index e1a7618251929cd060b0e33c4763e4bb5e5f9057..0000000000000000000000000000000000000000 --- a/docker/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -docker build -t openharmony-docker:1.0.0 . diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md index cb075f42cf7ef08d02f78ec1d0377c84d5a0bbf6..661b2532c49d36c79855c3e0530326ef590c7cd2 100644 --- a/en/application-dev/IDL/idl-guidelines.md +++ b/en/application-dev/IDL/idl-guidelines.md @@ -590,7 +590,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { testIntTransaction(data: number, callback: testIntTransactionCallback): void { - let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _option = new rpc.MessageOption(); let _data = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel(); _data.writeInt(data); @@ -612,7 +612,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { testStringTransaction(data: string, callback: testStringTransactionCallback): void { - let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _option = new rpc.MessageOption(); let _data = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel(); _data.writeString(data); diff --git a/en/application-dev/ability/figures/page-ability-lifecycle.png b/en/application-dev/ability/figures/page-ability-lifecycle.png index edb49acd0647f3af7355ceda987c5ca812866128..b35954967bb9c733725da2f0700481932619ae45 100644 Binary files a/en/application-dev/ability/figures/page-ability-lifecycle.png and b/en/application-dev/ability/figures/page-ability-lifecycle.png differ diff --git a/en/application-dev/ability/stage-call.md b/en/application-dev/ability/stage-call.md index aaa9a9918345c52015969245c3bbba3efbb81048..6b5823e76db2c95190111a55b9d2ef43ddd2d946 100644 --- a/en/application-dev/ability/stage-call.md +++ b/en/application-dev/ability/stage-call.md @@ -19,7 +19,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r |API|Description| |:------|:------| |startAbilityByCall(want: Want): Promise\|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.| -|on(method: string, callback: CaleeCallBack): void|Callback invoked when the callee registers a method.| +|on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee registers a method.| |off(method: string): void|Callback invoked when the callee deregisters a method.| |call(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee.| |callWithResult(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.| @@ -28,7 +28,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r ## How to Develop > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. For details about the complete project code, see [Samples](#samples). +> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. ### Creating a Callee For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener. 1. Configure the ability startup mode. diff --git a/en/application-dev/ability/stage-serviceextension.md b/en/application-dev/ability/stage-serviceextension.md index 0bda2156cdaa3b79c694f399453208ed9a0d13cf..5154a97d6a65bc787596f54466e7983a60a8bb11 100644 --- a/en/application-dev/ability/stage-serviceextension.md +++ b/en/application-dev/ability/stage-serviceextension.md @@ -39,33 +39,36 @@ OpenHarmony does not support creation of a Service Extension ability for third-p ``` -2. Customize a class that inherits from **ServiceExtensionAbility** in the .ts file in the directory where the Service Extension ability is defined and override the lifecycle callbacks of the base class. The code sample is as follows: +2. Customize a class that inherits from **ServiceExtensionAbility** in the .ts file in the directory where the Service Extension ability is defined (**entry\src\main\ets\ServiceExtAbility\ServiceExtAbility.ts** by default) and override the lifecycle callbacks of the base class. The code sample is as follows: ```js + import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' import rpc from '@ohos.rpc' + class StubTest extends rpc.RemoteObject { - constructor(des) { + constructor(des) { super(des); - } - onRemoteRequest(code, data, reply, option) { - } + } + onRemoteRequest(code, data, reply, option) { + } } - - class ServiceExt extends ServiceExtensionAbility { - console.log('onCreate, want:' + want.abilityName); - } - onRequest(want, startId) { - console.log('onRequest, want:' + want.abilityName); - } - onConnect(want) { - console.log('onConnect , want:' + want.abilityName); - return new StubTest("test"); - } - onDisconnect(want) { - console.log('onDisconnect, want:' + want.abilityName); - } - onDestroy() { - console.log('onDestroy'); - } + + class ServiceExtAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('onCreate, want:' + want.abilityName); + } + onRequest(want, startId) { + console.log('onRequest, want:' + want.abilityName); + } + onConnect(want) { + console.log('onConnect , want:' + want.abilityName); + return new StubTest("test"); + } + onDisconnect(want) { + console.log('onDisconnect, want:' + want.abilityName); + } + onDestroy() { + console.log('onDestroy'); + } } - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md index dde1feb495e9827ab1f0fd1fad903f71acb9cbb3..cfde2b66f2a3094355d6166bcaa4fb17856fbfaf 100644 --- a/en/application-dev/database/database-distributedobject-guidelines.md +++ b/en/application-dev/database/database-distributedobject-guidelines.md @@ -17,7 +17,7 @@ Call **createDistributedObject()** to create a distributed data object instance. **Table 1** API for creating a distributed data object instance | Package| API| Description| | -------- | -------- | -------- | -| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the **distributedObject** set.
- **DistributedObject**: returns the distributed object created.| +| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the **distributedObject** set.
- **DistributedObject**: returns the distributed object created.| ### Generating a Session ID @@ -35,16 +35,16 @@ Call **setSessionId()** to set a session ID for a distributed data object. The s **Table 3** API for setting a session ID | Class| API| Description| | -------- | -------- | -------- | -| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.
**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| +| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.
**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| ### Observing Data Changes Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes. **Table 4** APIs for observing data changes of a distributed data object -| Class| API| Description| +| Class| API| Description| | -------- | -------- | -------- | -| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.| +| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.| | DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. **Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.| ### Observing Online or Offline Status @@ -85,7 +85,11 @@ The following example shows how to implement a distributed data object synchroni ```js import distributedObject from '@ohos.data.distributedDataObject'; ``` -2. Request the permission.
Add the required permission in the **config.json** file. The sample code is as follows: + +2. Request the permission. + + Add the required permission in the **config.json** file. The sample code is as follows: + ``` { "module": { @@ -97,10 +101,11 @@ The following example shows how to implement a distributed data object synchroni } } ``` - This permission must also be authorized by the user through a dialog box when the application is started for the first time. The sample code is as follows: - ```js + This permission must also be authorized by the user through a dialog box when the application is started for the first time. The sample code is as follows: + + ``` import featureAbility from '@ohos.ability.featureAbility'; - + function grantPermission() { console.info('grantPermission'); let context = featureAbility.getContext(); @@ -108,11 +113,13 @@ The following example shows how to implement a distributed data object synchroni console.info(`result.requestCode=${result.requestCode}`) }) - console.info('end grantPermission'); + console.info('end grantPermission'); } grantPermission(); ``` - + + + 3. Obtain a distributed data object instance. The sample code is as follows: @@ -130,7 +137,7 @@ The following example shows how to implement a distributed data object synchroni ```js // Local object var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true, - parent:{mother:"jack mom",father:"jack Dad"},list:[{mother:"jack mom"}, {father:"jack Dad"}]}); + parent:{mother:"jack mom", father:"jack Dad"}, list:[{mother:"jack mom"}, {father:"jack Dad"}]}); local_object.setSessionId(sessionId); // Remote object @@ -140,8 +147,10 @@ The following example shows how to implement a distributed data object synchroni // After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18. ``` -5. Observe the data changes of the distributed data object.
You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes. +5. Observe the data changes of the distributed data object. + You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes. + The sample code is as follows: ```js @@ -152,26 +161,32 @@ The following example shows how to implement a distributed data object synchroni changeData.forEach(element => { console.info("changed !" + element + " " + local_object[element]); }); - } + } } - + // To refresh the page in changeCallback, correctly bind (this) to the changeCallback. local_object.on("change", this.changeCallback.bind(this)); ``` -6. Modify object attributes.
The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types). - +6. Modify object attributes. + + The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types). + The sample code is as follows: ```js local_object.name = "jack"; local_object.age = 19; local_object.isVis = false; - local_object.parent = {mother:"jack mom",father:"jack Dad"}; + local_object.parent = {mother:"jack mom", father:"jack Dad"}; local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}]; ``` - > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
- > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example: + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** + > + > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. + + Example: + ```js // Supported modification. local_object.parent = {mother:"mom", father:"dad"}; @@ -179,13 +194,18 @@ The following example shows how to implement a distributed data object synchroni local_object.parent.mother = "mom"; ``` -7. Access the distributed data object.
Obtain the distributed data object attribute, which is the latest data on the network. - +7. Access the distributed data object. + + Obtain the distributed data object attribute, which is the latest data on the network. + The sample code is as follows: ```js console.info("name " + local_object["name"]); ``` -8. Unsubscribe from data changes.
You can specify the callback to unregister. If you do not specify the callback, all data change callbacks of the distributed data object will be unregistered. + +8. Unsubscribe from data changes. + + You can specify the callback to unregister. If you do not specify the callback, all data change callbacks of the distributed data object will be unregistered. The sample code is as follows: ```js @@ -194,6 +214,7 @@ The following example shows how to implement a distributed data object synchroni // Unregister all data change callbacks. local_object.off("change"); ``` + 9. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline. The sample code is as follows: ```js @@ -207,58 +228,62 @@ The following example shows how to implement a distributed data object synchroni 10. Save a distributed data object and revoke the data saving operation. - Callback - - ```js - // Save a distributed data object. - local_object.save("local", (result, data)=>{ - console.log("save callback"); - console.info("save sessionId " + data.sessionId); - console.info("save version " + data.version); - console.info("save deviceId " + data.deviceId); - }); - // Revoke the data saving operation. - local_object.revokeSave((result, data) =>{ - console.log("revokeSave callback"); - console.info("revokeSave sessionId " + data.sessionId); - }); - ``` - - Promise - ```js - // Save a distributed data object. - g_object.save("local").then((result)=>{ - console.info("save sessionId " + result.sessionId); - console.info("save version " + result.version); - console.info("save deviceId " + result.deviceId); - }, (result)=>{ - console.info("save local failed."); - }); - // Revoke the data saving operation. - g_object.revokeSave().then((result)=>{ - console.info("revokeSave success."); - }, (result)=>{ - console.info("revokeSave failed."); - }); - ``` -11. Unsubscribe from the status changes of the distributed data object.
You can specify the callback to unregister. If you do not specify the callback, this API unregisters all callbacks of this distributed data object. + + ``` + ​```js + // Save a distributed data object. + local_object.save("local", (result, data) => { + console.log("save callback"); + console.info("save sessionId " + data.sessionId); + console.info("save version " + data.version); + console.info("save deviceId " + data.deviceId); + }); + // Revoke the data saving operation. + local_object.revokeSave((result, data) => { + console.log("revokeSave callback"); + console.info("revokeSave sessionId " + data.sessionId); + }); + ​``` + ``` + + - Promise + + ``` + ​```js + // Save a distributed data object. + g_object.save("local").then((result) => { + console.info("save sessionId " + result.sessionId); + console.info("save version " + result.version); + console.info("save deviceId " + result.deviceId); + }, (result)=>{ + console.info("save local failed."); + }); + // Revoke the data saving operation. + g_object.revokeSave().then((result) => { + console.info("revokeSave success."); + }, (result)=>{ + console.info("revokeSave failed."); + }); + ​``` + ``` + + + +11. Unsubscribe from the status changes of the distributed data object. + + You can specify the callback to unregister. If you do not specify the callback, this API unregisters all callbacks of this distributed data object. The sample code is as follows: - ```js + ```js // Unregister the specified status change callback. local_object.off("status", this.statusCallback); // Unregister all status change callbacks. local_object.off("status"); - ``` + ``` + 12. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object. The sample code is as follows: ```js local_object.setSessionId(""); ``` -## Development Example - -The following example is provided for you to better understand the development of distributed data objects: - -- [Distributed Notepad](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad) - - -When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network. diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index c5608c6eabd526c38a87bd3907fba89fb1a11629..dd1594215a10d1c93c9825444253484ed8956e05 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -6,22 +6,20 @@ The Distributed Data Service (DDS) implements synchronization of application dat ## Available APIs - For details about the APIs related to distributed data, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md). -The table below describes the APIs provided by the OpenHarmony DDS module. **Table 1** APIs provided by the DDS -| Category | API | Description | -| ------------ | ------------- | ------------- | -| Creating a distributed database| createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void
createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KVManager** object for database management.| -| Obtaining a distributed KV store| getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | Obtains the KV store with the specified **Options** and **storeId**.| -| Managing data in a distributed KV store| put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback<void>): void
put(key: string, value: Uint8Array \| string \| number \| boolean): Promise<void> | Inserts and updates data.| -| Managing data in a distributed KV store| delete(key: string, callback: AsyncCallback<void>): void
delete(key: string): Promise<void> | Deletes data. | -| Managing data in a distributed KV store| get(key: string, callback: AsyncCallback<Uint8Array \| string \| boolean \| number>): void
get(key: string): Promise<Uint8Array \| string \| boolean \| number> | Queries data. | -| Subscribing to changes in the distributed data| on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void
on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void | Subscribes to data changes in the KV store.| -| Synchronizing data across devices| sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | +| API | Description | +| ------------------------------------------------------------ | ----------------------------------------------- | +| createKVManager(config:KVManagerConfig,callback:AsyncCallback<KVManager>):void
createKVManager(config:KVManagerConfig):Promise<KVManager> | Creates a **KVManager** object for database management.| +| getKVStore<TextendsKVStore>(storeId:string,options:Options,callback:AsyncCallback<T>):void
getKVStore<TextendsKVStore>(storeId:string,options:Options):Promise<T> | Obtains a KV store with the specified **Options** and **storeId**.| +| put(key:string,value:Uint8Array\|string\|number\|boolean,callback:AsyncCallback<void>):void
put(key:string,value:Uint8Array\|string\|number\|boolean):Promise<void> | Inserts and updates data. | +| delete(key:string,callback:AsyncCallback<void>):void
delete(key:string):Promise<void> | Deletes data. | +| get(key:string,callback:AsyncCallback<Uint8Array\|string\|boolean\|number>):void
get(key:string):Promise<Uint8Array\|string\|boolean\|number> | Queries data. | +| on(event:'dataChange',type:SubscribeType,observer:Callback<ChangeNotification>):void
on(event:'syncComplete',syncCallback:Callback<Array<[string,number]>>):void | Subscribes to data changes in the KV store. | +| sync(deviceIdList:string[],mode:SyncMode,allowedDelayMs?:number):void | Triggers database synchronization in manual mode. | @@ -36,11 +34,14 @@ The following uses a single KV store as an example to describe the development p ``` 2. Create a **KvManager** instance based on the specified **KvManagerConfig** object. + (1) Create a **KvManagerConfig** object based on the application context. - (2) Create a **KvManager** instance. + (2) Create a **KvManager** instance. + The sample code is as follows: - ```js + + ``` let kvManager; try { const kvManagerConfig = { @@ -62,9 +63,12 @@ The following uses a single KV store as an example to describe the development p console.log("An unexpected error occurred. Error:" + e); } ``` - + + 3. Create and obtain a single KV store. + (1) Declare the ID of the single KV store to create. + (2) Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required. The sample code is as follows: @@ -92,8 +96,9 @@ The following uses a single KV store as an example to describe the development p } ``` - > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
- > For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (**kvStore** in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle. + > **NOTE** + > + > For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (`kvStore` in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle. 4. Subscribe to changes in the distributed data.
The following is the sample code for subscribing to the data changes of a single KV store: @@ -104,7 +109,9 @@ The following uses a single KV store as an example to describe the development p ``` 5. Write data to the single KV store. + (1) Construct the key and value to be written into the single KV store. + (2) Write key-value pairs into the single KV store. The following is the sample code for writing key-value pairs of the string type into the single KV store: @@ -126,7 +133,9 @@ The following uses a single KV store as an example to describe the development p ``` 6. Query data in the single KV store. + (1) Construct the key to be queried from the single KV store. + (2) Query data from the single KV store. The following is the sample code for querying data of the string type from the single KV store: @@ -152,7 +161,11 @@ The following uses a single KV store as an example to describe the development p 7. Synchronize data to other devices.
Select the devices in the same network and the synchronization mode to synchronize data. - The following is the sample code for data synchronization in a single KV store. **deviceIds** can be obtained by deviceManager by calling **getTrustedDeviceListSync()**, and **1000** indicates that the maximum delay time is 1000 ms. + > **NOTE** + > + > The APIs of the `deviceManager` module are system interfaces. + + The following is the sample code for synchronizing data in a single KV store: ```js import deviceManager from '@ohos.distributedHardware.deviceManager'; @@ -161,7 +174,7 @@ The following uses a single KV store as an example to describe the development p deviceManager.createDeviceManager("bundleName", (err, value) => { if (!err) { devManager = value; - // Obtain deviceIds. + // deviceIds is obtained by deviceManager by calling getTrustedDeviceListSync(). let deviceIds = []; if (devManager != null) { var devices = devManager.getTrustedDeviceListSync(); @@ -170,6 +183,7 @@ The following uses a single KV store as an example to describe the development p } } try{ + // 1000 indicates that the maximum delay is 1000 ms. kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); }catch (e) { console.log("An unexpected error occurred. Error:" + e); @@ -177,7 +191,3 @@ The following uses a single KV store as an example to describe the development p } }); ``` -## Samples -The following samples are provided to help you better understand the distributed data development: -- [`KvStore`: Distributed Database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) -- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index 7f93b1ca5684d4268ca7fe46e35442a776a3b201..f6c7395339d66cb1c79bf71d424c15072f77f1b6 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -7,7 +7,7 @@ A relational database (RDB) store allows you to operate local data with or witho ## Available APIs -For details about RDB APIs, see [Relational Database](../reference/apis/js-apis-data-rdb.md). +Most of the RDB store APIs are asynchronous interfaces, which can use a callback or promise to return the result. This document uses the promise-based APIs as an example. For details about the APIs, see [Relational Database](../reference/apis/js-apis-data-rdb.md). ### Creating or Deleting an RDB Store @@ -15,51 +15,48 @@ The table below describes the APIs available for creating and deleting an RDB st **Table 1** APIs for creating and deleting an RDB store -| API| Description| -| -------- | -------- | -|getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void| Obtains an RDB store. This API uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.
- **context**: context of the application or function.
- **config**: configuration of the RDB store.
- **version**: RDB version.
- **callback**: callback invoked to return the RDB store obtained.| -|getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> | Obtains an RDB store. This API uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.
- **context**: context of the application or function.
- **config**: configuration of the RDB store.
- **version**: RDB version.| -|deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void> ): void | Deletes an RDB store. This API uses a callback to return the result.
- **context**: context of the application or function.
- **name**: RDB store to delete.
- **callback**: callback invoked to return the result.| -| deleteRdbStore(context: Context, name: string): Promise<void> | Deletes an RDB store. This API uses a promise to return the result.
- **context**: context of the application or function.
- **name**: RDB store to delete.| +| API | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> | Obtains an RDB store. This API uses a promise to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
- **context**: context of the application or function.
- **config**: configuration of the RDB store.
- **version**: version of the RDB store.| +| deleteRdbStore(context: Context, name: string): Promise<void> | Deletes an RDB store. This API uses a promise to return the result.
- **context**: context of the application or function.
- **name**: name of the RDB store to delete.| ### Managing Data in an RDB Store The RDB provides APIs for inserting, deleting, updating, and querying data in the local RDB store. -- **Inserting data** +- **Inserting Data** The RDB provides APIs for inserting data through a **ValuesBucket** in a data table. If the data is inserted, the row ID of the data inserted will be returned; otherwise, **-1** will be returned. - **Table 2** APIs for inserting data + **Table 2** API for inserting data - | Class| API| Description| - | -------- | -------- | -------- | - | RdbStore | insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void | Inserts a row of data into a table. This API uses a callback to return the result.
- **table**: name of the target table.
- **values**: data to be inserted into the table.
- **callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.| - | RdbStore | insert(table: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This API uses a promise to return the result.
- **table**: name of the target table.
- **values**: data to be inserted into the table.| + | Class | API | Description | + | -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | + | RdbStore | insert(table:string,values:ValuesBucket):Promise<number> | Inserts a row of data into a table. This API uses a promise to return the result.
If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.
- **table**: name of the target table.
- **values**: data to be inserted into the table.| -- **Updating data** +- **Updating Data** Call the **update()** method to pass new data and specify the update conditions by using **RdbPredicates**. If the data is updated, the number of rows of the updated data will be returned; otherwise, **0** will be returned. - **Table 3** APIs for updating data + **Table 3** API for updating data - | Class| API| Description| - | -------- | -------- | -------- | - | RdbStore | update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>):void | Updates data in the RDB store based on the specified **RdbPredicates** object. This API uses a callback to return the result.
- **values**: data to update, which is stored in a **ValuesBucket**.
- **predicates**: conditions for updating data.
- **callback**: callback invoked to return the number of rows updated.| - | RdbStore | update(values: ValuesBucket, predicates: RdbPredicates): Promise<number> | Updates data in the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
- **values**: data to update, which is stored in a **ValuesBucket**.
- **predicates**: conditions for updating data.| + | Class | API | Description | + | -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | + | RdbStore | update(values:ValuesBucket,predicates:RdbPredicates):Promise<number> | Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the result.
- **values**: data to update, which is stored in **ValuesBucket**.
- **predicates**: conditions for updating data.
Return value: number of rows updated. | -- **Deleting data** +- **Deleting Data** Call the **delete()** method to delete data meeting the conditions specified by **RdbPredicates**. If the data is deleted, the number of rows of the deleted data will be returned; otherwise, **0** will be returned. - **Table 4** APIs for deleting data + **Table 4** API for deleting data - | Class| API| Description| - | -------- | -------- | -------- | - | RdbStore | delete(predicates: RdbPredicates, callback: AsyncCallback<number>):void | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result.
- **predicates**: conditions for deleting data.
- **callback**: callback invoked to return the number of rows updated.| - | RdbStore | delete(predicates: RdbPredicates): Promise<number> | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
- **predicates**: conditions for deleting data.| + | Class | API | Description | + | -------- | ------------------------------------------------------ | ------------------------------------------------------------ | + | RdbStore | delete(predicates:RdbPredicates):Promise<number> | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
- **predicates**: conditions for deleting data.
Return value: number of rows updated. | -- **Querying data** + + +- **Querying Data** You can query data in an RDB store in either of the following ways: @@ -68,78 +65,48 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th **Table 5** APIs for querying data - | Class| API| Description| - | -------- | -------- | -------- | - | RdbStore | query(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void | Queries data in the RDB store based on the specified **RdbPredicates** object. This API uses a callback to return the result.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.
- **callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| - | RdbStore | query(predicates: RdbPredicates, columns?: Array<string>): Promise<ResultSet> | Queries data in the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.| - | RdbStore | querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void | Queries data in the RDB store using the specified SQL statement. This API uses a callback to return the result.
- **sql**: SQL statement.
- **bindArgs**: arguments in the SQL statement.
- **callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| - | RdbStore | querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> | Queries data in the RDB store using the specified SQL statement. This API uses a promise to return the result.
- **sql**: SQL statement.
- **bindArgs**: arguments in the SQL statement.| - | RdbStore | remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void |Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result.
- **device**: network ID of the remote device.
- **table**: name of the table to query.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.
- **callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| - | RdbStore | remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>): Promise<ResultSet> | Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result.
- **device**: network ID of the remote device.
- **table**: name of the table to query.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.| + | Class | API | Description | + | -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | + | RdbStore | query(predicates:RdbPredicates,columns?:Array<string>):Promise<ResultSet> | Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.| + | RdbStore | querySql(sql:string,bindArgs?:Array<ValueType>):Promise<ResultSet> | Queries data using the specified SQL statement. This API uses a promise to return the result.
- **sql**: SQL statement.
- **bindArgs**: arguments in the SQL statement.| + | RdbStore | remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>): Promise<ResultSet> | Queries data from the database of a remote device based on specified conditions. This API uses a promise to return the result.
- **device**: network ID of the remote device.
- **table**: name of the table to be queried.
- **predicates**: **RdbPredicates** that specifies the query condition.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.| ### Using Predicates The RDB provides **RdbPredicates** for you to set database operation conditions. +The following lists common predicates. For more information about predicates, see [**RdbPredicates**](../reference/apis/js-apis-data-rdb.md#rdbpredicates). + **Table 6** APIs for using RDB store predicates -| Class| API| Description| -| -------- | -------- | -------- | -| RdbPredicates |inDevices(devices: Array\): RdbPredicates | Specifies remote devices on the network with RDB stores to be synchronized.
- **devices**: IDs of the remote devices on the network.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates |inAllDevices(): RdbPredicates | Connects to all remote devices on the network with RDB stores to be synchronized.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | beginWrap(): RdbPredicates | Adds a left parenthesis to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with a left parenthesis.| -| RdbPredicates | endWrap(): RdbPredicates | Adds a right parenthesis to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with a right parenthesis.| -| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with the OR condition.| -| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with the AND condition.| -| RdbPredicates | contains(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to match a string containing the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string.| -| RdbPredicates | beginsWith(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to match a string that starts with the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | endsWith(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to match a string that ends with the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | isNull(field: string): RdbPredicates | Sets an **RdbPredicates** to match the field whose value is null.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | isNotNull(field: string): RdbPredicates | Sets an **RdbPredicates** to match the field whose value is not null.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | like(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to match a string that is similar to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | glob(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to match the specified string.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets ta **RdbPredicates** to match the field with data type **ValueType** and value within the specified range.
- **field**: column name in the database table.
- **low**: minimum value that matches the **RdbPredicates**.
- **high**: maximum value that matches the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range.
- **field**: column name in the database table.
- **low**: minimum value that matches the **RdbPredicates**.
- **high**: maximum value that matches the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | orderByAsc(field: string): RdbPredicates | Sets an **RdbPredicates** to match the column with values sorted in ascending order.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | orderByDesc(field: string): RdbPredicates | Sets an **RdbPredicates** to match the column with values sorted in descending order.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | distinct(): RdbPredicates | Sets an **RdbPredicates** to filter out duplicate records.
- **RdbPredicates**: returns a **RdbPredicates** object that can filter out duplicate records.| -| RdbPredicates | limitAs(value: number): RdbPredicates | Sets an **RdbPredicates** to specify the maximum number of records.
- **value**: maximum number of records.
- **RdbPredicates**: returns a **RdbPredicates** object that can be used to set the maximum number of records.| -| RdbPredicates | offsetAs(rowOffset: number): RdbPredicates | Sets the **RdbPredicates** to specify the start position of the returned result.
- **rowOffset**: start position of the returned result. The value is a positive integer.
- **RdbPredicates**: returns a **RdbPredicates** object that specifies the start position of the returned result.| -| RdbPredicates | groupBy(fields: Array<string>): RdbPredicates | Sets an **RdbPredicates** to group rows that have the same value into summary rows.
- **fields**: names of the columns grouped for querying data.
- **RdbPredicates**: returns a **RdbPredicates** object that groups rows with the same value.| -| RdbPredicates | indexedBy(indexName: string): RdbPredicates | Sets an **RdbPredicates** to specify the index column.
- **indexName**: name of the index column.
- **RdbPredicates**: returns a **RdbPredicates** object that specifies the index column.| -| RdbPredicates | in(field: string, value: Array<ValueType>): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **Array<ValueType>** and value within the specified range.
- **field**: column name in the database table.
- **value**: array of **ValueType** to match.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| -| RdbPredicates | notIn(field: string, value: Array<ValueType>): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **Array<ValueType>** and value out of the specified range.
- **field**: column name in the database table.
- **value**: array of **ValueType** to match.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| +| Class | API | Description | +| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbPredicates | equalTo(field:string,value:ValueType):RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.| +| RdbPredicates | notEqualTo(field:string,value:ValueType):RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.| +| RdbPredicates | or():RdbPredicates | Adds the OR condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the OR condition.| +| RdbPredicates | and():RdbPredicates | Adds the AND condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the AND condition.| +| RdbPredicates | contains(field:string,value:string):RdbPredicates | Sets an **RdbPredicates** to match a string containing the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.| + ### Using the Result Set -A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**. +A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. + +For details about how to use result set APIs, see [Result Set](../reference/apis/js-apis-data-resultset.md). > **NOTICE**
> After a result set is used, you must call the **close()** method to close it explicitly. **Table 7** APIs for using the result set -| Class| API| Description| -| -------- | -------- | -------- | -| ResultSet | goTo(offset:number): boolean | Moves the result set forwards or backwards by the specified offset relative to its current position.| -| ResultSet | goToRow(position: number): boolean | Moves the result set to the specified row.| -| ResultSet | goToNextRow(): boolean | Moves the result set to the next row.| -| ResultSet | goToPreviousRow(): boolean | Moves the result set to the previous row.| -| ResultSet | getColumnIndex(columnName: string): number | Obtains the column index based on the specified column name.| -| ResultSet | getColumnName(columnIndex: number): string | Obtains the column name based on the specified column index.| -| ResultSet | goToFirstRow(): boolean | Moves to the first row of the result set.| -| ResultSet | goToLastRow(): boolean | Moves to the last row of the result set.| -| ResultSet | getString(columnIndex: number): string | Obtains the value in the specified column of the current row, in a string.| -| ResultSet | getBlob(columnIndex: number): Uint8Array | Obtains the values in the specified column of the current row, in a byte array.| -| ResultSet | getDouble(columnIndex: number): number | Obtains the values in the specified column of the current row, in double.| -| ResultSet | isColumnNull(columnIndex: number): boolean | Checks whether the value in the specified column of the current row is null.| -| ResultSet | close(): void | Closes the result set.| +| Class | API | Description | +| --------- | ---------------------------------------------------- | ------------------------------------------ | +| ResultSet | goToFirstRow():boolean | Moves to the first row of the result set. | +| ResultSet | getString(columnIndex:number):string | Obtains the value in the form of a string based on the specified column and current row. | +| ResultSet | getBlob(columnIndex:number):Uint8Array | Obtains the value in the form of a byte array based on the specified column and the current row.| +| ResultSet | getDouble(columnIndex:number):number | Obtains the value in the form of double based on the specified column and current row. | +| ResultSet | getLong(columnIndex:number):number | Obtains the value in the form of a long integer based on the specified column and current row. | +| ResultSet | close():void | Closes the result set. | @@ -149,78 +116,73 @@ A result set can be regarded as a row of data in the queried results. It allows **Setting Distributed Tables** -**Table 8** APIs for setting distributed tables +**Table 8** API for setting distributed tables -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore | setDistributedTables(tables: Array\, callback: AsyncCallback\): void | Sets a list of distributed tables. This API uses a callback to return the result.
- **tables**: names of the distributed tables to set.
- **callback**: callback invoked to return the result.| -| RdbStore | setDistributedTables(tables: Array\): Promise\ | Sets a list of distributed tables. This API uses a promise to return the result.
- **tables**: names of the distributed tables to set.| +| Class | API | Description | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbStore | setDistributedTables(tables: Array\): Promise\ | Sets distributed tables. This API uses a promise to return the result.
- **tables**: names of the distributed tables to set.| **Obtaining the Distributed Table Name for a Remote Device** You can obtain the distributed table name for a remote device based on the local table name. The distributed table name can be used to query the RDB store of the remote device. -**Table 9** APIs for obtaining the distributed table name of a remote device +**Table 9** API for obtaining the distributed table name of a remote device -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore | obtainDistributedTableName(device: string, table: string, callback: AsyncCallback\): void | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This API uses an asynchronous callback to return the result.
- **device**: remote device.
- **table**: local table name.
- **callback**: callback used to return the result. If the operation is successful, the distributed table name of the remote device will be returned.| -| RdbStore | obtainDistributedTableName(device: string, table: string): Promise\ | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is used to query the RDB store of the remote device. This API uses a promise to return the result.
- **device**: remote device.
- **table**: local table name.| +| Class | API | Description | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbStore | obtainDistributedTableName(device: string, table: string): Promise\ | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the RDB store of a remote device is queried. This API uses a promise to return the result.
- **device**: remote device.
- **table**: local table name.| **Synchronizing Data Between Devices** -**Table 10** APIs for synchronizing data between devices +**Table 10** API for synchronizing data between devices -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback\>): void | Synchronizes data between devices. This API uses a callback to return the result.
- **mode**: data synchronization mode. **SYNC_MODE_PUSH** means to push data from the local device to a remote device. **SYNC_MODE_PULL** means to pull data from a remote device to the local device.
- **predicates**: data and devices to be synchronized.
- **callback**: callback invoked to return the result. In the result, **string** indicates the device ID, and **number** indicates the synchronization status of each device. The value **0** indicates a success, and other values indicate a failure.| -| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise\> | Synchronizes data between devices. This API uses a promise to return the result.
- **mode**: data synchronization mode. **SYNC_MODE_PUSH** means to push data from the local device to a remote device. **SYNC_MODE_PULL** means to pull data from a remote device to the local device.
- **predicates**: data and devices to be synchronized.| +| Class | API | Description | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise\> | Synchronizes data between devices. This API uses a promise to return the result.
- **mode**: synchronization mode. **SYNC_MODE_PUSH** means to push data from the local device to a remote device. **SYNC_MODE_PULL** means to pull data from a remote device to the local device.
- **predicates**: specifies the data and devices to synchronize.
- **string**: device ID.
- **number**: synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure.| **Registering an RDB Store Observer** **Table 11** API for registering an observer -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore |on(event: 'dataChange', type: SubscribeType, observer: Callback\>): void| Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE** means to subscribe to remote data changes.
- **observer**: observer that listens for data changes in the RDB store.| +| Class | API | Description | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbStore | on(event: 'dataChange', type: SubscribeType, observer: Callback\>): void | Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE** means to subscribe to remote data changes.
- **observer**: observer that listens for data changes in the RDB store.| **Unregistering an RDB Store Observer** **Table 12** API for unregistering an observer -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore |off(event:'dataChange', type: SubscribeType, observer: Callback\>): void;| Unregisters the observer of the specified type for the RDB store. This API uses a callback to return the result.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE** means to subscribe to remote data changes.
- **observer**: observer to unregister.| +| Class | API | Description | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbStore | off(event:'dataChange', type: SubscribeType, observer: Callback\>): void; | Unregisters the observer of the specified type from the RDB store. This API uses an asynchronous callback to return the result.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE** means to subscribe to remote data changes.
- **observer**: observer to unregister.| ### Backing Up and Restoring an RDB Store **Backing Up an RDB Store** -**Table 13** APIs for backing up an RDB store +**Table 13** API for backing up an RDB store -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore |backup(destName:string, callback: AsyncCallback<void>):void| Backs up an RDB store. This API uses an asynchronous callback to return the result.
- **destName**: name of the RDB backup file.
- **callback**: callback invoked to return the result.| -| RdbStore |backup(destName:string): Promise<void>| Backs up an RDB store. This API uses a promise to return the result.
- **destName**: name of the RDB backup file.| +| Class | API | Description | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbStore | backup(destName:string): Promise<void> | Backs up an RDB store. This API uses a promise to return the result.
- **destName**: name of the RDB backup file.| **Restoring an RDB Store** -**Table 14** APIs for restoring an RDB store +**Table 14** API for restoring an RDB store -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore |restore(srcName:string, callback: AsyncCallback<void>):void| Restores an RDB store using a backup file. This API uses an asynchronous callback to return the result.
- **srcName**: name of the RDB backup file.
- **callback**: callback invoked to return the result.| -| RdbStore |restore(srcName:string): Promise<void>| Restores an RDB store using a backup file. This API uses a promise to return the result.
- **srcName**: name of the RDB backup file.| +| Class | API | Description | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| RdbStore | restore(srcName:string): Promise<void> | Restores an RDB store from a backup file. This API uses a promise to return the result.
- **srcName**: name of the backup file used to restore the RDB store.| **Transaction** Table 15 Transaction APIs -| Class| API| Description| -| -------- | -------- | -------- | -| RdbStore |beginTransaction():void| Starts the transaction before executing SQL statements.| -| RdbStore |commit():void| Commits the executed SQL statements.| -| RdbStore |rollBack():void| Rolls back the SQL statements that have been executed.| +| Class | API | Description | +| -------- | ----------------------- | --------------------------------- | +| RdbStore | beginTransaction():void | Starts the transaction before executing SQL statements.| +| RdbStore | commit():void | Commits the executed SQL statements. | +| RdbStore | rollBack():void | Rolls back the SQL statements that have been executed. | ## How to Develop @@ -238,7 +200,7 @@ Table 15 Transaction APIs import data_rdb from '@ohos.data.rdb' const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; - const STORE_CONFIG = {name: "rdbstore.db",} + const STORE_CONFIG = {name: "rdbstore.db"} data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { rdbStore.executeSql(CREATE_TABLE_TEST) console.info('create table done.') @@ -255,7 +217,7 @@ Table 15 Transaction APIs ```js var u8 = new Uint8Array([1, 2, 3]) - const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,} + const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8} let insertPromise = rdbStore.insert("test", valueBucket) ``` @@ -424,3 +386,4 @@ Table 15 Transaction APIs console.info('Restore failed, err: ' + err) }) ``` + diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md index ab4c8234ba4147008ea9515d20e23506eddd3f13..4f49e7996188a7bc668e23fc2a21a1a29ec6e562 100644 --- a/en/application-dev/device/vibrator-guidelines.md +++ b/en/application-dev/device/vibrator-guidelines.md @@ -65,9 +65,9 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md import vibrator from "@ohos.vibrator" vibrator.vibrate(1000).then((error) => { if (error) { // The call fails, and error.code and error.message are printed. - Console.log("Promise return failed.error.code " + error.code + "error.message " + error.message); + console.log("Promise return failed.error.code " + error.code + "error.message " + error.message); } else { // The call is successful, and the device starts to vibrate. - Console.log("Promise returned to indicate a successful vibration.") + console.log("Promise returned to indicate a successful vibration.") } }) ``` @@ -78,9 +78,9 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md import vibrator from "@ohos.vibrator" vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error) => { if (error) { // The call fails, and error.code and error.message are printed. - Console.log("Promise return failed.error.code " + error.code + "error.message " + error.message); + console.log("Promise return failed.error.code " + error.code + "error.message " + error.message); } else { // The call is successful, and the device stops vibrating. - Console.log("Promise returned to indicate a successful stop."); + console.log("Promise returned to indicate successful."); } }) ``` diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md index d65d0abfc4d4649f7f1847abdbe6fb0a832e194e..faf977c7b42644a03066947e45996a936529f8cc 100644 --- a/en/application-dev/media/audio-playback.md +++ b/en/application-dev/media/audio-playback.md @@ -39,28 +39,28 @@ function printfDescription(obj) { // Set the player callbacks. function setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered. }); - audioPlayer.on('play', () => { // Set the `play` event callback. + audioPlayer.on('play', () => { // Set the 'play' event callback. console.info('audio play success'); audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. }); - audioPlayer.on('pause', () => { // Set the `pause` event callback. + audioPlayer.on('pause', () => { // Set the 'pause' event callback. console.info('audio pause success'); audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. }); - audioPlayer.on('stop', () => { // Set the `stop` event callback. + audioPlayer.on('stop', () => { // Set the 'stop' event callback. console.info('audio stop success'); audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. }); - audioPlayer.on('reset', () => { // Set the `reset` event callback. + audioPlayer.on('reset', () => { // Set the 'reset' event callback. console.info('audio reset success'); audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer = undefined; }); - audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the `timeUpdate` event callback. + audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback. if (typeof(seekDoneTime) == 'undefined') { console.info('audio seek fail'); return; @@ -68,7 +68,7 @@ function setCallBack(audioPlayer) { console.info('audio seek success, and seek time is ' + seekDoneTime); audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. }); - audioPlayer.on('volumeChange', () => { // Set the `volumeChange` event callback. + audioPlayer.on('volumeChange', () => { // Set the 'volumeChange' event callback. console.info('audio volumeChange success'); audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. if (typeof (arrlist) != 'undefined') { @@ -107,7 +107,7 @@ async function audioPlayerDemo() { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. } ``` @@ -119,11 +119,11 @@ import fileIO from '@ohos.fileio' export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); - audioPlayer.on('play', () => { // Set the `play` event callback. + audioPlayer.on('play', () => { // Set the 'play' event callback. console.info('audio play success'); }); audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. @@ -147,7 +147,7 @@ export class AudioDemo { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. } } ``` @@ -161,15 +161,15 @@ export class AudioDemo { // Set the player callbacks. private isNextMusic = false; setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); - audioPlayer.on('play', () => { // Set the `play` event callback. + audioPlayer.on('play', () => { // Set the 'play' event callback. console.info('audio play success'); audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. }); - audioPlayer.on('reset', () => { // Set the `reset` event callback. + audioPlayer.on('reset', () => { // Set the 'reset' event callback. console.info('audio play success'); if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. this.nextMusic(audioPlayer); // Changing songs is implemented. @@ -223,7 +223,7 @@ import fileIO from '@ohos.fileio' export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); audioPlayer.loop = true; // Set the loop playback attribute. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. @@ -247,7 +247,7 @@ export class AudioDemo { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. } } ``` diff --git a/en/application-dev/media/image.md b/en/application-dev/media/image.md index a262b3e219970b107ee5debdbc1254907f9d3e22..5be7a47cf20f0269c670593bf412bee5dd92162f 100644 --- a/en/application-dev/media/image.md +++ b/en/application-dev/media/image.md @@ -267,7 +267,7 @@ imageSourceApi.getImageInfo(imageInfo => { }) // Update incremental data. -imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {}) +imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error, data)=> {}) ``` diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 6b5bbc8aa3d671c4cf0b01316db441d33c0f189f..97c99233c3ded3f9eddbaadb68496ce9b3e55e48 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -19,6 +19,7 @@ - [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md) - [@ohos.application.StartOptions](js-apis-application-StartOptions.md) - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md) + - [@ohos.application.WindowExtensionAbility](js-apis-application-WindowExtensionAbility.md) - application/[AbilityContext](js-apis-ability-context.md) - application/[ApplicationContext](js-apis-application-applicationContext.md) - application/[AbilityStageContext](js-apis-abilitystagecontext.md) @@ -37,6 +38,7 @@ - [@ohos.application.Configuration](js-apis-configuration.md) - [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md) - [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md) + - [@ohos.application.errorManager](js-apis-errorManager.md) - [@ohos.application.formBindingData](js-apis-formbindingdata.md) - [@ohos.application.formError](js-apis-formerror.md) - [@ohos.application.formHost](js-apis-formhost.md) @@ -68,18 +70,25 @@ - [@ohos.bundle](js-apis-Bundle.md) - [@ohos.bundle.defaultAppManager](js-apis-bundle-defaultAppManager.md) + - [@ohos.bundle.innerBundleManager)](js-apis-Bundle-InnerBundleManager.md) - [@ohos.bundleState](js-apis-deviceUsageStatistics.md) + - [@ohos.distributedBundle)](js-apis-Bundle-distributedBundle.md) - [@ohos.zlib](js-apis-zlib.md) - bundle/[AbilityInfo](js-apis-bundle-AbilityInfo.md) - bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md) - bundle/[BundleInfo](js-apis-bundle-BundleInfo.md) + - bundle/[BundleInstaller](js-apis-bundle-BundleInstaller.md) - bundle/[CustomizeData](js-apis-bundle-CustomizeData.md) + - bundle/[DispatchInfo](js-apis-dispatchInfo.md) - bundle/[ElementName](js-apis-bundle-ElementName.md) - bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) - bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md) + - bundle/[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md) - bundle/[Metadata](js-apis-bundle-Metadata.md) - bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md) - + - bundle/[PermissionDef](js-apis-bundle-PermissionDef.md) + - bundle/[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md) + - bundle/[ShortcutInfo](js-apis-bundle-ShortcutInfo.md) - UI Page - [@ohos.animator](js-apis-animator.md) @@ -90,6 +99,7 @@ - Graphics + - [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md) - [@ohos.display ](js-apis-display.md) - [@ohos.effectKit](js-apis-effectKit.md) - [@ohos.screen](js-apis-screen.md) @@ -115,6 +125,7 @@ - Resource Scheduling - [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md) + - [@ohos.distributedMissionManager](js-apis-distributedMissionManager.md) - [@ohos.workScheduler ](js-apis-workScheduler.md) - [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md) diff --git a/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md b/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md new file mode 100644 index 0000000000000000000000000000000000000000..3691d636ac769e8bfad9099f92554a2476925d40 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md @@ -0,0 +1,307 @@ +# innerBundleManager + +The **innerBundleManager** module manages internal bundles. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import innerBundleManager from '@ohos.bundle.innerBundleManager'; +``` + +## System Capability + +SystemCapability.BundleManager.BundleFramework + +## Required Permissions + +| Permission | Permission Level | Description | +| ------------------------------------------ | ------------ | ---------------------------- | +| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all applications. | +| ohos.permission.LISTEN_BUNDLE_CHANGE | system_grant | Permission to listen for application changes.| + +For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). + +## innerBundleManager.getLauncherAbilityInfos + +getLauncherAbilityInfos(bundleName: string, userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; + +Obtains the launcher ability information based on a given bundle name. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| callback | AsyncCallback\> | Yes | Callback used to return an array of the launcher ability information. | + + + +## innerBundleManager.getLauncherAbilityInfos + +getLauncherAbilityInfos(bundleName: string, userId: number) : Promise<Array<LauncherAbilityInfo>> + +Obtains the launcher ability information based on a given bundle name. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ----------------------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ------------------------- | +| Promise\> | Promise used to return an array of the launcher ability information.| + +## innerBundleManager.on + +on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback, callback: AsyncCallback<string>) : void; + +Registers a callback to receive bundle status changes. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------------- | --------------------- | ---- | ---------------------------------------------------- | +| type | "BundleStatusChange" | Yes | Event type. | +| bundleStatusCallback | BundleStatusCallback | Yes | Callback to register. | +| callback | AsyncCallback\ | Yes | Callback used to return a successful result or error information.| + +## innerBundleManager.on + +on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback): Promise<string> + +Registers a callback to receive bundle status changes. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------------- | -------------------- | ---- | ------------------ | +| type | "BundleStatusChange" | Yes | Event type. | +| bundleStatusCallback | BundleStatusCallback | Yes | Callback to register.| + +**Return value** + +| Type | Description | +| --------------- | ----------------------------------- | +| Promise\ | Promise used to return a successful result or error information.| + +## innerBundleManager.off + +off(type:"BundleStatusChange", callback: AsyncCallback<string>) : void; + +Deregisters the callback that receives bundle status changes. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ---------------------------------------------------- | +| type | "BundleStatusChange" | Yes | Event type. | +| callback | AsyncCallback\ | Yes | Callback used to return a successful result or error information.| + +## innerBundleManager.off + +off(type:"BundleStatusChange"): Promise<string> + +Deregisters the callback that receives bundle status changes. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | -------------------- | ---- | ---------------- | +| type | "BundleStatusChange" | Yes | Event type.| + +**Return value** + +| Type | Description | +| --------------- | ----------------------------------- | +| Promise\ | Promise used to return a successful result or error information.| + +## innerBundleManager.getAllLauncherAbilityInfos + +getAllLauncherAbilityInfos(userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; + +Obtains the information about all launcher abilities. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| callback | AsyncCallback\> | Yes | Callback used to return an array of the launcher ability information. | + +## innerBundleManager.getAllLauncherAbilityInfos + +getAllLauncherAbilityInfos(userId: number) : Promise<Array<LauncherAbilityInfo>> + +Obtains the information about all launcher abilities. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------ | ------ | ---- | ----------------------------------------------------- | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ------------------------- | +| Promise\> | Promise used to return an array of the launcher ability information.| + +## innerBundleManager.getShortcutInfos + +getShortcutInfos(bundleName :string, callback: AsyncCallback<Array<ShortcutInfo>>) : void; + +Obtains the shortcut information based on a given bundle name. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ---------------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| callback | AsyncCallback\> | Yes | Callback used to return an array of the shortcut information.| + +## innerBundleManager.getShortcutInfos + +getShortcutInfos(bundleName : string) : Promise<Array<ShortcutInfo>> + +Obtains the shortcut information based on a given bundle name. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------ | +| bundleName | string | Yes | Bundle name of an application.| + +**Return value** + +| Type | Description | +| -------------------------------------------------------- | ----------------------------- | +| Promise\> | Promise used to return an array of the shortcut information.| diff --git a/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md b/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md new file mode 100644 index 0000000000000000000000000000000000000000..f321aca70ed972845f73ca702501e574aeafe5e0 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md @@ -0,0 +1,139 @@ +# distributedBundle + +The **distributedBundle** module manages distributed bundles. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import distributedBundle from '@ohos.distributedBundle'; +``` + +## System Capability + +SystemCapability.BundleManager.DistributedBundleFramework + +## Required Permissions + +| Permission | Permission Level | Description | +| ------------------------------------------ | ------------ | ------------------ | +| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all applications.| + +For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback<RemoteAbilityInfo>): void; + +Obtains information about the remote ability that matches the given element name. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.DistributedBundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | **ElementName**. | +| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Yes | Callback used to return the remote ability information.| + + + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName): Promise<RemoteAbilityInfo> + +Obtains information about the remote ability that matches the given element name. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.DistributedBundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | -------------------------------------------- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | **ElementName**.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Promise used to return the remote ability information.| + +## distributedBundle.getRemoteAbilityInfos + +getRemoteAbilityInfos(elementNames: Array<ElementName>, callback: AsyncCallback<Array<RemoteAbilityInfo>>): void; + +Obtains information about remote abilities that match the given element names. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.DistributedBundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | +| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return an array of the remote ability information.| + + + +## distributedBundle.getRemoteAbilityInfos + +getRemoteAbilityInfos(elementNames: Array<ElementName>): Promise<Array<RemoteAbilityInfo>> + +Obtains information about remote abilities that match the given element names. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.DistributedBundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------------------------- | ---- | ----------------------- | +| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\> | Promise used to return an array of the remote ability information.| diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index 94d93df6aa2f25bfce6b2094cfe06a88429df346..e487baedfd496a9ac0a6e90332aa99f3323a4fc2 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -39,11 +39,11 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ------ | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of an application. | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name of an application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** @@ -81,12 +81,12 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ------------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of an application. | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | -| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name of an application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | **Example** @@ -119,11 +119,11 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ------------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of an application. | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name of an application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).| +| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | **Example** @@ -155,10 +155,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ---------- | ---- | --------------------------------------- | -| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| Name | Type | Mandatory| Description | +| ---------- | ---------- | ---- | ------------------------------------------------------------ | +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** @@ -195,10 +195,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | --------------------------------- | ---- | --------------------------------------- | -| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| +| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | **Example** @@ -229,11 +229,11 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | --------------------------------- | ---- | --------------------------------------- | -| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | -| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | **Example** @@ -268,7 +268,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------------- | ---- | --------------------------------------- | | bundleName | string | Yes | Bundle name of an application. | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| | options | [BundleOptions](#bundleoptions) | No | Includes **userId**. | **Return value** @@ -309,11 +309,11 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | -------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of an application. | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. | +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name of an application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| +| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. | **Example** @@ -346,12 +346,12 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | -------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of an application. | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| options | [BundleOptions](#bundleoptions) | Yes | Includes **userId**. | -| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. | +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name of an application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| +| options | [BundleOptions](#bundleoptions) | Yes | Includes **userId**. | +| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. | **Example** @@ -847,10 +847,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ------ | ---- | --------------------------------------- | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ------------------------------------------------------------ | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** @@ -889,11 +889,11 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | -------------------------------------- | ---- | --------------------------------------- | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | -| callback | AsyncCallback> | Yes | Callback used to return the application information. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the application information. | **Example** @@ -926,10 +926,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | -------------------------------------- | ---- | --------------------------------------- | -| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| callback | AsyncCallback> | Yes | Callback used to return the application information. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).| +| callback | AsyncCallback> | Yes | Callback used to return the application information. | **Example** @@ -959,7 +959,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ------ | ---- | ------------ | | hapFilePath | string | Yes | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.| -| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| **Return value** | Type | Description | @@ -994,7 +994,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ------ | ---- | ------------ | | hapFilePath | string | Yes | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.| -| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).| | callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the information about the bundles.| **Example** @@ -1474,7 +1474,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ------------------------------------- | | want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).| | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** @@ -1518,12 +1518,12 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ---------------------------------- | ---- | ------------------------------------- | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | -| callback | AsyncCallback> | Yes | Callback used to return the ability information. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the ability information. | **Example** @@ -1559,11 +1559,11 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ---------------------------------- | ---- | ------------------------------------- | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| -| callback | AsyncCallback> | Yes | Callback used to return the ability information. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).| +| callback | AsyncCallback> | Yes | Callback used to return the ability information. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index ce415ad942510c481755380bdd90adb7eb1c75ae..c432f719593a2aa3f32db509b339b2cc783ea5b4 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -4,8 +4,7 @@ The **Context** module provides context for abilities or applications. It allows > **NOTE** > -> The initial APIs of this module are supported since API version 6. 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 6. 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 FA model. ## Usage @@ -30,9 +29,9 @@ If this API is called for the first time, a root directory will be created. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the local root directory.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the local root directory.| **Example** @@ -58,8 +57,8 @@ If this API is called for the first time, a root directory will be created. **Return value** -| Type | Description | -| ---------------- | ---------------------- | +| Type | Description | +| ---------------- | ----------- | | Promise\ | Promise used to return the local root directory.| **Example** @@ -84,11 +83,11 @@ Verifies whether a specific PID and UID have the given permission. This API uses **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | --------------------------------------- | ---- | ------------------------------------- | -| permission | string | Yes | Name of the permission to verify. | -| options | [PermissionOptions](#permissionoptions) | Yes | Permission options. | -| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| +| Name | Type | Mandatory | Description | +| ---------- | --------------------------------------- | ---- | -------------------- | +| permission | string | Yes | Name of the permission to verify. | +| options | [PermissionOptions](#permissionoptions) | Yes | Permission options. | +| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| **Example** @@ -113,10 +112,10 @@ Verifies whether the current PID and UID have the given permission. This API use **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ---------------------- | ---- | ------------------------------------- | -| permission | string | Yes | Name of the permission to verify. | -| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| +| Name | Type | Mandatory | Description | +| ---------- | ---------------------- | ---- | -------------------- | +| permission | string | Yes | Name of the permission to verify. | +| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| **Example** @@ -136,15 +135,15 @@ Verifies whether a specific PID and UID have the given permission. This API uses **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | --------------------------------------- | ---- | ---------------- | -| permission | string | Yes | Name of the permission to verify.| -| options | [PermissionOptions](#permissionoptions) | No | Permission options. | +| Name | Type | Mandatory | Description | +| ---------- | --------------------------------------- | ---- | -------- | +| permission | string | Yes | Name of the permission to verify.| +| options | [PermissionOptions](#permissionoptions) | No | Permission options. | **Return value** -| Type | Description | -| ---------------- | ----------------------------------------------------------- | +| Type | Description | +| ---------------- | ---------------------------------- | | Promise\ | Promise used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| **Example** @@ -171,11 +170,11 @@ Requests certain permissions from the system. This API uses an asynchronous call **Parameters** -| Name | Type | Mandatory| Description | -| -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| permissions | Array\ | Yes | Permissions to request. This parameter cannot be **null**. | -| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.| -| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. | +| Name | Type | Mandatory | Description | +| -------------- | ---------------------------------------- | ---- | ----------------------------------- | +| permissions | Array\ | Yes | Permissions to request. This parameter cannot be **null**. | +| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.| +| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. | **Example** @@ -207,9 +206,9 @@ Obtains information about the current application. This API uses an asynchronous **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------- | ---- | ------------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the application information.| +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | ---- | ------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the application information.| **Example** @@ -231,8 +230,8 @@ Obtains information about the current application. This API uses a promise to re **Return value** -| Type | Description | -| ------------------------- | ------------------ | +| Type | Description | +| ------------------------- | --------- | | Promise\ | Promise used to return the application information.| **Example** @@ -258,9 +257,9 @@ Obtains the bundle name of this ability. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ----------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** @@ -282,8 +281,8 @@ Obtains the bundle name of this ability. This API uses a promise to return the r **Return value** -| Type | Description | -| ---------------- | ------------------------- | +| Type | Description | +| ---------------- | ---------------- | | Promise\ | Promise used to return the bundle name.| **Example** @@ -307,9 +306,9 @@ Obtains the display orientation of this ability. This API uses an asynchronous c **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ----------------------------- | -| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Yes | Callback used to return the display orientation.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------ | +| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Yes | Callback used to return the display orientation.| **Example** @@ -329,9 +328,9 @@ Obtains the display orientation of this ability. This API uses a promise to retu **Return value** -| Type | Description | -| ---------------- | ------------------------- | -| Promise\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Promise used to return the display orientation.| +| Type | Description | +| ---------------------------------------- | --------- | +| Promise\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Promise used to return the display orientation.| **Example** @@ -348,16 +347,16 @@ context.getDisplayOrientation().then((data) => { setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback\): void -Obtains the display orientation for this ability. This API uses an asynchronous callback to return the result. +Sets the display orientation for this ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ----------------------------- | -| orientation | [bundle.DisplayOrientation](js-apis-bundle.md#displayorientation) | Yes | Display orientation to set.| -| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Yes | Callback used to return the display orientation.| +| Name | Type | Mandatory | Description | +| ----------- | ---------------------------------------- | ---- | ------------ | +| orientation | [bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation) | Yes | Display orientation to set.| +| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Yes | Callback used to return the display orientation. | **Example** @@ -375,16 +374,16 @@ context.setDisplayOrientation(orientation, (err) => { setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\; -Obtains the display orientation for this ability. This API uses a promise to return the result. +Sets the display orientation for this ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Return value** -| Type | Description | -| ---------------- | ------------------------- | -| orientation | [bundle.DisplayOrientation](js-apis-bundle.md#displayorientation) | Yes | Display orientation to set.| -| Promise\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Promise used to return the display orientation.| +| Type | Description | +| ---------------------------------------- | ---------------------------------------- | +| orientation | [bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation) | +| Promise\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Promise used to return the display orientation. | **Example** @@ -403,16 +402,16 @@ context.setDisplayOrientation(orientation).then((data) => { setShowOnLockScreen(show: boolean, callback: AsyncCallback\): void -Sets whether to show this feature at the top of the lock screen each time the lock screen is displayed so that the feature remains activated. This API uses an asynchronous callback to return the result. +Sets whether to show this feature at the top of the lock screen so that the feature remains activated. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ----------------------------- | -| show | boolean | Yes | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ---------------------------------------- | +| show | boolean | Yes | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -429,21 +428,21 @@ context.setShowOnLockScreen(show, (err) => { setShowOnLockScreen(show: boolean): Promise\; -Sets whether to show this feature at the top of the lock screen each time the lock screen is displayed so that the feature remains activated. This API uses a promise to return the result. +Sets whether to show this feature at the top of the lock screen so that the feature remains activated. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ----------------------------- | -| show | boolean | Yes | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.| +| Name | Type | Mandatory | Description | +| ---- | ------- | ---- | ---------------------------------------- | +| show | boolean | Yes | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.| **Return value** -| Type | Description | -| ---------------- | ------------------------- | -| Promise\| Promise used to return the result.| +| Type | Description | +| -------------- | --------------- | +| Promise\ | Promise used to return the result.| **Example** @@ -467,10 +466,10 @@ Sets whether to wake up the screen when this feature is restored. This API uses **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ----------------------------- | -| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | --------------------------------- | +| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -493,15 +492,15 @@ Sets whether to wake up the screen when this feature is restored. This API uses **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ----------------------------- | -| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| +| Name | Type | Mandatory | Description | +| ------ | ------- | ---- | --------------------------------- | +| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| **Return value** -| Type | Description | -| ---------------- | ------------------------- | -| Promise\| Promise used to return the result.| +| Type | Description | +| -------------- | --------------- | +| Promise\ | Promise used to return the result.| **Example** @@ -528,9 +527,9 @@ Obtains information about the current process, including the PID and process nam **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the process information.| +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ---------- | +| callback | AsyncCallback\ | Yes | Callback used to return the process information.| **Example** @@ -552,8 +551,8 @@ Obtains information about the current process, including the PID and process nam **Return value** -| Type | Description | -| --------------------- | -------------- | +| Type | Description | +| --------------------- | ------- | | Promise\ | Promise used to return the process information.| **Example** @@ -581,9 +580,9 @@ This API is available only to Page abilities. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------- | ---- | ---------------------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the **ohos.bundle.ElementName** object.| +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the **ohos.bundle.ElementName** object.| **Example** @@ -607,8 +606,8 @@ This API is available only to Page abilities. **Return value** -| Type | Description | -| --------------------- | ------------------------------------------ | +| Type | Description | +| --------------------- | ------------------------------------ | | Promise\ | Promise used to return the **ohos.bundle.ElementName** object.| **Example** @@ -632,9 +631,9 @@ Obtains the name of the current process. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the process name.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ---------- | +| callback | AsyncCallback\ | Yes | Callback used to return the process name.| **Example** @@ -656,8 +655,8 @@ Obtains the name of the current process. This API uses a promise to return the r **Return value** -| Type | Description | -| ---------------- | -------------------- | +| Type | Description | +| ---------------- | ---------- | | Promise\ | Promise used to return the process name.| **Example** @@ -683,9 +682,9 @@ Obtains the bundle name of the calling ability. This API uses an asynchronous ca **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** @@ -707,8 +706,8 @@ Obtains the bundle name of the calling ability. This API uses a promise to retur **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------- | -------------- | | Promise\ | Promise used to return the bundle name.| **Example** @@ -732,9 +731,9 @@ Obtains the cache directory of the application in the internal storage. This API **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the cache directory.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | --------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the cache directory.| **Example** @@ -760,8 +759,8 @@ Obtains the cache directory of the application in the internal storage. This API **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------- | --------------- | | Promise\ | Promise used to return the cache directory.| **Example** @@ -785,9 +784,9 @@ Obtains the file directory of the application in the internal storage. This API **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the file directory.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the file directory.| **Example** @@ -813,8 +812,8 @@ Obtains the file directory of the application in the internal storage. This API **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------- | ------------------- | | Promise\ | Promise used to return the file directory.| **Example** @@ -840,9 +839,9 @@ If the distributed file path does not exist, the system will create one and retu **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.| **Example** @@ -870,8 +869,8 @@ If the distributed file path does not exist, the system will create one and retu **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------- | ----------------------------------- | | Promise\ | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created.| **Example** @@ -894,9 +893,9 @@ Obtains the application type. This API uses an asynchronous callback to return t **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the application type.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | -------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the application type.| **Example** @@ -922,8 +921,8 @@ Obtains the application type. This API uses a promise to return the result. **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------- | ------------------ | | Promise\ | Promise used to return the application type.| **Example** @@ -946,9 +945,9 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes | Callback used to return the **ModuleInfo** object.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| callback | AsyncCallback\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes | Callback used to return the **ModuleInfo** object.| **Example** @@ -974,8 +973,8 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------------------------------- | ------------------ | | Promise\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Promise used to return the **ModuleInfo** object.| **Example** @@ -998,9 +997,9 @@ Obtains the version information of this application. This API uses an asynchrono **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.| **Example** @@ -1026,8 +1025,8 @@ Obtains the version information of this application. This API uses a promise to **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------------------------------- | --------- | | Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.| **Example** @@ -1050,9 +1049,9 @@ Obtains information about this ability. This API uses an asynchronous callback t **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | Callback used to return the ability information.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | Callback used to return the ability information.| **Example** @@ -1078,8 +1077,8 @@ Obtains information about this ability. This API uses a promise to return the re **Return value** -| Type | Description | -| --------------- | ------------------------- | +| Type | Description | +| ---------------------------------------- | ------------------ | | Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.| **Example** @@ -1102,9 +1101,9 @@ Obtains the context of the application. **Return value** -| Type | Description | -| --------- |------ | -| Context | Application context.| +| Type | Description | +| ------- | ---------- | +| Context | Application context.| **Example** @@ -1117,15 +1116,15 @@ var context = featureAbility.getContext().getApplicationContext(); isUpdatingConfigurations(callback: AsyncCallback\): void; -Checks whether the configuration of this ability is being changed. This API uses an asynchronous callback to return the result. +Checks whether the configuration of this ability is being updated. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Returns **true** if the configuration of the capability is being changed; returns **false** otherwise.| +| Name | Type | Mandatory | Description | +| -------- | ----------------------- | ---- | ----------------------------- | +| callback | AsyncCallback\ | Yes | Returns **true** if the configuration of the capability is being updated; returns **false** otherwise.| **Example** @@ -1145,15 +1144,15 @@ context.isUpdatingConfigurations((err, data) => { isUpdatingConfigurations(): Promise\; -Checks whether the configuration of this ability is being changed. This API uses a promise to return the result. +Checks whether the configuration of this ability is being updated. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Return value** -| Type | Description | -| --------------- | ------------------------- | -|Promise\ | Returns **true** if the configuration of the capability is being changed; returns **false** otherwise.| +| Type | Description | +| ----------------- | ----------------------------- | +| Promise\ | Returns **true** if the configuration of the capability is being updated; returns **false** otherwise.| **Example** @@ -1175,9 +1174,9 @@ Notifies the system of the time required to draw this page function. This API us **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ----------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -1203,9 +1202,9 @@ Notifies the system of the time required to draw this page function. This API us **Return value** -| Type | Description | -| --------------- | ------------------------- | -|Promise\ | Promise used to return the result.| +| Type | Description | +| -------------- | --------------- | +| Promise\ | Promise used to return the result.| **Example** @@ -1222,27 +1221,27 @@ context.printDrawnCompleted().then((data) => { **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Readable/Writable| Type | Mandatory| Description | -| ---- | -------- | ------ | ---- | ------ | -| pid | Read-only | number | No | Process ID.| -| uid | Read-only | number | No | User ID.| +| Name | Readable/Writable| Type | Mandatory | Description | +| ---- | ---- | ------ | ---- | ----- | +| pid | Read-only | number | No | Process ID.| +| uid | Read-only | number | No | User ID.| ## PermissionRequestResult7+ **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Readable/Writable| Type | Mandatory| Description | -| ----------- | -------- | -------------- | ---- | ------------------ | -| requestCode | Read-only | number | Yes | Request code passed.| -| permissions | Read-only | Array\ | Yes | Permissions requested. | -| authResults | Read-only | Array\ | Yes | Permission request result. | +| Name | Readable/Writable| Type | Mandatory | Description | +| ----------- | ---- | -------------- | ---- | ---------- | +| requestCode | Read-only | number | Yes | Request code passed.| +| permissions | Read-only | Array\ | Yes | Permissions requested. | +| authResults | Read-only | Array\ | Yes | Permission request result. | ## AppVersionInfo7+ **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Type| Readable | Writable | Description| -| ------ | ------ | ------| ------ | ------ | -| appName | string | Yes | No | Module name. | -| versionCode | number | Yes | No | Module description. | -| versionName | string | Yes | No | Module description ID. | +| Name | Type | Readable | Writable | Description | +| ----------- | ------ | ---- | ---- | ------- | +| appName | string | Yes | No | Module name. | +| versionCode | number | Yes | No | Module description.| +| versionName | string | Yes | No | Module description ID.| diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md index e2333a523a918e229c6a35c4e341df9383bfb26a..cd4e27214b3617970071bcfb8e4e5b1c76bc2a2c 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -2,7 +2,7 @@ The **AbilityContext** module, inherited from **Context**, implements the context for abilities. -This module provides APIs for accessing ability-specific resources. You can use the APIs to start and terminate an ability, obtain the caller interface, and request permissions from users by displaying a pop-up window. +This module provides APIs for accessing ability-specific resources. You can use the APIs to start and terminate an ability, obtain the caller interface, and request permissions from users by displaying a dialog box. > **NOTE** > @@ -40,13 +40,11 @@ Starts an ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -**System API**: This is a system API and cannot be called by third-party applications. - **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -71,13 +69,11 @@ Starts an ability with start options specified. This API uses an asynchronous ca **System capability**: SystemCapability.Ability.AbilityRuntime.Core -**System API**: This is a system API and cannot be called by third-party applications. - **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| @@ -106,13 +102,11 @@ Starts an ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -**System API**: This is a system API and cannot be called by third-party applications. - **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| **Return value** @@ -153,7 +147,7 @@ Starts an ability. This API uses an asynchronous callback to return the result w | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want |[Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| @@ -181,7 +175,7 @@ Starts an ability with start options specified. This API uses an asynchronous ca | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want |[Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| @@ -214,7 +208,7 @@ Starts an ability. This API uses a promise to return the result when the ability | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| @@ -239,7 +233,7 @@ Starts an ability. This API uses a promise to return the result when the ability ## AbilityContext.startAbilityForResultWithAccount -startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; +startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void; Starts an ability. This API uses an asynchronous callback to return the result when the account of the ability is destroyed. @@ -253,8 +247,8 @@ Starts an ability. This API uses an asynchronous callback to return the result w | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -289,8 +283,8 @@ Starts an ability with start options specified. This API uses an asynchronous ca | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| @@ -312,7 +306,7 @@ Starts an ability with start options specified. This API uses an asynchronous ca ``` - ## AbilityContext.startAbilityForResultWithAccount +## AbilityContext.startAbilityForResultWithAccount startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\; @@ -328,8 +322,8 @@ Starts an ability with start options specified. This API uses a promise to retur | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| **Return value** @@ -358,7 +352,271 @@ Starts an ability with start options specified. This API uses a promise to retur console.log('---------- startAbilityForResultWithAccount fail, err: -----------', err); }) ``` +## AbilityContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; + +Starts a new Service Extension ability. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want, (err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## AbilityContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want): Promise\; + +Starts a new Service Extension ability. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want) + .then((data) => { + console.log('---------- startServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }) + ``` +## AbilityContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void; + +Starts a new Service Extension ability with the account ID specified. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## AbilityContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\; + +Starts a new Service Extension ability with the account ID specified. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` +## AbilityContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; + +Stops a Service Extension ability in the same application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want, (err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## AbilityContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want): Promise\; + +Stops a Service Extension ability in the same application. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want) + .then((data) => { + console.log('---------- stopServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }) + ``` + +## AbilityContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void; + +Stops a Service Extension ability in the same application with the account ID specified. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## AbilityContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\; + +Stops a Service Extension ability in the same application with the account ID specified. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` ## AbilityContext.terminateSelf @@ -412,7 +670,7 @@ Terminates this ability. This API uses a promise to return the result. terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; -Terminates this ability. This API uses an asynchronous callback to return the information to the caller of **startAbilityForResult**. +Terminates this ability. This API uses an asynchronous callback to return the ability result information. It is used together with **startAbilityForResult**. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -426,11 +684,17 @@ Terminates this ability. This API uses an asynchronous callback to return the in **Example** ```js - this.context.terminateSelfWithResult( - { - want: {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo"}, - resultCode: 100 - }, (error) => { + var want = { + "bundleName": "com.extreme.myapplication", + "abilityName": "SecondAbility" + } + var resultCode = 100; + // AbilityResult information returned to the caller. + var abilityResult = { + want, + resultCode + } + this.context.terminateSelfWithResult(abilityResult, (error) => { console.log("terminateSelfWithResult is called = " + error.code) } ); @@ -441,7 +705,7 @@ Terminates this ability. This API uses an asynchronous callback to return the in terminateSelfWithResult(parameter: AbilityResult): Promise<void>; -Terminates this ability. This API uses a promise to return information to the caller of **startAbilityForResult**. +Terminates this ability. This API uses a promise to return the ability result information. It is used together with **startAbilityForResult**. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -460,11 +724,17 @@ Terminates this ability. This API uses a promise to return information to the ca **Example** ```js - this.context.terminateSelfWithResult( - { - want: {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo"}, - resultCode: 100 - }).then((result) => { + var want = { + "bundleName": "com.extreme.myapplication", + "abilityName": "SecondAbility" + } + var resultCode = 100; + // AbilityResult information returned to the caller. + var abilityResult = { + want, + resultCode + } + this.context.terminateSelfWithResult(abilityResult).then((result) => { console.log("terminateSelfWithResult") } ) @@ -484,8 +754,8 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | No| Remote object instance.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | No| Parameters for the connection.| **Return value** @@ -515,7 +785,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; -Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect this ability to another ability. +Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect this ability to another ability with the account ID specified. **Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS @@ -527,8 +797,8 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | No| Parameters for the connection.| **Return value** @@ -618,7 +888,7 @@ Disconnects a connection. This API uses an asynchronous callback to return the r startAbilityByCall(want: Want): Promise<Caller>; -Obtains the caller interface of the specified ability, and if the specified ability is not started, starts the ability in the background. +Starts an ability in the foreground or background and obtains the caller interface for communication with the ability. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -626,7 +896,7 @@ Obtains the caller interface of the specified ability, and if the specified abil | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including **abilityName**, **moduleName**, **bundleName**, **deviceId** (optional), and **parameters** (optional). If **deviceId** is left blank or null, the local ability is started. If **parameters** is left blank or null, the ability is started in the background.| **Return value** @@ -637,22 +907,40 @@ Obtains the caller interface of the specified ability, and if the specified abil **Example** ```js - import Ability from '@ohos.application.Ability'; - var caller; - export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" - }).then((obj) => { - caller = obj; - console.log('Caller GetCaller Get ' + caller); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); + let caller = undefined; + + // Start an ability in the background without passing parameters. + var wantBackground = { + bundleName: "com.example.myservice", + moduleName: "entry", + abilityName: "MainAbility", + deviceId: "" + }; + this.context.startAbilityByCall(wantBackground) + .then((obj) => { + caller = obj; + console.log('GetCaller success'); + }).catch((error) => { + console.log(`GetCaller failed with ${error}`); + }); + + // Start an ability in the foreground with ohos.aafwk.param.callAbilityToForeground in parameters set to true. + var wantForeground = { + bundleName: "com.example.myservice", + moduleName: "entry", + abilityName: "MainAbility", + deviceId: "", + parameters: { + "ohos.aafwk.param.callAbilityToForeground": true } - } + }; + this.context.startAbilityByCall(wantForeground) + .then((obj) => { + caller = obj; + console.log('GetCaller success'); + }).catch((error) => { + console.log(`GetCaller failed with ${error}`); + }); ``` ## AbilityContext.startAbilityWithAccount @@ -671,8 +959,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -706,8 +994,8 @@ Starts an ability with the account ID and start options specified. This API uses | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| @@ -745,8 +1033,8 @@ Starts an ability with the account ID specified. This API uses a promise to retu | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| **Example** @@ -774,7 +1062,7 @@ Starts an ability with the account ID specified. This API uses a promise to retu requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; -Requests permissions from the user by displaying a pop-up window. This API uses an asynchronous callback to return the result. +Requests permissions from the user by displaying a dialog box. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -783,7 +1071,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | permissions | Array<string> | Yes| Permissions to request.| -| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the permission request result.| +| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result.| **Example** @@ -800,7 +1088,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses requestPermissionsFromUser(permissions: Array<string>) : Promise<PermissionRequestResult>; -Requests permissions from the user by displaying a pop-up window. This API uses a promise to return the result. +Requests permissions from the user by displaying a dialog box. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -814,7 +1102,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses | Type| Description| | -------- | -------- | -| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the permission request result.| +| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result.| **Example** @@ -1006,7 +1294,7 @@ Checks whether this ability is in the terminating state. | Type| Description| | -------- | -------- | -| bool | The value **true** means that the ability is in terminating state, and **false** means the opposite.| +| boolean| The value **true** means that the ability is in the terminating state, and **false** means the opposite.| **Example** 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 c2bb08c5314a44dcf6f4ad9246e6ee08a313ecd8..545da5d468feefce2440a356812356e6206e11e3 100644 --- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md +++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -1,6 +1,6 @@ # wantConstant -The **wantConstant** module provides the action, entity, and flags used in **Want** objects. +The **wantConstant** module provides the actions, entities, and flags used in **Want** objects. > **NOTE** > @@ -23,15 +23,15 @@ Enumerates the action constants of the **Want** object. | ACTION_HOME | ohos.want.action.home | Action of returning to the home page. | | ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. | | ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. | -| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides radio network settings, for example, Wi-Fi option. | +| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides wireless network settings, for example, Wi-Fi options. | | ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. | | ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. | | ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. | -| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all clock alarms. | +| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all alarms. | | ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. | | ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. | | ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. | -| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS. | +| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. | | ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. | | ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | Action of launching the UI for photographing. | | ACTION_VIDEO_CAPTURE8+ | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. | diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 2b17d252af9d09d5519f36ece4306834e8085c5a..003a5efd92057dc7127b74aa35553f3220bd890e 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -49,7 +49,7 @@ Checks whether an application has been granted the specified permission. This AP | Name | Type | Mandatory| Description | | -------- | ------------------- | ---- | ------------------------------------------ | -| tokenID | number | Yes | ID of the application. | +| tokenID | number | Yes | ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). | | permissionName | string | Yes | Name of the permission to verify.| **Return value** @@ -105,7 +105,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl Grants a user granted permission to an application. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +This is a system API. **Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS @@ -143,7 +143,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl Grants a user granted permission to an application. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +This is a system API. **Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS @@ -179,7 +179,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF Revokes a user granted permission given to an application. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +This is a system API. **Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS @@ -217,7 +217,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF Revokes a user granted permission given to an application. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +This is a system API. **Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS @@ -253,7 +253,7 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g Obtains the flags of the specified permission of a given application. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +This is a system API. **Required permissions**: ohos.permission.GET_SENSITIVE_PERMISSIONS, ohos.permission.GRANT_SENSITIVE_PERMISSIONS, or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md index f51fee8402c98f9c36e81f355df105a3154e0105..43786f3925b5277d3b806cf638ab7238fe40fd6b 100644 --- a/en/application-dev/reference/apis/js-apis-application-Want.md +++ b/en/application-dev/reference/apis/js-apis-application-Want.md @@ -23,23 +23,94 @@ import Want from '@ohos.application.Want'; | abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.| | uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. | -| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).| +| flags | Read only | number | No | How the **Want** object will be handled. For details, see [flags](js-apis-featureAbility.md#flags).| | action | Read only | string | No | Action option. | -| parameters | Read only | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
**ohos.aafwk.callerPid**: PID of the caller.
**ohos.aafwk.param.callerToken**: token of the caller.
**ohos.aafwk.param.callerUid**: UID of the caller. The **userId** parameter in the [Bundle](js-apis-Bundle.js) module can be used to obtain application and bundle information. | +| parameters | Read only | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
**ohos.aafwk.callerPid**: PID of the caller.
**ohos.aafwk.param.callerToken**: token of the caller.
**ohos.aafwk.param.callerUid**: UID of the caller. The **userId** parameter in the [Bundle](js-apis-Bundle.md) module can be used to obtain application and bundle information. | | entities | Read only | Array\ | No | List of entities. | | moduleName9+ | Read only | string | No | Module to which the ability belongs.| **Example** -``` js - var want = { - "deviceId": "", // An empty deviceId indicates the local device. - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry" // moduleName is optional. - }; - this.context.startAbility(want, (error) => { - // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters uniquely identify an ability. - console.log("error.code = " + error.code) - }) -``` +- Basic usage + + ``` js + var want = { + "deviceId": "", // An empty deviceId indicates the local device. + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleName is optional. + }; + this.context.startAbility(want, (error) => { + // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. + console.log("error.code = " + error.code) + }) + ``` + +- Passing a file descriptor (FD) + + ``` js + var fd; + try { + fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); + } catch(e) { + console.log("openSync fail:" + JSON.stringify(e)); + } + var want = { + "deviceId": "", // An empty deviceId indicates the local device. + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleName is optional. + "parameters": { + "keyFd":{"type":"FD", "value":fd} + } + }; + this.context.startAbility(want, (error) => { + // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. + console.log("error.code = " + error.code) + }) + ``` + +- Passing **RemoteObject** data + + ``` js + class Stub extends rpc.RemoteObject { + constructor(des) { + if (typeof des == 'string') { + super(des); + } else { + return null; + } + } + + onRemoteRequest(code, data, reply, option) { + if (code === 1) { + console.log('onRemoteRequest called') + let token = data.readInterfaceToken(); + let num = data.readInt(); + this.method(); + return true; + } + return false; + } + + method() { + console.log('method called'); + } + } + + var remoteObject = new Stub('want-test'); + var want = { + "deviceId": "", // An empty deviceId indicates the local device. + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleName is optional. + "parameters": { + "keyRemoteObject":{"type":"RemoteObject", "value":remoteObject} + } + }; + this.context.startAbility(want, (error) => { + // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. + console.log("error.code = " + error.code) + }) + ``` + \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md index 42974b5fd683af842146b53fec22022edca84de6..54264312fcc88ad0177473a7e4d256f566e6c2d2 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @@ -1,6 +1,6 @@ # AbilityLifecycleCallback -The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onAbilityWindowStageCreate**, and **onAbilityWindowStageDestroy**, to receive lifecycle state changes in the application context. +The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onWindowStageCreate**, and **onWindowStageDestroy**, to receive lifecycle state changes in the application context. > **NOTE** > @@ -30,9 +30,9 @@ Called when an ability is created. | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| -## AbilityLifecycleCallback.onAbilityWindowStageCreate +## AbilityLifecycleCallback.onWindowStageCreate -onAbilityWindowStageCreate(ability: Ability): void; +onWindowStageCreate(ability: Ability, windowStage: window.WindowStage): void; Called when the window stage of an ability is created. @@ -43,11 +43,44 @@ Called when the window stage of an ability is created. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| + | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.| -## AbilityLifecycleCallback.onAbilityWindowStageDestroy +## AbilityLifecycleCallback.onWindowStageActive -onAbilityWindowStageDestroy(ability: Ability): void; +onWindowStageActive(ability: Ability, windowStage: window.WindowStage): void; + +Called when the window stage of an ability gains focus. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| + | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.| + + +## AbilityLifecycleCallback.onWindowStageInactive + +onWindowStageInactive(ability: Ability, windowStage: window.WindowStage): void; + +Called when the window stage of an ability loses focus. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| + | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.| + + +## AbilityLifecycleCallback.onWindowStageDestroy + +onWindowStageDestroy(ability: Ability, windowStage: window.WindowStage): void; Called when the window stage of an ability is destroyed. @@ -58,6 +91,7 @@ Called when the window stage of an ability is destroyed. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| + | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.| ## AbilityLifecycleCallback.onAbilityDestroy @@ -132,12 +166,22 @@ Called when an ability is continued on another device. onAbilityCreate(ability){ console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); }, - onAbilityWindowStageCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability)); - }, - onAbilityWindowStageDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability)); - }, + onWindowStageCreate(ability, windowStage){ + console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability)); + console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage)); + }, + onWindowStageActive(ability, windowStage){ + console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability)); + console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage)); + }, + onWindowStageInactive(ability, windowStage){ + console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability)); + console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage)); + }, + onWindowStageDestroy(ability, windowStage){ + console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability)); + console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage)); + }, onAbilityDestroy(ability){ console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); }, diff --git a/en/application-dev/reference/apis/js-apis-application-context.md b/en/application-dev/reference/apis/js-apis-application-context.md index cf5291224477451554ea36e823ecedc0629cbfe0..16d5fd0c3d79d097bc8f78ef24cae8f91869b8e3 100644 --- a/en/application-dev/reference/apis/js-apis-application-context.md +++ b/en/application-dev/reference/apis/js-apis-application-context.md @@ -19,7 +19,7 @@ import AbilityContext from '@ohos.application.Ability' let context = this.context.createBundleContext(test); } } - ``` +``` ## Attributes @@ -53,15 +53,15 @@ Creates a context for a given application. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| bundleName | string | Yes| Application bundle name.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Application bundle name.| **Return value** -| Type| Description| -| -------- | -------- | -| Context | Context created.| + | Type| Description| + | -------- | -------- | + | Context | Context created.| **Example** @@ -87,15 +87,15 @@ Creates a context for a given HAP. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| moduleName | string | Yes| HAP name in the application.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | moduleName | string | Yes| HAP name in the application.| **Return value** -| Type| Description| -| -------- | -------- | -| Context | Context created.| + | Type| Description| + | -------- | -------- | + | Context | Context created.| **Example** @@ -123,16 +123,16 @@ Creates a context for a given HAP in an application. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| bundleName | string | Yes| Application bundle name.| -| moduleName | string | Yes| HAP name in the application.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Application bundle name.| + | moduleName | string | Yes| HAP name in the application.| **Return value** -| Type| Description| -| -------- | -------- | -| Context | Context created.| + | Type| Description| + | -------- | -------- | + | Context | Context created.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md index 05ff78e77e6d6d54527148782b18d0dbca007cd6..1b2bd22548deeed3145803c1a3939e59399b904c 100644 --- a/en/application-dev/reference/apis/js-apis-appmanager.md +++ b/en/application-dev/reference/apis/js-apis-appmanager.md @@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a **Return value** - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API **Return value** - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t **Return value** - | Type| Description| - | -------- | -------- | - | Promise<number> | Size of the application memory.| +| Type| Description| +| -------- | -------- | +| Promise<number> | Size of the application memory.| **Example** @@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | No| Size of the application memory.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<number> | No| Size of the application memory.| **Example** @@ -155,7 +155,11 @@ Obtains the memory size of this application. This API uses an asynchronous callb console.log('startAbility result success:' + JSON.stringify(data)); }) ``` -## appManager.getProcessRunningInfos8+ +## appManager.getProcessRunningInfos(deprecated) + +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation9+](#appmanagergetprocessrunninginformation9) instead. getProcessRunningInfos(): Promise\>; @@ -181,7 +185,11 @@ Obtains information about the running processes. This API uses a promise to retu }); ``` -## appManager.getProcessRunningInfos8+ +## appManager.getProcessRunningInfos(deprecated) + +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation9+](#appmanagergetprocessrunninginformation9-1) instead. getProcessRunningInfos(callback: AsyncCallback\>): void; @@ -206,11 +214,62 @@ Obtains information about the running processes. This API uses an asynchronous c }) ``` +## appManager.getProcessRunningInformation9+ + +getProcessRunningInformation(): Promise\>; + +Obtains information about the running processes. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_RUNNING_INFO + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise\> | Promise used to return the process information.| + +**Example** + + ```js + app.getProcessRunningInformation().then((data) => { + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); + ``` + +## appManager.getProcessRunningInformation9+ + +getProcessRunningInformation(callback: AsyncCallback\>): void; + +Obtains information about the running processes. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_RUNNING_INFO + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback\> | No| Callback used to return the process information.| + +**Example** + + ```js + app.getProcessRunningInformation((err, data) => { + console.log('startAbility result failed :' + JSON.stringify(err)); + console.log('startAbility result success:' + JSON.stringify(data)); + }) + ``` + ## appManager.registerApplicationStateObserver8+ registerApplicationStateObserver(observer: ApplicationStateObserver): number; -Registers the application state observer. +Registers an observer to listen for the state of all applications. **Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER @@ -222,7 +281,7 @@ Registers the application state observer. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| observer | ApplicationStateObserver | No| Numeric code of the observer.| +| observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.| **Example** @@ -244,6 +303,48 @@ Registers the application state observer. const observerCode = app.registerApplicationStateObserver(applicationStateObserver); console.log('-------- observerCode: ---------', observerCode); + ``` + +## appManager.registerApplicationStateObserver9+ + +registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array): number; + +Registers an observer to listen for the state of a specified application. + +**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.| +| bundleNameList | Array | No| **bundleName** array to be registered for listening. The maximum value is 128.| + +**Example** + + ```js + var applicationStateObserver = { + onForegroundApplicationChanged(appStateData) { + console.log('------------ onForegroundApplicationChanged -----------', appStateData); + }, + onAbilityStateChanged(abilityStateData) { + console.log('------------ onAbilityStateChanged -----------', abilityStateData); + }, + onProcessCreated(processData) { + console.log('------------ onProcessCreated -----------', processData); + }, + onProcessDied(processData) { + console.log('------------ onProcessDied -----------', processData); + } + } + var bundleNameList = ['bundleName1', 'bundleName2']; + const observerCode = app.registerApplicationStateObserver(applicationStateObserver, bundleNameList); + console.log('-------- observerCode: ---------', observerCode); + ``` ## appManager.unregisterApplicationStateObserver8+ @@ -258,7 +359,7 @@ Deregisters the application state observer. This API uses an asynchronous callba **System API**: This is a system API and cannot be called by third-party applications. **Parameters** - + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | observerId | number | No| Numeric code of the observer.| @@ -319,7 +420,7 @@ Deregisters the application state observer. This API uses a promise to return th getForegroundApplications(callback: AsyncCallback\>): void; -Obtains applications that run in the foreground. This API uses an asynchronous callback to return the result. +Obtains applications that are running in the foreground. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_RUNNING_INFO @@ -350,7 +451,7 @@ Obtains applications that run in the foreground. This API uses an asynchronous c getForegroundApplications(): Promise\>; -Obtains applications that run in the foreground. This API uses a promise to return the result. +Obtains applications that are running in the foreground. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_RUNNING_INFO @@ -380,7 +481,7 @@ Obtains applications that run in the foreground. This API uses a promise to retu killProcessWithAccount(bundleName: string, accountId: number): Promise\ -Kills the process by bundle name and account ID. This API uses a promise to return the result. +Kills a process by bundle name and account ID. This API uses a promise to return the result. **Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES @@ -390,10 +491,10 @@ Kills the process by bundle name and account ID. This API uses a promise to retu **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | bundleName | string | Yes| Bundle name of an application.| - | accountId | number | Yes| Account ID.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | Yes| Bundle name of an application.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| **Example** @@ -414,7 +515,7 @@ app.killProcessWithAccount(bundleName, accountId) killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback\): void -Kills the process by bundle name and account ID. This API uses an asynchronous callback to return the result. +Kills a process by bundle name and account ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -424,11 +525,11 @@ Kills the process by bundle name and account ID. This API uses an asynchronous c **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | bundleName | string | Yes| Bundle name of an application.| - | accountId | number | Yes| Account ID.| - | callback | AsyncCallback\ | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | Yes| Bundle name of an application.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -708,7 +809,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); | bundleName8+ | string | Yes | No | Bundle name of an application. | | abilityName8+ | string | Yes | No | Ability name. | | uid8+ | number | Yes | No | User ID. | -| state8+ | number | Yes | No | Application information. | +| state8+ | number | Yes | No | Ability state. | | moduleName9+ | string | Yes | No | Name of the HAP file to which the ability belongs. | | abilityType8+ | string | Yes | No | Ability type. | @@ -736,3 +837,16 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); | uid9+ | Read only | number | No | User ID.| | processName9+ | Read only | string | No | Process name.| | bundleNames9+ | Read only | Array\ | No | **bundleName** array in the running processes.| + +## ApplicationStateObserver + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Readable| Writable| Description | +| ----------------------- | ---------| ---- | ---- | ------------------------- | +| [onForegroundApplicationChanged8+](#applicationstateobserveronforegroundapplicationchanged8) | AsyncCallback\ | Yes | No | Callback invoked when the foreground or background state of an application changes. | +| [onAbilityStateChanged8+](#applicationstateobserveronabilitystatechanged8) | AsyncCallback\ | Yes | No | Callback invoked when the ability state changes. | +| [onProcessCreated8+](#applicationstateobserveronprocesscreated8) | AsyncCallback\ | Yes | No | Callback invoked when a process is created. | +| [onProcessDied8+](#applicationstateobserveronprocessdied8) | AsyncCallback\ | Yes | No | Callback invoked when a process is destroyed. | diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md index cbb0ff47c767fd26e499913f44ba88d7e6187f17..67b4a955e1cfe2d9bd557cc47fdc938b010a8de6 100644 --- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -1,6 +1,6 @@ -# BackgroundTaskManager +# Background Task Management -This module provides background task management. +The **BackgroundTaskManager** module provides APIs to manage background tasks. If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task or continuous task for delayed suspension based on the service type. @@ -15,7 +15,7 @@ If an application has a service that can be intuitively perceived by users and n ## Modules to Import -``` +```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; ``` @@ -144,12 +144,12 @@ Requests a continuous task from the system. This API uses an asynchronous callba **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ---------------------------------- | ---- | ------------------------ | -| context | [Context](js-apis-Context.md) | Yes | Application context. | -| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | -| wantAgent | [WantAgent](js-apis-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. | +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------- | ---- | ---------------------------------------- | +| context | Context | Yes | Application context.
For the application context of the FA model, see [Context](js-apis-Context.md).
For the application context of the stage model, see [Context](js-apis-ability-context.md).| +| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | +| wantAgent | [WantAgent](js-apis-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. | **Example** ```js @@ -196,11 +196,11 @@ Requests a continuous task from the system. This API uses a promise to return th **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ---------------------------------- | ---- | ----------------------- | -| context | [Context](js-apis-Context.md) | Yes | Application context. | -| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | -| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.| +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------- | ---- | ---------------------------------------- | +| context | Context | Yes | Application context.
For the application context of the FA model, see [Context](js-apis-Context.md).
For the application context of the stage model, see [Context](js-apis-ability-context.md).| +| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | **Return value** | Type | Description | @@ -245,10 +245,10 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------------- | ---- | ---------------------- | -| context | [Context](js-apis-Context.md) | Yes | Application context. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ---------------------------------------- | +| context | Context | Yes | Application context.
For the application context of the FA model, see [Context](js-apis-Context.md).
For the application context of the stage model, see [Context](js-apis-ability-context.md).| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js @@ -276,9 +276,9 @@ Requests to cancel a continuous task. This API uses a promise to return the resu **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------------------------- | ---- | --------- | -| context | [Context](js-apis-Context.md) | Yes | Application context.| +| Name | Type | Mandatory | Description | +| ------- | ------- | ---- | ---------------------------------------- | +| context | Context | Yes | Application context.
For the application context of the FA model, see [Context](js-apis-Context.md).
For the application context of the stage model, see [Context](js-apis-ability-context.md).| **Return value** | Type | Description | @@ -314,14 +314,14 @@ Provides the information about the suspension delay. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| Name | Value| Description | -| ----------------------- | ------ | ------------------------------------------------------------ | -| DATA_TRANSFER | 1 | Data transfer. | -| AUDIO_PLAYBACK | 2 | Audio playback. | -| AUDIO_RECORDING | 3 | Audio recording. | -| LOCATION | 4 | Positioning and navigation. | -| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | -| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | -| WIFI_INTERACTION | 7 | WLAN-related.
This is a system API and cannot be called by third-party applications.| -| VOIP | 8 | Audio and video calls.
This is a system API and cannot be called by third-party applications.| -| TASK_KEEPING | 9 | Computing task (effective only for specific devices). | +| Name | Value | Description | +| ----------------------- | ---- | --------------------- | +| DATA_TRANSFER | 1 | Data transfer. | +| AUDIO_PLAYBACK | 2 | Audio playback. | +| AUDIO_RECORDING | 3 | Audio recording. | +| LOCATION | 4 | Positioning and navigation. | +| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | +| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | +| WIFI_INTERACTION | 7 | WLAN-related.
This is a system API.| +| VOIP | 8 | Audio and video calls.
This is a system API. | +| TASK_KEEPING | 9 | Computing task (effective only for specific devices). | diff --git a/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md index 74ba45c52450241572aff5ab9cba2a55debd9124..3cb5f2792733b4ad88914023b7debb7354fa74b4 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md @@ -1,16 +1,11 @@ # AbilityInfo - +Unless otherwise specified, ability information is obtained through **GET_BUNDLE_DEFAULT**. > **NOTE** -> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. - - -Provides the ability information. - - +## AbilityInfo **System capability**: SystemCapability.BundleManager.BundleFramework @@ -25,24 +20,24 @@ Provides the ability information. | iconId | number | Yes | No | Ability icon ID. | | moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. | | process | string | Yes | No | Process in which the ability runs. If this parameter is not set, the bundle name is used.| -| targetAbility | string | Yes | No | Target ability that the ability alias points to. | -| backgroundModes | number | Yes | No | Background service mode of the ability. | +| targetAbility | string | Yes | No | Target ability that the ability alias points to.
This attribute can be used only in the FA model.| +| backgroundModes | number | Yes | No | Background service mode of the ability.
This attribute can be used only in the FA model. | | isVisible | boolean | Yes | No | Whether the ability can be called by other applications. | -| formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability. | -| type | AbilityType | Yes | No | Ability type. | +| formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability.
This attribute can be used only in the FA model.| +| type | AbilityType | Yes | No | Ability type.
This attribute can be used only in the FA model. | | orientation | DisplayOrientation | Yes | No | Ability display orientation. | | launchMode | LaunchMode | Yes | No | Ability launch mode. | -| permissions | Array\ | Yes | No | Permissions required for other applications to call the ability.| +| permissions | Array\ | Yes | No | Permissions required for other applications to call the ability.
The value is obtained by passing **GET_ABILITY_INFO_WITH_PERMISSION**.| | deviceTypes | Array\ | Yes | No | Device types supported by the ability. | | deviceCapabilities | Array\ | Yes | No | Device capabilities required for the ability. | -| readPermission | string | Yes | No | Permission required for reading the ability data. | -| writePermission | string | Yes | No | Permission required for writing data to the ability. | -| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information. | -| uri | string | Yes | No | URI of the ability. | +| readPermission | string | Yes | No | Permission required for reading the ability data.
This attribute can be used only in the FA model.| +| writePermission | string | Yes | No | Permission required for writing data to the ability.
This attribute can be used only in the FA model.| +| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information.
The value is obtained by passing **GET_ABILITY_INFO_WITH_APPLICATION**.| +| uri | string | Yes | No | URI of the ability.
This attribute can be used only in the FA model.| | labelId | number | Yes | No | Ability label ID. | -| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. | -| metaData8+ | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | Yes | No | Custom metadata of the ability. | -| metadata9+ | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability. | +| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability.
This attribute can be used only in the FA model.| +| metaData8+ | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | Yes | No | Custom metadata of the ability.
The value is obtained by passing **GET_ABILITY_INFO_WITH_METADATA**.| +| metadata9+ | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability.
The value is obtained by passing **GET_ABILITY_INFO_WITH_METADATA**.| | enabled8+ | boolean | Yes | No | Whether the ability is enabled. | | supportWindowMode9+ | Array\<[SupportWindowMode](js-apis-Bundle.md)> | Yes | No | Window modes supported by the ability. | | maxWindowRatio9+ | number | Yes | No | Maximum window ratio supported by the ability. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md new file mode 100644 index 0000000000000000000000000000000000000000..7c86528db55ea364316caaa927b29a90f88b253c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @@ -0,0 +1,100 @@ +# BundleInstaller + +The **BundleInstaller** module provides APIs for installing, updating, and deleting bundles on devices. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## System Capability + +SystemCapability.BundleManager.BundleFramework + +## BundleInstaller.install + +install(bundleFilePaths: Array<string>, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; + +Installs bundles. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| bundleFilePaths | Array<string> | Yes | Paths where the bundles are stored. Each path should point to a relative directory of the current application's data directory.| +| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | Yes | Callback used to return the installation status. | + +## BundleInstaller.uninstall + +uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; + +Uninstalls a bundle. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | Yes | Callback used to return the installation status.| + +## BundleInstaller.recover + +recover(bundleName: string, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; + +Recovers a bundle. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | Yes | Callback used to return the installation status.| + +## InstallParam + +Describes the parameters required for bundle installation or uninstall. + + **System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Description | +| ----------- | ------- | ------------------ | +| userId | number | User ID. | +| installFlag | number | Installation flag. | +| isKeepData | boolean | Whether data is kept.| + +## InstallStatus + +Describes the bundle installation status. + + **System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Readable| Writable| Description | +| ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ | +| status | bundle.[InstallErrorCode](js-apis-Bundle.md#installerrorcode) | Yes | No | Installation or uninstall error code. | +| statusMessage | string | Yes | No | Installation or uninstall status message.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-ElementName.md b/en/application-dev/reference/apis/js-apis-bundle-ElementName.md index ede83cd6de76637220005f0821471c0141c9721f..205c9f15192c4c2c9abfcb08b1f1ae156d7baf75 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ElementName.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ElementName.md @@ -1,14 +1,14 @@ # ElementName +The **ElementName** module provides the element name information. + > **NOTE** > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -Provides the element name information. - ## ElementName - **System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework | Name | Type | Readable| Writable| Description | | ----------------------- | ---------| ---- | ---- | ------------------------- | diff --git a/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..7b932cacbc2195e8c52976aa80e71bd3b638921d --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md @@ -0,0 +1,20 @@ +# LauncherAbilityInfo + +The **LauncherAbilityInfo** module provides information about a launcher ability. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## LauncherAbilityInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Readable| Writable| Description | +| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ | +| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the launcher ability.| +| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | No | Element name of the launcher ability. | +| labelId | number | Yes | No | Label ID of the launcher ability. | +| iconId | number | Yes | No | Icon ID of the launcher ability. | +| userId | number | Yes | No | User ID of the launcher ability. | +| installTime | number | Yes | No | Time when the launcher ability is installed. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-PermissionDef.md b/en/application-dev/reference/apis/js-apis-bundle-PermissionDef.md new file mode 100644 index 0000000000000000000000000000000000000000..4ebc8d40516c596de2977ea19583e019cce2ac1f --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundle-PermissionDef.md @@ -0,0 +1,19 @@ +# PermissionDef + +The **PermissionDef** module provides permission details defined in the configuration file. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## **PermissionDef** + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Readable| Writable| Description | +| -------------- | ------ | ---- | ---- | -------------- | +| permissionName | string | Yes | No | Name of the permission. | +| grantMode | number | Yes | No | Grant mode of the permission.| +| labelId | number | Yes | No | Label ID of the permission. | +| descriptionId | number | Yes | No | Description ID of the permission. | + diff --git a/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..8b2cf350047aa0d4c8e165b71b030f3816f6f75f --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md @@ -0,0 +1,41 @@ +# ShortcutInfo + +The **ShortcutInfo** module provides shortcut information defined in the configuration file. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## ShortcutWant + +Describes the information about the target to which the shortcut points. + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Readable| Writable| Description | +| ------------------------- | ------ | ---- | ---- | -------------------- | +| targetBundle | string | Yes | No | Target bundle of the shortcut.| +| targetModule9+ | string | Yes | No | Target module of the shortcut. | +| targetClass | string | Yes | No | Target class required by the shortcut.| + +## ShortcutInfo + +Describes the shortcut attribute information. + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Readable| Writable| Description | +| ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- | +| id | string | Yes | No | ID of the application to which the shortcut belongs. | +| bundleName | string | Yes | No | Name of the bundle that contains the shortcut. | +| hostAbility | string | Yes | No | Local ability information of the shortcut. | +| icon | string | Yes | No | Icon of the shortcut. | +| iconId8+ | number | Yes | No | Icon ID of the shortcut. | +| label | string | Yes | No | Label of the shortcut. | +| labelId8+ | number | Yes | No | Label ID of the shortcut. | +| disableMessage | string | Yes | No | Message displayed when the shortcut is disabled. | +| wants | Array<[ShortcutWant](#shortcutwant)> | Yes | No | Want information required for the shortcut. | +| isStatic | boolean | Yes | No | Whether the shortcut is static. | +| isHomeShortcut | boolean | Yes | No | Whether the shortcut is a home shortcut.| +| isEnabled | boolean | Yes | No | Whether the shortcut is enabled. | +| moduleName9+ | string | Yes | No | Module name of the shortcut. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..4210ac52230c5e86855c8afacd7c442999efdea6 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md @@ -0,0 +1,17 @@ +# RemoteAbilityInfo + +The **RemoteAbilityInfo** module provides information about a remote ability. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## RemoteAbilityInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Readable| Writable| Description | +| ----------- | -------------------------------------------- | ---- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | No | Element name of the ability. | +| label | string | Yes | No | Label of the ability. | +| icon | string | Yes | No | Icon of the ability.| diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 381796969cdc260896b9ea4857d0461eebf7d519..79ad744268f719cf6c9c24310e27e91c00ae9630 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -1327,7 +1327,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | | slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | -| callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.

- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| +| callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.

- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| **Example** @@ -2743,13 +2743,13 @@ Defines the dialup options. **System capability**: SystemCapability.Telephony.CallManager -| Name | Type | Mandatory| Description | -| ---------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| extras | boolean | No | Indication of a video call.
- **true**: video call
- **false** (default): voice call| -| accountId | number | No | Account ID. This API is supported since API version 8. It is a system API. | -| videoState | [VideoStateType](#videostatetype7) | No | Video state type. This API is supported since API version 8. It is a system API. | -| dialScene | [DialScene](#dialscene8) | No | Dialup scenario. This API is supported since API version 8. It is a system API. | -| dialType | [DialType](#dialtype8) | No | Dialup type. This API is supported since API version 8. It is a system API. | +| Name | Type | Mandatory| Description | +| ------------------------ | ---------------------------------- | ---- | ------------------------------------------------------------ | +| extras | boolean | No | Indication of a video call.
- **true**: video call
- **false** (default): voice call| +| accountId 8+ | number | No | Account ID. This is a system API. | +| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. | +| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. | +| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. | ## CallState diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index fac4104f5cb135b5c5afa45127cdbd488a9a6225..410bfd51d89defc480e3d4dde2da2a351b1fbd24 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -30,7 +30,7 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to ```js camera.getCameraManager(context, (err, cameraManager) => { if (err) { - console.error('Failed to get the CameraManager instance ${err.message}'); + console.error(`Failed to get the CameraManager instance ${err.message}`); return; } console.log('Callback returned with the CameraManager instance'); @@ -146,10 +146,10 @@ Obtains supported cameras. This API uses an asynchronous callback to return the ```js cameraManager.getSupportedCameras((err, cameras) => { if (err) { - console.error('Failed to get the cameras. ${err.message}'); + console.error(`Failed to get the cameras. ${err.message}`); return; } - console.log('Callback returned with an array of supported cameras: ' + cameras.length); + console.log(`Callback returned with an array of supported cameras: ${cameras.length}`); }) ``` @@ -172,7 +172,7 @@ Obtains supported cameras. This API uses a promise to return the result. ```js cameraManager.getSupportedCameras().then((cameraArray) => { - console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); + console.log(`Promise returned with an array of supported cameras: ${cameraArray.length}`); }) ``` @@ -188,7 +188,7 @@ Obtains the output capability supported by a camera. This API uses an asynchrono | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ---------------------------------- | -| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object. | +| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object. | | callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | Yes | Callback used to return the output capability.| **Example** @@ -196,7 +196,7 @@ Obtains the output capability supported by a camera. This API uses an asynchrono ```js cameraManager.getSupportedOutputCapability(cameraDevice, (err, cameras) => { if (err) { - console.error('Failed to get the cameras. ${err.message}'); + console.error(`Failed to get the cameras. ${err.message}`); return; } console.log('Callback returned with an array of supported outputCapability'); @@ -215,7 +215,7 @@ Obtains the output capability supported by a camera. This API uses a promise to | Name | Type | Mandatory| Description | | ------ | ----------------------------- | ---- | ------------------ | -| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object.| +| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.| **Return value** @@ -251,7 +251,7 @@ Obtains the metadata information supported by this camera. This API uses an asyn ```js cameraManager.getSupportedMetadataObjectType((err, metadataobject) => { if (err) { - console.error('Failed to get the supported metadataObjectType. ${err.message}'); + console.error(`Failed to get the supported metadataObjectType. ${err.message}`); return; } console.log('Callback returned with an array of supported metadataObjectType.' ); @@ -300,7 +300,7 @@ Checks whether this camera is muted. This API uses an asynchronous callback to r ```js cameraManager.isCameraMuted((err, status) => { if (err) { - console.error('Failed to get the cameraMuted status. ${err.message}'); + console.error(`Failed to get the cameraMuted status. ${err.message}`); return; } console.log('Callback returned with cameraMuted status'); @@ -353,7 +353,7 @@ This is a system API. ```js cameraManager.isCameraMuteSupported((err, status) => { if (err) { - console.error('Failed to get the cameraMuteSupported. ${err.message}'); + console.error(`Failed to get the cameraMuteSupported. ${err.message}`); return; } console.log('Callback returned with the status whether cameraMuteSupported.'); @@ -411,7 +411,7 @@ This is a system API. ```js cameraManager.muteCamera(isMuted, (err) => { if (err) { - console.error('Failed to mute the camera. ${err.message}'); + console.error(`Failed to mute the camera. ${err.message}`); return; } console.log('Callback returned with the muteCamera.'); @@ -467,7 +467,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------- | ---- | ----------------------------------- | -| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object. | +| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object. | | callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.| **Example** @@ -475,7 +475,7 @@ This is a system API. ```js cameraManager.createCameraInput(camera, (err, cameraInput) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error(`Failed to create the CameraInput instance. ${err.message}`); return; } console.log('Callback returned with the CameraInput instance.'); @@ -498,7 +498,7 @@ This is a system API. | Name | Type | Mandatory| Description | | ------ | ----------------------------- | ---- | ------------------ | -| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object.| +| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.| **Return value** @@ -539,7 +539,7 @@ This is a system API. ```js cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error(`Failed to create the CameraInput instance. ${err.message}`); return; } console.log('Callback returned with the CameraInput instance'); @@ -600,7 +600,7 @@ Creates a **PreviewOutput** instance. This API uses an asynchronous callback to ```js cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => { if (err) { - console.error('Failed to gcreate previewOutput. ${err.message}'); + console.error(`Failed to gcreate previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput created.'); @@ -656,7 +656,7 @@ Creates a **PreviewOutput** instance without a surface ID. This API uses an asyn ```js cameraManager.createDeferredPreviewOutput(profile, (err, previewoutput) => { if (err) { - console.error('Failed to create deferredPreviewOutput. ${err.message}'); + console.error(`Failed to create deferredPreviewOutput. ${err.message}`); return; } console.log('Callback returned with deferredPreviewOutput created.'); @@ -712,7 +712,7 @@ Creates a **PhotoOutput** instance. This API uses an asynchronous callback to re ```js cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => { if (err) { - console.error('Failed to create photoOutput. ${err.message}'); + console.error(`Failed to create photoOutput. ${err.message}`); return; } console.log('Callback returned with photoOutput created.'); @@ -769,7 +769,7 @@ Creates a **VideoOutput** instance. This API uses an asynchronous callback to re ```js cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => { if (err) { - console.error('Failed to create videoOutput. ${err.message}'); + console.error(`Failed to create videoOutput. ${err.message}`); return; } console.log('Callback returned with an array of supported outputCapability' ); @@ -825,7 +825,7 @@ Creates a **MetadataOutput** instance. This API uses an asynchronous callback to ```js cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataoutput) => { if (err) { - console.error('Failed to create metadataOutput. ${err.message}'); + console.error(`Failed to create metadataOutput. ${err.message}`); return; } console.log('Callback returned with metadataOutput created.'); @@ -879,7 +879,7 @@ Creates a **CaptureSession** instance. This API uses an asynchronous callback to ```js cameraManager.createCaptureSession((err, capturesession) => { if (err) { - console.error('Failed to create captureSession. ${err.message}'); + console.error(`Failed to create captureSession. ${err.message}`); return; } console.log('Callback returned with captureSession created.'); @@ -928,11 +928,11 @@ Listens for camera status changes. This API uses an asynchronous callback to ret ```js cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { if (err) { - console.error('Failed to get cameraStatus callback. ${err.message}'); + console.error(`Failed to get cameraStatus callback. ${err.message}`); return; } - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); + console.log(`camera : ${cameraStatusInfo.camera.cameraId}`); + console.log(`status: ${cameraStatusInfo.status}`); }) ``` @@ -960,10 +960,10 @@ This is a system API. ```js cameraManager.on('cameraMute', (err, status) => { if (err) { - console.error('Failed to get cameraMute callback. ${err.message}'); + console.error(`Failed to get cameraMute callback. ${err.message}`); return; } - console.log('status: ' + status); + console.log(`status: ${status}`); }) ``` @@ -975,7 +975,7 @@ Describes the camera status information. | Name | Type | Description | | ------ | ----------------------------- | ---------- | -| camera | [CameraDevice](#cameraDevice) | Camera object.| +| camera | [CameraDevice](#cameradevice) | Camera object.| | status | [CameraStatus](#camerastatus) | Camera status.| ## CameraPosition @@ -1033,13 +1033,13 @@ Defines the camera device information. ```js async function getCameraInfo("cameraId") { - var cameraManager = await camera.getCameraManager(context); - var cameras = await cameraManager.getSupportedCameras(); - var cameraObj = cameras[0]; - var cameraId = cameraObj.cameraId; - var cameraPosition = cameraObj.cameraPosition; - var cameraType = cameraObj.cameraType; - var connectionType = cameraObj.connectionType; + let cameraManager = await camera.getCameraManager(context); + let cameras = await cameraManager.getSupportedCameras(); + let cameraObj = cameras[0]; + let cameraId = cameraObj.cameraId; + let cameraPosition = cameraObj.cameraPosition; + let cameraType = cameraObj.cameraType; + let connectionType = cameraObj.connectionType; } ``` @@ -1099,7 +1099,7 @@ Opens this camera. This API uses an asynchronous callback to return the result. ```js cameraInput.open((err) => { if (err) { - console.error('Failed to open the camera. ${err.message}'); + console.error(`Failed to open the camera. ${err.message}`); return; } console.log('Callback returned with camera opened.'); @@ -1147,7 +1147,7 @@ Closes this camera. This API uses an asynchronous callback to return the result. ```js cameraInput.close((err) => { if (err) { - console.error('Failed to close the cameras. ${err.message}'); + console.error(`Failed to close the cameras. ${err.message}`); return; } console.log('Callback returned with camera closed.'); @@ -1195,7 +1195,7 @@ Releases this camera. This API uses an asynchronous callback to return the resul ```js cameraInput.release((err) => { if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); + console.error(`Failed to release the CameraInput instance ${err.message}`); return; } console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); @@ -1243,7 +1243,7 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul ```js cameraInput.on('error', (cameraInputError) => { - console.log('Camera input error code: ' + cameraInputError.code); + console.log(`Camera input error code: ${cameraInputError.code}`); }) ``` @@ -1371,7 +1371,7 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn ```js captureSession.beginConfig((err) => { if (err) { - console.error('Failed to start the configuration. ${err.message}'); + console.error(`Failed to start the configuration. ${err.message}`); return; } console.log('Callback invoked to indicate the begin config success.'); @@ -1420,7 +1420,7 @@ Commits the configuration for this **CaptureSession** instance. This API uses an ```js captureSession.commitConfig((err) => { if (err) { - console.error('Failed to commit the configuration. ${err.message}'); + console.error(`Failed to commit the configuration. ${err.message}`); return; } console.log('Callback invoked to indicate the commit config success.'); @@ -1469,7 +1469,7 @@ Checks whether a **[CameraInput](#camerainput)** instance can be added to this * ```js captureSession.canAddInput(cameraInput, (err, status) => { if (err) { - console.error('Can not add cameraInput. ${err.message}'); + console.error(`Can not add cameraInput. ${err.message}`); return; } console.log('Callback returned with cameraInput can added.'); @@ -1524,7 +1524,7 @@ Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This ```js captureSession.addInput(cameraInput, (err) => { if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); + console.error(`Failed to add the CameraInput instance. ${err.message}`); return; } console.log('Callback invoked to indicate that the CameraInput instance is added.'); @@ -1579,7 +1579,7 @@ Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. ```js captureSession.removeInput(cameraInput, (err) => { if (err) { - console.error('Failed to remove the CameraInput instance. ${err.message}'); + console.error(`Failed to remove the CameraInput instance. ${err.message}`); return; } console.log('Callback invoked to indicate that the cameraInput instance is removed.'); @@ -1626,7 +1626,7 @@ Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this | Name | Type | Mandatory| Description | | ------------ | ----------------------------- | ---- | ---------------------------- | -| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| +| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.| | callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1634,7 +1634,7 @@ Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this ```js captureSession.canAddOutput(cameraOutput, (err, status) => { if (err) { - console.error('Can not add cameraOutput. ${err.message}'); + console.error(`Can not add cameraOutput. ${err.message}`); return; } console.log('Callback returned with cameraOutput can added.'); @@ -1653,7 +1653,7 @@ Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this | Name | Type | Mandatory| Description | | ------------ | ----------------------------- | ---- | ---------------------------- | -| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| +| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.| **Return value** @@ -1683,7 +1683,7 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th | Name | Type | Mandatory| Description | | ------------ | ----------------------------- | ---- | ---------------------------- | -| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| +| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.| | callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1691,7 +1691,7 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th ```js captureSession.addOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to add output. ${err.message}'); + console.error(`Failed to add output. ${err.message}`); return; } console.log('Callback returned with output added.'); @@ -1710,7 +1710,7 @@ Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. Th | Name | Type | Mandatory| Description | | ------------ | ----------------------------- | ---- | ---------------------------- | -| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| +| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.| **Return value** @@ -1738,7 +1738,7 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession* | Name | Type | Mandatory| Description | | ------------ | ----------------------------- | ---- | ---------------------------- | -| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to remove.| +| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.| | callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1746,7 +1746,7 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession* ```js captureSession.removeOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to remove the CameraOutput instance. ${err.message}'); + console.error(`Failed to remove the CameraOutput instance. ${err.message}`); return; } console.log('Callback invoked to indicate that the CameraOutput instance is removed.'); @@ -1765,7 +1765,7 @@ Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession* | Name | Type | Mandatory| Description | | ------------ | ----------------------------- | ---- | ---------------------------- | -| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to remove.| +| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.| **Return value** @@ -1802,7 +1802,7 @@ Starts this **CaptureSession**. This API uses an asynchronous callback to return ```js captureSession.start((err) => { if (err) { - console.error('Failed to start the session ${err.message}'); + console.error(`Failed to start the session ${err.message}`); return; } console.log('Callback invoked to indicate the session start success.'); @@ -1850,7 +1850,7 @@ Stops this **CaptureSession**. This API uses an asynchronous callback to return ```js captureSession.stop((err) => { if (err) { - console.error('Failed to stop the session ${err.message}'); + console.error(`Failed to stop the session ${err.message}`); return; } console.log('Callback invoked to indicate the session stop success.'); @@ -1898,7 +1898,7 @@ Requests to exclusively control the hardware attributes **[CameraInput](#camerai ```js captureSession.lockForControl((err) => { if (err) { - console.error('Failed to lock. ${err.message}'); + console.error(`Failed to lock. ${err.message}`); return; } console.log('Locked.'); @@ -1946,7 +1946,7 @@ Releases the exclusive control on the device configuration. This API uses an asy ```js captureSession.unlockForControl((err) => { if (err) { - console.error('Failed to unlock. ${err.message}'); + console.error(`Failed to unlock. ${err.message}`); return; } console.log('Unlocked.'); @@ -1994,7 +1994,7 @@ Releases this **CaptureSession**. This API uses an asynchronous callback to retu ```js captureSession.release((err) => { if (err) { - console.error('Failed to release the CaptureSession instance ${err.message}'); + console.error(`Failed to release the CaptureSession instance ${err.message}`); return; } console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); @@ -2042,10 +2042,10 @@ Checks whether the device has flash light. This API uses an asynchronous callbac ```js cameraInput.hasFlash((err, status) => { if (err) { - console.error('Failed to check whether the device has flash light. ${err.message}'); + console.error(`Failed to check whether the device has flash light. ${err.message}`); return; } - console.log('Callback returned with flash light support status: ' + status); + console.log(`Callback returned with flash light support status: ${status}`); }) ``` @@ -2067,7 +2067,7 @@ Checks whether the device has flash light. This API uses a promise to return the ```js cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); + console.log(`Promise returned with the flash light support status: ${status}`); }) ``` @@ -2091,10 +2091,10 @@ Checks whether a specified flash mode is supported. This API uses an asynchronou ```js cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { if (err) { - console.error('Failed to check whether the flash mode is supported. ${err.message}'); + console.error(`Failed to check whether the flash mode is supported. ${err.message}`); return; } - console.log('Callback returned with the flash mode support status: ' + status); + console.log(`Callback returned with the flash mode support status: ${status}`); }) ``` @@ -2122,7 +2122,7 @@ Checks whether a specified flash mode is supported. This API uses a promise to r ```js cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { - console.log('Promise returned with flash mode support status.' + status); + console.log(`Promise returned with flash mode support status.${status}`); }) ``` @@ -2151,7 +2151,7 @@ Before the setting, do the following checks: ```js cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { if (err) { - console.error('Failed to set the flash mode ${err.message}'); + console.error(`Failed to set the flash mode ${err.message}`); return; } console.log('Callback returned with the successful execution of setFlashMode.'); @@ -2210,10 +2210,10 @@ Obtains the flash mode in use. This API uses an asynchronous callback to return ```js cameraInput.getFlashMode((err, flashMode) => { if (err) { - console.error('Failed to get the flash mode ${err.message}'); + console.error(`Failed to get the flash mode ${err.message}`); return; } - console.log('Callback returned with current flash mode: ' + flashMode); + console.log(`Callback returned with current flash mode: ${flashMode}`); }) ``` @@ -2235,7 +2235,7 @@ Obtains the flash mode in use. This API uses a promise to return the result. ```js cameraInput.getFlashMode().then((flashMode) => { - console.log('Promise returned with current flash mode : ' + flashMode); + console.log(`Promise returned with current flash mode : ${flashMode}`); }) ``` @@ -2259,7 +2259,7 @@ Checks whether a specified exposure mode is supported. This API uses an asynchro ```js cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { if (err) { - console.log('Failed to check exposure mode supported ${err.message}'); + console.log(`Failed to check exposure mode supported ${err.message}`); return ; } console.log('Callback returned with the successful excution of isExposureModeSupported'); @@ -2290,7 +2290,7 @@ Checks whether a specified exposure mode is supported. This API uses a promise t ```js cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { - console.log('Promise returned with exposure mode supported : ' + isSupported); + console.log(`Promise returned with exposure mode supported : ${isSupported}`); }) ``` @@ -2313,10 +2313,10 @@ Obtains the exposure mode in use. This API uses an asynchronous callback to retu ```js cameraInput.getExposureMode((err, exposureMode) => { if (err) { - console.log('Failed to get the exposure mode ${err.message}'); + console.log(`Failed to get the exposure mode ${err.message}`); return ; } - console.log('Callback returned with current exposure mode:' + exposureMode); + console.log(`Callback returned with current exposure mode: ${exposureMode}`); }) ``` @@ -2338,7 +2338,7 @@ Obtains the exposure mode in use. This API uses a promise to return the result. ```js cameraInput.getExposureMode().then((exposureMode) => { - console.log('Promise returned with current exposure mode : ' + exposureMode); + console.log(`Promise returned with current exposure mode : ${exposureMode}`); }) ``` @@ -2362,7 +2362,7 @@ Sets an exposure mode. This API uses an asynchronous callback to return the resu ```js cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { if (err) { - console.log('Failed to set the exposure mode ${err.message}'); + console.log(`Failed to set the exposure mode ${err.message}`); return ; } console.log('Callback returned with the successful excution of setExposureMode'); @@ -2410,10 +2410,10 @@ Obtains the center of the metering area. This API uses an asynchronous callback ```js cameraInput.getMeteringPoint((err, exposurePoint) => { if (err) { - console.log('Failed to get the current exposure point ${err.message}'); + console.log(`Failed to get the current exposure point ${err.message}`); return ; } - console.log('Callback returned with current exposure point:' + exposurePoint); + console.log(`Callback returned with current exposure point: ${exposurePoint}`); }) ``` @@ -2435,7 +2435,7 @@ Obtains the center of the metering area. This API uses a promise to return the r ```js cameraInput.getMeteringPoint().then((exposurePoint) => { - console.log('Promise returned with current exposure point : ' + exposurePoint); + console.log(`Promise returned with current exposure point : ${exposurePoint}`); }) ``` @@ -2457,11 +2457,11 @@ Sets the center of the metering area. This API uses an asynchronous callback to **Example** ```js -var Point1 = {x: 1, y: 1}; +const Point1 = {x: 1, y: 1}; cameraInput.setMeteringPoint(Point1,(err) => { if (err) { - console.log('Failed to set the exposure point ${err.message}'); + console.log(`Failed to set the exposure point ${err.message}`); return ; } console.log('Callback returned with the successful excution of setMeteringPoint'); @@ -2491,7 +2491,7 @@ Sets the center of the metering area. This API uses a promise to return the resu **Example** ```js -var Point2 = {x: 2, y: 2}; +const Point2 = {x: 2, y: 2}; cameraInput.setMeteringPoint(Point2).then(() => { console.log('Promise returned with the successful execution of setMeteringPoint'); @@ -2517,7 +2517,7 @@ Obtains the exposure compensation values. This API uses an asynchronous callback ```js cameraInput.getExposureBiasRange((err, biasRangeArray) => { if (err) { - console.log('Failed to get the array of compenstation range ${err.message}'); + console.log(`Failed to get the array of compenstation range ${err.message}`); return ; } console.log('Callback returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray)); @@ -2542,7 +2542,7 @@ Obtains the exposure compensation values. This API uses a promise to return the ```js cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { - console.log('Promise returned with exposure mode supported : ' + isSupported); + console.log(`Promise returned with exposure mode supported : ${isSupported}`); }) ``` @@ -2568,7 +2568,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure ```js cameraInput.setExposureBias(-4,(err) => { if (err) { - console.log('Failed to set the exposure bias ${err.message}'); + console.log(`Failed to set the exposure bias ${err.message}`); return ; } console.log('Callback returned with the successful excution of setExposureBias'); @@ -2624,10 +2624,10 @@ Obtains the exposure value in use. This API uses an asynchronous callback to ret ```js cameraInput.getExposureValue((err, exposureValue) => { if (err) { - console.log('Failed to get the exposure value ${err.message}'); + console.log(`Failed to get the exposure value ${err.message}`); return ; } - console.log('Callback returned with the exposure value: ' + exposureValue); + console.log(`Callback returned with the exposure value: ${exposureValue}`); }) ``` @@ -2649,7 +2649,7 @@ Obtains the exposure value in use. This API uses a promise to return the result. ```js cameraInput.getExposureValue().then((exposureValue) => { - console.log('Promise returned with exposure value: ' + exposureValue); + console.log(`Promise returned with exposure value: ${exposureValude}`); }) ``` @@ -2673,10 +2673,10 @@ Checks whether a specified focus mode is supported. This API uses an asynchronou ```js cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => { if (err) { - console.error('Failed to check whether the focus mode is supported. ${err.message}'); + console.error(`Failed to check whether the focus mode is supported. ${err.message}`); return; } - console.log('Callback returned with the focus mode support status: ' + status); + console.log(`Callback returned with the focus mode support status: ${status}`); }) ``` @@ -2704,7 +2704,7 @@ Checks whether a specified focus mode is supported. This API uses a promise to r ```js cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { - console.log('Promise returned with focus mode support status.' + status); + console.log(`Promise returned with focus mode support status ${status}.`); }) ``` @@ -2730,7 +2730,7 @@ Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to che ```js cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => { if (err) { - console.error('Failed to set the focus mode ${err.message}'); + console.error(`Failed to set the focus mode ${err.message}`); return; } console.log('Callback returned with the successful execution of setFocusMode.'); @@ -2786,10 +2786,10 @@ Obtains the focus mode in use. This API uses an asynchronous callback to return ```js cameraInput.getFocusMode((err, afMode) => { if (err) { - console.error('Failed to get the focus mode ${err.message}'); + console.error(`Failed to get the focus mode ${err.message}`); return; } - console.log('Callback returned with current focus mode: ' + afMode); + console.log(`Callback returned with current focus mode: ${afMode}`); }) ``` @@ -2811,7 +2811,7 @@ Obtains the focus mode in use. This API uses a promise to return the result. ```js cameraInput.getFocusMode().then((afMode) => { - console.log('Promise returned with current focus mode : ' + afMode); + console.log(`Promise returned with current focus mode : ${afMode}`); }) ``` @@ -2827,17 +2827,17 @@ Sets a focus point. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | -| point | [Point](#Point) | Yes | Focus point. | +| point | [Point](#point) | Yes | Focus point. | | callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -var Point1 = {x: 1, y: 1}; +const Point1 = {x: 1, y: 1}; cameraInput.setFocusPoint(Point1, (err) => { if (err) { - console.error('Failed to set the focus point ${err.message}'); + console.error(`Failed to set the focus point ${err.message}`); return; } console.log('Callback returned with the successful execution of setFocusPoint.'); @@ -2856,7 +2856,7 @@ Sets a focus point. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ----- | --------------- | ---- | ------ | -| point | [Point](#Point) | Yes | Focus point.| +| point | [Point](#point) | Yes | Focus point.| **Return value** @@ -2867,7 +2867,7 @@ Sets a focus point. This API uses a promise to return the result. **Example** ```js -var Point2 = {x: 2, y: 2}; +const Point2 = {x: 2, y: 2}; cameraInput.setFocusPoint(Point2).then(() => { console.log('Promise returned with the successful execution of setFocusPoint.'); @@ -2893,7 +2893,7 @@ Obtains the focus point. This API uses an asynchronous callback to return the re ```js cameraInput.getFocusPoint((err, point) => { if (err) { - console.error('Failed to get the current focus point ${err.message}'); + console.error(`Failed to get the current focus point ${err.message}`); return; } console.log('Callback returned with the current focus point: ' + JSON.stringify(point)); @@ -2941,10 +2941,10 @@ Obtains the focal length. This API uses an asynchronous callback to return the r ```js cameraInput.getFocalLength((err, focalLength) => { if (err) { - console.error('Failed to get the current focal length ${err.message}'); + console.error(`Failed to get the current focal length ${err.message}`); return; } - console.log('Callback returned with the current focal length: ' + focalLength); + console.log(`Callback returned with the current focal length: ${focalLength}`); }) ``` @@ -2966,7 +2966,7 @@ Obtains the focal length. This API uses a promise to return the result. ```js cameraInput.getFocalLength().then((focalLength) => { - console.log('Promise returned with the current focal length: ' + focalLength); + console.log(`Promise returned with the current focal length: ${focalLength}`); }) ``` @@ -2989,10 +2989,10 @@ Obtains the zoom range. This API uses an asynchronous callback to return the res ```js cameraInput.getZoomRatioRange((err, zoomRatioRange) => { if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); + console.error(`Failed to get the zoom ratio range. ${err.message}`); return; } - console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); + console.log(`Callback returned with zoom ratio range: ${zoomRatioRange.length}`); }) ``` @@ -3014,7 +3014,7 @@ Obtains the zoom range. This API uses a promise to return the result. ```js cameraInput.getZoomRatioRange().then((zoomRatioRange) => { - console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); + console.log(`Promise returned with zoom ratio range: ${zoomRatioRange.length}`); }) ``` @@ -3038,7 +3038,7 @@ Sets a zoom ratio. This API uses an asynchronous callback to return the result. ```js cameraInput.setZoomRatio(1, (err) => { if (err) { - console.error('Failed to set the zoom ratio value ${err.message}'); + console.error(`Failed to set the zoom ratio value ${err.message}`); return; } console.log('Callback returned with the successful execution of setZoomRatio.'); @@ -3092,10 +3092,10 @@ Obtains the zoom ratio in use. This API uses an asynchronous callback to return ```js cameraInput.getZoomRatio((err, zoomRatio) => { if (err) { - console.error('Failed to get the zoom ratio ${err.message}'); + console.error(`Failed to get the zoom ratio ${err.message}`); return; } - console.log('Callback returned with current zoom ratio: ' + zoomRatio); + console.log(`Callback returned with current zoom ratio: ${zoomRatio}`); }) ``` @@ -3117,7 +3117,7 @@ Obtains the zoom ratio in use. This API uses a promise to return the result. ```js cameraInput.getZoomRatio().then((zoomRatio) => { - console.log('Promise returned with current zoom ratio : ' + zoomRatio); + console.log(`Promise returned with current zoom ratio : ${zoomRatio}`); }) ``` @@ -3133,7 +3133,7 @@ Checks whether a specified video stabilization mode is supported. This API uses | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------------------------ | -| vsMode | [VideoStabilizationMode](#videostabilizationMode) | Yes | Video stabilization mode. | +| vsMode | [VideoStabilizationMode](#videostabilizationmode) | Yes | Video stabilization mode. | | callback | AsyncCallback | Yes | Callback used to return whether the video stabilization mode is supported. The value **true** means that the video stabilization mode is supported, and **false** means the opposite.| **Example** @@ -3141,10 +3141,10 @@ Checks whether a specified video stabilization mode is supported. This API uses ```js captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF, (err, isSupported) => { if (err) { - console.error('Failed to check whether video stabilization mode supported. ${err.message}'); + console.error(`Failed to check whether video stabilization mode supported. ${err.message}`); return; } - console.log('Callback returned with the successful execution of isVideoStabilizationModeSupported: ' + status); + console.log(`Callback returned with the successful execution of isVideoStabilizationModeSupported: ${status}`); }) ``` @@ -3166,7 +3166,7 @@ Checks whether a specified video stabilization mode is supported. This API uses ```js captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF).then((isSupported) => { - console.log('Promise returned with video stabilization mode supported: ' + isSupported); + console.log(`Promise returned with video stabilization mode supported: ${isSupported}`); }) ``` @@ -3189,7 +3189,7 @@ Obtains the video stabilization mode in use. This API uses an asynchronous callb ```js captureSession.getActiveVideoStabilizationMode((err, vsMode) => { if (err) { - console.error('Failed to get active video stabilization mode ${err.message}'); + console.error(`Failed to get active video stabilization mode ${err.message}`); return; } console.log('Callback returned with the successful execution of getActiveVideoStabilizationMode.'); @@ -3214,7 +3214,7 @@ Obtains the video stabilization mode in use. This API uses a promise to return t ```js captureSession.getActiveVideoStabilizationMode().then((vsMode) => { - console.log('Promise returned with the current video stabilization mode: ' + vsMode); + console.log(`Promise returned with the current video stabilization mode: ${vsMode}`); }) ``` @@ -3238,7 +3238,7 @@ Sets a video stabilization mode. This API uses an asynchronous callback to retur ```js captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF, (err) => { if (err) { - console.error('Failed to set the video stabilization mode ${err.message}'); + console.error(`Failed to set the video stabilization mode ${err.message}`); return; } console.log('Callback returned with the successful execution of setVideoStabilizationMode.'); @@ -3292,7 +3292,7 @@ Listens for focus state changes. This API uses an asynchronous callback to retur ```js cameraInput.on('focusStateChange', (focusState) => { - console.log('Focus state : ' + focusState); + console.log(`Focus state : ${focusState}`); }) ``` @@ -3309,13 +3309,13 @@ Listens for exposure state changes. This API uses an asynchronous callback to re | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ----------------------------------------------------------- | | type | string | Yes | Event type. The value is fixed at **'exposureStateChange'**, indicating the exposure state change event.| -| callback | AsyncCallback<[ExposureState](#exposureState)\> | Yes | Callback used to return the exposure state change. | +| callback | AsyncCallback<[ExposureState](#exposurestate)\> | Yes | Callback used to return the exposure state change. | **Example** ```js cameraInput.on('exposureStateChange', (exposureState) => { - console.log('Exposuer state : ' + exposureState); + console.log(`Exposuer state : ${exposureState}`); }) ``` @@ -3338,7 +3338,7 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er ```js captureSession.on('error', (captureSessionError) => { - console.log('Capture session error code: ' + captureSessionError.code); + console.log(`Capture session error code: ${captureSessionError.code}`); }) ``` @@ -3387,7 +3387,7 @@ Releases output resources. This API uses an asynchronous callback to return the ```js previewOutput.release((err) => { if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); + console.error(`Failed to release the PreviewOutput instance ${err.message}`); return; } console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); @@ -3440,7 +3440,7 @@ Adds a surface after a **PreviewOutput** instance is created. This API uses an a ```js previewOutput.addDeferredSurface('surfaceId', (err) => { if (err) { - console.error('Failed to add deferredSurface. ${err.message}'); + console.error(`Failed to add deferredSurface. ${err.message}`); return; } console.log('Callback returned with deferredSurface added.'); @@ -3494,7 +3494,7 @@ Starts to output preview streams. This API uses an asynchronous callback to retu ```js previewOutput.start((err) => { if (err) { - console.error('Failed to start the previewOutput. ${err.message}'); + console.error(`Failed to start the previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput started.'); @@ -3542,7 +3542,7 @@ Stops outputting preview streams. This API uses an asynchronous callback to retu ```js previewOutput.stop((err) => { if (err) { - console.error('Failed to stop the previewOutput. ${err.message}'); + console.error(`Failed to stop the previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput stoped.'); @@ -3636,7 +3636,7 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err ```js previewOutput.on('error', (previewOutputError) => { - console.log('Preview output error code: ' + previewOutputError.code); + console.log(`Preview output error code: ${previewOutputError.code}`); }) ``` @@ -3734,7 +3734,7 @@ Obtains the default shooting parameters. This API uses an asynchronous callback ```js photoOutput.getDefaultCaptureSetting((err, photocapturesetting) => { if (err) { - console.error('Failed to get the defaultCaptureSetting. ${err.message}'); + console.error(`Failed to get the defaultCaptureSetting. ${err.message}`); return; } console.log('Callback returned with an array of defaultCaptureSetting.'); @@ -3782,7 +3782,7 @@ Captures a photo with the default shooting parameters. This API uses an asynchro ```js photoOutput.capture((err) => { if (err) { - console.error('Failed to capture the photo ${err.message}'); + console.error(`Failed to capture the photo ${err.message}`); return; } console.log('Callback invoked to indicate the photo capture request success.'); @@ -3813,7 +3813,7 @@ let settings:PhotoCaptureSetting = { } photoOutput.capture(settings, (err) => { if (err) { - console.error('Failed to capture the photo ${err.message}'); + console.error(`Failed to capture the photo ${err.message}`); return; } console.log('Callback invoked to indicate the photo capture request success.'); @@ -3868,7 +3868,7 @@ Checks whether mirroring is supported. This API uses an asynchronous callback to ```js captureSession.isMirrorSupported((err, isSupported) => { if (err) { - console.error('Failed to check mirror is supported ${err.message}'); + console.error(`Failed to check mirror is supported ${err.message}`); return; } console.log('Callback returned with the successful execution of isMirrorSupported.'); @@ -3893,7 +3893,7 @@ Checks whether mirroring is supported. This API uses a promise to return the res ```js captureSession.isMirrorSupported().then((isSupported) => { - console.log('Promise returned with mirror supported: ' + isSupported); + console.log(`Promise returned with mirror supported: ${isSupported}`); }) ``` @@ -3916,7 +3916,7 @@ Listens for shooting start events. This API uses an asynchronous callback to ret ```js photoOutput.on('captureStart', (err, captureId) => { - console.log('photo capture stated, captureId : ' + captureId); + console.log(`photo capture stated, captureId : ${captureId}`); }) ``` @@ -3939,8 +3939,8 @@ Listens for frame shutter events. This API uses an asynchronous callback to retu ```js photoOutput.on('frameShutter', (err, frameShutterInfo) => { - console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); - console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); + console.log(`photo capture end, captureId : ${frameShutterInfo.captureId}`); + console.log(`Timestamp for frame : ${frameShutterInfo.timestamp}`); }) ``` @@ -3963,8 +3963,8 @@ Listens for shooting end events. This API uses an asynchronous callback to retur ```js photoOutput.on('captureEnd', (err, captureEndInfo) => { - console.log('photo capture end, captureId : ' + captureEndInfo.captureId); - console.log('frameCount : ' + captureEndInfo.frameCount); + console.log(`photo capture end, captureId : ${captureEndInfo.captureId}`); + console.log(`frameCount : ${captureEndInfo.frameCount}`); }) ``` @@ -3987,7 +3987,7 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error ```js photoOutput.on('error', (err, photoOutputError) => { - console.log('Photo output error code: ' + photoOutputError.code); + console.log(`Photo output error code: ${photoOutputError.code}`); }) ``` @@ -4059,7 +4059,7 @@ Starts video recording. This API uses an asynchronous callback to return the res ```js videoOutput.start((err) => { if (err) { - console.error('Failed to start the video output ${err.message}'); + console.error(`Failed to start the video output ${err.message}`); return; } console.log('Callback invoked to indicate the video output start success.'); @@ -4108,7 +4108,7 @@ Stops video recording. This API uses an asynchronous callback to return the resu ```js videoOutput.stop((err) => { if (err) { - console.error('Failed to stop the video output ${err.message}'); + console.error(`Failed to stop the video output ${err.message}`); return; } console.log('Callback invoked to indicate the video output stop success.'); @@ -4202,7 +4202,7 @@ Listens for errors that occur during video recording. This API uses a callback t ```js videoOutput.on('error', (VideoOutputError) => { - console.log('Video output error code: ' + VideoOutputError.code); + console.log(`Video output error code: ${VideoOutputError.code}`); }) ``` @@ -4266,14 +4266,14 @@ Obtains the metadata object type. This API uses an asynchronous callback to retu | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------ | -| callback | AsyncCallback<[MetadataObjectType](#metadataObjectType)\> | Yes | Callback used to return the result.| +| callback | AsyncCallback<[MetadataObjectType](#metadataobjecttype)\> | Yes | Callback used to return the result.| **Example** ```js metadataObject.getType((err, metadataObjectType) => { if (err) { - console.error('Failed to get type. ${err.message}'); + console.error(`Failed to get type. ${err.message}`); return; } console.log('Callback returned with an array of metadataObjectType.'); @@ -4292,7 +4292,7 @@ Obtains the metadata object type. This API uses a promise to return the result. | Type | Description | | --------------------------------------------------- | --------------------------- | -| Promise<[MetadataObjectType](#metadataObjectType)\> | Promise used to return the result.| +| Promise<[MetadataObjectType](#metadataobjecttype)\> | Promise used to return the result.| **Example** @@ -4321,7 +4321,7 @@ Obtains the metadata timestamp. This API uses an asynchronous callback to return ```js metadataObject.getTimestamp((err) => { if (err) { - console.error('Failed to get timestamp. ${err.message}'); + console.error(`Failed to get timestamp. ${err.message}`); return; } console.log('Callback returned with timestamp getted.'); @@ -4369,7 +4369,7 @@ Obtains the bounding box of metadata. This API uses an asynchronous callback to ```js metadataObject.getBoundingBox((err, rect) => { if (err) { - console.error('Failed to get boundingBox. ${err.message}'); + console.error(`Failed to get boundingBox. ${err.message}`); return; } console.log('Callback returned with boundingBox getted.'); @@ -4425,7 +4425,7 @@ Starts to output metadata. This API uses an asynchronous callback to return the ```js metadataOutput.start((err) => { if (err) { - console.error('Failed to start metadataOutput. ${err.message}'); + console.error(`Failed to start metadataOutput. ${err.message}`); return; } console.log('Callback returned with metadataOutput started.'); @@ -4473,7 +4473,7 @@ Stops outputting metadata. This API uses an asynchronous callback to return the ```js metadataOutput.stop((err) => { if (err) { - console.error('Failed to stop the metadataOutput. ${err.message}'); + console.error(`Failed to stop the metadataOutput. ${err.message}`); return; } console.log('Callback returned with metadataOutput stoped.'); @@ -4515,13 +4515,13 @@ Listens for metadata objects. This API uses an asynchronous callback to return t | Name | Type | Mandatory| Description | | -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**, that is, the metadata object.| -| callback | Callback\> | Yes | Callback used to return the error information. | +| callback | Callback\> | Yes | Callback used to return the error information. | **Example** ```js metadataOutput.on('metadataObjectsAvailable', (metadataObject) => { - console.log('metadata output error code: ' + metadataObject.code); + console.log(`metadata output error code: ${metadataObject.code}`); }) ``` @@ -4538,13 +4538,13 @@ Listens for metadata errors. This API uses an asynchronous callback to return th | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------ | ---- | --------------------------------------------- | | type | string | Yes | Event type. The value is fixed at **'error'**, that is, the metadata error.| -| callback | Callback<[MetadataOutputError](#metadataOutputError)\> | Yes | Callback used to return the error information. | +| callback | Callback<[MetadataOutputError](#metadataoutputerror)\> | Yes | Callback used to return the error information. | **Example** ```js metadataOutput.on('error', (metadataOutputError) => { - console.log('Metadata output error code: ' + metadataOutputError.code); + console.log(`Metadata output error code: ${metadataOutputError.code}`); }) ``` @@ -4567,4 +4567,4 @@ Defines a metadata output error. | Name| Type | Description | | ---- | --------------------------------------------------- | -------------------------- | -| code | [MetadataOutputErrorCode](#MetadataOutputErrorCode) | **MetadataOutput** error code.| +| code | [MetadataOutputErrorCode](#metadataoutputerrorcode) | **MetadataOutput** error code.| diff --git a/en/application-dev/reference/apis/js-apis-cardEmulation.md b/en/application-dev/reference/apis/js-apis-cardEmulation.md index 7c65ecbd616c0bd3ea8fb0c7f7b12a06b67533d4..9168a42e978c20caaface2523337d8c413a2296e 100644 --- a/en/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/en/application-dev/reference/apis/js-apis-cardEmulation.md @@ -1,9 +1,9 @@ # Standard NFC Card Emulation -The cardEmulation module implements Near-Field Communication (NFC) card emulation. +The **cardEmulation** module implements Near-Field Communication (NFC) card emulation. > **NOTE**
-> The initial APIs of this module are supported since API version 8. 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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -19,7 +19,7 @@ isSupported(feature: number): boolean Checks whether a certain type of card emulation is supported. -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** @@ -27,11 +27,11 @@ Checks whether a certain type of card emulation is supported. | -------- | -------- | | boolean | Returns **true** if the card emulation is supported; returns **false** otherwise.| -## HceService +## HceService8+ Implements Host-based Card Emulation (HCE). Before calling any API in **HceService**, you must use **new cardEmulation.HceService()** to create an **HceService** instance. -### startHCE +### startHCE8+ startHCE(aidList: string[]): boolean @@ -39,7 +39,7 @@ Starts HCE. **Required permissions**: ohos.permission.NFC_CARD_EMULATION -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Parameters** @@ -47,7 +47,7 @@ Starts HCE. | ------- | -------- | ---- | ----------------------- | | aidList | string[] | Yes | Application ID (AID) list to be registered for card emulation.| -### stopHCE +### stopHCE8+ stopHCE(): boolean @@ -55,9 +55,9 @@ Stops HCE. **Required permissions**: ohos.permission.NFC_CARD_EMULATION -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core -### on +### on8+ on(type: "hceCmd", callback: AsyncCallback): void; @@ -65,7 +65,7 @@ Subscribes to messages from the peer device after **startHCE()**. **Required permissions**: ohos.permission.NFC_CARD_EMULATION -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Parameters** @@ -74,7 +74,7 @@ Subscribes to messages from the peer device after **startHCE()**. | type | string | Yes | Event type to subscribe to. The value is **hceCmd**. | | callback | AsyncCallback | Yes | Callback invoked to return the subscribed event. The input parameter is a data array that complies with the Application Protocol Data Unit (APDU).| -### sendResponse +### sendResponse8+ sendResponse(responseApdu: number[]): void; @@ -82,7 +82,7 @@ Sends a response to the peer device. **Required permissions**: ohos.permission.NFC_CARD_EMULATION -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Parameters** diff --git a/en/application-dev/reference/apis/js-apis-connectedTag.md b/en/application-dev/reference/apis/js-apis-connectedTag.md index f351fb3148f0e216af608b6222b8c32a0805a3cb..57cf8eadb5a07bcd3038c67d4d582ab4359d2ea2 100644 --- a/en/application-dev/reference/apis/js-apis-connectedTag.md +++ b/en/application-dev/reference/apis/js-apis-connectedTag.md @@ -1,5 +1,7 @@ # Active Tag +The **connectedTag** module provides methods for using active tags. You can use the APIs provided by this module to initialize the active tag chip and read and write active tags. + > **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -22,9 +24,9 @@ Initializes the active tag chip. **System capability**: SystemCapability.Communication.ConnectedTag - Return value - | **Type** | **Description** | - | -------- | -------- | - | boolean | Returns **true** if the initialization is successful; returns **false** otherwise. | + | **Type**| **Description**| + | -------- | -------- | + | boolean | Returns **true** if the initialization is successful; returns **false** otherwise.| ## connectedTag.uninit @@ -38,9 +40,9 @@ Uninitializes the active tag resources. **System capability**: SystemCapability.Communication.ConnectedTag - Return value - | **Type** | **Description** | - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise. | + | **Type**| **Description**| + | -------- | -------- | + | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ## connectedTag.readNdefTag @@ -54,14 +56,14 @@ Reads the content of this active tag. This method uses a promise to return the r **System capability**: SystemCapability.Communication.ConnectedTag - Return value - | **Type** | **Description** | - | -------- | -------- | - | Promise<string> | Promise used to return the content of the active tag. | + | **Type**| **Description**| + | -------- | -------- | + | Promise<string> | Promise used to return the content of the active tag.| - Example ``` import connectedTag from '@ohos.connectedTag'; - + connectedTag.readNdefTag().then(result => { console.log("promise recv ndef response: " + result); }); @@ -78,9 +80,9 @@ Reads the content of this active tag. This method uses an asynchronous callback **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name** | **Type** | **Mandatory** | **Description** | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the active tag content obtained. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<string> | Yes| Callback invoked to return the active tag content obtained.| - Example ``` @@ -102,14 +104,14 @@ Writes data to this active tag. This method uses a promise to return the result. **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name** | **Type** | **Mandatory** | **Description** | - | -------- | -------- | -------- | -------- | - | data | string | Yes | Data to write. The maximum length is 1024 bytes. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | data | string | Yes| Data to write. The maximum length is 1024 bytes.| - Return value - | **Type** | **Description** | - | -------- | -------- | - | Promise<void> | Promise used to return the result. This method returns no value. | + | **Type**| **Description**| + | -------- | -------- | + | Promise<void> | Promise used to return the result. This method returns no value.| - Example ``` @@ -127,7 +129,7 @@ Writes data to this active tag. This method uses a promise to return the result. ## connectedTag.writeNdefTag -writeNdefTag(data: string, callback: AsyncCallback<string>): void +writeNdefTag(data: string, callback: AsyncCallback<void>): void Writes data to this active tag. This method uses an asynchronous callback to return the result. @@ -136,10 +138,10 @@ Writes data to this active tag. This method uses an asynchronous callback to ret **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name** | **Type** | **Mandatory** | **Description** | - | -------- | -------- | -------- | -------- | - | data | string | Yes | Data to write. The maximum length is 1024 bytes. | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the operation result. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | data | string | Yes| Data to write. The maximum length is 1024 bytes.| + | callback | AsyncCallback<string> | Yes| Callback invoked to return the active tag content obtained.| - Example ``` @@ -151,7 +153,7 @@ Writes data to this active tag. This method uses an asynchronous callback to ret console.error(`failed to write event because ${err.code}`); return; } - + // Data is written to the tag. console.log(`success to write event: ${value}`); }); @@ -168,16 +170,16 @@ Registers the NFC field strength state events. **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name** | **Type** | **Mandatory** | **Description** | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Event type. The value is **notify**. | - | callback | Callback<number> | Yes | Callback invoked to return the field strength state. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is **notify**.| + | callback | Callback<number> | Yes| Callback invoked to return the field strength state.| - Enumerates the field strength states. - | **Value** | **Description** | - | -------- | -------- | - | 0 | Field off. | - | 1 | Field on. | + | **Value**| **Description**| + | -------- | -------- | + | 0 | Field off.| + | 1 | Field on.| ## connectedTag.off('notify') @@ -191,10 +193,10 @@ Unregisters the NFC field strength state events. **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name** | **Type** | **Mandatory** | **Description** | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Event type. The value is **notify**. | - | callback | Callback<number> | No | Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is **notify**.| + | callback | Callback<number> | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| - Example ``` @@ -206,10 +208,10 @@ Unregisters the NFC field strength state events. console.info("nfc rf receive state: " + result); } - // Register event notification + // Register event notification. connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); - // Unregister event notification + // Unregister event notification. connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); ``` @@ -217,7 +219,9 @@ Unregisters the NFC field strength state events. Enumerates the NFC states. - | Name | Default Value | Description | - | -------- | -------- | -------- | - | NFC_RF_LEAVE | 0 | Field off. | - | NFC_RF_ENTER | 1 | Field on. | +**System capability**: SystemCapability.Communication.ConnectedTag + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| NFC_RF_LEAVE | 0 | Field on.| +| NFC_RF_ENTER | 1 | Field on.| diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md index adf54efbe8e95058c353a049211cec7c20e72ae3..296b8a58c2e89677eed23ee377c7568603429646 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -4,7 +4,7 @@ The relational database (RDB) manages data based on relational models. With the This module provides the following RDB-related functions: -- [RdbPredicates](#rdbpredicates): predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store. +- [RdbPredicates](#rdbpredicates): provides predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store. - [RdbStore](#rdbstore): provides APIs for managing an RDB store. > **NOTE**
@@ -166,14 +166,14 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE") inDevices(devices: Array<string>): RdbPredicates -Specifies a remote device on the network during distributed database synchronization. +Connects to the specified remote devices on the network during distributed database synchronization. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| devices | Array<string> | Yes| ID of the remote device to specify.| +| devices | Array<string> | Yes| IDs of the remote devices in the same network.| **Return value** | Type| Description| @@ -948,6 +948,8 @@ predicates.notIn("NAME", ["Lisa", "Rose"]) Provides methods to manage an RDB store. +Before using the following APIs, use [executeSql](#executesql) to initialize the database table structure and related data. For details, see [RDB Development](../../database/database-relational-guidelines.md). + ### insert @@ -977,7 +979,7 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) { console.log("Failed to insert data"); return; } - console.log("Inserted data, rowId = " + rowId); + console.log("Inserted data successfully, rowId = " + rowId); }) ``` @@ -1011,7 +1013,7 @@ const valueBucket = { } let promise = rdbStore.insert("EMPLOYEE", valueBucket) promise.then((rowId) => { - console.log("Inserted data, rowId = " + rowId); + console.log("Inserted data successfully, rowId = " + rowId); }).catch((status) => { console.log("Failed to insert data"); }) @@ -1056,10 +1058,10 @@ const valueBucket3 = { var valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); rdbStore.batchInsert("EMPLOYEE", valueBuckets, function(status, insertNum) { if (status) { - console.log("bathInsert failed, status = " + status); + console.log("Failed to batch insert data, status = " + status); return; } - console.log("bathInsert is successful, the number of values that were inserted = " + insertNum); + console.log("Batch inserted data successfully. The number of values that were inserted = " + insertNum); }) ``` @@ -1106,9 +1108,9 @@ const valueBucket3 = { var valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); let promise = rdbStore.batchInsert("EMPLOYEE", valueBuckets); promise.then((insertNum) => { - console.log("bathInsert is successful, the number of values that were inserted = " + insertNum); + console.log("Batch inserted data successfully. The number of values that were inserted = " + insertNum); }).catch((status) => { - console.log("bathInsert failed, status = " + status); + console.log("Failed to batch insert data, status = " + status); }) ``` @@ -1116,14 +1118,14 @@ promise.then((insertNum) => { update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>):void -Updates data based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result. +Updates data in the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| +| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The key-value pair is associated with the column name in the target table.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.| | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.| @@ -1158,7 +1160,7 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| +| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The key-value pair is associated with the column name in the target table.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.| **Return value** @@ -1187,7 +1189,7 @@ promise.then(async (ret) => { ### update9+ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void -Updates data based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. +Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1222,7 +1224,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise<number> -Updates data based on the specified **DataSharePredicates** object. This API uses a promise to return the result. +Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1520,7 +1522,7 @@ Queries data from the RDB store of a remote device based on specified conditions | -------- | -------- | -------- | -------- | | device | string | Yes| Network ID of the remote device.| | table | string | Yes| Name of the target table.| -| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions for querying data.| +| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.| | columns | Array<string> | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.| | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md#resultset)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| @@ -1553,7 +1555,7 @@ Queries data from the RDB store of a remote device based on specified conditions | -------- | -------- | -------- | -------- | | device | string | Yes| Network ID of the remote device.| | table | string | Yes| Name of the target table.| -| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions for querying data.| +| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.| | columns | Array<string> | No| Columns to query. If this parameter is not specified, the query applies to all columns.| **Return value** @@ -1580,7 +1582,7 @@ promise.then((resultSet) => { querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void -Queries data using the specified SQL statement. This API uses an asynchronous callback to return the result. +Queries data in the RDB store using the specified SQL statement. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1588,7 +1590,7 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | sql | string | Yes| SQL statement to run.| -| bindArgs | Array<[ValueType](#valuetype)> | Yes| Values of the parameters in the SQL statement.| +| bindArgs | Array<[ValueType](#valuetype)> | Yes| Arguments in the SQL statement.| | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** @@ -1608,7 +1610,7 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> -Queries data using the specified SQL statement. This API uses a promise to return the result. +Queries data in the RDB store using the specified SQL statement. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1616,7 +1618,7 @@ Queries data using the specified SQL statement. This API uses a promise to retur | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | sql | string | Yes| SQL statement to run.| -| bindArgs | Array<[ValueType](#valuetype)> | No| Values of the parameters in the SQL statement.| +| bindArgs | Array<[ValueType](#valuetype)> | No| Arguments in the SQL statement.| **Return value** | Type| Description| @@ -1648,7 +1650,7 @@ Executes an SQL statement that contains specified arguments but returns no value | -------- | -------- | -------- | -------- | | sql | string | Yes| SQL statement to run.| | bindArgs | Array<[ValueType](#valuetype)> | Yes| Arguments in the SQL statement.| -| callback | AsyncCallback<void> | Yes| Callback that returns no value.| +| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** ```js @@ -1658,7 +1660,7 @@ rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { console.info("Failed to execute SQL, err: " + err) return } - console.info('Create table done.') + console.info('Created table successfully.') }) ``` @@ -1680,14 +1682,14 @@ Executes an SQL statement that contains specified arguments but returns no value **Return value** | Type| Description| | -------- | -------- | -| Promise<void> | Promise that returns no value.| +| Promise<void> | Promise used to return the result.| **Example** ```js const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" let promise = rdbStore.executeSql(SQL_CREATE_TABLE) promise.then(() => { - console.info('Create table done.') + console.info('Created table successfully.') }).catch((err) => { console.info("Failed to execute SQL, err: " + err) }) @@ -1785,7 +1787,7 @@ rdbStore.backup("dbBackup.db", function(err) { console.info('Failed to back up data, err: ' + err) return } - console.info('Backup successful.') + console.info('Backed up data successfully.') }) ``` @@ -1811,7 +1813,7 @@ Backs up an RDB store. This API uses a promise to return the result. ```js let promiseBackup = rdbStore.backup("dbBackup.db") promiseBackup.then(()=>{ - console.info('Backup successful.') + console.info('Backed up data successfully.') }).catch((err)=>{ console.info('Failed to back up data, err: ' + err) }) @@ -1838,7 +1840,7 @@ rdbStore.restore("dbBackup.db", function(err) { console.info('Failed to restore data, err: ' + err) return } - console.info('Restore successful.') + console.info('Restored data successfully.') }) ``` @@ -1864,7 +1866,7 @@ Restores an RDB store from a backup file. This API uses a promise to return the ```js let promiseRestore = rdbStore.restore("dbBackup.db") promiseRestore.then(()=>{ - console.info('Restore successful.') + console.info('Restored data successfully.') }).catch((err)=>{ console.info('Failed to restore data, err: ' + err) }) @@ -1924,7 +1926,7 @@ let promise = rdbStore.setDistributedTables(["EMPLOYEE"]) promise.then(() => { console.info("Set distributed tables successfully.") }).catch((err) => { - console.info("Failed to set distributed tables, err: " + err) + console.info('Failed to set distributed tables, err: ' + err) }) ``` @@ -1932,7 +1934,7 @@ promise.then(() => { obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void -Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the RDB store of a remote device is queried. This API uses an asynchronous callback to return the result. +Obtains the distributed table name for a remote device based on the local table name. This API uses an asynchronous callback to return the result. The distributed table name is required when the RDB store of a remote device is queried. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC @@ -1961,7 +1963,7 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, obtainDistributedTableName(device: string, table: string): Promise<string> -Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the RDB store of a remote device is queried. This API uses a promise to return the result. +Obtains the distributed table name for a remote device based on the local table name. This API uses a promise to return the result. The distributed table name is required when the RDB store of a remote device is queried. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC @@ -2003,7 +2005,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret | -------- | -------- | -------- | -------- | | mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| **RdbPredicates** object that specifies the data and devices to synchronize.| -| callback | AsyncCallback<Array<[string, number]>> | Yes| Callback invoked to send the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | +| callback | AsyncCallback<Array<[string, number]>> | Yes| Callback invoked to send the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** ```js @@ -2042,7 +2044,7 @@ Synchronizes data between devices. This API uses a promise to return the result. | Type| Description| | -------- | -------- | -| Promise<Array<[string, number]>> | Promise used to return the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | +| Promise<Array<[string, number]>> | Promise used to return the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md index 52af89ae7faa9fd20a28a62f959f4a3f39340ced..1d10f56aeb69e13d2f329bfc18f56127667ef930 100644 --- a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -119,7 +119,7 @@ helper.on( off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void -Unregisters the observer used to observe data specified by a given URI. This API uses an asynchronous callback to return the result. +Deregisters the observer used to observe data specified by a given URI. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -647,7 +647,7 @@ Deletes one or more data records from the database. This API uses an asynchronou ```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' +import ohos_data_ability from '@ohos.data.dataAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -662,7 +662,7 @@ DAHelper.delete( ## DataAbilityHelper.delete -delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\ +delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\; Deletes one or more data records from the database. This API uses a promise to return the result. @@ -685,7 +685,7 @@ Deletes one or more data records from the database. This API uses a promise to r ```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' +import ohos_data_ability from '@ohos.data.dataAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -719,7 +719,7 @@ Updates data records in the database. This API uses an asynchronous callback to ```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' +import ohos_data_ability from '@ohos.data.dataAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -741,7 +741,7 @@ DAHelper.update( ## DataAbilityHelper.update -update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise\ +update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.DataAbilityPredicates): Promise\; Updates data records in the database. This API uses a promise to return the result. @@ -765,7 +765,7 @@ Updates data records in the database. This API uses a promise to return the resu ```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' +import ohos_data_ability from '@ohos.data.dataAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -806,7 +806,7 @@ Queries data in the database. This API uses an asynchronous callback to return t ```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' +import ohos_data_ability from '@ohos.data.dataAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -825,7 +825,7 @@ DAHelper.query( ## DataAbilityHelper.query -query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates): Promise\ +query(uri: string, columns?: Array\, predicates?: dataAbility.DataAbilityPredicates): Promise\; Queries data in the database. This API uses a promise to return the result. @@ -849,7 +849,7 @@ Queries data in the database. This API uses a promise to return the result. ```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' +import ohos_data_ability from '@ohos.data.dataAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -876,7 +876,7 @@ Calls the extended API of the Data ability. This API uses a promise to return th | Name | Type | Mandatory| Description | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" | +| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". | | method | string | Yes | Name of the API to call. | | arg | string | Yes |Parameter to pass. | | extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. | @@ -912,7 +912,7 @@ Calls the extended API of the Data ability. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" | +| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". | | method | string | Yes | Name of the API to call. | | arg | string | Yes |Parameter to pass. | | extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. | @@ -932,8 +932,107 @@ dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", " console.info('Operation succeeded: ' + data); }); ``` + +## DataAbilityHelper.executeBatch + +executeBatch(uri: string, operations: Array\, callback: AsyncCallback\>): void; + +Operates data in the database. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx".| +| operations | Array\<[DataAbilityOperation](#dataabilityoperation)> | Yes | A list of data operations on the database. | +| callback | AsyncCallback\> | Yes |Callback used to return the result of each operation in the **DataAbilityResult** array. | + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility'; + +// Select the operations to be performed on the database according to the DataAbilityOperation array. +let op=new Array(); +let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility"); +dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility", op, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + err); + return; + } + console.info('Operation succeeded: ' + data); +}); +``` + +## DataAbilityHelper.executeBatch + +executeBatch(uri: string, operations: Array\): Promise\>; + +Operates data in the database. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | -------------------------------| ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx".| +| operations | Array\<[DataAbilityOperation](#dataabilityoperation)> | Yes | A list of data operations on the database. | + +**Return value** + +| Type| Description| +|------ | ------- | +|Promise\> | Promise used to return the result of each operation in the **DataAbilityResult** array.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility'; + +// Select the operations to be performed on the database according to the DataAbilityOperation array. +let op=new Array(); +let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility"); +dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility",op ).then((data) => { + console.info('Operation succeeded: ' + data); +}).catch((error) => { + console.error('Operation failed. Cause: ' + error); +}); + +``` + ## PacMap +[key: string]: number | string | boolean | Array\ | null; + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + | Name| Type| Mandatory| Description| | ------ | ------ | ------ | ------ | | [key: string] | number \| string \| boolean \| Array\ \| null | Yes| Data stored in key-value pairs.| + +## DataAbilityOperation + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +| Name | Type | Readable | Writable | Mandatory| Description | +| -------- | -------- | -------- | -------- | --------| -------- | +| uri | string | Yes | No | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". | +| type | featureAbility.DataAbilityOperationType | Yes | No | Yes | Operation type. | +| valuesBucket? | rdb.ValuesBucket | Yes | No | No | Data value to set. | +| valueBackReferences? | rdb.ValuesBucket | Yes | No | No | **ValuesBucket** object that contains a set of key-value pairs. | +| predicates? | dataAbility.DataAbilityPredicates | Yes | No | No | Predicates to set. If no predicate is set, all data records are displayed. | +| predicatesBackReferences? | Map\ | Yes | No | No | Back references of the predicates. | +| interrupted? | boolean | Yes | No | No | Whether batch operations can be interrupted. | +| expectedCount? | number | Yes | No | No | Expected number of rows to be updated or deleted. | + +## DataAbilityResult + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +| Name | Type | Readable | Writable | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | -------- | +| uri? | string | Yes | No | No | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". | +| count? | number | Yes | No | No | Number of rows affected by the operation. | diff --git a/en/application-dev/reference/apis/js-apis-device-manager.md b/en/application-dev/reference/apis/js-apis-device-manager.md index 8c27495f208ad620ed6e104fb19c958350805c1e..659a6b126357cb32865e9bc1d21eecd5228bdfd5 100644 --- a/en/application-dev/reference/apis/js-apis-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-device-manager.md @@ -9,7 +9,7 @@ System applications can call the APIs to do the following: - Authenticate or deauthenticate a device. - Query the trusted device list. - Query local device information, including the device name, type, and ID. - +- Publish device information for discovery purposes. > **NOTE** > > - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -31,23 +31,24 @@ Creates a **DeviceManager** instance. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ---------------------------------------- | ---- | ------------------------------------ | - | bundleName | string | Yes | Bundle name of an application. | - | callback | AsyncCallback<[DeviceManager](#devicemanager)> | Yes | Callback used to return the **DeviceManager** instance created.| +**Parameters** +| Name | Type | Mandatory | Description | +| ---------- | ---------------------------------------- | ---- | ------------------------------------ | +| bundleName | string | Yes | Bundle name of an application. | +| callback | AsyncCallback<[DeviceManager](#devicemanager)> | Yes | Callback used to return the **DeviceManager** instance created.| -- Example - ``` - deviceManager.createDeviceManager("ohos.samples.jshelloworld", (err, data) => { - if (err) { - console.info("createDeviceManager err:" + JSON.stringify(err)); - return; - } - console.info("createDeviceManager success"); - let dmInstance = data; - }); - ``` +**Example** + +``` +deviceManager.createDeviceManager("ohos.samples.jshelloworld", (err, data) => { + if (err) { + console.info("createDeviceManager err:" + JSON.stringify(err)); + return; + } + console.info("createDeviceManager success"); + let dmInstance = data; +}); +``` ## DeviceInfo @@ -61,7 +62,7 @@ Defines device information. | deviceName | string | Yes | Device name. | | deviceType | [DeviceType](#devicetype) | Yes | Device type. | | networkId8+ | string | Yes | Network ID of the device. | - +| range9+ | number | Yes | Distance between the device (discovered device) and the device that initiates device discovery. | ## DeviceType @@ -184,6 +185,18 @@ Defines authentication information. | token | number | Yes | Authentication token. | | extraInfo | {[key:string] : any} | No | Extended field.| +## PublishInfo + +Defines published device information. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Type | Mandatory | Description | +| ------------- | --------------------------------- | ---- | ----------------- | +| publishId | number | Yes | ID used to identify a publication period.| +| mode | [DiscoverMode ](#discovermode) | Yes | Device discovery mode. | +| freq | [ExchangeFreq](#exchangefreq) | Yes | Frequency of device discovery. | +| ranging | boolean | Yes | Whether the device supports distance reporting. | ## DeviceManager @@ -198,10 +211,11 @@ Releases this **DeviceManager** instance when it is no longer used. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- Example - ```js - dmInstance.release(); - ``` +**Example** + +```js +dmInstance.release(); +``` ### getTrustedDeviceListSync @@ -212,15 +226,17 @@ Obtains all trusted devices synchronously. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- Return value - | Name | Description | - | -------------------------------------- | --------- | - | Array<[DeviceInfo](#deviceinfo)> | List of trusted devices obtained.| +**Return value** -- Example - ```js - var deviceInfoList = dmInstance.getTrustedDeviceListSync(); - ``` +| Name | Description | +| -------------------------------------- | --------- | +| Array<[DeviceInfo](#deviceinfo)> | List of trusted devices obtained.| + +**Example** + +```js +var deviceInfoList = dmInstance.getTrustedDeviceListSync(); +``` ### getTrustedDeviceList8+ @@ -231,12 +247,12 @@ Obtains all trusted devices. This API uses an asynchronous callback to return th **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------------------- | - | callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | Yes | Callback used to return the list of trusted devices.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------- | +| callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | Yes | Callback used to return the list of trusted devices.| -- Example +**Example** ```js dmInstance.getTrustedDeviceList((err, data) => { console.log("getTrustedDeviceList err: " + JSON.stringify(err)); @@ -253,12 +269,12 @@ Obtains all trusted devices. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- Return value - | Type | Description | - | ---------------------------------------- | --------------------- | - | Promise<Array<[DeviceInfo](#deviceinfo)>> | Promise used to return the list of trusted devices.| +**Return value** +| Type | Description | +| ---------------------------------------- | --------------------- | +| Promise<Array<[DeviceInfo](#deviceinfo)>> | Promise used to return the list of trusted devices.| -- Example +**Example** ```js dmInstance.getTrustedDeviceList().then((data) => { console.log('get trusted device info: ' + JSON.stringify(data)); @@ -275,12 +291,12 @@ Obtains local device information synchronously. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- Return value - | Name | Description | - | -------------------------------------- | --------- | - | Array<[DeviceInfo](#deviceinfo)> | List of local devices obtained.| +**Return value** +| Name | Description | +| -------------------------------------- | --------- | +| Array<[DeviceInfo](#deviceinfo)> | List of local devices obtained.| -- Example +**Example** ```js var deviceInfo = dmInstance.getLocalDeviceInfoSync(); ``` @@ -294,12 +310,12 @@ Obtains local device information. This API uses an asynchronous callback to retu **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------- | - | callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | Yes | Callback used to return the local device information.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | Yes | Callback used to return the local device information.| -- Example +**Example** ```js dmInstance.getLocalDeviceInfo((err, data) => { console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); @@ -316,12 +332,12 @@ Obtains local device information. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- Return value - | Type | Description | - | ---------------------------------------- | --------------------- | - | Promise<[DeviceInfo](#deviceinfo)> | Promise used to return the local device information.| +**Return value** +| Type | Description | +| ---------------------------------------- | --------------------- | +| Promise<[DeviceInfo](#deviceinfo)> | Promise used to return the local device information.| -- Example +**Example** ```js dmInstance.getLocalDeviceInfo().then((data) => { console.log('get local device info: ' + JSON.stringify(data)); @@ -338,12 +354,12 @@ Starts to discover peripheral devices. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | ------------- | ------------------------------- | ---- | ----- | - | subscribeInfo | [SubscribeInfo](#subscribeinfo) | Yes | Subscription information.| +**Parameters** +| Name | Type | Mandatory | Description | +| ------------- | ------------------------------- | ---- | ----- | +| subscribeInfo | [SubscribeInfo](#subscribeinfo) | Yes | Subscription information.| -- Example +**Example** ```js // Automatically generate a unique subscription ID. var subscribeId = Math.floor(Math.random() * 10000 + 1000); @@ -359,6 +375,45 @@ Starts to discover peripheral devices. dmInstance.startDeviceDiscovery(subscribeInfo); // The deviceFound callback is invoked to notify the application when a device is discovered. ``` +### startDeviceDiscovery9+ + +startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions: string): void + +Starts to discover peripheral devices and filters discovered devices. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ------------- | ------------------------------- | ---- | ----- | +| subscribeInfo | [SubscribeInfo](#subscribeinfo) | Yes | Subscription information.| +| filterOptions | string | No | Options for filtering discovered devices.| + +**Example** + ```js + // Automatically generate a unique subscription ID. + var subscribeId = Math.floor(Math.random() * 10000 + 1000); + var subscribeInfo = { + "subscribeId": subscribeId, + "mode": 0xAA, // Active discovery + "medium": 0, // Automatic. Multiple media can be used for device discovery. + "freq": 2, // High frequency + "isSameAccount": false, + "isWakeRemote": false, + "capability": 1 + }; + var filterOptions = { + "filter_op": "OR", // Optional. The default value is OR. + "filters": [ + { + "type": "range", + "value": 50 // Filter discovered devices based on the distance (in cm). + } + ] + }; + dmInstance.startDeviceDiscovery(subscribeInfo, JSON.stringify(filterOptions)); // The deviceFound callback is invoked to notify the application when a device is discovered. + ``` + ### stopDeviceDiscovery stopDeviceDiscovery(subscribeId: number): void @@ -367,17 +422,63 @@ Stops device discovery. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | ----------- | ------ | ---- | ----- | - | subscribeId | number | Yes | Subscription ID.| +**Parameters** +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | ----- | +| subscribeId | number | Yes | Subscription ID.| -- Example +**Example** ```js // The subscribeId input must be the same as that automatically generated in startDeviceDiscovery. dmInstance.stopDeviceDiscovery(subscribeId); ``` +### publishDeviceDiscovery9+ + +publishDeviceDiscovery(publishInfo: PublishInfo): void + +Publishes device information for discovery purposes. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** +| Name | Type | Mandatory| Description | +| ------------- | ------------------------------- | ---- | ----- | +| publishInfo | [PublishInfo](#publishinfo) | Yes | Device information to publish.| + +**Example** + ```js + // Automatically generate a unique subscription ID. + var publishId = Math.floor(Math.random() * 10000 + 1000); + var publishInfo = { + "publishId": publishId, + "mode": 0xAA, // Active discovery + "freq": 2, // High frequency + "ranging": 1 // The device supports reporting the distance to the discovery initiator. + }; + dmInstance.publishDeviceDiscovery(publishInfo); // A callback is invoked to notify the application when the device information is published. + ``` + +### unPublishDeviceDiscovery + +unPublishDeviceDiscovery(publishId: number): void + +Stops publishing device information. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** + +| Name | Type| Mandatory| Description | +| ----------- | -------- | ---- | ----- | +| publishId | number | Yes | Publish ID.| + +**Example** + ```js + // The publishId input must be the same as that automatically generated in publishDeviceDiscovery. + dmInstance.unPublishDeviceDiscovery(publishId); + ``` + ### authenticateDevice authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void @@ -386,14 +487,14 @@ Authenticates a device. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ---------------------------------------- | ---- | ------- | - | deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information. | - | authParam | [AuthParam](#authparam) | Yes | Authentication parameter. | - | callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | Yes | Callback used to return the authentication result.| +**Parameters** +| Name | Type | Mandatory | Description | +| ---------- | ---------------------------------------- | ---- | ------- | +| deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information. | +| authParam | [AuthParam](#authparam) | Yes | Authentication parameter. | +| callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | Yes | Callback used to return the authentication result.| -- Example +**Example** ```js // Information about the device to authenticate. The information can be obtained from the device discovery result. var deviceInfo ={ @@ -423,12 +524,13 @@ Deauthenticates a device. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------------------------- | ---- | ----- | - | deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information.| +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ------------------------- | ---- | ----- | +| deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information.| -- Example +**Example** ```js dmInstance.unAuthenticateDevice(deviceInfo); ``` @@ -442,13 +544,13 @@ Verifies authentication information. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------- | - | authInfo | [AuthInfo](#authinfo) | Yes | Authentication information. | - | authInfo | AsyncCallback<{ deviceId: string, level: number }> | Yes | Callback used to return the verification result.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------- | +| authInfo | [AuthInfo](#authinfo) | Yes | Authentication information. | +| authInfo | AsyncCallback<{ deviceId: string, level: number }> | Yes | Callback used to return the verification result.| -- Example +**Example** ```js let authInfo = { "authType": 1, @@ -473,13 +575,13 @@ Subscribes to changes in the device state. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------------------------------ | - | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.| - | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes | Callback invoked to return the device information and state. | +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.| +| callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes | Callback invoked to return the device information and state. | -- Example +**Example** ```js dmInstance.on('deviceStateChange', (data) => { console.info("deviceStateChange on:" + JSON.stringify(data)); @@ -496,19 +598,20 @@ Unsubscribes from changes in the device state. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------------------------- | - | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. | - | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes | Callback invoked to return the device information and state.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------------- | +| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. | +| callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes | Callback invoked to return the device information and state.| -- Example - ```js - dmInstance.off('deviceStateChange', (data) => { - console.info('deviceStateChange' + JSON.stringify(data)); - } - ); - ``` +**Example** + +```js +dmInstance.off('deviceStateChange', (data) => { + console.info('deviceStateChange' + JSON.stringify(data)); + } +); +``` ### on('deviceFound') @@ -519,13 +622,13 @@ Subscribes to device discovery events. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | -------------------------- | - | type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered.| - | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | Yes | Callback used for device discovery. | +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | -------------------------- | +| type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered.| +| callback | Callback<{ subscribeId: number, device: DeviceInfo }> | Yes | Callback used for device discovery. | -- Example +**Example** ```js dmInstance.on('deviceFound', (data) => { console.info("deviceFound:" + JSON.stringify(data)); @@ -541,13 +644,13 @@ Unsubscribes from device discovery events. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------------------------- | - | type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered. | - | callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | Yes | Callback used for device discovery, which is invoked to return the device information and state.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------------- | +| type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered. | +| callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | Yes | Callback invoked to return the device information and state.| -- Example +**Example** ```js dmInstance.off('deviceFound', (data) => { console.info('deviceFound' + JSON.stringify(data)); @@ -563,13 +666,13 @@ Subscribes to device discovery failures. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------------------------------ | - | type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails.| - | callback | Callback<{ subscribeId: number, reason: number }> | Yes | Callback used for the device discovery failure. | +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails.| +| callback | Callback<{ subscribeId: number, reason: number }> | Yes | Callback used for the device discovery failure. | -- Example +**Example** ```js dmInstance.on('discoverFail', (data) => { this.log("discoverFail on:" + JSON.stringify(data)); @@ -585,13 +688,13 @@ Unsubscribes from device discovery failures. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ----------------- | - | type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails. | - | callback | Callback<{ subscribeId: number, reason: number }> | Yes | Callback used for the device discovery failure.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------------- | +| type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails. | +| callback | Callback<{ subscribeId: number, reason: number }> | Yes | Callback used for the device discovery failure.| -- Example +**Example** ```js dmInstance.off('deviceFound', (data) => { console.info('deviceFound' + JSON.stringify(data)); @@ -599,6 +702,93 @@ Unsubscribes from device discovery failures. ); ``` +### on('publishSuccess') + +on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void + +Subscribes to device information publication success events. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | -------------------------- | +| type | string | Yes | Event type. The value **'publishSuccess'** indicates an event reported when device information is published.| +| callback | Callback<{ publishId: number }> | Yes | Callback invoked to return the publish ID. | + +**Example** +```js +dmInstance.on('publishSuccess', (data) => { + console.info("publishSuccess:" + JSON.stringify(data)); + } +); +``` + +### off('publishSuccess') + +off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void + +Unsubscribes from device information publication success events. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | --------------------------- | +| type | string | Yes | Event type. The value **'publishSuccess'** indicates an event reported when device information is published. | +| callback | Callback<{ publishId: number }> | Yes | Callback used to return the publish ID.| + +**Example** + ```js + dmInstance.off('publishSuccess', (data) => { + console.info('publishSuccess' + JSON.stringify(data)); + } + ); + ``` + +### on('publishFail') + +on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void + +Subscribes to device information publication failures. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type. The event **'publishFail'** indicates an event reported when publishing device information fails.| +| callback | Callback<{ publishId: number, reason: number }> | Yes | Callback used for the publication failure. | + +**Example** + ```js + dmInstance.on('publishFail', (data) => { + this.log("publishFail on:" + JSON.stringify(data)); + } + ); + ``` + +### off('publishFail') + +off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void + +Unsubscribes from device information publication failures. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | ----------------- | +| type | string | Yes | Event type. The event **'publishFail'** indicates an event reported when publishing device information fails. | +| callback | Callback<{ publishId: number, reason: number }> | Yes | Callback used for the device discovery failure.| + +**Example** + ```js + dmInstance.off('publishFail', (data) => { + console.info('publishFail' + JSON.stringify(data)); + } + ); + ``` ### on('serviceDie') @@ -608,13 +798,13 @@ Subscribes to dead events of the **DeviceManager** service. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ----------------------- | ---- | ---------------------------------------- | - | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| - | callback | () => void | Yes | Callback invoked when a dead event of the **DeviceManager** service occurs. | +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| +| callback | () => void | Yes | Callback invoked when a dead event of the **DeviceManager** service occurs. | -- Example +**Example** ```js dmInstance.on("serviceDie", () => { console.info("serviceDie on"); @@ -631,13 +821,13 @@ Unsubscribes from dead events of the **DeviceManager** service. **System capability**: SystemCapability.DistributedHardware.DeviceManager -- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ----------------------- | ---- | ---------------------------------------- | - | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| - | callback | () => void | No | Callback used to return the dead event of the **DeviceManager** service. | +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| +| callback | () => void | No | Callback used to return the dead event of the **DeviceManager** service. | -- Example +**Example** ```js dmInstance.off("serviceDie", () => { console.info("serviceDie off"); diff --git a/en/application-dev/reference/apis/js-apis-dispatchInfo.md b/en/application-dev/reference/apis/js-apis-dispatchInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..5f476f34bd9ed8c08fc0e033243c1f4fb55ca23c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-dispatchInfo.md @@ -0,0 +1,16 @@ +# DispatchInfo + +The **DispatchInfo** module provides dispatch information. + +> **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. + +## DispatchInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Readable| Writable| Description | +| ----------- | ------ | ---- | ---- | ------------------------ | +| verison | string | Yes | No | Version of the API to dispatch.| +| dispatchAPI | string | Yes | No | API to dispatch. | diff --git a/en/application-dev/reference/apis/js-apis-distributedMissionManager.md b/en/application-dev/reference/apis/js-apis-distributedMissionManager.md new file mode 100644 index 0000000000000000000000000000000000000000..4c7d2ea1d3d66e5d65118f376ed2a9300dd06cd3 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-distributedMissionManager.md @@ -0,0 +1,345 @@ +# Distributed Mission Management + +The **distributedMissionManager** module implements system mission management across devices. You can use the APIs provided by this module to register or deregister a mission status listener, and start or stop synchronizing the remote mission list. + +> **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 provided by this module are system APIs. + +## Modules to Import + +```js +import distributedMissionManager from '@ohos.distributedMissionManager' +``` + + +## distributedMissionManager.registerMissionListener + +registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, callback: AsyncCallback<void>): void; + +Registers a mission status listener. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------- | ---- | --------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for.| +| options | [MissionCallback](#missioncallback) | Yes | Callback to register. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + + ```ts + function NotifyMissionsChanged(deviceId) { + console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId)); + } + function NotifySnapshot(deviceId, missionId) { + console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId)); + console.log('NotifySnapshot missionId ' + JSON.stringify(missionId)); + } + function NotifyNetDisconnect(deviceId, state) { + console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId)); + console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); + } + var parameter = { + deviceId: remoteDeviceId + }; + var options = { + notifyMissionsChanged: NotifyMissionsChanged, + notifySnapshot: NotifySnapshot, + notifyNetDisconnect: NotifyNetDisconnect + } + distributedMissionManager.registerMissionListener(parameter, options, (error) => { + console.log("error.code = " + error.code) + }) + ``` +## distributedMissionManager.registerMissionListener + +registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): Promise<void> + +Registers a mission status listener. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------------- | ---- | -------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. | +| options | MissionCallback | Yes | Callback to register.| + +**Return value** + +| Type | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```ts + function NotifyMissionsChanged(deviceId) { + console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId)); + } + function NotifySnapshot(deviceId, missionId) { + console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId)); + console.log('NotifySnapshot missionId ' + JSON.stringify(missionId)); + } + function NotifyNetDisconnect(deviceId, state) { + console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId)); + console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); + } + var parameter = { + deviceId: remoteDeviceId + }; + var options = { + notifyMissionsChanged: NotifyMissionsChanged, + notifySnapshot: NotifySnapshot, + notifyNetDisconnect: NotifyNetDisconnect + } + distributedMissionManager.registerMissionListener(parameter, options) + .then(data => { + console.info('success data is ' + data); + }).catch(error => { + console.info('error error is ' + error); + }) + ``` + + +## distributedMissionManager.unregisterMissionListener + +unregisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback<void>): void; + +Deregisters a mission status listener. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------- | ---- | --------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + + ```ts + var parameter = { + deviceId: remoteDeviceId + }; + distributedMissionManager.unregisterMissionListener(parameter, (error) => { + console.log("error.code = " + error.code) + }) + ``` + + +## distributedMissionManager.unregisterMissionListener + +unregisterMissionListener(parameter: MissionDeviceInfo): Promise<void> + +Deregisters a mission status listener. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for.| + +**Return value** + +| Type | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```ts + var parameter = { + deviceId: remoteDeviceId + }; + distributedMissionManager.unregisterMissionListener(parameter) + .then(data => { + console.info('success data is ' + data); + }).catch(error => { + console.info('error error is ' + error); + }) + ``` + +## distributedMissionManager.startSyncRemoteMissions + +startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback<void>): void; + +Starts to synchronize the remote mission list. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------------------- | ---- | --------- | +| parameter | [MissionParameter](#missionparameter) | Yes | Parameters required for synchronization. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + + ```ts + var parameter = { + deviceId: remoteDeviceId, + fixConflict: false, + tag: 0 + }; + distributedMissionManager.startSyncRemoteMissions(parameter, (error) => { + console.log("error.code = " + error.code) + }) + ``` + +## distributedMissionManager.startSyncRemoteMissions + +startSyncRemoteMissions(parameter: MissionParameter): Promise<void> + +Starts to synchronize the remote mission list. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------------------- | ---- | ----- | +| parameter | [MissionParameter](#missionparameter) | Yes | Parameters required for synchronization.| + +**Return value** + +| Type | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```ts + var parameter = { + deviceId: remoteDeviceId, + fixConflict: false, + tag: 0 + }; + distributedMissionManager.startSyncRemoteMissions(parameter) + .then(data => { + console.info('success data is ' + data); + }).catch(error => { + console.info('error error is ' + error); + }) + ``` + +## distributedMissionManager.stopSyncRemoteMissions + +stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback<void>): void; + +Stops synchronizing the remote mission list. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------- | ---- | --------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Parameters required for synchronization. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + + ```ts + var parameter = { + deviceId: remoteDeviceId + }; + distributedMissionManager.stopSyncRemoteMissions(parameter, (error) => { + console.log("error.code = " + error.code) + }) + ``` + +## distributedMissionManager.stopSyncRemoteMissions + +stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise<void> + +Stops synchronizing the remote mission list. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Parameters required for synchronization.| + +**Return value** + +| Type | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```ts + var parameter = { + deviceId: remoteDeviceId + }; + distributedMissionManager.stopSyncRemoteMissions(parameter) + .then(data => { + console.info('success data is ' + data); + }).catch(error => { + console.info('error error is ' + error); + }) + ``` + +## MissionCallback + +Defines the callbacks that can be registered as a mission status listener. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +| Name | Type | Readable | Writable | Description | +| --------------------- | -------- | ---- | ---- | ------------------ | +| notifyMissionsChanged | function | Yes | No | Callback used to notify the mission change event and return the device ID. | +| notifySnapshot | function | Yes | No | Callback used to notify the snapshot change event and return the device ID and mission ID.| +| notifyNetDisconnect | function | Yes | No | Callback used to notify the disconnection event and return the device ID and network status.| + +## MissionParameter + +Defines the parameters required for mission synchronization. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +| Name | Type | Readable | Writable | Description | +| ----------- | ------- | ---- | ---- | ----------- | +| deviceId | string | Yes | Yes | Device ID. | +| fixConflict | boolean | Yes | Yes | Whether a version conflict occurs.| +| tag | number | Yes | Yes | Tag of the mission. | + +## MissionDeviceInfo + +Defines the parameters required for registering a listener. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +| Name | Type | Readable | Writable | Description | +| -------- | ------ | ---- | ---- | ------- | +| deviceId | string | Yes | Yes | Device ID.| diff --git a/en/application-dev/reference/apis/js-apis-errorManager.md b/en/application-dev/reference/apis/js-apis-errorManager.md new file mode 100644 index 0000000000000000000000000000000000000000..a06e1650bd6f3614a33c58dd092b55451d0a0db8 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-errorManager.md @@ -0,0 +1,139 @@ +# ErrorManager + +The **ErrorManager** module provides APIs for registering and deregistering error observers. + +> **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. + +## Modules to Import +``` +import errorManager from '@ohos.application.errorManager' +``` + +## ErrorManager.registerErrorObserver + +registerErrorObserver(observer: ErrorObserver): number; + +Registers an error observer. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| observer | [ErrorObserver](#errorobserver) | No| Numeric code of the observer.| + +**Example** + +```js +var observer = { + onUnhandledException(errorMsg) { + console.log('onUnhandledException, errorMsg: ', errorMsg) + } +} +errorManager.registerErrorObserver(observer) + .then((data) => { + console.log('----------- registerErrorObserver success ----------', data); + }) + .catch((err) => { + console.log('----------- registerErrorObserver fail ----------', err); + }) + +``` + +## ErrorManager.unregisterErrorObserver + +unregisterErrorObserver(observerId: number, callback: AsyncCallback\): void; + +Deregisters an error observer. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| observerId | number | No| Numeric code of the observer.| +| callback | AsyncCallback\ | No| Callback used to return the result.| + +**Example** + +```js +var observerId = 100; + +function unregisterErrorObserverCallback(err) { + if (err) { + console.log('------------ unregisterErrorObserverCallback ------------', err); + } +} +errorManager.unregisterErrorObserver(observerId, unregisterErrorObserverCallback); + +``` + +## ErrorManager.unregisterErrorObserver + +unregisterErrorObserver(observerId: number): Promise\; + +Deregisters an error observer. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| observerId | number | No| Numeric code of the observer.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +var observerId = 100; +errorManager.unregisterErrorObserver(observerId) +.then((data) => { + console.log('----------- unregisterErrorObserver success ----------', data); +}) +.catch((err) => { + console.log('----------- unregisterErrorObserver fail ----------', err); +}) + +``` + +## ErrorObserver + +onUnhandledException(errMsg: string): void; + +Called when an unhandled exception occurs in the JS runtime. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| errMsg | string | No| Message and error stack trace about the exception.| + +**Example** + +```js +var observer = { + onUnhandledException(errorMsg) { + console.log('onUnhandledException, errorMsg: ', errorMsg) + } +} +errorManager.registerErrorObserver(observer) + .then((data) => { + console.log('----------- registerErrorObserver success ----------', data); + }) + .catch((err) => { + console.log('----------- registerErrorObserver fail ----------', err); + }) + +``` diff --git a/en/application-dev/reference/apis/js-apis-formextension.md b/en/application-dev/reference/apis/js-apis-formextension.md index daea33dbb50edf3aec50c84eee9795339bd9c43a..1540e538e1bcc8f53165a3fd277e60f76e73a7a1 100644 --- a/en/application-dev/reference/apis/js-apis-formextension.md +++ b/en/application-dev/reference/apis/js-apis-formextension.md @@ -35,15 +35,15 @@ Called to notify the widget provider that a **Form** instance (widget) has been **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| + | Name| Type | Mandatory| Description | + | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | + | want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| **Return value** -| Type | Description | -| ------------------------------------------------------------ | ----------------------------------------------------------- | -| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.| + | Type | Description | + | ------------------------------------------------------------ | ----------------------------------------------------------- | + | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.| **Example** @@ -72,9 +72,9 @@ Called to notify the widget provider that a temporary widget has been converted **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| formId | string | Yes | ID of the widget that requests to be converted to a normal one.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | formId | string | Yes | ID of the widget that requests to be converted to a normal one.| **Example** @@ -96,9 +96,9 @@ Called to notify the widget provider that a widget has been updated. After obtai **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| formId | string | Yes | ID of the widget that requests to be updated.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------ | + | formId | string | Yes | ID of the widget that requests to be updated.| **Example** @@ -127,9 +127,9 @@ Called to notify the widget provider of the change of visibility. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------- | ---- | ---------------------------- | -| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.| + | Name | Type | Mandatory| Description | + | --------- | ------------------------- | ---- | ---------------------------- | + | newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.| **Example** @@ -162,10 +162,10 @@ Called to instruct the widget provider to receive and process the widget event. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------ | ---- | ---------------------- | -| formId | string | Yes | ID of the widget that requests the event.| -| message | string | Yes | Event message. | + | Name | Type | Mandatory| Description | + | ------- | ------ | ---- | ---------------------- | + | formId | string | Yes | ID of the widget that requests the event.| + | message | string | Yes | Event message. | **Example** @@ -187,9 +187,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| formId | string | Yes | ID of the widget to be destroyed.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------ | + | formId | string | Yes | ID of the widget to be destroyed.| **Example** @@ -211,9 +211,9 @@ Called when the configuration of the environment where the ability is running is **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| **Example** @@ -235,9 +235,9 @@ Called when the widget provider receives the status query result of a widget. By **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.| **Example** @@ -250,3 +250,40 @@ Called when the widget provider receives the status query result of a widget. By } } ``` + +## FormExtension.onShare + +onShare?(formId: string): {[key: string]: any}; + +Called by the widget provider to receive shared widget data. + +This is a system API. + +**System capability**: SystemCapability.Ability.Form + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | formId | string | Yes | ID of a widget.| + +**Return value** + + | Type | Description | + | ------------------------------------------------------------ | ----------------------------------------------------------- | + | {[key: string]: any} | Data to be shared by the widget, in the form of key-value pairs.| + +**Example** + + ```js + class MyFormExtension extends FormExtension { + onShare(formId) { + console.log('FormExtension onShare, formId:' + formId); + let wantParams = { + "temperature":"20", + "time":"2022-8-8 09:59", + }; + return wantParams; + } + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-formextensioncontext.md b/en/application-dev/reference/apis/js-apis-formextensioncontext.md index f2e1fe143fbac2991698d2dd4244d88b23b0ebd5..7cd19e0e0f9a5d4ae906abd1a6d469893c1e95e0 100644 --- a/en/application-dev/reference/apis/js-apis-formextensioncontext.md +++ b/en/application-dev/reference/apis/js-apis-formextensioncontext.md @@ -2,13 +2,32 @@ The **FormExtensionContext** module, inherited from **ExtensionContext**, provides context for Form Extension abilities. -You can use the APIs of this module to start abilities. +You can use the APIs of this module to start Form Extension abilities. > **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. +## Usage + +Before using the **ServiceExtensionContext** module, you must first obtain a **FormExtension** instance. +```js +import FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData' +export default class MyFormExtension extends FormExtension { + onCreate() { + let dataObj1 = { + temperature:"11c", + "time":"11:00" + }; + let obj1 = formBindingData.createFormBindingData(dataObj1); + return obj1; + } +} + +``` + ## FormExtensionContext.startAbility startAbility(want: Want, callback: AsyncCallback<void>): void @@ -64,7 +83,7 @@ Starts an ability. This API uses a promise to return the result. | Type | Description | | ------------ | ---------------------------------- | -| Promise\ | Promise used to return the result.| +| Promise<void< | Promise used to return the result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-formprovider.md b/en/application-dev/reference/apis/js-apis-formprovider.md index 81855948f4994b85d601763ffe5e817a175d3733..fbe8907aed6b59d005f027af62ec4d0b0ec9a141 100644 --- a/en/application-dev/reference/apis/js-apis-formprovider.md +++ b/en/application-dev/reference/apis/js-apis-formprovider.md @@ -189,6 +189,7 @@ Obtains the application's widget information that meets a filter criterion on th **Example** ```js +import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { moduleName : "entry" }; @@ -224,6 +225,7 @@ Obtains the application's widget information on the device. This API uses a prom **Example** ```js +import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { moduleName : "entry" }; @@ -236,13 +238,13 @@ formProvider.getFormsInfo(filter).then((data) => { ## requestPublishForm9+ -requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback<string>): <void>; +requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void; Requests to publish a widget carrying data to the widget host. This API uses an asynchronous callback to return the result. -**System capability** +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -276,13 +278,13 @@ SystemCapability.Ability.Form ## requestPublishForm9+ -requestPublishForm(want: Want, callback: AsyncCallback<string>): <void>; +requestPublishForm(want: Want, callback: AsyncCallback<string>): void; Requests to publish a widget to the widget host. This API uses an asynchronous callback to return the result. -**System capability** +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -317,9 +319,9 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData Requests to publish a widget to the widget host. This API uses a promise to return the result. -**System capability** +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -360,6 +362,8 @@ Checks whether a widget can be published to the widget host. This API uses an as **System capability**: SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type | Mandatory| Description | @@ -402,6 +406,8 @@ Checks whether a widget can be published to the widget host. This API uses a pro **System capability**: SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. + **Return value** | Type | Description | diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index 9baa14b8fcc490c92a115d026628c9f4a5613436..a21e4ddb660cba43fef79e5e509464eca986aea9 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -35,7 +35,7 @@ Obtains the localized script for the specified language. | string | Localized script for the specified language.| **Example** - ``` + ```js i18n.getDisplayLanguage("zh", "en-GB", true); i18n.getDisplayLanguage("zh", "en-GB"); ``` @@ -62,7 +62,7 @@ Obtains the localized script for the specified country. | string | Localized script for the specified country.| **Example** - ``` + ```js i18n.getDisplayCountry("zh-CN", "en-GB", true); i18n.getDisplayCountry("zh-CN", "en-GB"); ``` @@ -87,7 +87,7 @@ Checks whether the localized script for the specified language is displayed from | boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.| **Example** - ``` + ```js i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned. ``` @@ -107,7 +107,7 @@ Obtains the system language. | string | System language ID.| **Example** - ``` + ```js i18n.getSystemLanguage(); ``` @@ -135,7 +135,7 @@ This is a system API. | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** - ``` + ```js i18n.setSystemLanguage('zh'); ``` @@ -156,7 +156,7 @@ Obtains the list of system languages. | Array<string> | List of the IDs of system languages.| **Example** - ``` + ```js i18n.getSystemLanguages(); ``` @@ -182,7 +182,7 @@ Obtains the list of countries and regions supported for the specified language. | Array<string> | List of the IDs of the countries and regions supported for the specified language.| **Example** - ``` + ```js i18n.getSystemCountries('zh'); ``` @@ -201,7 +201,7 @@ Obtains the system region. | string | System region ID.| **Example** - ``` + ```js i18n.getSystemRegion(); ``` @@ -229,7 +229,7 @@ This is a system API. | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** - ``` + ```js i18n.setSystemRegion('CN'); ``` @@ -248,7 +248,7 @@ Obtains the system locale. | string | System locale ID.| **Example** - ``` + ```js i18n.getSystemLocale(); ``` @@ -276,7 +276,7 @@ This is a system API. | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** - ``` + ```js i18n.setSystemLocale('zh-CN'); ``` @@ -303,7 +303,7 @@ Checks whether the system language matches the specified region. | boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.| **Example** - ``` + ```js i18n.isSuggested('zh', 'CN'); ``` @@ -328,7 +328,7 @@ Obtains a **Calendar** object. | [Calendar](#calendar8) | **Calendar** object.| **Example** - ``` + ```js i18n.getCalendar("zh-Hans", "gregory"); ``` @@ -350,7 +350,7 @@ Sets the date for this **Calendar** object. | date | Date | Yes | Date to be set for the **Calendar** object.| **Example** - ``` + ```js var calendar = i18n.getCalendar("en-US", "gregory"); var date = new Date(2021, 10, 7, 8, 0, 0, 0); calendar.setTime(date); @@ -371,7 +371,7 @@ Sets the date and time for this **Calendar** object. The value is represented by | time | number | Yes | Number of milliseconds that have elapsed since the Unix epoch.| **Example** - ``` + ```js var calendar = i18n.getCalendar("en-US", "gregory"); calendar.setTime(10540800000); ``` @@ -396,7 +396,7 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object | second | number | No | Second to set. | **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 ``` @@ -416,7 +416,7 @@ Sets the time zone of this **Calendar** object. | timezone | string | Yes | Time zone, for example, **Asia/Shanghai**.| **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setTimeZone("Asia/Shanghai"); ``` @@ -436,7 +436,7 @@ Obtains the time zone of this **Calendar** object. | string | Time zone of the **Calendar** object.| **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setTimeZone("Asia/Shanghai"); calendar.getTimeZone(); // Asia/Shanghai" @@ -457,7 +457,7 @@ Obtains the start day of a week for this **Calendar** object. | number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| **Example** - ``` + ```js var calendar = i18n.getCalendar("en-US", "gregory"); calendar.getFirstDayOfWeek(); ``` @@ -477,7 +477,7 @@ Sets the start day of a week for this **Calendar** object. | value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setFirstDayOfWeek(0); ``` @@ -497,7 +497,7 @@ Obtains the minimum number of days in the first week of a year. | number | Minimum number of days in the first week of a year.| **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.getMinimalDaysInFirstWeek(); ``` @@ -517,7 +517,7 @@ Sets the minimum number of days in the first week of a year. | value | number | No | Minimum number of days in the first week of a year.| **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setMinimalDaysInFirstWeek(3); ``` @@ -542,7 +542,7 @@ Obtains the value of the specified field in the **Calendar** object. | number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.| **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.get("hour_of_day"); // 8 @@ -568,7 +568,7 @@ Obtains the name of the **Calendar** object displayed for the specified locale. | string | Name of the **Calendar** object displayed for the specified locale.| **Example** - ``` + ```js var calendar = i18n.getCalendar("en-US", "buddhist"); calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. ``` @@ -593,7 +593,7 @@ Checks whether the specified date in this **Calendar** object is a weekend. | boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.| **Example** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 calendar.isWeekend(); // false @@ -620,7 +620,7 @@ Parameters | options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. | **Example** - ``` + ```js var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); ``` @@ -644,7 +644,7 @@ Checks whether the format of the specified phone number is valid. | boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.| **Example** - ``` + ```js var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); phonenumberfmt.isValidNumber("15812312312"); ``` @@ -669,9 +669,9 @@ Formats a phone number. | string | Formatted phone number.| **Example** - ``` + ```js var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); - phonenumberfmt.format("15812312312"); + phonenumberfmt.isValidNumber("15812312312"); ``` ### getLocationName9+ @@ -694,11 +694,10 @@ Obtains the home location of a phone number. | string | Home location of the phone number.| **Example** + ```js + var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); + phonenumberfmt.isValidNumber("15812312312"); ``` - var location = i18n.PhoneNumberFormat.getLocationName('15812312345', 'zh-CN'); - ``` - - ## PhoneNumberFormatOptions8+ @@ -750,7 +749,7 @@ Converts one measurement unit into another and formats the unit based on the spe | string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.| **Example** - ``` + ```js i18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); ``` @@ -797,7 +796,7 @@ Creates an **IndexUtil** object. | [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.| **Example** - ``` + ```js var indexUtil= i18n.getInstance("zh-CN"); ``` @@ -819,7 +818,7 @@ Obtains the index list for this **locale** object. | Array<string> | Index list for this **locale** object.| **Example** - ``` + ```js var indexUtil = i18n.getInstance("zh-CN"); var indexList = indexUtil.getIndexList(); ``` @@ -839,7 +838,7 @@ Adds the index of the new **locale** object to the index list. | locale | string | Yes | A string containing locale information, including the language, optional script, and region.| **Example** - ``` + ```js var indexUtil = i18n.getInstance("zh-CN"); indexUtil.addLocale("en-US"); ``` @@ -864,7 +863,7 @@ Obtains the index of a text object. | string | Index of the **text** object.| **Example** - ``` + ```js var indexUtil= i18n.getInstance("zh-CN"); indexUtil.getIndex("hi"); // Return h. ``` @@ -892,7 +891,7 @@ Checks whether the input character string is composed of digits. | boolean | Returns **true** if the input character is a digit; returns **false** otherwise.| **Example** - ``` + ```js var isdigit = i18n.Character.isDigit("1"); // Return true. ``` @@ -916,7 +915,7 @@ Checks whether the input character is a space. | boolean | Returns **true** if the input character is a space; returns **false** otherwise.| **Example** - ``` + ```js var isspacechar = i18n.Character.isSpaceChar("a"); // Return false. ``` @@ -940,7 +939,7 @@ Checks whether the input character is a white space. | boolean | Returns **true** if the input character is a white space; returns **false** otherwise.| **Example** - ``` + ```js var isspacechar = i18n.Character.isSpaceChar("a"); // Return false. ``` @@ -964,7 +963,7 @@ Checks whether the input character is of the right to left (RTL) language. | boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.| **Example** - ``` + ```js var isrtl = i18n.Character.isRTL("a"); // Return false. ``` @@ -988,7 +987,7 @@ Checks whether the input character is an ideographic character. | boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.| **Example** - ``` + ```js var isideograph = i18n.Character.isIdeograph("a"); // Return false. ``` @@ -1012,7 +1011,7 @@ Checks whether the input character is a letter. | boolean | Returns **true** if the input character is a letter; returns **false** otherwise.| **Example** - ``` + ```js var isletter = i18n.Character.isLetter("a"); // Return true. ``` @@ -1036,7 +1035,7 @@ Checks whether the input character is a lowercase letter. | boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.| **Example** - ``` + ```js var islowercase = i18n.Character.isLowerCase("a"); // Return true. ``` @@ -1060,7 +1059,7 @@ Checks whether the input character is an uppercase letter. | boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.| **Example** - ``` + ```js var isuppercase = i18n.Character.isUpperCase("a"); // Return false. ``` @@ -1084,7 +1083,7 @@ Obtains the type of the input character string. | string | Type of the input character.| **Example** - ``` + ```js var type = i18n.Character.getType("a"); ``` @@ -1108,7 +1107,7 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation. | [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); ``` @@ -1130,7 +1129,7 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object. | text | string | Yes | Text to be processed by the **BreakIterator** object.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); ``` @@ -1150,7 +1149,7 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object. | string | Text being processed by the **BreakIterator** object.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.getLineBreakText(); // Apple is my favorite fruit. @@ -1171,7 +1170,7 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text | number | Position of the **BreakIterator** object in the text being processed.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.current(); // 0 @@ -1192,7 +1191,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi | number | Offset to the first text boundary of the processed text.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.first(); // 0 @@ -1213,7 +1212,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic | number | Offset of the last text boundary of the processed text.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.last(); // 27 @@ -1239,7 +1238,7 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.first(); // 0 @@ -1262,7 +1261,7 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary. | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.first(); // 0 @@ -1290,7 +1289,7 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the | number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.following(0); // 6 @@ -1318,7 +1317,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru | boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.| **Example** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.isBoundary(0); // true; @@ -1340,7 +1339,7 @@ Checks whether the 24-hour clock is used. | boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.| **Example** - ``` + ```js var is24HourClock = i18n.is24HourClock(); ``` @@ -1366,7 +1365,7 @@ Sets the 24-hour clock. | boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.| **Example** - ``` + ```js // Set the system time to the 24-hour clock. var success = i18n.set24HourClock(true); ``` @@ -1394,7 +1393,7 @@ Adds a preferred language to the specified position on the preferred language li | boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.| **Example** - ``` + ```js // Add zh-CN to the preferred language list. var language = 'zh-CN'; var index = 0; @@ -1423,7 +1422,7 @@ Deletes a preferred language from the specified position on the preferred langua | boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.| **Example** - ``` + ```js // Delete the first preferred language from the preferred language list. var index = 0; var success = i18n.removePreferredLanguage(index); @@ -1444,7 +1443,7 @@ Obtains the list of preferred languages. | Array<string> | List of preferred languages.| **Example** - ``` + ```js var preferredLanguageList = i18n.getPreferredLanguageList(); ``` @@ -1463,7 +1462,7 @@ Obtains the first language in the preferred language list. | string | First language in the preferred language list.| **Example** - ``` + ```js var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); ``` @@ -1482,7 +1481,7 @@ Obtains the preferred language of an application. | string | Preferred language of the application.| **Example** - ``` + ```js var appPreferredLanguage = i18n.getAppPreferredLanguage(); ``` @@ -1506,7 +1505,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID. | TimeZone | **TimeZone** object corresponding to the time zone ID.| **Example** - ``` + ```js var timezone = i18n.getTimeZone(); ``` @@ -1528,7 +1527,7 @@ Obtains the ID of the specified **TimeZone** object. | string | Time zone ID corresponding to the **TimeZone** object.| **Example** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getID(); ``` @@ -1554,7 +1553,7 @@ Obtains the representation of a **TimeZone** object in the specified locale. | string | Representation of the **TimeZone** object in the specified locale.| **Example** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getDisplayName("zh-CN", false); ``` @@ -1574,7 +1573,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.| **Example** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getRawOffset(); ``` @@ -1594,7 +1593,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.| **Example** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getOffset(1234567890); ``` @@ -1613,7 +1612,7 @@ Obtains the list of time zone IDs supported by the system. | Array<string> | List of time zone IDs supported by the system.| **Example** - ``` + ```js var ids = i18n.TimeZone.getAvailableIDs(); ``` @@ -1632,7 +1631,7 @@ Obtains the list of time zone city IDs supported by the system. | Array<string> | List of time zone city IDs supported by the system.| **Example** - ``` + ```js var cityIDs = i18n.TimeZone.getAvailableZoneCityIDs(); ``` @@ -1657,7 +1656,7 @@ Obtains the localized display of a time zone city in the specified locale. | string | Localized display of the time zone city in the specified locale.| **Example** - ``` + ```js var displayName = i18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN"); ``` @@ -1681,7 +1680,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID | TimeZone | **TimeZone** object corresponding to the specified time zone city ID.| **Example** - ``` + ```js var timezone = i18n.TimeZone.getTimezoneFromCity("Shanghai"); ``` @@ -1708,7 +1707,7 @@ This is a system API. | boolean | Result indicating whether the local digit switch is successfully set. The value **true** indicates that the local digit switch is successfully set, and the value **false** indicates the opposite.| **Example** - ``` + ```js var status = i18n.setUsingLocalDigit(true); ``` @@ -1727,7 +1726,7 @@ Checks whether the local digit switch is turned on. | boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.| **Example** - ``` + ```js var status = i18n.getUsingLocalDigit(); ``` diff --git a/en/application-dev/reference/apis/js-apis-inputconsumer.md b/en/application-dev/reference/apis/js-apis-inputconsumer.md index c7662424d0b5bbde7888fe9dd696b177f532dcd5..98529f06257e7d2dfe3e9a395fd176dd413bb347 100644 --- a/en/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/en/application-dev/reference/apis/js-apis-inputconsumer.md @@ -32,7 +32,7 @@ This is a system API. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| -| keyOptions | [keyOptions](#keyOptions) | Yes| Key option, which specifies the condition for combination key input.| +| keyOptions | [keyOptions](#keyoptions) | Yes| Key option, which specifies the condition for combination key input.| | callback | Callback<KeyOptions> | Yes| Callback used to return the result.
When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.| **Example** @@ -62,7 +62,7 @@ This is a system API. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| -| keyOptions | [keyOptions](#keyOptions) | Yes| Key options passed to the key input event when listening starts.| +| keyOptions | [keyOptions](#keyoptions) | Yes| Key options passed to the key input event when listening starts.| | callback | Callback<KeyOptions> | Yes| Callback function passed to the key input event with **keyOptions** when listening starts.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md index 178313a1ff1a83a905895656793ff5977a486d0d..2f4986f90f431852a7b2e76d8f58e24ba8469ed9 100644 --- a/en/application-dev/reference/apis/js-apis-inputdevice.md +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -4,7 +4,8 @@ The Input Device module implements listening for connection, disconnection, and update events of input devices and displays information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse. -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -28,7 +29,7 @@ Enables listening for hot swap events of an input device. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ----------- | | type | string | Yes | Event type of the input device. | -| listener | Callback<[DeviceListener](#devicelistener9+)> | Yes | Listener for events of the input device.| +| listener | Callback<[DeviceListener](#devicelistener9)> | Yes | Listener for events of the input device.| **Example** @@ -63,7 +64,7 @@ Disables listening for hot swap events of an input device. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ----------- | | type | string | Yes | Event type of the input device. | -| listener | Callback<[DeviceListener](#devicelistener9+)> | No | Listener for events of the input device.| +| listener | Callback<[DeviceListener](#devicelistener9)> | No | Listener for events of the input device.| **Example** @@ -245,7 +246,7 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | --------------------------------- | | deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -| callback | AsyncCallback<[KeyboardType](#keyboardtype)> | Yes | Callback used to return the result. | +| callback | AsyncCallback<[KeyboardType](#keyboardtype9)> | Yes | Callback used to return the result. | **Example** @@ -268,7 +269,7 @@ Obtains the keyboard type of an input device. This API uses a promise to return | Parameter | Description | | ---------------------------------------- | ------------------- | -| Promise<[KeyboardType](#keyboardtype)> | Promise used to return the result.| +| Promise<[KeyboardType](#keyboardtype9)> | Promise used to return the result.| **Example** @@ -336,7 +337,7 @@ Defines the axis range of an input device. | Name | Type | Description | | ----------------------- | ------------------------- | -------- | | source | [SourceType](#sourcetype) | Input source type of the axis.| -| axis | [AxisType](#axistype) | Axis type. | +| axis | [AxisType](#axistype9) | Axis type. | | max | number | Maximum value of the axis. | | min | number | Minimum value of the axis. | | fuzz9+ | number | Fuzzy value of the axis. | @@ -358,7 +359,7 @@ Enumerates the input source types. For example, if a mouse reports an x-axis eve | touchpad | string | The input device is a touchpad.| | joystick | string | The input device is a joystick.| -## ChangeType +## ChangedType Defines the change type for the hot swap event of an input device. diff --git a/en/application-dev/reference/apis/js-apis-inputmethod.md b/en/application-dev/reference/apis/js-apis-inputmethod.md index fa10d1c9b41f587ecfa8a86ff60e1abc24473fbc..47f0d3429179406f598940f977baab87ef7b3482 100644 --- a/en/application-dev/reference/apis/js-apis-inputmethod.md +++ b/en/application-dev/reference/apis/js-apis-inputmethod.md @@ -126,7 +126,7 @@ Switches to another input method. This API uses a promise to return the result. ``` ## InputMethodController -In the following API examples, you must first use **[getInputMethodController](#inputmethodgetinputmethodcontroller)** to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance. +In the following API examples, you must first use [getInputMethodController](#inputmethodgetinputmethodcontroller) to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance. ### stopInput @@ -174,7 +174,7 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. ## InputMethodSetting8+ -In the following API examples, you must first use **[getInputMethodSetting](#inputmethodgetinputmethodcontroller)** to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance. +In the following API examples, you must first use [getInputMethodSetting](#inputmethodgetinputmethodcontroller) to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance. ### listInputMethod diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index d9be9b9a2cbc59fb48e2beae81da77d05be9c84f..3060af2da4bd047461f0cce0d866753bd8caf36a 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -536,7 +536,7 @@ Parameters **Example** ``` - var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); + var pluralRules= new Intl.PluralRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); ``` diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index 77002020139fbdb2aada0cb1141a0f2840a9f250..66af65d60b482342733fcc149c8b7b4078eeb851 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -61,7 +61,7 @@ Creates a **VideoPlayer** instance in asynchronous mode. This API uses a callbac let videoPlayer media.createVideoPlayer((error, video) => { - if (typeof(video) != 'undefined') { + if (video != null) { videoPlayer = video; console.info('video createVideoPlayer success'); } else { @@ -90,7 +90,7 @@ Creates a **VideoPlayer** instance in asynchronous mode. This API uses a promise let videoPlayer media.createVideoPlayer().then((video) => { - if (typeof(video) != 'undefined') { + if (video != null) { videoPlayer = video; console.info('video createVideoPlayer success'); } else { @@ -106,6 +106,7 @@ media.createVideoPlayer().then((video) => { createAudioRecorder(): AudioRecorder Creates an **AudioRecorder** instance to control audio recording. +Only one **AudioRecorder** instance can be created per device. **System capability**: SystemCapability.Multimedia.Media.AudioRecorder @@ -126,6 +127,7 @@ let audioRecorder = media.createAudioRecorder(); createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void Creates a **VideoRecorder** instance in asynchronous mode. This API uses a callback to return the result. +Only one **AudioRecorder** instance can be created per device. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -141,7 +143,7 @@ Creates a **VideoRecorder** instance in asynchronous mode. This API uses a callb let videoRecorder media.createVideoRecorder((error, video) => { - if (typeof(video) != 'undefined') { + if (video != null) { videoRecorder = video; console.info('video createVideoRecorder success'); } else { @@ -155,6 +157,7 @@ media.createVideoRecorder((error, video) => { createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> Creates a **VideoRecorder** instance in asynchronous mode. This API uses a promise to return the result. +Only one **AudioRecorder** instance can be created per device. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -170,7 +173,7 @@ Creates a **VideoRecorder** instance in asynchronous mode. This API uses a promi let videoRecorder media.createVideoRecorder().then((video) => { - if (typeof(video) != 'undefined') { + if (video != null) { videoRecorder = video; console.info('video createVideoRecorder success'); } else { @@ -272,14 +275,15 @@ For details about the audio playback demo, see [Audio Playback Development](../. **System capability**: SystemCapability.Multimedia.Media.AudioPlayer -| Name | Type | Readable| Writable| Description | -| ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| src | string | Yes | Yes | Audio media URI. The mainstream audio formats (MPEG-4, AAC, MPEG-3, OGG, and WAV) are supported.
**Example of supported URIs**:
1. FD playback: fd://xx
![](figures/en-us_image_url.png)
2. HTTP network playback: http://xx
3. HTTPS network playback: https://xx
**Note**:
To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.| -| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. | -| currentTime | number | Yes | No | Current audio playback position. | -| duration | number | Yes | No | Audio duration. | -| state | [AudioState](#audiostate) | Yes | No | Audio playback state. | - +| Name | Type | Readable| Writable| Description | +| ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| src | string | Yes | Yes | Audio file URI. The mainstream audio formats (M4A, AAC, MPEG-3, OGG, and WAV) are supported.
**Examples of supported URI schemes**:
1. FD: fd://xx
![](figures/en-us_image_url.png)
2. HTTP: http://xx
3. HTTPS: https://xx
4. HLS: http://xx or https://xx
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.INTERNET (The latter is required only when online resources are used.)| +| fdSrc9+ | [AVFileDescriptor](#interruptmode9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.
**Example:**
Assume that a music file that stores continuous music resources consists of the following:
Music 1 (address offset: 0, byte length: 100)
Music 2 (address offset: 101; byte length: 50)
Music 3 (address offset: 151, byte length: 150)
1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }
2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }
3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }
If the file is an independent music file, use **src=fd://xx**.

**Required permissions**: ohos.permission.READ_MEDIA| +| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. | +| audioInterruptMode9+ | [InterruptMode](#interruptmode9) | Yes | Yes | Audio interruption mode. | +| currentTime | number | Yes | No | Current audio playback position, in ms. | +| duration | number | Yes | No | Audio duration, in ms. | +| state | [AudioState](#audiostate) | Yes | No | Audio playback state. This state cannot be used as the condition for triggering the call of **play()**, **pause()**, or **stop()**.| ### play play(): void @@ -366,7 +370,7 @@ Seeks to the specified playback position. ```js audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback. - if (typeof (seekDoneTime) == 'undefined') { + if (seekDoneTime == null) { console.info('audio seek fail'); return; } @@ -439,7 +443,7 @@ function printfDescription(obj) { } audioPlayer.getTrackDescription((error, arrlist) => { - if (typeof (arrlist) != 'undefined') { + if (arrlist != null) { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); } @@ -475,7 +479,7 @@ function printfDescription(obj) { } audioPlayer.getTrackDescription().then((arrlist) => { - if (typeof (arrlist) != 'undefined') { + if (arrlist != null) { arrayDescription = arrlist; } else { console.log('audio getTrackDescription fail'); @@ -501,7 +505,7 @@ Subscribes to the audio buffering update event. | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'bufferingUpdate' in this case. | +| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. | | callback | function | Yes | Callback invoked when the event is triggered.
When [BufferingInfoType](#bufferinginfotype8) is set to **BUFFERING_PERCENT** or **CACHED_DURATION**, **value** is valid. Otherwise, **value** is fixed at **0**.| **Example** @@ -550,7 +554,7 @@ audioPlayer.on('reset', () => { // Set the 'reset' event callback. audioPlayer = undefined; }); audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback. - if (typeof(seekDoneTime) == "undefined") { + if (seekDoneTime == null) { console.info('audio seek fail'); return; } @@ -590,7 +594,7 @@ audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' e on(type: 'timeUpdate', callback: Callback\): void -Subscribes to the 'timeUpdate' event. +Subscribes to the **'timeUpdate'** event. **System capability**: SystemCapability.Multimedia.Media.AudioPlayer @@ -598,14 +602,14 @@ Subscribes to the 'timeUpdate' event. | Name | Type | Mandatory| Description | | -------- | ----------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'timeUpdate' in this case.
The 'timeUpdate' event is triggered when the [seek()](#audioplayer_seek) API is called.| +| type | string | Yes | Event type, which is **'timeUpdate'** in this case.
The **'timeUpdate'** event is triggered when the [seek()](#audioplayer_seek) API is called.| | callback | Callback\ | Yes | Callback invoked when the event is triggered. The input parameter of the callback is the time when the seek operation is successful. | **Example** ```js audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback. - if (typeof (seekDoneTime) == 'undefined') { + if (seekDoneTime == null) { console.info('audio seek fail'); return; } @@ -618,7 +622,7 @@ audioPlayer.seek(30000); // Seek to 30000 ms. on(type: 'error', callback: ErrorCallback): void -Subscribes to the audio playback error event. +Subscribes to audio playback error events. After an error event is reported, you must handle the event and exit the playback. **System capability**: SystemCapability.Multimedia.Media.AudioPlayer @@ -626,13 +630,13 @@ Subscribes to the audio playback error event. | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'error' in this case.
The 'error' event is triggered when an error occurs during audio playback.| +| type | string | Yes | Event type, which is **'error'** in this case.
The **'error'** event is triggered when an error occurs during audio playback.| | callback | ErrorCallback | Yes | Callback invoked when the event is triggered. | **Example** ```js -audioPlayer.on('error', (error) => { // Set the error event callback. +audioPlayer.on('error', (error) => { // Set the 'error' event callback. console.info(`audio error called, errName is ${error.name}`); // Print the error name. console.info(`audio error called, errCode is ${error.code}`); // Print the error code. console.info(`audio error called, errMessage is ${error.message}`);// Print the detailed description of the error type. @@ -646,13 +650,38 @@ Enumerates the audio playback states. You can obtain the state through the **sta **System capability**: SystemCapability.Multimedia.Media.AudioPlayer -| Name | Type | Description | -| ------------------ | ------ | -------------- | -| idle | string | The audio player is idle.| -| playing | string | Audio playback is in progress.| -| paused | string | Audio playback is paused.| -| stopped | string | Audio playback is stopped.| -| error8+ | string | Audio playback is in the error state. | +| Name | Type | Description | +| ------------------ | ------ | ---------------------------------------------- | +| idle | string | No audio playback is in progress. The audio player is in this state after the **'dataload'** or **'reset'** event is triggered.| +| playing | string | Audio playback is in progress. The audio player is in this state after the **'play'** event is triggered. | +| paused | string | Audio playback is paused. The audio player is in this state after the **'pause'** event is triggered. | +| stopped | string | Audio playback is stopped. The audio player is in this state after the **'stop'** event is triggered. | +| error8+ | string | Audio playback is in the error state. | + +## AVFileDescriptor9+ + +Describes audio and video file resources. It is used to specify a particular resource for playback based on its offset and length within a file. + +**System capability**: SystemCapability.Multimedia.Media.AudioPlayer + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| fd | number | Yes | Resource handle, which is obtained by calling **resourceManager.getRawFileDescriptor**. | +| offset | number | Yes | Resource offset, which needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.| +| length | number | Yes | Resource length, which needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.| + +## InterruptMode9+ + +Describes the audio interruption mode. + +**System capability**: SystemCapability.Multimedia.Media.AudioPlayer + +| Name | Default Value| Description | +| ---------------------------- | ------ | ---------- | +| SHARE_MODE | 0 | Shared mode.| +| INDEPENDENT_MODE| 1 | Independent mode. | ## VideoPlayer8+ @@ -666,13 +695,16 @@ For details about the video playback demo, see [Video Playback Development](../. | Name | Type | Readable| Writable| Description | | ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| url8+ | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.
**Example of supported URIs**:
1. FD playback: fd://xx
![](figures/en-us_image_url.png)
2. HTTP network playback: http://xx
3. HTTPS network playback: https://xx
3. HLS network playback: http://xx or https://xx
**Note**:
To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.| +| url8+ | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.
**Example of supported URIs**:
1. FD: fd://xx
![](figures/en-us_image_url.png)
2. HTTP: http://xx
3. HTTPS: https://xx
4. HLS: http://xx or https://xx
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.INTERNET (The latter is required only when online resources are used.)| +| fdSrc9+ | [AVFileDescriptor](#interruptmode9) | Yes| Yes| Description of a video file. This attribute is required when video resources of an application are continuously stored in a file.
**Example:**
Assume that a music file that stores continuous music resources consists of the following:
Video 1 (address offset: 0, byte length: 100)
Video 2 (address offset: 101; byte length: 50)
Video 3 (address offset: 151, byte length: 150)
1. To play video 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }
2. To play video 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }
3. To play video 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }
To play an independent video file, use **src=fd://xx**.
**Note**:
**Required permissions**: ohos.permission.READ_MEDIA| | loop8+ | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. | -| currentTime8+ | number | Yes | No | Current video playback position. | -| duration8+ | number | Yes | No | Video duration. The value **-1** indicates the live streaming mode. | +| videoScaleType9+ | [VideoScaleType](#videoscaletype9) | Yes | Yes | Video scale type. | +| audioInterruptMode9+ | [InterruptMode](#interruptmode9) | Yes | Yes | Audio interruption mode. | +| currentTime8+ | number | Yes | No | Current video playback position, in ms. | +| duration8+ | number | Yes | No | Video duration, in ms. The value **-1** indicates the live mode. | | state8+ | [VideoPlayState](#videoplaystate8) | Yes | No | Video playback state. | -| width8+ | number | Yes | No | Video width. | -| height8+ | number | Yes | No | Video height. | +| width8+ | number | Yes | No | Video width, in pixels. | +| height8+ | number | Yes | No | Video height, in pixels. | ### setDisplaySurface8+ @@ -695,7 +727,7 @@ Sets **SurfaceId**. This API uses a callback to return the result. ```js videoPlayer.setDisplaySurface(surfaceId, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('setDisplaySurface success!'); } else { console.info('setDisplaySurface fail!'); @@ -753,7 +785,7 @@ Prepares for video playback. This API uses a callback to return the result. ```js videoPlayer.prepare((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('prepare success!'); } else { console.info('prepare fail!'); @@ -803,7 +835,7 @@ Starts to play video resources. This API uses a callback to return the result. ```js videoPlayer.play((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('play success!'); } else { console.info('play fail!'); @@ -853,7 +885,7 @@ Pauses video playback. This API uses a callback to return the result. ```js videoPlayer.pause((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('pause success!'); } else { console.info('pause fail!'); @@ -903,7 +935,7 @@ Stops video playback. This API uses a callback to return the result. ```js videoPlayer.stop((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('stop success!'); } else { console.info('stop fail!'); @@ -953,7 +985,7 @@ Switches the video resource to be played. This API uses a callback to return the ```js videoPlayer.reset((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('reset success!'); } else { console.info('reset fail!'); @@ -1005,7 +1037,7 @@ Seeks to the specified playback position. The next key frame at the specified po ```js let seekTime = 5000; videoPlayer.seek(seekTime, (err, result) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('seek success!'); } else { console.info('seek fail!'); @@ -1036,7 +1068,7 @@ import media from '@ohos.multimedia.media' let seekTime = 5000; let seekMode = media.SeekMode.SEEK_NEXT_SYNC; videoPlayer.seek(seekTime, seekMode, (err, result) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('seek success!'); } else { console.info('seek fail!'); @@ -1102,7 +1134,7 @@ Sets the volume. This API uses a callback to return the result. ```js let vol = 0.5; videoPlayer.setVolume(vol, (err, result) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('setVolume success!'); } else { console.info('setVolume fail!'); @@ -1159,7 +1191,7 @@ Releases the video playback resource. This API uses a callback to return the res ```js videoPlayer.release((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('release success!'); } else { console.info('release fail!'); @@ -1217,7 +1249,7 @@ function printfDescription(obj) { } videoPlayer.getTrackDescription((error, arrlist) => { - if (typeof (arrlist) != 'undefined') { + if (arrlist) != null) { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); } @@ -1254,7 +1286,7 @@ function printfDescription(obj) { let arrayDescription; videoPlayer.getTrackDescription().then((arrlist) => { - if (typeof (arrlist) != 'undefined') { + if (arrlist != null) { arrayDescription = arrlist; } else { console.log('video getTrackDescription fail'); @@ -1289,7 +1321,7 @@ import media from '@ohos.multimedia.media' let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; videoPlayer.setSpeed(speed, (err, result) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('setSpeed success!'); } else { console.info('setSpeed fail!'); @@ -1334,7 +1366,7 @@ videoPlayer.setSpeed(speed).then() => { selectBitrate(bitrate:number, callback: AsyncCallback\): void -Selects a bit rate from available bit rates. This API uses a callback to return the result. The available bit rates can be obtained by calling [availableBitrateCollected](#on('availableBitrateCollected')9+). +Selects a bit rate from available ones, which can be obtained by calling [availableBitratesCollect](#onavailablebitratescollect9). This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Media.VideoPlayer @@ -1350,7 +1382,7 @@ Selects a bit rate from available bit rates. This API uses a callback to return ```js let bitrate = 1024000; videoPlayer.selectBitrate(bitrate, (err, result) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('selectBitrate success!'); } else { console.info('selectBitrate fail!'); @@ -1362,7 +1394,7 @@ videoPlayer.selectBitrate(bitrate, (err, result) => { selectBitrate(bitrate:number): Promise\ -Selects a bit rate from available bit rates. This API uses a promise to return the result. The available bit rates can be obtained by calling [availableBitrateCollected](#on('availableBitrateCollected')9+). +Selects a bit rate from available ones, which can be obtained by calling [availableBitratesCollect](#onavailablebitratescollect9). This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Media.VideoPlayer @@ -1401,7 +1433,7 @@ Subscribes to the video playback completion event. | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ----------------------------------------------------------- | -| type | string | Yes | Event type, which is 'playbackCompleted' in this case.| +| type | string | Yes | Event type, which is **'playbackCompleted'** in this case.| | callback | function | Yes | Callback invoked when the event is triggered. | **Example** @@ -1424,7 +1456,7 @@ Subscribes to the video buffering update event. | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'bufferingUpdate' in this case. | +| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. | | callback | function | Yes | Callback invoked when the event is triggered.
When [BufferingInfoType](#bufferinginfotype8) is set to **BUFFERING_PERCENT** or **CACHED_DURATION**, **value** is valid. Otherwise, **value** is fixed at **0**.| **Example** @@ -1448,7 +1480,7 @@ Subscribes to the frame rendering start event. | Name | Type | Mandatory| Description | | -------- | --------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'startRenderFrame' in this case.| +| type | string | Yes | Event type, which is **'startRenderFrame'** in this case.| | callback | Callback\ | Yes | Callback invoked when the event is triggered. | **Example** @@ -1471,7 +1503,7 @@ Subscribes to the video width and height change event. | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'videoSizeChanged' in this case.| +| type | string | Yes | Event type, which is **'videoSizeChanged'** in this case.| | callback | function | Yes | Callback invoked when the event is triggered. **width** indicates the video width, and **height** indicates the video height. | **Example** @@ -1487,7 +1519,7 @@ videoPlayer.on('videoSizeChanged', (width, height) => { on(type: 'error', callback: ErrorCallback): void -Subscribes to the video playback error event. +Subscribes to video playback error events. After an error event is reported, you must handle the event and exit the playback. **System capability**: SystemCapability.Multimedia.Media.VideoPlayer @@ -1495,7 +1527,7 @@ Subscribes to the video playback error event. | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'error' in this case.
The 'error' event is triggered when an error occurs during video playback.| +| type | string | Yes | Event type, which is **'error'** in this case.
The **'error'** event is triggered when an error occurs during video playback.| | callback | ErrorCallback | Yes | Callback invoked when the event is triggered. | **Example** @@ -1506,12 +1538,12 @@ videoPlayer.on('error', (error) => { // Set the 'error' event callback. console.info(`video error called, errCode is ${error.code}`); // Print the error code. console.info(`video error called, errMessage is ${error.message}`);// Print the detailed description of the error type. }); -videoPlayer.setVolume(3); // Set volume to an invalid value to trigger the 'error' event. +videoPlayer.url = 'fd://error'; // Set an incorrect URL to trigger the 'error' event. ``` -### on('availableBitrateCollected')9+ +### on('availableBitratesCollect')9+ -on(type: 'availableBitrateCollected', callback: (bitrates: Array) => void): void +on(type: 'availableBitratesCollect', callback: (bitrates: Array\) => void): void Subscribes to the video playback bit rate reporting event. @@ -1521,15 +1553,15 @@ Subscribes to the video playback bit rate reporting event. | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'availableBitrateCollected' in this case. This event is reported only once when the playback starts.| -| callback | function | Yes | Callback used to return supported bit rates, in an array. | +| type | string | Yes | Event type, which is **'availableBitratesCollect'** in this case. This event is reported only once when the playback starts.| +| callback | function | Yes | Callback used to return supported bit rates, in an array. | **Example** ```js -videoPlayer.on('availableBitrateCollected', (bitrates) => { +videoPlayer.on('availableBitratesCollect', (bitrates) => { for (let i = 0; i < bitrates.length; i++) { - console.info('case availableBitrateCollected bitrates: ' + bitrates[i]); // Print bit rates. + console.info('case availableBitratesCollect bitrates: ' + bitrates[i]); // Print bit rates. } }); ``` @@ -1574,6 +1606,17 @@ Enumerates the video playback speeds, which can be passed in the **setSpeed** AP | SPEED_FORWARD_1_75_X | 3 | Plays the video at 1.75 times the normal speed.| | SPEED_FORWARD_2_00_X | 4 | Plays the video at 2.00 times the normal speed.| +## VideoScaleType9+ + +Enumerates the video scale modes. + +**System capability**: SystemCapability.Multimedia.Media.VideoPlayer + +| Name | Default Value| Description | +| ---------------------------- | ------ | ---------- | +| VIDEO_SCALE_TYPE_FIT | 0 | The video will be stretched to fit the window.| +| VIDEO_SCALE_TYPE_FIT_CROP| 1 | The video will be stretched to fit the window, without changing its aspect ratio. The content may be cropped. | + ## MediaDescription8+ ### [key : string] : Object @@ -1597,7 +1640,7 @@ function printfItemDescription(obj, key) { } audioPlayer.getTrackDescription((error, arrlist) => { - if (typeof (arrlist) != 'undefined') { + if (arrlist != null) { for (let i = 0; i < arrlist.length; i++) { printfItemDescription(arrlist[i], MD_KEY_TRACK_TYPE); // Print the MD_KEY_TRACK_TYPE value of each track. } @@ -1765,7 +1808,7 @@ Subscribes to the audio recording events. | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The following events are supported: 'prepare'\|'start'\| 'pause' \| 'resume' \|'stop'\|'release'\|'reset'
- The 'prepare' event is triggered when the [prepare](#audiorecorder_prepare) API is called and the audio recording parameters are set.
- The 'start' event is triggered when the [start](#audiorecorder_start) API is called and audio recording starts.
- The 'pause' event is triggered when the [pause](#audiorecorder_pause) API is called and audio recording is paused.
- The 'resume' event is triggered when the [resume](#audiorecorder_resume) API is called and audio recording is resumed.
- The 'stop' event is triggered when the [stop](#audiorecorder_stop) API is called and audio recording stops.
- The 'release' event is triggered when the [release](#audiorecorder_release) API is called and the recording resource is released.
- The 'reset' event is triggered when the [reset](#audiorecorder_reset) API is called and audio recording is reset.| +| type | string | Yes | Event type. The following events are supported:
- 'prepare': triggered when the [prepare](#audiorecorder_prepare) API is called and the audio recording parameters are set.
- 'start': triggered when the [start](#audiorecorder_start) API is called and audio recording starts.
- 'pause': triggered when the [pause](#audiorecorder_pause) API is called and audio recording is paused.
- 'resume': triggered when the [resume](#audiorecorder_resume) API is called and audio recording is resumed.
- 'stop': triggered when the [stop](#audiorecorder_stop) API is called and audio recording stops.
- 'release': triggered when the [release](#audiorecorder_release) API is called and the recording resource is released.
- 'reset': triggered when the [reset](#audiorecorder_reset) API is called and audio recording is reset. | | callback | ()=>void | Yes | Callback invoked when the event is triggered. | **Example** @@ -1781,41 +1824,41 @@ let audioRecorderConfig = { uri : 'fd://xx', // The file must be created by the caller and granted with proper permissions. location : { latitude : 30, longitude : 130}, } -audioRecorder.on('error', (error) => { // Set the error event callback. +audioRecorder.on('error', (error) => { // Set the 'error' event callback. console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errMessage is ${error.message}`); }); -audioRecorder.on('prepare', () => { // Set the prepare event callback. +audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. console.log('prepare success'); - audioRecorder.start(); // Start recording and trigger the start event callback. + audioRecorder.start(); // Start recording and trigger the 'start' event callback. }); -audioRecorder.on('start', () => { // Set the start event callback. +audioRecorder.on('start', () => { // Set the 'start' event callback. console.log('audio recorder start success'); }); -audioRecorder.on('pause', () => { // Set the pause event callback. +audioRecorder.on('pause', () => { // Set the 'pause' event callback. console.log('audio recorder pause success'); }); -audioRecorder.on('resume', () => { // Set the resume event callback. +audioRecorder.on('resume', () => { // Set the 'resume' event callback. console.log('audio recorder resume success'); }); -audioRecorder.on('stop', () => { // Set the stop event callback. +audioRecorder.on('stop', () => { // Set the 'stop' event callback. console.log('audio recorder stop success'); }); -audioRecorder.on('release', () => { // Set the release event callback. +audioRecorder.on('release', () => { // Set the 'release' event callback. console.log('audio recorder release success'); }); -audioRecorder.on('reset', () => { // Set the reset event callback. +audioRecorder.on('reset', () => { // Set the 'reset' event callback. console.log('audio recorder reset success'); }); -audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the prepare event callback. +audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the 'prepare' event callback. ``` ### on('error') on(type: 'error', callback: ErrorCallback): void -Subscribes to the audio recording error event. +Subscribes to audio recording error events. After an error event is reported, you must handle the event and exit the recording. **System capability**: SystemCapability.Multimedia.Media.AudioRecorder @@ -1823,18 +1866,18 @@ Subscribes to the audio recording error event. | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'error' in this case.
The 'error' event is triggered when an error occurs during audio recording.| +| type | string | Yes | Event type, which is **'error'** in this case.
The **'error'** event is triggered when an error occurs during audio recording.| | callback | ErrorCallback | Yes | Callback invoked when the event is triggered. | **Example** ```js -audioRecorder.on('error', (error) => { // Set the error event callback. +audioRecorder.on('error', (error) => { // Set the 'error' event callback. console.info(`audio error called, errName is ${error.name}`); // Print the error name. console.info(`audio error called, errCode is ${error.code}`); // Print the error code. console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type. }); -audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the error event callback. +audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the 'error' event callback. ``` ## AudioRecorderConfig @@ -1953,7 +1996,7 @@ let eventEmitter = new events.EventEmitter(); eventEmitter.on('prepare', () => { videoRecorder.prepare(videoConfig, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('prepare success'); } else { console.info('prepare failed and error is ' + err.message); @@ -1962,7 +2005,7 @@ eventEmitter.on('prepare', () => { }); media.createVideoRecorder((err, recorder) => { - if (typeof (err) == 'undefined' && typeof (recorder) != 'undefined') { + if (err == null && recorder != null) { videoRecorder = recorder; console.info('createVideoRecorder success'); eventEmitter.emit('prepare'); // Trigger the 'prepare' event. @@ -1978,7 +2021,7 @@ prepare(config: VideoRecorderConfig): Promise\; Sets video recording parameters in asynchronous mode. This API uses a promise to return the result. -**Required permissions:** ohos.permission.MICROPHONE and ohos.permission.CAMERA +**Required permissions:** ohos.permission.MICROPHONE **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2022,7 +2065,7 @@ let videoConfig = { // promise let videoRecorder = null; media.createVideoRecorder().then((recorder) => { - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; console.info('createVideoRecorder success'); } else { @@ -2063,7 +2106,7 @@ This API can be called only after [prepare()](#videorecorder_prepare1) is called // asyncallback let surfaceID = null; // Surface ID passed to the external system. videoRecorder.getInputSurface((err, surfaceId) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('getInputSurface success'); surfaceID = surfaceId; } else { @@ -2109,7 +2152,7 @@ start(callback: AsyncCallback\): void; Starts video recording in asynchronous mode. This API uses a callback to return the result. -This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first. +This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) are called, because the data source must pass data to the surface first. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2124,7 +2167,7 @@ This API can be called only after [prepare()](#videorecorder_prepare1) and [getI ```js // asyncallback videoRecorder.start((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('start videorecorder success'); } else { console.info('start videorecorder failed and error is ' + err.message); @@ -2138,7 +2181,7 @@ start(): Promise\; Starts video recording in asynchronous mode. This API uses a promise to return the result. -This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first. +This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) are called, because the data source must pass data to the surface first. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2180,7 +2223,7 @@ This API can be called only after [start()](#videorecorder_start1) is called. Yo ```js // asyncallback videoRecorder.pause((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('pause videorecorder success'); } else { console.info('pause videorecorder failed and error is ' + err.message); @@ -2234,7 +2277,7 @@ Resumes video recording in asynchronous mode. This API uses a callback to return ```js // asyncallback videoRecorder.resume((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('resume videorecorder success'); } else { console.info('resume videorecorder failed and error is ' + err.message); @@ -2273,7 +2316,7 @@ stop(callback: AsyncCallback\): void; Stops video recording in asynchronous mode. This API uses a callback to return the result. -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. +To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2288,7 +2331,7 @@ To start another recording, you must call [prepare()](#videorecorder_prepare1) a ```js // asyncallback videoRecorder.stop((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('stop videorecorder success'); } else { console.info('stop videorecorder failed and error is ' + err.message); @@ -2302,7 +2345,7 @@ stop(): Promise\; Stops video recording in asynchronous mode. This API uses a promise to return the result. -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. +To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2342,7 +2385,7 @@ Releases the video recording resource in asynchronous mode. This API uses a call ```js // asyncallback videoRecorder.release((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('release videorecorder success'); } else { console.info('release videorecorder failed and error is ' + err.message); @@ -2381,7 +2424,7 @@ reset(callback: AsyncCallback\): void; Resets video recording in asynchronous mode. This API uses a callback to return the result. -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. +To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2396,7 +2439,7 @@ To start another recording, you must call [prepare()](#videorecorder_prepare1) a ```js // asyncallback videoRecorder.reset((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('reset videorecorder success'); } else { console.info('reset videorecorder failed and error is ' + err.message); @@ -2410,7 +2453,7 @@ reset(): Promise\; Resets video recording in asynchronous mode. This API uses a promise to return the result. -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. +To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2435,7 +2478,7 @@ videoRecorder.reset().then(() => { on(type: 'error', callback: ErrorCallback): void -Subscribes to the video recording error event. +Subscribes to video recording error events. After an error event is reported, you must handle the event and exit the recording. **System capability**: SystemCapability.Multimedia.Media.VideoRecorder @@ -2443,13 +2486,13 @@ Subscribes to the video recording error event. | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type, which is 'error' in this case.
The 'error' event is triggered when an error occurs during video recording.| +| type | string | Yes | Event type, which is **'error'** in this case.
The **'error'** event is triggered when an error occurs during video recording.| | callback | ErrorCallback | Yes | Callback invoked when the event is triggered. | **Example** ```js -videoRecorder.on('error', (error) => { // Set the error event callback. +videoRecorder.on('error', (error) => { // Set the 'error' event callback. console.info(`audio error called, errName is ${error.name}`); // Print the error name. console.info(`audio error called, errCode is ${error.code}`); // Print the error code. console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type. @@ -2485,7 +2528,7 @@ Describes the video recording parameters. | profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. | | rotation | number | No | Rotation angle of the recorded video. | | location | [Location](#location) | No | Geographical location of the recorded video. | -| url | string | Yes | Video output URL. Supported: fd://xx (fd number)
![](figures/en-us_image_url.png)
The file must be created by the caller and granted with proper permissions.| +| url | string | Yes | Video output URL. Supported: fd://xx (fd number)
![](figures/en-us_image_url.png)
**Required permissions**: ohos.permission.READ_MEDIA| ## AudioSourceType9+ diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md index b59e88a401cebca64a2be96b29de92dd375e893d..b66eeec85c124ac083b27859849a86e1a5f1d4c2 100644 --- a/en/application-dev/reference/apis/js-apis-medialibrary.md +++ b/en/application-dev/reference/apis/js-apis-medialibrary.md @@ -2280,7 +2280,7 @@ Describes options for fetching media files. | ----------------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ | | selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?', | | selectionArgs | Array<string> | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.
Example:
selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], | -| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"| +| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " ASC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC" | | uri8+ | string | Yes | Yes | No | File URI. | | networkId8+ | string | Yes | Yes | No | Network ID of the registered device. | | extendArgs8+ | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. | diff --git a/en/application-dev/reference/apis/js-apis-missionManager.md b/en/application-dev/reference/apis/js-apis-missionManager.md index b981d28061d45feb313dbaf7ea0709d6f198e0e8..50057062701f1ddbe0b058dc79e957c1a47e63a3 100644 --- a/en/application-dev/reference/apis/js-apis-missionManager.md +++ b/en/application-dev/reference/apis/js-apis-missionManager.md @@ -362,6 +362,88 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r }); ``` +## missionManager.getLowResolutionMissionSnapShot9+ + +getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\): void; + +Obtains the low-resolution snapshot of a given mission. This API uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | missionId | number | Yes| Mission ID.| + | callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => { + console.log("getLowResolutionMissionSnapShot is called, error.code = " + error.code); + console.log("bundleName = " + snapshot.ability.bundleName); + }) + }) + ``` + + +## missionManager.getLowResolutionMissionSnapShot9+ + +getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\; + +Obtains the low-resolution snapshot of a given mission. This API uses a promise to return the result. + +**Required permission**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | missionId | number | Yes| Mission ID.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions; + missionManager.getMissionInfos("",10).then(function(res){ + allMissions=res; + }).catch(function(err){console.log(err);}); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + + var snapshot = missionManager.getLowResolutionMissionSnapShot("", id).catch(function (err){ + console.log(err); + }); + ``` + ## missionManager.lockMission diff --git a/en/application-dev/reference/apis/js-apis-nfcController.md b/en/application-dev/reference/apis/js-apis-nfcController.md index d4c99452483b63a9893905329d4fd1aae0be4505..c8a9d7cf699963e494c5f04c1d5e887e8795eb0f 100644 --- a/en/application-dev/reference/apis/js-apis-nfcController.md +++ b/en/application-dev/reference/apis/js-apis-nfcController.md @@ -1,9 +1,9 @@ # Standard NFC -Implements Near-Field Communication (NFC). +The **nfcController** module implements Near-Field Communication (NFC). > **NOTE**
-> The initial APIs of this module are supported since API version 8. 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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## **Modules to Import** @@ -19,6 +19,8 @@ isNfcAvailable(): boolean Checks whether NFC is available. +**System capability**: SystemCapability.Communication.NFC.Core + **Return value** | **Type**| **Description**| @@ -34,7 +36,7 @@ Opens NFC. **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** @@ -50,7 +52,7 @@ Closes NFC. **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** @@ -64,7 +66,7 @@ isNfcOpen(): boolean Checks whether NFC is open. -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** @@ -78,7 +80,7 @@ getNfcState(): NfcState Obtains the NFC state. -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** @@ -92,7 +94,7 @@ on(type: "nfcStateChange", callback: Callback<NfcState>): void Subscribes to NFC state changes. -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Parameter** @@ -109,7 +111,7 @@ off(type: "nfcStateChange", callback?: Callback<NfcState>): void Unsubscribes from the NFC state changes. -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Parameter** @@ -140,6 +142,8 @@ Unsubscribes from the NFC state changes. Enumerates the NFC states. +**System capability**: SystemCapability.Communication.NFC.Core + | Name| Default Value| Description| | -------- | -------- | -------- | | STATE_OFF | 1 | Off| diff --git a/en/application-dev/reference/apis/js-apis-nfcTag.md b/en/application-dev/reference/apis/js-apis-nfcTag.md index 51731e95e192713e71add3304331475c11dd6629..01315a62d6aecacea806cdecebc268ed1f571c84 100644 --- a/en/application-dev/reference/apis/js-apis-nfcTag.md +++ b/en/application-dev/reference/apis/js-apis-nfcTag.md @@ -1,78 +1,171 @@ # Standard NFC Tag -Manages Near-Field Communication (NFC) tags. +The **nfcTag** module provides methods for managing Near-Field Communication (NFC) tags. > **NOTE**
-> The initial APIs of this module are supported since API version 8. 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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## **Modules to Import** -``` +```js import tag from '@ohos.nfc.tag'; ``` - ## tag.getNfcATag -getNfcATag(tagInfo: TagInfo): NfcATag +getNfcATag(tagInfo: [TagInfo](#taginfo9)): [NfcATag](js-apis-nfctech.md#nfcatag) Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology. **Required permissions**: ohos.permission.NFC_TAG -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** | **Type**| **Description**| | -------- | -------- | -| NfcATag | **NfcATag** object obtained.| +| [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.| ## tag.getNfcBTag -getNfcBTag(tagInfo: TagInfo): NfcBTag +getNfcBTag(tagInfo: [TagInfo](#taginfo9)): [NfcBTag](js-apis-nfctech.md#nfcbtag) Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology. **Required permissions**: ohos.permission.NFC_TAG -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** | **Type**| **Description** | | -------- | ---------------- | -| NfcBTag | **NfcBTag** object obtained.| +| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| ## tag.getNfcFTag -getNfcFTag(tagInfo: TagInfo): NfcFTag +getNfcFTag(tagInfo: [TagInfo](#taginfo9)): [NfcFTag](js-apis-nfctech.md#nfcftag) Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology. **Required permissions**: ohos.permission.NFC_TAG -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** | **Type**| **Description** | | -------- | ---------------- | -| NfcFTag | **NfcFTag** object obtained.| +| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| ## tag.getNfcVTag -getNfcVTag(tagInfo: TagInfo): NfcVTag +getNfcVTag(tagInfo: [TagInfo](#taginfo9)): [NfcVTag](js-apis-nfctech.md#nfcvtag) Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology. **Required permissions**: ohos.permission.NFC_TAG -**System capability**: SystemCapability.Communication.NFC +**System capability**: SystemCapability.Communication.NFC.Core **Return value** | **Type**| **Description** | | -------- | ---------------- | -| NfcVTag | **NfcVTag** object obtained.| +| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| + +## tag.getIsoDepTag9+ + +getIsoDepTag(tagInfo: [TagInfo](#taginfo9)): [IsoDepTag](js-apis-nfctech.md#isodeptag9 ) + +Obtains an **IsoDepTag** object, which allows access to the tags that use the ISO-DEP technology. + + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ---------- | ------------------| +| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | **IsoDepTag** object obtained.| + +## tag.getNdefTag9+ + +getNdefTag(tagInfo: [TagInfo](#taginfo9)): [NdefTag](js-apis-nfctech.md#ndeftag9) + +Obtains an **NdefTag** object, which allows access to the tags in the NFC Data Exchange Format (NDEF). + + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ---------| -------------- | +| [NdefTag](js-apis-nfctech.md#ndeftag9) | **NdefTag** object obtained.| + +## tag.getMifareClassicTag9+ + +getMifareClassicTag(tagInfo: [TagInfo](#taginfo9)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) + +Obtains a **MifareClassicTag** object, which allows access to the tags that use MIFARE Classic. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ----------------- | ------------------------| +| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.| + +## tag.getMifareUltralightTag9+ + +getMifareUltralightTag(tagInfo: [TagInfo](#taginfo9)): [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) + +Obtains a **MifareUltralightTag** object, which allows access to the tags that use MIFARE Ultralight. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| -------------------- | ---------------------------| +| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | **MifareUltralightTag** object obtained.| + +## tag.getNdefFormatableTag9+ + +getNdefFormatableTag(tagInfo: [TagInfo](#taginfo9)): [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag9) + +Obtains an **NdefFormatableTag** object, which allows access to the tags that are NDEF formattable. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | **NdefFormatableTag** object obtained.| + +## TagInfo9+ + +Represents the NFC tag information. + +| **Name**| **Type**| **Description**| +| -------- | -------- | -------- | +| uid | string | UID of the tag.| +| technology | number[] | Technology supported by the tag.| +| extrasData | PacMap[] | Additional information about the tag.| +| tagRfDiscId | number | RF discovery ID of the tag.| +| remoteTagService | rpc.RemoteObject | RPC remote object of the tag service.| +| supportedProfiles | number[] | Profiles supported by the tag.| diff --git a/en/application-dev/reference/apis/js-apis-nfctech.md b/en/application-dev/reference/apis/js-apis-nfctech.md new file mode 100644 index 0000000000000000000000000000000000000000..eb7d01dda3b5bcf8c88a45981d661aacf6d4e4f4 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-nfctech.md @@ -0,0 +1,1820 @@ +# Standard NFC Tag Technologies + +The **nfctech** module provides methods for reading and writing tags that use different Near-Field Communication (NFC) technologies. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## **Modules to Import** + +```js +import tag from '@ohos.nfc.tag'; +``` + +## NfcATag + +Provides access to NFC-A (ISO 14443-3A) properties and I/O operations. **NfcATag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **NfcATag**. + +### NfcATag.getSak + +getSak(): number + +Obtains the SAK value of this NFC-A tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | SAK value obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let sak = tag.getNfcATag(taginfo).getSak(); +console.log("sak:" +sak); +``` + +### NfcATag.getAtqa + +getAtqa(): number[] + +Obtains the ATQA value of this NFC-A tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number[] | ATQA value obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let atqa = tag.getNfcATag(taginfo).getAtqa(); +console.log("atqa:" +atqa); +``` + +## NfcBTag + +Provides access to NFC-B (ISO 14443-3B) properties and I/O operations. **NfcBTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **NfcBTag**. + +### NfcBTag.getRespAppData + +getRespAppData(): number[] + +Obtains the application data of this NFC-B tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number[] | Application data obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let appData = tag.getNfcBTag(taginfo).getRespAppData(); +console.log("appData:" +appData); +``` + +### NfcBTag.getRespProtocol + +getRespProtocol(): number[] + +Obtains protocol information of this NFC-B tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number[] | Protocol information obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let protocol = tag.getNfcBTag(taginfo).getRespProtocol(); +console.log("appData:" +protocol); +``` + +## NfcFTag + +Provides access to NFC-F(JIS 6319-4) properties and I/O operations. **NfcFTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **NfcFTag**. + +### NfcFTag.getSystemCode + +getSystemCode(): number[] + +Obtains the system code from the tag instance. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number[] | System code obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let systemCode = tag.getNfcFTag(taginfo).getSystemCode(); +console.log("systemCode:" +systemCode); +``` + +### NfcFTag.getPmm + +getPmm(): number[] + +Obtains the PMm (consisting of the IC code and manufacturer parameters) information from the tag instance. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number[] | PMm information obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let pmm = tag.getNfcFTag(taginfo).getPmm(); +console.log("pmm:" +pmm); +``` + +## NfcVTag + +Provides access to NFC-V (ISO 15693) properties and I/O operations. **NfcVTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **NfcVTag**. + +### NfcvTag.getResponseFlags + +getResponseFlags(): number + +Obtains the response flags from the tag instance. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | Response flags obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let flags = tag.getNfcVTag(taginfo).getResponseFlags(); +console.log("flags:" +flags); +``` + +### NfcvTag.getDsfId + +getDsfId(): number + +Obtains the data storage format identifier (DSFID) from the tag instance. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | DSFID obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let dsfId = tag.getNfcVTag(taginfo).getDsfId(); +console.log("dsfId:" +dsfId); +``` + +## IsoDepTag9+ + +Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations. **IsoDepTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **IsoDepTag**. + +### IsoDepTag.getHistoricalBytes9+ + +getHistoricalBytes(): string + +Obtains the historical bytes of this tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| string | Historical bytes obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let historicalBytes = tag.getIsoDepTag(taginfo).getHistoricalBytes(); +console.log("historicalBytes:" +historicalBytes); +``` + +### IsoDepTag.getHiLayerResponse9+ + +getHiLayerResponse(): string + +Obtains the HiLayer response of this tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| string | HiLayer response obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let hiLayerResponse = tag.getIsoDepTag(taginfo).getHiLayerResponse(); +console.log("hiLayerResponse:" +hiLayerResponse); +``` + +### IsoDepTag.isExtendedApduSupported9+ + +isExtendedApduSupported(): Promise<boolean> + +Checks whether an extended application protocol data unit (APDU) is supported. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise<boolean> | Promise used to return the result. If the extended APDU is supported, **true** is returned; otherwise, **false** is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.getIsoDepTag(taginfo).isExtendedApduSupported().then(function (has) { + console.log('has: ' + has) +}) +``` + +### IsoDepTag.isExtendedApduSupported9+ + +isExtendedApduSupported(callback: AsyncCallback\): void + +Checks whether an extended application protocol data unit (APDU) is supported. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the extended APDU is supported, **true** is returned; otherwise, **false** is returned.| + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.getIsoDepTag(taginfo).isExtendedApduSupported(function (error, has) { + console.log(JSON.stringify(error)) + console.log('has: ' + has) +}) +``` + +## NdefTag9+ + +Provides access to the tags in the NFC Data Exchange Format (NDEF). **NdefTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **NdefTag**. + +### NdefTag.createNdefMessage9+ + +createNdefMessage(data: string): [NdefMessage](#ndefmessage9) + +Creates an NDEF message using raw bytes. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| data | string | Yes| Raw bytes of the string type.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| [NdefMessage](#ndefmessage9) | NDEF message created.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let NdefMessage = tag.NdefTag(taginfo).createNdefMessage(data); +``` + +## NdefMessage9+ + +### NdefMessage.getNdefRecords9+ + +getNdefRecords(): [NdefRecord](#ndefrecord9)[ ] + +Obtains all NDEF records. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| [NdefRecord](#ndefrecord9)[ ] | All records obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let NdefRecord = tag.NdefTag(taginfo).getNdefRecords(); +``` + +## NdefRecord9+ + +| **Name**| **Type**| **Description**| +| -------- | -------- | -------- | +| tnf | number | UID of the tag.| +| [rtdType](#rtdtype9) | string | NFC Record Type Definition (RTD) supported by the tag.| +| id | string | Additional information about the tag.| +| payload | string | RF discovery ID of the tag.| + +## RtdType9+ + +| **Name**| **Type**| **Description**| +| -------- | -------- | -------- | +| RTD_TEXT | 'T' | Text information.| +| RTD_URI | 'U' | Network address, email, or phone number.| + +### NdefTag.createNdefMessage9+ + +createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](#ndefmessage9) + +Creates an NDEF message using the NDEF records. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| ndefRecords | [NdefRecord](#ndefrecord9)[] | Yes| A list of NDEF records.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| [NdefMessage](#ndefmessage9) | NDEF message created.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let NdefMessage = tag.NdefTag(taginfo).createNdefMessage(ndefRecords); +``` + +### NdefTag.getNdefTagType9+ + +getNdefTagType(): NfcForumType + +Obtains the type of this NDEF tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| [NfcForumType](#nfcforumtype9) | NDEF tag type obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let NfcForumType = tag.NdefTag(taginfo).getNdefTagType(); +``` + +### NdefTag.getNdefMessage9+ + +getNdefMessage(): NdefMessage + +Obtains the NDEF message from the tag discovered. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| [NdefMessage](#ndefmessage9) | NDEF message created.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let NdefMessage = tag.NdefTag(taginfo).getNdefMessage(); +``` + +### NdefTag.isNdefWritable9+ + +isNdefWritable(): Promise<boolean> + +Checks whether the NDEF tag is writable. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise<boolean> | Promise used to return the result. If the tag is writable, **true** is returned; otherwise, **false** is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).isNdefWritable().then(function (has) { + console.log(JSON.stringify(has)) +}) +``` + +### NdefTag.isNdefWritable9+ + +isNdefWritable(callback: AsyncCallback<boolean>): void; + +Checks whether the NDEF tag is writable. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the tag is writable, **true** is returned; otherwise, **false** is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).isNdefWritable(function (error, has) { + console.log(JSON.stringify(error)) + console.log('has: ' + has) +}) +``` + +### NdefTag.readNdef9+ + +readNdef(): Promise\ + +Reads the NDEF message from this tag. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\<[NdefMessage](#ndefmessage9)> | Promise used to return the message read.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).readNdef().then(function (ndefMessage) { + console.log(JSON.stringify(ndefMessage)) +}) +``` + +### NdefTag.readNdef9+ + +readNdef(callback: AsyncCallback\<[NdefMessage](#ndefmessage9)>): void + +Reads the NDEF message from this tag. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\<[NdefMessage](#ndefmessage9)> | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).readNdef(function (error, ndefMessage) { + console.log(JSON.stringify(error)) + console.log('ndefMessage: ' + ndefMessage) +}) +``` + +### NdefTag.writeNdef9+ + +writeNdef(msg: NdefMessage): Promise\; + +Write an NDEF message to this tag. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| msg | NdefMessage | Yes | NDEF message to write.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +NdefTag.writeNdef(msg).then(function (netHandle) { + console.log(JSON.stringify(netHandle)) +}) +``` + +### NdefTag.writeNdef9+ + +writeNdef(msg: NdefMessage, callback: AsyncCallback\): void + +Write an NDEF message to this tag. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| msg | NdefMessage | Yes | NDEF message to write.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).write(msg, function (error, has) { + console.log(JSON.stringify(error)) + console.log('has: ' + has) +}) +``` + +### NdefTag.canSetReadOnly9+ + +canSetReadOnly(): Promise\ + +Checks whether this NDEF tag can be set to read-only. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise<boolean> | Promise used to return the result. If the tag can be set to read-only, **true** is returned; otherwise, **false** is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).canSetReadOnly().then(function (has) { + console.log(JSON.stringify(has)) +}) +``` + +### NdefTag.canSetReadOnly9+ + +canSetReadOnly()(callback: AsyncCallback<boolean>): void; + +Checks whether this NDEF tag can be set to read-only. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the tag can be set to read-only, **true** is returned; otherwise, **false** is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).canSetReadOnly(function (error, has) { + console.log(JSON.stringify(error)) + console.log('has: ' + has) +}) +``` + +### NdefTag.setReadOnly9+ + +setReadOnly(): Promise\ + +Sets this NDEF tag to read-only. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise<number> | Promise used to return the result. If the operation is successful, **0** is returned; otherwise, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).setReadOnly().then(function (errcode) { + console.log(JSON.stringify(errcode)) +}) +``` + +### NdefTag.setReadOnly9+ + +setReadOnly(callback: AsyncCallback): void + +Sets this NDEF tag to read-only. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefTag(taginfo).setReadOnly(function (error, errcode) { + console.log(JSON.stringify(error)) + console.log('has: ' + errcode) +}) +``` + +### NdefTag.getNdefTagTypeString9+ + +getNdefTagTypeString(type: [NfcForumType](#nfcforumtype9)): string + +Converts the NFC Forum Type to a byte array defined in the NFC Forum. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| type | [NfcForumType](#nfcforumtype9) | Yes | NFC Forum Type.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| string | Byte array obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let ndefTypeString= tag.NdefTag(taginfo).getNdefTagTypeString(type); +``` + +## NfcForumType9+ + +| **Name**| **Type**| **Description**| +| -------- | -------- | -------- | +| NFC_FORUM_TYPE_1 | 1 | NFC Forum Type 1.| +| NFC_FORUM_TYPE_2 | 2 | NFC Forum Type 2.| +| NFC_FORUM_TYPE_3 | 3 | NFC Forum Type 3.| +| NFC_FORUM_TYPE_4 | 4 | NFC Forum Type 4.| +| MIFARE_CLASSIC | 101 | MIFARE Classic.| + +## MifareClassicTag 9+ + +Provides access to MIFARE Classic properties and I/O operations. **MifareClassicTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **MifareClassicTag**. + +### MifareClassicTag.authenticateSector9+ + +authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise\ + +Authenticates a sector using the key. The sector can be accessed only after the authentication is successful. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| sectorIndex | number | Yes | Index of the sector to authenticate.| +| key | number[]| Yes | Key (6 bytes) used for authentication.| +| isKeyA | boolean | Yes | Whether the key is key A. The value **true** indicates key A, and **false** indicates key B.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If the authentication is successful, **true** is returned. Otherwise, **false** is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).authenticateSector(sectorIndex, key).then(function (isKeyA) { + console.log(JSON.stringify(isKeyA)) + }) +``` + +### MifareClassicTag.authenticateSector9+ + +authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback): void + +Authenticates a sector using the key. The sector can be accessed only after the authentication is successful. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| sectorIndex | number | Yes | Index of the sector to authenticate.| +| key | number[]| Yes | Key (6 bytes) used for authentication.| +| isKeyA | boolean | Yes | Whether the key is key A. The value **true** indicates key A, and **false** indicates key B.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).authenticateSector(sectorIndex, key, function (error, has) { + console.log(JSON.stringify(error)) + console.log('has: ' + has) +}) +``` + +### MifareClassicTag.readSingleBlock9+ + +readSingleBlock(blockIndex: number): Promise\ + +Reads a block on the tag. The size of a block is 16 bytes. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the block to read.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the block data read.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +let data = "xxx"; +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).readSingleBlock(blockIndex).then(function (data){ + console.log('data: ' + data) + }) +``` + +### MifareClassicTag.readSingleBlock9+ + +readSingleBlock(blockIndex: number, callback: AsyncCallback\): void + +Reads a block on the tag. The size of a block is 16 bytes. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the block to read.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the block read.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +let data = "xxx"; +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).readSingleBlock(blockIndex, function (error, data) { + console.log(JSON.stringify(error)) + console.log('data: ' + data) +}) +``` + +### MifareClassicTag.writeSingleBlock9+ + +writeSingleBlock(blockIndex: number, data: string): Promise\ + +Writes data to a block on the tag. The size of a block is 16 bytes. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the target block.| +| data | string | Yes | Data to write.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +let data = "xxx"; +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).writeSingleBlock(blockIndex, data).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### MifareClassicTag.writeSingleBlock9+ + +writeSingleBlock(blockIndex: number, data: string, callback: AsyncCallback\): void + +Writes data to a block on the tag. The size of a block is 16 bytes. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the target block.| +| data | string | Yes | Data to write.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +let data = "xxx"; +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).writeSingleBlock(blockIndex, data, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` + +### MifareClassicTag.incrementBlock9+ + +incrementBlock(blockIndex: number, value: number): Promise\ + +Increments a block with data. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the block to increment.| +| value | number | Yes | Block data to increment. The value is a non-negative number.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).incrementBlock(blockIndex, value).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### MifareClassicTag.incrementBlock9+ + +incrementBlock(blockIndex: number, value: number, callback: AsyncCallback\): void + +Increments a block with data. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the block to increment.| +| value | number | Yes | Block data to increment. The value is a non-negative number.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).incrementBlock(blockIndex, value, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` + +### MifareClassicTag.decrementBlock9+ + +decrementBlock(blockIndex: number, value: number): Promise\ + +Decrements a block with data. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the block to decrement.| +| value | number | Yes | Block data to decrement. The value is a non-negative number.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).decrementBlock(blockIndex, value).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### MifareClassicTag.decrementBlock9+ + +decrementBlock(blockIndex: number, value: number, callback: AsyncCallback\): void + +Decrements a block with data. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the block to decrement.| +| value | number | Yes | Block data to decrement. The value is a non-negative number.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).decrementBlock(blockIndex, value, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` + +### MifareClassicTag.transferToBlock9+ + +transferToBlock(blockIndex: number): Promise\ + +Copies data from the register to a block. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the destination block.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js + +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).transferToBlock(blockIndex).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### MifareClassicTag.transferToBlock + +transferToBlock(blockIndex: number, callback: AsyncCallback\): void + +Copies data from the register to a block. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the destination block.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).transferToBlock(blockIndex, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` + +### MifareClassicTag.restoreFromBlock9+ + +restoreFromBlock(blockIndex: number): Promise\ + +Copies data from a block to the register. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the source block.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js + +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).restoreFromBlock(blockIndex).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### MifareClassicTag.restoreFromBlock9+ + +restoreFromBlock(blockIndex: number, callback: AsyncCallback\): void + +Copies data from a block to the register. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the source block.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareClassicTag(taginfo).restoreFromBlock(blockIndex, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` + +### MifareClassicTag.getSectorCount9+ + +getSectorCount(): number + +Obtains the number of sectors in this MIFARE Classic tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | Number of sectors obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let setorCount = tag.MifareClassicTag(taginfo).getSectorCount(); +``` + +### MifareClassicTag.getBlockCountInSector9+ + +getBlockCountInSector(sectorIndex: number): number + +Obtains the number of blocks in a sector. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| sectorIndex | number | Yes | Index of the sector.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | Number of blocks obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let blockNumber = tag.MifareClassicTag(taginfo).getBlockCountInSector(sectorIndex); +``` + +### MifareClassicTag.getType9+ + +getType(): [MifareClassicType](#mifareclassictype9) + +Obtains the type of this MIFARE Classic tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| [MifareClassicType](#mifareclassictype9) | Type of the MIFARE Classic tag obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let type = tag.MifareClassicTag(taginfo).getType(); +``` + +### MifareClassicTag.getTagSize9+ + +getTagSize(): number + +Obtains the tag size (in bytes). For details, see [MifareTagSize](#mifaretagsize9). + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | Tag size obtained, in bytes. For details, see [MifareTagSize](#mifaretagsize9).| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let size = tag.MifareClassicTag(taginfo).getTagSize(); +``` + +## MifareClassicType9+ + +| **Name**| **Value**| **Description**| +| -------- | -------- | -------- | +| TYPE_UNKNOWN | -1 | Unknown type.| +| TYPE_CLASSIC | 0 | MIFARE Classic.| +| TYPE_PLUS | 1 | MIFARE Plus.| +| TYPE_PRO | 2 | MIFARE Pro.| + +## MifareTagSize9+ + +| **Name**| **Value**| **Description**| +| -------- | -------- | -------- | +| MC_SIZE_MINI | 320 | Each tag has five sectors, and each sector has four blocks.| +| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has four blocks.| +| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has four blocks.| +| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has four blocks.| + +### MifareClassicTag.isEmulatedTag9+ + +isEmulatedTag(): boolean + +Checks whether the tag is an emulated tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| boolean |Returns **true** if the tag is an emulated tag; returns **false** otherwise.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let isEmulated = tag.MifareClassicTag(taginfo).isEmulatedTag(); +``` + +### MifareClassicTag.getBlockIndex9+ + +getBlockIndex(sectorIndex: number): number + +Obtains the first block of a sector. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| sectorIndex | number | Yes | Index of the sector.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | Index of the first block obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let index = tag.MifareClassicTag(taginfo).getBlockIndex(sectorIndex); +``` + +### MifareClassicTag.getSectorIndex9+ + +getSectorIndex(blockIndex: number): number + +Obtains the index of a sector that contains the specified block. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| blockIndex | number | Yes | Index of the block contained in the sector.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | Index of the sector obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let index = tag.MifareClassicTag(taginfo).getSectorIndex(blockIndex); +``` + +## MifareUltralightTag9+ + +Provides access to MIFARE Ultralight properties and I/O operations. **MifareUltralightTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **MifareUltralightTag**. + +### MifareUltralightTag.readMultiplePages9+ + +readMultiplePages(pageIndex: number): Promise\ + +Reads multiple pages. The size of each page is 4 bytes. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------------ | +| pageIndex | number | Yes | Indexes of the pages to read.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the data read.| + +**Example** + +```js + +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareUltralightTag(taginfo).readMultiplePages(pageIndex).then(function (data){ + console.log("data: " + data) + }) +``` + +### MifareUltralightTag.readMultiplePages9+ + +readMultiplePages(pageIndex: number, callback: AsyncCallback\): void + +Reads multiple pages. The size of each page is 4 bytes. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| pageIndex | number | Yes | Indexes of the pages to read.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the data read.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareUltralightTag(taginfo).readMultiplePages(pageIndex, function (error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}) +``` + +### MifareUltralightTag.writeSinglePages9+ + +writeSinglePages(pageIndex: number, data: string): Promise\ + +Writes a page of data. The size of each page is 4 bytes. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| pageIndex | number | Yes | Index of the page.| +| data | string | Yes | Data to write.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareUltralightTag(taginfo).writeSinglePages(pageIndex, data).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### MifareUltralightTag.writeSinglePages9+ + +writeSinglePages(pageIndex: number, data: string, callback: AsyncCallback\): void + +Writes a page of data. The size of each page is 4 bytes. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------ | +| pageIndex | number | Yes | Index of the page.| +| data | string | Yes | Data to write.| +| callback|AsyncCallback\ |Yes| Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.MifareUltralightTag(taginfo).writeSinglePages(pageIndex, data, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` + +### MifareUltralightTag.getType9+ + +getType(): MifareUltralightType + +Obtains the MIFARE Ultralight tag type, in bytes. For details, see [MifareUltralightType](#mifareultralighttype9). + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| MifareUltralightType | Type of the MIFARE Ultralight tag. For details, see [MifareUltralightType](#mifareultralighttype9).| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let type = tag.MifareUltralightType(taginfo).getType(); +``` + +### MifareUltralightType9+ + +| **Name**| **Value**| **Description**| +| -------- | -------- | -------- | +| TYPE_UNKOWN | -1 | Unknown type.| +| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight.| +| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.| + +## NdefFormatableTag9+ + +Provides methods for operating NDEF formattable tags. **NdefFormatableTag** inherits from **TagSession**. + +**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md). + +The following describes the unique interfaces of **NdefFormatableTag**. + +### NdefFormatableTag.format9+ + +format(message: [NdefMessage](#ndefmessage9)): Promise\ + +Formats this tag as an NDEF tag, and writes an NDEF message to the tag. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefFormatableTag(taginfo).format(message).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### NdefFormatableTag.format9+ + +format(message: [NdefMessage](#ndefmessage9), callback: AsyncCallback\): void + +Formats this tag as an NDEF tag, and writes an NDEF message to the tag. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.| +| callback: AsyncCallback\ | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefFormatableTag(taginfo).format(message, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` + +### NdefFormatableTag.formatReadOnly9+ + +formatReadOnly(message: [NdefMessage](#ndefmessage9)): Promise\ + +Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and then sets the tag to read-only. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.| + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| Promise\ | Promise used to return the result. If **0** is returned, the operation is successful. If the operation fails, an error code is returned.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefFormatableTag(taginfo).formatReadOnly(message).then(function (errcode){ + console.log(JSON.stringify(errcode)) + }) +``` + +### NdefFormatableTag.formatReadOnly9+ + +formatReadOnly(message: [NdefMessage](#ndefmessage9), callback: AsyncCallback\): void + +Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and then sets the tag to read-only. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.| +| callback: AsyncCallback\ | Callback invoked to return the result.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +tag.NdefFormatableTag(taginfo).formatReadOnly(message, function (error, errcode) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(errcode)) +}) +``` diff --git a/en/application-dev/reference/apis/js-apis-pointer.md b/en/application-dev/reference/apis/js-apis-pointer.md new file mode 100644 index 0000000000000000000000000000000000000000..97429f0dee1df4f12487cce5d361182ba660fe87 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-pointer.md @@ -0,0 +1,114 @@ +# Mouse Pointer + +The mouse pointer module provides APIs related to pointer attribute management. + +> **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. + +## Modules to Import + +```js +import pointer from '@ohos.multimodalInput.pointer'; +``` + +## pointer.setPointerVisibele + +setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void + +Sets the visible status of the mouse pointer. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------------------------------------------- | +| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| +| callback | AysncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +pointer.setPointerVisible(true, (err, data) => { + if (err) { + console.log(`set pointer visible failed. err=${JSON.stringify(err)}`); + return; + } + console.log(`set pointer visible success.`); +); +``` + +## pointer.setPointerVisible + +setPointerVisible(visible: boolean): Promise<void> + +Sets the visible status of the mouse pointer. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------- | ---- | ------------------------------------------------------------------- | +| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| + +**Return value** + +| Parameter | Description | +| ------------------- | ------------------------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + +```js +pointer.setPointerVisible(false).then( data => { + console.log(`set mouse pointer visible success`); + }, data => { + console.log(`set mouse pointer visible failed err=${JSON.stringify(data)}`); +}); +``` + +## pointer.isPointerVisible + +isPointerVisible(callback: AsyncCallback<boolean>): void + +Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| + +**Example** + +```js +pointer.isPointerVisible((visible)=>{ + console.log("The mouse pointer visible attributes is " + visible); +}); +``` + +## pointer.isPointerVisible + +isPointerVisible(): Promise<boolean> + +Checks the visible status of the mouse pointer. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Return value** + +| Parameter | Description | +| ---------------------- | ------------------------------- | +| Promise<boolean> | Promise used to return the result.| + +**Example** + +```js +pointer.isPointerVisible().then( data => { + console.log(`isPointerThen success data=${JSON.stringify(data)}`); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-process.md b/en/application-dev/reference/apis/js-apis-process.md index 98d55f53e7f3c51f33fc9505fccf33df846c9ef6..8420e6055aadb9d2e7d45567d25b5fee9c21b795 100755 --- a/en/application-dev/reference/apis/js-apis-process.md +++ b/en/application-dev/reference/apis/js-apis-process.md @@ -390,7 +390,7 @@ var pres = process.getEnvironmentVar("PATH") ## process.runCmd -runCmd(command: string, options?: { timeout : number, killSignal : number | string, maxBuffer : number }): ChildProcess +runCmd(command: string, options?: { timeout?: number, killSignal?: number | string, maxBuffer?: number }): ChildProcess Forks a new process to run a shell command and returns the **ChildProcess** object. diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index 16da2e93685e99d26b9af2040af3f294ce68bd08..6e3ee3ab521fd77e73a8085002296cd6b5883430 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -1588,6 +1588,128 @@ promise.then(data => { }); ``` +## radio.getImsRegInfo9+ + +getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback): void + +Obtains the IMS registration status of the specified IMS service type. This API uses an asynchronous callback to return the result. + +This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| imsType | [ImsServiceType](#imsservicetype9) | Yes | IMS service type. | +| callback | AsyncCallback<[ImsRegInfo](#imsreginfo9)\> | Yes | Callback used to return the result. | + +**Example** + +```js +radio.getImsRegInfo(0, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## radio.getImsRegInfo9+ + +getImsRegInfo(slotId: number, imsType: ImsServiceType): Promise + +Obtains the IMS registration status of the specified IMS service type. This API uses a promise to return the result. + +This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| imsType | [ImsServiceType](#imsservicetype9) | Yes | IMS service type. | + +**Return value** + +| Type | Description | +| ------------------------------------- | ----------------------- | +| Promise\<[ImsRegInfo](#imsreginfo9)\> | Promise used to return the result.| + +**Example** + +```js +let promise = radio.getImsRegInfo(0, 1); +promise.then(data => { + console.log(`getImsRegInfo success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getImsRegInfo fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.on('imsRegStateChange')9+ + +on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: Callback): void + +Enables listening for **imsRegStateChange** events. This API uses an asynchronous callback to return the result. + +This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------ | ---- | -------------------------------------- | +| type | string | Yes | IMS registration status changes. | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| imsType | [ImsServiceType](#imsservicetype9) | Yes | IMS service type. | +| callback | Callback<[ImsRegInfo](#imsreginfo9)> | Yes | Callback used to return the result. | + +**Example** + +```js +radio.on('imsRegStateChange', 0, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## radio.off('imsRegStateChange')9+ + +off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback?: Callback): void + +Disables listening for **imsRegStateChange** events. This API uses an asynchronous callback to return the result. + +This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------ | ---- | -------------------------------------- | +| type | string | Yes | IMS registration status changes. | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| imsType | [ImsServiceType](#imsservicetype9) | Yes | IMS service type. | +| callback | Callback<[ImsRegInfo](#imsreginfo9)> | No | Callback used to return the result. | + +**Example** + +```js +radio.off('imsRegStateChange', 0, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + ## RadioTechnology Enumerates radio access technologies. @@ -1755,11 +1877,11 @@ This is a system API. | Name | Type | Description | | ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| networkType | [NetworkType](#networkType) | Network type of the cell. | +| networkType | [NetworkType](#networktype) | Network type of the cell. | | isCamped | boolean | Status of the cell. | | timeStamp | number | Timestamp when cell information is obtained. | | signalInformation | [SignalInformation](#signalinformation) | Signal information. | -| data | [CdmaCellInformation](#cdmacellinformation) \| [GsmCellInformation](#gsmcellinformation) \| [LteCellInformation](#ltecellinformation) \| [NrCellInformation](#nrcellinformation) \| [TdscdmaCellInformation](#tdscdmacellinformation) | CDMA cell information \| GSM cell information \| LTE cell information \| NR cell information \| TD-SCDMA cell information | +| data | [CdmaCellInformation](#cdmacellinformation8) \| [GsmCellInformation](#gsmcellinformation8) \| [LteCellInformation](#ltecellinformation8) \| [NrCellInformation](#nrcellinformation8) \| [TdscdmaCellInformation](#tdscdmacellinformation8) | CDMA cell information \|GSM cell information \|LTE cell information \|NR cell information \|TD-SCDMA cell information| ## CdmaCellInformation8+ @@ -1883,6 +2005,8 @@ This is a system API. Defines the network search result. +This is a system API. + **System capability**: SystemCapability.Telephony.CoreService | Name | Type | Description | @@ -1934,3 +2058,59 @@ This is a system API. | selectMode | [NetworkSelectionMode](#networkselectionmode) | Network selection mode. | | networkInformation | [NetworkInformation](#networkinformation) | Network information. | | resumeSelection | boolean | Whether to resume selection. | + +## ImsRegState9+ + +Enumerates IMS registration states. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Value | Description | +| ---------------- | ---- | -------- | +| IMS_UNREGISTERED | 0 | Not registered.| +| IMS_REGISTERED | 1 | Registered.| + +## ImsRegTech9+ + +Enumerates IMS registration technologies. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Value | Description | +| ----------------------- | ---- | --------------- | +| REGISTRATION_TECH_NONE | 0 | None. | +| REGISTRATION_TECH_LTE | 1 | LTE. | +| REGISTRATION_TECH_IWLAN | 2 | I-WLAN.| +| REGISTRATION_TECH_NR | 3 | NR. | + +## ImsRegInfo9+ + +Defines the IMS registration information. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Type | Description | +| ----------- | ---------------------------- | ------------- | +| imsRegState | [ImsRegState](#imsregstate9) | IMS registration state.| +| imsRegTech | [ImsRegTech](#imsregtech9) | IMS registration technology.| + +## ImsServiceType9+ + +Enumerates IMS service types. + +This is a system API. + +**System capability**: SystemCapability.Telephony.CoreService + +| Name | Value | Description | +| ---------- | ---- | ---------- | +| TYPE_VOICE | 0 | Voice service.| +| TYPE_VIDEO | 1 | Video service.| +| TYPE_UT | 2 | UT service. | +| TYPE_SMS | 3 | SMS service.| diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md index 4f6da3208d7bef31f14e626a8fc09c57b5cb0423..272b2f8e21fe21adf0fac3fea2e1ea02c6581e96 100644 --- a/en/application-dev/reference/apis/js-apis-request.md +++ b/en/application-dev/reference/apis/js-apis-request.md @@ -465,6 +465,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r **Required permissions**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | name | string | Yes| Name of a form element.| diff --git a/en/application-dev/reference/apis/js-apis-router.md b/en/application-dev/reference/apis/js-apis-router.md index ac9435450c7e47d70deb11ed0a5b7249eea8f368..5fd946a50a96ae6ba4086934c749d05f89e5362e 100644 --- a/en/application-dev/reference/apis/js-apis-router.md +++ b/en/application-dev/reference/apis/js-apis-router.md @@ -5,7 +5,7 @@ The **Router** module provides APIs to access pages through URLs. You can use th > **NOTE** > > - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> +> > - Page routing APIs can be invoked only after page rendering is complete. Do not call these APIs in **onInit** and **onReady** when the page is still in the rendering phase. ## Modules to Import @@ -23,9 +23,9 @@ Navigates to a specified page in the application. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | ------------------ | -| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters.| +| Name | Type | Mandatory | Description | +| ------- | ------------------------------- | ---- | --------- | +| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters.| **Example** @@ -49,10 +49,10 @@ Navigates to a specified page in the application. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| ----------------- | ------------------------------- | ---- | -------------------- | -| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters. | -| mode9+ | [RouterMode](#routermode9) | Yes | Routing mode.| +| Name | Type | Mandatory | Description | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters. | +| mode | [RouterMode](#routermode9) | Yes | Routing mode.| **Example** @@ -77,6 +77,7 @@ Replaces the current page with another one in the application and destroys the c **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | Name | Type | Mandatory| Description | | ------- | ------------------------------- | ---- | ------------------ | | options | [RouterOptions](#routeroptions) | Yes | Description of the new page.| @@ -101,10 +102,10 @@ Replaces the current page with another one in the application and destroys the c **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| ----------------- | ------------------------------- | ---- | -------------------- | -| options | [RouterOptions](#routeroptions) | Yes | Description of the new page. | -| mode9+ | [RouterMode](#routermode9) | Yes | Routing mode.| +| Name | Type | Mandatory | Description | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | Yes | Description of the new page. | +| mode | [RouterMode](#routermode9) | Yes | Routing mode.| **Example** @@ -128,7 +129,7 @@ Returns to the previous page or a specified page. **Parameters** | Name | Type | Mandatory| Description | | ------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| options | [RouterOptions](#routeroptions) | No | Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.| +| options | [RouterOptions](#routeroptions) | No | Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If no URL is set, the previous page is returned, and the page in the page stack is not reclaimed. It will be reclaimed after being popped up.| **Example** @@ -159,8 +160,8 @@ Obtains the number of pages in the current stack. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Return value** -| Type | Description | -| ------ | ---------------------------------- | +| Type | Description | +| ------ | ------------------ | | string | Number of pages in the stack. The maximum value is **32**.| **Example** @@ -179,8 +180,8 @@ Obtains state information about the current page. **Return value** -| Type | Description | -| --------------------------- | -------------- | +| Type | Description | +| --------------------------- | ------- | | [RouterState](#routerstate) | Page routing state.| **Example** @@ -197,11 +198,11 @@ Describes the page routing state. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name | Type | Description | -| ----- | ------ | ------------------------------------------------------------ | +| Name | Type | Description | +| ----- | ------ | ---------------------------------- | | index | number | Index of the current page in the stack. The index starts from 1 from the bottom to the top of the stack.| -| name | string | Name of the current page, that is, the file name. | -| path | string | Path of the current page. | +| name | string | Name of the current page, that is, the file name. | +| path | string | Path of the current page. | ## router.enableAlertBeforeBackPage @@ -212,9 +213,9 @@ Enables the display of a confirm dialog box before returning to the previous pag **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ----------------------------------------- | ---- | ------------------ | -| options | [EnableAlertOptions](#enablealertoptions) | Yes | Description of the dialog box.| +| Name | Type | Mandatory | Description | +| ------- | ---------------------------------------- | ---- | --------- | +| options | [EnableAlertOptions](#enablealertoptions) | Yes | Description of the dialog box.| **Example** @@ -229,9 +230,9 @@ Describes the confirm dialog box. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name | Type | Mandatory| Description | -| ------- | ------ | ---- | ---------------- | -| message | string | Yes | Content displayed in the confirm dialog box.| +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | -------- | +| message | string | Yes | Content displayed in the confirm dialog box.| ## router.disableAlertBeforeBackPage @@ -256,8 +257,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu **Return value** -| Type | Description | -| ------ | ---------------------------------- | +| Type | Description | +| ------ | ----------------- | | Object | Parameters passed from the page that initiates redirection to the current page.| **Example** @@ -272,14 +273,13 @@ Describes the page routing options. **System capability**: SystemCapability.ArkUI.ArkUI.Lite -| Name | Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| url | string | Yes | URI of the destination page, in either of the following formats:
- Absolute path of the page. The value is available in the pages list in the **config.json** file, for example:
- pages/index/index
- pages/detail/detail
- Particular path. If the URI is a slash (/), the home page is displayed. | -| params | Object | No | Data that needs to be passed to the destination page during redirection. After the destination page is displayed, it can use the passed data, for example, **this.data1** (**data1** is a key in **params**). If there is the same key (for example, **data1**) on the destination page, the passed **data1** value will replace the original value on the destination page.| +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ---------------------------------------- | +| url | string | Yes | URI of the destination page, in either of the following formats:
- Absolute path of the page. The value is available in the pages list in the **config.json** file, for example:
- pages/index/index
- pages/detail/detail
- Particular path. If the URI is a slash (/), the home page is displayed.| +| params | Object | No | Data that needs to be passed to the destination page during redirection. After the destination page is displayed, it can use the passed data, for example, **this.data1** (**data1** is a key in **params**). If there is the same key (for example, **data1**) on the destination page, the passed **data1** value will replace the original value on the destination page.| > **NOTE** - > > The page routing stack supports a maximum of 32 pages. ## RouterMode9+ @@ -288,9 +288,9 @@ Enumerates the routing modes. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name | Description | -| -------- | ------------------------------------------------------------ | -| Standard | Standard mode. | +| Name | Description | +| -------- | ---------------------------------------- | +| Standard | Standard mode. | | Single | Singleton mode.
If the URL of the target page already exists in the page stack, the page closest to the top of the stack is moved as a new page to the top of the stack.
If the URL of the target page does not exist in the page stack, the page is redirected to in standard mode.| ## Examples diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index 7f83f0250c209dbd6b5d57970fe7beb8d9b9a494..8f88d00f0d246628e3669ae376da04191efedb92 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -68,29 +68,30 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.| -| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback used to return a **PixelMap** object. | **Example** ```js - var ScreenshotOptions = { - "screenRect": { - "left": 200, - "top": 100, - "width": 200, - "height": 200}, - "imageSize": { - "width": 300, - "height": 300}, - "rotation": 0, - "displayId": 0 + var screenshotOptions = { + "screenRect": { + "left": 200, + "top": 100, + "width": 200, + "height": 200}, + "imageSize": { + "width": 300, + "height": 300}, + "rotation": 0, + "displayId": 0 }; - screenshot.save(ScreenshotOptions, (err, data) => { - if (err) { - console.error('Failed to save the screenshot. Error: ' + JSON.stringify(err)); - return; - } - console.info('Screenshot saved. Data: ' + JSON.stringify(data)); + screenshot.save(screenshotOptions, (err, pixelMap) => { + if (err) { + console.log('Failed to save screenshot: ' + JSON.stringify(err)); + return; + } + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // Release the memory in time after the PixelMap is used. }); ``` @@ -114,12 +115,12 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis | Type | Description | | ----------------------------- | ----------------------------------------------- | -| Promise<image.PixelMap> | Promise used to return a **PixelMap** object.| +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise used to return a **PixelMap** object.| **Example** ```js - var ScreenshotOptions = { + var screenshotOptions = { "screenRect": { "left": 200, "top": 100, @@ -131,10 +132,11 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis "rotation": 0, "displayId": 0 }; - let promise = screenshot.save(ScreenshotOptions); - promise.then(() => { - console.log('screenshot save success'); + let promise = screenshot.save(screenshotOptions); + promise.then((pixelMap) => { + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // Release the memory in time after the PixelMap is used. }).catch((err) => { - console.log('screenshot save fail: ' + JSON.stringify(err)); + console.log('Failed to save screenshot: ' + JSON.stringify(err)); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-service-extension-ability.md b/en/application-dev/reference/apis/js-apis-service-extension-ability.md index 388657b05dce3f05601cc88123ff2d64adbf127b..388b4308555f8dc061bfa62da40fd4dc5d97cfee 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-ability.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-ability.md @@ -23,9 +23,9 @@ None. **System API**: This is a system API and cannot be called by third-party applications. -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service Extension context, which is inherited from **ExtensionContext**.| +| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service Extension context, which is inherited from **ExtensionContext**.| ## ServiceExtensionAbility.onCreate @@ -40,9 +40,9 @@ Called when a Service Extension ability is created to initialize the service log **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.| **Example** @@ -88,10 +88,10 @@ Called after **onCreate** is invoked when a Service Extension ability is started **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.| -| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.| + | startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| **Example** @@ -116,15 +116,15 @@ Called after **onCreate** is invoked when a Service Extension ability is started **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| **Return value** -| Type| Description| -| -------- | -------- | -| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| + | Type| Description| + | -------- | -------- | + | rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| **Example** @@ -158,9 +158,9 @@ Called when this Service Extension ability is disconnected. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| **Example** @@ -184,16 +184,16 @@ Called when this Service Extension ability is reconnected. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| **Example** ```js class ServiceExt extends ServiceExtension { - onDisconnect(want) { - console.log('onDisconnect, want:' + want.abilityName); + onReconnect(want) { + console.log('onReconnect, want:' + want.abilityName); } } ``` @@ -202,7 +202,7 @@ Called when this Service Extension ability is reconnected. onConfigurationUpdated(config: Configuration): void; -Called when the configuration of this Service Extension ability is updated. + Called when the configuration of this Service Extension ability is updated. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -210,9 +210,9 @@ Called when the configuration of this Service Extension ability is updated. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| **Example** @@ -236,9 +236,9 @@ Dumps the client information. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| params | Array\ | Yes| Parameters in the form of a command.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | params | Array\ | Yes| Parameters in the form of a command.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md index 241a8bf17f94a3362fe6d12d4662b139c4c4cd8b..cb56fdccb85fd5aa96e161df2f86fbc1a5573b2d 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md @@ -26,7 +26,7 @@ Before using the **ServiceExtensionContext** module, you must define a child cla startAbility(want: Want, callback: AsyncCallback<void>): void; -Starts an ability. This API uses a callback to return the result. +Starts an ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -36,8 +36,8 @@ Starts an ability. This API uses a callback to return the result. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| + | want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.| + | callback | AsyncCallback<void> | No| Callback used to return the result.| **Example** @@ -64,14 +64,14 @@ Starts an ability. This API uses a promise to return the result. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| + | want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.| | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| **Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| + | Promise<void> | Promise used to return the result.| **Example** @@ -92,7 +92,7 @@ Starts an ability. This API uses a promise to return the result. startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void -Starts an ability. This API uses a callback to return the result. +Starts an ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -102,7 +102,7 @@ Starts an ability. This API uses a callback to return the result. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| @@ -136,8 +136,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -169,8 +169,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| @@ -206,10 +206,16 @@ Starts an ability with the account ID specified. This API uses a promise to retu | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| +**Return value** + + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result.| + **Example** ```js @@ -245,7 +251,7 @@ Starts a new Service Extension ability. This API uses an asynchronous callback t | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -275,7 +281,13 @@ Starts a new Service Extension ability. This API uses a promise to return the re | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result.| **Example** @@ -310,8 +322,8 @@ Starts a new Service Extension ability with the account ID specified. This API u | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -344,8 +356,14 @@ Starts a new Service Extension ability with the account ID specified. This API u | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + +**Return value** + + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result.| **Example** @@ -369,7 +387,7 @@ Starts a new Service Extension ability with the account ID specified. This API u stopServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; -Stops Service Extension abilities in the same application. This API uses an asynchronous callback to return the result. +Stops a Service Extension ability in the same application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -379,7 +397,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -399,7 +417,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn stopServiceExtensionAbility(want: Want): Promise\; -Stops Service Extension abilities in the same application. This API uses a promise to return the result. +Stops a Service Extension ability in the same application. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -409,7 +427,13 @@ Stops Service Extension abilities in the same application. This API uses a promi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result.| **Example** @@ -432,7 +456,7 @@ Stops Service Extension abilities in the same application. This API uses a promi stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void; -Stops Service Extension abilities in the same application with the account ID specified. This API uses an asynchronous callback to return the result. +Stops a Service Extension ability in the same application with the account ID specified. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS @@ -444,8 +468,8 @@ Stops Service Extension abilities in the same application with the account ID sp | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -466,7 +490,7 @@ Stops Service Extension abilities in the same application with the account ID sp stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\; -Stops Service Extension abilities in the same application with the account ID specified. This API uses a promise to return the result. +Stops a Service Extension ability in the same application with the account ID specified. This API uses a promise to return the result. **Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS @@ -478,8 +502,14 @@ Stops Service Extension abilities in the same application with the account ID sp | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + +**Return value** + + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result.| **Example** @@ -503,7 +533,7 @@ Stops Service Extension abilities in the same application with the account ID sp terminateSelf(callback: AsyncCallback<void>): void; -Terminates this ability. This API uses a callback to return the result. +Terminates this ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -513,7 +543,7 @@ Terminates this ability. This API uses a callback to return the result. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| + | callback | AsyncCallback<void> | No| Callback used to return the result.| **Example** @@ -537,7 +567,7 @@ Terminates this ability. This API uses a promise to return the result. | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| + | Promise<void> | Promise used to return the result.| **Example** @@ -563,7 +593,7 @@ Connects this ability to a Service ability. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to connect to, such as the ability name and bundle name.| + | want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.| | options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| **Return value** @@ -601,8 +631,8 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| -| accountId | number | Yes| ID of the account.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.| +| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | options | ConnectOptions | No| Remote object instance.| **Return value** @@ -633,7 +663,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect disconnectAbility(connection: number, callback:AsyncCallback<void>): void; -Disconnects this ability from the Service ability. This API uses a callback to return the result. +Disconnects this ability from the Service ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -644,7 +674,7 @@ Disconnects this ability from the Service ability. This API uses a callback to r | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | connection | number | Yes| Number returned after **connectAbility** is called.| - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| + | callback | AsyncCallback<void> | No| Callback used to return the result.| **Example** @@ -676,7 +706,7 @@ Disconnects this ability from the Service ability. This API uses a promise to re | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| + | Promise<void> | Promise used to return the result.| **Example** @@ -689,3 +719,41 @@ Disconnects this ability from the Service ability. This API uses a promise to re console.log('failed:' + JSON.stringify(error)); }); ``` + +## ServiceExtensionContext.startAbilityByCall + +startAbilityByCall(want: Want): Promise<Caller>; + +Starts an ability in the background and obtains the caller interface for communication. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, including the ability name, module name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<Caller> | Promise used to return the caller object to communicate with.| + +**Example** + + ```js + let caller = undefined; + this.context.startAbilityByCall({ + bundleName: "com.example.myservice", + moduleName: "entry", + abilityName: "MainAbility", + deviceId: "" + }).then((obj) => { + caller = obj; + console.log('Caller GetCaller Get ' + caller); + }).catch((e) => { + console.log('Caller GetCaller error ' + e); + }); + ``` + diff --git a/en/application-dev/reference/apis/js-apis-settings.md b/en/application-dev/reference/apis/js-apis-settings.md index 9371381ea8d39f48410d925bd0b28b441f6a9be6..3cb8380f9f35b7fa584f09b0d88c5fb45e0c22fe 100644 --- a/en/application-dev/reference/apis/js-apis-settings.md +++ b/en/application-dev/reference/apis/js-apis-settings.md @@ -21,7 +21,7 @@ getUriSync(name: string): string Obtains the URI of a data item. -**System capability**: SystemCapability.Applictaions.settings.Core +**System capability**: SystemCapability.Applications.settings.Core **Parameters** @@ -50,7 +50,7 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin Obtains the value of a data item. -**System capability**: SystemCapability.Applictaions.settings.Core +**System capability**: SystemCapability.Applications.settings.Core **Parameters** | Name| Type| Mandatory| Description| @@ -87,7 +87,7 @@ If the specified data item exists in the database, the **setValueSync** method u **Required permissions**: ohos.permission.MODIFY_SETTINGS -**System capability**: SystemCapability.Applictaions.settings.Core +**System capability**: SystemCapability.Applications.settings.Core **Parameters** diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index 958de3d7d1bb9d7295bedac1c844867160d687ca..681e5cdc6ac3dea7924feb25752e017052bef23e 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -1482,7 +1482,7 @@ promise.then(data => { ## sim.**unlockPin**28+ -****unlockPin2****(slotId: number,pin2: string ,callback: AsyncCallback): void +unlockPin2(slotId: number,pin2: string ,callback: AsyncCallback): void Unlocks PIN 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. @@ -1549,7 +1549,7 @@ promise.then(data => { ## sim.**unlockPuk**28+ -unlockPuk2(slotId: number,newPin2: string,puk2: string ,callback: AsyncCallback): void +unlockPuk2(slotId: number, newPin2: string, puk2: string, callback: AsyncCallback): void Unlocks PUK 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. @@ -1581,7 +1581,7 @@ sim.unlockPuk2(0, newPin2, puk2, (err, data) => { ## sim.**unlockPuk2**8+ -unlockPuk2slotId: number,newPin2: string,puk2: string): Promise<LockStatusResponse\> +unlockPuk2(slotId: number, newPin2: string, puk2: string): Promise<LockStatusResponse\> Unlocks PUK 2 of the SIM card in the specified slot. This API uses a promise to return the result. @@ -2653,7 +2653,7 @@ promise.then(data => { ## sim.getOpKey9+ -getOpKey(slotId: number, callback: AsyncCallback): void +getOpKey(slotId: number, callback: AsyncCallback): void Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. @@ -2666,7 +2666,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | -------------------------------------- | | slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -2679,7 +2679,7 @@ sim.getOpKey(0, (err, data) => { ## sim.getOpKey9+ -getOpKey(slotId: number): Promise +getOpKey(slotId: number): Promise Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result. @@ -2697,7 +2697,7 @@ This is a system API. | Type | Description | | ---------------- | ----------------------------------------- | -| Promise | Promise used to return the result.| +| Promise | Promise used to return the result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index fa226f072e2a1c4aa568937455e7ee78e3513469..9039fb774527e9ed6bbd43c95b0996afdc94780d 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -678,7 +678,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------------- | ---- | ----------------------------------------- | | slotId | number | Yes | SIM card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| callback | AsyncCallback> | Yes | Callback used to return the result. | +| callback | AsyncCallback> | Yes | Callback used to return the result. | **Example** @@ -712,7 +712,7 @@ This is a system API. | Type | Description | | ------------------------------------------------------- | ---------------------------------- | -| PromiseArray<[SimShortMessage](#simshortmessage8)\>> | Promise used to return the result.| +| PromiseArray<[SimShortMessage](#simshortmessage7)\>> | Promise used to return the result.| **Example** @@ -742,7 +742,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------ | -| options | [CBConfigOptions](#cbconfigoptions8) | Yes | Cell broadcast configuration options.| +| options | [CBConfigOptions](#cbconfigoptions7) | Yes | Cell broadcast configuration options.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -776,7 +776,7 @@ This is a system API. | Name | Type | Mandatory| Description | | ------- | ------------------------------------ | ---- | ------------ | -| options | [CBConfigOptions](#cbconfigoptions8) | Yes | Cell broadcast configuration options.| +| options | [CBConfigOptions](#cbconfigoptions7) | Yes | Cell broadcast configuration options.| **Return value** @@ -818,7 +818,7 @@ This is a system API. | slotId | number | Yes | SIM card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | message | string | Yes | SMS message. | | force7bit | boolean | Yes | Whether to use 7-bit coding. | -| callback | AsyncCallback<[SmsSegmentsInfo](#8+ + +Defines the MMS message reading index. + +This is a system API. + +**System capability**: SystemCapability.Telephony.SmsMms + +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------- | ---- | -------- | +| version | [MmsVersionType](#mmsversiontype8) | Yes | Version | +| messageId | string | Yes | Message ID. | +| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Destination. | +| from | [MmsAddress](#mmsaddress8) | Yes | Source. | +| readStatus | number | Yes | Read state.| +| date | number | No | Date. | + + ## MmsAttachment8+ Defines the attachment of an MMS message. @@ -1466,7 +1485,7 @@ This is a system API. | MMS_YES | 128 | YES | | MMS_NO | 129 | NO | -## CBConfigOptions8+ +## CBConfigOptions7+ Defines the cell broadcast configuration options. @@ -1557,7 +1576,7 @@ This is a system API. | pdu | string | Yes | Protocol data unit. | | smsc | string | Yes | Short message service center.| -## SimShortMessage8+ +## SimShortMessage7+ Defines a SIM message. diff --git a/en/application-dev/reference/apis/js-apis-system-mediaquery.md b/en/application-dev/reference/apis/js-apis-system-mediaquery.md index f2057a86685a5d212e84caf27e69468b8169c267..841cebeb1da0380128d3704650a0aaf9ef095d5f 100644 --- a/en/application-dev/reference/apis/js-apis-system-mediaquery.md +++ b/en/application-dev/reference/apis/js-apis-system-mediaquery.md @@ -1,7 +1,9 @@ # Media Query +The **mediaquery** module provides different styles for different media types. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** + +> **NOTE** > > - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.mediaquery`](js-apis-mediaquery.md) instead. > - 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. @@ -38,11 +40,7 @@ Creates a **MediaQueryList** object based on the query condition. **Example** ``` -export default { - matchMedia() { - var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)'); - }, -} +var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)'); ``` ## MediaQueryEvent @@ -95,11 +93,16 @@ Adds a listener for this **MediaQueryList** object. The listener must be added b | Name | Type | Mandatory | Description | | -------- | -------------------------------- | ---- | -------------- | -| callback | (event: MediaQueryEvent) => void | Yes | Callback invoked when the matching condition changes.| +| callback | (event: MediaQueryEvent) => void | Yes | Callback invoked when the query condition changes.| **Example** ``` +function maxWidthMatch(e){ + if(e.matches){ + // do something + } +} mMediaQueryList.addListener(maxWidthMatch); ``` @@ -116,10 +119,15 @@ Removes the listener for this **MediaQueryList** object. | Name | Type | Mandatory | Description | | -------- | --------------------------------- | ---- | -------------- | -| callback | (event: MediaQueryEvent) => void) | Yes | Callback invoked when the matching condition changes.| +| callback | (event: MediaQueryEvent) => void) | Yes | Callback invoked when the query condition changes.| **Example** ``` +function maxWidthMatch(e){ + if(e.matches){ + // do something + } +} mMediaQueryList.removeListener(maxWidthMatch); ``` diff --git a/en/application-dev/reference/apis/js-apis-system-router.md b/en/application-dev/reference/apis/js-apis-system-router.md index 0f1f932efe54af1337ce19354d19343b6f637687..a35aa162b0b7eb57c3535f821b74a15d4cb58d9f 100644 --- a/en/application-dev/reference/apis/js-apis-system-router.md +++ b/en/application-dev/reference/apis/js-apis-system-router.md @@ -1,5 +1,7 @@ # Page Routing +The **Router** module provides APIs to access pages through URIs. + > **NOTE** > > - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.router`](js-apis-router.md) instead. @@ -372,12 +374,12 @@ Defines the **EnableAlertBeforeBackPage** parameters. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name | Type | Mandatory | Description | -| -------- | ------------------------ | ---- | ------------------------- | -| message | string | Yes | Content displayed in the confirm dialog box. | -| success | (errMsg: string) => void | No | Called when a dialog box is displayed. **errMsg** indicates the returned information. | -| fail | (errMsg: string) => void | No | Called when the API fails to be called. **errMsg** indicates the returned information.| -| complete | () => void | No | Called when the API call is complete. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------ | ---- | -------------------------------------------------- | +| message | string | Yes | Content displayed in the confirm dialog box. | +| success | (errMsg: string) => void | No | Called when the **OK** button in the confirm dialog box is clicked. **errMsg** indicates the returned information.| +| cancel | (errMsg: string) => void | No | Called when the **Cancel** button in the confirm dialog box is clicked. **errMsg** indicates the returned information.| +| complete | () => void | No | Called when the API call is complete. | ## DisableAlertBeforeBackPageOptions6+ @@ -385,11 +387,11 @@ Define the **DisableAlertBeforeBackPage** parameters. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name | Type | Mandatory | Description | -| -------- | ------------------------ | ---- | ------------------------- | -| success | (errMsg: string) => void | No | Called when a dialog box is displayed. **errMsg** indicates the returned information. | -| fail | (errMsg: string) => void | No | Called when the API fails to be called. **errMsg** indicates the returned information.| -| complete | () => void | No | Called when the API call is complete. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------ | ---- | -------------------------------------------------- | +| success | (errMsg: string) => void | No | Called when the dialog box is closed. **errMsg** indicates the returned information.| +| cancel | (errMsg: string) => void | No | Called when the dialog box fails to be closed. **errMsg** indicates the returned information.| +| complete | () => void | No | Called when the API call is complete. | ## ParamsInterface diff --git a/en/application-dev/reference/apis/js-apis-tagSession.md b/en/application-dev/reference/apis/js-apis-tagSession.md new file mode 100644 index 0000000000000000000000000000000000000000..5ed3760a0cf3664cc6991a73489dd7f53ab9d83b --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-tagSession.md @@ -0,0 +1,127 @@ +# Standard NFC Tag Session + +The **tagSession** module provides common APIs for establishing connections and transferring data. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## **Modules to Import** + +```js +import tag from '@ohos.nfc.tag'; +``` + +## tagSession + +Provides common APIs for establishing connections and transferring data. **tagSession** is the base class of all [NFC tag technologies](js-apis-nfctech.md). + +A child class instance is required to access the following interfaces. You can use **get**XX**Tag()** to obtain a child class instance. + +The specific method varies with the NFC tag technology in use. For details, see [nfcTag](js-apis-nfcTag.md). + +### tagSession.connectTag + +connectTag(): boolean; + +Connects to this tag. + +Call this method to set up a connection before reading data from or writing data to a tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let isNfcConnected = tag.getXXXTag(taginfo).connectTag(); +console.log("isNfcConnected:" +isNfcConnected); +``` + +### tagSession.reset() + +reset(): void + +Resets the connection to this tag and restores the default timeout duration for writing data to the tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let reset = tag.getXXXTag(taginfo).reset(); +console.log("reset:" +reset); +``` + +### tagSession.isTagConnected + +isTagConnected(): boolean + +Checks whether the tag is connected. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| boolean | Returns **true** if the tag is connected; returns **false** otherwise.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an Object given by nfc service when tag is dispatched. +let isTagConnected = tag.getXXXTag(taginfo).isTagConnected(); +console.log("isTagConnected:" +isTagConnected); +``` + +### tagSession.getMaxSendLength + +getMaxSendLength(): number + +Obtains the maximum length of the data that can be sent to the tag. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.NFC.Core + +**Return value** + +| **Type**| **Description** | +| ------------------ | --------------------------| +| number | Maximum data length obtained.| + +**Example** + +```js +import tag from '@ohos.nfc.tag'; + +// tagInfo is an object given by the NFC service when a tag is dispatched. +let mazSendLen = tag.getXXXTag(taginfo).getMaxSendLength(); +console.log("mazSendLen:" +mazSendLen); +``` diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index 64d76026eeb3981fd589401d71f599fc2112f9dd..1cad2b9d5796f5039d62124ff9543c77d7dc48f1 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -7,7 +7,7 @@ There are two types of updates: SD card update and over the air (OTA) update. - The SD card update depends on the update packages and SD cards. - The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer. -> **NOTE** +> **Note:** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > @@ -29,9 +29,9 @@ Obtains an **OnlineUpdater** object. **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | --------------------------- | ---- | ---- | -| upgradeInfo | [UpgradeInfo](#upgradeinfo) | Yes | **UpgradeInfo** object.| +| Name | Type | Mandatory | Description | +| ----------- | --------------------------- | ---- | ------ | +| upgradeInfo | [UpgradeInfo](#upgradeinfo) | Yes | **UpgradeInfo** object.| **Return value** @@ -41,7 +41,7 @@ Obtains an **OnlineUpdater** object. **Example** -``` +```ts try { var upgradeInfo = { upgradeApp: "com.ohos.ota.updateclient", @@ -67,13 +67,13 @@ Obtains a **Restorer** object for restoring factory settings. **Return value** -| Type | Description | -| ------------------- | ---- | +| Type | Description | +| --------------------- | ------ | | [Restorer](#restorer) | **Restorer** object for restoring factory settings.| **Example** -``` +```ts try { let restorer = update.getRestorer(); } catch(error) { @@ -91,13 +91,13 @@ Obtains a **LocalUpdater** object. **Return value** -| Type | Description | -| ------------------- | ---- | +| Type | Description | +| ----------------------------- | ------ | | [LocalUpdater](#localupdater) | **LocalUpdater** object.| **Example** -``` +```ts try { let localUpdater = update.getLocalUpdater(); } catch(error) { @@ -119,13 +119,13 @@ Checks whether a new version is available. This API uses an asynchronous callbac **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | -------------- | | callback | AsyncCallback\<[CheckResult](#checkresult)> | Yes | Callback used to return the result.| **Example** -``` +```ts updater.checkNewVersion((err, result) => { console.log(`checkNewVersion isExistNewVersion ${result?.isExistNewVersion}`); }); @@ -143,13 +143,13 @@ Checks whether a new version is available. This API uses a promise to return the **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| ------------------------------------- | ------------------- | | Promise\<[CheckResult](#checkresult)> | Promise used to return the result.| **Example** -``` +```ts updater.checkNewVersion().then(result => { console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`); // Version digest information @@ -171,13 +171,13 @@ Obtains information about the new version. This API uses an asynchronous callbac **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------- | | callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | Yes | Callback used to return the result.| **Example** -``` +```ts updater.getNewVersionInfo((err, info) => { console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`); console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`); @@ -196,13 +196,13 @@ Obtains information about the new version. This API uses a promise to return the **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| ---------------------------------------- | -------------------- | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| **Example** -``` +```ts updater.getNewVersionInfo().then(info => { console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`); console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`); @@ -223,15 +223,15 @@ Obtains the description file of the new version. This API uses an asynchronous c **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| -| callback | AsyncCallback\>) | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| ------------------ | ---------------------------------------- | ---- | -------------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file. | +| callback | AsyncCallback\>) | Yes | Callback used to return the result.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -261,20 +261,20 @@ Obtains the description file of the new version. This API uses a promise to retu **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| Name | Type | Mandatory | Description | +| ------------------ | ---------------------------------------- | ---- | ------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| | descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| ---------------------------------------- | ------------------- | | Promise\> | Promise used to return the result.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -305,13 +305,13 @@ Obtains information about the current version. This API uses an asynchronous cal **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ---------------- | | callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | Yes | Callback used to return the result.| **Example** -``` +```ts updater.getCurrentVersionInfo((err, info) => { console.log(`info osVersion = ${info?.osVersion}`); console.log(`info deviceName = ${info?.deviceName}`); @@ -331,13 +331,13 @@ Obtains information about the current version. This API uses a promise to return **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| ---------------------------------------- | ------------------- | | Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise used to return the result.| **Example** -``` +```ts updater.getCurrentVersionInfo().then(info => { console.log(`info osVersion = ${info.osVersion}`); console.log(`info deviceName = ${info.deviceName}`); @@ -359,14 +359,14 @@ Obtains the description file of the current version. This API uses an asynchrono **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| -| callback | AsyncCallback\>) | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| ------------------ | ---------------------------------------- | ---- | --------------- | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file. | +| callback | AsyncCallback\>) | Yes | Callback used to return the result.| **Example** -``` +```ts // Options of the description file var descriptionOptions = { format: DescriptionFormat.STANDARD, // Standard format @@ -391,19 +391,19 @@ Obtains the description file of the current version. This API uses a promise to **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| ------------------ | ---------------------------------------- | ---- | ------ | | descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| ---------------------------------------- | -------------------- | | Promise\> | Promise used to return the result.| **Example** -``` +```ts // Options of the description file var descriptionOptions = { format: DescriptionFormat.STANDARD, // Standard format @@ -429,13 +429,13 @@ Obtains information about the update task. This API uses an asynchronous callbac **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| -------- | ------------------------------------- | ---- | ---------------- | | callback | AsyncCallback\<[TaskInfo](#taskinfo)> | Yes | Callback used to return the result.| **Example** -``` +```ts updater.getTaskInfo((err, info) => { console.log(`getTaskInfo isexistTask= ${info?.existTask}`); }); @@ -453,13 +453,13 @@ Obtains information about the update task. This API uses a promise to return the **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| ------------------------------- | ------------------- | | Promise\<[TaskInfo](#taskinfo)> | Promise used to return the result.| **Example** -``` +```ts updater.getTaskInfo().then(info => { console.log(`getTaskInfo isexistTask= ${info.existTask}`); }).catch(err => { @@ -479,15 +479,15 @@ Downloads the new version. This API uses an asynchronous callback to return the **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| ----------------- | --------------------------------------- | ---- | ---------------------------------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -515,20 +515,20 @@ Downloads the new version. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| ----------------- | --------------------------------------- | ---- | ------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options.| +| downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options. | **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -558,15 +558,15 @@ Resumes download of the new version. This API uses an asynchronous callback to r **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| --------------------- | ---------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -593,20 +593,20 @@ Resumes download of the new version. This API uses a promise to return the resul **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| Name | Type | Mandatory | Description | +| --------------------- | ---------------------------------------- | ---- | ------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| | resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download.| **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -635,15 +635,15 @@ Pauses download of the new version. This API uses an asynchronous callback to re **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| -------------------- | ---------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -670,20 +670,20 @@ Resumes download of the new version. This API uses a promise to return the resul **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| Name | Type | Mandatory | Description | +| -------------------- | ---------------------------------------- | ---- | ------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| | pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download.| **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -712,15 +712,15 @@ Updates the version. This API uses an asynchronous callback to return the result **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| ----------------- | --------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -747,20 +747,20 @@ Updates the version. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| ----------------- | --------------------------------------- | ---- | ------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options.| +| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options. | **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -789,15 +789,15 @@ Clears errors. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| clearOptions | [ClearOptions](#clearoptions) | Yes | Clear options.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| ----------------- | --------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| clearOptions | [ClearOptions](#clearoptions) | Yes | Clear options. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -824,20 +824,20 @@ Clears errors. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | +| Name | Type | Mandatory | Description | +| ----------------- | --------------------------------------- | ---- | ------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| -| clearOptions | [ClearOptions](#clearoptions) | Yes | Update options.| +| clearOptions | [ClearOptions](#clearoptions) | Yes | Update options. | **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts // Version digest information var versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result @@ -866,13 +866,13 @@ Obtains the update policy. This API uses an asynchronous callback to return the **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------- | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------- | | callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | Yes | Callback used to return the result.| **Example** -``` +```ts updater.getUpgradePolicy((err, policy) => { console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`); console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`); @@ -891,13 +891,13 @@ Obtains the update policy. This API uses a promise to return the result. **Return value** -| Type | Description | -| --------------------------------------- | ----------------- | +| Type | Description | +| ---------------------------------------- | --------------------- | | Promise\<[UpgradePolicy](#upgradepolicy)> | Promise used to return the result.| **Example** -``` +```ts updater.getUpgradePolicy().then(policy => { console.log(`policy downloadStrategy = ${policy.downloadStrategy}`); console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`); @@ -918,14 +918,14 @@ Sets the update policy. This API uses an asynchronous callback to return the res **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------- | -| policy | [UpgradePolicy](#upgradepolicy) | Yes | Update policy.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | ---- | ------------- | +| policy | [UpgradePolicy](#upgradepolicy) | Yes | Update policy. | +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** -``` +```ts let policy = { downloadStrategy: false, autoUpgradeStrategy: false, @@ -948,19 +948,19 @@ Sets the update policy. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ----------------------------- | ---- | ------ | +| Name | Type | Mandatory | Description | +| ------ | ------------------------------- | ---- | ---- | | policy | [UpgradePolicy](#upgradepolicy) | Yes | Update policy.| **Return value** -| Type | Description | -| ---------------- | --------------- | +| Type | Description | +| -------------- | ------------------- | | Promise\ | Promise used to return the result.| **Example** -``` +```ts let policy = { downloadStrategy: false, autoUpgradeStrategy: false, @@ -985,13 +985,13 @@ Terminates the update. This API uses an asynchronous callback to return the resu **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts updater.terminateUpgrade((err) => { console.log(`terminateUpgrade error ${JSON.stringify(err)}`); }); @@ -1009,13 +1009,13 @@ Terminates the update. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts updater.terminateUpgrade().then(() => { console.log(`terminateUpgrade success`); }).catch(err => { @@ -1033,14 +1033,14 @@ Enables listening for update events. This API uses an asynchronous callback to r **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| +| Name | Type | Mandatory | Description | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| **Example** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" @@ -1060,14 +1060,14 @@ Disables listening for update events. This API uses an asynchronous callback to **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | No | Event callback.| +| Name | Type | Mandatory | Description | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | No | Event callback.| **Example** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" @@ -1084,7 +1084,7 @@ updater.off(eventClassifyInfo, (eventInfo) => { factoryReset(callback: AsyncCallback\): void -Restores factory settings. This API uses an asynchronous callback to return the result. +Restore the device to its factory settings. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService @@ -1092,13 +1092,13 @@ Restores factory settings. This API uses an asynchronous callback to return the **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts restorer.factoryReset((err) => { console.log(`factoryReset error ${JSON.stringify(err)}`); }); @@ -1108,7 +1108,7 @@ restorer.factoryReset((err) => { factoryReset(): Promise\ -Restores factory settings. This API uses a promise to return the result. +Restore the device to its factory settings. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService @@ -1116,13 +1116,13 @@ Restores factory settings. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts restorer.factoryReset().then(() => { console.log(`factoryReset success`); }).catch(err => { @@ -1144,15 +1144,15 @@ Verifies the update package. This API uses an asynchronous callback to return th **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file.| -| certsFile | string | Yes | Path of the certificate file.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| ----------- | --------------------------- | ---- | ---------------- | +| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file. | +| certsFile | string | Yes | Path of the certificate file. | +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** -``` +```ts var upgradeFile = { fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package @@ -1175,20 +1175,20 @@ Verifies the update package. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file.| -| certsFile | string | Yes | Path of the certificate file.| +| Name | Type | Mandatory | Description | +| ----------- | --------------------------- | ---- | ------ | +| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file. | +| certsFile | string | Yes | Path of the certificate file.| **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | ---------------------- | | Promise\ | Promise used to return the result.| **Example** -``` +```ts var upgradeFile = { fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package @@ -1211,14 +1211,14 @@ Installs the update package. This API uses an asynchronous callback to return th **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes | Update file.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| Name | Type | Mandatory | Description | +| ----------- | ---------------------------------- | ---- | --------------------------------------- | +| upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes | Update file. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** -``` +```ts var upgradeFiles = [{ fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package @@ -1241,13 +1241,13 @@ Installs the update package. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | +| Type | Description | +| -------------- | -------------------------- | | Promise\ | Promise that returns no value.| **Example** -``` +```ts var upgradeFiles = [{ fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package @@ -1268,14 +1268,14 @@ Enables listening for update events. This API uses an asynchronous callback to r **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| +| Name | Type | Mandatory | Description | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| **Example** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" @@ -1297,14 +1297,14 @@ Disables listening for update events. This API uses an asynchronous callback to **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| +| Name | Type | Mandatory | Description | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| **Example** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" @@ -1323,10 +1323,10 @@ Represents update information. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| upgradeApp | string | Yes | Application package name. | -| businessType | [BusinessType](#businesstype) | Yes | Update service type. | +| Name | Type | Mandatory | Description | +| ------------ | ----------------------------- | ---- | ------ | +| upgradeApp | string | Yes | Application package name. | +| businessType | [BusinessType](#businesstype) | Yes | Update service type.| ## BusinessType @@ -1334,10 +1334,10 @@ Enumerates update service types. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| vendor | [BusinessVendor](#businessvendor) | Yes | Application vendor. | -| subType | [BusinessSubType](#businesssubtype) | Yes | Update service sub-type. | +| Name | Type | Mandatory | Description | +| ------- | ----------------------------------- | ---- | ---- | +| vendor | [BusinessVendor](#businessvendor) | Yes | Application vendor. | +| subType | [BusinessSubType](#businesssubtype) | Yes | Type | ## CheckResult @@ -1345,10 +1345,10 @@ Represents the package check result. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| isExistNewVersion | bool | Yes | Whether a new version is available. | -| newVersionInfo | [NewVersionInfo](#newversioninfo) | No | Information about the new version. | +| Name | Type | Mandatory | Description | +| ----------------- | --------------------------------- | ---- | ------ | +| isExistNewVersion | bool | Yes | Whether a new version is available.| +| newVersionInfo | [NewVersionInfo](#newversioninfo) | No | Information about the new version. | ## NewVersionInfo @@ -1356,10 +1356,10 @@ Represents information about the new version. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | -| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components. | +| Name | Type | Mandatory | Description | +| ----------------- | ---------------------------------------- | ---- | ---- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components.| ## VersionDigestInfo @@ -1367,9 +1367,9 @@ Represents version digest information. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| versionDigest | string | Yes | Version digest information. | +| Name | Type | Mandatory | Description | +| ------------- | ------ | ---- | ---- | +| versionDigest | string | Yes | Version digest information.| ## VersionComponent @@ -1377,16 +1377,16 @@ Represents a version component. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| componentId | number | Yes | Component ID. | -| componentType | [ComponentType](#componentyype) | Yes | Component type. | -| upgradeAction | [UpgradeAction](#upgradeaction) | Yes | Update mode. | -| displayVersion | string | Yes | Display version number. | -| innerVersion | string | Yes | Internal version number. | -| size | number | Yes | Update package size. | -| effectiveMode | [EffectiveMode](#effectivemode) | Yes | Effective mode. | -| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the version description file. | +| Parameter | Type | Mandatory | Description | +| --------------- | ----------------------------------- | ---- | -------- | +| componentId | number | Yes | Component ID. | +| componentType | [ComponentType](#componenttype) | Yes | Component type. | +| upgradeAction | [UpgradeAction](#upgradeaction) | Yes | Update mode. | +| displayVersion | string | Yes | Display version number. | +| innerVersion | string | Yes | Internal version number. | +| size | number | Yes | Update package size. | +| effectiveMode | [EffectiveMode](#effectivemode) | Yes | Effective mode. | +| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the version description file.| ## DescriptionOptions @@ -1394,10 +1394,10 @@ Represents options of the description file. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| format | [DescriptionFormat](#descriptionformat) | Yes | Format of the description file. | -| language | string | Yes | Language of the description file. | +| Name | Type | Mandatory | Description | +| -------- | --------------------------------------- | ---- | ------ | +| format | [DescriptionFormat](#descriptionformat) | Yes | Format of the description file.| +| language | string | Yes | Language of the description file.| ## ComponentDescription @@ -1405,10 +1405,10 @@ Represents a component description file. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| componentId | string | Yes | Component ID. | -| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the description file. | +| Name | Type | Mandatory | Description | +| --------------- | ----------------------------------- | ---- | ------ | +| componentId | string | Yes | Component ID. | +| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the description file.| ## DescriptionInfo @@ -1416,10 +1416,10 @@ Represents information about the version description file. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| descriptionType | [DescriptionType](#descriptiontype) | Yes | Type of the description file. | -| content | string | Yes | Content of the description file. | +| Name | Type | Mandatory | Description | +| --------------- | ----------------------------------- | ---- | ------ | +| descriptionType | [DescriptionType](#descriptiontype) | Yes | Type of the description file.| +| content | string | Yes | Content of the description file.| ## CurrentVersionInfo @@ -1427,11 +1427,11 @@ Represents information about the current version. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| osVersion | string | Yes | System version number. | -| deviceName | string | Yes | Device name. | -| versionComponents | Array\<[VersionComponent](#vesioncomponent)> | No | Version components. | +| Name | Type | Mandatory | Description | +| ----------------- | ---------------------------------------- | ---- | ----- | +| osVersion | string | Yes | System version number.| +| deviceName | string | Yes | Device name. | +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | No | Version components. | ## DownloadOptions @@ -1439,10 +1439,10 @@ Represents download options. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| allowNetwork | [NetType](#nettype) | Yes | Network type. | -| order | [Order](#order) | Yes | Update command. | +| Name | Type | Mandatory | Description | +| ------------ | ------------------- | ---- | ---- | +| allowNetwork | [NetType](#nettype) | Yes | Network type.| +| order | [Order](#order) | Yes | Update command.| ## ResumeDownloadOptions @@ -1450,9 +1450,9 @@ Represents options for resuming download. **System capability**: SystemCapability.Update.UpdateService -| Parameter | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| allowNetwork | [NetType](#nettype) | Yes | Network type. | +| Name | Type | Mandatory | Description | +| ------------ | ------------------- | ---- | ---- | +| allowNetwork | [NetType](#nettype) | Yes | Network type.| ## PauseDownloadOptions @@ -1460,9 +1460,9 @@ Represents options for pausing download. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| isAllowAutoResume | bool | Yes | Whether to allow automatic resuming of download. | +| Name | Type| Mandatory | Description | +| ----------------- | ---- | ---- | -------- | +| isAllowAutoResume | bool | Yes | Whether to allow automatic resuming of download.| ## UpgradeOptions @@ -1470,9 +1470,9 @@ Represents update options. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| order | [Order](#order) | Yes | Update command. | +| Name | Type | Mandatory | Description | +| ----- | --------------- | ---- | ---- | +| order | [Order](#order) | Yes | Update command.| ## ClearOptions @@ -1480,9 +1480,9 @@ Represents options for clearing errors. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| status | [UpgradeStatus](#upgradestatus) | Yes | Error status. | +| Name | Type | Mandatory | Description | +| ------ | ------------------------------- | ---- | ---- | +| status | [UpgradeStatus](#upgradestatus) | Yes | Error status.| ## UpgradePolicy @@ -1490,11 +1490,11 @@ Represents an update policy. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| downloadStrategy | bool | Yes | Automatic download policy. | -| autoUpgradeStrategy | bool | Yes | Automatic update policy. | -| autoUpgradePeriods | Array\<[UpgradePeriod](#upgradeperiod)> | Yes | Automatic update period.| +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------------------- | ---- | ------- | +| downloadStrategy | bool | Yes | Automatic download policy. | +| autoUpgradeStrategy | bool | Yes | Automatic update policy. | +| autoUpgradePeriods | Array\<[UpgradePeriod](#upgradeperiod)> | Yes | Automatic update period.| ## UpgradePeriod @@ -1502,10 +1502,10 @@ Represents a period for automatic update. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| start | number | Yes | Start time. | -| end | number | Yes | End time. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ---- | +| start | number | Yes | Start time.| +| end | number | Yes | End time.| ## TaskInfo @@ -1513,21 +1513,21 @@ Represents task information. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| existTask | bool | Yes | Whether a task exists. | -| taskBody | [TaskBody](#taskinfo) | Yes | Task data. | +| Name | Type | Mandatory | Description | +| --------- | --------------------- | ---- | ------ | +| existTask | bool | Yes | Whether a task exists.| +| taskBody | [TaskBody](#taskinfo) | Yes | Task data. | ## EventInfo -Represents event information. +Represents event type information. **System capability**: SystemCapability.Update.UpdateService -| Parameter | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| eventId | [EventId](#eventid) | Yes | Event ID. | -| taskBody | [TaskBody](#taskinfo) | Yes | Task data. | +| Name | Type | Mandatory | Description | +| -------- | --------------------- | ---- | ---- | +| eventId | [EventId](#eventid) | Yes | Event ID.| +| taskBody | [TaskBody](#taskinfo) | Yes | Task data.| ## TaskBody @@ -1535,15 +1535,15 @@ Represents task data. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | -| status | [UpgradeStatus](#upgradestatus) | Yes | Update status. | -| subStatus | number | No | Sub-status. | -| progress | number | Yes | Progress. | -| installMode | number | Yes | Installation mode. | -| errorMessages | Array\<[ErrorMessage](#errormessage)> | No | Error message. | -| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components. | +| Name | Type | Mandatory | Description | +| ----------------- | ---------------------------------------- | ---- | ---- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| status | [UpgradeStatus](#upgradestatus) | Yes | Update status.| +| subStatus | number | No | Sub-status. | +| progress | number | Yes | Progress. | +| installMode | number | Yes | Installation mode.| +| errorMessages | Array\<[ErrorMessage](#errormessage)> | No | Error message.| +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components.| ## ErrorMessage @@ -1551,10 +1551,10 @@ Represents an error message. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| errorCode | number | Yes | Error code. | -| errorMessage | string | Yes | Error description. | +| Name | Type | Mandatory | Description | +| ------------ | ------ | ---- | ---- | +| errorCode | number | Yes | Error code. | +| errorMessage | string | Yes | Error description.| ## EventClassifyInfo @@ -1562,10 +1562,10 @@ Represents event type information. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| eventClassify | [EventClassify](#eventclassify) | Yes | Event type. | -| extraInfo | string | Yes | Additional information. | +| Name | Type | Mandatory | Description | +| ------------- | ------------------------------- | ---- | ---- | +| eventClassify | [EventClassify](#eventclassify) | Yes | Event type.| +| extraInfo | string | Yes | Additional information.| ## UpgradeFile @@ -1573,22 +1573,22 @@ Represents an update file. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | ---- | ------- | -| fileType | [ComponentType](#componenttype) | Yes | File type. | -| filePath | string | Yes | File path. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | ---- | ---- | +| fileType | [ComponentType](#componenttype) | Yes | File type.| +| filePath | string | Yes | File path.| ## UpgradeTaskCallback ### (eventInfo: [EventInfo](#eventinfo)): void -Event callback. +Represents an event callback. **System capability**: SystemCapability.Update.UpdateService -| Parameter | Type | Mandatory | Description | -| --------------- | ---------------------------------------- | ---- | ---- | -| eventInfo | [EventInfo](#eventinfo) | Yes | Event information.| +| Name | Type | Mandatory | Description | +| --------- | ----------------------- | ---- | ---- | +| eventInfo | [EventInfo](#eventinfo) | Yes | Event information.| ## BusinessVendor @@ -1596,9 +1596,9 @@ Device vendor. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| PUBLIC | "public" | Open source. | +| Name | Default Value | Description | +| ------ | -------- | ---- | +| PUBLIC | "public" | Open source. | ## BusinessSubType @@ -1606,9 +1606,9 @@ Represents an update type. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| FIRMWARE | 1 | Firmware. | +| Name | Default Value | Description | +| -------- | ---- | ---- | +| FIRMWARE | 1 | Firmware. | ## ComponentType @@ -1616,9 +1616,9 @@ Represents a component type. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| OTA | 1 | Firmware. | +| Name | Default Value | Description | +| ---- | ---- | ---- | +| OTA | 1 | Firmware. | ## UpgradeAction @@ -1626,10 +1626,10 @@ Represents an update mode. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| UPGRADE | "upgrade" | Differential package. | -| RECOVERY | "recovery" | Recovery package. | +| Name | Default Value | Description | +| -------- | ---------- | ---- | +| UPGRADE | "upgrade" | Differential package. | +| RECOVERY | "recovery" | Recovery package. | ## EffectiveMode @@ -1637,11 +1637,11 @@ Represents an effective mode. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| COLD | 1 | Cold update. | -| LIVE | 2 | Live update. | -| LIVE_AND_COLD | 3 | Hybrid live and cold update. | +| Name | Default Value | Description | +| ------------- | ---- | ---- | +| COLD | 1 | Cold update. | +| LIVE | 2 | Live update. | +| LIVE_AND_COLD | 3 | Hybrid live and cold update.| ## DescriptionType @@ -1649,10 +1649,10 @@ Represents a description file type. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| CONTENT | 0 | Content. | -| URI | 1 | Link. | +| Name | Default Value | Description | +| ------- | ---- | ---- | +| CONTENT | 0 | Content. | +| URI | 1 | Link. | ## DescriptionFormat @@ -1660,10 +1660,10 @@ Represents a description file format. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| STANDARD | 0 | Standard format. | -| SIMPLIFIED | 1 | Simple format. | +| Name | Default Value | Description | +| ---------- | ---- | ---- | +| STANDARD | 0 | Standard format.| +| SIMPLIFIED | 1 | Simple format.| ## NetType @@ -1671,13 +1671,13 @@ Enumerates network types. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| CELLULAR | 1 | Data network. | -| METERED_WIFI | 2 | Wi-Fi hotspot. | -| NOT_METERED_WIFI | 4 | Non Wi-Fi hotspot. | -| WIFI | 6 | WIFI | -| CELLULAR_AND_WIFI | 7 | Data network and Wi-Fi. | +| Name | Default Value | Description | +| ----------------- | ---- | --------- | +| CELLULAR | 1 | Data network. | +| METERED_WIFI | 2 | Wi-Fi hotspot. | +| NOT_METERED_WIFI | 4 | Non Wi-Fi hotspot. | +| WIFI | 6 | Wi-Fi. | +| CELLULAR_AND_WIFI | 7 | Data network and Wi-Fi.| ## Order @@ -1685,13 +1685,13 @@ Represents an update command. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| DOWNLOAD | 1 | Download. | -| INSTALL | 2 | Install. | -| DOWNLOAD_AND_INSTALL | 3 | Download and install. | -| APPLY | 4 | Apply. | -| INSTALL_AND_APPLY | 6 | Install and apply. | +| Name | Default Value | Description | +| -------------------- | ---- | ----- | +| DOWNLOAD | 1 | Download. | +| INSTALL | 2 | Install. | +| DOWNLOAD_AND_INSTALL | 3 | Download and install.| +| APPLY | 4 | Apply. | +| INSTALL_AND_APPLY | 6 | Install and apply.| ## UpgradeStatus @@ -1699,18 +1699,18 @@ Enumerates update states. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| WAITING_DOWNLOAD | 20 | Waiting for download. | -| DOWNLOADING | 21 | Downloading. | -| DOWNLOAD_PAUSED | 22 | Download paused. | -| DOWNLOAD_FAIL | 23 | Download failed. | -| WAITING_INSTALL | 30 | Waiting for installation. | -| UPDATING | 31 | Updating. | -| WAITING_APPLY | 40 | Waiting for applying the update. | -| APPLYING | 21 | Applying the update. | -| UPGRADE_SUCCESS | 50 | Update succeeded. | -| UPGRADE_FAIL | 51 | Update failed. | +| Name | Default Value | Description | +| ---------------- | ---- | ---- | +| WAITING_DOWNLOAD | 20 | Waiting for download. | +| DOWNLOADING | 21 | Downloading. | +| DOWNLOAD_PAUSED | 22 | Download paused.| +| DOWNLOAD_FAIL | 23 | Download failed.| +| WAITING_INSTALL | 30 | Waiting for installation. | +| UPDATING | 31 | Updating. | +| WAITING_APPLY | 40 | Waiting for applying the update. | +| APPLYING | 21 | Applying the update. | +| UPGRADE_SUCCESS | 50 | Update succeeded.| +| UPGRADE_FAIL | 51 | Update failed.| ## EventClassify @@ -1718,9 +1718,9 @@ Represents an event type. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| TASK | 0x01000000 | Task event. | +| Name | Default Value | Description | +| ---- | ---------- | ---- | +| TASK | 0x01000000 | Task event.| ## EventId @@ -1728,22 +1728,22 @@ Enumerates event IDs. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ---- | -------- | -| EVENT_TASK_BASE | 0x01000000 | Indicates a task event. | -| EVENT_TASK_RECEIVE | 0x01000001 | Indicates that a task is received. | -| EVENT_TASK_CANCEL | 0x01000010 | Indicates that a task is cancelled. | -| EVENT_DOWNLOAD_WAIT | 0x01000011 | Indicates the state of waiting for the download. | -| EVENT_DOWNLOAD_START | 0x01000100 | Indicates that the download starts. | -| EVENT_DOWNLOAD_UPDATE | 0x01000101 | Indicates the download progress update. | -| EVENT_DOWNLOAD_PAUSE | 0x01000110 | Indicates that the download is paused. | -| EVENT_DOWNLOAD_RESUME | 0x01000111 | Indicates that the download is resumed. | -| EVENT_DOWNLOAD_SUCCESS | 0x01001000 | Indicates that the download succeeded. | -| EVENT_DOWNLOAD_FAIL | 0x01001001 | Indicates that the download failed. | -| EVENT_UPGRADE_WAIT | 0x01001010 | Indicates the state of waiting for the update. | -| EVENT_UPGRADE_START | 0x01001011 | Indicates that the update starts. | -| EVENT_UPGRADE_UPDATE | 0x01001100 | Indicates that the update is in progress. | -| EVENT_APPLY_WAIT | 0x01001101 | Indicates the state of waiting for applying the update. | -| EVENT_APPLY_START | 0x01001110 | Indicates the state of applying the update. | -| EVENT_UPGRADE_SUCCESS | 0x01001111 | Indicates that the update succeeded. | -| EVENT_UPGRADE_FAIL | 0x01010000 | Indicates that the update failed. | +| Name | Default Value | Description | +| ---------------------- | ---------- | ------ | +| EVENT_TASK_BASE | 0x01000000 | Indicates a task event. | +| EVENT_TASK_RECEIVE | 0x01000001 | Indicates that a task is received. | +| EVENT_TASK_CANCEL | 0x01000010 | Indicates that a task is cancelled. | +| EVENT_DOWNLOAD_WAIT | 0x01000011 | Indicates the state of waiting for the download. | +| EVENT_DOWNLOAD_START | 0x01000100 | Indicates that the download starts. | +| EVENT_DOWNLOAD_UPDATE | 0x01000101 | Indicates the download progress update.| +| EVENT_DOWNLOAD_PAUSE | 0x01000110 | Indicates that the download is paused. | +| EVENT_DOWNLOAD_RESUME | 0x01000111 | Indicates that the download is resumed. | +| EVENT_DOWNLOAD_SUCCESS | 0x01001000 | Indicates that the download succeeded. | +| EVENT_DOWNLOAD_FAIL | 0x01001001 | Indicates that the download failed. | +| EVENT_UPGRADE_WAIT | 0x01001010 | Indicates the state of waiting for the update. | +| EVENT_UPGRADE_START | 0x01001011 | Indicates that the update starts. | +| EVENT_UPGRADE_UPDATE | 0x01001100 | Indicates that the update is in progress. | +| EVENT_APPLY_WAIT | 0x01001101 | Indicates the state of waiting for applying the update. | +| EVENT_APPLY_START | 0x01001110 | Indicates the state of applying the update. | +| EVENT_UPGRADE_SUCCESS | 0x01001111 | Indicates that the update succeeded. | +| EVENT_UPGRADE_FAIL | 0x01010000 | Indicates that the update failed. | diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index b5eab0ff1825741b77cf81ae966c499aff4c1398..76bba2f5b15c6a9da9b2f4bb4f5201f4552a9cbd 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -25,21 +25,24 @@ Enumerates the window types. | Name | Value| Description | | ----------------- | ------ | ------------------ | -| TYPE_APP | 0 | Application subwindow. This type can be used only in the FA model.| +| TYPE_APP | 0 | Application subwindow.
**Model restriction**: This API can be used only in the FA model.| | TYPE_SYSTEM_ALERT | 1 | System alert window.| -| TYPE_INPUT_METHOD9+ | 2 | Input method window. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_STATUS_BAR9+ | 3 | Status bar. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_PANEL9+ | 4 | Notification panel. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_KEYGUARD9+ | 5 | Lock screen. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_VOLUME_OVERLAY9+ | 6 | Volume bar. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_NAVIGATION_BAR9+ | 7 | Navigation bar. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_FLOAT9+ | 8 | Floating window. This type can be used only in the stage model.
**Required permissions**: ohos.permission.SYSTEM_FLOAT_WINDOW| -| TYPE_WALLPAPER9+ | 9 | Wallpaper. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_DESKTOP9+ | 10 | Home screen. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_LAUNCHER_RECENT9+ | 11 | Recent tasks screen. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_LAUNCHER_DOCK9+ | 12 | Dock bar on the home screen. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_VOICE_INTERACTION9+ | 13 | Voice assistant. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| -| TYPE_POINTER9+ | 14 | Mouse. This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.| +| TYPE_INPUT_METHOD9+ | 2 | Input method window.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_STATUS_BAR9+ | 3 | Status bar.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_PANEL9+ | 4 | Notification panel.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_KEYGUARD9+ | 5 | Lock screen.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_VOLUME_OVERLAY9+ | 6 | Volume bar.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_NAVIGATION_BAR9+ | 7 | Navigation bar.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_FLOAT9+ | 8 | Floating window.
**Model restriction**: This API can be used only in the stage model.
**Required permissions**: ohos.permission.SYSTEM_FLOAT_WINDOW| +| TYPE_WALLPAPER9+ | 9 | Wallpaper.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_DESKTOP9+ | 10 | Home screen.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_LAUNCHER_RECENT9+ | 11 | Recent tasks screen.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_LAUNCHER_DOCK9+ | 12 | Dock bar on the home screen.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_VOICE_INTERACTION9+ | 13 | Voice assistant.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_POINTER9+ | 14 | Mouse.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_FLOAT_CAMERA9+ | 15 | Floating camera window.
**Model restriction**: This API can be used only in the stage model.
**Required permissions**: ohos.permission.SYSTEM_FLOAT_WINDOW| +| TYPE_DIALOG9+ | 16 | Modal window.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| +| TYPE_SCREENSHOT9+ | 17 | Screenshot window.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.| ## AvoidAreaType7+ @@ -58,7 +61,7 @@ Enumerates the types of the area where the window cannot be displayed. Enumerates the window modes. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -74,7 +77,7 @@ This is a system API and cannot be called by third-party applications. Enumerates the window layout modes. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -119,11 +122,26 @@ Enumerates the window orientations. | AUTO_ROTATION_LANDSCAPE_RESTRICTED | 10 | Switched-determined auto rotation in the horizontal direction.| | LOCKED | 11 | Locked.| +## BlurStyle9+ + +Enumerates the window blur styles. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Value | Description | +| ------- | ---- | -------------------- | +| OFF | 0 | Blur disabled. | +| THIN | 1 | Thin blur.| +| REGULAR | 2 | Regular blur.| +| THICK | 3 | Thick blur.| + ## SystemBarRegionTint8+ Describes the callback for a single system bar. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -139,7 +157,7 @@ This is a system API and cannot be called by third-party applications. Describes the callback for the current system bar. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -169,7 +187,7 @@ Describes the area where the window cannot be displayed. | Name | Type | Readable| Writable| Description | | ---------- | ------------- | ---- | ---- | ------------------ | -| visible9+ | boolean | Yes | Yes | Whether the area is visible.| +| visible9+ | boolean | Yes | Yes | Whether the window can be displayed in the area.| | leftRect | [Rect](#rect) | Yes | Yes | Rectangle on the left of the screen.| | topRect | [Rect](#rect) | Yes | Yes | Rectangle at the top of the screen.| | rightRect | [Rect](#rect) | Yes | Yes | Rectangle on the right of the screen.| @@ -192,20 +210,20 @@ Describes the window properties. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Type | Readable| Writable| Description | -| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- | -| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | -| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | -| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is `false`. | -| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`. | -| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is `true`. | -| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is `true`. | -| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness. | -| dimBehindValue(deprecated) | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.
**NOTE**
This attribute is deprecated since API version 9.
| -| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is `false`. | -| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is `false`. | -| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners. The default value is `false`. | -| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is `false`. | +| Name | Type | Readable| Writable| Description | +| ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | +| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | +| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | +| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is `false`. | +| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`. | +| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is `true`. | +| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is `true`. | +| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness. | +| dimBehindValue(deprecated) | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.
**NOTE**
This property is supported since API version 7 and deprecated since API version 9.
| +| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is `false`. | +| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is `false`. | +| isRoundCorner(deprecated) | boolean | Yes | Yes | Whether the window has rounded corners. The default value is `false`.
**NOTE**
This property is supported since API version 7 and deprecated since API version 9.
| +| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is `false`. | ## ColorSpace8+ @@ -218,13 +236,58 @@ Describes the color gamut mode. | DEFAULT | 0 | Default color gamut mode.| | WIDE_GAMUT | 1 | Wide color gamut mode. | +## ScaleOptions9+ + +Describes the scale parameters. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| ------ | -------- | ---- | ---- | -------------------------------------------------- | +| x | number | No | Yes | Scale factor of the x-axis. The default value is `1.0`. | +| y | number | No | Yes | Scale factor of the y-axis. The default value is `1.0`. | +| pivotX | number | No | Yes | X coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.| +| pivotY | number | No | Yes | Y coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.| + +## RotateOptions9+ + +Describes the rotation parameters. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| ------ | -------- | ---- | ---- | -------------------------------------------------- | +| x | number | No | Yes | Rotation angle around the x-axis. The default value is `0.0`. | +| y | number | No | Yes | Rotation angle around the y-axis. The default value is `0.0`. | +| z | number | No | Yes | Rotation angle around the z-xis. The default value is `0.0`. | +| pivotX | number | No | Yes | X coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.| +| pivotY | number | No | Yes | Y coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.| + +## TranslateOptions9+ + +Describes the translation parameters. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name| Type| Readable| Writable| Description | +| ---- | -------- | ---- | ---- | ---------------------------- | +| x | number | No | Yes | Distance to translate along the x-axis. The default value is `0.0`.| +| y | number | No | Yes | Distance to translate along the y-axis. The default value is `0.0`.| +| z | number | No | Yes | Distance to translate along the z-axis. The default value is `0.0`.| + ## window.create7+ create(id: string, type: WindowType, callback: AsyncCallback<Window>): void Creates a subwindow. This API uses an asynchronous callback to return the result. -This API can be used only in the FA model. +**Model restriction**: This API can be used only in the FA model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -240,13 +303,14 @@ This API can be used only in the FA model. ```js var windowClass = null; - let promise = window.create("first", window.WindowType.TYPE_APP); - promise.then((data)=> { - windowClass = data; - console.info('SubWindow created. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); - }); +window.create("first", window.WindowType.TYPE_APP,(err,data) => { + if(err.code){ + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); +}); ``` ## window.create7+ @@ -255,7 +319,7 @@ create(id: string, type: WindowType): Promise<Window> Creates a subwindow. This API uses a promise to return the result. -This API can be used only in the FA model. +**Model restriction**: This API can be used only in the FA model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -279,7 +343,7 @@ var windowClass = null; let promise = window.create("first", window.WindowType.TYPE_APP); promise.then((data)=> { windowClass = data; - console.info('SubWindow created. Data: ' + JSON.stringify(data)); + console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); }); @@ -300,7 +364,7 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). | ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).| | id | string | Yes | Window ID. | | type | [WindowType](#windowtype) | Yes | Window type. | -| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created. | **Example** @@ -308,11 +372,11 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). var windowClass = null; window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { if (err.code) { - console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); return; } windowClass = data; - console.info('Window created. Data: ' + JSON.stringify(data)); + console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); windowClass.resetSize(500, 1000); }); ``` @@ -337,7 +401,7 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). | Type | Description | | -------------------------------- | --------------------------------------- | -| Promise<[Window](#window)> | Promise used to return the window created. | +| Promise<[Window](#window)> | Promise used to return the subwindow created.| **Example** @@ -345,8 +409,8 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). var windowClass = null; let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); promise.then((data)=> { - windowClass = data; - console.info('Window created. Data:' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); }); @@ -377,7 +441,7 @@ var windowClass = null; return; } windowClass = data; - console.info('window found. Data: ' + JSON.stringify(data)); + console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); }); ``` @@ -408,7 +472,7 @@ var windowClass = null; let promise = window.find("alertWindow"); promise.then((data)=> { windowClass = data; - console.info('window found. Data: ' + JSON.stringify(data)); + console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); }); @@ -420,7 +484,7 @@ getTopWindow(callback: AsyncCallback<Window>): void Obtains the top window of the current application. This API uses an asynchronous callback to return the result. -This API can be used only in the FA model. +**Model restriction**: This API can be used only in the FA model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -450,7 +514,7 @@ getTopWindow(): Promise<Window> Obtains the top window of the current application. This API uses a promise to return the result. -This API can be used only in the FA model. +**Model restriction**: This API can be used only in the FA model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -540,7 +604,7 @@ minimizeAll(id: number, callback: AsyncCallback<void>): void Minimizes all windows on a display. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -548,7 +612,7 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | -------------- | -| id | number | Yes | ID of the [display](js-apis-display.md#display). | +| id | number | Yes | ID of the [display](js-apis-display.md#display).| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -578,7 +642,7 @@ minimizeAll(id: number): Promise<void> Minimizes all windows on a display. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -620,7 +684,7 @@ toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void Hides or restores the application's windows during quick multi-window switching. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -647,7 +711,7 @@ toggleShownStateForAllAppWindows(): Promise<void> Hides or restores the application's windows during quick multi-window switching. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -673,7 +737,7 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>) Sets the window layout mode. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -697,7 +761,7 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> Sets the window layout mode. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -730,7 +794,7 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v Enables listening for properties changes of the status bar and navigation bar. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -755,7 +819,7 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >) Disables listening for properties changes of the status bar and navigation bar. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -784,7 +848,7 @@ hide (callback: AsyncCallback<void>): void Hides this window. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -802,7 +866,7 @@ windowClass.hide((err, data) => { console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); return; } - console.info('window hidden. data: ' + JSON.stringify(data)); + console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); }) ``` @@ -812,7 +876,7 @@ hide(): Promise<void> Hides this window. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -827,12 +891,67 @@ This is a system API and cannot be called by third-party applications. ```js let promise = windowClass.hide(); promise.then((data)=> { - console.info('window hidden. Data: ' + JSON.stringify(data)); + console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); }) ``` +### hideWithAnimation9+ + +hideWithAnimation(callback: AsyncCallback<void>): void + +Hides this window and plays an animation during the process. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +windowClass.hideWithAnimation((err, data) => { + if (err.code) { + console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in hiding the window with animation. data: ' + JSON.stringify(data)); +}) +``` + +### hideWithAnimation9+ + +hideWithAnimation(): Promise<void> + +Hides this window and plays an animation during the process. This API uses a promise to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** + +```js +let promise = windowClass.hideWithAnimation(); +promise.then((data)=> { + console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); +}) +``` + ### show7+ show(callback: AsyncCallback<void>): void @@ -884,6 +1003,61 @@ promise.then((data)=> { }) ``` +### showWithAnimation9+ + +showWithAnimation(callback: AsyncCallback<void>): void + +Shows this window and plays an animation during the process. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +windowClass.showWithAnimation((err, data) => { + if (err.code) { + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); +}) +``` + +### showWithAnimation9+ + +showWithAnimation(): Promise<void> + +Shows this window and plays an animation during the process. This API uses a promise to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** + +```js +let promise = windowClass.showWithAnimation(); +promise.then((data)=> { + console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); +}) +``` + ### destroy7+ destroy(callback: AsyncCallback<void>): void @@ -959,7 +1133,7 @@ windowClass.moveTo(300, 300, (err, data)=>{ console.error('Failed to move the window. Cause:' + JSON.stringify(err)); return; } - console.info('Window moved. Data: ' + JSON.stringify(data)); + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); }); ``` @@ -990,7 +1164,7 @@ Moves this window. This API uses a promise to return the result. ```js let promise = windowClass.moveTo(300, 300); promise.then((data)=> { - console.info('Window moved. Data: ' + JSON.stringify(data)); + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); }) @@ -1020,7 +1194,7 @@ windowClass.resetSize(500, 1000, (err, data) => { console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); return; } - console.info('Window size changed. Data: ' + JSON.stringify(data)); + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); }); ``` @@ -1050,19 +1224,23 @@ Changes the size of this window. This API uses a promise to return the result. ```js let promise = windowClass.resetSize(500, 1000); promise.then((data)=> { - console.info('Window size changed. Data: ' + JSON.stringify(data)); + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); }); ``` -### setWindowType7+ +### setWindowType(deprecated) setWindowType(type: WindowType, callback: AsyncCallback<void>): void Sets the type of this window. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. + +> **NOTE**
This API is supported since API version 7 and deprecated since API version 9. +> +> **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1086,13 +1264,17 @@ windowClass.setWindowType(type, (err, data) => { }); ``` -### setWindowType7+ +### setWindowType(deprecated) setWindowType(type: WindowType): Promise<void> Sets the type of this window. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. + +> **NOTE**
This API is supported since API version 7 and deprecated since API version 9. +> +> **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1183,7 +1365,7 @@ Obtains the area where this window cannot be displayed, for example, the system | Name | Type | Mandatory| Description | | -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. **TYPE_SYSTEM_GESTURE** indicates the gesture area. **TYPE_KEYBOARD** indicates the soft keyboard area.| +| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. `TYPE_SYSTEM_GESTURE` indicates the gesture area. `TYPE_KEYBOARD` indicates the soft keyboard area.| | callback | AsyncCallback<[AvoidArea](#avoidarea7)> | Yes | Callback used to return the area. | **Example** @@ -1211,7 +1393,7 @@ Obtains the area where this window cannot be displayed, for example, the system | Name| Type | Mandatory| Description | | ------ |----------------------------------| ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. **TYPE_SYSTEM_GESTURE** indicates the gesture area. **TYPE_KEYBOARD** indicates the soft keyboard area.| +| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. `TYPE_SYSTEM_GESTURE` indicates the gesture area. `TYPE_KEYBOARD` indicates the soft keyboard area.| **Return value** @@ -1368,13 +1550,14 @@ Sets whether to display the status bar and navigation bar in this window. This A **Example** ```js -var names = ["status", "navigation"]; +// In this example, the status bar and navigation bar are not displayed. +var names = []; windowClass.setSystemBarEnable(names, (err, data) => { if (err.code) { - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); }); ``` @@ -1401,12 +1584,13 @@ Sets whether to display the status bar and navigation bar in this window. This A **Example** ```js -var names = ["status", "navigation"]; +// In this example, the status bar and navigation bar are not displayed. +var names = []; let promise = windowClass.setSystemBarEnable(names); promise.then((data)=> { - console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); }); ``` @@ -1611,7 +1795,7 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void Loads content from a page associated with a local storage to this window. This API uses an asynchronous callback to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1620,14 +1804,14 @@ This API can be used only in the stage model. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| +| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```ts class myAbility extends Ability { - storage : LocalStorage + storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); this.storage.setOrCreate("storageSimpleProp",121); @@ -1649,7 +1833,7 @@ loadContent(path: string, storage: LocalStorage): Promise<void> Loads content from a page associated with a local storage to this window. This API uses a promise to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1658,7 +1842,7 @@ This API can be used only in the stage model. | Name | Type | Mandatory| Description | | ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| +| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| **Return value** @@ -1670,7 +1854,7 @@ This API can be used only in the stage model. ```ts class myAbility extends Ability { - storage : LocalStorage + storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); this.storage.setOrCreate("storageSimpleProp",121); @@ -1786,9 +1970,9 @@ windowClass.off('windowSizeChange'); on(type: 'systemAvoidAreaChange', callback: Callback<[AvoidArea](#avoidarea7)>): void Enables listening for changes to the area where the window cannot be displayed. -> **NOTE** +> **NOTE**
This API is supported since API version 7 and deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead. > -> This API is deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead. +> **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1812,9 +1996,9 @@ windowClass.on('systemAvoidAreaChange', (data) => { off(type: 'systemAvoidAreaChange', callback?: Callback<[AvoidArea](#avoidarea7)>): void Disables listening for changes to the area where the window cannot be displayed. -> **NOTE** +> **NOTE**
This API is supported since API version 7 and deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead. > -> This API is deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead. +> **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1850,8 +2034,8 @@ Enables listening for changes to the area where the window cannot be displayed. **Example** ```js -windowClass.on('avoidAreaChange', (type, data) => { - console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(type) + 'Data: ' + JSON.stringify(data)); +windowClass.on('avoidAreaChange', (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area)); }); ``` @@ -1925,7 +2109,8 @@ windowClass.off('keyboardHeightChange'); on(type: 'touchOutside', callback: Callback<void>): void Enables listening for click events outside this window. -This is a system API and cannot be called by third-party applications. + +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1949,7 +2134,8 @@ windowClass.on('touchOutside', () => { off(type: 'touchOutside', callback?: Callback<void>): void Disables listening for click events outside this window. -This is a system API and cannot be called by third-party applications. + +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -1966,6 +2152,209 @@ This is a system API and cannot be called by third-party applications. windowClass.off('touchOutside'); ``` +### on('screenshot')9+ + +on(type: 'screenshot', callback: Callback<void>): void + +Subscribes to screenshot events. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.| +| callback | Callback<void> | Yes | Callback invoked when a screenshot event occurs. | + +**Example** + +```js +windowClass.on('screenshot', () => { + console.info('screenshot happened'); +}); +``` + +### off('screenshot')9+ + +off(type: 'screenshot', callback?: Callback<void>): void + +Unsubscribes from screenshot events. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.| +| callback | Callback<void> | No | Callback invoked when a screenshot event occurs.| + +**Example** + +```js +var callback = ()=>{ + console.info('screenshot happened'); +} +windowClass.on('screenshot', callback) +windowClass.off('screenshot', callback) + +// If multiple callbacks are enabled in on(), they will all be disabled. +windowClass.off('screenshot'); +``` + +### on('dialogTargetTouch')9+ + +on(type: 'dialogTargetTouch', callback: Callback<void>): void + +Subscribes to click events of the target window in the modal window mode. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.| +| callback | Callback<void>| Yes | Callback invoked when the click event occurs in the target window of the modal window mode.| + +**Example** + +```js +windowClass.on('dialogTargetTouch', () => { + console.info('touch dialog target'); +}); +``` + +### off('dialogTargetTouch')9+ + +off(type: 'dialogTargetTouch', callback?: Callback<void>): void + +Unsubscribes from click events of the target window in the modal window mode. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.| +| callback | Callback<void> | No | Callback invoked when the click event occurs in the target window of the modal window mode.| + +**Example** + +```js +windowClass.off('dialogTargetTouch'); +``` + +### bindDialogTarget9+ + +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void + +Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes | Token of the target window.| +| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } +} +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } +} +let token = new TestRemoteObject("testObject"); +windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); +}, (err, data) => { + if (err.code) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); +}); +``` + +### bindDialogTarget9+ + +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> + +Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses a promise to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes | Token of the target window.| +| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** + +```js +class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } +} +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } +} +let token = new TestRemoteObject("testObject"); +let promise = windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); +}); +promise.then((data)=> { + console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); +}); +``` + ### isSupportWideGamut8+ isSupportWideGamut(callback: AsyncCallback<boolean>): void @@ -2138,7 +2527,7 @@ Sets the background color for this window. This API uses an asynchronous callbac | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| +| color | string | Yes | Background color to set. The value is a hexadecimal color and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -2166,7 +2555,7 @@ Sets the background color for this window. This API uses a promise to return the | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| +| color | string | Yes | Background color to set. The value is a hexadecimal color and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| **Return value** @@ -2186,26 +2575,49 @@ promise.then((data)=> { }); ``` -### setBrightness +### setWakeUpScreen()9+ -setBrightness(brightness: number, callback: AsyncCallback<void>): void +setWakeUpScreen(wakeUp: boolean): void; -Sets the screen brightness for this window. This API uses an asynchronous callback to return the result. +Wakes up the screen. + +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------- | ---- | ------------------------------------ | -| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| ---------------- | ------- | ---- | ---------------------------- | +| wakeUp | boolean | Yes | Whether to wake up the screen.| **Example** ```js -var brightness = 1; -windowClass.setBrightness(brightness, (err, data) => { +var wakeUp = true; +windowClass.setWakeUpScreen(wakeUp); +``` + +### setBrightness + +setBrightness(brightness: number, callback: AsyncCallback<void>): void + +Sets the screen brightness for this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------------------------------ | +| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +var brightness = 1; +windowClass.setBrightness(brightness, (err, data) => { if (err.code) { console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); return; @@ -2253,8 +2665,10 @@ setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result. > **NOTE** -> -> This API is deprecated since API version 9. +> +> This API cannot be used. +> +> This API is supported since API version 7 and deprecated since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2284,8 +2698,10 @@ setDimBehind(dimBehindValue: number): Promise<void> Sets the dimness of the window that is not on top. This API uses a promise to return the result. > **NOTE** -> -> This API is deprecated since API version 9. +> +> This API cannot be used. +> +> This API is supported since API version 7 and deprecated since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2428,7 +2844,7 @@ let promise = windowClass.setKeepScreenOn(isKeepScreenOn); promise.then((data) => { console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); }); ``` @@ -2439,8 +2855,10 @@ setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): vo Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result. > **NOTE** -> -> This API is deprecated since API version 9. +> +> This API cannot be used. +> +> This API is supported since API version 7 and deprecated since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2470,8 +2888,10 @@ setOutsideTouchable(touchable: boolean): Promise<void> Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result. > **NOTE** -> -> This API is deprecated since API version 9. +> +> This API cannot be used. +> +> This API is supported since API version 7 and deprecated since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2502,7 +2922,7 @@ promise.then((data)=> { setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. +Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2531,7 +2951,7 @@ windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { setPrivacyMode(isPrivacyMode: boolean): Promise<void> -Sets whether this window is in privacy mode. This API uses a promise to return the result. +Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2559,6 +2979,25 @@ promise.then((data)=> { }); ``` +### setSnapshotSkip9+ +setSnapshotSkip(isSkip: boolean): void + +Sets whether to ignore this window during screen capturing or recording. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | ------- | ---- | -------------------- | +| isSkip | boolean | Yes | Whether to ignore the window. The default value is `false`.
The value `true` means that the window is ignored, and `false` means the opposite.
| +```js +var isSkip = true; +windowClass.setSnapshotSkip(isSkip); +``` + ### setTouchable7+ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void @@ -2626,7 +3065,7 @@ setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void&g Sets whether this window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2657,7 +3096,7 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> Sets whether this window is forbidden to move in split-screen mode. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2685,11 +3124,330 @@ promise.then((data)=> { }); ``` +### snapshot9+ + +snapshot(callback: AsyncCallback<image.PixelMap>): void + +Captures this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | -------------------- | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback used to return the result. | + +**Example** + +```js +windowClass.snapshot((err, data) => { + if (err.code) { + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + data.release(); // Release the memory in time after the PixelMap is used. +}); +``` + +### snapshot9+ + +snapshot(): Promise<image.PixelMap> + +Captures this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise used to return the window screenshot.| + +**Example** + +```js +let promise = windowClass.snapshot(); +promise.then((pixelMap)=> { + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // Release the memory in time after the PixelMap is used. +}).catch((err)=>{ + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); +}); +``` + +### setBlur9+ + +setBlur(radius: number): void + +Blurs this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | Yes | Radius of the blur. The value is greater than or equal to 0. The value `0` means that the blur is disabled for the window.| + +**Example** + +```js +windowClass.setBlur(4.0); +``` + +### setBackdropBlur9+ + +setBackdropBlur(radius: number): void + +Blurs the background of this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | Yes | Radius of the blur. The value is greater than or equal to 0. The value `0` means that the blur is disabled for the background of the window.| + +**Example** + +```js +windowClass.setBackdropBlur(4.0); +``` + +### setBackdropBlurStyle9+ + +setBackdropBlurStyle(blurStyle: BlurStyle): void + +Sets the blur style for the background of this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | --------- | ---- | ---------------------- | +| blurStyle | [BlurStyle](#blurstyle9) | Yes | Blur style to set for the background of the window.| + +**Example** + +```js +windowClass.setBackdropBlurStyle(window.BlurType.THIN); +``` + +### setShadow9+ + +setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void + +Sets the shadow for the window borders. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| radius | number | Yes | Radius of the blur for the borders. The value is greater than or equal to 0. The value `0` means that the shadow is disabled for the window borders.| +| color | string | No | Color of the shadow. The value is a hexadecimal color and is case insensitive, for example, `#00FF00` or `#FF00FF00`.| +| offsetX | number | No | Offset of the shadow along the x-axis, in pixels. | +| offsetY | number | No | Offset of the shadow along the y-axis, in pixels. | + +**Example** + +```js +windowClass.setShadow(4.0, '#FF00FF00', 2, 3); +``` + +### setCornerRadius9+ + +setCornerRadius(cornerRadius: number): void + +Sets the radius of the rounded corners for this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------- | ---- | -------------------- | +| radius | number | Yes | Radius of the rounded corners. The value is greater than or equal to 0. The value `0` means that the window does not use rounded corners.| + +**Example** + +```js +windowClass.setCornerRadius(4.0); +``` + +### opacity9+ + +opacity(opacity: number): void + +Sets the opacity for this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | --------------------- | +| opacity | number | Yes | Opacity to set. The value ranges from 0.0 to 1.0.| + +**Example** + +```js +windowClass.opacity(0.5); +``` + +### scale9+ + +scale(scaleOptions: ScaleOptions): void + +Sets the scale parameters for this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------------------------------ | ---- | ---------- | +| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes | Scale parameters to set.| + +**Example** + +```js +var obj : window.ScaleOptions; +obj.x = 2.0; +obj.y = 1.0; +obj.pivotX = 0.5; +obj.pivotY = 0.5; +windowClass.scale(obj); +``` + +### rotate9+ + +rotate(rotateOptions: RotateOptions): void + +Sets the rotation parameters for this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | -------------------------------- | ---- | ---------- | +| rotateOptions | [RotateOptions](#rotateoptions9) | Yes | Rotation parameters to set.| + +**Example** + +```js +var obj : window.RotateOptions; +obj.x = 1.0; +obj.y = 1.0; +obj.z = 45.0; +obj.pivotX = 0.5; +obj.pivotY = 0.5; +windowClass.rotate(obj); +``` + +### translate9+ + +translate(translateOptions: TranslateOptions): void + +Sets the translation parameters for this window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------------- | -------------------------------------- | ---- | ---------- | +| translateOptions | [TranslateOptions](#translateoptions9) | Yes | Translation parameters to set.| + +**Example** + +```js +var obj : window.TranslateOptions; +obj.x = 100.0; +obj.y = 0.0; +obj.z = 0.0; +windowClass.translate(obj); +``` + +### getTransitionController9+ + + getTransitionController(): TransitionController + +Obtains the transition animation controller. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Return value** + +| Type | Description | +| ---------------------------------------------- | ---------------- | +| [TransitionController](#transitioncontroller9) | Transition animation controller.| + +**Example** + +```js +let controller = windowClass.getTransitionController(); // Obtain the transition animation controller. +controller.animationForHidden = (context : window.TransitionContext) => { + let toWindow = context.toWindow + animateTo({ + duration: 1000, // Animation duration. + tempo: 0.5, // Playback speed. + curve: Curve.EaseInOut, // Animation curve. + delay: 0, // Animation delay. + iterations: 1, // Number of playback times. + playMode: PlayMode.Normal // Animation mode. + }, () => { + var obj : window.TranslateOptions; + obj.x = 100.0; + obj.y = 0.0; + obj.z = 0.0; + toWindow.translate(obj); // Set the transition animation. + console.info('toWindow translate end'); + } + ) + context.completeTransition(true) + console.info('complete transition end'); +} +windowClass.showWithAnimation((err, data) => { + if (err.code) { + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); +}) +``` + ## WindowStageEventType9+ Describes the lifecycle of a window stage. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2712,7 +3470,7 @@ getMainWindow(callback: AsyncCallback<Window>): void Obtains the main window of this window stage. This API uses an asynchronous callback to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2747,7 +3505,7 @@ getMainWindow(): Promise<Window> Obtains the main window of this window stage. This API uses a promise to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2781,7 +3539,7 @@ createSubWindow(name: string, callback: AsyncCallback<Window>): void Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2818,7 +3576,7 @@ createSubWindow(name: string): Promise<Window> Creates a subwindow for this window stage. This API uses a promise to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2858,7 +3616,7 @@ getSubWindow(callback: AsyncCallback<Array<Window>>): void Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2893,7 +3651,7 @@ getSubWindow(): Promise<Array<Window>> Obtains all the subwindows of this window stage. This API uses a promise to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2927,7 +3685,7 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void Loads content from a page associated with a local storage to the main window in this window stage. This API uses an asynchronous callback to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2936,7 +3694,7 @@ This API can be used only in the stage model. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| +| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -2944,7 +3702,7 @@ This API can be used only in the stage model. ```ts import Ability from '@ohos.application.Ability'; class myAbility extends Ability { - storage : LocalStorage + storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); this.storage.setOrCreate("storageSimpleProp",121); @@ -2966,7 +3724,7 @@ loadContent(path: string, storage?: LocalStorage): Promise<void> Loads content from a page associated with a local storage to the main window in this window stage. This API uses a promise to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -2975,7 +3733,7 @@ This API can be used only in the stage model. | Name | Type | Mandatory| Description | | ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | LocalStorage | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| +| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| **Return value** @@ -2988,7 +3746,7 @@ This API can be used only in the stage model. ```ts import Ability from '@ohos.application.Ability'; class myAbility extends Ability { - storage : LocalStorage + storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); this.storage.setOrCreate("storageSimpleProp",121); @@ -3011,7 +3769,7 @@ loadContent(path: string, callback: AsyncCallback<void>): void Loads content from a page to this window stage. This API uses an asynchronous callback to return the result. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -3046,7 +3804,7 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType> Enables listening for window stage lifecycle changes. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -3077,7 +3835,7 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g Disables listening for window stage lifecycle changes. -This API can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -3106,9 +3864,9 @@ disableWindowDecor(): void Disables window decorators. -This type can be used only in the stage model. +**Model restriction**: This API can be used only in the stage model. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -3130,7 +3888,9 @@ setShowOnLockScreen(showOnLockScreen: boolean): void Sets whether to display the window of the application on the lock screen. -This API can be used only in the stage model. +**System API**: This is a system API. + +**Model restriction**: This API can be used only in the stage model. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -3151,3 +3911,145 @@ class myAbility extends Ability { } } ``` +## TransitionContext9+ + +Provides the context for the transition animation. + +**System API**: This is a system API. + +### toWindow9+ + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Readable| Writable| Description | +| -------- | ----------------- | ---- | ---- | ---------------- | +| toWindow | [Window](#window) | Yes | Yes | Target window to display the animation.| + +### completeTransition9+ + +completeTransition(isCompleted: boolean): void + +Completes the transition. This API must be called after [animateTo()](../arkui-ts/ts-explicit-animation.md) is executed. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------- | ---- | ------------------------------------------------------------ | +| isCompleted | boolean | Yes | Whether the transition is complete. The value `true` means that the transition is complete, and `false` means the opposite.| + +**Example** + +```js +let controller = windowClass.getTransitionController(); +controller.animationForShown = (context : window.TransitionContext) => { + let toWindow = context.toWindow + animateTo({ + duration: 1000, // Animation duration. + tempo: 0.5, // Playback speed. + curve: Curve.EaseInOut, // Animation curve. + delay: 0, // Animation delay. + iterations: 1, // Number of playback times. + playMode: PlayMode.Normal // Animation mode. + }, () => { + var obj : window.TranslateOptions; + obj.x = 100.0; + obj.y = 0.0; + obj.z = 0.0; + toWindow.translate(obj); + console.info('toWindow translate end'); + } + ) + context.completeTransition(true) + console.info('complete transition end'); +} +``` + +## TransitionController9+ + +Implements the transition animation controller. + +**System API**: This is a system API. + +### animationForShown9+ + +animationForShown(context: TransitionContext): void + +Customizes the animation when the window is shown. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | -------------------- | +| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.| + +**Example** + +```js +let controller = windowClass.getTransitionController(); +controller.animationForShown = (context : window.TransitionContext) => { + let toWindow = context.toWindow + animateTo({ + duration: 1000, // Animation duration. + tempo: 0.5, // Playback speed. + curve: Curve.EaseInOut, // Animation curve. + delay: 0, // Animation delay. + iterations: 1, // Number of playback times. + playMode: PlayMode.Normal // Animation mode. + }, () => { + var obj : window.TranslateOptions; + obj.x = 100.0; + obj.y = 0.0; + obj.z = 0.0; + toWindow.translate(obj); + console.info('toWindow translate end'); + } + ) + context.completeTransition(true) + console.info('complete transition end'); +} +``` + +### animationForHidden9+ + +animationForHidden(context: TransitionContext): void + +Customizes the animation when the window is hidden. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | -------------------- | +| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.| + +**Example** + +```js +let controller = windowClass.getTransitionController(); +controller.animationForHidden = (context : window.TransitionContext) => { + let toWindow = context.toWindow + animateTo({ + duration: 1000, // Animation duration. + tempo: 0.5, // Playback speed. + curve: Curve.EaseInOut, // Animation curve. + delay: 0, // Animation delay. + iterations: 1, // Number of playback times. + playMode: PlayMode.Normal // Animation mode. + }, () => { + var obj : window.TranslateOptions; + obj.x = 100.0; + obj.y = 0.0; + obj.z = 0.0; + toWindow.translate(obj); + console.info('toWindow translate end'); + } + ) + context.completeTransition(true) + console.info('complete transition end'); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-windowAnimationManager.md b/en/application-dev/reference/apis/js-apis-windowAnimationManager.md new file mode 100644 index 0000000000000000000000000000000000000000..a81bb5c76c64a092ea77afb14db231040adf77ac --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-windowAnimationManager.md @@ -0,0 +1,375 @@ +# Window Animation Management +The **WindowAnimationManager** module provides APIs to listen for application start/exit events and window minimization/maximization events and associate animations with these events. + +> **NOTE** +> +> This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. +> +> The APIs provided by this module are system APIs. + +## Modules to Import + +```js +import windowAnimationManager from '@ohos.animation.windowAnimationManager' +``` + +## windowAnimationManager.setController + +setController(controller: WindowAnimationController): void + +Sets a window animation controller. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| controller | [WindowAnimationController](#windowanimationcontroller) | Yes| Window animation controller to set.| + +**Example** + +```js +var controller = { + onStartAppFromLauncher(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromLauncher', startingWindowTarget); + }, + onStartAppFromRecent(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromRecent', startingWindowTarget); + }, + onStartAppFromOther(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromOther', startingWindowTarget); + }, + onAppTransition(fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + }, + onMinimizeWindow(minimizingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + }, + onCloseWindow(closingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + }, + onScreenUnlock(finishCallback: WindowAnimationFinishedCallback): void { + } +} + +windowAnimationManager.setController(controller) +``` + +## windowAnimationManager.minimizeWindowWithAnimation + +minimizeWindowWithAnimation(windowTarget: WindowAnimationTarget, callback: AsyncCallback<WindowAnimationFinishedCallback>): void + +Minimizes the window that displays the animation. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| windowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes| Target window to minimize.| +| callback | AsyncCallback<[WindowAnimationFinishedCallback](#windowanimationfinishedcallback)> | Yes| Callback invoked when the animation is finished.| + +**Example** + +```js +var target: WindowAnimationTarget = undefined; +var controller = { + onWindowAnimationTargetsUpdate(fullScreenWindowTarget: WindowAnimationTarget, floatingWindowTargets: Array): void { + target = fullScreenWindowTarget; + }, +} + +windowAnimationManager.setController(controller) + +var finishedCallback = null; +windowAnimationManager.minimizeWindowWithAnimation(target, (err, data) => { + if (err.code) { + console.error('Failed to minimize the window target. Cause: ' + JSON.stringify(err)); + return; + } + + finishedCallback = data; +}); + +finishedCallback.onAnimationFinish(); +``` + +## windowAnimationManager.minimizeWindowWithAnimation + +minimizeWindowWithAnimation(windowTarget: WindowAnimationTarget): Promise<WindowAnimationFinishedCallback> + +Minimizes the window that displays the animation. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| windowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes| Target window to display the animation.| + +**Return value** + +| Type | Description | +| -------------------------------- | --------------------------------------- | +| Promise<[WindowAnimationFinishedCallback](#windowanimationfinishedcallback)> | Promise used to return a call when the animation is finished.| + + +**Example** + +```js +var target: WindowAnimationTarget = undefined; +var controller = { + onWindowAnimationTargetsUpdate(fullScreenWindowTarget: WindowAnimationTarget, floatingWindowTargets: Array): void { + target = fullScreenWindowTarget; + }, +} + +windowAnimationManager.setController(controller) + +let promise = windowAnimationManager.minimizeWindowWithAnimation(target); +promise.then((data) => { + data.onAnimationFinish(); +}).catch((err)=>{ + console.error('Failed to minimize the window target. Cause: ' + JSON.stringify(err)); + return; +}); +``` + +## WindowAnimationController + +Implements the window animation controller. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +### onStartAppFromLauncher + +onStartAppFromLauncher(startingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +Called when an application is started from the home screen. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------ | +| startingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Target window to display the animation. | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | Yes | Callback invoked when the animation is finished.| + +**Example** + +```js +var controller = { + onStartAppFromLauncher(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromLauncher', startingWindowTarget); + } +} +``` + +### onStartAppFromRecent + +onStartAppFromRecent(startingWindowTarget: WindowAnimationTarget,finishCallback:WindowAnimationFinishedCallback): void + +Called when an application is started from the recent task list. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------ | +| startingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Target window to display the animation. | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | Yes | Callback invoked when the animation is finished.| + +**Example** + +```js +var controller = { + onStartAppFromRecent(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromRecent', startingWindowTarget); + } +} +``` + +### onStartAppFromOther + +onStartAppFromOther(startingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +Called when an application is started from a place other than the home screen and recent task list. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------ | +| startingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Target window to display the animation. | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | Yes | Callback invoked when the animation is finished.| + +**Example** + +```js +var controller = { + onStartAppFromOther(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromOther', startingWindowTarget); + } +} +``` + +### onAppTransition + +onAppTransition(fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +Called during application transition. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------- | ---- | ---------------- | +| fromWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Window that displays the animation before the transition.| +| toWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Window that displays the animation after the transition.| +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | Yes | Callback invoked when the animation is finished.| + +**Example** + +```js +var controller = { + onAppTransition(fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget, + finishCallback: WindowAnimationFinishedCallback): void { + console.log('onAppTransition', fromWindowTarget); + } +} +``` + +### onMinimizeWindow + +onMinimizeWindow(minimizingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +Called when a window is minimized. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------- | ---- | ---------------- | +| minimizingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Target window to display the animation. | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | Yes | Callback invoked when the animation is finished.| + +**Example** + +```js +var controller = { + onMinimizeWindow(minimizingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onMinimizeWindow', minimizingWindowTarget); + } +} +``` + +### onCloseWindow + +onCloseWindow(closingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +Called when a window is closed. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------- | ---- | ---------------- | +| closingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Target window to display the animation. | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | Yes | Callback invoked when the animation is finished.| + +**Example** + +```js +var controller = { + onCloseWindow(closingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onCloseWindow', closingWindowTarget); + } +} +``` + +### onScreenUnlock + +onScreenUnlock(finishCallback: [WindowAnimationFinishedCallback](#windowanimationfinishedcallback)): void + +Called when the screen is unlocked. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------------------------------------ | ---- | ------------------ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | Yes | Callback invoked when the animation is finished.| + +**Example** + +```js +var controller = { + onScreenUnlock(finishCallback: WindowAnimationFinishedCallback): void { + console.log('onScreenUnlock'.); + } +} +``` + +### onWindowAnimationTargetsUpdate + +onWindowAnimationTargetsUpdate(fullScreenWindowTarget: WindowAnimationTarget, floatingWindowTargets: Array<WindowAnimationTarget>): void + +Called when the window that displays the animation is updated. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------- | ---- | ---------------- | +| fullScreenWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | Yes | Target window in full-screen mode.| +| floatingWindowTargets| Array<[WindowAnimationTarget](#windowanimationtarget)> | Yes | Target window in the form of a floating window.| + +**Example** + +```js +var controller = { + onWindowAnimationTargetsUpdate(fullScreenWindowTarget: WindowAnimationTarget, floatingWindowTargets: Array): void { + console.log('onWindowAnimationTargetsUpdate'.); + } +} + +windowAnimationManager.setController(controller) +``` + +## WindowAnimationFinishedCallback +Implements a callback that is invoked when the animation is finished. + +### onAnimationFinish + +onAnimationFinish():void + +Called when the animation is finished. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Example** + +```js +var controller = { + onCloseWindow(closingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + finishCallback.onAnimationFinish(); + } +} +``` + +## WindowAnimationTarget +Implements animation in a window. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Description| +| ------- | ------ | ----------------------- | +| bundleName | string | Bundle name corresponding to the target window.| +| abilityName | string | Ability name corresponding to the target window.| +| windowBounds | [RRect](#rrect) | Actual size of the target window.| +| missionId | number | Mission ID.| + +## RRect +Describes a rounded rectangle. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Description| +| ------- | ------ | ----------------------- | +| left | number | Horizontal coordinate of the upper left corner of the target window relative to the screen.| +| top | number | Vertical coordinate of the upper left corner of the target window relative to the screen.| +| width | number | Width of the target window.| +| height | number | Height of the target window.| +| radius | number | Radius of the rounded corner of the target window.| diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md index 1ecbdd65106ffc30514cb7be9a7eb3d5a699d219..ec2ef9926c71afe8e8745d8ab65a92efa6cceacf 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -34,8 +34,8 @@ Not supported | Name | Type | Default Value | Description | | ------------------ | ---------------------------------------- | ----------------- | ---------------------------------------- | | domStorageAccess | boolean | false | Whether to enable the DOM Storage API permission. By default, the permission is disabled.| -| fileAccess | boolean | false | Whether to enable in-application rawfile access through [$rawfile(filepath/filename)](../../ui/ts-application-resource-access.md). By default, this feature is enabled. | -| fileFromUrlAccess | boolean | true | Whether to allow JavaScript scripts on web pages to access the content in [$rawfile(filepath/filename)](../../ui/ts-application-resource-access.md). By default, this feature is disabled. | +| fileAccess | boolean | false | Whether to enable in-application rawfile access through [$rawfile(filepath/filename)](../../ui/ts-resource-access.md). By default, this feature is enabled. | +| fileFromUrlAccess | boolean | true | Whether to allow JavaScript scripts on web pages to access the content in [$rawfile(filepath/filename)](../../ui/ts-resource-access.md). By default, this feature is disabled. | | imageAccess | boolean | true | Whether to enable automatic image loading. By default, this feature is enabled. | | javaScriptProxy | {
object: object,
name: string,
methodList: Array\,
controller: WebController
} | - | JavaScript object to be injected into the window. Methods of this object can be invoked in the window. The parameters in this attribute cannot be updated.
**object** indicates the object to be registered. Methods can be declared, but not attributes. The parameters and return value can only be of the string, number, or Boolean type.
**name** indicates the name of the object to be registered, which is the same as that invoked in the window. After registration, the window can use this name to access the JavaScript object at the application side.
**methodList** indicates the methods of the JavaScript object to be registered at the application side.
**controller** indicates the controller.| | javaScriptAccess | boolean | true | Whether JavaScript scripts can be executed. By default, JavaScript scripts can be executed. | diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md index 495cd2a220e5c5d775ef395803ca5b26efa55175..5d6a38dd6cb5ec8b13e97b0d660e11674859f585 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md @@ -1,7 +1,9 @@ # TapGesture +A tap gesture can recognize one or more taps. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -15,23 +17,24 @@ None TapGesture(options?: { count?: number, fingers?: number }) - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | count | number | No | 1 | Number of consecutive taps. If this parameter is set to a value less than **1**, the default value will be used.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. | - | fingers | number | No | 1 | Minimum number of fingers to trigger a tap. The value ranges from 1 to 10.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> 1. When multi-finger is configured, if the number of fingers used for tap does not reach the specified number within 300 ms after the first finger is tapped, the gesture fails to be recognized.
>
> 2. Gesture recognition fails if the number of fingers used for tap exceeds the configured number. | + | count | number | No | 1 | Number of consecutive taps. If this parameter is set to a value less than **1**, the default value will be used.
> **NOTE**
> If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. | + | fingers | number | No | 1 | Minimum number of fingers to trigger a tap. The value ranges from 1 to 10.
> **NOTE**
> 1. When multi-finger is configured, if the number of fingers used for tap does not reach the specified number within 300 ms after the first finger is tapped, the gesture fails to be recognized.
> 2. Gesture recognition fails if the number of fingers used for tap exceeds the configured number. | ## Events - | Name | Description | +| Name | Description | | -------- | -------- | -| onAction((event?: GestureEvent) => void) | Callback invoked when a tap gesture is recognized. | +| onAction((event?: [GestureEvent](ts-gesture-settings.md)) => void) | Callback invoked when a tap gesture is recognized. | ## Example -``` +```ts +// xxx.ets @Entry @Component struct TapGestureExample { diff --git a/en/application-dev/task-management/background-task-dev-guide.md b/en/application-dev/task-management/background-task-dev-guide.md index e8d85cc571320bd7994e9e80a9b72e89acff367b..e820da263fb189ab9a2717c45a31a82d830a8cbc 100644 --- a/en/application-dev/task-management/background-task-dev-guide.md +++ b/en/application-dev/task-management/background-task-dev-guide.md @@ -10,11 +10,11 @@ If a service needs to be continued when the application or service module is run **Table 1** Main APIs for transient tasks -| API| Description| -| -------- | -------- | -| requestSuspendDelay(reason: string, callback: Callback<void>): [DelaySuspendInfo](../reference/apis/js-apis-backgroundTaskManager.md#delaysuspendinfo) | Requests delayed suspension after the application switches to the background.
The default duration value of delayed suspension is 180000 when the battery level is normal and 60000 when the battery level is low.| -| getRemainingDelayTime(requestId: number): Promise<number> | Obtains the remaining duration before the application is suspended.
This API uses a promise to return the task execution result.| -| cancelSuspendDelay(requestId: number): void | Cancels the suspension delay.| +| API | Description | +| ---------------------------------------- | ---------------------------------------- | +| requestSuspendDelay(reason: string, callback: Callback<void>): [DelaySuspendInfo](../reference/apis/js-apis-backgroundTaskManager.md#delaysuspendinfo) | Requests delayed suspension after the application switches to the background.
The default duration value of delayed suspension is 180000 when the battery level is normal and 60000 when the battery level is low.| +| getRemainingDelayTime(requestId: number): Promise<number> | Obtains the remaining duration before the application is suspended.
This API uses a promise to return the result. | +| cancelSuspendDelay(requestId: number): void | Cancels the suspension delay. | ### How to Develop @@ -24,12 +24,12 @@ If a service needs to be continued when the application or service module is run ```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; - + let myReason = 'test requestSuspendDelay'; let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { console.info("Request suspension delay will time out."); }); - + var id = delayInfo.requestId; console.info("requestId is: " + id); ``` @@ -91,31 +91,33 @@ ohos.permission.KEEP_BACKGROUND_RUNNING **Table 2** Main APIs for continuous tasks -| API| Description| -| -------- | -------- | +| API | Description | +| ---------------------------------------- | ---------------------------- | | startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void> | Requests a continuous task from the system so that the application keeps running in the background.| -| stopBackgroundRunning(context: Context): Promise<void> | Cancels the continuous task.| +| stopBackgroundRunning(context: Context): Promise<void> | Cancels the continuous task. | For details about **wantAgent**, see [WantAgent](../reference/apis/js-apis-wantAgent.md). **Table 3** Background modes -| Name| ID| Description| Item| -| -------- | -------- | -------- | -------- | -| DATA_TRANSFER | 1 | Data transfer.| dataTransfer | -| AUDIO_PLAYBACK | 2 | Audio playback.| audioPlayback | -| AUDIO_RECORDING | 3 | Audio recording.| audioRecording | -| LOCATION | 4 | Positioning and navigation.| location | -| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task.| bluetoothInteraction | -| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection.| multiDeviceConnection | -| WIFI_INTERACTION | 7 | WLAN-related task (reserved).| wifiInteraction | -| VOIP | 8 | Voice and video call (reserved).| voip | -| TASK_KEEPING | 9 | Computing task (for specific devices only).| taskKeeping | +| Name | ID | Description | Configuration Item | +| ----------------------- | ---- | -------------- | --------------------- | +| DATA_TRANSFER | 1 | Data transfer. | dataTransfer | +| AUDIO_PLAYBACK | 2 | Audio playback. | audioPlayback | +| AUDIO_RECORDING | 3 | Audio recording. | audioRecording | +| LOCATION | 4 | Positioning and navigation. | location | +| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | bluetoothInteraction | +| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | multiDeviceConnection | +| WIFI_INTERACTION | 7 | WLAN-related task (reserved). | wifiInteraction | +| VOIP | 8 | Voice and video call (reserved). | voip | +| TASK_KEEPING | 9 | Computing task (for specific devices only).| taskKeeping | ### How to Develop +Development on the FA model: + 1. Create an API version 8 project. Then right-click the project directory and choose **New > Ability > Service Ability** to create a Service ability. Configure the continuous task permission and background mode type in the **config.json** file, with the ability type set to **service**. ``` @@ -137,7 +139,7 @@ For details about **wantAgent**, see [WantAgent](../reference/apis/js-apis-wantA ] } ``` - + 2. Request a continuous task. ```js @@ -173,16 +175,84 @@ For details about **wantAgent**, see [WantAgent](../reference/apis/js-apis-wantA ```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; import featureAbility from '@ohos.ability.featureAbility'; - + backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { console.info("Operation stopBackgroundRunning succeeded"); }).catch((err) => { console.error("Operation stopBackgroundRunning failed Cause: " + err); }); - + + ``` + +Development on the stage model: + +1. Create an API version 9 project. Then right-click the project directory and choose **New > Ability** to create an ability. Configure the continuous task permission and background mode type in the **module.json5** file. + + ``` + "module": { + "abilities": [ + { + "backgroundModes": [ + "dataTransfer", + "location" + ], // Background mode + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" // Continuous task permission + } + ] + } ``` +2. Request a continuous task. + + ```ts + import backgroundTaskManager from '@ohos.backgroundTaskManager'; + import wantAgent from '@ohos.wantAgent'; + + let wantAgentInfo = { + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + // Obtain the WantAgent object by using the getWantAgent API of the wantAgent module. + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + backgroundTaskManager.startBackgroundRunning(this.context, + backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { + console.info("Operation startBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation startBackgroundRunning failed Cause: " + err); + }); + }); + ``` + +3. Cancel the continuous task. + + ```ts + import backgroundTaskManager from '@ohos.backgroundTaskManager'; + + backgroundTaskManager.stopBackgroundRunning(this.context).then(() => { + console.info("Operation stopBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation stopBackgroundRunning failed Cause: " + err); + }); + + ``` + + ### Development Examples + +Development on the FA model: + For details about how to use the Service ability in the FA model, see [Service Ability Development](../ability/fa-serviceability.md). If an application does not need to interact with a continuous task in the background, you can use **startAbility()** to start the Service ability. In the **onStart** callback of the Service ability, call **startBackgroundRunning()** to declare that the Service ability needs to run in the background for a long time. After the task execution is complete, call **stopBackgroundRunning()** to release resources. @@ -284,3 +354,127 @@ export default { } }; ``` + +Development on the stage model: + +For details about the stage model, see [Stage Model Overview](../ability/stage-brief.md). +If an application needs to run a continuous task in the background, you can use **Call** to create and run an ability in the background. For details, see [Call Development](../ability/stage-call.md). + +```ts +import Ability from '@ohos.application.Ability' +import backgroundTaskManager from '@ohos.backgroundTaskManager'; +import wantAgent from '@ohos.wantAgent'; + +let mContext = null; + +function startContinuousTask() { + let wantAgentInfo = { + // List of operations to be executed after the notification is clicked. + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" + } + ], + // Type of the operation to perform after the notification is clicked. + operationType: wantAgent.OperationType.START_ABILITY, + // Custom request code. + requestCode: 0, + // Execution attribute of the operation to perform after the notification is clicked. + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + // Obtain the WantAgent object by using the getWantAgent API of the wantAgent module. + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + backgroundTaskManager.startBackgroundRunning(mContext, + backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { + console.info("Operation startBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation startBackgroundRunning failed Cause: " + err); + }); + }); +} + +function stopContinuousTask() { + backgroundTaskManager.stopBackgroundRunning(mContext).then(() => { + console.info("Operation stopBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation stopBackgroundRunning failed Cause: " + err); + }); +} + +class MySequenceable { + num: number = 0; + str: String = ""; + + constructor(num, string) { + this.num = num; + this.str = string; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } +} + +function sendMsgCallback(data) { + console.info('BgTaskAbility funcCallBack is called ' + data) + let receivedData = new Mysequenceable(0, "") + data.readSequenceable(receivedData) + console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) + if (receivedData.str === 'start_bgtask') { + startContinuousTask() + } else if (receivedData.str === 'stop_bgtask') { + stopContinuousTask(); + } + return new Mysequenceable(10, "Callee test"); +} + +export default class BgTaskAbility extends Ability { + onCreate(want, launchParam) { + console.info("[Demo] BgTaskAbility onCreate") + this.callee.on("test", sendMsgCallback); + + try { + this.callee.on(MSG_SEND_METHOD, sendMsgCallback) + } catch (error) { + console.error(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) + } + mContext = this.context; + } + + onDestroy() { + console.info("[Demo] BgTaskAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + console.info("[Demo] BgTaskAbility onWindowStageCreate") + + windowStage.loadContent("pages/second").then((data)=> { + console.info(`load content succeed with data ${JSON.stringify(data)}`) + }).catch((error)=>{ + console.error(`load content failed with error ${JSON.stringify(error)}`) + }) + } + + onWindowStageDestroy() { + console.info("[Demo] BgTaskAbility onWindowStageDestroy") + } + + onForeground() { + console.info("[Demo] BgTaskAbility onForeground") + } + + onBackground() { + console.info("[Demo] BgTaskAbility onBackground") + } +}; +``` diff --git a/en/application-dev/webgl/webgl-guidelines.md b/en/application-dev/webgl/webgl-guidelines.md index d4528ff7ce4abc2e61e885974039bc2aae788724..b169d0586096c5e5932da39625fe656b50b21733 100644 --- a/en/application-dev/webgl/webgl-guidelines.md +++ b/en/application-dev/webgl/webgl-guidelines.md @@ -65,7 +65,7 @@ To draw a 2D image without using WebGL, that is, to implement CPU rather than GP 3. Edit the **index.js** file to add the 2D drawing logic code. The following is an example of the file content: ``` - //index.js + // index.js export default { // Native API interaction code data: { title: "DEMO BY TEAMOL", @@ -136,7 +136,7 @@ To use WebGL to draw a color triangle (GPU drawing), perform the following steps 3. Edit the JavaScript code file to add the logic code for drawing a color triangle. The following is an example of the file content: ``` - //index.js + // index.js // WebGL-related predefinition var gl = { @@ -696,13 +696,6 @@ To use WebGL to draw a color triangle (GPU drawing), perform the following steps } ``` - **Figure 2** Effect of clicking the button to draw a color triangle ![en-us_image_0000001192429306](figures/en-us_image_0000001192429306.gif) - -## Samples - -The following sample is provided to help you better understand how to develop WebGL: - -- [`JsWbgGL`: WebGL (JS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/Graphics/JsWebGL) diff --git a/en/application-dev/windowmanager/display-guidelines.md b/en/application-dev/windowmanager/display-guidelines.md index 10895f9f6a6e9f59c7d7e446eaceb491503bd268..cdfaa91c9e30760be35923d2c41345feba682080 100644 --- a/en/application-dev/windowmanager/display-guidelines.md +++ b/en/application-dev/windowmanager/display-guidelines.md @@ -10,12 +10,11 @@ For details about the APIs, see [Display](../reference/apis/js-apis-display.md). ## How to Develop -Call **getDefaultDisplay(): Promise** to obtain the default display object. An example code snippet is as follows: +Call `getDefaultDisplay(): Promise` to obtain the default display object. An example code snippet is as follows: ```js import display from '@ohos.display' // Import the module. -let disp; // disp is used to save the default display object. display.getDefaultDisplay().then((disp) => { console.log('display.getDefaultDisplay success, display :' + JSON.stringify(disp)); }, (err) => { diff --git a/en/device-dev/driver/driver-peripherals-vibrator-des.md b/en/device-dev/driver/driver-peripherals-vibrator-des.md index c4603f7d46e5ac0375ed9aabc8a3a967c64fbafa..6a6164eef36695838ee3bfb9a0590c7e727d2b42 100644 --- a/en/device-dev/driver/driver-peripherals-vibrator-des.md +++ b/en/device-dev/driver/driver-peripherals-vibrator-des.md @@ -4,7 +4,7 @@ ### Introduction -Developed on the Hardware Driver Foundation (HDF), the vibrator driver model makes vibrator driver development easier. This model masks the interaction between the device driver and system, provides unified and stable driver interfaces for the hardware service layer, and offers open interfaces and interface parsing capabilities for driver developers. This document provides guidance for developing vibrator drivers and deploying vibrators in different OSs. The figure below shows the vibrator driver model. +Developed on the Hardware Driver Foundation (HDF), the vibrator driver model makes vibrator driver development easier. The motor driver model shields the interaction between the device driver and the system and provides unified and stable driver interface capabilities for the hardware service layer. It also provides open interfaces and interface parsing capabilities for developers to develop vibrator drivers and deploy vibrators in different OSs.
The figure below shows the vibrator driver model. **Figure 1** Vibrator driver model @@ -20,22 +20,22 @@ The system controls device vibration by invoking the vibrator. There are two vib - Periodic vibration - The vibrator vibrates with a preset effect. For example, if the preset effect is "haptic.clock.timer" = [600, 600, 200, 600], the vibrator waits for 600 ms, vibrates for 600 ms, waits for 200 ms, and vibrates for 600 ms. + The vibrator vibrates with a preset effect. For example, if **haptic.clock.timer** is set to **[600, 600, 200, 600]**, the vibrator waits for 600 ms, vibrates for 600 ms, waits for 200 ms, and vibrates for 600 ms. ### Working Principles -Based on the loading and running process (shown below) of the vibrator driver model, the relationships between key modules in the model and associated modules are clearly defined. +The figure below shows how a vibrator driver is loaded. -**Figure 2** How vibrator driver works +**Figure 2** How a vibrator driver works ![How vibrator driver works](figures/vibrator_working.png) The following uses the vibrator driver on the Hi3516D V300 development board of the standard system as an example to describe the driver loading and running process. -1. The vibrator host reads the vibrator management configuration from the Vibrator Host node of the device_info HCS (vibrator device information HCS). -2. The vibrator host parses the vibrator management configuration and associates it with the corresponding vibrator abstract driver. -3. The vibrator host reads the vibrator data configuration from the linear_vibrator_config HCS (vibrator private configuration HCS). -4. The vibrator host parses the vibrator data configuration and associates it with the corresponding vibrator haptic driver. +1. The vibrator driver reads the vibrator management configuration information from **Vibrator Host** in the **device_info.hcs** file. +2. The HCS parser parses the vibrator management configuration and associates it with the vibrator abstract driver. +3. The vibrator chipset driver reads the vibrator data configuration from the **linear_vibrator_config.hcs** file. +4. The HCS parser parses the vibrator data configuration and associates it with the vibrator haptic driver. 5. The vibrator proxy delivers an instruction to the vibrator stub. 6. The vibrator stub calls the vibrator controller. 7. The vibrator host initializes the vibrator abstract driver interfaces. @@ -51,32 +51,34 @@ You can set different vibration effects as needed, for example, customizing vibr ### Available APIs -The vibrator driver model supports static HDF Configuration Source (HCS) configurations and dynamic parameter configurations. The vibrator hardware service calls the **StartOnce** interface to trigger continuous vibration and calls the **Start** interface to trigger vibration with a specified effect. The table below lists the APIs provided by the vibrator driver model for the hardware service layer. +The vibrator driver model supports static HDF Configuration Source (HCS) configuration and dynamic parameter configuration. The vibrator hardware service calls **StartOnce()** to trigger continuous vibration and calls **Start()** to trigger vibration with a specified effect. The table below lists the APIs provided by the vibrator driver model for the hardware service layer. -**Table 1** External APIs of the vibrator driver model +**Table 1** APIs of the vibrator driver model -| API | Description | -| -------------------------------------- | -------------------------------------------------------- | -| int32_t StartOnce(uint32_t duration) | Triggers vibration with a given **duration**. | -| int32_t Start(const char *effectType) | Triggers vibration with a given effect, which is specified by **effectType**.| -| int32_t Stop(enum VibratorMode mode) | Stops vibration. | +| API | Description | +| -------------------------------------- | ------------------------------------------------ | +| int32_t StartOnce(uint32_t duration) | Triggers vibration with a given **duration**. | +| int32_t Start(const char *effectType) | Triggers vibration with a given effect, which is specified by **effectType**. | +| int32_t Stop(enum VibratorMode mode) | Stops vibration. | +| int32_t EnableVibratorModulation(uint32_t duration, int32_t intensity, int32_t frequency) | Triggers vibration with the given **duration**, **frequency**, and **intensity**.| +| int32_t GetVibratorInfo(struct VibratorInfo **vibratorInfo); | Obtains vibrator information, including whether the intensity and frequency can be set and the intensity and frequency range.| ### How to Develop -The vibrator driver model provides stable interfaces for the upper-layer hardware service to trigger a one-shot vibration with a given duration, trigger vibration with a given effect, and stop vibration. The model implements functionalities such as cross-OS migration and differentiated configurations. To develop a vibrator, perform the following steps: +The vibrator driver model provides APIs for the upper-layer hardware service to trigger a one-shot vibration with a given duration, trigger vibration with a given effect, and stop vibration. This model implements functionalities such as cross-OS porting and device-specific configurations. The development procedure is as follows: -1. Develop the vibrator abstract driver based on the driver entry. Specifically, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions, configure resources, and parse HCS configurations. +1. Develop the vibrator abstract driver based on the driver entry. Specifically, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions, configure resources, and parse the HCS. - - Call **HDF_INIT** to register the driver entry with the HDF. During driver loading, the HDF calls the **Bind** function and then the **Init** function to load the driver. If the **Init** function fails to be called, the HDF calls **Release** to release the driver resources and exit the vibrator driver model. The vibrator driver model uses the HCS as the configuration source code. For details about HCS fields, see [Driver Configuration Management](driver-hdf-manage.md). The driver entry function is defined as follows: + - Call **HDF_INIT** to register the driver entry with the HDF. During driver loading, the HDF calls the **Bind** function and then the **Init** function to load the driver. If the **Init** function fails to be called, the HDF calls **Release** to release the driver resources and exit the vibrator driver model. The vibrator driver model uses the HCS as the configuration source code. For details about HCS configuration fields, see [Configuration Management](driver-hdf-manage.md). The driver entry function is defined as follows: ```c /* Register the entry structure object of the vibrator abstract driver. */ struct HdfDriverEntry g_vibratorDriverEntry = { .moduleVersion = 1, // Version of the vibrator module. - .moduleName = "HDF_VIBRATOR", // Vibrator module name. The value must be the same as the value of moduleName in the device_info.hcs file. + .moduleName = "HDF_VIBRATOR", // Vibrator module name, which must be the same as moduleName in the device_info.hcs file. .Bind = BindVibratorDriver, // Function for binding a vibrator. .Init = InitVibratorDriver, // Function for initializing a vibrator. - .Release = ReleaseVibratorDriver, // Function for releasing vibrator resources. + .Release = ReleaseVibratorDriver, // Function for releasing vibrator resources. }; HDF_INIT(g_vibratorDriverEntry); @@ -85,18 +87,18 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar - Develop the vibrator abstract driver. Specifically, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions. ```c - /* External service published by the vibrator driver. */ + /* Message exchange capability of the vibrator driver. */ static int32_t DispatchVibrator(struct HdfDeviceIoClient *client, int32_t cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { int32_t loop; - + for (loop = 0; loop < sizeof(g_vibratorCmdHandle) / sizeof(g_vibratorCmdHandle[0]); ++loop) { if ((cmd == g_vibratorCmdHandle[loop].cmd) && (g_vibratorCmdHandle[loop].func != NULL)) { return g_vibratorCmdHandle[loop].func(data, reply); } } - + return HDF_SUCCESS; } @@ -105,34 +107,34 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar { struct VibratorDriverData *drvData = NULL; CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(device, HDF_FAILURE); - + drvData = (struct VibratorDriverData *)OsalMemCalloc(sizeof(*drvData)); CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_ERR_MALLOC_FAIL); - + drvData->ioService.Dispatch = DispatchVibrator; drvData->device = device; device->service = &drvData->ioService; g_vibratorDrvData = drvData; - + return HDF_SUCCESS; } - + /* Entry function for vibrator driver initialization. */ int32_t InitVibratorDriver(struct HdfDeviceObject *device) { struct VibratorDriverData *drvData = NULL; - + drvData->mode = VIBRATOR_MODE_BUTT; drvData->state = VIBRATOR_STATE_IDLE; ...... if (CreateVibratorHaptic(device) != HDF_SUCCESS) { - HDF_LOGE("%s: init workQueue fail!", __func__); + HDF_LOGE("%s: init workQueue failed!", __func__); return HDF_FAILURE; } - + return HDF_SUCCESS; } - + /* Release the resources allocated during vibrator driver initialization. */ void ReleaseVibratorDriver(struct HdfDeviceObject *device) { @@ -155,21 +157,21 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar device0 :: deviceNode { policy = 2; // Policy for publishing the driver service. priority = 100; // Driver startup priority (0–200). A larger value indicates a lower priority. The default value 100 is recommended. The sequence for loading devices with the same priority is random. - preload = 0; // Field for specifying whether to load the driver. The value 0 means to load the driver, and 2 means the opposite. + preload = 0; // Whether to load the driver on demand. The value 0 means to load the driver on demand, and 2 means the opposite. permission = 0664; // Permission for the driver to create a device node. - moduleName = "HDF_VIBRATOR"; // Driver name. The value must be the same as that of moduleName in the driver entry structure. + moduleName = "HDF_VIBRATOR"; // Driver name, which must be the same as moduleName in the driver entry structure. serviceName = "hdf_misc_vibrator"; // Name of the service provided by the driver. The name must be unique. deviceMatchAttr = "hdf_vibrator_driver"; // Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver. } } ``` -2. Create a vibrator haptic model and parse the haptic HCS configuration. +2. Create a vibrator haptic model and parse the haptic HCS. - Create a vibrator haptic model. - ```hcs - /* Create a vibrator haptic model, allocate resources, and parse the haptic HCS configuration. */ + ```c + /* Create a vibrator haptic model, allocate resources, and parse the haptic HCS. */ int32_t CreateVibratorHaptic(struct HdfDeviceObject *device) { struct VibratorHapticData *hapticData = NULL; @@ -181,15 +183,15 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar hapticData->supportHaptic = false; if (OsalMutexInit(&hapticData->mutex) != HDF_SUCCESS) { - HDF_LOGE("%s: fail to init mutex", __func__); + HDF_LOGE("%s: failed to init mutex", __func__); goto EXIT; } DListHeadInit(&hapticData->effectSeqHead); - /* Parse the haptic HCS configuration. */ + /* Parse the haptic HCS. */ if (ParserVibratorHapticConfig(device->property) != HDF_SUCCESS) { - HDF_LOGE("%s: parser haptic config fail!", __func__); + HDF_LOGE("%s: parser haptic config failed!", __func__); goto EXIT; } @@ -200,9 +202,9 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar } ``` - - The vibrator effect model uses the HCS. For details about HCS fields, see [Driver Configuration Management](driver-hdf-manage.md). + - The vibrator haptic model uses the HCS. For details about the HCS fields, see [Configuration Management](driver-hdf-manage.md). - ``` + ```hcs /* Vibrator data configuration template (vibrator_config.hcs). */ root { vibratorConfig { @@ -250,7 +252,7 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar /* Create a timer based on the vibration effect. */ ret = StartHaptic(&config); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: start haptic fail!", __func__); + HDF_LOGE("%s: start haptic failed!", __func__); return ret; } @@ -272,7 +274,7 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar ret = StartHaptic(&config); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: start haptic fail!", __func__); + HDF_LOGE("%s: start haptic failed!", __func__); return ret; } @@ -290,7 +292,7 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar /* Stop vibration and destroy the timer. */ ret = StopHaptic(); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: stop haptic fail!", __func__); + HDF_LOGE("%s: stop haptic failed!", __func__); return ret; } @@ -300,6 +302,58 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar return HDF_SUCCESS; } + + /* Trigger vibration with the given duration, frequency, and intensity. */ + static int32_t EnableModulationParameter(struct HdfSBuf *data, struct HdfSBuf *reply) + { + (void)reply; + struct VibratorEffectCfg config; + struct VibratorDriverData *drvData; + uint32_t duration; + int32_t intensity; + int32_t frequency; + int32_t ret; + ..... + (void)OsalMutexLock(&drvData->mutex); + drvData->mode = VIBRATOR_MODE_ONCE; + (void)OsalMutexUnlock(&drvData->mutex); + /* Set the vibration intensity and frequency. */ + ret = drvData->ops.SetParameter(intensity, frequency); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set parameter failed", __func__); + return HDF_FAILURE; + } + + config.cfgMode = VIBRATOR_MODE_ONCE; + config.duration = duration; + config.effect = NULL; + + ret = StartHaptic(&config); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: start haptic failed", __func__); + return HDF_FAILURE; + } + + return HDF_SUCCESS; + } + + /* Obtain vibrator information, including whether the intensity and frequency can be set and the intensity and frequency range. */ + static int32_t GetVibratorInfo(struct HdfSBuf *data, struct HdfSBuf *reply) + { + (void)data; + struct VibratorDriverData *drvData; + + drvData = GetVibratorDrvData(); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_ERR_INVALID_PARAM); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(reply, HDF_ERR_INVALID_PARAM); + + if (!HdfSbufWriteBuffer(reply, &drvData->vibratorInfo, sizeof(drvData->vibratorInfo))) { + HDF_LOGE("%s: write sbuf failed", __func__); + return HDF_FAILURE; + } + + return HDF_SUCCESS; + } ``` 4. Implement the interfaces for the vibrator chipset driver. @@ -319,50 +373,180 @@ The vibrator driver model provides stable interfaces for the upper-layer hardwar drvData->ops.Start = ops->Start; drvData->ops.StartEffect = ops->StartEffect; drvData->ops.Stop = ops->Stop; + drvData->ops.SetParameter = ops->SetParameter; + (void)OsalMutexUnlock(&drvData->mutex); + + return HDF_SUCCESS; + } + + /* Register vibrator information. */ + int32_t RegisterVibratorInfo(struct VibratorInfo *vibratorInfo) + { + struct VibratorDriverData *drvData = GetVibratorDrvData(); + + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(vibratorInfo, HDF_FAILURE); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); + + (void)OsalMutexLock(&drvData->mutex); + if (memcpy_s(&drvData->vibratorInfo, sizeof(drvData->vibratorInfo), vibratorInfo, sizeof(*vibratorInfo)) != EOK) { + HDF_LOGE("%s: Memcpy vibrator config failed", __func__); + return HDF_FAILURE; + } (void)OsalMutexUnlock(&drvData->mutex); return HDF_SUCCESS; } ``` + + - The vibrator driver model provides vibrator chipset driver interfaces. Implement these interfaces as follows: ```c - /* Start a linear vibrator to vibrate with a given duration. */ - static int32_t StartLinearVibrator() + /* Stop vibration based on the specified vibration mode. */ + static int32_t StopModulationParameter() { - int32_t ret; - struct VibratorLinearDriverData *drvData = GetLinearVibratorData(); - CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); - ...... - ret = GpioWrite(drvData->gpioNum, GPIO_VAL_LOW); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: pull gpio%d to %d level failed", __func__, drvData->gpioNum, GPIO_VAL_LOW); - return ret; + uint8_t value[DRV2605L_VALUE_BUTT]; + struct Drv2605lDriverData *drvData = NULL; + drvData = GetDrv2605lDrvData(); + + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData->drv2605lCfgData, HDF_FAILURE); + + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_MODE; + value[DRV2605L_VALUE_INDEX] = (uint8_t)DRV2605_MODE_STANDBY; + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + return HDF_FAILURE; + } + + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_RTPIN; + value[DRV2605L_VALUE_INDEX] = (uint8_t)&drvData->drv2605lCfgData->vibratorAttr.defaultIntensity; + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + } + + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_LRARESON; + value[DRV2605L_VALUE_INDEX] = (uint8_t)&drvData->drv2605lCfgData->vibratorAttr.defaultFrequency; + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); } - return HDF_SUCCESS; - } - /* Start a linear vibration to vibrate with a given effect. */ - static int32_t StartEffectLinearVibrator(uint32_t effectType) - { - (void)effectType; - HDF_LOGE("%s: vibrator set build-in effect no support!", __func__); return HDF_SUCCESS; } - /* Stop a linear vibration based on the specified vibration mode. */ - static int32_t StopLinearVibrator() + /* Set the vibration intensity and frequency. */ + static void SetModulationParameter(int32_t intensity, int32_t frequency) { - int32_t ret; - struct VibratorLinearDriverData *drvData = GetLinearVibratorData(); + uint8_t value[DRV2605L_VALUE_BUTT]; + struct Drv2605lDriverData *drvData = NULL; + drvData = GetDrv2605lDrvData(); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); - ...... - ret = GpioWrite(drvData->gpioNum, GPIO_VAL_HIGH); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: pull gpio%d to %d level failed", __func__, drvData->gpioNum, GPIO_VAL_HIGH); - return ret; + + if (intensity != 0) { + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_RTPIN; + value[DRV2605L_VALUE_INDEX] = (uint8_t)INTENSITY_MAPPING_VALUE(intensity); + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + return; + } + } else { + HDF_LOGD("%s: the setting of intensity 0 is not supported and \ + will be set as the system default intensity", __func__); + } + + if (frequency != 0) { + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_LRARESON; + value[DRV2605L_VALUE_INDEX] = (uint8_t)FREQUENCY_MAPPING_VALUE(frequency); + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + return; + } + } else { + HDF_LOGD("%s: the setting of frequency 0 is not supported and \ + will be set as the system default frequency", __func__); } - return HDF_SUCCESS; } ``` + +### Verification + +After the driver is developed, develop test cases in the sensor unit test to verify the basic functions of the driver. Use the developer self-test platform as the test environment. + +``` +/* Initialize the vibrator interface instance before executing test cases. */ +void HdfVibratorTest::SetUpTestCase() +{ + g_vibratorDev = NewVibratorInterfaceInstance(); +} +/* Release test case resources. */ +void HdfVibratorTest::TearDownTestCase() +{ + if(g_vibratorDev != nullptr){ + FreeVibratorInterfaceInstance(); + g_vibratorDev = nullptr; + } +} + +/* Verify one-short vibration. */ +HWTEST_F(HdfVibratorTest, PerformOneShotVibratorDuration_001, TestSize.Level1) +{ + ASSERT_NE(nullptr, g_vibratorDev); + + int32_t startRet = g_vibratorDev->StartOnce(g_duration); + EXPECT_EQ(startRet, HDF_SUCCESS); + + OsalMSleep(g_sleepTime1); + + int32_t endRet = g_vibratorDev->Stop(VIBRATOR_MODE_ONCE); + EXPECT_EQ(endRet, HDF_SUCCESS); +} +/* Verify vibration with the preset effect. */ +HWTEST_F(HdfVibratorTest, ExecuteVibratorEffect_002, TestSize.Level1) +{ + ASSERT_NE(nullptr, g_vibratorDev); + + int32_t startRet = g_vibratorDev->Start(g_builtIn); + EXPECT_EQ(startRet, HDF_SUCCESS); + + OsalMSleep(g_sleepTime1); + + int32_t endRet = g_vibratorDev->Stop(VIBRATOR_MODE_PRESET); + EXPECT_EQ(endRet, HDF_SUCCESS); +} +/* Obtain vibrator information, including whether the intensity and frequency can be set and the intensity and frequency range. */ +HWTEST_F(HdfVibratorTest, GetVibratorInfo_001, TestSize.Level1) +{ + ASSERT_NE(nullptr, g_vibratorDev); + + int32_t startRet = g_vibratorDev->GetVibratorInfo(&g_vibratorInfo); + EXPECT_EQ(startRet, HDF_SUCCESS); + EXPECT_NE(g_vibratorInfo, nullptr); + + printf("intensity = %d, intensityMaxValue = %d, intensityMinValue = %d\n\t", + g_vibratorInfo->isSupportIntensity, g_vibratorInfo->intensityMaxValue, g_vibratorInfo->intensityMinValue); + printf("frequency = %d, frequencyMaxValue = %d, frequencyMinValue = %d\n\t", + g_vibratorInfo->isSupportFrequency, g_vibratorInfo->frequencyMaxValue, g_vibratorInfo->frequencyMinValue); +} +/* Trigger vibration with the given duration, frequency, and intensity. */ +HWTEST_F(HdfVibratorTest, EnableVibratorModulation_001, TestSize.Level1) +{ + int32_t startRet; + ASSERT_NE(nullptr, g_vibratorDev); + EXPECT_GT(g_duration, 0); + + if ((g_vibratorInfo->isSupportIntensity == 1) || (g_vibratorInfo->isSupportFrequency == 1)) { + EXPECT_GE(g_intensity1, g_vibratorInfo->intensityMinValue); + EXPECT_LE(g_intensity1, g_vibratorInfo->intensityMaxValue); + EXPECT_GE(g_frequency1, g_vibratorInfo->frequencyMinValue); + EXPECT_LE(g_frequency1, g_vibratorInfo->frequencyMaxValue); + + startRet = g_vibratorDev->EnableVibratorModulation(g_duration, g_intensity1, g_frequency1); + EXPECT_EQ(startRet, HDF_SUCCESS); + OsalMSleep(g_sleepTime1); + startRet = g_vibratorDev->Stop(VIBRATOR_MODE_ONCE); + EXPECT_EQ(startRet, HDF_SUCCESS); + } +} +``` diff --git a/en/device-dev/porting/porting-chip-board-hal.md b/en/device-dev/porting/porting-chip-board-hal.md index f3bf12e1fee0c2deee2be149464ea3e8586a08f6..d06c425d8c3d6314b8b64111bf15bd2b795b9ad9 100644 --- a/en/device-dev/porting/porting-chip-board-hal.md +++ b/en/device-dev/porting/porting-chip-board-hal.md @@ -20,7 +20,7 @@ The IoT peripheral subsystem provides dedicated peripheral operation interfaces **Description for HAL APIs of the IoT peripheral subsystem** -The SoC needs to implement related APIs. For details about the dependency of OpenHarmony on the chip peripheral APIs, see [HAL header files of IoT peripherals](https://gitee.com/openharmony/iothardware_peripheral/tree/master/interfaces/kits). +The SoC needs to implement related APIs. For details about the dependency of OpenHarmony on the chip peripheral APIs, see [HAL header files of IoT peripherals](https://gitee.com/openharmony/iothardware_peripheral/tree/master/interfaces/inner_api). ## WLAN diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index e109fa185f4feacedf1033af5cf83c0ae6c8eec6..389cff3cc3f464451721d2b34e952f0db1f93f0e 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -77,7 +77,6 @@ - [init Module](subsys-boot-init.md) - [appspawn Module](subsys-boot-appspawn.md) - [bootstrap Module](subsys-boot-bootstrap.md) - - [syspara Module](subsys-boot-syspara.md) - [FAQs](subsys-boot-faqs.md) - [Reference](subsys-boot-ref.md) - [Test Case Development](subsys-testguide-test.md) diff --git a/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md b/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md index 298489f6d6faf68f35c7e2b39616d0ae6c7e94b0..5bb827d8262903199e27122c11b9e5f65d5c5cb1 100644 --- a/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md +++ b/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md @@ -20,7 +20,7 @@ }; ``` - The preceding code implements the **IPlugin** API provided by the server. [Table 1](#table567211582104) shows the mapping between the client APIs and the plug-in APIs. + The preceding code implements the **IPlugin** API provided by the server. The following table shows the mapping between the client APIs and the plug-in APIs. **Table 1** Mapping between the client APIs and the plug-in APIs diff --git a/en/device-dev/subsystems/subsys-aiframework-tech-codemanage.md b/en/device-dev/subsystems/subsys-aiframework-tech-codemanage.md index 16602e69ef26c7ddc5e383c8658cb4bce5938f90..e10289c626c0a22be29a97a109d5254c54e4cc75 100644 --- a/en/device-dev/subsystems/subsys-aiframework-tech-codemanage.md +++ b/en/device-dev/subsystems/subsys-aiframework-tech-codemanage.md @@ -15,15 +15,19 @@ In the overall planning of the AI engine framework, northbound SDKs are a part o - SDK code directory: //foundation/ai/engine/services/client/algorithm\_sdk - e.g. //foundation/ai/engine/services/client/algorithm\_sdk/cv + Examples: + + //foundation/ai/engine/services/client/algorithm\_sdk/cv - e.g. //foundation/ai/engine/services/client/algorithm\_sdk/nlu + //foundation/ai/engine/services/client/algorithm\_sdk/nlu - Plug-in code directory: //foundation/ai/engine/services/server/plugin - e.g. //foundation/ai/engine/services/server/plugin/cv + Examples: - e.g. //foundation/ai/engine/services/server/plugin/nlu + //foundation/ai/engine/services/server/plugin/cv + + //foundation/ai/engine/services/server/plugin/nlu ## Rule: Store all external APIs provided by plug-ins in the **interfaces/kits** directory of the AI subsystem. diff --git a/en/device-dev/subsystems/subsys-boot-init-jobs.md b/en/device-dev/subsystems/subsys-boot-init-jobs.md index 8bbbc1a8c030cf07366fc49c010862b99555f207..31e52aa9bb74cb28168744a9427a88df47279460 100644 --- a/en/device-dev/subsystems/subsys-boot-init-jobs.md +++ b/en/device-dev/subsystems/subsys-boot-init-jobs.md @@ -160,6 +160,20 @@ A job is a command set, where you can manage the commands to be executed. A maxi Small and standard systems + + + write + + + write filename value
Example:
write /data/testfile 0 + + + Writes a file. filename and value respectively indicate the absolute file path and the string to write. + + + Standard system + + stop @@ -300,6 +314,20 @@ A job is a command set, where you can manage the commands to be executed. A maxi Small and standard systems + + + syncexec + + + syncexec Path of the executable file Parameters passed by the executable file
Example:
syncexec /system/bin/udevadm trigger + + + Runs an executable file synchronously. The **wait** function will be called to wait for the child process to end. The command must not contain more than 10 parameters. + + + Standard system + + mknode diff --git a/en/device-dev/subsystems/subsys-boot-init-plugin.md b/en/device-dev/subsystems/subsys-boot-init-plugin.md index aeb47c97c0ec13179059f1face42d6dba59f730b..89acad326572294105c9946ecae6bc6c7b415cff 100644 --- a/en/device-dev/subsystems/subsys-boot-init-plugin.md +++ b/en/device-dev/subsystems/subsys-boot-init-plugin.md @@ -17,7 +17,7 @@ bootchart is available only for the standard system, and begetctl is available f ## How to Develop ### Parameters - **Table 1** Description of begetctl commands + **Table 1** Description of begetctl commands | Command| Format and Example| Description| | :---------- | :---------- |:--------| | init group test [stage] | init group test | For details about **stage**, see **ServiceStatus**.| diff --git a/en/device-dev/subsystems/subsys-boot-init-service.md b/en/device-dev/subsystems/subsys-boot-init-service.md index 38f88f250c710101c84320f59b378b3cc827d568..6c306c1543b4dd7ff81b0e090eb3306483a73704 100644 --- a/en/device-dev/subsystems/subsys-boot-init-service.md +++ b/en/device-dev/subsystems/subsys-boot-init-service.md @@ -114,7 +114,7 @@ The service management module is available only for the mini system and standard By parsing the *.cfg file, you can obtain **service** fields, and then set and start the service. ### Parameters - **Table 1** Description of service fields + **Table 1** Description of service fields @@ -208,11 +208,11 @@ By parsing the *.cfg file, you can obtain **service** fields, a importance
- Current service priority. + Service priority (for the standard system) or service importance (for the mini system). Standard system: The service priority ranges from -20 to 19. A value beyond the range is invalid.
- Small system: The value 0 indicates an unimportant process and a value greater than 0 indicates an important process. + Small system: The value 0 indicates that a system restart is not required, and a value greater than 0 indicates the opposite.
Small and standard systems @@ -362,7 +362,7 @@ By parsing the *.cfg file, you can obtain **service** fields, a | option | Socket option. This field is passed when **setsockopt** is called. Currently, the available options include SOCKET_OPTION_PASSCRED, SOCKET_OPTION_RCVBUFFORCE, SOCK_CLOEXEC, and SOCK_NONBLOCK.| ### Available APIs - **Table 3** FD proxy APIs + **Table 3** FD proxy APIs | API | Function| Description | | ---------- | ---------- |--------| | int *ServiceGetFd(const char *serviceName, size_t *outfdCount) | Obtains the proxy FD from the init process.| Return value: Returns the pointer to the fd array if the operation is successful; returns **NULL** otherwise. (Note: Manual release is required.)
Arguments:
**serviceName**: service name.
**outfdCount**: length of the returned fd array.| diff --git a/en/device-dev/subsystems/subsys-boot.md b/en/device-dev/subsystems/subsys-boot.md index a5b61f59149cd57c0df24fa4d656e92271808808..7888048a08574ef3a06b3cdca551a4d598dc201d 100644 --- a/en/device-dev/subsystems/subsys-boot.md +++ b/en/device-dev/subsystems/subsys-boot.md @@ -4,7 +4,6 @@ - **[init Module](subsys-boot-init.md)** - **[appspawn Module](subsys-boot-appspawn.md)** - **[bootstrap Module](subsys-boot-bootstrap.md)** -- **[syspara Module](subsys-boot-syspara.md)** - **[FAQs](subsys-boot-faqs.md)** - **[Reference](subsys-boot-ref.md)** diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md index 23edcbae978020463839ea97b876ef4819fe09d1..2bb67bf541229f541a5461db0c04beecbeabd18e 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md @@ -23,13 +23,14 @@ Use HiSysEvent logging to flush logged event data to disks. HiSysEvent logging is implemented using the API provided by the **HiSysEvent** class. For details, see the API Reference. > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> > In OpenHarmony-3.2-Beta3, HiSysEvent logging is open for restricted use to avoid event storms. The **HiSysEvent::Write** API in Table 1 is replaced by the **HiSysEventWrite** API in Table 2. The **HiSysEvent::Write** API has been deprecated. Use the **HiSysEventWrite** API instead for HiSysEvent logging. **Table 1** C++ event logging API (deprecated) | API | Description | | ------------------------------------------------------------ | ---------------------- | -| template<typename... Types> 
static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | Flushes logged event data to disks.| +| template<typename... Types>
static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | Flushes logged event data to disks.| **Table 2** C++ event logging API (in use) | API | Description | @@ -49,7 +50,7 @@ HiSysEvent logging is implemented using the API provided by the **HiSysEvent** c The following table describes the kernel event logging APIs. -**Table 4** Description of kernel event logging APIs +**Table 4** Kernel event logging APIs | API | Description | | ------------------------------------------------------------ | ------------------------------------ | diff --git a/en/readme/figures/location_En-1.png b/en/readme/figures/location_En-1.png new file mode 100644 index 0000000000000000000000000000000000000000..1ae4bcd7173f2e95004c96fa13d420c09f017f76 Binary files /dev/null and b/en/readme/figures/location_En-1.png differ diff --git a/en/readme/globalization.md b/en/readme/globalization.md index 8ba91ef0aa3a8cd788fe54792a4a7148af5c3cdf..8e1841cc3fb0c65a43b29fa7c8ac07c4e931a2b8 100755 --- a/en/readme/globalization.md +++ b/en/readme/globalization.md @@ -15,7 +15,7 @@ If OpenHarmony devices and applications need to be used globally, they must meet ## Architecture -**Figure 1** Architecture of the globalization subsystem +**Figure 1** Architecture of the globalization subsystem ![](figures/architecture-of-the-globalization-subsystem.png "architecture-of-the-globalization-subsystem") diff --git a/en/readme/location.md b/en/readme/location.md index 09cacb485331c6b0e5b46af2c070acae735690c6..2e7ba90b4b18d9f86e708ddb16cf0aa539b7fc07 100644 --- a/en/readme/location.md +++ b/en/readme/location.md @@ -8,7 +8,7 @@ With the location awareness capability offered by OpenHarmony, mobile devices wi Your application can call location-specific APIs to obtain the location information of a mobile device for offering location-based services such as drive navigation and motion track recording. -Basic Concepts +**Basic Concepts** Location awareness helps determine where a mobile device locates. The system identifies the location of a mobile device with its coordinates, and uses location technologies such as Global Navigation Satellite System (GNSS) and network positioning (for example, base station positioning or WLAN/Bluetooth positioning) to provide diverse location-based services. These advanced location technologies make it possible to obtain the accurate location of the mobile device, regardless of whether it is indoors or outdoors. @@ -28,6 +28,10 @@ Location awareness helps determine where a mobile device locates. The system ide WLAN or Bluetooth positioning estimates the current location of a mobile device based on the locations of WLANs and Bluetooth devices that can be discovered by the device. The location accuracy of this technology depends on the distribution of fixed WLAN access points (APs) and Bluetooth devices around the device. A high density of WLAN APs and Bluetooth devices can produce a more accurate location result than base station positioning. This technology also requires access to the network. +**Figure 1** ** Location subsystem architecture** + +![](figures/location_En-1.png) +![](figures/location_En-1.png) ## Directory Structure @@ -102,7 +106,8 @@ The following table describes APIs available for obtaining device location infor **Obtaining the device location information:** 1. Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user. - The system provides the following location permissions: + + The system provides the following location permissions: - ohos.permission.LOCATION - ohos.permission.LOCATION_IN_BACKGROUND @@ -131,7 +136,7 @@ The following table describes APIs available for obtaining device location infor } ``` - For details about the configuration fields, see the description of the **module.json** file. + For details about the configuration fields, see [Application Package Structure Configuration File](../application-dev/quick-start/stage-structure.md). 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. @@ -204,7 +209,8 @@ The following table describes APIs available for obtaining device location infor ``` 4. Instantiate the **Callback** object for the system to report location results. - Your application needs to implement the callback defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. + + Your application needs to implement the callback defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. ``` var locationChange = (location) => { @@ -239,6 +245,7 @@ The following table describes APIs available for obtaining device location infor **Converting the coordinates and geocoding information:** > **NOTE** +> > The **GeoConvert** instance needs to access backend services to obtain information. Therefore, before performing the following steps, ensure that your device is connected to the network. 1. Import the **geolocation** module by which you can implement all APIs related to the geocoding and reverse geocoding conversion capabilities. @@ -248,6 +255,7 @@ The following table describes APIs available for obtaining device location infor ``` 2. Obtain the conversion result. + - Call **getAddressesFromLocation** to convert coordinates into geographical location information. ``` @@ -258,6 +266,7 @@ The following table describes APIs available for obtaining device location infor ``` Your application can obtain the **GeoAddress** list that matches the specified coordinates and then read location information from it. For details, see the *API Reference*. + - Call **getAddressesFromLocationName** to convert geographic description into coordinates. ``` diff --git a/en/release-notes/OpenHarmony-1-0.md b/en/release-notes/OpenHarmony-1-0.md index 158ce20ed259cc583f16567db144b48d432d0a6f..59bad423d7a587ef7c23f49b58bec58bb93faea7 100644 --- a/en/release-notes/OpenHarmony-1-0.md +++ b/en/release-notes/OpenHarmony-1-0.md @@ -1,79 +1,28 @@ -# OpenHarmony 1.0 \(2020-09-10\) +# OpenHarmony 1.0 \(2020-09-10) -## Overview +## Overview This is the initial release for this product. -## Source Code Acquisition +## Source Code Acquisition -### Acquiring Source Code from Mirrors +### Acquiring Source Code from Mirrors **Table 1** Mirrors for acquiring source code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Source Code

-

Version Information

-

Mirror

-

SHA-256 Checksum

-

Full code base

-

1.0

-

Download

-

Download

-

Hi3861 solution (binary)

-

1.0

-

Download

-

Download

-

Hi3518 solution (binary)

-

1.0

-

Download

-

Download

-

Hi3516 solution (binary)

-

1.0

-

Download

-

Download

-

RELEASE-NOTES

-

1.0

-

Download

-

N/A

-
+| Source Code | Version Information | Mirror | SHA-256 Checksum | +| ------------------------ | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Full code base | 1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz.sha256) | +| Hi3861 solution (binary) | 1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/wifiiot-1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/wifiiot-1.0.tar.gz.sha256) | +| Hi3518 solution (binary) | 1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/ipcamera_hi3518ev300-1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/ipcamera_hi3518ev300-1.0.tar.gz.sha256) | +| Hi3516 solution (binary) | 1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/ipcamera_hi3516dv300-1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/ipcamera_hi3516dv300-1.0.tar.gz.sha256) | +| Release Notes | 1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.0/RELEASE-NOTES.txt) | - | -### Acquiring Source Code Using the repo Tool +### Acquiring Source Code Using the repo Tool Method 1 \(recommended\): Use the **repo** tool to download the source code. -``` +```shell repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify repo sync -c ``` @@ -82,7 +31,7 @@ Method 2: Run the **git clone** command to clone a single code repository. Go to the [code repository homepage](https://gitee.com/openharmony), select the code repository to be cloned, and run the following command: -``` +```shell git clone https://gitee.com/openharmony/manifest.git -b master ``` diff --git a/en/release-notes/OpenHarmony-1-1-0-LTS.md b/en/release-notes/OpenHarmony-1-1-0-LTS.md index 998465a35dd195ad265e2f5ddbf104925d84d95c..3b549c608a76f7bb3103eff29673e5230df66464 100644 --- a/en/release-notes/OpenHarmony-1-1-0-LTS.md +++ b/en/release-notes/OpenHarmony-1-1-0-LTS.md @@ -1,6 +1,6 @@ -# OpenHarmony 1.1.0 LTS \(2021-04-01\) +# OpenHarmony 1.1.0 LTS \(2021-04-01\) -## Overview +## Overview This is the first long-term support \(LTS\) version of OpenHarmony. It supports more functions and fixes some bugs in OpenHarmony 1.0. @@ -11,234 +11,53 @@ This is the first long-term support \(LTS\) version of OpenHarmony. It supports - The graphics subsystem has been optimized for an enhanced UI and improved performance and memory for the JS application framework. - The directory structure and module repositories have been significantly improved. -## Source Code Acquisition +## Source Code Acquisition -### Acquiring Source Code from Mirrors +### Acquiring Source Code from Mirrors **Table 1** Mirrors for acquiring source code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Source Code

-

Version Information

-

Mirror

-

SHA-256 Checksum

-

Full code base

-

1.1.0

-

Download

-

Download

-

Hi3861 solution (binary)

-

1.1.0

-

Download

-

Download

-

Hi3518 solution (binary)

-

1.1.0

-

Download

-

Download

-

Hi3516 solution (binary)

-

1.1.0

-

Download

-

Download

-

Release Notes

-

1.1.0

-

Download

-

N/A

-
+| Source Code | Version Information | Mirror | SHA-256 Checksum | +| ------------------------ | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Full code base | 1.1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/code-1.1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/code-1.1.0.tar.gz.sha256) | +| Hi3861 solution (binary) | 1.1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/wifiiot-1.1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/wifiiot-1.1.0.tar.gz.sha256) | +| Hi3518 solution (binary) | 1.1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/ipcamera_hi3518ev300-1.1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/ipcamera_hi3518ev300-1.1.0.tar.gz.sha256) | +| Hi3516 solution (binary) | 1.1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/ipcamera_hi3516dv300-1.1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/ipcamera_hi3516dv300-1.1.0.tar.gz.sha256) | +| Release Notes | 1.1.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.0/OpenHarmony_Release_Notes_zh_cn.zip) | N/A | -### Acquiring Source Code Using the repo Tool +### Acquiring Source Code Using the repo Tool Run the following commands to download the source code: -``` + +```shell repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony_release_v1.1.0 --no-repo-verify repo sync -c ``` -## What's New +## What's New This version inherits all features of OpenHarmony 1.0, and adds and optimizes features for different modules based on OpenHarmony 1.0. The following table lists the feature updates. **Table 2** Feature updates - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Type

-

New Features

-

Modified Features

-

Deleted Features

-

Kernel

-
  • The LiteOS Cortex-M kernel supports the Cortex-M7, Cortex-M33, and RISC-V chip architecture, and the corresponding samples are provided.
  • The LiteOS Cortex-M kernel supports the memory protection unit (MPU).
  • The LiteOS Cortex-M kernel supports some POSIX APIs.
  • The LiteOS Cortex-M kernel supports the FatFS file system.
  • The LiteOS Cortex-M kernel supports the registration of exception callbacks.
  • The architecture of the LiteOS Cortex-M kernel has been adjusted for third-party chips to adapt to OpenHarmony.
  • The LiteOS Cortex-M and LiteOS Cortex-A kernels support the heap memory debugging functionalities, covering memory leakage, illegal access to the memory, and memory statistics.
  • The LiteOS Cortex-M and LiteOS Cortex-A kernels support the TLSF heap memory algorithm, which improves the efficiency of memory application and release and reduces the fragmentation rate.
-

LiteOS Cortex-A scheduling has been optimized.

-

None

-

Pan-sensor

-

A sensor module has been added. You can now query the sensor list, enable or disable a sensor, subscribe to or unsubscribe from sensor data, set the data reporting mode of a sensor, and set sensor options such as the data sampling interval.

-

None

-

None

-

Globalization

-

C/C++ APIs have been added for number, date, time, and singular-plural formatting in 79 languages.

-

None

-

None

-

JS Application Framework

-
  • A global JavaScript UI attribute, opacity, has been added.
  • A prompt.showDialog API has been added.
  • A QR code component qrcode has been added.
  • Event pop-ups have been added.
-
  • Internationalization has been improved, with quicker page redirections. Number internationalization and time/date conversions are now available.
  • The UI layout has been enhanced, with percentage values supported for some styles.
  • The size adaptation capabilities of the input and switch components have been enhanced.
  • The image component supports access to images in an application's private directory.
  • The image-animator component allows you to specify the end frame.
  • Some APIs have been made available for the canvas component.
  • Some return fields have been added for the device.getInfo API.
  • DFX can trace methods that encounter exceptions and output a list of such methods.
-

Backtracking is no longer supported for internationalization functions.

-

Testing

-
  • The testing tool can filter test cases to execute based on the case level.
  • Demo test cases have been added.
-

None

-

None

-

Graphics

-
  • Component rotation, scaling, and opacity management have been added.
  • Event pop-ups and the crown rotation event have been added.
  • There is now GIF image parsing and display, percentage-based width and height layout, and video and QR code components.
-

Partial rendering and SIMD performance have been optimized.

-

None

-

Utils

-
  • System attribute dumping is supported.
  • Memory pool management APIs have been added for upper-layer modules.
-

None

-

None

-

Driver

-
  • The sensor, input, and display driver models have been added.
  • The MIPI DSI and pulse width modulation (PWM) have been added.
  • Hardware Device Interfaces (HDIs) and Wi-Fi flow control have been added.
  • The I/O service grouping feature has been added for the Hardware Driver Foundation (HDF).
-

Driver loading has been optimized. It can now be accomplished in segmented parts.

-

None

-

Intelligent Soft Bus

-
  • A Wi-Fi Aware module has been added.
  • IPC supports non-aligned marshalling.
-

None

-

None

-

Security

-
  • HUKS provides the SHA-256, RSA-3072, RSA-2048, AES-128, and ECC security algorithms and APIs, as well as key management and storage.
  • The lightweight HiChain is available for managing and authenticating device groups without requiring login to devices using the same account, and for ensuring the communication security based on the Intelligent Soft Bus. It also provides APIs for system services and applications.
  • A unified permission management system has been added to manage permissions for lightweight devices.
-

None

-

None

-

AI

-
  • A unified AI engine framework has been added to implement quick integration of AI algorithm plug-ins. The framework consists of plug-in management, module management, and communications management modules. This framework provides lifecycle management and allows for on-demand deployment of AI algorithms.
  • A developer guide, and two AI capability plug-ins developed based on the AI engine framework and two AI application samples are provided for you to quickly integrate AI algorithms in the AI engine framework.
-

None

-

None

-

Update

-

An update capability framework for mini-system devices has been added. It provides APIs for update package verification, parsing, and installation.

-

None

-

None

-

XTS

-

AI, DFX, globalization, and OTA compatibility test cases have been added.

-

Capabilities for the application framework, Intelligent Soft Bus, distributed scheduler, IoT, and kernel have been enhanced.

-

None

-

Compilation and Building

-
  • The command line tool hb has been added. It provides the hb set and hb build commands for building in the source code directory or any subdirectory.
  • Components provided by independent chip vendors are supported.
  • Components can be built independently based on the component name.
  • The build toolchain and options can be customized for different development boards.
-

The product configuration has been decoupled from the build_lite repository and is stored in vendor/solution vendor/product/config.json.

-

None

-

Power Management

-
  • Battery level query is now supported.
  • Always-on screen functionalities have been added, along with corresponding APIs.
-

None

-

None

-
+| Type | New Features | Modified Features | Deleted Features | +| ------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Kernel | - The LiteOS Cortex-M kernel supports the Cortex-M7, Cortex-M33, and RISC-V chip architecture, and the corresponding samples are provided.
- The LiteOS Cortex-M kernel supports the memory protection unit (MPU).
- The LiteOS Cortex-M kernel supports some POSIX APIs.
- The LiteOS Cortex-M kernel supports the FatFS file system.
- The LiteOS Cortex-M kernel supports the registration of exception callbacks.
- The architecture of the LiteOS Cortex-M kernel has been adjusted for third-party chips to adapt to OpenHarmony.
- The LiteOS Cortex-M and LiteOS Cortex-A kernels support the heap memory debugging functionalities, covering memory leakage, illegal access to the memory, and memory statistics.
- The LiteOS Cortex-M and LiteOS Cortex-A kernels support the TLSF heap memory algorithm, which improves the efficiency of memory application and release and reduces the fragmentation rate. | LiteOS Cortex-A scheduling has been optimized. | None | +| Pan-sensor | A sensor module has been added. You can now query the sensor list, enable or disable a sensor, subscribe to or unsubscribe from sensor data, set the data reporting mode of a sensor, and set sensor options such as the data sampling interval. | None | None | +| Globalization | C/C++ APIs have been added for number, date, time, and singular-plural formatting in 79 languages. | None | None | +| JS Application Framework | - A global JavaScript UI attribute, **opacity**, has been added.
- A **prompt.showDialog** API has been added.
- A QR code component **qrcode** has been added.
- Event pop-ups have been added. | - Internationalization has been improved, with quicker page redirections. Number internationalization and time/date conversions are now available.
- The UI layout has been enhanced, with percentage values supported for some styles.
- The size adaptation capabilities of the **input** and **switch** components have been enhanced.
- The **image** component supports access to images in an application's private directory.
- The **image-animator** component allows you to specify the end frame.
- Some APIs have been made available for the **canvas** component.
- Some return fields have been added for the **device.getInfo** API.
- DFX can trace methods that encounter exceptions and output a list of such methods. | Backtracking is no longer supported for internationalization functions. | +| Testing | - The testing tool can filter test cases to execute based on the case level.
- Demo test cases have been added. | None | None | +| Graphics | - Component rotation, scaling, and opacity management have been added.
- Event pop-ups and the crown rotation event have been added.
- There is now GIF image parsing and display, percentage-based width and height layout, and video and QR code components. | Partial rendering and SIMD performance have been optimized. | None | +| Utils | - System attribute dumping is supported.
- Memory pool management APIs have been added for upper-layer modules. | None | None | +| Driver | - The sensor, input, and display driver models have been added.
- The MIPI DSI and pulse width modulation (PWM) have been added.
- Hardware Device Interfaces (HDIs) and Wi-Fi flow control have been added.
- The I/O service grouping feature has been added for the Hardware Driver Foundation (HDF). | Driver loading has been optimized. It can now be accomplished in segmented parts. | None | +| DSoftBus | - A Wi-Fi Aware module has been added.
- IPC supports non-aligned marshalling. | None | None | +| Security | - HUKS provides the SHA-256, RSA-3072, RSA-2048, AES-128, and ECC security algorithms and APIs, as well as key management and storage.
- The lightweight HiChain is available for managing and authenticating device groups without requiring login to devices using the same account, and for ensuring the communication security based on the Intelligent Soft Bus. It also provides APIs for system services and applications.
- A unified permission management system has been added to manage permissions for lightweight devices. | None | None | +| AI | - A unified AI engine framework has been added to implement quick integration of AI algorithm plug-ins. The framework consists of plug-in management, module management, and communications management modules. This framework provides lifecycle management and allows for on-demand deployment of AI algorithms.
- A developer guide, and two AI capability plug-ins developed based on the AI engine framework and two AI application samples are provided for you to quickly integrate AI algorithms in the AI engine framework. | None | None | +| Update | An update capability framework for mini-system devices has been added. It provides APIs for update package verification, parsing, and installation. | None | None | +| XTS | AI, DFX, globalization, and OTA compatibility test cases have been added. | Capabilities for the application framework, Intelligent Soft Bus, distributed scheduler, IoT, and kernel have been enhanced. | None | +| Compilation and Building | - The command line tool hb has been added. It provides the **hb set** and **hb build** commands for building in the source code directory or any subdirectory.
- Components provided by independent chip vendors are supported.
- Components can be built independently based on the component name.
- The build toolchain and options can be customized for different development boards. | The product configuration has been decoupled from the **build_lite** repository and is stored in **vendor/solution vendor/product/config.json**. | None | +| Power Management | - Battery level query is now supported.
- Always-on screen functionalities have been added, along with corresponding APIs. | None | None | The following table describes the optimization of repositories. @@ -248,912 +67,142 @@ The following table describes the optimization of repositories. **Table 3** Optimization of repositories - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

OpenHarmony1.0

-

OpenHarmony1.1.0

-

Optimization

-

ace_lite_jsfwk

-

ace_engine_lite

-

The repository name has been changed.

-

ace_interfaces_innerkits_builtin

-

N/A

-

Read-only archiving

-

N/A

-

ai_engine

-

New module

-

hiviewdfx_frameworks_hievent_lite

-

hiviewdfx_hievent_lite

-

The repository name has been changed.

-

hiviewdfx_frameworks_hilog_lite

-

hiviewdfx_hilog_lite

-

The repository name has been changed.

-

hiviewdfx_utils_lite

-

hiviewdfx_hiview_lite

-

The repository name has been changed.

-

hiviewdfx_frameworks_ddrdump_lite

-

N/A

-

Read-only archiving

-

hiviewdfx_interfaces_innerkits_hievent_lite

-

N/A

-

Read-only archiving

-

hiviewdfx_interfaces_innerkits_hilog

-

N/A

-

Read-only archiving

-

hiviewdfx_interfaces_kits_hilog

-

N/A

-

Read-only archiving

-

hiviewdfx_interfaces_kits_hilog_lite

-

N/A

-

Read-only archiving

-

hiviewdfx_services_hilogcat_lite

-

N/A

-

Read-only archiving

-

hiviewdfx_services_hiview_lite

-

N/A

-

Read-only archiving

-

iothardware_hals_wifiiot_lite

-

N/A

-

Read-only archiving

-

iothardware_interfaces_kits_wifiiot_lite

-

N/A

-

Read-only archiving

-

iothardware_frameworks_wifiiot_lite

-

iothardware_peripheral

-

The repository name has been changed.

-

N/A

-

applications_camera_sample_communication

-

New module

-

N/A

-

applications_camera_screensaver_app

-

New module

-

N/A

-

sensors_miscdevice_lite

-

New module

-

N/A

-

sensors_sensor_lite

-

New module

-

xts_tools_lite

-

xts_tools

-

The repository name has been changed.

-

security_services_iam_lite

-

security_permission

-

The repository name has been changed.

-

security_interfaces_innerkits_iam_lite

-

N/A

-

Read-only archiving

-

security_interfaces_kits_iam_lite

-

N/A

-

Read-only archiving

-

security_services_secure_os

-

security_itrustee_ree_lite

-

The repository name has been changed.

-

security_interfaces_innerkits_secure_os

-

N/A

-

Read-only archiving

-

security_frameworks_secure_os

-

N/A

-

Read-only archiving

-

security_services_app_verify

-

security_appverify

-

The repository name has been changed.

-

security_interfaces_innerkits_app_verify

-

N/A

-

Read-only archiving

-

security_services_hichainsdk_lite

-

security_deviceauth

-

The repository name has been changed.

-

security_interfaces_innerkits_hichainsdk_lite

-

N/A

-

Read-only archiving

-

security_services_huks_lite

-

security_huks

-

The repository name has been changed.

-

security_interfaces_innerkits_huks_lite

-

N/A

-

Read-only archiving

-

security_frameworks_crypto_lite

-

N/A

-

Read-only archiving

-

security_interfaces_innerkits_crypto_lite

-

N/A

-

Read-only archiving

-

N/A

-

signcenter_tool

-

New module

-

N/A

-

third_party_cryptsetup

-

New module

-

N/A

-

third_party_JSON-C

-

New module

-

N/A

-

third_party_libuuid

-

New module

-

N/A

-

third_party_LVM2

-

New module

-

N/A

-

third_party_popt

-

New module

-

communication_interfaces_kits_wifi_lite

-

N/A

-

Read-only archiving

-

communication_frameworks_wifi_lite

-

N/A

-

Read-only archiving

-

N/A

-

communication_wifi_lite

-

New module

-

N/A

-

powermgr_powermgr_lite

-

New module

-

distributedschedule_services_dtbschedmgr_lite

-

distributedschedule_dms_fwk_lite

-

The repository name has been changed.

-

distributedschedule_services_safwk_lite

-

distributedschedule_safwk_lite

-

The repository name has been changed.

-

distributedschedule_services_samgr_lite

-

distributedschedule_samgr_lite

-

The repository name has been changed.

-

distributedschedule_interfaces_innerkits_samgr_lite

-

N/A

-

Read-only archiving

-

distributedschedule_interfaces_kits_samgr_lite

-

N/A

-

Read-only archiving

-

multimedia_frameworks_audio_lite

-

multimedia_audio_lite

-

The repository name has been changed.

-

multimedia_frameworks_camera_lite

-

multimedia_camera_lite

-

The repository name has been changed.

-

multimedia_frameworks_player_lite

-

multimedia_media_lite

-

The repository name has been changed.

-

multimedia_hals_camera_lite

-

N/A

-

Read-only archiving

-

multimedia_frameworks_recorder_lite

-

N/A

-

Read-only archiving

-

multimedia_interfaces_kits_audio_lite

-

N/A

-

Read-only archiving

-

multimedia_interfaces_kits_camera_lite

-

N/A

-

Read-only archiving

-

multimedia_interfaces_kits_player_lite

-

N/A

-

Read-only archiving

-

multimedia_interfaces_kits_recorder_lite

-

N/A

-

Read-only archiving

-

multimedia_services_media_lite

-

N/A

-

Read-only archiving

-

kernel_liteos_a_huawei_proprietary_fs_proc

-

N/A

-

Read-only archiving

-

N/A

-

third_party_mksh

-

New module

-

N/A

-

third_party_optimized_routines

-

New module

-

N/A

-

third_party_toybox

-

New module

-

vendor_huawei_camera

-

N/A

-

Read-only archiving

-

vendor_huawei_wifi_iot

-

N/A

-

Read-only archiving

-

startup_services_bootstrap_lite

-

startup_bootstrap_lite

-

The repository name has been changed.

-

startup_frameworks_syspara_lite

-

startup_syspara_lite

-

The repository name has been changed.

-

startup_hals_syspara_lite

-

N/A

-

Read-only archiving

-

startup_interfaces_kits_syspara_lite

-

N/A

-

Read-only archiving

-

graphic_lite

-

graphic_surface

-

The repository name has been changed.

-

N/A

-

graphic_ui

-

New module

-

N/A

-

graphic_utils

-

New module

-

N/A

-

graphic_wms

-

New module

-

N/A

-

third_party_giflib

-

New module

-

N/A

-

third_party_qrcodegen

-

New module

-

N/A

-

drivers_adapter_khdf_linux

-

New module

-

drivers_hdf_lite

-

drivers_adapter_khdf_liteos

-

The repository name has been changed.

-

N/A

-

drivers_adapter_uhdf

-

New module

-

drivers_hdf_frameworks

-

drivers_framework

-

The repository name has been changed.

-

N/A

-

drivers_peripheral_audio

-

New module

-

N/A

-

drivers_peripheral_codec

-

New module

-

N/A

-

drivers_peripheral_display

-

New module

-

N/A

-

drivers_peripheral_format

-

New module

-

N/A

-

drivers_peripheral_input

-

New module

-

N/A

-

drivers_peripheral_sensor

-

New module

-

N/A

-

drivers_peripheral_wlan

-

New module

-

N/A

-

global_cust_lite

-

New module

-

N/A

-

global_i18n_lite

-

New module

-

global_frameworks_resmgr_lite

-

global_resmgr_lite

-

The repository name has been changed.

-
  

third_party_icu

-

New module

-

global_interfaces_innerkits_resmgr_lite

-

N/A

-

Read-only archiving

-

communication_frameworks_ipc_lite

-

communication_ipc_lite

-

The repository name has been changed.

-

communication_interfaces_kits_ipc_lite

-

N/A

-

Read-only archiving

-

communication_interfaces_kits_softbuskit_lite

-

N/A

-

Read-only archiving

-

communication_hals_wifi_lite

-

N/A

-

Read-only archiving

-

communication_services_softbus_lite

-

communication_softbus_lite

-

The repository name has been changed.

-

N/A

-

communication_wifi_aware

-

New module

-

N/A

-

update_ota_lite

-

New module

-

vendor_hisi_hi35xx_hi35xx_init

-

device_hisilicon_build

-

The repository name has been changed.

-

vendor_hisi_hi35xx_platform

-

device_hisilicon_drivers

-

The repository name has been changed.

-

vendor_hisi_hi35xx_hardware

-

device_hisilicon_hardware

-

The repository name has been changed.

-

vendor_hisi_hi35xx_hi3518ev300

-

device_hisilicon_hispark_aries

-

The repository name has been changed.

-

vendor_hisi_hi3861_hi3861

-

device_hisilicon_hispark_pegasus

-

The repository name has been changed.

-

vendor_hisi_hi35xx_hi3516dv300

-

device_hisilicon_hispark_taurus

-

The repository name has been changed.

-

vendor_hisi_hi35xx_middleware

-

device_hisilicon_modules

-

The repository name has been changed.

-

vendor_hisi_hi35xx_middleware_source_third_party_ffmpeg

-

device_hisilicon_third_party_ffmpeg

-

The repository name has been changed.

-

vendor_hisi_hi35xx_thirdparty_uboot_src

-

device_hisilicon_third_party_uboot

-

The repository name has been changed.

-

N/A

-

vendor_hisilicon

-

New module

-

vendor_hisi_hi35xx_hi3516dv300_uboot

-

N/A

-

Read-only archiving

-

vendor_hisi_hi35xx_hi3518ev300_uboot

-

N/A

-

Read-only archiving

-

aafwk_interfaces_innerkits_abilitykit_lite

-

N/A

-

Read-only archiving

-

aafwk_interfaces_innerkits_intent_lite

-

aafwk_aafwk_lite

-

The repository name has been changed.

-

aafwk_interfaces_innerkits_abilitymgr_lite

-

N/A

-

Read-only archiving

-

appexecfwk_kits_appkit_lite

-

appexecfwk_appexecfwk_lite

-

The repository name has been changed.

-

aafwk_frameworks_kits_ability_lite

-

N/A

-

Read-only archiving

-
  

developtools_packing_tool

-

New module

-

aafwk_interfaces_kits_ability_lite

-

N/A

-

Read-only archiving

-

appexecfwk_frameworks_bundle_lite

-

N/A

-

Read-only archiving

-

aafwk_services_abilitymgr_lite

-

N/A

-

Read-only archiving

-

appexecfwk_interfaces_innerkits_appexecfwk_lite

-

N/A

-

Read-only archiving

-

appexecfwk_interfaces_innerkits_bundlemgr_lite

-

N/A

-

Read-only archiving

-

appexecfwk_services_bundlemgr_lite

-

N/A

-

Read-only archiving

-

aafwk_frameworks_kits_content_lite

-

N/A

-

Read-only archiving

-
- -## Resolved Issues +| OpenHarmony1.0 | OpenHarmony1.1.0 | Optimization | +| ------------------------------------------------------------ | --------------------------------------------- | ------------------------------------- | +| ace_lite_jsfwk | ace_engine_lite | Repository renamed | +| ace_interfaces_innerkits_builtin | N/A | Read-only archiving | +| N/A | ai_engine | New module | +| hiviewdfx_frameworks_hievent_lite | hiviewdfx_hievent_lite | Repository renamed | +| hiviewdfx_frameworks_hilog_lite | hiviewdfx_hilog_lite | Repository renamed | +| hiviewdfx_utils_lite | hiviewdfx_hiview_lite | Repository renamed | +| hiviewdfx_frameworks_ddrdump_lite | N/A | Read-only archiving | +| hiviewdfx_interfaces_innerkits_hievent_
lite | N/A | Read-only archiving | +| hiviewdfx_interfaces_innerkits_hilog | N/A | Read-only archiving | +| hiviewdfx_interfaces_kits_hilog | N/A | Read-only archiving | +| hiviewdfx_interfaces_kits_hilog_lite | N/A | Read-only archiving | +| hiviewdfx_services_hilogcat_lite | N/A | Read-only archiving | +| hiviewdfx_services_hiview_lite | N/A | Read-only archiving | +| iothardware_hals_wifiiot_lite | N/A | Read-only archiving | +| iothardware_interfaces_kits_wifiiot_lite | N/A | Read-only archiving | +| iothardware_frameworks_wifiiot_lite | iothardware_peripheral | Repository renamed | +| N/A | applications_camera_sample_
communication | New module | +| N/A | applications_camera_screensaver_
app | New module | +| N/A | sensors_miscdevice_lite | New module | +| N/A | sensors_sensor_lite | New module | +| xts_tools_lite | xts_tools | Repository renamed | +| security_services_iam_lite | security_permission | Repository renamed | +| security_interfaces_innerkits_iam_lite | N/A | Read-only archiving | +| security_interfaces_kits_iam_lite | N/A | Read-only archiving | +| security_services_secure_os | security_itrustee_ree_lite | Repository renamed | +| security_interfaces_innerkits_secure_os | N/A | Read-only archiving | +| security_frameworks_secure_os | N/A | Read-only archiving | +| security_services_app_verify | security_appverify | Repository renamed | +| security_interfaces_innerkits_app_verify | N/A | Read-only archiving | +| security_services_hichainsdk_lite | security_deviceauth | Repository renamed | +| security_interfaces_innerkits_hichainsdk_
lite | N/A | Read-only archiving | +| security_services_huks_lite | security_huks | Repository renamed | +| security_interfaces_innerkits_huks_lite | N/A | Read-only archiving | +| security_frameworks_crypto_lite | N/A | Read-only archiving | +| security_interfaces_innerkits_crypto_lite | N/A | Read-only archiving | +| N/A | signcenter_tool | New module | +| N/A | third_party_cryptsetup | New module | +| N/A | third_party_JSON-C | New module | +| N/A | third_party_libuuid | New module | +| N/A | third_party_LVM2 | New module | +| N/A | third_party_popt | New module | +| communication_interfaces_kits_wifi_lite | N/A | Read-only archiving | +| communication_frameworks_wifi_lite | N/A | Read-only archiving | +| N/A | communication_wifi_lite | New module | +| N/A | powermgr_powermgr_lite | New module | +| distributedschedule_services_
dtbschedmgr_lite | distributedschedule_dms_fwk_lite | Repository renamed | +| distributedschedule_services_safwk_lite | distributedschedule_safwk_lite | Repository renamed | +| distributedschedule_services_samgr_lite | distributedschedule_samgr_lite | Repository renamed | +| distributedschedule_interfaces_innerkits_
samgr_lite | N/A | Read-only archiving | +| distributedschedule_interfaces_kits_samgr_
lite | N/A | Read-only archiving | +| multimedia_frameworks_audio_lite | multimedia_audio_lite | Repository renamed | +| multimedia_frameworks_camera_lite | multimedia_camera_lite | Repository renamed | +| multimedia_frameworks_player_lite | multimedia_media_lite | Repository renamed | +| multimedia_hals_camera_lite | N/A | Read-only archiving | +| multimedia_frameworks_recorder_lite | N/A | Read-only archiving | +| multimedia_interfaces_kits_audio_lite | N/A | Read-only archiving | +| multimedia_interfaces_kits_camera_lite | N/A | Read-only archiving | +| multimedia_interfaces_kits_player_lite | N/A | Read-only archiving | +| multimedia_interfaces_kits_recorder_lite | N/A | Read-only archiving | +| multimedia_services_media_lite | N/A | Read-only archiving | +| kernel_liteos_a_huawei_proprietary_fs_
proc | N/A | Read-only archiving | +| N/A | third_party_mksh | New module | +| N/A | third_party_optimized_routines | New module | +| N/A | third_party_toybox | New module | +| vendor_huawei_camera | N/A | Read-only archiving | +| vendor_huawei_wifi_iot | N/A | Read-only archiving | +| startup_services_bootstrap_lite | startup_bootstrap_lite | Repository renamed | +| startup_frameworks_syspara_lite | startup_syspara_lite | Repository renamed | +| startup_hals_syspara_lite | N/A | Read-only archiving | +| startup_interfaces_kits_syspara_lite | N/A | Read-only archiving | +| graphic_lite | graphic_surface | Repository renamed | +| N/A | graphic_ui | New module | +| N/A | graphic_utils | New module | +| N/A | graphic_wms | New module | +| N/A | third_party_giflib | New module | +| N/A | third_party_qrcodegen | New module | +| N/A | drivers_adapter_khdf_linux | New module | +| drivers_hdf_lite | drivers_adapter_khdf_liteos | Repository renamed | +| N/A | drivers_adapter_uhdf | New module | +| drivers_hdf_frameworks | drivers_framework | Repository renamed | +| N/A | drivers_peripheral_audio | New module | +| N/A | drivers_peripheral_codec | New module | +| N/A | drivers_peripheral_display | New module | +| N/A | drivers_peripheral_format | New module | +| N/A | drivers_peripheral_input | New module | +| N/A | drivers_peripheral_sensor | New module | +| N/A | drivers_peripheral_wlan | New module | +| N/A | global_cust_lite | New module | +| N/A | global_i18n_lite | New module | +| global_frameworks_resmgr_lite | global_resmgr_lite | Repository renamed | +| | third_party_icu | New module | +| global_interfaces_innerkits_resmgr_lite | N/A | Read-only archiving | +| communication_frameworks_ipc_lite | communication_ipc_lite | Repository renamed | +| communication_interfaces_kits_ipc_lite | N/A | Read-only archiving | +| communication_interfaces_kits_
softbuskit_lite | N/A | Read-only archiving | +| communication_hals_wifi_lite | N/A | Read-only archiving | +| communication_services_softbus_lite | communication_softbus_lite | Repository renamed | +| N/A | communication_wifi_aware | New module | +| N/A | update_ota_lite | New module | +| vendor_hisi_hi35xx_hi35xx_init | device_hisilicon_build | Repository renamed | +| vendor_hisi_hi35xx_platform | device_hisilicon_drivers | Repository renamed | +| vendor_hisi_hi35xx_hardware | device_hisilicon_hardware | Repository renamed | +| vendor_hisi_hi35xx_hi3518ev300 | device_hisilicon_hispark_aries | Repository renamed | +| vendor_hisi_hi3861_hi3861 | device_hisilicon_hispark_pegasus | Repository renamed | +| vendor_hisi_hi35xx_hi3516dv300 | device_hisilicon_hispark_taurus | Repository renamed | +| vendor_hisi_hi35xx_middleware | device_hisilicon_modules | Repository renamed | +| vendor_hisi_hi35xx_middleware_source_
third_party_ffmpeg | device_hisilicon_third_party_ffmpeg | Repository renamed | +| vendor_hisi_hi35xx_thirdparty_uboot_src | device_hisilicon_third_party_uboot | Repository renamed | +| N/A | vendor_hisilicon | New module | +| vendor_hisi_hi35xx_hi3516dv300_uboot | N/A | Read-only archiving | +| vendor_hisi_hi35xx_hi3518ev300_uboot | N/A | Read-only archiving | +| aafwk_interfaces_innerkits_abilitykit_lite | N/A | Read-only archiving | +| aafwk_interfaces_innerkits_intent_lite | aafwk_aafwk_lite | Repository renamed | +| aafwk_interfaces_innerkits_abilitymgr_
lite | N/A | Read-only archiving | +| appexecfwk_kits_appkit_lite | appexecfwk_appexecfwk_lite | Repository renamed | +| aafwk_frameworks_kits_ability_lite | - | Read-only archiving | +| | developtools_packing_tool | New module | +| aafwk_interfaces_kits_ability_lite | N/A | Read-only archiving | +| appexecfwk_frameworks_bundle_lite | N/A | Read-only archiving | +| aafwk_services_abilitymgr_lite | N/A | Read-only archiving | +| appexecfwk_interfaces_innerkits_
appexecfwk_lite | N/A | Read-only archiving | +| appexecfwk_interfaces_innerkits_
bundlemgr_lite | N/A | Read-only archiving | +| appexecfwk_services_bundlemgr_lite | N/A | Read-only archiving | +| aafwk_frameworks_kits_content_lite | N/A | Read-only archiving | + +## Resolved Issues The following table lists the issues known in OpenHarmony 1.0, which have been resolved in this version. **Table 4** Resolved issues - - - - - - - - - - - - - - - -

Issue

-

Description

-

I3EALU

-

[Multimedia] During execution of the cameraActs case, the camera configuration file cannot be found, and the initialization fails.

-

I3EGUX

-

[Reliability] When the system is reset repeatedly, and the KIdle process crashes once, the system is suspended and cannot be started.

-

I3DHIL

-

[System] The remaining space of the Hi3518 development board is insufficient, causing a failure in executing a large number of ACTS test cases.

-
+| Issue | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [I3EALU](https://gitee.com/openharmony/multimedia_camera_lite/issues/I3EALU) | [Multimedia] During execution of the cameraActs case, the camera configuration file cannot be found, and the initialization fails. | +| [I3EGUX](https://gitee.com/openharmony/release-management/issues/I3EGUX) | [Reliability] When the system is reset repeatedly, and the KIdle process crashes once, the system is suspended and cannot be started. | +| [I3DHIL](https://gitee.com/openharmony/community/issues/I3DHIL) | [System] The remaining space of the Hi3518 development board is insufficient, causing a failure in executing a large number of ACTS test cases. | diff --git a/en/release-notes/OpenHarmony-1-1-1-LTS.md b/en/release-notes/OpenHarmony-1-1-1-LTS.md index aac5017f810e6bed67a94079b98863e26be4b7bf..03653f2552a5ad06e7d326fc5adbeb459d3d4618 100644 --- a/en/release-notes/OpenHarmony-1-1-1-LTS.md +++ b/en/release-notes/OpenHarmony-1-1-1-LTS.md @@ -1,133 +1,44 @@ -# OpenHarmony 1.1.1 LTS \(2021-06-22\) +# OpenHarmony 1.1.1 LTS \(2021-06-22) -## Version Description +## Version Description This is an updated long-term support \(LTS\) version of OpenHarmony. It supports more functions and fixes some bugs in OpenHarmony 1.1.0. -## Source Code Acquisition +## Source Code Acquisition -### Acquiring Source Code from Mirrors +### Acquiring Source Code from Mirrors **Table 1** Mirrors for acquiring source code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Source Code

-

Version

-

Mirror

-

SHA-256 Checksum

-

Full code base

-

1.1.1

-

Download

-

Download

-

Hi3861 solution (binary)

-

1.1.1

-

Download

-

Download

-

Hi3518 solution (binary)

-

1.1.1

-

Download

-

Download

-

Hi3516 solution (binary)

-

1.1.1

-

Download

-

Download

-

Release Notes

-

1.1.1

-

Download

-

-

-
+| Source Code | Version | Mirror | SHA-256 Checksum | +| ------------------------ | ------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Full code base | 1.1.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/code-v1.1.1-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/code-v1.1.1-LTS.tar.gz.sha256) | +| Hi3861 solution (binary) | 1.1.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/wifiiot-1.1.0.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/wifiiot-1.1.0.tar.gz.sha256) | +| Hi3518 solution (binary) | 1.1.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/ipcamera_hi3518ev300-1.1.1.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/ipcamera_hi3518ev300-1.1.1.tar.gz.sha256) | +| Hi3516 solution (binary) | 1.1.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/ipcamera_hi3516dv300-1.1.1.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/ipcamera_hi3516dv300-1.1.1.tar.gz.sha256) | +| Release Notes | 1.1.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.1/OpenHarmony_Release_Notes_1.1.1_LTS.md) | - | -### Acquiring Source Code Using the repo Tool +### Acquiring Source Code Using the repo Tool Run the following commands to download the source code: repo init -u [https://gitee.com/openharmony/manifest.git](https://gitee.com/openharmony/manifest.git) -b refs/tags/OpenHarmony-v1.1.1-LTS --no-repo-verify -## What's New +## What's New This version inherits all features of OpenHarmony 1.1.0, and fixes bugs and optimizes performance for different modules based on OpenHarmony 1.1.0. The following table lists the updates. **Table 2** Version updates - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Type

-

Description

-

Communications

-
  • Updated data classes of some STA related functions, and added innerkits APIs of some AP related functions
  • Added innerkits APIs for Bluetooth-related functions, including GATT related operations of BLE devices, BLE broadcast, and scanning.
-

Security

-
  • Removed device authentication so callers can use bound capabilities alone.
  • Allowed device authentication removed from Huawei Universal Keystore Service (HUKS).
-

Kernel

-
  • Fixed the bug of unavailable kernel stack backtracking of the system image built using Clang.
  • Fixed the bug of improper comparison between signed numbers and unsigned numbers during scheduling.
  • Fixed the bug of memory overwriting because setitimer does not hold the scheduler lock when periodically sending signals to the process.
  • Added adaptation to the kernel's POSIX APIs for lwIP.
  • Fixed the bug of unexpected signal execution sequence after sigsuspend in sigaction is called; fixed the bug so that the signal mask field passed by the developer is now masked during signal registration.
-

Driver

-
  • Corrected the compilation error on liteos_m.
  • Fixed MMC crashes.
-

AI

-
  • Added support for shared memory.
  • Added adaptation to the Linux kernel.
  • Disabled asynchronous call for the synchronous algorithm.
  • Added gitignore and CMakeLists.
-

Graphics

-
  • Fixed the bug that occurs when the endpoint style is enabled for circle progress.
  • Resolved issues related to the sensitivity and direction of crown rotation.
  • Added the feature of automatic alignment with the animation time for UIList.
  • Provided correct width for GetTextWidth in UILabel when LineBreakMode is set to LINE_BREAK_ELLIPSIS.
  • Added new style attributes to the Slider component.
  • Added the API for setting loops to the UITimePicker component.
  • Fixed the bug of abnormal Neon rotation and scaling display that results from optimization of fixed-point numbers.
  • Rectified the improper newline issue that occurs when a string contains multiple newlines.
  • Fixed the bug of the blurred screen of watch pointers.
-

Globalization

-
  • Added the Ed and MEd templates for data and time formatting.
-

ACE framework

-
  • Fixed the bug of abnormal click events on the checkbox and radio buttons.
  • Fixed JavaScript application crashes when list and if are used.
  • Normalized the styles of the <slider> component.
  • Added swiping loops for the <picker-view> component.
  • Fixed the bug of in-the-middle display of child components when align-item is set to stretch.
-
+| Type | Description | +| -------------- | ------------------------------------------------------------ | +| Communications | - Updated data classes of some STA related functions, and added innerkits APIs of some AP related functions
- Added innerkits APIs for Bluetooth-related functions, including GATT related operations of BLE devices, BLE broadcast, and scanning. | +| Security | - Removed device authentication so callers can use bound capabilities alone.
- Allowed device authentication removed from Huawei Universal Keystore Service (HUKS). | +| Kernel | - Fixed the bug of unavailable kernel stack backtracking of the system image built using Clang.
- Fixed the bug of improper comparison between signed numbers and unsigned numbers during scheduling.
- Fixed the bug of memory overwriting because **setitimer** does not hold the scheduler lock when periodically sending signals to the process.
- Added adaptation to the kernel's POSIX APIs for lwIP.
- Fixed the bug of unexpected signal execution sequence after **sigsuspend** in **sigaction** is called; fixed the bug so that the signal mask field passed by the developer is now masked during signal registration. | +| Driver | - Corrected the compilation error on **liteos_m**.
- Fixed MMC crashes. | +| AI | - Added support for shared memory.
- Added adaptation to the Linux kernel.
- Disabled asynchronous call for the synchronous algorithm.
- Added gitignore and CMakeLists. | +| Graphics | - Fixed the bug that occurs when the endpoint style is enabled for circle progress.
- Resolved issues related to the sensitivity and direction of crown rotation.
- Added the feature of automatic alignment with the animation time for **UIList**.
- Provided correct width for **GetTextWidth** in **UILabel** when **LineBreakMode** is set to **LINE_BREAK_ELLIPSIS**.
- Added new style attributes to the **Slider** component.
- Added the API for setting loops to the **UITimePicker** component.
- Fixed the bug of abnormal Neon rotation and scaling display that results from optimization of fixed-point numbers.
- Rectified the improper newline issue that occurs when a string contains multiple newlines.
- Fixed the bug of the blurred screen of watch pointers. | +| Globalization | Added the **Ed** and **MEd** templates for data and time formatting. | +| ACE framework | - Fixed the bug of abnormal click events on the checkbox and radio buttons.
- Fixed JavaScript application crashes when **list** and **if** are used.
- Normalized the styles of the **\** component.
- Added swiping loops for the **\** component.
- Fixed the bug of in-the-middle display of child components when **align-item** is set to **stretch**. | + diff --git a/en/release-notes/OpenHarmony-2-0-Canary.md b/en/release-notes/OpenHarmony-2-0-Canary.md index b8b23c579d2136cf61b3c4ec15c60f2af303ce5a..76de97d902ce443c46ffd8d6286eccc42e94450b 100644 --- a/en/release-notes/OpenHarmony-2-0-Canary.md +++ b/en/release-notes/OpenHarmony-2-0-Canary.md @@ -1,6 +1,6 @@ -# OpenHarmony 2.0 Canary \(2021-06-01\) +# OpenHarmony 2.0 Canary \(2021-06-01\) -## Version Description +## Version Description On the basis of OpenHarmony 1.1.0, OpenHarmony 2.0 adds the version for the standard system, which delivers the following functions: @@ -11,42 +11,15 @@ On the basis of OpenHarmony 1.1.0, OpenHarmony 2.0 adds the version for the stan - A media framework has been provided to support the development of audio and video functions. - The Java UI framework has been provided to support window management, image synthesis, and GPU rendering capabilities. -## Version Mapping +## Version Mapping **Table 1** Version mapping of software and tools - - - - - - - - - - - - - - - - - - - -

Software

-

Version

-

Remarks

-

OpenHarmony

-

2.0 Canary

-

N/A

-

(Optional) HUAWEI DevEco Studio

-

DevEco Studio 2.1 Release

-

It is recommended for developing OpenHarmony apps.

-

(Optional) HUAWEI DevEco Device Tool

-

Deveco DeviceTool 2.2 Beta1

-

It is recommended for OpenHarmony smart devices.

-
+| Software | Version | Remarks | +| ------------------------------------ | --------------------------- | -------------------------------------------------- | +| OpenHarmony | 2.0 Canary | N/A | +| (Optional) HUAWEI DevEco Studio | DevEco Studio 2.1 Release | It is recommended for developing OpenHarmony apps. | +| (Optional) HUAWEI DevEco Device Tool | Deveco DeviceTool 2.2 Beta1 | It is recommended for OpenHarmony smart devices. | ## Source Code Acquisition @@ -56,18 +29,21 @@ On the basis of OpenHarmony 1.1.0, OpenHarmony 2.0 adds the version for the stan **Method 1 (recommended)**: Use the **repo** tool to download the source code over SSH. (You must have registered an SSH public key for access to Gitee.) -``` + + ```shell repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-2.0-Canary --no-repo-verify -repo sync-c -repo forall -c'git lfs pull' -``` +repo sync -c +repo forall -c 'git lfs pull' + ``` **Method 2**: Use the **repo** tool to download the source code over HTTPS. -``` + + +```shell repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-2.0-Canary --no-repo-verify -repo sync-c -repo forall -c'git lfs pull' +repo sync -c +repo forall -c 'git lfs pull' ``` @@ -75,170 +51,46 @@ repo forall -c'git lfs pull' **Table 2** Mirrors for acquiring source code -| Source Code | Version | Mirror | SHA-256 Checksum | +| Source Code | Version | Mirror | SHA-256 Checksum | | -------- | -------- | -------- | -------- | -| Full code base | 2.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz.sha256) | -| Release Notes | 2.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-2-0-Canary.md) | - | +| Full code base | 2.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz.sha256) | +| Release Notes | 2.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-2-0-Canary.md) | - | -## What's New +## What's New This version inherits all the features of OpenHarmony 1.1.0 and adds the version form for the standard system. The following table describes the specific features added for the version form. **Table 3** New features - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Subsystem

-

New Feature

-

Kernel

-

The OpenHarmony kernel is built based on the open-source Linux kernel LTS release and forms a complete kernel baseline by merging the common vulnerabilities and exposures (CVE) patches and features for OpenHarmony upper-layer adaptation.

-

Distributed File

-

Provided JavaScript APIs for local file synchronization, including reading and writing files, accessing directories, and collecting file statistics.

-

Graphics

-
  • Provided window management functions, including creating and destroying windows and managing window stacks.
  • Added the synthesizer function, which implements CPU, GPU, and TDE synthesis.
  • Added the BufferQueue function to support inter-process communication.
  • Added the VSync management function.
-

Driver

-

Added the user-space driver framework.

-

Power Management

-

Added power management capabilities, including powering off the device, turning on/off the device screen, adjusting the brightness, querying the battery status, and managing the system power and running lock.

-

Multimodal Input

-

Added the single-touch input capability.

-

Startup

-

Added JavaScript APIs for managing system attributes.

-

Update

-
  • Added the OTA update using a full package.
  • Added the OTA update using a differential package.
  • Added JavaScript APIs for managing system attributes.
-

Account

-

Provided login status management of distributed cloud accounts.

-

Compilation and Building

-
  • Added building of targets by module name or submodule name.
  • Supported access of different chip platforms and configuration of the product module list.
-

Testing

-

Added the developer test capability of conducting C++ API unit tests and API performance tests.

-

Data Management

-

Provided lightweight key-value operations for local apps to store a small amount of data. As the stored data is already loaded in the memory, the faster data access speed achieves a higher work efficiency.

-

Programming Language Runtime

-

Provided the compilation and execution environment for programs developed with JavaScript, and C/C++, basic libraries that support the runtime, and the runtime-associated APIs, compilers, and auxiliary tools.

-

Distributed Scheduler

-

Provided the capabilities of starting, registering, querying, and managing system services.

-

JS UI framework

-
  • Provided more than 40 basic UI components and container components.
  • Provided standard CSS animations.
  • Provided the atomic layout and grid layout.
  • Provided a UI programming framework that supports the web-development-like paradigm.
  • Provided the JavaScript API extension mechanism.
-

Multimedia

-
  • Added basic functions of media playback and recording.
  • Added basic functions of camera management and sampling.
  • Added basic functions of audio volume and device management.
-

Event Notification

-

Added basic functions of publishing, subscribing to, and receiving common events.

-

Misc Services

-

Added the function of setting the time.

-

Application framework

-

Provided bundle installation, uninstallation, running, and management capabilities.

-

Telephony

-
  • Provided the capabilities of obtaining the signal strength and the network registration status.
  • Provided the capability of obtaining the SIM card status.
  • Provided the capabilities of making, rejecting, and ending calls.
  • Provided the capabilities of sending and receiving SMS messages.
-

Utils

-

Provides some common enhanced APIs for development using C and C++.

-

Development Tools

-
  • Provided the device connection debugger.
  • Provided the performance tracing capability.
  • Provided real-time memory analysis, trace, and device-side plug-ins.
-

Intelligent Soft Bus

-
  • Provided inter-process communication (IPC) and remote procedure call (RPC) capabilities.
  • Provided soft bus services including device discovery, networking, and transmission.
  • Provided basic WLAN capabilities, including enabling/disabling, scanning, and connecting to a station.
-

XTS

-

Provided test case suites for maintaining the compatibility of common APIs for subsystems.

-

System Apps

-

Launcher

-
  • Provided the capabilities of displaying all app icons, starting an app, and uninstalling an app.
  • Provided the Launcher system app that allows switching between the grid layout and list layout.
  • Provided recent task management to support hot start and task deletion.
-

Settings

-
  • Provided the Settings system app that allows users to set the brightness and time and to query app and device information.
-

SystemUI

-
  • Provided the system status bar to display time and battery information.
  • Provided the display of system navigation.
-

DFX

-
  • Provided the logging function.
  • Provided fault information collection and subscription.
  • Provided APIs for logging system events.
  • Provided the framework and APIs for logging app events.
-

Globalization

-
  • Provided the capability of parsing and reading i18n resources.
  • Provided the capability of formatting the date and time.
-

Security

-
  • Provided system permission management, including system permission declaration, parsing of the permissions requested or declared during app installation, permission query, and permission granting.
  • Provided the app signature and signature verification capabilities.
  • Provided mutual authentication and device group management for trusted P2P devices.
-
+| Subsystem | New Feature | +| ---------------------------- | ------------------------------------------------------------ | +| Kernel | The OpenHarmony kernel is built based on the open-source Linux kernel LTS release and forms a complete kernel baseline by merging the common vulnerabilities and exposures (CVE) patches and features for OpenHarmony upper-layer adaptation. | +| Distributed File | Provided JavaScript APIs for local file synchronization, including reading and writing files, accessing directories, and collecting file statistics. | +| Graphics | - Provided window management functions, including creating and destroying windows and managing window stacks.
- Added the synthesizer function, which implements CPU, GPU, and TDE synthesis.
- Added the BufferQueue function to support inter-process communication.
- Added the VSync management function. | +| Driver | Added the user-space driver framework. | +| Power Management | Added power management capabilities, including powering off the device, turning on/off the device screen, adjusting the brightness, querying the battery status, and managing the system power and running lock. | +| Multimodal Input | Added the single-touch input capability. | +| Startup | Added JavaScript APIs for managing system attributes. | +| Update | - Added the OTA update using a full package.
- Added the OTA update using a differential package.
- Added JavaScript APIs for managing system attributes. | +| Account | Provided login status management of distributed cloud accounts. | +| Compilation and Building | - Added building of targets by module name or submodule name.
- Supported access of different chip platforms and configuration of the product module list. | +| Testing | Added the developer test capability of conducting C++ API unit tests and API performance tests. | +| Data Management | Provided lightweight key-value operations for local apps to store a small amount of data. As the stored data is already loaded in the memory, the faster data access speed achieves a higher work efficiency. | +| Programming Language Runtime | Provided the compilation and execution environment for programs developed with JavaScript, and C/C++, basic libraries that support the runtime, and the runtime-associated APIs, compilers, and auxiliary tools. | +| Distributed Scheduler | Provided the capabilities of starting, registering, querying, and managing system services. | +| JS UI framework | - Provided more than 40 basic UI components and container components.
- Provided standard CSS animations.
- Provided the atomic layout and grid layout.
- Provided a UI programming framework that supports the web-development-like paradigm.
- Provided the JavaScript API extension mechanism. | +| Multimedia | - Added basic functions of media playback and recording.
- Added basic functions of camera management and sampling.
- Added basic functions of audio volume and device management. | +| Event Notification | Added basic functions of publishing, subscribing to, and receiving common events. | +| Misc Services | Added the function of setting the time. | +| Application framework | Provided bundle installation, uninstallation, running, and management capabilities. | +| Telephony | - Provided the capabilities of obtaining the signal strength and the network registration status.
- Provided the capability of obtaining the SIM card status.
- Provided the capabilities of making, rejecting, and ending calls.
- Provided the capabilities of sending and receiving SMS messages. | +| Utils | Provides some common enhanced APIs for development using C and C++. | +| Development Tools | - Provided the device connection debugger.
- Provided the performance tracing capability.
- Provided real-time memory analysis, trace, and device-side plug-ins. | +| DSoftBus | - Provided inter-process communication (IPC) and remote procedure call (RPC) capabilities.
- Provided soft bus services including device discovery, networking, and transmission.
- Provided basic WLAN capabilities, including enabling/disabling, scanning, and connecting to a station. | +| XTS | Provided test case suites for maintaining the compatibility of common APIs for subsystems. | +| System Apps | Home screen:
- Provided the capabilities of displaying all app icons, starting an app, and uninstalling an app.
- Provided the Launcher system app that allows switching between the grid layout and list layout.
- Provided recent task management to support hot start and task deletion.
Settings:
- Provided the Settings system app that allows users to set the brightness and time and to query app and device information.
SystemUI:
- Provided the system status bar to display time and battery information.
- Provided the display of system navigation. | +| DFX | - Provided the logging function.
- Provided fault information collection and subscription.
- Provided APIs for logging system events.
- Provided the framework and APIs for logging app events. | +| Globalization | - Provided the capability of parsing and reading i18n resources.
- Provided the capability of formatting the date and time. | +| Security | - Provided system permission management, including system permission declaration, parsing of the permissions requested or declared during app installation, permission query, and permission granting.
- Provided the app signature and signature verification capabilities.
- Provided mutual authentication and device group management for trusted P2P devices. | diff --git a/en/release-notes/OpenHarmony-v1-1-3-LTS.md b/en/release-notes/OpenHarmony-v1-1-3-LTS.md index f14a725a648af8f94b27f99229e4f553330a1985..de7054e735c4fafcc872aad6834c4715d6fc1c85 100644 --- a/en/release-notes/OpenHarmony-v1-1-3-LTS.md +++ b/en/release-notes/OpenHarmony-v1-1-3-LTS.md @@ -1,46 +1,26 @@ -# OpenHarmony v1.1.3 LTS +# OpenHarmony v1.1.3 LTS -## Overview +## Overview This is an updated long-term support \(LTS\) version of OpenHarmony. It supports more functions than and fixes some bugs in OpenHarmony 1.1.2. -## Version Mapping +## Version Mapping **Table 1** Version mapping of software and tools - - - - - - - - - - - - - - - -

Software

-

Version

-

Remarks

-

OpenHarmony

-

1.1.3 LTS

-

N/A

-

(Optional) HUAWEI DevEco Device Tool

-

HUAWEI DevEco Device Tool 2.1 Release

-

Recommended for developing OpenHarmony smart devices

-
- -## Source Code Acquisition - -### Acquiring Source Code Using the repo Tool +| Software | Version | Remarks | +| ------------------------------------ | ------------------------------------- | ---------------------------------------------------- | +| OpenHarmony | 1.1.3 LTS | N/A | +| (Optional) HUAWEI DevEco Device Tool | HUAWEI DevEco Device Tool 2.1 Release | Recommended for developing OpenHarmony smart devices | + +## Source Code Acquisition + +### Acquiring Source Code Using the repo Tool Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\) -``` + +```shell repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v1.1.3-LTS --no-repo-verify repo sync -c repo forall -c 'git lfs pull' @@ -48,166 +28,50 @@ repo forall -c 'git lfs pull' Method 2: Use the **repo** tool to download the source code over HTTPS. -``` +```shell repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v1.1.3-LTS --no-repo-verify repo sync -c repo forall -c 'git lfs pull' ``` -### Acquiring Source Code from Mirrors +### Acquiring Source Code from Mirrors **Table 2** Mirrors for acquiring source code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Source Code

-

Version Information

-

Mirror

-

SHA-256 Checksum

-

Full code base

-

1.1.3

-

Download

-

Download

-

Hi3861 solution (binary)

-

1.1.3

-

Download

-

Download

-

Hi3518 solution (binary)

-

1.1.3

-

Download

-

Download

-

Hi3516 solution (binary)

-

1.1.3

-

Download

-

Download

-

Release Notes

-

1.1.3

-

Download

-

N/A

-
- -## What's New +| Source Code | Version Information | Mirror | SHA-256 Checksum | +| ------------------------ | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Full code base | 1.1.3 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/code-v1.1.3-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/code-v1.1.3-LTS.tar.gz.sha256) | +| Hi3861 solution (binary) | 1.1.3 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/wifiiot-1.1.3.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/wifiiot-1.1.3.tar.gz.sha256) | +| Hi3518 solution (binary) | 1.1.3 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/ipcamera_hi3518ev300-1.1.3.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/ipcamera_hi3518ev300-1.1.3.tar.gz.sha256) | +| Hi3516 solution (binary) | 1.1.3 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/ipcamera_hi3516dv300-1.1.3.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/ipcamera_hi3516dv300-1.1.3.tar.gz.sha256) | +| Release Notes | 1.1.3 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.3/OpenHarmony-Release-Notes-1.1.3-LTS.zip) | N/A | + +## What's New This version inherits all the features of OpenHarmony v1.1.2 and adds the support for version compilation for mini-system devices in the Windows environment. For details, see [Setting Up the Windows Build Environment](https://device.harmonyos.com/en/docs/documentation/guide/ide-install-windows-0000001050164976). **Table 3** Feature updates - - - - - - - - - - - - - -

Subsystem

-

New Feature

-

Modified Feature

-

Deleted Feature

-

Chip platform

-

Supports version compilation for mini-system devices in the Windows environment (pulls/60).

-

N/A

-

N/A

-
- -## Resolved Issues +| Subsystem | New Feature | Modified Feature | Deleted Feature | +| ------------- | ------------------------------------------------------------ | ---------------- | --------------- | +| Chip platform | Supports version compilation for mini-system devices in the Windows environment ([pulls/60](https://gitee.com/openharmony/device_hisilicon_hispark_pegasus/pulls/60)). | N/A | N/A | + +## Resolved Issues The following table lists the known issues with OpenHarmony 1.1.2 that have been resolved in this version. **Table 4** Resolved issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Issue

-

Description

-

I43MZK

-

The release 1.0.1 branch name contains spaces, which does not comply with the external interface standard.

-

I44ZGK

-

The FFmpeg 4.2.2 component has an unfixed vulnerability.

-

I41ZMV

-

After ROM flashing on the Hi3516 chip, the module_ActsUiInterfaceTest1.bin test file exists in the bin directory.

-

I3ZOIO

-

Releasing the los_disk_deinit resource fails.

-

I43WLG

-

Starting OsMountRootfs fails.

-

I48FKQ

-

A value other than 0 is returned when osEventFlagsGet is set to NULL.

-

I48FL1

-

Thread creation fails when attr of the osThreadNew function is set to NULL.

-

I48FLX

-

A system error occurs when the shell command rm -r is run to delete a node under dev.

-

I48FMK

-

The ActsProcessApiTest/UidGidTest/testGetgroup test case of small-system devices fails.

-

I48FMT

-

The implementation of the nanosleep function has a defect.

-
+| Issue No. | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [I43MZK](https://gitee.com/openharmony/startup_syspara_lite/issues/I43MZK?from=project-issue) | The release 1.0.1 branch name contains spaces, which does not comply with the external interface standard. | +| [I44ZGK](https://gitee.com/openharmony/device_hisilicon_third_party_ffmpeg/issues/I44ZGK?from=project-issue) | The FFmpeg 4.2.2 component has an unfixed vulnerability. | +| [I41ZMV](https://gitee.com/openharmony/graphic_utils/issues/I41ZMV?from=project-issue) | After ROM flashing on the Hi3516 chip, the **module_ActsUiInterfaceTest1.bin** test file exists in the **bin** directory. | +| [I3ZOIO](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZOIO?from=project-issue) | Releasing the **los_disk_deinit** resource fails. | +| [I43WLG](https://gitee.com/openharmony/kernel_liteos_a/issues/I43WLG?from=project-issue) | Starting OsMountRootfs fails. | +| [I48FKQ](https://gitee.com/openharmony/kernel_liteos_m/issues/I48FKQ?from=project-issue) | A value other than **0** is returned when **osEventFlagsGet** is set to **NULL**. | +| [I48FL1](https://gitee.com/openharmony/kernel_liteos_m/issues/I48FL1?from=project-issue) | Thread creation fails when **attr** of the **osThreadNew** function is set to **NULL**. | +| [I48FLX](https://gitee.com/openharmony/kernel_liteos_a/issues/I48FLX?from=project-issue) | A system error occurs when the shell command **rm -r** is run to delete a node under **dev**. | +| [I48FMK](https://gitee.com/openharmony/kernel_liteos_a/issues/I48FMK?from=project-issue) | The **ActsProcessApiTest/UidGidTest/testGetgroup** test case of small-system devices fails. | +| [I48FMT](https://gitee.com/openharmony/kernel_liteos_a/issues/I48FMT?from=project-issue) | The implementation of the **nanosleep** function has a defect. | diff --git a/en/release-notes/OpenHarmony-v1.1.2-LTS.md b/en/release-notes/OpenHarmony-v1.1.2-LTS.md index a0ab3c229fd859cc89c4e47d1b7d4e171b5e28eb..8f897f2d83e546c6b31fc1e86e23284a831728c6 100644 --- a/en/release-notes/OpenHarmony-v1.1.2-LTS.md +++ b/en/release-notes/OpenHarmony-v1.1.2-LTS.md @@ -1,109 +1,39 @@ -# OpenHarmony v1.1.2 LTS +# OpenHarmony v1.1.2 LTS -## Overview +## Overview This is an updated long-term support \(LTS\) version of OpenHarmony. It supports more functions and fixes some bugs in OpenHarmony 1.1.1. -## Version Mapping +## Version Mapping **Table 1** Version mapping of software and tools - - - - - - - - - - - - - - - -

Software

-

Version

-

Remarks

-

OpenHarmony

-

1.1.2 LTS

-

N/A

-

(Optional) HUAWEI DevEco Device Tool

-

Deveco DeviceTool 2.2 Beta1

-

Recommended for developing OpenHarmony smart devices

-
+| Software | Version | Remarks | +| ------------------------------------ | --------------------------- | ---------------------------------------------------- | +| OpenHarmony | 1.1.2 LTS | N/A | +| (Optional) HUAWEI DevEco Device Tool | Deveco DeviceTool 2.2 Beta1 | Recommended for developing OpenHarmony smart devices | -## Source Code Acquisition -### Acquiring Source Code from Mirrors +## Source Code Acquisition + +### Acquiring Source Code from Mirrors **Table 2** Mirrors for acquiring source code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Source Code

-

Version Information

-

Mirror

-

SHA-256 Checksum

-

Full code base

-

1.1.2

-

Download

-

Download

-

Hi3861 solution (binary)

-

1.1.2

-

Download

-

Download

-

Hi3518 solution (binary)

-

1.1.2

-

Download

-

Download

-

Hi3516 solution (binary)

-

1.1.2

-

Download

-

Download

-

Release Notes

-

1.1.2

-

Download

-

N/A

-
+| Source Code | Version Information | Mirror | SHA-256 Checksum | +| ------------------------ | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Full code base | 1.1.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/code-v1.1.2-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/code-v1.1.2-LTS.tar.gz.sha256) | +| Hi3861 solution (binary) | 1.1.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/wifiiot-1.1.2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/wifiiot-1.1.2.tar.gz.sha256) | +| Hi3518 solution (binary) | 1.1.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/ipcamera_hi3518ev300-1.1.2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/ipcamera_hi3518ev300-1.1.2.tar.gz.sha256) | +| Hi3516 solution (binary) | 1.1.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/ipcamera_hi3516dv300-1.1.2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/ipcamera_hi3516dv300-1.1.2.tar.gz.sha256) | +| Release Notes | 1.1.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/1.1.2/OpenHarmony-Release-Notes-1.1.2-LTS.zip) | N/A | -### Acquiring Source Code Using the repo Tool +### Acquiring Source Code Using the repo Tool Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\) -``` + +```shell repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v1.1.2-LTS --no-repo-verify repo sync -c repo forall -c 'git lfs pull' @@ -111,246 +41,56 @@ repo forall -c 'git lfs pull' Method 2: Use the **repo** tool to download the source code over HTTPS. -``` +```shell repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v1.1.2-LTS --no-repo-verify repo sync -c repo forall -c 'git lfs pull' ``` -## What's New +## What's New This version inherits all features of OpenHarmony 1.1.1, and adds and optimizes features for different modules based on OpenHarmony 1.1.1. The following table lists the feature updates. **Table 3** Feature updates - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Subsystem

-

New Feature

-

Modified Feature

-

Deleted Feature

-

Graphics

-

Added settings for the slider style.

-

None

-

None

-

Update

-

Added the 3072-bit RSA signature algorithm for update packages.

-

None

-

None

-

Driver

-

Added certain internal OSAL APIs.

-

Optimized the sensor model.

-

None

-

Globalization

-
  • Added data functions such as the digital switch and weekday.
-
  • Added the Get12HourTimeWithoutAmpm API.
-

None

-

None

-
+| Subsystem | New Feature | Modified Feature | Deleted Feature | +| ------------- | ------------------------------------------------------------ | --------------------------- | --------------- | +| Graphics | Added settings for the slider style. | None | None | +| Update | Added the 3072-bit RSA signature algorithm for update packages. | None | None | +| Driver | Added certain internal OSAL APIs. | Optimized the sensor model. | None | +| Globalization | - Added data functions such as the digital switch and weekday.
- Added the **Get12HourTimeWithoutAmpm** API. | None | None | -## Resolved Issues +## Resolved Issues The following table lists the issues known in OpenHarmony 1.1.1 that have been resolved in this version. **Table 4** Resolved issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Subsystem

-

PR NO.

-

Description

-

Application Framework

-

aafwk_aafwk_lite/pulls/35

-

There is a low probability that the Linux system cannot be shut down.

-

-

AI

-

ai_engine/pulls/50

-

The test case for the client is not released.

-

ai_engine/pulls/46

-

Class members are not initialized.

-

IoT Hardware

-

applications_sample_wifi_iot/pulls/12

-

A build fails.

-

Compilation and Building

-

build_lite/pulls/151

-

The test case is not available in the build process.

-

-

-

Chip Platform

-

-

third_party_ffmpeg/pulls/9

-

The CVE-2020-22025 vulnerability is detected.

-

third_party_ffmpeg/pulls/6

-

A build fails due to the dependency on valgrind in some environments.

-

vendor_hisilicon/pulls/39

-

Building the release fails.

-

-

Distributed Scheduler

-

distributedschedule_dms_fwk_lite/pulls/23

-

The test case name is inappropriate.

-

distributedschedule_samgr_lite/pulls/25

-

The CVE-2021-22478 vulnerability is detected.

-

-

Globalization

-

-

global_i18n_lite/pulls/24

-

Resource loading of i18n.dat is defective.

-

third_party_jerryscript/pulls/22

-

There is a possibility that the breakpoint cannot be stopped during debugging of the macOS version.

-

Graphics

-

graphic_ui/pulls/220

-

The Remove function is provided, but the Add function is not. After the modification, the child nodes are not cleared when the UIViewGroup is destructed.

-

graphic_ui/pulls/199

-

The image is not updated after the image path is updated.

-

-

Lite Kernel

-

-

kernel_liteos_a/pulls/385

-

The CVE-2021-22479 vulnerability is detected.

-

kernel_liteos_a/pulls/299

-

There are unnecessary maintenance and test logs of the PRINTK function.

-

third_party_musl/pulls/44

-

The implementation of the srand function for setting random number seeds is inappropriate.

-

Startup

-

startup_syspara_lite/pulls/31

-

The date of the security patch is incorrect.

-

-

Driver

-

drivers_adapter_khdf_linux/pulls/28

-

The CVE-2021-22441 vulnerability is detected.

-

drivers_adapter/pulls/50

-

The CVE-2021-22480 vulnerability is detected.

-

-

-

-

Testing

-

xts_acts/pulls/294

-

Certain test cases of the fs_posix module are unstable.

-

xts_acts/pulls/287

-

The acts test fails.

-

xts_acts/pulls/283

-

Certain CMSIS test cases fail occasionally.

-

xts_acts/pulls/270

-

The ShmTest.testShmatSHM_REMAP function in the ShmTest.cpp test case of the shared_memory module does not run as expected.

-

xts_acts/pulls/314

-

The test of the net_posix module fails.

-
+| Subsystem | PR No. | Description | +| ------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Application Framework | aafwk_aafwk_lite/pulls/35 | There is a low probability that the Linux system cannot be shut down. | +| AI | [ai_engine/pulls/50](https://gitee.com/openharmony/ai_engine/pulls/50) | The test case for the client is not released. | +| AI | [ai_engine/pulls/46](https://gitee.com/openharmony/ai_engine/pulls/46) | Class members are not initialized. | +| IoT Hardware | [applications_sample_wifi_iot/pulls/12](https://gitee.com/openharmony/applications_sample_wifi_iot/pulls/12) | A build fails. | +| Compilation and Building | [build_lite/pulls/151](https://gitee.com/openharmony/build_lite/pulls/151) | The test case is not available in the build process. | +| Chip Platform | [third_party_ffmpeg/pulls/9](https://gitee.com/openharmony/device_hisilicon_third_party_ffmpeg/pulls/9) | The CVE-2020-22025 vulnerability is detected. | +| Chip Platform | [third_party_ffmpeg/pulls/6](https://gitee.com/openharmony/device_hisilicon_third_party_ffmpeg/pulls/6) | A build fails due to the dependency on valgrind in some environments. | +| Chip Platform | [vendor_hisilicon/pulls/39](https://gitee.com/openharmony/vendor_hisilicon/pulls/39) | Building the release fails. | +| Distributed Scheduler | distributedschedule_dms_fwk_lite/pulls/23 | The test case name is inappropriate. | +| Distributed Scheduler | distributedschedule_samgr_lite/pulls/25 | The CVE-2021-22478 vulnerability is detected. | +| Globalization | [global_i18n_lite/pulls/24](https://gitee.com/openharmony/global_i18n_lite/pulls/24) | Resource loading of **i18n.dat** is defective. | +| Globalization | [third_party_jerryscript/pulls/22](https://gitee.com/openharmony/third_party_jerryscript/pulls/22) | There is a possibility that the breakpoint cannot be stopped during debugging of the macOS version. | +| Graphics | [graphic_ui/pulls/220](https://gitee.com/openharmony/graphic_ui/pulls/220) | The Remove function is provided, but the Add function is not. After the modification, the child nodes are not cleared when the **UIViewGroup** is destructed. | +| Graphics | [graphic_ui/pulls/199](https://gitee.com/openharmony/graphic_ui/pulls/199) | The image is not updated after the image path is updated. | +| Lite Kernel | [kernel_liteos_a/pulls/385](https://gitee.com/openharmony/kernel_liteos_a/pulls/385) | The CVE-2021-22479 vulnerability is detected. | +| Lite Kernel | [kernel_liteos_a/pulls/299](https://gitee.com/openharmony/kernel_liteos_a/pulls/299) | There are unnecessary maintenance and test logs of the PRINTK function. | +| Lite Kernel | [third_party_musl/pulls/44](https://gitee.com/openharmony/third_party_musl/pulls/44) | The implementation of the srand function for setting random number seeds is inappropriate. | +| Startup | [startup_syspara_lite/pulls/31](https://gitee.com/openharmony/startup_syspara_lite/pulls/31) | The date of the security patch is incorrect. | +| Driver | [drivers_adapter_khdf_linux/pulls/28](https://gitee.com/openharmony/drivers_adapter_khdf_linux/pulls/28) | The CVE-2021-22441 vulnerability is detected. | +| Driver | [drivers_adapter/pulls/50](https://gitee.com/openharmony/drivers_adapter/pulls/50) | The CVE-2021-22480 vulnerability is detected. | +| Testing | [xts_acts/pulls/294](https://gitee.com/openharmony/xts_acts/pulls/294) | Certain test cases of the fs_posix module are unstable. | +| Testing | [xts_acts/pulls/287](https://gitee.com/openharmony/xts_acts/pulls/287) | The acts test fails. | +| Testing | [xts_acts/pulls/283](https://gitee.com/openharmony/xts_acts/pulls/283) | Certain CMSIS test cases fail occasionally. | +| Testing | [xts_acts/pulls/270](https://gitee.com/openharmony/xts_acts/pulls/270) | The ShmTest.testShmatSHM_REMAP function in the ShmTest.cpp test case of the shared_memory module does not run as expected. | +| Testing | [xts_acts/pulls/314](https://gitee.com/openharmony/xts_acts/pulls/314) | The test of the net_posix module fails. | diff --git a/en/release-notes/OpenHarmony-v2.2-beta2.md b/en/release-notes/OpenHarmony-v2.2-beta2.md index c1a9b2d97442ca4609ffd3ad21bce33371bcc859..cfa49a7202091c9e6d068dff91b11fd1ca470c98 100644 --- a/en/release-notes/OpenHarmony-v2.2-beta2.md +++ b/en/release-notes/OpenHarmony-v2.2-beta2.md @@ -1,6 +1,6 @@ -# OpenHarmony v2.2 Beta2 +# OpenHarmony v2.2 Beta2 -## Version Description +## Version Description This release provides new and enhanced features for the mini system, small system, and standard system based on OpenHarmony 2.0 Canary. @@ -18,42 +18,15 @@ The feature updates for the mini system and small system are as follows: - Enhanced the design for X \(DFX\) capabilities, including enhanced HiLog and HiEvent features, a lightweight tool to dump system information, and the maintenance and test framework upon system restart. - Enhanced the AI capabilities, including Linux kernel adaptation and support for shared memory-based data transmission by the AI engine. -## Version Mapping +## Version Mapping **Table 1** Version mapping of software and tools - - - - - - - - - - - - - - - - - - - -

Software

-

Version

-

Remarks

-

OpenHarmony

-

2.2 Beta2

-

N/A

-

(Optional) HUAWEI DevEco Studio

-

DevEco Studio 2.2 Beta1

-

Recommended for developing OpenHarmony apps

-

(Optional) HUAWEI DevEco Device Tool

-

Deveco DeviceTool 2.2 Beta1

-

Recommended for developing OpenHarmony smart devices

-
+| Software | Version | Remarks | +| ------------------------------------ | --------------------------- | ---------------------------------------------------- | +| OpenHarmony | 2.2 Beta2 | N/A | +| (Optional) HUAWEI DevEco Studio | DevEco Studio 2.2 Beta1 | Recommended for developing OpenHarmony apps | +| (Optional) HUAWEI DevEco Device Tool | Deveco DeviceTool 2.2 Beta1 | Recommended for developing OpenHarmony smart devices | ## Source Code Acquisition @@ -62,7 +35,8 @@ The feature updates for the mini system and small system are as follows: **Method 1 (recommended)**: Use the **repo** tool to download the source code over SSH. (You must have registered an SSH public key for access to Gitee.) -``` + +```shell repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v2.2-Beta2 --no-repo-verify repo sync -c repo forall -c 'git lfs pull' @@ -70,7 +44,8 @@ repo forall -c 'git lfs pull' **Method 2**: Use the **repo** tool to download the source code over HTTPS. -``` + +```shell repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v2.2-Beta2 --no-repo-verify repo sync -c repo forall -c 'git lfs pull' @@ -81,180 +56,44 @@ repo forall -c 'git lfs pull' **Table 2** Mirrors for acquiring source code -| Source Code | Version | Mirror | SHA-256 Checksum | +| Source Code | Version | Mirror | SHA-256 Checksum | | -------- | -------- | -------- | -------- | -| Full code (for mini, small, and standard systems) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/code-v2.2-beta2_20210730.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/code-v2.2-beta2_20210730.tar.gz.sha256) | -| Standard system solution (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/standard-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/standard-2.2-Beta2.tar.gz.sha256) | -| Hi3861 solution (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_pegasus-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_pegasus-2.2-Beta2.tar.gz.sha256) | -| Hi3518 solution (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_aries-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_aries-2.2-Beta2.tar.gz.sha256) | -| Hi3516 solution-LiteOS (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus-2.2-Beta2.tar.gz.sha256) | -| Hi3516 solution-Linux (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus_linux-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus_linux-2.2-Beta2.tar.gz.sha256) | -| Release Notes | 2.2 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v2.2-beta2.md) | - | +| Full code (for mini, small, and standard systems) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/code-v2.2-beta2_20210730.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/code-v2.2-beta2_20210730.tar.gz.sha256) | +| Standard system solution (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/standard-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/standard-2.2-Beta2.tar.gz.sha256) | +| Hi3861 solution (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_pegasus-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_pegasus-2.2-Beta2.tar.gz.sha256) | +| Hi3518 solution (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_aries-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_aries-2.2-Beta2.tar.gz.sha256) | +| Hi3516 solution-LiteOS (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus-2.2-Beta2.tar.gz.sha256) | +| Hi3516 solution-Linux (binary) | 2.2 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus_linux-2.2-Beta2.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.2-Beta2/hispark_taurus_linux-2.2-Beta2.tar.gz.sha256) | +| Release Notes | 2.2 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v2.2-beta2.md) | - | -## What's New +## What's New This release provides the following new and enhanced features based on OpenHarmony 2.0 Canary. **Table 3** New and enhanced features - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Subsystem

-

Standard System

-

Mini and Small Systems

-

Distributed File

-

Provided JS APIs in the system.file class for asynchronous file operations, including file read/write, directory access, and directory addition/deletion.

-

NA

-

Driver

-

3QE85: Added the audio, camera, USB, motor, and Analog to Digital Converter (ADC) driver models.

-

Enabled LiteOS-M to support the Hardware Driver Foundation (HDF).

-

Power Management

-

Added the system power state machine, running lock, and sleep/wakeup features.

-
  • Added the APIs for querying the battery charging/discharging status and the battery level.
  • Added the support for the low-power mode with unified APIs.
-

Update

-

Added the feature of restoring factory settings.

-

NA

-

Media

-
  • Added the audio service to provide basic audio control.
  • Added the camera service to provide basic functions such as preview and photographing.
  • Added the media service to support audio and video playback.
-

NA

-

JS UI Framework

-

Added support for the hybrid use of both JS and C/C++ for JS API development.

-

NA

-

Event Notification

-

Enabled applications to locally send and cancel a notification that includes multiple lines of text.

-

NA

-

DSoftBus

-

Added self-networking for DSoftBus. After a trusted device is connected to a LAN (either through Ethernet or Wi-Fi), the device can be automatically detected and connected to the DSoftBus. The device is not aware of this connection.

-

NA

-

Distributed Data Management

-
  • Added distributed data management to support locally encrypted storage of distributed databases.
  • Added support for lightweight preferences databases.
-
  • Implemented data deletion from databases.
  • Added unified functions to operate the Hardware Abstraction Layer (HAL) file system.
  • Implemented atomic operations related to data storage.
  • Implemented read/write of binary values.
-

System Apps

-

Home screen:

-
  • Optimized UX for the home screen setting page.
  • Added support for icon dragging on the home screen.
-

Settings:

-
  • Added WLAN settings.
-

SystemUI:

-
  • Implemented the display of the signal icon of SIM cards.
-

Photos:

-
  • Added the features of viewing, moving, copying, deleting, and renaming images and videos.
-

NA

-

Globalization

-
  • Optimized time and date formatting.
  • Added support for time segment formatting.
  • Added support for number formatting.
-
  • Added custom data compilation.
  • Added internationalization for the week, singular and plural forms, and numbers.
  • Added the mechanism for parsing and loading build resources.
  • Added the build resource backtracking mechanism.
-

Sample Apps

-
  • Added the distributed calculator feature, which allows the calculator on one device to start the calculator on another networked device to perform collaborative calculation and synchronize the calculation data in real time.
  • Added the audio player app that supports audio playback on any networked devices.
-

NA

-

Distributed Device Management

-

Added the device management system service that provides authentication and networking irrelevant to distributed device accounts.

-

NA

-

DFX

-

NA

-
  • Provided a tool to dump LiteOS kernel information.
  • Implemented a maintenance and test framework for the LiteOS kernel upon restarting after a breakdown.
  • Added number formatting.
  • Enhanced HiLog.
  • Enhanced HiEvent.
-

Kernel

-

NA

-
  • Added support for the lightweight Linux version.
  • Enhanced support for the proc file system.
  • Added the mksh command interpreter.
  • Enhanced file system maintenance and testing.
  • Added support for configuration of LiteOS-A kernel modules.
  • Enabled the LiteOS-A small system to adapt to third-party chips.
  • Enabled LiteOS-M to support Mbed TLS compilation of third-party components.
  • Enabled LiteOS-M to support Curl compilation of third-party components.
  • Added support for the lightweight shell framework and common debugging commands.
  • Enabled LiteOS-M to support the ARM9 architecture.
  • Added support for the little file system (LittleFS) setup on the NOR flash.
  • Enabled LiteOS-M to provide unified file system operation APIs for external systems.
  • Added the Namecache, Vnode, and Lookup modules.
-

Graphics

-

NA

-
  • Added support for input of A4, A8, LUT8, and TSC images.
  • Added support for multi-language text alignment.
  • Added component outline display for UIKit.
  • Enabled the ScrollView or List component to display the swiping progress using an arc progress bar.
  • Implemented animation for the switch, check box, and radio button.
  • Enabled UIKit to support the decoupling of dot-matrix fonts from products.
  • Provided a unified multi-backend framework to support multiple chip platforms.
  • Enabled UIKit to support margin and padding.
  • Implemented zoom and white layer animations for the round and capsule buttons.
-

Compilation and Building

-

NA

-

Added support for the general patch framework of open-source software.

-

Startup

-

NA

-

Added support for factory setting restoration and multi-language text alignment.

-

Distributed Scheduler

-

NA

-

Added support for the start of an ability on the rich device from a mini-system device.

-

AI

-

NA

-
  • Added support for Linux kernel adaptation with related compilation options.
  • Enabled shared memory-based data transmission.
-
+| Subsystem | Standard System | Mini and Small Systems | +| ----------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Distributed File | Provided JS APIs in the **system.file** class for asynchronous file operations, including file read/write, directory access, and directory addition/deletion. | NA | +| Driver | Added the audio, camera, USB, motor, and Analog to Digital Converter (ADC) driver models. | Enabled LiteOS-M to support the Hardware Driver Foundation (HDF). | +| Power Management | Added the system power state machine, running lock, and sleep/wakeup features. | - Added the APIs for querying the battery charging/discharging status and the battery level.
- Added the support for the low-power mode with unified APIs. | +| Update | Added the feature of restoring factory settings. | NA | +| Media | - Added the audio service to provide basic audio control.
- Added the camera service to provide basic functions such as preview and photographing.
- Added the media service to support audio and video playback. | NA | +| JS UI Framework | Added support for the hybrid use of both JS and C/C++ for JS API development. | NA | +| Common Event and Notification | Enabled applications to locally send and cancel a notification that includes multiple lines of text. | NA | +| DSoftBus | Added self-networking for DSoftBus. After a trusted device is connected to a LAN (either through Ethernet or Wi-Fi), the device can be automatically detected and connected to the DSoftBus. The device is not aware of this connection. | NA | +| Distributed Data Management | - Added distributed data management to support locally encrypted storage of distributed databases.
- Added support for lightweight preferences databases. | - Implemented data deletion from databases.
- Added unified functions to operate the Hardware Abstraction Layer (HAL) file system.
- Implemented atomic operations related to data storage.
- Implemented read/write of binary values. | +| System Apps | Home screen:
- Optimized UX for the home screen setting page.
- Added support for icon dragging on the home screen.
Settings:
- Added WLAN settings.
SystemUI:
- Implemented the display of the signal icon of SIM cards.
Photos:
- Added the features of viewing, moving, copying, deleting, and renaming images and videos. | NA | +| Globalization | - Optimized time and date formatting.
- Added support for time segment formatting.
- Added support for number formatting. | - Added custom data compilation.
- Added internationalization for the week, singular and plural forms, and numbers.
- Added the mechanism for parsing and loading build resources.
- Added the build resource backtracking mechanism. | +| Sample Apps | - Added the distributed calculator feature, which allows the calculator on one device to start the calculator on another networked device to perform collaborative calculation and synchronize the calculation data in real time.
- Added the audio player app that supports audio playback on any networked devices. | NA | +| Distributed Device Management | Added the device management system service that provides authentication and networking irrelevant to distributed device accounts. | NA | +| DFX | NA | - Provided a tool to dump LiteOS kernel information.
- Implemented a maintenance and test framework for the LiteOS kernel upon restarting after a breakdown.
- Added number formatting.
- Enhanced HiLog.
- Enhanced HiEvent. | +| Kernel | NA | - Added support for the lightweight Linux version.
- Enhanced support for the proc file system.
- Added the mksh command interpreter.
- Enhanced file system maintenance and testing.
- Added support for configuration of LiteOS-A kernel modules.
- Enabled the LiteOS-A small system to adapt to third-party chips.
- Enabled LiteOS-M to support Mbed TLS compilation of third-party components.
- Enabled LiteOS-M to support Curl compilation of third-party components.
- Added support for the lightweight shell framework and common debugging commands.
- Enabled LiteOS-M to support the ARM9 architecture.
- Added support for the little file system (LittleFS) setup on the NOR flash.
- Enabled LiteOS-M to provide unified file system operation APIs for external systems.
- Added the Namecache, Vnode, and Lookup modules. | +| Graphics | NA | - Added support for input of A4, A8, LUT8, and TSC images.
- Added support for multi-language text alignment.
- Added component outline display for UIKit.
- Enabled the **ScrollView** or **List** component to display the swiping progress using an arc progress bar.
- Implemented animation for the switch, check box, and radio button.
- Enabled UIKit to support the decoupling of dot-matrix fonts from products.
- Provided a unified multi-backend framework to support multiple chip platforms.
- Enabled UIKit to support margin and padding.
- Implemented zoom and white layer animations for the round and capsule buttons. | +| Compilation and Building | NA | Added support for the general patch framework of open-source software. | +| Startup | NA | Added support for factory setting restoration and multi-language text alignment. | +| Distributed Scheduler | NA | Added support for the start of an ability on the rich device from a mini-system device. | +| AI | NA | - Added support for Linux kernel adaptation with related compilation options.
- Enabled shared memory-based data transmission. | ### API Updates @@ -264,112 +103,28 @@ For details, see: - [Native API Differences](api-change/v2.2-beta2/native-apidiff-v2.2-beta2.md) -## Resolved Issues +## Resolved Issues **Table 4** **Resolved issues** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Issue No.

-

Description

-

I3I31W

-

ActsNFSTest.bin causes a kernel crash.

-

I3D49E

-

The U-Boot path is incorrect.

-

I3D71U

-

[Driver subsystem] During repeated system reset, there is a high possibility that the system is suspended after successful hmac_main_init startup.

-

I3DGZW

-

[Application Framework subsystem] After the Hi3516 development board enters screen saver mode, a blue screen is displayed upon a tap on the touchscreen.

-

I3DHIL

-

[System] The remaining space of the Hi3518 development board is insufficient, causing a failure in executing a large number of ACTS test cases.

-

I3DU36

-

[Application Framework subsystem] The query command ipcamera bm does not take effect.

-

I3EALU

-

[Media subsystem] During the execution of the cameraActs test case, the camera configuration file cannot be found and the initialization fails.

-

I3EGUX

-

[Reliability] When the KIdle process crashes once during repeated system reset, the system is suspended and cannot be started.

-

I3EH4E

-

[Pipeline] There is a high probability that the system does not respond after the uname and reset commands are executed.

-

I3EQJA

-

[File system] The cat /proc/mounts command does not take effect.

-

I3EQRC

-

The system crashes when three concurrent test processes are run during disk file mapping delay testing.

-

I3HVL0

-

The Hi3861 development board compilation fails and the error message "[OHOS ERROR] Fatal error: invalid -march= option:rv32imac" is displayed.

-

I3TS1Y

-

File-specific Vnode resources are exhausted in stress testing.

-

I3TXT8

-

Orphan processes cannot be reclaimed, and TCB resources are exhausted in stress testing.

-

I3UWXI

-

The libwap.so file is prone to the following vulnerability: CVE-2021-30004, CVSS: 5.3, released on 2021-04-02.

-

I3SWY2

-

There is a high probability that the KProcess is suspended.

-

I3YJRO

-

The compilation of configurable LiteOS-A kernel modules fails.

-

I3YNWM

-

The enhanced file system maintenance and test feature is defective.

-

I3VEOG

-

The bin directory does not contain the mksh and toybox commands, leading to a failure to test the toybox command set.

-
- +| Issue No. | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [I3I31W](https://gitee.com/openharmony/kernel_liteos_a/issues/I3I31W) | **ActsNFSTest.bin** causes a kernel crash. | +| [I3D49E](https://gitee.com/openharmony/docs/issues/I3D49E) | The U-Boot path is incorrect. | +| [I3D71U](https://gitee.com/openharmony-retired/drivers_adapter_khdf_liteos/issues/I3D71U) | Driver subsystem] During repeated system reset, there is a high possibility that the system is suspended after successful **hmac_main_init** startup. | +| I3DGZW | [Application Framework subsystem] After the Hi3516 development board enters screen saver mode, a blue screen is displayed upon a tap on the touchscreen. | +| [I3DHIL](https://gitee.com/openharmony/community/issues/I3DHIL) | [System] The remaining space of the Hi3518 development board is insufficient, causing a failure in executing a large number of ACTS test cases. | +| I3DU36 | [Application Framework subsystem] The query command **ipcamera bm** does not take effect. | +| [I3EALU](https://gitee.com/openharmony/multimedia_camera_lite/issues/I3EALU) | [Multimedia subsystem] During the execution of the **cameraActs** test case, the camera configuration file cannot be found and the initialization fails. | +| [I3EGUX](https://gitee.com/openharmony/release-management/issues/I3EGUX) | [Reliability] When the KIdle process crashes once during repeated system reset, the system is suspended and cannot be started. | +| [I3EH4E](https://gitee.com/openharmony/community/issues/I3EH4E) | [Pipeline] There is a high probability that the system does not respond after the **uname** and **reset** commands are executed. | +| [I3EQJA](https://gitee.com/openharmony/kernel_liteos_a/issues/I3EQJA) | [File system] The **cat /proc/mounts** command does not take effect. | +| [I3EQRC](https://gitee.com/openharmony/kernel_liteos_a/issues/I3EQRC) | The system crashes when three concurrent test processes are run during disk file mapping delay testing. | +| [I3HVL0](https://gitee.com/openharmony/docs/issues/I3HVL0) | The Hi3861 development board compilation fails and the error message "[OHOS ERROR] Fatal error: invalid -march= option:rv32imac" is displayed. | +| [I3TS1Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TS1Y) | File-specific Vnode resources are exhausted in stress testing. | +| [I3TXT8](https://gitee.com/openharmony/startup_init_lite/issues/I3TXT8) | Orphan processes cannot be reclaimed, and TCB resources are exhausted in stress testing. | +| [I3UWXI](https://gitee.com/openharmony/applications_sample_wifi_iot/issues/I3UWXI) | The **libwap.so** file is prone to the following vulnerability: CVE-2021-30004, CVSS: 5.3, released on 2021-04-02. | +| [I3SWY2](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SWY2) | There is a high probability that the KProcess is suspended. | +| [I3YJRO](https://gitee.com/openharmony/kernel_liteos_m/issues/I3YJRO) | The compilation of configurable LiteOS-A kernel modules fails. | +| [I3YNWM](https://gitee.com/openharmony/kernel_liteos_a/issues/I3YNWM) | The enhanced file system maintenance and test feature is defective. | +| [I3VEOG](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VEOG) | The **bin** directory does not contain the **mksh** and **toybox** commands, leading to a failure to test the **toybox** command set. | diff --git a/en/release-notes/OpenHarmony-v3.0-LTS.md b/en/release-notes/OpenHarmony-v3.0-LTS.md index 7db0fb909f89c9268f59694a2cb64958e7493390..a7f029ed5010e3df2f07787e4dfe8b22666ab1b5 100644 --- a/en/release-notes/OpenHarmony-v3.0-LTS.md +++ b/en/release-notes/OpenHarmony-v3.0-LTS.md @@ -45,11 +45,11 @@ The feature updates for the mini and small systems are as follows: **Table 1** Version mapping of software and tools -| Software| Version| Remarks| +| Software| Version| Remarks| | -------- | -------- | -------- | -| OpenHarmony | 3.0 LTS | N/A| -| (Optional) HUAWEI DevEco Studio| 3.0 Beta1 | Recommended for developing OpenHarmony applications| -| (Optional) HUAWEI DevEco Device Tool| 2.2 Beta2 | Recommended for developing OpenHarmony smart devices| +| OpenHarmony | 3.0 LTS | N/A| +| (Optional) HUAWEI DevEco Studio| 3.0 Beta1 | Recommended for developing OpenHarmony applications| +| (Optional) HUAWEI DevEco Device Tool| 2.2 Beta2 | Recommended for developing OpenHarmony smart devices| ## Source Code Acquisition @@ -59,7 +59,8 @@ The feature updates for the mini and small systems are as follows: **Method 1 (recommended)**: Use the **repo** tool to download the source code over SSH. (You must have registered an SSH public key for access to Gitee.) -``` + +```shell repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.0-LTS --no-repo-verify repo sync -c repo forall -c 'git lfs pull' @@ -67,7 +68,8 @@ repo forall -c 'git lfs pull' **Method 2**: Use the **repo** tool to download the source code over HTTPS. -``` + +```shell repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.0-LTS --no-repo-verify repo sync -c repo forall -c 'git lfs pull' @@ -78,15 +80,15 @@ repo forall -c 'git lfs pull' **Table 2** Mirrors for acquiring source code -| LTS Code | Version Information | Mirror | SHA-256 Checksum | +| LTS Code | Version Information | Mirror | SHA-256 Checksum | | -------- | -------- | -------- | -------- | -| Full code (for mini, small, and standard systems) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/code-v3.0-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/code-v3.0-LTS.tar.gz.sha256) | -| Standard system solution (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/standard.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/standard.tar.gz.sha256) | -| Hi3861 solution (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_pegasus.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_pegasus.tar.gz.sha256) | -| Hi3518 solution (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_aries.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_aries.tar.gz.sha256) | -| Hi3516 solution-LiteOS (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus.tar.gz.sha256) | -| Hi3516 solution-Linux (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus_linux.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus_linux.tar.gz.sha256) | -| Release Notes | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v3.0-LTS.md) | - | +| Full code (for mini, small, and standard systems) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/code-v3.0-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/code-v3.0-LTS.tar.gz.sha256) | +| Standard system solution (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/standard.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/standard.tar.gz.sha256) | +| Hi3861 solution (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_pegasus.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_pegasus.tar.gz.sha256) | +| Hi3518 solution (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_aries.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_aries.tar.gz.sha256) | +| Hi3516 solution-LiteOS (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus.tar.gz.sha256) | +| Hi3516 solution-Linux (binary) | 3.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus_linux.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus_linux.tar.gz.sha256) | +| Release Notes | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v3.0-LTS.md) | N/A | @@ -99,28 +101,28 @@ This version has the following updates to OpenHarmony 2.2 Beta2. **Table 3** New and enhanced features -| Subsystem| Standard System| Mini and Small Systems| +| Subsystem| Standard System| Mini and Small Systems| | -------- | -------- | -------- | -| Distributed Scheduler| - Remote Service ability binding is supported.
- Cross-device FA migration is supported.
- Permission verification is added for the visible attribute of a component. | The small system can now start HarmonyOS abilities.| -| Graphics| For chip platforms with GPU modules, GPUs can be used for rendering and composition to improve graphics performance and reduce CPU load.| N/A| -| Distributed Hardware| - The formal PIN authentication scheme based on DSoftBus authentication channels is supported.
- A pop-up window is displayed for PIN authentication.
- A pop-up window is displayed to show a PIN.
- A pop-up window is displayed for the user to enter a PIN.| N/A| -| Event Notification| - Application notification subscription and unsubscription are supported.
- Local text and picture-attached notifications can be published or canceled on the application side.
- Application notification redirection is supported.
- Notification slots can be added or removed on the application side.
- Notification flow control and death monitor are supported.| N/A| -| DSoftBus| DSoftBus:
- CoAP-based active discovery and passive discovery are supported, and active discovery and connection through BLE are supported.
- WLAN-based manual network access and self-networking are supported.
- WLAN-based message, byte, and file transfer is supported.
IPC:
- Intra-device IPC based on Linux kernel's binder protocol is supported.
- Object-oriented data communication and serialized data communication are supported.
RPC:
- Inter-device IPC based on DSoftBus is supported.
- Object-oriented data communication and serialized data communication are supported.
- The APIs are the same as those of the IPC.| DSoftBus:
- CoAP-based active discovery and passive discovery are supported.
- WLAN-based manual network access and self-networking are supported.
- WLAN-based message, byte, and file transfer is supported.
IPC:
- Intra-device IPC based on the Linux/LiteOS kernel's binder protocol is supported.
- Serialized communication of char/int/long data APIs is supported.| -| Globalization| The capability of obtaining the language, region, and locale information configured in the system and obtaining the localized names of the language and region.| The lightweight globalization capability is enhanced to support 31 more languages.| -| System Applications| - Home Screen: A new architecture is introduced.
- SystemUI:
  - Notification center and common text notification are optimized.
  - WLAN, airplane mode, brightness adjustment, and volume adjustment in the Control Panel are optimized.
  - A new architecture is introduced.
- Settings: A new architecture is introduced.
- Camera:
  - Photographing and video recording are supported.
  - Distributed collaboration: Users can now start the peer camera to take photos.| N/A| -| Multi-language Runtime| The ARK JS compiler toolchain and runtime are added, and the OpenHarmony JS UI framework application development and running are also supported.| N/A| -| Media| - The video recording function is added to the camera module.
- The audio recording API is added. | MP3 files can be played.| -| JS UI Framework| - Migration-related lifecycle management is supported.
- Pop-up windows are added for system services.
- JS can be used to develop Service and Data abilities.| N/A| -| Kernel| OpenHarmony Common Linux Kernel 5.10 is supported.| OpenHarmony Common Linux Kernel 5.10 is supported for the small system.| -| DFX | - JS APIs are added for HiAppEvent event logging.
- The HiCollie suspension detection framework is provided.
- The HiTrace distributed call chain basic library is provided.| N/A| -| Driver| The I2S, gyroscope, pressure, and Hall driver models are added.| N/A| -| Security| In the distributed networking of standard-system devices, permission verification is provided for applications to access peer-end resources or capabilities.| The permission attribute field and its write interface are added for the mini system. Upper-layer applications can use this field to implement related services. (When a pop-up window is used to request authorization, no dialog box is displayed after the user rejects the authorization.)| -| Telephony Service| - Network search module: supports airplane mode setting, network search mode setting (manual and automatic network search), and LTE signal strength retrieval.
- SIM module: supports PIN/PUK unlocking, SIM card file information retrieval, card account information storage and retrieval, and card status retrieval.
- Cellular call module: supports foreground/background switchover, incoming call muting, call holding and resuming, three-party call, and DTMF.
- SMS and MMS modules: support addition, deletion, modification, and query of SMS and MMS messages on the SIM card.| N/A| -| Distributed File| - Mounting of partitions with different parameter settings is supported for the F2FS and EXT4 file systems.
- Secure file access is supported, which means that a file object can be converted into a URI and a URI can be parsed to open a file.
- System applications can now access public directories.| N/A| -| Distributed Data Management| - Basic JS capabilities (such as adding, deleting, modifying, and querying) are added for relational databases.
- Basic JS capabilities (such as adding, deleting, modifying, and querying) are added for distributed data management.| N/A| -| Compilation and Building| - Compilation of ARM64 products is supported.
- Compilation of ohos-sdk is supported.| N/A| -| Application Framework| - JS based Service ability development is supported.
- JS based Data ability development is supported.
- The HAP supports multiple ability statements.
- Ability migration to a remote device is supported.
- The application task stack can be saved and restored.
- JS JS can now use ZIP Library to compress and decompress files.| N/A| -| Misc Services| The timer capability and the scheduled time zone management capability are supported.| N/A| +| Distributed Scheduler| - Remote Service ability binding is supported.
- Cross-device FA migration is supported.
- Permission verification is added for the visible attribute of a component. | The small system can now start HarmonyOS abilities.| +| Graphics| For chip platforms with GPU modules, GPUs can be used for rendering and composition to improve graphics performance and reduce CPU load.| N/A| +| Distributed Hardware| - The formal PIN authentication scheme based on DSoftBus authentication channels is supported.
- A pop-up window is displayed for PIN authentication.
- A pop-up window is displayed to show a PIN.
- A pop-up window is displayed for the user to enter a PIN.| N/A| +| Event Notification| - Application notification subscription and unsubscription are supported.
- Local text and picture-attached notifications can be published or canceled on the application side.
- Application notification redirection is supported.
- Notification slots can be added or removed on the application side.
- Notification flow control and death monitor are supported.| N/A| +| DSoftBus| DSoftBus:
- CoAP-based active discovery and passive discovery are supported, and active discovery and connection through BLE are supported.
- WLAN-based manual network access and self-networking are supported.
- WLAN-based message, byte, and file transfer is supported.
IPC:
- Intra-device IPC based on Linux kernel's binder protocol is supported.
- Object-oriented data communication and serialized data communication are supported.
RPC:
- Inter-device IPC based on DSoftBus is supported.
- Object-oriented data communication and serialized data communication are supported.
- The APIs are the same as those of the IPC.| DSoftBus:
- CoAP-based active discovery and passive discovery are supported.
- WLAN-based manual network access and self-networking are supported.
- WLAN-based message, byte, and file transfer is supported.
IPC:
- Intra-device IPC based on the Linux/LiteOS kernel's binder protocol is supported.
- Serialized communication of char/int/long data APIs is supported.| +| Globalization| The capability of obtaining the language, region, and locale information configured in the system and obtaining the localized names of the language and region.| The lightweight globalization capability is enhanced to support 31 more languages.| +| System Applications| - Home Screen: A new architecture is introduced.
- SystemUI:
  - Notification center and common text notification are optimized.
  - WLAN, airplane mode, brightness adjustment, and volume adjustment in the Control Panel are optimized.
  - A new architecture is introduced.
- Settings: A new architecture is introduced.
- Camera:
  - Photographing and video recording are supported.
  - Distributed collaboration: Users can now start the peer camera to take photos.| N/A| +| Multi-language Runtime| The ARK JS compiler toolchain and runtime are added, and the OpenHarmony JS UI framework application development and running are also supported.| N/A| +| Media| - The video recording function is added to the camera module.
- The audio recording API is added. | MP3 files can be played.| +| JS UI Framework| - Migration-related lifecycle management is supported.
- Pop-up windows are added for system services.
- JS can be used to develop Service and Data abilities.| N/A| +| Kernel| OpenHarmony Common Linux Kernel 5.10 is supported.| OpenHarmony Common Linux Kernel 5.10 is supported for the small system.| +| DFX | - JS APIs are added for HiAppEvent event logging.
- The HiCollie suspension detection framework is provided.
- The HiTrace distributed call chain basic library is provided.| N/A| +| Driver| The I2S, gyroscope, pressure, and Hall driver models are added.| N/A| +| Security| In the distributed networking of standard-system devices, permission verification is provided for applications to access peer-end resources or capabilities.| The permission attribute field and its write interface are added for the mini system. Upper-layer applications can use this field to implement related services. (When a pop-up window is used to request authorization, no dialog box is displayed after the user rejects the authorization.)| +| Telephony Service| - Network search module: supports airplane mode setting, network search mode setting (manual and automatic network search), and LTE signal strength retrieval.
- SIM module: supports PIN/PUK unlocking, SIM card file information retrieval, card account information storage and retrieval, and card status retrieval.
- Cellular call module: supports foreground/background switchover, incoming call muting, call holding and resuming, three-party call, and DTMF.
- SMS and MMS modules: support addition, deletion, modification, and query of SMS and MMS messages on the SIM card.| N/A| +| Distributed File| - Mounting of partitions with different parameter settings is supported for the F2FS and EXT4 file systems.
- Secure file access is supported, which means that a file object can be converted into a URI and a URI can be parsed to open a file.
- System applications can now access public directories.| N/A| +| Distributed Data Management| - Basic JS capabilities (such as adding, deleting, modifying, and querying) are added for relational databases.
- Basic JS capabilities (such as adding, deleting, modifying, and querying) are added for distributed data management.| N/A| +| Compilation and Building| - Compilation of ARM64 products is supported.
- Compilation of ohos-sdk is supported.| N/A| +| Application Framework| - JS based Service ability development is supported.
- JS based Data ability development is supported.
- The HAP supports multiple ability statements.
- Ability migration to a remote device is supported.
- The application task stack can be saved and restored.
- JS JS can now use ZIP Library to compress and decompress files.| N/A| +| Misc Services| The timer capability and the scheduled time zone management capability are supported.| N/A| ### API Updates @@ -137,46 +139,46 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op **Table 4** Issues resolved for mini and small systems -| Issue No.| Description| +| Issue No.| Description| | -------- | -------- | -| [I45AVP](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I45AVP) | The **hilog** command fails to be executed after a flush operation.| -| [I47EPA](https://gitee.com/openharmony/appexecfwk_appexecfwk_lite/issues/I47EPA?from=project-issue) | **GetBundleSize** returns an error when the input parameter is null or invalid.| -| [I434AD](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434AD) | For Hi3516DV300, the resident memory of the mini system exceeds the baseline.| -| [I434P1](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434P1) | For Hi3518EV300, the resident memory of the mini system exceeds the baseline.| -| [I46I6K](https://gitee.com/openharmony/multimedia_media_lite/issues/I46I6K?from=project-issue) | There are security coding defects in the code of the multimedia subsystem.| -| [I46E6S](https://gitee.com/openharmony/kernel_liteos_m/issues/I46E6S?from=project-issue) | The **-Werror** compilation option is unavailable for the lightweight kernel module compilation.| -| [I47ETO](https://gitee.com/openharmony/appexecfwk_appexecfwk_lite/issues/I47ETO?from=project-issue -) | The permission verification does not take effect. When the test .bin file is used to invoke the HAP that has not obtained the **ohos.permission.GET_BUNDLE_INFO** permission, the query is successful. The expected result is a query failure with **0** returned.| -| [I48A2I](https://gitee.com/openharmony/drivers_peripheral/issues/I48A2I) | The board is suspended when the Hi3516DV300 lightweight version calls **AllocMem**.| -| [I42LCU](https://gitee.com/openharmony/kernel_liteos_m/issues/I42LCU) | The method of checking thread insufficiency and the method of configuring the number of threads are unavailable in the integration test and development board migration guide.| -| [I3IPD7](https://gitee.com/openharmony/kernel_liteos_m/issues/I3IPD7) | A description indicating that the **osThreadExit** and **join** functions are not supported is missing in the header file.| -| [I3M12H](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M12H) | During the integration test, two different signals are sent, but **sigwait** receives the first signal twice.| -| [I47X2Z](https://gitee.com/openharmony/kernel_liteos_a/issues/I47X2Z?from=project-issue) | When the **ActsIpcShmTest.bin** script is executed during the integration test, a large amount of shared memory is not released.| -| [I4BL3S](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BL3S) | When the **nfs** cases of the fs_posix module are executed multiple times during the integration test, the message indicating a failure to apply for memory is repeatedly printed.| -| [I490KZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I490KZ) | The **FutexTest.testPthreadTimdOutRWlockWR** case fails to be executed.| -| [I44SFO](https://gitee.com/openharmony/third_party_toybox/issues/I44SFO) | During the integration test, a file in a directory is moved to another directory, and then a file with the same name is created in the first directory. When the user attempts to move the new file, a message is displayed, indicating that the file does not exist.| +| [I45AVP](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I45AVP) | The **hilog** command fails to be executed after a flush operation.| +| I47EPA | **GetBundleSize** returns an error when the input parameter is null or invalid.| +| [I434AD](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434AD) | For Hi3516DV300, the resident memory of the mini system exceeds the baseline.| +| [I434P1](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434P1) | For Hi3518EV300, the resident memory of the mini system exceeds the baseline.| +| [I46I6K](https://gitee.com/openharmony/multimedia_media_lite/issues/I46I6K?from=project-issue) | There are security coding defects in the code of the multimedia subsystem.| +| [I46E6S](https://gitee.com/openharmony/kernel_liteos_m/issues/I46E6S?from=project-issue) | The **-Werror** compilation option is unavailable for the lightweight kernel module compilation.| +| I47ETO | The permission verification does not take effect. When the test .bin file is used to invoke the HAP that has not obtained the **ohos.permission.GET_BUNDLE_INFO** permission, the query is successful. The expected result is a query failure with **0** returned.| +| [I48A2I](https://gitee.com/openharmony/drivers_peripheral/issues/I48A2I) | The board is suspended when the Hi3516DV300 lightweight version calls **AllocMem**.| +| [I42LCU](https://gitee.com/openharmony/kernel_liteos_m/issues/I42LCU) | The method of checking thread insufficiency and the method of configuring the number of threads are unavailable in the integration test and development board migration guide.| +| [I3IPD7](https://gitee.com/openharmony/kernel_liteos_m/issues/I3IPD7) | A description indicating that the **osThreadExit** and **join** functions are not supported is missing in the header file.| +| [I3M12H](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M12H) | During the integration test, two different signals are sent, but **sigwait** receives the first signal twice.| +| [I47X2Z](https://gitee.com/openharmony/kernel_liteos_a/issues/I47X2Z?from=project-issue) | When the **ActsIpcShmTest.bin** script is executed during the integration test, a large amount of shared memory is not released.| +| [I4BL3S](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BL3S) | When the **nfs** cases of the fs_posix module are executed multiple times during the integration test, the message indicating a failure to apply for memory is repeatedly printed.| +| [I490KZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I490KZ) | The **FutexTest.testPthreadTimdOutRWlockWR** case fails to be executed.| +| [I44SFO](https://gitee.com/openharmony/third_party_toybox/issues/I44SFO) | During the integration test, a file in a directory is moved to another directory, and then a file with the same name is created in the first directory. When the user attempts to move the new file, a message is displayed, indicating that the file does not exist.| Table 5 Issues resolved for the standard system -| Issue No.| Description| +| Issue No.| Description| | -------- | -------- | -| [I46A6H](https://gitee.com/openharmony/ace_ace_engine/issues/I46A6H) | During the X test suite (XTS) subsystem pressure test, the **libace.z.so** file is abnormal. As a result, the **ohos.samples.flashlight** file encounters the cppcrash exception.| -| [I48HLN](https://gitee.com/openharmony/app_samples/issues/I48HLN) | Bug-[Demo & application subsystem] [JsCanvas] The Clear button does not take effect.| -| [I46HH7](https://gitee.com/openharmony/drivers_peripheral/issues/I46HH7) | Driver Subsystem - WLAN test cases fail for a standard-system board.| -| [I4312A](https://gitee.com/openharmony/communication_dsoftbus/issues/I4312A) | [OpenHarmony 2.2 Beta2] [DSoftBus] When multiple devices are networked and one of them is disconnected, self-networking fails for the disconnected device (**GetAllNodeDeviceInfo** returns null).| -| [I43WIJ](https://gitee.com/openharmony/communication_dsoftbus/issues/I43WIJ) | [OpenHarmony 2.2 Beta2] [DSoftBus] When multiple devices are networked and one of them is switched to another network and then switched back, the device remains online during this switchover (no callback indicating that the device goes offline or goes online is invoked).| -| [I43KLC](https://gitee.com/openharmony/communication_dsoftbus/issues/I43KLC) | [OpenHarmony 2.2 Beta2] [DSoftBus] A listener for the node status is registered. When a device goes online and then offline, the callback indicating the offline state is invoked twice.| -| [I47WTY](https://gitee.com/openharmony/communication_dsoftbus/issues/I47WTY) | [OpenHarmony 3.0 Beta1] [DSoftBus-Transmission] The verification of the session ID range is incorrect. The valid range is 1-16, but the verification result is greater than 17.| +| I46A6H | During the X test suite (XTS) subsystem pressure test, the **libace.z.so** file is abnormal. As a result, the **ohos.samples.flashlight** file encounters the cppcrash exception.| +| I48HLN | Bug-[Demo & application subsystem] [JsCanvas] The Clear button does not take effect.| +| [I46HH7](https://gitee.com/openharmony/drivers_peripheral/issues/I46HH7) | Driver Subsystem - WLAN test cases fail for a standard-system board.| +| [I4312A](https://gitee.com/openharmony/communication_dsoftbus/issues/I4312A) | [OpenHarmony 2.2 Beta2] [DSoftBus] When multiple devices are networked and one of them is disconnected, self-networking fails for the disconnected device (**GetAllNodeDeviceInfo** returns null).| +| [I43WIJ](https://gitee.com/openharmony/communication_dsoftbus/issues/I43WIJ) | [OpenHarmony 2.2 Beta2] [DSoftBus] When multiple devices are networked and one of them is switched to another network and then switched back, the device remains online during this switchover (no callback indicating that the device goes offline or goes online is invoked).| +| [I43KLC](https://gitee.com/openharmony/communication_dsoftbus/issues/I43KLC) | [OpenHarmony 2.2 Beta2] [DSoftBus] A listener for the node status is registered. When a device goes online and then offline, the callback indicating the offline state is invoked twice.| +| [I47WTY](https://gitee.com/openharmony/communication_dsoftbus/issues/I47WTY) | [OpenHarmony 3.0 Beta1] [DSoftBus-Transmission] The verification of the session ID range is incorrect. The valid range is 1-16, but the verification result is greater than 17.| ## Known Issues **Table 6** Known issues -| Issue| Description| Impact| To Be Resolved On| +| Issue| Description| Impact| To Be Resolved On| | -------- | -------- | -------- | -------- | -| [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the hilog pressure test, **hilogd** restarts unexpectedly, and the **hilog** command cannot be used.| In the pressure test, there is a low probability that the log output is abnormal. The log output is normal in the commissioning scenario.| October 30| -| [I48YPH](https://gitee.com/openharmony/security_deviceauth/issues/I48YPH) | [DSoftBus - Networking] During the testing of the getting-offline - discovery - networking cycle, there are 3 failures among all the 110 attempts.| There is a low probability that this issue occurs. If a networking failure occurs, initiate the networking again.| October 30| -| [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | [DSoftBus - Networking] The success rate of self-networking between a standard-system device and mobile phone is 97%.| There is a low probability that the networking fails.| October 30| -| [I4BXWY](https://gitee.com/openharmony/multimedia_media_standard/issues/I4BXWY) | For Hi3516, noises occur during playback of an audio recording.| This issue occurs only when this development board is used.| October 30| -| [I4BXY1](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4BXY1) | There is no sound in the first few seconds of a video recording, the sound and image are out of sync, frame freezing occurs, and noises occur when the audio source was far away during recording.| This issue occurs only when this development board is used.| October 30| -| [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | There is a possibility that the user mode fails in the XTS pressure test of the permission case.| There is a low probability that the UID of a child process fails to be set in the XTS pressure test scenario where child processes are repeatedly created.| October 30| +| [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the hilog pressure test, **hilogd** restarts unexpectedly, and the **hilog** command cannot be used.| In the pressure test, there is a low probability that the log output is abnormal. The log output is normal in the commissioning scenario.| October 30| +| I48YPH | [DSoftBus - Networking] During the testing of the getting-offline - discovery - networking cycle, there are 3 failures among all the 110 attempts.| There is a low probability that this issue occurs. If a networking failure occurs, initiate the networking again.| October 30| +| [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | [DSoftBus - Networking] The success rate of self-networking between a standard-system device and mobile phone is 97%.| There is a low probability that the networking fails.| October 30| +| [I4BXWY](https://gitee.com/openharmony/multimedia_media_standard/issues/I4BXWY) | For Hi3516, noises occur during playback of an audio recording.| This issue occurs only when this development board is used.| October 30| +| [I4BXY1](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4BXY1) | There is no sound in the first few seconds of a video recording, the sound and image are out of sync, frame freezing occurs, and noises occur when the audio source was far away during recording.| This issue occurs only when this development board is used.| October 30| +| [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | There is a possibility that the user mode fails in the XTS pressure test of the permission case.| There is a low probability that the UID of a child process fails to be set in the XTS pressure test scenario where child processes are repeatedly created.| October 30| diff --git a/en/website.md b/en/website.md index c059218c165614858598ef400f61c441e429928f..33a9b0c244d9ad45f4c9043428091902f93b880f 100644 --- a/en/website.md +++ b/en/website.md @@ -8,49 +8,81 @@ - [OpenHarmony v3.1.1 Release (2022-05-31)](release-notes/OpenHarmony-v3.1.1-release.md) - [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md) + - [OpenHarmony v3.0.5 LTS (2022-07-01)](release-notes/OpenHarmony-v3.0.5-LTS.md) - [OpenHarmony v3.0.3 LTS (2022-04-08)](release-notes/OpenHarmony-v3.0.3-LTS.md) - [OpenHarmony v3.0.2 LTS (2022-03-18)](release-notes/OpenHarmony-v3.0.2-LTS.md) - [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md) - [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) + - OpenHarmony 2.x Releases + - [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md) - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) - + - OpenHarmony 1.x Releases - + - [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md) - [OpenHarmony v1.1.2 LTS (2021-08-04)](release-notes/OpenHarmony-v1.1.2-LTS.md) - [OpenHarmony 1.1.1 LTS (2021-06-22)](release-notes/OpenHarmony-1-1-1-LTS.md) - [OpenHarmony 1.1.0 LTS (2021-04-01)](release-notes/OpenHarmony-1-1-0-LTS.md) - [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md) - - - API Differences - - - OpenHarmony 3.2 Beta1 + +- API Differences + + - OpenHamrony 3.2 Beta2 + - JS API Differences + - [Ability framework](release-notes/api-change/v3.2-beta2/js-apidiff-ability.md) + - [Accessibility subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-accessibility.md) + - [Account subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-account.md) + - [ArkUI development framework](release-notes/api-change/v3.2-beta2/js-apidiff-arkui.md) + - [Bundle management framework](release-notes/api-change/v3.2-beta2/js-apidiff-bundle.md) + - [Communication subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-communicate.md) + - [Utils subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-compiler-and-runtime.md) + - [DFX subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-dfx.md) + - [Distributed data management subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-distributed-data.md) + - [Common event and notification subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-event-and-notification.md) + - [File management subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-file-management.md) + - [Location subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-geolocation.md) + - [Globalization subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-global.md) + - [Graphics subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-graphic.md) + - [Misc services subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-misc.md) + - [Multimodal input subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-multi-modal-input.md) + - [Multimedia subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-multimedia.md) + - [Distributed scheduler subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-resource-scheduler.md) + - [Security subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-security.md) + - [Pan-sensor subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-sensor.md) + - [DSoftBus subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-soft-bus.md) + - [Test subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-unitest.md) + - [Update subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-update.md) + - [USB subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-usb.md) + - [User IAM subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-user-authentication.md) + - [Web subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-web.md) + - [Window manager subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-window.md) + - OpenHarmony 3.2 Beta1 - JS API Differences - - [Ability framework](release-notes/api-change/v3.2-beta/js-apidiff-ability.md) - - [ArkUI development framework](release-notes/api-change/v3.2-beta/js-apidiff-arkui.md) - - [Power management subsystem](release-notes/api-change/v3.2-beta/js-apidiff-battery.md) - - [Bundle management framework](release-notes/api-change/v3.2-beta/js-apidiff-bundle.md) - - [Communication subsystem](release-notes/api-change/v3.2-beta/js-apidiff-communicate.md) - - [DFX subsystem](release-notes/api-change/v3.2-beta/js-apidiff-dfx.md) - - [Distributed data management subsystem](release-notes/api-change/v3.2-beta/js-apidiff-distributed-data.md) - - [Common event and notification subsystem](release-notes/api-change/v3.2-beta/js-apidiff-event-and-notification.md) - - [File management subsystem](release-notes/api-change/v3.2-beta/js-apidiff-file-management.md) - - [Globalization subsystem](release-notes/api-change/v3.2-beta/js-apidiff-global.md) - - [Startup subsystem](release-notes/api-change/v3.2-beta/js-apidiff-init.md) - - [Misc services subsystem](release-notes/api-change/v3.2-beta/js-apidiff-misc.md) - - [Multimodal input subsystem](release-notes/api-change/v3.2-beta/js-apidiff-multi-modal-input.md) - - [Multimedia subsystem](release-notes/api-change/v3.2-beta/js-apidiff-multimedia.md) - - [Distributed scheduler subsystem](release-notes/api-change/v3.2-beta/js-apidiff-resource-scheduler.md) - - [DSoftBus subsystem](release-notes/api-change/v3.2-beta/js-apidiff-soft-bus.md) - - [Test subsystem](release-notes/api-change/v3.2-beta/js-apidiff-unitest.md) - - [Web subsystem](release-notes/api-change/v3.2-beta/js-apidiff-web.md) - - [Window manager subsystem](release-notes/api-change/v3.2-beta/js-apidiff-window.md) - - [Native API Differences](release-notes/api-change/v3.2-beta/native-apidiff-v3.2-beta.md) - - OpenHarmony 3.1 Release + - [Ability framework](release-notes/api-change/v3.2-beta1/js-apidiff-ability.md) + - [ArkUI development framework](release-notes/api-change/v3.2-beta1/js-apidiff-arkui.md) + - [Power management subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-battery.md) + - [Bundle management framework](release-notes/api-change/v3.2-beta1/js-apidiff-bundle.md) + - [Communication subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-communicate.md) + - [DFX subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-dfx.md) + - [Distributed data management subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-distributed-data.md) + - [Common event and notification subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-event-and-notification.md) + - [File management subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-file-management.md) + - [Globalization subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-global.md) + - [Startup subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-init.md) + - [Misc services subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-misc.md) + - [Multimodal input subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-multi-modal-input.md) + - [Multimedia subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-multimedia.md) + - [Distributed scheduler subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-resource-scheduler.md) + - [DSoftBus subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-soft-bus.md) + - [Test subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-unitest.md) + - [Web subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-web.md) + - [Window manager subsystem](release-notes/api-change/v3.2-beta1/js-apidiff-window.md) + - [Native API Differences](release-notes/api-change/v3.2-beta1/native-apidiff-v3.2-beta.md) + - OpenHarmony 3.1 Release - JS API Differences (API Version 8) - [Ability framework](release-notes/api-change/v3.1-Release/js-apidiff-ability.md) - [Accessibility subsystem](release-notes/api-change/v3.1-Release/js-apidiff-accessibility.md) @@ -82,6 +114,20 @@ - [User IAM subsystem](release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md) - [Window manager subsystem](release-notes/api-change/v3.1-Release/js-apidiff-window.md) - [Native API Differences](release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md) + - OpenHarmony 3.1 Beta + - [JS API Differences](release-notes/api-change/v3.1-beta/js-apidiff-v3.1-beta.md) + - [Native API Differences](release-notes/api-change/v3.1-beta/native-apidiff-v3.1-beta.md) + - OpenHarmony 3.0 LTS + - [JS API Differences](release-notes/api-change/v3.0-LTS/js-apidiff-v3.0-lts.md) + - OpenHarmony v2.2 Beta2 + - [JS API Differences](release-notes/api-change/v2.2-beta2/js-apidiff-v2.2-beta2.md) + - [Native API Differences](release-notes/api-change/v2.2-beta2/native-apidiff-v2.2-beta2.md) +- ChangeLog + - OpenHarmony 3.1 Beta + - [Updates Between OpenHarmony 3.1 Beta and OpenHarmony 3.0](release-notes/api-change/v3.1-beta/changelog-v3.1-beta.md) +- OpenHarmony Third-Party Components + - [OpenHarmony Third-Party Components](third-party-components/third-party-components-introduction.md) + - [Using OpenHarmony JS and TS Third-Party Components](third-party-components/npm-third-party-guide.md) - Contribution - [How to Contribute](contribute/how-to-contribute.md) diff --git a/zh-cn/application-dev/IDL/idl-guidelines.md b/zh-cn/application-dev/IDL/idl-guidelines.md index bcfde1302f38de916e7c3ebc45e3f0cb78d71241..5c2cadf08ea84b332bbe9c375b27bbbd2e83a699 100644 --- a/zh-cn/application-dev/IDL/idl-guidelines.md +++ b/zh-cn/application-dev/IDL/idl-guidelines.md @@ -590,7 +590,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { testIntTransaction(data: number, callback: testIntTransactionCallback): void { - let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _option = new rpc.MessageOption(); let _data = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel(); _data.writeInt(data); @@ -612,7 +612,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { testStringTransaction(data: string, callback: testStringTransactionCallback): void { - let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _option = new rpc.MessageOption(); let _data = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel(); _data.writeString(data); diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index 19b9ca337e53338101d7d995f08865062ed8b290..ae23f2193f7096885e1fd4d7e38f652013b4ca38 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -43,6 +43,7 @@ - API参考 - [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) - [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) + - [JS服务卡片UI组件参考](reference/js-service-widget-ui/Readme-CN.md) - 接口 - [JS及TS API参考](reference/apis/Readme-CN.md) - Native API diff --git a/zh-cn/application-dev/ability/fa-brief.md b/zh-cn/application-dev/ability/fa-brief.md index 6d658d0655c9c33b58d9f096aebc8e038b97cf28..d017561c9f02c1a94a7abd1016ea157acd30e0ad 100644 --- a/zh-cn/application-dev/ability/fa-brief.md +++ b/zh-cn/application-dev/ability/fa-brief.md @@ -29,9 +29,9 @@ Ability框架在API 8及更早版本使用FA模型。FA模型中Ability分为Pag ## 相关实例 针对Ability开发,有以下相关实例可供参考: -- [`DistributeCalc`:分布式计算器(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Preset/DistributeCalc) -- [`DistributeGraffiti`:分布式涂鸦(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DistributedGraffiti) - +- [`DistributedCalc`:分布式计算器(JS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/DistributeCalc) +- [`DistributedCalc`:分布式计算器(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/Preset/DistributeCalc) +- [`DistributeGraffiti`:分布式涂鸦(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/DistributedGraffiti) - [分布式调度启动远程FA(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteStartFA) - [分布式新闻客户端(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/NewsDemo) - [分布式手写板(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts) diff --git a/zh-cn/application-dev/ability/fa-dataability.md b/zh-cn/application-dev/ability/fa-dataability.md index 86447ebe432cdcbf09577a00a309bd6de6a39151..bd66df25aa9f2b56c6bdfda61bbf68e0c10f1be1 100644 --- a/zh-cn/application-dev/ability/fa-dataability.md +++ b/zh-cn/application-dev/ability/fa-dataability.md @@ -311,4 +311,4 @@ URI示例: 针对DataAbility开发,有以下相关实例可供参考: -- [`DataAbility`:DataAbility的创建与访问(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DataAbility) +- [`DataAbility`:DataAbility的创建与访问(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/DataAbility) diff --git a/zh-cn/application-dev/ability/fa-formability.md b/zh-cn/application-dev/ability/fa-formability.md index 1d37606f11ff5a4195685b7e045feac0caa2f0b2..77287afbc078064cf9ca260efd355eaa2e67a5f6 100644 --- a/zh-cn/application-dev/ability/fa-formability.md +++ b/zh-cn/application-dev/ability/fa-formability.md @@ -404,5 +404,5 @@ onUpdate(formId) { ## 相关实例 针对FA模型卡片提供方的开发,有以下相关实例可供参考: -- [`FormAbility`:FA模型卡片(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/FormAbility) -- [`FormLauncher`:卡片使用方(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/FormLauncher) \ No newline at end of file +- [`FormAbility`:FA模型卡片(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/FormAbility) +- [`FormLauncher`:卡片使用方(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/FormLauncher) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-pageability.md b/zh-cn/application-dev/ability/fa-pageability.md index 9293f3c13cb83d6a33981facddf82de6dade61a7..c854269adc4054c88b3f3d1a61c89bf6db1d6129 100644 --- a/zh-cn/application-dev/ability/fa-pageability.md +++ b/zh-cn/application-dev/ability/fa-pageability.md @@ -227,4 +227,4 @@ export default { 针对PageAbility开发,有以下相关实例可供参考: -- [`DMS`:分布式Demo(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) \ No newline at end of file +- [`DMS`:分布式Demo(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/DMS) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index 58991ec7147c2789774dff1892c68f8a34d72653..d00801955385bee15b008864cb96537879272cb3 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -128,7 +128,7 @@ let promise = featureAbility.startAbility( 使用OpenHarmony IDL(OpenHarmony Interface Definition Language)来自动生成对应客户端服务端及IRemoteObject代码,具体示例代码和说明请参考: - - [`OpenHarmony IDL`:TS开发步骤](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/IDL/idl-guidelines.md#32-ts开发步骤) + - [`OpenHarmony IDL`:TS开发步骤](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/IDL/idl-guidelines.md#ts开发步骤) 2. 在对应文件编写代码 @@ -220,7 +220,7 @@ let promise = featureAbility.startAbility( } ``` -### 连接远程Service(当前仅对系统应用开放) +### 连接远程Service(当前仅对系统应用开放) >说明:由于DeviceManager的getTrustedDeviceListSync接口仅对系统应用开放,当前连接远程Service仅支持系统应用。 @@ -406,5 +406,5 @@ export default { ## 相关实例 针对ServiceAbility开发,有以下相关实例可供参考: -- [`ServiceAbility`:ServiceAbility的创建与使用(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceAbility) -- [`DMS`:分布式Demo(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) +- [`ServiceAbility`:ServiceAbility的创建与使用(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/ServiceAbility) +- [`DMS`:分布式Demo(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/DMS) diff --git a/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png b/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png index edb49acd0647f3af7355ceda987c5ca812866128..b35954967bb9c733725da2f0700481932619ae45 100755 Binary files a/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png and b/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png differ diff --git a/zh-cn/application-dev/ability/figures/stage-call.png b/zh-cn/application-dev/ability/figures/stage-call.png index 28f2a0f7ea9d86fc81e0c1a37d556384b14a9bdd..511632f7b7ce2c4c4d6582792311184f46fbf703 100644 Binary files a/zh-cn/application-dev/ability/figures/stage-call.png and b/zh-cn/application-dev/ability/figures/stage-call.png differ diff --git a/zh-cn/application-dev/ability/stage-ability.md b/zh-cn/application-dev/ability/stage-ability.md index c03b9eeccdb77712709d7612f192b2738212833b..c57d70f7352f16443a48912c616169f5833b3fa2 100644 --- a/zh-cn/application-dev/ability/stage-ability.md +++ b/zh-cn/application-dev/ability/stage-ability.md @@ -231,8 +231,8 @@ var want = { "bundleName": "com.example.MyApplication", "abilityName": "MainAbility" }; -context.startAbility(want).then((data) => { - console.log("Succeed to start ability with data: " + JSON.stringify(data)) +context.startAbility(want).then(() => { + console.log("Succeed to start ability") }).catch((error) => { console.error("Failed to start ability with error: "+ JSON.stringify(error)) }) @@ -248,8 +248,8 @@ var want = { "bundleName": "com.example.MyApplication", "abilityName": "MainAbility" }; -context.startAbility(want).then((data) => { - console.log("Succeed to start remote ability with data: " + JSON.stringify(data)) +context.startAbility(want).then(() => { + console.log("Succeed to start remote ability") }).catch((error) => { console.error("Failed to start remote ability with error: " + JSON.stringify(error)) }) @@ -324,4 +324,4 @@ struct Index { ## 相关实例 针对Stage模型Ability开发,有以下相关示例可供参考: -- [`StageCallAbility`:StageCallAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) +- [`StageCallAbility`:StageCallAbility的创建与使用(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/StageCallAbility) diff --git a/zh-cn/application-dev/ability/stage-brief.md b/zh-cn/application-dev/ability/stage-brief.md index 9099e1e557bbd9abd7f3a8fae0eee7de15764a49..0183b259a263c277b1b27b74d6cb2c1378549238 100644 --- a/zh-cn/application-dev/ability/stage-brief.md +++ b/zh-cn/application-dev/ability/stage-brief.md @@ -97,4 +97,5 @@ ![stageprocessmodel](figures/stageprocessmodel.png) ## 相关实例 针对Stage模型下的Ability开发,有以下相关实例可供参考: -- [`MissionManager`:系统任务管理(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/MissionManager) +- [`MissionManager`:系统任务管理(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/MissionManager) +- [`Launcher`:仿桌面应用(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/Launcher) diff --git a/zh-cn/application-dev/ability/stage-call.md b/zh-cn/application-dev/ability/stage-call.md index e8126fa0d7b92f82c9a35d2b92fe3d5017f9ca4d..fb49d6a030feaaa8a9978f3827c7ae7b1accf960 100644 --- a/zh-cn/application-dev/ability/stage-call.md +++ b/zh-cn/application-dev/ability/stage-call.md @@ -1,39 +1,58 @@ # Call调用开发指导 ## 场景介绍 -Ability Call调用是Ability能力的扩展,它为Ability提供一种能够被外部调用的能力,使Ability既能被拉起到前台展示UI,也支持Ability在后台被创建并运行。应用开发者可通过Call调用,使用IPC通信实现不同Ability之间的数据共享。Call调用的场景主要包括: -- 创建Callee被调用端。 -- 访问Callee被调用端。 +Call调用是Ability能力的扩展,它为Ability提供一种能够被外部调用并与外部进行通信的能力。Call调用支持前台与后台两种启动方式,使Ability既能被拉起到前台展示UI,也可以在后台被创建并运行。Call调用在调用方与被调用方间建立了IPC通信,因此应用开发者可通过Call调用实现不同Ability之间的数据共享。 + +Call调用的核心接口是startAbilityByCall方法,与startAbility接口的不同之处在于: + - startAbilityByCall支持前台与后台两种启动方式,而startAbility仅支持前台启动。 + - 调用方可使用startAbilityByCall所返回的Caller对象与被调用方进行通信,而startAbilty不具备通信能力。 + +Call调用的使用场景主要包括: +- 需要与被启动的Ability进行通信 +- 希望被启动的Ability在后台运行 -本文中的Caller和Callee分别表示调用者和被调用者,IPC表示进程间通信,Call调用流程示意图如下。 +**表1** Call调用相关名词解释 +|名词|描述| +|:------|:------| +|CallerAbility|指代进行Call调用的Ability(调用方)| +|CalleeAbility|指代被Call调用的Ability(被调用方)| +|Caller |实际对象,由startAbilityByCall接口所返回,CallerAbility可使用Caller与CalleeAbility进行通信,具体接口见表2| +|Callee |实际对象,被Ability对象所持有,可与Caller进行通信| +|IPC |指代进程间通信| +Call调用流程示意图如下: + - CallerAbility调用startAbilityByCall接口获取Caller,并使用Caller对象的call方法向CalleeAbility发送数据 + - CalleeAbility持有一个Callee对象,通过Callee的on方法注册回调函数,当接收到Caller发送的数据时将会调用对应的回调函数 ![stage-call](figures/stage-call.png) > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> Callee被调用端所在的Ability,启动模式需要为单实例。 -> 当前仅支持系统应用及ServiceExtensionAbility使用Call访问Callee。 +> CalleeAbility的启动模式需要为单实例。 +> 当前仅支持系统应用使用Call调用。 ## 接口说明 Caller及Callee功能如下:具体的API详见[接口文档](../reference/apis/js-apis-application-ability.md#caller)。 -**表1** Call API接口功能介绍 +**表2** Call API接口功能介绍 |接口名|描述| |:------|:------| -|startAbilityByCall(want: Want): Promise\|获取指定通用组件的Caller通信接口,拉起指定通用组件并将其切换到后台。| +|startAbilityByCall(want: Want): Promise\|启动指定Ability并获取其Caller通信接口,默认为后台启动,通过配置want可实现前台启动,详见[接口文档](../reference/apis/js-apis-ability-context.md#abilitycontextstartabilitybycall)。AbilityContext与ServiceExtensionContext均支持该接口。| |on(method: string, callback: CalleeCallBack): void|通用组件Callee注册method对应的callback方法。| -|off(method: string): void|通用组件Callee去注册method的callback方法。| +|off(method: string): void|通用组件Callee解注册method的callback方法。| |call(method: string, data: rpc.Sequenceable): Promise\|向通用组件Callee发送约定序列化数据。| -|callWithResult(method: string, data: rpc.Sequenceable): Promise\|向通用组件Callee发送约定序列化数据, 并将返回的约定序列化数据带回。| +|callWithResult(method: string, data: rpc.Sequenceable): Promise\|向通用组件Callee发送约定序列化数据, 并将Callee返回的约定序列化数据带回。| |release(): void|释放通用组件的Caller通信接口。| |onRelease(callback: OnReleaseCallBack): void|注册通用组件通信断开监听通知。| ## 开发步骤 +Call调用的开发步骤: +- 创建Callee被调用端。 +- 访问Callee被调用端。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 开发步骤章节中的示例代码片段是开发过程的步骤化展示,部分代码可能无法单独运行,完整工程代码请参考[相关实例](#相关实例)。 ### 创建Callee被调用端 Callee被调用端,需要实现指定方法的数据接收回调函数、数据的序列化及反序列化方法。在需要接收数据期间,通过on接口注册监听,无需接收数据时通过off接口解除监听。 -1. 配置Ability的启动模式 +**1. 配置Ability的启动模式** - 配置module.json5,将Callee被调用端所在的Ability配置为单实例"singleton"。 + 配置module.json5,将CalleeAbility配置为单实例"singleton"。 |Json字段|字段说明| |:------|:------| @@ -51,11 +70,11 @@ Ability配置标签示例如下: "visible": true }] ``` -2. 导入Ability模块。 -``` +**2. 导入Ability模块** +```ts import Ability from '@ohos.application.Ability' ``` -3. 定义约定的序列化数据。 +**3. 定义约定的序列化数据** 调用端及被调用端发送接收的数据格式需协商一致,如下示例约定数据由number和string组成。具体示例代码如下: ```ts @@ -81,7 +100,7 @@ export default class MySequenceable { } } ``` -4. 实现Callee.on监听及Callee.off解除监听。 +**4. 实现Callee.on监听及Callee.off解除监听** 被调用端Callee的监听函数注册时机, 取决于应用开发者。注册监听之前的数据不会被处理,取消监听之后的数据不会被处理。如下示例在Ability的onCreate注册'MSG_SEND_METHOD'监听,在onDestroy取消监听,收到序列化数据后作相应处理并返回,应用开发者根据实际需要做相应处理。具体示例代码如下: ```ts @@ -89,12 +108,12 @@ const TAG: string = '[CalleeAbility]' const MSG_SEND_METHOD: string = 'CallSendMsg' function sendMsgCallback(data) { - Logger.log(TAG, 'CalleeSortFunc called') + console.log('CalleeSortFunc called') // 获取Caller发送的序列化数据 let receivedData = new MySequenceable(0, '') data.readSequenceable(receivedData) - Logger.log(TAG, `receiveData[${receivedData.num}, ${receivedData.str}]`) + console.log(`receiveData[${receivedData.num}, ${receivedData.str}]`) // 作相应处理 // 返回序列化数据result给Caller @@ -106,7 +125,7 @@ export default class CalleeAbility extends Ability { try { this.callee.on(MSG_SEND_METHOD, sendMsgCallback) } catch (error) { - Logger.error(TAG, `${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) + console.log(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) } } @@ -121,14 +140,26 @@ export default class CalleeAbility extends Ability { ``` ### 访问Callee被调用端 -1. 导入Ability模块。 -``` +**1. 导入Ability模块** +```ts import Ability from '@ohos.application.Ability' ``` -2. 获取Caller通信接口。 +**2. 获取Caller通信接口** Ability的context属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过`this.context`获取Ability实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease监听。应用开发者根据实际需要做相应处理。具体示例代码如下: ```ts +// 注册caller的release监听 +private regOnRelease(caller) { + try { + caller.onRelease((msg) => { + console.log(`caller onRelease is called ${msg}`) + }) + console.log('caller register OnRelease succeed') + } catch (error) { + console.log(`caller register OnRelease failed with ${error}`) + } +} + async onButtonGetCaller() { try { this.caller = await context.startAbilityByCall({ @@ -136,41 +167,40 @@ async onButtonGetCaller() { abilityName: 'CalleeAbility' }) if (this.caller === undefined) { - Logger.error(TAG, 'get caller failed') + console.log('get caller failed') return } - Logger.log(TAG, 'get caller success') + console.log('get caller success') this.regOnRelease(this.caller) } catch (error) { - Logger.error(TAG, `get caller failed with ${error}`) + console.log(`get caller failed with ${error}`) } -}.catch((error) => { - console.error(TAG + 'get caller failed with ' + error) -}) +} ``` 在跨设备场景下,需指定对端设备deviceId。具体示例代码如下: ```ts -let TAG = '[MainAbility] ' -var caller = undefined -let context = this.context - -context.startAbilityByCall({ - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.CallApplication', - abilityName: 'CalleeAbility' -}).then((data) => { - if (data != null) { - caller = data - console.log(TAG + 'get remote caller success') - // 注册caller的release监听 - caller.onRelease((msg) => { - console.log(TAG + 'remote caller onRelease is called ' + msg) - }) - console.log(TAG + 'remote caller register OnRelease succeed') - } -}).catch((error) => { - console.error(TAG + 'get remote caller failed with ' + error) -}) +async onButtonGetRemoteCaller() { + var caller = undefined + var context = this.context + + context.startAbilityByCall({ + deviceId: getRemoteDeviceId(), + bundleName: 'com.samples.CallApplication', + abilityName: 'CalleeAbility' + }).then((data) => { + if (data != null) { + caller = data + console.log('get remote caller success') + // 注册caller的release监听 + caller.onRelease((msg) => { + console.log(`remote caller onRelease is called ${msg}`) + }) + console.log('remote caller register OnRelease succeed') + } + }).catch((error) => { + console.error(`get remote caller failed with ${error}`) + }) +} ``` 从DeviceManager获取指定设备的deviceId,getTrustedDeviceListSync接口仅对系统应用开放。具体示例代码如下: ```ts @@ -178,29 +208,31 @@ import deviceManager from '@ohos.distributedHardware.deviceManager'; var dmClass; function getRemoteDeviceId() { if (typeof dmClass === 'object' && dmClass != null) { - var list = dmClass.getTrustedDeviceListSync(); + var list = dmClass.getTrustedDeviceListSync() if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') { - console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null"); - return; + console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null") + return } - console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId); - return list[0].deviceId; + console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId) + return list[0].deviceId } else { - console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null"); + console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null") } } ``` 在跨设备场景下,需要向用户申请数据同步的权限。具体示例代码如下: ```ts -let context = this.context -let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] -context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) -}).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) -}) +requestPermission() { + let context = this.context + let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] + context.requestPermissionsFromUser(permissions).then((data) => { + console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) + }).catch((error) => { + console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) + }) +} ``` -3. 发送约定序列化数据 +**3. 发送约定序列化数据** 向被调用端发送Sequenceable数据有两种方式,一种是不带返回值,一种是获取被调用端返回的数据,method以及序列化数据需要与被调用端协商一致。如下示例调用Call接口,向Callee被调用端发送数据。具体示例代码如下: ```ts @@ -210,7 +242,7 @@ async onButtonCall() { let msg = new MySequenceable(1, 'origin_Msg') await this.caller.call(MSG_SEND_METHOD, msg) } catch (error) { - Logger.error(TAG, `caller call failed with ${error}`) + console.log(`caller call failed with ${error}`) } } ``` @@ -224,30 +256,32 @@ async onButtonCallWithResult(originMsg, backMsg) { try { let msg = new MySequenceable(1, originMsg) const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg) - Logger.log(TAG, 'caller callWithResult succeed') + console.log('caller callWithResult succeed') let result = new MySequenceable(0, '') data.readSequenceable(result) backMsg(result.str) - Logger.log(TAG, `caller result is [${result.num}, ${result.str}]`) + console.log(`caller result is [${result.num}, ${result.str}]`) } catch (error) { - Logger.error(TAG, `caller callWithResult failed with ${error}`) + console.log(`caller callWithResult failed with ${error}`) } } ``` -4. 释放Caller通信接口 +**4. 释放Caller通信接口** Caller不再使用后,应用开发者可以通过release接口释放Caller。具体示例代码如下: ```ts -try { - this.caller.release() - this.caller = undefined - Logger.log(TAG, 'caller release succeed') -} catch (error) { - Logger.error(TAG, `caller release failed with ${error}`) +releaseCall() { + try { + this.caller.release() + this.caller = undefined + console.log('caller release succeed') + } catch (error) { + console.log(`caller release failed with ${error}`) + } } ``` ## 相关实例 针对Stage模型本地Call功能开发,有以下相关实例可供参考: -- [`StageCallAbility`:StageCallAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) +- [`StageCallAbility`:StageCallAbility的创建与使用(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/StageCallAbility) diff --git a/zh-cn/application-dev/ability/stage-formextension.md b/zh-cn/application-dev/ability/stage-formextension.md index 87f32400698c5e7b2f1023b61d6600ed423cfd25..02a8e399e5a4360072d18b104889a33ce5f075d3 100644 --- a/zh-cn/application-dev/ability/stage-formextension.md +++ b/zh-cn/application-dev/ability/stage-formextension.md @@ -48,10 +48,10 @@ FormExtension类还拥有成员context,为FormExtensionContext类,具体的A **表2** FormExtensionContext API接口功能介绍 -| 接口名 | 描述 | -| :----------------------------------------------------------- | :------------------------ | -| updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void | 回调形式主动更新卡片。 | -| updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\ | Promise形式主动更新卡片。 | +| 接口名 | 描述 | +| :----------------------------------------------------------- | :----------------------------------------------------------- | +| startAbility(want: Want, callback: AsyncCallback<void>): void | 回调形式拉起一个卡片所属应用的Ability(系统接口,三方应用不支持调用)。 | +| startAbility(want: Want): Promise<void> | Promise形式拉起一个卡片所属应用的Ability(系统接口,三方应用不支持调用)。 | FormProvider类具体的API介绍详见[接口文档](../reference/apis/js-apis-formprovider.md)。 @@ -415,4 +415,5 @@ onUpdate(formId) { ## 相关实例 针对Stage模型卡片提供方的开发,有以下相关实例可供参考: -- [`FormExtAbility`:Stage模型卡片(eTS JS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/FormExtAbility) \ No newline at end of file +- [`FormExtAbility`:Stage模型卡片(eTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/FormExtAbility) +- [`GalleryForm`:图库卡片(eTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/GalleryForm) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/stage-serviceextension.md b/zh-cn/application-dev/ability/stage-serviceextension.md index e427bbc7f859eff7dd486f32474ddf98a4c4428d..2540855d34ba71c4c44a7be4581caca2aad166aa 100644 --- a/zh-cn/application-dev/ability/stage-serviceextension.md +++ b/zh-cn/application-dev/ability/stage-serviceextension.md @@ -75,4 +75,4 @@ OpenHarmony当前不支持三方应用创建ServiceExtensionAbility。 ## 相关实例 针对ServiceExtensionAbility开发,有以下相关实例可供参考: -- [`ServiceExtAbility`:StageExtAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility) +- [`ServiceExtAbility`:StageExtAbility的创建与使用(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/ServiceExtAbility) diff --git a/zh-cn/application-dev/application-dev-guide-for-gitee.md b/zh-cn/application-dev/application-dev-guide-for-gitee.md index e17831a387db2b9ff959a3cf458369760f0545e6..79371930d291fc6452179a1f11f65c0f83f670c1 100644 --- a/zh-cn/application-dev/application-dev-guide-for-gitee.md +++ b/zh-cn/application-dev/application-dev-guide-for-gitee.md @@ -56,9 +56,8 @@ API参考提供了OpenHarmony全量组件和接口的参考文档,可以帮助 内容包括: - [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) - - - [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) +- [JS服务卡片UI组件参考](reference/js-service-widget-ui/Readme-CN.md) - 接口参考 - [JS及TS API参考](reference/apis/Readme-CN.md) - Native API diff --git a/zh-cn/application-dev/application-dev-guide.md b/zh-cn/application-dev/application-dev-guide.md index 1a2dba85bb227a47c8a76fcdd2872190a184c585..b9cef5ddb5958576b70755b6b02fe4cd172fad72 100644 --- a/zh-cn/application-dev/application-dev-guide.md +++ b/zh-cn/application-dev/application-dev-guide.md @@ -60,6 +60,8 @@ API参考提供了OpenHarmony全量组件和接口的参考文档,可以帮助 - [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) +- [JS服务卡片UI组件参考](reference/js-service-widget-ui/Readme-CN.md) + - [接口参考(JS及TS API)](reference/apis/js-apis-DataUriUtils.md) - 接口参考(Native API) diff --git a/zh-cn/application-dev/connectivity/http-request.md b/zh-cn/application-dev/connectivity/http-request.md index d71280393c8c3afc28b8d81bd26f11f7e84af841..2778c2a1bfe14e6db49c9ad666165d8f084a6673 100644 --- a/zh-cn/application-dev/connectivity/http-request.md +++ b/zh-cn/application-dev/connectivity/http-request.md @@ -74,5 +74,5 @@ httpRequest.request( ## 相关实例 针对HTTP数据请求,有以下相关实例可供参考: -- [`Http`:数据请求(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Http) +- [`Http:`数据请求(eTS)(API9))](https://gitee.com/openharmony/applications_app_samples/tree/master/Network/Http) - [使用HTTP实现与服务端通信(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH) \ No newline at end of file diff --git a/zh-cn/application-dev/connectivity/socket-connection.md b/zh-cn/application-dev/connectivity/socket-connection.md index 653ed9a40ace72b56f0013ae515e3172cb54d07c..a538d2134dee0e74e6510d81ddab7b2663535d73 100644 --- a/zh-cn/application-dev/connectivity/socket-connection.md +++ b/zh-cn/application-dev/connectivity/socket-connection.md @@ -125,6 +125,6 @@ UDP与TCP流程大体类似,下面以TCP为例: ## 相关实例 针对Socket连接开发,有以下相关实例可供参考: -- [`Socket`:Socket 连接(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Socket) +- [`Socket`:Socket 连接(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/Network/Socket) - [使用UDP实现与服务端通信(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/UdpDemoOH) - [使用TCP实现与服务端通信(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/TcpSocketDemo) \ No newline at end of file diff --git a/zh-cn/application-dev/connectivity/websocket-connection.md b/zh-cn/application-dev/connectivity/websocket-connection.md index 53598fc5031da880ebf59edba43fb29bcc8b626b..41ddfa0a73707b4d5cf0db3c3b30d735dbb775f3 100644 --- a/zh-cn/application-dev/connectivity/websocket-connection.md +++ b/zh-cn/application-dev/connectivity/websocket-connection.md @@ -87,4 +87,4 @@ WebSocket连接功能主要由webSocket模块提供。使用该功能需要申 ## 相关实例 针对WebSocket连接的开发,有以下相关实例可供参考: -- [`WebSocket`:WebSocket(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/WebSocket) \ No newline at end of file +- [`WebSocket`:WebSocket(eTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/Network/WebSocket) \ No newline at end of file diff --git a/zh-cn/application-dev/database/database-datashare-guidelines.md b/zh-cn/application-dev/database/database-datashare-guidelines.md index c730616e533b82c03ac7acc927658afa34150e08..c074190962aafb0593dbcdee38f7faa97855ac5a 100644 --- a/zh-cn/application-dev/database/database-datashare-guidelines.md +++ b/zh-cn/application-dev/database/database-datashare-guidelines.md @@ -80,7 +80,7 @@ DataShare即数据共享模块,提供了向其他应用共享以及管理其 } // 重写query接口 - query(uri, predicates, columns, callback) { + query(uri, predicates, columns, callback) { if (predicates == null || predicates == undefined) { console.info('invalid predicates'); } @@ -144,48 +144,49 @@ DataShare即数据共享模块,提供了向其他应用共享以及管理其 let dseUri = ("datashare:///com.samples.datasharetest.DataShare"); ``` -2. 创建工具接口类对象。 +3. 创建工具接口类对象。 ```ts let dsHelper; let abilityContext; + export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { abilityContext = this.context; - dataShare.createDataShareHelper(abilityContext, dseUri, (err,data)=>{ + dataShare.createDataShareHelper(abilityContext, dseUri, (err, data)=>{ dsHelper = data; }); } } ``` -3. 获取到接口类对象后,便可利用其提供的接口访问提供方提供的服务,如进行数据的增删改查等。 +4. 获取到接口类对象后,便可利用其提供的接口访问提供方提供的服务,如进行数据的增删改查等。 ```ts // 构建一条数据 - var valuesBucket = {"name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1,2,3])}; - var updateBucket = {"name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1,2,3])}; - let da = new dataSharePredicates.DataSharePredicates(); - var valArray =new Array("*"); + var valuesBucket = { "name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1, 2, 3]) }; + var updateBucket = { "name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1, 2, 3]) }; + let da = new dataSharePredicates.DataSharePredicates(); + var valArray = new Array("*"); let people = new Array( - {"name": "LiSi", "age": 41, "Binary": ar}, - {"name": "WangWu", "age": 21, "Binary": arr}, - {"name": "ZhaoLiu", "age": 61, "Binary": arr}); + { "name": "LiSi", "age": 41, "Binary": ar }, + { "name": "WangWu", "age": 21, "Binary": arr }, + { "name": "ZhaoLiu", "age": 61, "Binary": arr }); // 插入一条数据 - dsHelper.insert(dseUri, valuesBucket, (err,data) => { - console.log("dsHelper insert result: " + data); + dsHelper.insert(dseUri, valuesBucket, (err, data) => { + console.log("dsHelper insert result: " + data); }); // 删除指定的数据 - dsHelper.delete(dseUri, da, (err,data) => { - console.log("dsHelper delete result: " + data); + dsHelper.delete(dseUri, da, (err, data) => { + console.log("dsHelper delete result: " + data); }); // 更新数据 - dsHelper.update(dseUri, da, updateBucket, (err,data) => { - console.log("dsHelper update result: " + data); + dsHelper.update(dseUri, da, updateBucket, (err, data) => { + console.log("dsHelper update result: " + data); }); // 查询数据 - dsHelper.query(dseUri, da, valArray, (err,data) => { - console.log("dsHelper query result: " + data); + dsHelper.query(dseUri, da, valArray, (err, data) => { + console.log("dsHelper query result: " + data); }); ``` diff --git a/zh-cn/application-dev/database/database-distributedobject-guidelines.md b/zh-cn/application-dev/database/database-distributedobject-guidelines.md index 61db857faf49b8f9f3d1adbdd14e1737c63712bc..c53bcdc61c1c5fff9c6e3850b2027244293bebc7 100644 --- a/zh-cn/application-dev/database/database-distributedobject-guidelines.md +++ b/zh-cn/application-dev/database/database-distributedobject-guidelines.md @@ -2,22 +2,23 @@ ## 场景介绍 -分布式数据对象通过屏蔽设备间复杂的数据交互处理,提供了与本地变量类似的极简操作,当设备1的应用A的分布式数据对象增、删、改数据后,设备2的应用A也可以获取到对应的数据变化,同时还能监听数据变更以及对端数据对象的上下线。分布式数据对象支持的数据类型包括数字型、字符型、布尔型等基本类型,同时也支持数组、基本类型嵌套等复杂类型。 +分布式数据对象为开发者在分布式应用场景下提供简单易用的功能接口,可实现多设备间同应用的数据协同,同时设备间还可以监听对象的状态和数据变更。 +比如,当设备1上应用A的分布式数据对象增、删、改数据后,设备2上应用A也可以获取到对应的数据变化,同时还能监听数据变更以及对端数据对象的上下线。 ## 接口说明 -具体分布式数据对象相关功能接口请见[分布式数据对象](../reference/apis/js-apis-data-distributedobject.md)。 +分布式数据对象相关功能接口请见[分布式数据对象](../reference/apis/js-apis-data-distributedobject.md)。 ### 创建数据对象实例 -创建一个分布式数据对象实例,用户可以通过source指定分布式对象中的属性。 +创建一个分布式数据对象实例,开发者可以通过source指定分布式对象中的属性。 **表1** 分布式数据对象实例创建接口 -| 包名 | 接口名 | 描述 | +| 包名 | 接口名 | 描述 | | -------- | -------- | -------- | -| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | 创建一个分布式数据对象实例,用于数据操作
- source:设置distributedObject的属性。
- DistributedObject:返回值是创建好的分布式对象。| +| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | 创建一个分布式数据对象实例,用于数据操作。
- source:设置distributedObject的属性。
- DistributedObject:返回值是创建好的分布式对象。 | ### 创建分布式数据对象sessionId @@ -35,16 +36,17 @@ **表3** 分布式数据对象sessionId设置接口 | 类名 | 接口名 | 描述 | | -------- | -------- | -------- | -| DistributedDataObject | setSessionId(sessionId?: string): boolean | 为分布式数据对象设置sessionId
 sessionId:分布式对象在可信组网中的标识ID。如果要退出分布式组网,设置为""或不设置均可。| +| DistributedDataObject | setSessionId(sessionId?: string): boolean | 为分布式数据对象设置sessionId。
 sessionId:分布式对象在可信组网中的标识ID。如果要退出分布式组网,设置为""或不设置均可。 | ### 订阅数据变更 订阅数据变更需要指定Callback作为回调方法,订阅的数据对象发生数据变更后,Callback被回调。 **表4** 分布式数据对象数据变更订阅接口 -| 类名 | 接口名 | 描述 | + +| 类名 | 接口名 | 描述 | | -------- | -------- | -------- | -| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | 订阅数据变更。 | +| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | 订阅数据变更。 | | DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | 注销订阅。需要删除的变更回调,若不设置则删除该对象所有的变更回调。 | ### 订阅数据对象上下线 @@ -73,8 +75,6 @@ | 类名 | 接口名 | 描述 | | -------- | -------- | -------- | | DistributedDataObject | save(deviceId: string): Promise<SaveSuccessResponse> | 保存数据对象。 | -| DistributedDataObject| save(deviceId: string, callback: AsyncCallback<SaveSuccessResponse>): void | 保存数据对象。 | -| DistributedDataObject | revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void | 撤回已保存的数据对象。 | | DistributedDataObject| revokeSave(): Promise<RevokeSaveSuccessResponse> | 撤回已保存的数据对象。 | ## 开发步骤 @@ -82,11 +82,13 @@ 以一次分布式数据对象同步为例,说明开发步骤。 1. 准备工作,导入@ohos.data.distributedDataObject模块到开发环境。 + ```js import distributedObject from '@ohos.data.distributedDataObject'; - ``` -2. 请求权限。需要在`config.json`里面进行配置请求权限,示例代码如下: - ``` + ``` +2. 请求权限。需要在`config.json`或`module.json5`文件里进行配置请求权限,示例代码如下: + + ```json { "module": { "reqPermissions": [ @@ -96,8 +98,9 @@ ] } } - ``` + ``` 这个权限还需要在应用首次启动的时候弹窗获取用户授权,可以通过如下代码实现: + ```js import featureAbility from '@ohos.ability.featureAbility'; @@ -110,34 +113,50 @@ }) console.info('end grantPermission'); } + grantPermission(); ``` - + 3. 获取分布式数据对象实例。 以下为创建分布式数据对象的代码示例: + ```js - var local_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, - parent:undefined, list:undefined}); + var local_object = distributedObject.createDistributedObject({ + name: undefined, + age: undefined, + isVis: true, + parent: undefined, + list: undefined + }); var sessionId = distributedObject.genSessionId(); ``` - 4. 加入同步组网。同步组网中的数据对象分为发起方和被拉起方。 以下为加入同步组网的代码示例: ```js // 发起方 - var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true, - parent:{mother:"jack mom", father:"jack Dad"}, list:[{mother:"jack mom"}, {father:"jack Dad"}]}); + var local_object = distributedObject.createDistributedObject({ + name: "jack", + age: 18, + isVis: true, + parent: { mother: "jack mom", father: "jack Dad" }, + list: [{ mother: "jack mom" }, { father: "jack Dad" }] + }); local_object.setSessionId(sessionId); // 被拉起方 - var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, - parent:undefined, list:undefined}); - remote_object.setSessionId(sessionId); + var remote_object = distributedObject.createDistributedObject({ + name: undefined, + age: undefined, + isVis: true, + parent: undefined, + list: undefined + }); // 收到status上线后remote_object同步数据,即name变成jack,age是18 + remote_object.setSessionId(sessionId); ``` 5. 监听对象数据变更。可监听对端数据的变更,以callback作为变更回调实例。 @@ -146,35 +165,37 @@ ```js function changeCallback(sessionId, changeData) { - console.info("change" + sessionId); + console.info("change" + sessionId); - if (changeData != null && changeData != undefined) { - changeData.forEach(element => { - console.info("changed !" + element + " " + local_object[element]); - }); - } - } - - // 发起方要在changeCallback里刷新界面,则需要将正确的this绑定给changeCallback - local_object.on("change", this.changeCallback.bind(this)); + if (changeData != null && changeData != undefined) { + changeData.forEach(element => { + console.info("changed !" + element + " " + local_object[element]); + }); + } + } + + // 发起方要在changeCallback里刷新界面,则需要将正确的this绑定给changeCallback + local_object.on("change", this.changeCallback.bind(this)); ``` 6. 修改对象属性,对象属性支持基本类型(数字类型、布尔类型、字符串类型)以及复杂类型(数组、基本类型嵌套等)。 以下为修改分布式数据对象属性的代码示例: + ```js local_object.name = "jack"; local_object.age = 19; local_object.isVis = false; - local_object.parent = {mother:"jack mom", father:"jack Dad"}; - local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}]; + local_object.parent = { mother: "jack mom", father: "jack Dad" }; + local_object.list = [{ mother: "jack mom" }, { father: "jack Dad" }]; ``` - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > **说明:** > 针对复杂类型的数据修改,目前支持对根属性的修改,暂不支持对下级属性的修改。示例如下: + ```js // 支持的修改方式 - local_object.parent = {mother:"mom", father:"dad"}; + local_object.parent = { mother: "mom", father: "dad" }; // 不支持的修改方式 local_object.parent.mother = "mom"; ``` @@ -182,12 +203,14 @@ 7. 访问对象。可以通过直接获取的方式访问到分布式数据对象的属性,且该数据为组网内的最新数据。 以下为访问对象的代码示例: + ```js console.info("name " + local_object["name"]); ``` 8. 删除监听数据变更。可以指定删除监听的数据变更回调;也可以不指定,这将会删除该分布式数据对象的所有数据变更回调。 以下为取消监听数据变更的代码示例: + ```js // 删除变更回调changeCallback local_object.off("change", changeCallback); @@ -196,6 +219,7 @@ ``` 9. 监听分布式对象的上下线。可以监听对端分布式数据对象的上下线。 以下为访问对象的代码示例: + ```js function statusCallback(sessionId, networkId, status) { this.response += "status changed " + sessionId + " " + status + " " + networkId; @@ -206,61 +230,41 @@ 10. 保存和撤回已保存的数据对象。 - 1.callback方式 - - ```js - // 保存数据对象 - local_object.save("local", (result, data) => { - console.log("save callback"); - console.info("save sessionId " + data.sessionId); - console.info("save version " + data.version); - console.info("save deviceId " + data.deviceId); - }); - // 撤回保存的数据对象 - local_object.revokeSave((result, data) => { - console.log("revokeSave callback"); - console.info("revokeSave sessionId " + data.sessionId); - }); - ``` - 2.Promise方式 - ```js - // 保存数据对象 - g_object.save("local").then((result) => { - console.info("save sessionId " + result.sessionId); - console.info("save version " + result.version); - console.info("save deviceId " + result.deviceId); - }, (result)=>{ - console.info("save local failed."); - }); - // 撤回保存的数据对象 - g_object.revokeSave().then((result) => { - console.info("revokeSave success."); - }, (result)=>{ - console.info("revokeSave failed."); - }); - ``` + ```js + // 保存数据对象 + g_object.save("local").then((result) => { + console.info("save sessionId " + result.sessionId); + console.info("save version " + result.version); + console.info("save deviceId " + result.deviceId); + }, (result) => { + console.info("save local failed."); + }); + // 撤回保存的数据对象 + g_object.revokeSave().then((result) => { + console.info("revokeSave success."); + }, (result) => { + console.info("revokeSave failed."); + }); + ``` 11. 删除监听分布式对象的上下线。可以指定删除监听的上下线回调;也可以不指定,这将会删除该分布式数据对象的所有上下线回调。 以下为取消监听数据变更的代码示例: - ```js + + ```js // 删除上下线回调statusCallback local_object.off("status", this.statusCallback); // 删除所有的上下线回调 local_object.off("status"); - ``` + ``` 12. 退出同步组网。分布式对象退出组网后,本地的数据变更对端不会同步。 - 以下为退出同步组网的代码示例: - ```js - local_object.setSessionId(""); - ``` -## 相关实例 - -针对分布式数据对象,有以下开发实例可供参考: -- [`DistributedNote`:分布式备忘录(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedNote) + 以下为退出同步组网的代码示例: -- [备忘录应用](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad) - - 在备忘录应用中,当某一个设备上的备忘录事件发生变更时,通过分布式数据对象将事件变更同步在可信组网内的其他设备上,比如新增备忘录事件、编辑事件标题和内容、清空事件列表 - 等。 + ```js + local_object.setSessionId(""); + ``` +## 相关实例 +针对分布式数据对象,有以下相关实例可供参考: +- [`DistributedNote`:分布式备忘录(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/data/DistributedNote) +- [`DistributedObjectDms`:分布式跑马灯(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/data/DistributedObjectDms) \ No newline at end of file diff --git a/zh-cn/application-dev/database/database-distributedobject-overview.md b/zh-cn/application-dev/database/database-distributedobject-overview.md index 9f930a504d0f7622232c34b2420e02685de0c03b..8c8179db7b94d069b29a8139f8b6d6831048ce4f 100644 --- a/zh-cn/application-dev/database/database-distributedobject-overview.md +++ b/zh-cn/application-dev/database/database-distributedobject-overview.md @@ -1,6 +1,6 @@ # 分布式数据对象概述 -分布式数据对象管理框架是一款面向对象的内存数据管理框架。向应用开发者提供内存对象的创建、查询、删除、修改、订阅等基本数据对象的管理能力;同时具备分布式能力,满足超级终端场景下,相同应用多设备间的数据对象协同需求。 +分布式数据对象管理框架是一款面向对象的内存数据管理框架。向应用开发者提供内存对象的创建、查询、删除、修改、订阅等基本数据对象的管理能力;同时具备分布式能力,满足超级终端场景下,相同应用多设备间的数据对象协同需求。 ## 基本概念 @@ -36,7 +36,7 @@ - 不同设备间只有相同bundleName的应用才能直接同步。 -- 不建议创建过多分布式数据对象,每个分布式数据对象将占用100-150KB内存。 +- 不建议创建过多的分布式数据对象,每个分布式数据对象将占用100-150KB内存。 - 每个分布式数据对象大小不超过500KB。 diff --git a/zh-cn/application-dev/database/database-mdds-guidelines.md b/zh-cn/application-dev/database/database-mdds-guidelines.md index 6558bc98420f88eb0696e9c1cfb0413959ab1d6b..29d48003a3a1fd8985c7b517b3bfb3b1cc74b1fb 100644 --- a/zh-cn/application-dev/database/database-mdds-guidelines.md +++ b/zh-cn/application-dev/database/database-mdds-guidelines.md @@ -6,7 +6,7 @@ ## 接口说明 -具体分布式数据相关功能接口请见[分布式数据管理](../reference/apis/js-apis-distributed-data.md)。 +分布式数据相关功能接口请见[分布式数据管理](../reference/apis/js-apis-distributed-data.md)。 **表1** 分布式数据服务关键API功能介绍 @@ -21,72 +21,74 @@ | on(event:'dataChange',type:SubscribeType,observer:Callback<ChangeNotification>):void
on(event:'syncComplete',syncCallback:Callback<Array<[string,number]>>):void | 订阅数据库中数据的变化。 | | sync(deviceIdList:string[],mode:SyncMode,allowedDelayMs?:number):void | 在手动模式下,触发数据库同步。 | - - - ## 开发步骤 以单版本分布式数据库为例,说明开发步骤。 1. 导入模块。 + ```js import distributedData from '@ohos.data.distributedData'; ``` 2. 根据配置构造分布式数据库管理类实例。 + 1. 根据应用上下文创建`kvManagerConfig`对象。 2. 创建分布式数据库管理器实例。 以下为创建分布式数据库管理器的代码示例: + ```js let kvManager; try { - const kvManagerConfig = { - bundleName : 'com.example.datamanagertest', - userInfo : { - userId : '0', - userType : distributedData.UserType.SAME_USER_ID - } + const kvManagerConfig = { + bundleName: 'com.example.datamanagertest', + userInfo: { + userId: '0', + userType: distributedData.UserType.SAME_USER_ID } - distributedData.createKVManager(kvManagerConfig, function (err, manager) { - if (err) { - console.log("createKVManager err: " + JSON.stringify(err)); - return; - } - console.log("createKVManager success"); - kvManager = manager; - }); + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("createKVManager err: " + JSON.stringify(err)); + return; + } + console.log("createKVManager success"); + kvManager = manager; + }); } catch (e) { - console.log("An unexpected error occurred. Error:" + e); + console.log("An unexpected error occurred. Error: " + e); } ``` 3. 获取/创建分布式数据库。 + 1. 声明需要创建的分布式数据库ID描述。 2. 创建分布式数据库,建议关闭自动同步功能(`autoSync:false`),需要同步时主动调用`sync`接口。 以下为创建分布式数据库的代码示例: + ```js let kvStore; try { - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : false, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - securityLevel : distributedData.SecurityLevel.S0 - }; - kvManager.getKVStore('storeId', options, function (err, store) { - if (err) { - console.log("getKVStore err: " + JSON.stringify(err)); - return; - } - console.log("getKVStore success"); - kvStore = store; - }); + const options = { + createIfMissing: true, + encrypt: false, + backup: false, + autoSync: false, + kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, + securityLevel: distributedData.SecurityLevel.S0 + }; + kvManager.getKVStore('storeId', options, function (err, store) { + if (err) { + console.log("getKVStore err: " + JSON.stringify(err)); + return; + } + console.log("getKVStore success"); + kvStore = store; + }); } catch (e) { - console.log("An unexpected error occurred. Error:" + e); + console.log("An unexpected error occurred. Error: " + e); } ``` @@ -95,7 +97,9 @@ > 组网设备间同步数据的场景,建议在应用启动时打开分布式数据库,获取数据库的句柄。在该句柄(如示例中的`kvStore`)的生命周期内无需重复创建数据库,可直接使用句柄对数据库进行数据的插入等操作。 4. 订阅分布式数据变化。 + 以下为订阅单版本分布式数据库数据变化通知的代码示例: + ```js kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { console.log("dataChange callback call data: " + JSON.stringify(data)); @@ -103,6 +107,7 @@ ``` 5. 将数据写入分布式数据库。 + 1. 构造需要写入分布式数据库的`Key`(键)和`Value`(值)。 2. 将键值数据写入分布式数据库。 @@ -112,43 +117,46 @@ 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, function (err,data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.log("put err: " + JSON.stringify(err)); return; } console.log("put success"); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + } catch (e) { + console.log("An unexpected error occurred. Error: " + e); } ``` 6. 查询分布式数据库数据。 + 1. 构造需要从单版本分布式数据库中查询的`Key`(键)。 2. 从单版本分布式数据库中获取数据。 以下为从分布式数据库中查询字符串类型数据的代码示例: + ```js 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, function (err,data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.log("put err: " + JSON.stringify(err)); return; } console.log("put success"); - kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { + kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { console.log("get success data: " + data); }); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + } catch (e) { + console.log("An unexpected error occurred. Error: " + e); } ``` 7. 同步数据到其他设备。 + 选择同一组网环境下的设备以及同步模式,进行数据同步。 > **说明**: @@ -156,6 +164,7 @@ > 其中`deviceManager`模块的接口均为系统接口。 以下为单版本分布式数据库进行数据同步的代码示例: + ```js import deviceManager from '@ohos.distributedHardware.deviceManager'; @@ -175,15 +184,19 @@ try{ // 1000表示最大延迟时间为1000ms kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + } catch (e) { + console.log("An unexpected error occurred. Error: " + e); } } }); ``` ## 相关实例 + 针对分布式数据开发,有以下相关实例可供参考: -- [`DistributedDataGobang`:分布式五子棋(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedDataGobang) -- [`DDMQuery`:结果集与谓词(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DDMQuery) -- [`KvStore`:分布式数据库(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) + +- [`DistributedCalc`:分布式计算器(JS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/DistributeCalc) +- [`DistributedCalc`:分布式计算器(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/Preset/DistributeCalc) +- [`DistributedDataGobang`:分布式五子棋(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/data/DistributedDataGobang) +- [`DDMQuery`:结果集与谓词(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/data/DDMQuery) +- [`KvStore`:分布式数据库(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/data/Kvstore) - [分布式数据库(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) \ No newline at end of file diff --git a/zh-cn/application-dev/database/database-preference-guidelines.md b/zh-cn/application-dev/database/database-preference-guidelines.md index 55e258e3650726dd0ef39d3bf367118ca6496759..247076af7599e7343a82bb70380bb2850b519860 100644 --- a/zh-cn/application-dev/database/database-preference-guidelines.md +++ b/zh-cn/application-dev/database/database-preference-guidelines.md @@ -115,14 +115,15 @@ ```js promise.then((preferences) => { - let getPromise = preferences.get('startup', 'default'); - getPromise.then((value) => { - console.info("The value of 'startup' is " + value); - }).catch((err) => { - console.info("Failed to get the value of 'startup'. Cause: " + err); - }) + let getPromise = preferences.get('startup', 'default'); + getPromise.then((value) => { + console.info("The value of 'startup' is " + value); + }).catch((err) => { + console.info("Failed to get the value of 'startup'. Cause: " + err); + }) }).catch((err) => { - console.info("Failed to get preferences.")}); + console.info("Failed to get preferences.") + }); ``` 5. 数据持久化。 @@ -138,24 +139,24 @@ 应用订阅数据变化需要指定observer作为回调方法。订阅的Key的值发生变更后,当执行flush方法时,observer被触发回调。 ```js - var observer = function (key) { - console.info("The key" + key + " changed."); - } - preferences.on('change', observer); - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of 'startup'. Cause: " + err); - return; - } - console.info("Succeeded in putting the value of 'startup'."); - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush. Cause: " + err); - return; - } - console.info("Succeeded in flushing."); // observer will be called. - }) - }) + var observer = function (key) { + console.info("The key" + key + " changed."); + } + preferences.on('change', observer); + preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of 'startup'. Cause: " + err); + return; + } + console.info("Succeeded in putting the value of 'startup'."); + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush. Cause: " + err); + return; + } + console.info("Succeeded in flushing."); // observer will be called. + }) + }) ``` 7. 删除指定文件。 @@ -163,14 +164,14 @@ 使用deletePreferences方法从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。删除后,数据及文件将不可恢复。 ```js - let proDelete = data_preferences.deletePreferences(context, 'mystore'); - proDelete.then(() => { - console.info("Succeeded in deleting."); - }).catch((err) => { - console.info("Failed to delete. Cause: " + err); - }) + let proDelete = data_preferences.deletePreferences(context, 'mystore'); + proDelete.then(() => { + console.info("Succeeded in deleting."); + }).catch((err) => { + console.info("Failed to delete. Cause: " + err); + }) ``` ## 相关实例 针对首选项开发,有以下相关实例可供参考: -- [`Preferences`:首选项(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/data/Preferences) \ No newline at end of file +- [`Preferences`:首选项(eTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/data/Preferences) \ No newline at end of file diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md index 234b24caae2ee2e9b75671991ec458079a83755d..6faff74f2301251a65941e700b2b20012e539fd0 100644 --- a/zh-cn/application-dev/database/database-relational-guidelines.md +++ b/zh-cn/application-dev/database/database-relational-guidelines.md @@ -198,10 +198,10 @@ import data_rdb from '@ohos.data.rdb' const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; - const STORE_CONFIG = {name: "rdbstore.db",} + const STORE_CONFIG = { name: "rdbstore.db" } data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(CREATE_TABLE_TEST) - console.info('create table done.') + rdbStore.executeSql(CREATE_TABLE_TEST) + console.info('create table done.') }) ``` @@ -215,7 +215,7 @@ ```js var u8 = new Uint8Array([1, 2, 3]) - const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,} + const valueBucket = { "name": "Tom", "age": 18, "salary": 100.5, "blobType": u8 } let insertPromise = rdbStore.insert("test", valueBucket) ``` @@ -314,6 +314,7 @@ console.log('device=' + device[i] + 'data changed') } } + try { rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) } catch (err) { @@ -364,9 +365,7 @@ (1) 调用数据库的备份接口,备份当前数据库文件。 - (2) 调用数据库的恢复接口,从数据库的备份文件恢复数据库文件。 - - 示例代码如下: + 示例代码如下: ```js let promiseBackup = rdbStore.backup("dbBackup.db") @@ -376,6 +375,10 @@ console.info('Backup failed, err: ' + err) }) ``` + (2) 调用数据库的恢复接口,从数据库的备份文件恢复数据库文件。 + + 示例代码如下: + ```js let promiseRestore = rdbStore.restore("dbBackup.db") promiseRestore.then(() => { @@ -387,6 +390,5 @@ ## 相关实例 针对关系型数据库开发,有以下相关实例可供参考: -- [`Rdb`:关系型数据库(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb) -- [`DistributedRdb`:分布式关系型数据库(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb) +- [`DistributedRdb`:分布式关系型数据库(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/data/DistributedRdb) - [关系型数据库(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData) \ No newline at end of file diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md index 098873dec1929a1887c51a64c8f10ce329914236..494508ffcb752fea7c16cea172c09476393c7c79 100644 --- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md +++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md @@ -438,5 +438,5 @@ import stats from '@ohos.bundleState'; ``` ## 相关实例 针对设备使用信息统计,有以下相关实例可供参考: -- [`DeviceUsageStatistics`:设备使用信息统计(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/device/DeviceUsageStatistics) +- [`DeviceUsageStatistics`:设备使用信息统计(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/device/DeviceUsageStatistics) diff --git a/zh-cn/application-dev/device/device-location-overview.md b/zh-cn/application-dev/device/device-location-overview.md index d6a7606f38bc5ad49b72d9c8818ba2c0ec905d63..abd7fd615fecca1587c3deb5ee0bd1c11760a313 100644 --- a/zh-cn/application-dev/device/device-location-overview.md +++ b/zh-cn/application-dev/device/device-location-overview.md @@ -42,4 +42,4 @@ 针对位置服务,有以下相关实例可供参考: --[`Location`:位置服务(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/device/Location) +-[`Location`:位置服务(eTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/device/Location) diff --git a/zh-cn/application-dev/device/sensor-guidelines.md b/zh-cn/application-dev/device/sensor-guidelines.md index 8ffc74e20dea5ce602b497d67405ed87312ccf87..77d54dd0f32360733fed9892cd48fa3bff03d7fd 100644 --- a/zh-cn/application-dev/device/sensor-guidelines.md +++ b/zh-cn/application-dev/device/sensor-guidelines.md @@ -139,4 +139,4 @@ 针对传感器开发,有以下相关实例可供参考: -- [`Sensor`:传感器(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/device/Sensor) \ No newline at end of file +- [`Sensor`:传感器(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/device/Sensor) \ No newline at end of file diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md index 938786fd4b316a19c78b20867a4ee57e560f4e6e..bcad09090fa86580778829faaba1ff451abfefd3 100644 --- a/zh-cn/application-dev/device/usb-guidelines.md +++ b/zh-cn/application-dev/device/usb-guidelines.md @@ -17,19 +17,19 @@ USB类开放能力如下,具体请查阅[API参考文档](../reference/apis/js | 接口名 | 描述 | | -------- | -------- | -| hasRight(deviceName: string): boolean | 如果“使用者”(如各种App或系统)有权访问设备则返回true;无权访问设备则返回false。 | -| requestRight(deviceName: string): Promise<boolean> | 请求给定软件包的临时权限以访问设备。 | -| connectDevice(device: USBDevice): Readonly<USBDevicePipe> | 根据getDevices()返回的设备信息打开USB设备。 | -| getDevices(): Array<Readonly<USBDevice>> | 返回USB设备的列表。 | -| setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | 设置设备的配置。 | -| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | 设置设备的接口。 | -| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number | 获取接口。 | -|bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> | 批量传输。 | -| closePipe(pipe: USBDevicePipe): number | 关闭设备消息控制通道。 | -| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | 释放接口。 | -| getFileDescriptor(pipe: USBDevicePipe): number | 获取文件描述符。 | -| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | 获取原始的USB描述符。 | -| controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> | 控制传输。 | +| hasRight(deviceName:string):boolean | 如果“使用者”(如各种App或系统)有权访问设备则返回true;无权访问设备则返回false。 | +| requestRight(deviceName:string):Promise<boolean> | 请求给定软件包的临时权限以访问设备。 | +| connectDevice(device:USBDevice):Readonly<USBDevicePipe> | 根据`getDevices()`返回的设备信息打开USB设备。 | +| getDevices():Array<Readonly<USBDevice>> | 返回USB设备列表。 | +| setConfiguration(pipe:USBDevicePipe,config:USBConfig):number | 设置设备的配置。 | +| setInterface(pipe:USBDevicePipe,iface:USBInterface):number | 设置设备的接口。 | +| claimInterface(pipe:USBDevicePipe,iface:USBInterface,force?:boolean):number | 获取接口。 | +|bulkTransfer(pipe:USBDevicePipe,endpoint:USBEndpoint,buffer:Uint8Array,timeout?:number):Promise<number> | 批量传输。 | +| closePipe(pipe:USBDevicePipe):number | 关闭设备消息控制通道。 | +| releaseInterface(pipe:USBDevicePipe,iface:USBInterface):number | 释放接口。 | +| getFileDescriptor(pipe:USBDevicePipe):number | 获取文件描述符。 | +| getRawDescriptor(pipe:USBDevicePipe):Uint8Array | 获取原始的USB描述符。 | +| controlTransfer(pipe:USBDevicePipe,contrlparam:USBControlParams,timeout?:number):Promise<number> | 控制传输。 | ## 开发步骤 @@ -115,7 +115,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 打开对应接口,在设备信息(deviceList)中选取对应的interface。 interface1为设备配置中的一个接口。 */ - usb.claimInterface(pipe , interface1, true); + usb.claimInterface(pipe, interface1, true); ``` 4. 数据传输。 @@ -155,4 +155,4 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` ## 相关实例 针对USB管理开发,有以下相关实例可供参考: -- [`USBManager`:USB管理(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/device/USBManager) +- [`USBManager`:USB管理(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/device/USBManager) diff --git a/zh-cn/application-dev/device/vibrator-guidelines.md b/zh-cn/application-dev/device/vibrator-guidelines.md index e97b83874daab0ad9059f64f089dd6bb7f2bf34c..2da1934e2307d7fcdaea029b30b8482e3a73925d 100644 --- a/zh-cn/application-dev/device/vibrator-guidelines.md +++ b/zh-cn/application-dev/device/vibrator-guidelines.md @@ -89,4 +89,4 @@ 针对振动开发,有以下相关实例可供参考: -- [`Vibrator`:振动(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/device/Vibrator) \ No newline at end of file +- [`Vibrator`:振动(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/device/Vibrator) \ No newline at end of file diff --git a/zh-cn/application-dev/dfx/hiappevent-guidelines.md b/zh-cn/application-dev/dfx/hiappevent-guidelines.md index 23de727ff9f4c9e2fc857a68bcbc1c49163e1f73..da87158885033a25942fb4da2a9ed02253f7d5f3 100644 --- a/zh-cn/application-dev/dfx/hiappevent-guidelines.md +++ b/zh-cn/application-dev/dfx/hiappevent-guidelines.md @@ -162,4 +162,4 @@ 针对应用事件开发,有以下相关实例可供参考: -- [`JsDotTest`:测试打点(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest) \ No newline at end of file +- [`JsDotTest`:测试打点(JS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/DFX/JsDotTest) \ No newline at end of file diff --git a/zh-cn/application-dev/faqs/Readme-CN.md b/zh-cn/application-dev/faqs/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..7eeb2c756aed17a3bb8ddbdfd5a30e0bef9e9513 --- /dev/null +++ b/zh-cn/application-dev/faqs/Readme-CN.md @@ -0,0 +1,15 @@ +# 常见问题 + +- [Ability框架开发常见问题](faqs-ability.md) +- [UI框架(JS)开发常见问题](faqs-ui-js.md) +- [UI框架(eTS)开发常见问题](faqs-ui-ets.md) +- [图形图像开发常见问题](faqs-graphics.md) +- [文件管理开发常见问题](faqs-file-management.md) +- [网络与连接开发常见问题](faqs-connectivity.md) +- [数据管理开发常见问题](faqs-data-management.md) +- [设备管理开发常见问题](faqs-device-management.md) +- [Native API使用常见问题](faqs-native.md) +- [三四方库使用常见问题](faqs-third-party-library.md) +- [IDE使用常见问题](faqs-ide.md) +- [hdc_std命令使用常见问题](faqs-hdc-std.md) +- [开发板](faqs-development-board.md) diff --git a/zh-cn/application-dev/faqs/faqs-ability.md b/zh-cn/application-dev/faqs/faqs-ability.md new file mode 100644 index 0000000000000000000000000000000000000000..ffc4e0123da0ff228305bee962807bd279193acd --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-ability.md @@ -0,0 +1,62 @@ +# Ability框架开发常见问题 + + + +## Stage模型中是否有类似FA模型的DataAbility的开发指导文档 + +适用于:OpenHarmony SDK 3.2.3.5版本, API9 Stage模型 + +Stage模型中DataShareExtensionAbility提供了向其他应用共享以及管理其数据的方法。 + +参考文档:[数据共享开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/database/database-datashare-guidelines.md) + +## 拉起Ability为什么在界面上没反应? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +1. 如果是通过startAbility的方式拉起,检查want中abilityName字段是否携带了bundleName做前缀,如果有,请删除; + +2. 检查MainAbility.ts文件中onWindowStageCreate方法配置的Ability首页文件是否在main_pages.json中有定义,如果没有定义,请补齐; + +3. SDK和OpenHarmony SDK系统推荐同一天的版本。 + +参考文档:[OpenHarmony版本转测试信息](https://gitee.com/openharmony-sig/oh-inner-release-management/blob/master/Release-Testing-Version.md) + +## 调用方法的时候,如何解决方法内部的this变成undefined? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +方式一:在调用方法的时候加上.bind(this); + +方式二:使用箭头函数。 + +## 如何解决must have required property 'startWindowIcon'报错 + +适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 + +Ability配置中缺少startWindowIcon属性配置,需要在module.json5中abilities中配置startWindowIcon。 + +参考文档:[Stage模型配置文件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/stage-structure.md) + + 示例: + +``` +{ + "module": { + // do something + "abilities": [{ + // do something + "startWindowIcon": "$media:space", + "startWindowBackground": "$color:white", + }] + } +} +``` + +## 如何获取设备横竖屏的状态变化的通知 + +适用于:OpenHarmony SDK 3.2.3.5版本, API9 Stage模型 + +使用Ability的onConfigurationUpdated回调实现,系统语言、颜色模式以及Display相关的参数,比如方向、Density,发生变化时触发该回调。 + +参考文档:[Ability开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/stage-ability.md) diff --git a/zh-cn/application-dev/faqs/faqs-connectivity.md b/zh-cn/application-dev/faqs/faqs-connectivity.md new file mode 100644 index 0000000000000000000000000000000000000000..8690d9c205472b021b38799bf519fdde37a87aa9 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-connectivity.md @@ -0,0 +1,31 @@ +# 网络与连接开发常见问题 + + + +## Post请求时,extraData支持哪几种的数据格式? + +适用于:OpenHarmony SDK 3.2.2.5版本, API9 Stage模型 + +extraData代表发送请求的额外数据,支持如下数据: + +1. 当HTTP请求为POST、PUT方法时,此字段为HTTP请求的content。 + +2. 当HTTP请求为GET、OPTIONS、DELETE、TRACE、CONNECT方法时,此字段为HTTP请求的参数补充,参数内容会拼接到URL中进行发送。 + +3. 开发者传入string对象,开发者需要自行编码,将编码后的string传入。 + +## 如何理解http请求的错误码28? + +适用于:OpenHarmony SDK 3.2.2.5版本,API9 Stage模型 + +错误码28代表CURLE_OPERATION_TIMEDOUT 。网络请求底层使用libcurl库,更多错误码可以查看相应文档。 + +参考文档:[开发指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-http.md#response%E5%B8%B8%E7%94%A8%E9%94%99%E8%AF%AF%E7%A0%81)和[Curl错误码](https://curl.se/libcurl/c/libcurl-errors.html) + +## \@ohos.net.http.d.ts的response错误码返回6是什么意思? + +适用于:OpenHarmony SDK 3.2.3.5版本 + +6表示地址无法解析主机,可以尝试ping一下request中的url,确认是否可以ping通。 + +更多错误码参考[Response常用错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-http.md#response%E5%B8%B8%E7%94%A8%E9%94%99%E8%AF%AF%E7%A0%81)或者[Curl错误码](https://curl.se/libcurl/c/libcurl-errors.html) diff --git a/zh-cn/application-dev/faqs/faqs-data-management.md b/zh-cn/application-dev/faqs/faqs-data-management.md new file mode 100644 index 0000000000000000000000000000000000000000..bdeef869a7c52819b9634b1d5a4432d41c20118c --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-data-management.md @@ -0,0 +1,24 @@ +# 数据管理开发常见问题 + + + +## 如何将PixelMap的数据存储到数据库中。 + +适用于:OpenHarmony SDK 3.2.3.5版本 + +PixelMap应该被转换成相应的ArrayBuffer再放进数据库。 + +参考文档:[readPixelsToBuffer](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md#readpixelstobuffer7-1) + +## 如何获取rdb关系型数据库文件 + +适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 + +开发者可使用hdc_std命令拷贝文件,其中文件路径为: /data/app/el2/100/database/包名/entry/db/ ,然后拷贝该路径下后缀为 .db、.db-shm、.db-wal的文件,拷贝完成后,可以通过SQLite工具打开该数据库文件。 + +示例: + + +``` + hdc_std file recv /data/app/el2/100/database/com.xxxx.xxxx/entry/db/test.db ./test.db +``` diff --git a/zh-cn/application-dev/faqs/faqs-development-board.md b/zh-cn/application-dev/faqs/faqs-development-board.md new file mode 100644 index 0000000000000000000000000000000000000000..3ab491c0dc6b42b0ca2e91e7a55965f51f9d34ad --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-development-board.md @@ -0,0 +1,51 @@ +# 开发板 + + + +## 如何获取开发板上截屏图片? + +适用于:OpenHarmony SDK 3.2.2.5版本,API9 Stage模型 + +- 方法一:点击开发板下拉控制中心的截屏按钮,截屏图片通过相册可以查看。 + +- 方法二:通过截屏脚本一键截屏,可以在电脑上查看。操作方法:Windows上连接开发板,然后电脑上新建文本文件,拷贝如下脚本内容,文件名后缀改为.bat文件(需要提前配置好hdc的环境变量),点击运行后,截屏图片与脚本在同一目录。 + 示例: + + + ``` + set filepath=/data/%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%.png + echo %filepath% + : pause + hdc_std shell snapshot_display -f %filepath% + : pause + hdc_std file recv %filepath% . + : pause + ``` + +## RK3568板子和previewer上展示的效果差异较大,如何把previewer的尺寸调整成实际板子一样。 + +适用于:IDE 3.0.0.991 + +1. 给预览器新建Profile + ![zh-cn_image_0000001361254285](figures/zh-cn_image_0000001361254285.png) + +2. 新建Profile的具体参数可参考如下配置: + Device type : default + + Resolution: 720\*1280 + + DPI: 240 + +## 开发板安装驱动后设备仍然无法识别,设备管理器错误识别为其他设备:FT232R USB UART () + +可能原因:开发版的USB串口驱动没有安装。 + +解决办法:搜索FT232R USB UART确定,下载安装驱动即可。 + +## 在开发板上登录需要认证网络如何进行认证 + +适用于:OpenHarmony SDK 3.2.2.5版本 + +连接需要认证的网络后,用浏览器打开任意网址就可以进入认证页面。 + +如果开发板上没有浏览器,可以安装[浏览器Sample应用](https://gitee.com/openharmony/app_samples/tree/master/device/Browser)。 diff --git a/zh-cn/application-dev/faqs/faqs-device-management.md b/zh-cn/application-dev/faqs/faqs-device-management.md new file mode 100644 index 0000000000000000000000000000000000000000..b5bac9f878fb9e5bbe7732479e97c478df7dfc5d --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-device-management.md @@ -0,0 +1,24 @@ +# 设备管理开发常见问题 + + + +## 如何获取设备的dpi值 + +适用于:OpenHarmony SDK 3.2.2.5版本,API9 Stage模型 + +导入@ohos.display包,通过getDefaultDisplay方法获取。 + +示例: + + +``` +import display from '@ohos.display'; +display.getDefaultDisplay((err, data) => { + if (err.code) { + console.error('Test Failed to obtain the default display object. Code: ' + JSON.stringify(err)); + return; + } + console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); + console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); +});https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-device-info.md) +``` diff --git a/zh-cn/application-dev/faqs/faqs-file-management.md b/zh-cn/application-dev/faqs/faqs-file-management.md new file mode 100644 index 0000000000000000000000000000000000000000..a6caa4a7064430e4b0c2a2fb49523a8a433ec564 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-file-management.md @@ -0,0 +1,36 @@ +# 文件管理开发常见问题 + + + +## 调用媒体库getAlbums方法,没有收到返回,也没有捕获到异常是为什么 + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +getAlbums方法需要权限:ohos.permission.READ_MEDIA,从[OpenHarmony权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查询知道ohos.permission.READ_MEDIA权限是需要用户授权。 + +1. 在module.json5中配置权限: + + ``` + "requestPermissions": [ + { + "name": "ohos.permission.READ_MEDIA" + } + ] + ``` + +2. 在MainAbility.ts -> onWindowStageCreate页面加载前需要增加用户授权代码: + + ``` + private requestPermissions() { + let permissionList: Array = [ + "ohos.permission.READ_MEDIA" + ]; + this.context.requestPermissionsFromUser(permissionList) + .then(data => { + console.info(`request permission data result = ${data.authResults}`) + }) + .catch(err => { + console.error(`fail to request permission error:${err}`) + }) + } + ``` diff --git a/zh-cn/application-dev/faqs/faqs-graphics.md b/zh-cn/application-dev/faqs/faqs-graphics.md new file mode 100644 index 0000000000000000000000000000000000000000..f72711aefb13db79150b749d9a3e6ed470597d0c --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-graphics.md @@ -0,0 +1,15 @@ +# 图形图像开发常见问题 + + + +## 调用window实例的setSystemBarProperties接口时,设置isStatusBarLightIcon和isNavigationBarLightIcon属性不生效 + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +状态栏字体高亮属性的本质就只是让字体变成白色。调用window实例的setSystemBarProperties接口时,如果设置了状态栏内容颜色statusBarContentColor,就以开发者设置的颜色为准,isStatusBarLightIcon状态栏字体高亮属性就不生效;同理,如果设置了导航栏内容颜色navigationBarContentColor,isNavigationBarLightIcon导航栏字体高亮属性就不生效。 + +## 如何设置系统状态栏样式 + +适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 + +导入\@ohos.window模块,开发者可以使用window.setSystemBarProperties()接口设置状态栏样式属性,达到自定义样式的效果。 diff --git a/zh-cn/application-dev/faqs/faqs-hdc-std.md b/zh-cn/application-dev/faqs/faqs-hdc-std.md new file mode 100644 index 0000000000000000000000000000000000000000..90f627289b2fcefa4d9e62d23249f22ed7e597c2 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-hdc-std.md @@ -0,0 +1,63 @@ +# hdc_std命令使用常见问题 + + + +## 日志的常用命令 + +适用于:OpenHarmony SDK 3.2.2.5版本 + +清理日志:hdc_std shell hilog -r + +调大缓存到20M:hdc_std shell hilog -G 20M + +抓取日志:hdc_std shell hilog > log.txt + +## 日志限流怎么规避 + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +- 关闭日志限流 hdc_std shell hilog -Q pidoff + +- 关闭隐私标志 hdc_std shell hilog -p off + +- 增加日志buffer hdc_std shell hilog -G 200M + +- 关闭全局日志,只打开自己领域的日志 hdc_std shell hilog –b D –D 0xd0xxxxx + +执行完命令后重启DevEco Studio。 + +## 应用如何打印日志是使用hilog还是console,hilog接口参数domain的设置范围是什么? + +适用于:OpenHarmony SDK 3.2.2.5版本 + +推荐使用[hilog日志系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-hilog.md)进行日志打印,接口参数domain的设置范围可以参考[开发指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-hilog.md#hilogisloggable)。 + +## hilog日志打印长度限制是多少,是否可以配置 + +适用于:OpenHarmony SDK 3.2.2.5版本 + +日志打印的长度限制为1024,该长度不能配置。 + +## 为什么有时候直接用IDE安装HAP包到开发板上无法打开? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +请检查sdk和开发板烧录的系统版本是否一致,推荐取同一天的sdk和系统版本。 + +## 如何通过hdc命令上传文件 + +适用于:OpenHarmony SDK 3.2.2.5版本 + +可以使用hdc_std file send上传文件。 + +## 如何让RK3568开发板不熄屏? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +输入命令hdc_std shell "power-shell setmode 602" + +## 如何通过命令启动Ability? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +输入命令hdc_std shell aa start -a AbilityName -b bundleName -m moduleName diff --git a/zh-cn/application-dev/faqs/faqs-ide.md b/zh-cn/application-dev/faqs/faqs-ide.md new file mode 100644 index 0000000000000000000000000000000000000000..c9b32df07511cccbb9c1607d5bb121b635372457 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-ide.md @@ -0,0 +1,19 @@ +# IDE使用常见问题 + + + +## 如何解决报错“npm ERR! code SELF_SIGNED_CERT_IN_CHAIN”? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +1. 在Dev Eco Studio terminal中执行npm config set strict-ssl=false; + +2. 在Dev Eco Studio terminal中执行npm install。 + +## 手工更新DevEco的SDK后,编译HAP报错“Cannot find module 'xxx\ets\x.x.x.x\build-tools\ets-loader\node_modules\webpack\bin\webpack.js'” + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +1. 到SDK的ets\x.x.x.x\build-tools\ets-loader目录下执行npm install; + +2. 到SDK的js\x.x.x.x\build-tools\ace-loader目录下执行npm install。 完成步骤后重新编辑既可。 diff --git a/zh-cn/application-dev/faqs/faqs-native.md b/zh-cn/application-dev/faqs/faqs-native.md new file mode 100644 index 0000000000000000000000000000000000000000..cbf66a518dc8e55090fceb0b4d3858c22c814703 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-native.md @@ -0,0 +1,57 @@ +# Native API使用常见问题 + + + +## 运行Native HAP的时候,导入的命名空间报错Obj is not a valid object + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +检查模块根目录(注意不是工程根目录)下的build-profile.json5文件,如果设备是32位,需要在abiFilters参数中配置armeabi-v7a,如果设备是64位,需要在abiFilters参数中配置arm64-v8a。 + +## NAPI开发的C++代码中,如何获取到模块 package.json 文件中的 “version” 值? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +1. 在编译工具Hvigor脚本文件hvigorfile.js中,通过subModule.getPackageJsonPath方法获取module中package.json文件位置; + +2. 使用nodejs能力读取package.json文件中version字段,写入build-profile.json5文件buildOption.cppFlags字段; + +示例: + + +``` +// module hvigorfile.js +const subModule = require('@ohos/hvigor')(__filename) + +const fs = require("fs-extra") +const path = require("path") + +const packageJsonPath = subModule.getPackageJsonPath() +const buildProfilePath = path.resolve(packageJsonPath, '../build-profile.json5') +const packageJsonData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) +let buildProfileData = fs.readFileSync(buildProfilePath, 'utf8') +buildProfileData = buildProfileData.replace(/\"cppFlags\"\:(.*)\,/, `"cppFlags": "-D NWEBEX_VERSION=${packageJsonData.version}",`) +fs.writeFileSync(buildProfilePath, buildProfileData, 'utf8') + +const ohosPlugin = require('@ohos/hvigor-ohos-plugin').hapTasks(subModule) // 该插件执行了C++编译任务,读取了build-profile.json5文件 + +module.exports = { + ohos: ohosPlugin +} +``` + + +``` +// hellp.cpp 读取 +#define _NWEBEX_VERSION(v) #v +#define _NWEBEX_VER2STR(v) _NWEBEX_VERSION(v) + +static napi_value Add(napi_env env, napi_callback_info info) +{ + + napi_value fixed_version_value = nullptr; + napi_create_string_utf8(env, _NWEBEX_VER2STR(NWEBEX_VERSION), NAPI_AUTO_LENGTH, &fixed_version_value); + + return fixed_version_value; +} +``` diff --git a/zh-cn/application-dev/faqs/faqs-third-party-library.md b/zh-cn/application-dev/faqs/faqs-third-party-library.md new file mode 100644 index 0000000000000000000000000000000000000000..758305d4aca128e8d39001b2176c3f820f2302e2 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-third-party-library.md @@ -0,0 +1,9 @@ +# 三四方库使用常见问题 + + + +## 报错“Stage model module … does not support including OpenHarmony npm packages or modules in FA model. OpenHarmony build tasks will not be executed, and OpenHarmony resources will not be packed. ”是什么意思? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +三四方件未适配API9 Stage模型,无法使用。 diff --git a/zh-cn/application-dev/faqs/faqs-ui-ets.md b/zh-cn/application-dev/faqs/faqs-ui-ets.md new file mode 100644 index 0000000000000000000000000000000000000000..cd53f334c0463202a548a20158e27318923230b3 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-ui-ets.md @@ -0,0 +1,282 @@ +# UI框架(eTS)开发常见问题 + + + +## TS语言在生成器函数中编译失败,有哪些使用限制? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +TS语言的使用在生成器函数中存在以下限制: + +- 表达式仅允许在字符串(${expression})、if条件、ForEach的参数和组件的参数中使用; + +- 这些表达式中的任何一个都不能导致任何应用程序状态变量(\@State、\@Link、\@Prop)的改变,否则会导致未定义和潜在不稳定的框架行为; + +- 生成器函数内部不能有局部变量。 + +上述限制都不适用于事件处理函数(例如onClick)的匿名函数实现。 + +错误示例: + + +``` +build() { + let a: number = 1 // invalid: variable declaration not allowed + Column() { + Text('Hello ${this.myName.toUpperCase()}') // ok. + ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array varible in place + } + buildSpecial() // invalid: no function calls + Text(this.calcTextValue()) // this function call is ok. +} +``` + +## 在Stage模型下,如何通过router实现页面跳转 + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +1. 对于通过页面路由router实现页面跳转,首先要在main_pages.json配置文件中将所有跳转的页面加入pages列表; + +2. 页面路由需要在页面渲染完成之后才能调用,在onInit和onReady生命周期中页面还处于渲染阶段,禁止调用页面路由方法。 + +## router通过调用push方法进堆栈的page是否会被回收 + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +调用push进入堆栈的page不回收,调用back方法出栈后可以被回收。 + +## 如何动态替换掉资源文件中的“%s”占位符 + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +在应用中,通过"$r('app.string.xx')"的形式引用应用资源,$r的第二个参数可用于替换%s占位符。 + + 示例: + +``` +build() { + //do something + //引用的string资源,$r的第二个参数用于替换%s + Text($r('app.string.entry_desc','aaa')) + .fontSize(100) + .fontColor(Color.Black) + //do something +} +``` + +## 如何读取Resource中的xml文件并转化为String类型 + +适用于:OpenHarmony SDK 3.2.2.5版本, API9 Stage模型 + +1. 通过resourceManager的RawFile接口获取Uint8Array格式数据。 + +2. 通过String.fromCharCode将Uint8Array格式数据转化为String类型。 + +参考文档:[资源管理](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md) + +示例: + + +``` +resourceManager.getRawFile(path, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let rawFile = value; + let xml = String.fromCharCode.apply(null, rawFile) + } +}); +``` + +## 如何将Resource资源对象转成string类型 + +适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 + +通过\@ohos.resourceManager模块 resourceManager.getString()方法获取字符串。 + +参考文档:[资源管理](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md#getstring) + +## class全局静态变量无法使用的问题 + +适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 + +Page和Ability打包后会对import的对象分别形成两个不同的闭包,即打包出两个Global对象。因此,所引用的静态变量并不是同一对象,所以无法通过class静态变量方式定义全局变量。建议使用AppStorage进行全局变量管理。 + +参考文档:[应用程序的数据存储](https://docs.openharmony.cn/pages/v3.2Beta/zh-cn/application-dev/ui/ts-application-states-appstorage.md/) + +## Stage模型下如何获取资源 + +适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 + +Stage模型支持了通过context获取resourceManager对象的方式,再调用其内部获取资源的接口,无需再导入包,此方式FA模型不适用。 + +示例: + + +``` +const context = getContext(this) as any +context + .resourceManager + .getString($r('app.string.entry_desc').id) + .then(value => { + this.message = value.toString() +}) +``` + +## 如何将容器定位到屏幕的最底部? + +适用于:OpenHarmony SDK 3.2.3.5版本, API9 Stage模型 + +可以使用Stack堆叠容器,设置子组件在容器内的最底部。 + + 示例: + +``` +build() { + Stack({alignContent : Alignment.Bottom}) { + //容器位于最底部 + Stack() { + Column() + .width('100%') + .height('100%') + .backgroundColor(Color.Yellow) + } + .width('100%') + .height('10%') + } + .width('100%') + .height('100%') + .backgroundColor('rgba(255,255,255, 0)') +} +``` + +## CustomDialog是否支持在TS文件中使用? + +适用于:OpenHarmony SDK 3.2.2.5版本,API9 Stage模型 + +不支持,CustomDialog当前只支持在eTS的Page中使用。 + +参考文档:[自定义弹窗](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md) + +## 如何将CustomDialog中的变量传递给Page页面中的变量? + +适用于:OpenHarmony SDK 3.2.2.5版本,API9 Stage模型 + +利用自定义的回调函数,当点击弹窗的confirm按钮时,将data数据从自定义弹窗组件中传递给当前的page的页面。 + +示例: + + +``` +// CustomDialog 组件 +@CustomDialog +struct MyDialog { + controller: CustomDialogController + title: string + data: string + cancel: () => void + confirm: (data: string) => void + Button('confirm') + .onClick(() => { + this.controller.close() + this.data = 'test' + this.confirm(this.data) + }).backgroundColor(0xffffff).fontColor(Color.Red) +// Page页面 +@Entry +@Component +struct DialogTest { + dialogController: CustomDialogController = new CustomDialogController({ + builder: MyDialog({ title:'标题自定义',cancel: this.onCancel, + confirm: this.onAccept.bind(this) }), // 绑定自定义的回调函数 + cancel: this.existApp, + autoCancel: true + }) + onAccept(data:string) { + console.info('Callback when the second button is clicked ' + data) + } +} +``` + +## List组件上添加了Text组件后,List组件无法拖动到底部 + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +在List的父容器加上代码layoutWeight(1)。原理:List属于可滚动容器组件,默认高度是占满全屏幕高度,当出现其他固定高度的组件占领了屏幕的部分高度时,需要开发人员显性的指定List组件占满剩余高度,而不是全屏幕高度。 + +## 栅格布局子组件如何居中? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +GridContainer内子组件默认水平左对齐,居中显示可以参考以下处理方式: + +内部嵌套布局组件Row,设置Row属性justifyContent(FlexAlign.Center),内部嵌套子组件可保持居中显示,参考[栅格布局](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md)文档。 + + 示例: + +``` +GridContainer({ sizeType: SizeType.SM, columns: 12 }) { + Row() { + Text('1') + .useSizeType({ + sm: { span: 4, offset: 0 }, + }) + .backgroundColor(0x46F2B4) + }.justifyContent(FlexAlign.Center) // 该属性设置使子组件居中显示 +} +``` + +## 如何获取状态栏和导航栏高度? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +在加载窗口内容之前,采用systemAvoidAreaChange事件监听。 + + 示例: + +``` +// MainAbility.ts +import window from '@ohos.window'; + +/** + * 设置沉浸式窗口,并获取状态栏和导航栏高度 + * @param mainWindow 主窗口对象 + */ +async function enterImmersion(mainWindow: window.Window) { + mainWindow.on("systemAvoidAreaChange", (area: window.AvoidArea) => { + AppStorage.SetOrCreate("topHeight", area.topRect.height); + AppStorage.SetOrCreate("bottomHeight", area.bottomRect.height); + }) + await mainWindow.setFullScreen(true) + await mainWindow.setSystemBarEnable(["status", "navigation"]) + await mainWindow.setSystemBarProperties({ + navigationBarColor: "#00000000", + statusBarColor: "#00000000", + navigationBarContentColor: "#FF0000", + statusBarContentColor: "#FF0000" + }) +} +export default class MainAbility extends Ability { + // do something + async onWindowStageCreate(windowStage: window.WindowStage) { + let mainWindow = await windowStage.getMainWindow() + await enterImmersion(mainWindow) + windowStage.loadContent('pages/index') + } + // do something +} +``` + +## 如何在eTS代码中执行Web组件内的JS函数? + +适用于:OpenHarmony SDK 3.2.3.5版本, API9 Stage模型 + +通过WebController中runJavaScript方法异步执行JavaScript脚本,并通过回调方式返回脚本执行的结果。注意:runJavaScript需要在loadUrl完成后,比如onPageEnd中调用。 + +参考文档:[Web](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md) + +## 在容器组件嵌套的场景下,如何解决手势拖拽事件出现错乱的问题? + +适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 + +gesture的属性distance默认值是5,把gesture的属性distance设成1就可以解决。 diff --git a/zh-cn/application-dev/faqs/faqs-ui-js.md b/zh-cn/application-dev/faqs/faqs-ui-js.md new file mode 100644 index 0000000000000000000000000000000000000000..390b9e3753099a245a1395f9fc8e82ff7f271675 --- /dev/null +++ b/zh-cn/application-dev/faqs/faqs-ui-js.md @@ -0,0 +1,96 @@ +# UI框架(JS)开发常见问题 + + + +## 如何取出xml文件中对应的字段 + +适用于:OpenHarmony SDK 3.2.3.5版本, API9 Stage模型 + +convertxml中convert方法提供了转换xml文本为JavaScript对象的能力。 + +示例: + + +``` +import convertxml from '@ohos.convertxml'; +// 代码片段 +xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; +let conv = new convertxml.ConvertXML(); +// 转换选项, 参考文档使用 +let options = {trim : false, declarationKey:"_declaration", + instructionKey : "_instruction", attributesKey : "_attributes", + textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", + commentKey : "_comment", parentKey : "_parent", typeKey : "_type", + nameKey : "_name", elementsKey : "_elements"} +let result:any = conv.convert(xml, options) // 将xml文本转为JS对象 +console.log('Test: ' + JSON.stringify(result)) +console.log('Test: ' + result._declaration._attributes.version) // xml代码片段version字段信息 +console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // xml代码片段title字段内容 +``` + +参考文档:[xml转换JavaScript](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-convertxml.md) + +## JS、TS和eTS的区别 + +适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 + +- JS:Web 的编程语言。具有轻量级,弱类型等特点。 + +- TS:TS是JS的超集,拓展了JS的语法。有明确的类型与更多面向对象的内容如接口,枚举等。 + +- eTS:OpenHarmony UI开发框架语言,是对TS的扩展,通过声明式开发范式实现UI界面。 + +## 如何将时间转为时分秒格式 + +示例: + + +``` +export default class DateTimeUtil{ + /** + * 时分秒 + */ + getTime() { + const DATETIME = new Date() + return this.concatTime(DATETIME.getHours(),DATETIME.getMinutes(),DATETIME.getSeconds()) + } + /** + * 年月日 + */ + getDate() { + const DATETIME = new Date() + return this.concatDate(DATETIME.getFullYear(),DATETIME.getMonth()+1,DATETIME.getDate()) + } + /** + * 日期不足两位补充0 + * @param value-数据值 + */ + fill(value:number) { + return (value> 9 ? '' : '0') + value + } + /** + * 年月日格式修饰 + * @param year + * @param month + * @param date + */ + concatDate(year: number, month: number, date: number){ + return `${year}${this.fill(month)}${this.fill(date)}` + } + /** + * 时分秒格式修饰 + * @param hours + * @param minutes + * @param seconds + */ + concatTime(hours:number,minutes:number,seconds:number){ + return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}` + } +} +``` diff --git a/zh-cn/application-dev/faqs/figures/zh-cn_image_0000001361254285.png b/zh-cn/application-dev/faqs/figures/zh-cn_image_0000001361254285.png new file mode 100644 index 0000000000000000000000000000000000000000..bbce36c81db4c07075a8f91075842b6f33f35b34 Binary files /dev/null and b/zh-cn/application-dev/faqs/figures/zh-cn_image_0000001361254285.png differ diff --git a/zh-cn/application-dev/internationalization/intl-guidelines.md b/zh-cn/application-dev/internationalization/intl-guidelines.md index 0f3584a39921fe3065bc46b3ae296c297267442f..c14e19384a2ce28bc2bca975de01638daf8282c0 100644 --- a/zh-cn/application-dev/internationalization/intl-guidelines.md +++ b/zh-cn/application-dev/internationalization/intl-guidelines.md @@ -37,14 +37,6 @@ | kn | 表示字符串排序、比较时是否考虑数字的实际值 | | kf | 表示字符串排序、比较时是否考虑大小写 | -| 扩展参数ID | 扩展参数说明 | -| -------- | -------- | -| ca | 表示日历系统 | -| co | 表示排序规则 | -| hc | 表示守时惯例 | -| nu | 表示数字系统 | -| kn | 表示字符串排序、比较时是否考虑数字的实际值 | -| kf | 表示字符串排序、比较时是否考虑大小写 | ```js var locale = "zh-CN"; @@ -328,6 +320,6 @@ 针对Intl开发,有以下相关实例可供参考: --[`International`:国际化(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) +-[`International`:国际化(JS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/UI/International) --[`International`:国际化(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/International) \ No newline at end of file +-[`International`:国际化(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/International) \ No newline at end of file diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md b/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md index 474da8065f0ad6a0d8bd97afcca584ee260fbfc0..547597b6e0b751264dfbb432d445a7a8f47dd8a2 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md @@ -15,6 +15,6 @@ 下面将详细介绍这些布局能力。 ## 相关实例 针对一次开发,多端部署,有以下相关实例可供参考: -- [`AdaptiveCapabilities`:多设备自适应能力(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/MultiDeviceAppDev/AdaptiveCapabilities) -- [`JsAdaptiveCapabilities`:多设备自适应能力(JS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/MultiDeviceAppDev/JsAdaptiveCapabilities) +- [`AdaptiveCapabilities`:多设备自适应能力(eTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/AdaptiveCapabilities) +- [`JsAdaptiveCapabilities`:多设备自适应能力(JS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/JsAdaptiveCapabilities) - [一次开发多端部署(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/MultiDeploymentEts) diff --git a/zh-cn/application-dev/media/audio-capturer.md b/zh-cn/application-dev/media/audio-capturer.md index 84a51ffd2461a5e156d627f79033948b4a157be9..84702dd781f7c2bec186c7b1e5e61ed1333ff5c4 100644 --- a/zh-cn/application-dev/media/audio-capturer.md +++ b/zh-cn/application-dev/media/audio-capturer.md @@ -22,24 +22,24 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ```js var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } - var audioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 1 - } + var audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 1 + } - var audioCapturerOptions = { - streamInfo: audioStreamInfo, - capturerInfo: audioCapturerInfo - } + var audioCapturerOptions = { + streamInfo: audioStreamInfo, + capturerInfo: audioCapturerInfo + } - let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); - var state = audioRenderer.state; + let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); + var state = audioRenderer.state; ``` 2. (可选)使用on('stateChange')订阅音频采集器状态更改。 @@ -49,26 +49,26 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 audioCapturer.on('stateChange',(state) => { console.info('AudioCapturerLog: Changed State to : ' + state) switch (state) { - case audio.AudioState.STATE_PREPARED: - console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------'); - console.info('Audio State is : Prepared'); - break; - case audio.AudioState.STATE_RUNNING: - console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------'); - console.info('Audio State is : Running'); - break; - case audio.AudioState.STATE_STOPPED: - console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------'); - console.info('Audio State is : stopped'); - break; - case audio.AudioState.STATE_RELEASED: - console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------'); - console.info('Audio State is : released'); - break; - default: - console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------'); - console.info('Audio State is : invalid'); - break; + case audio.AudioState.STATE_PREPARED: + console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------'); + console.info('Audio State is : Prepared'); + break; + case audio.AudioState.STATE_RUNNING: + console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------'); + console.info('Audio State is : Running'); + break; + case audio.AudioState.STATE_STOPPED: + console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------'); + console.info('Audio State is : stopped'); + break; + case audio.AudioState.STATE_RELEASED: + console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------'); + console.info('Audio State is : released'); + break; + default: + console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------'); + console.info('Audio State is : invalid'); + break; } }); ``` @@ -80,9 +80,9 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ```js await audioCapturer.start(); if (audioCapturer.state == audio.AudioState.STATE_RUNNING) { - console.info('AudioRecLog: Capturer started'); + console.info('AudioRecLog: Capturer started'); } else { - console.info('AudioRecLog: Capturer start failed'); + console.info('AudioRecLog: Capturer start failed'); } ``` @@ -103,29 +103,29 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 const path = '/data/data/.pulse_dir/capture_js.wav'; let fd = fileio.openSync(path, 0o102, 0o777); if (fd !== null) { - console.info('AudioRecLog: file fd created'); + console.info('AudioRecLog: file fd created'); } else{ - console.info('AudioRecLog: file fd create : FAILED'); - return; + console.info('AudioRecLog: file fd create : FAILED'); + return; } fd = fileio.openSync(path, 0o2002, 0o666); if (fd !== null) { - console.info('AudioRecLog: file fd opened in append mode'); + console.info('AudioRecLog: file fd opened in append mode'); } var numBuffersToCapture = 150; while (numBuffersToCapture) { - var buffer = await audioCapturer.read(bufferSize, true); - if (typeof(buffer) == undefined) { - console.info('read buffer failed'); - } else { - var number = fileio.writeSync(fd, buffer); - console.info('AudioRecLog: data written: ' + number); - } + var buffer = await audioCapturer.read(bufferSize, true); + if (typeof(buffer) == undefined) { + console.info('read buffer failed'); + } else { + var number = fileio.writeSync(fd, buffer); + console.info('AudioRecLog: data written: ' + number); + } - numBuffersToCapture--; + numBuffersToCapture--; } ``` @@ -134,9 +134,9 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ``` await audioCapturer.stop(); if (audioCapturer.state == audio.AudioState.STATE_STOPPED) { - console.info('AudioRecLog: Capturer stopped'); + console.info('AudioRecLog: Capturer stopped'); } else { - console.info('AudioRecLog: Capturer stop failed'); + console.info('AudioRecLog: Capturer stop failed'); } ``` @@ -145,8 +145,8 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ```js await audioCapturer.release(); if (audioCapturer.state == audio.AudioState.STATE_RELEASED) { - console.info('AudioRecLog: Capturer released'); + console.info('AudioRecLog: Capturer released'); } else { - console.info('AudioRecLog: Capturer release failed'); + console.info('AudioRecLog: Capturer release failed'); } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index 6313ac85397e94b8e26c955ff647fc2d5c6208f3..0091b8cb7d20ec497cb98a6022f59444726b75f3 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -8,6 +8,8 @@ ![zh-ch_image_audio_state_machine](figures/zh-ch_image_audio_state_machine.png) +**说明**:当前为Idle状态,设置src不会改变状态;且src设置成功后,不能再次设置其它src,需调用reset()接口后,才能重新设置src。 + **图2** 音频播放零层图 @@ -256,7 +258,7 @@ export class AudioDemo { 针对音频播放开发,有以下相关实例可供参考: -- [`JsDistributedMusicPlayer`:分布式音乐播放(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer) -- [`JsAudioPlayer`:音频播放和管理(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) -- [`eTsAudioPlayer`: 音频播放器(eTS)(API8)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) +- [`JsDistributedMusicPlayer:`分布式音乐播放(JS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/JsDistributedMusicPlayer) +- [`JsAudioPlayer`:音频播放和管理(JS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/media/JsAudioPlayer) +- [`eTsAudioPlayer`: 音频播放器(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [音频播放器(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) \ No newline at end of file diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index 4fad7945ff6db32a2746751839a35427f5825674..85b07eaef0a61cf7e161c3c37a70928b2d1aa031 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -190,7 +190,7 @@ export class AudioRecorderDemo { 针对音频录制开发,有以下相关实例可供参考: -- [`Recorder`:录音机(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) -- [`JsRecorder`:录音机(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JSRecorder) -- [`eTsAudioPlayer`: 音频播放器(eTS)(API8)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) +- [`Recorder:`录音机(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/media/Recorder) +- [`JsRecorder`:录音机(JS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/media/JSRecorder) +- [`eTsAudioPlayer`: 音频播放器(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [音频播放器(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) diff --git a/zh-cn/application-dev/media/figures/zh-ch_image_audio_state_machine.png b/zh-cn/application-dev/media/figures/zh-ch_image_audio_state_machine.png index f6bdbebc49144f5afa093c753845ad7bd5d8f090..7497edd0edbdcfccbc448e9f2f48268ebb75e72e 100644 Binary files a/zh-cn/application-dev/media/figures/zh-ch_image_audio_state_machine.png and b/zh-cn/application-dev/media/figures/zh-ch_image_audio_state_machine.png differ diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index deda457636e444120cee5a4577ebe1fed567b5fa..6caf2a1fba2a11847e49325991e7edfc60857f51 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -115,6 +115,7 @@ pixelmap.release(()=>{ done(); }) +let path = '/data/local/tmp/test.jpg'; // 用于创建imagesource(uri) const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.jpg' @@ -145,7 +146,7 @@ imagePackerApi.release(); ### 解码场景 ```js -/data/local/tmp/test.jpg // 设置创建imagesource的路径 +let path = '/data/local/tmp/test.jpg'; // 设置创建imagesource的路径 // 用路径创建imagesource const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.jpg' @@ -222,7 +223,7 @@ catch(error => { ### 编码场景 ```js -/data/local/tmp/test.png // 设置创建imagesource的路径 +let path = '/data/local/tmp/test.png' // 设置创建imagesource的路径 // 用于设置imagesource const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.png' @@ -267,7 +268,7 @@ imageSourceApi.getImageInfo(imageInfo => { }) // 用于更新增量数据 -imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {}) +imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error, data)=> {}) ``` @@ -302,5 +303,5 @@ public async init(surfaceId: any) { 针对图片开发,有以下相关实例可供参考: -- [`Image`:图片处理(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/Image) -- [`GamePuzzle`:拼图(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/media/GamePuzzle) \ No newline at end of file +- [`Image`:图片处理(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/media/Image) +- [`GamePuzzle`:拼图(eTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/media/GamePuzzle) \ No newline at end of file diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index bb8a935684e397beef11c5ce4476b81a0a04fa1d..27279fb3b887efe6f0d62faffbf384e45196ffaf 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -445,5 +445,5 @@ export class VideoPlayerDemo { ## 相关实例 针对视频播放开发,有以下相关实例可供参考: -- [`VideoPlayer`:视频播放(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer) +- [`VideoPlayer:`视频播放(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/media/VideoPlayer) - [视频播放器(eTS)(API 9)](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoPlayerStage) \ No newline at end of file diff --git a/zh-cn/application-dev/media/video-recorder.md b/zh-cn/application-dev/media/video-recorder.md index 2e722caf3ab5de17c8872687b5faa9f3dcf56052..888767e721ad99e71565a1eb5d1607ecc0b303ba 100644 --- a/zh-cn/application-dev/media/video-recorder.md +++ b/zh-cn/application-dev/media/video-recorder.md @@ -86,7 +86,7 @@ export class VideoRecorderDemo { profile : videoProfile, url : this.testFdNumber, // testFdNumber由getFd生成 orientationHint : 0, - location : { latitude : 30, longitude : 130 }, + location : { latitude : 30, longitude : 130 } } // 创建videoRecorder对象 await media.createVideoRecorder().then((recorder) => { diff --git a/zh-cn/application-dev/napi/napi-guidelines.md b/zh-cn/application-dev/napi/napi-guidelines.md index 95c03925de5ba06ea0eb08e22ab390dc51a946e2..a7a57350b909eb196231103364b05ae7c630bc76 100644 --- a/zh-cn/application-dev/napi/napi-guidelines.md +++ b/zh-cn/application-dev/napi/napi-guidelines.md @@ -643,6 +643,6 @@ export default { ``` ## 相关实例 针对Native API的开发,有以下相关实例可供参考: -- [`NativeAPI`:NativeAPI(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Native/NativeAPI) +- [`NativeAPI`:NativeAPI(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/Native/NativeAPI) - [第一个Native C++应用(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/NativeTemplateDemo) - [Native Component(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/XComponent) \ No newline at end of file diff --git a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md index 309b35884a463fa5048b1ea03ae70a27a472ecdf..ef25e329e8edab09e8ccda480916d05265422ceb 100644 --- a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md @@ -26,7 +26,8 @@ enum ActionButtonType: 在提醒弹出的通知界面上的按钮的类型。 | 枚举名 | 描述 | | -------- | -------- | -| ACTION_BUTTON_TYPE_CLOSE | 指明是close按钮,点击后关闭当前提醒的铃声(如果正在响铃),关闭提醒的通知,取消延迟提醒。 | +| ACTION_BUTTON_TYPE_CLOSE | 关闭按钮。关闭提醒的通知,取消延迟提醒。如果正在响铃,点击后会关闭当前提醒的铃声。 | +| ACTION_BUTTON_TYPE_SNOOZE | 延迟按钮。点击当前的提醒会延迟相应时间。 | enum ReminderType: 提醒类型 @@ -283,6 +284,6 @@ let alarm : reminderAgent.ReminderRequestAlarm = { - [`AlarmClock`:后台代理提醒(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Notification/AlarmClock) -- [`FlipClock`:翻页时钟(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/CompleteApps/FlipClock) +- [`FlipClock`:翻页时钟(eTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/CompleteApps/FlipClock) - [闹钟应用(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/CommonEventAndNotification/AlarmClock) \ No newline at end of file diff --git a/zh-cn/application-dev/notification/common-event.md b/zh-cn/application-dev/notification/common-event.md index fd6f6a31e73ae42d5ed52c2f2196d22801ffb5f6..42319fb13e2dc2ca39e02b9e6789b6515f60223a 100644 --- a/zh-cn/application-dev/notification/common-event.md +++ b/zh-cn/application-dev/notification/common-event.md @@ -174,6 +174,6 @@ if (this.subscriber != null) { 针对公共事件开发,有以下相关实例可供参考: -- [`CommonEvent`:订阅公共事件(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) +- [`CommonEvent`:订阅公共事件(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/Notification/CommonEvent) diff --git a/zh-cn/application-dev/notification/notification-guidelines.md b/zh-cn/application-dev/notification/notification-guidelines.md index 063b0e3cc75e5e092c3f6e79ebddde3ca33e8646..6d54d97629004bf22fa25f01b278d98df010644b 100644 --- a/zh-cn/application-dev/notification/notification-guidelines.md +++ b/zh-cn/application-dev/notification/notification-guidelines.md @@ -262,6 +262,6 @@ Notification.cancel(1, "label", cancelCallback) 针对通知开发,有以下相关可供参考: -- [`Notification`:订阅、发送通知(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/Notification/Notification) +- [`Notification:`订阅、发送通知(eTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/Notification/Notification) -- [`Notification`:通知(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) +- [`Notification`:通知(eTS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/Notification) diff --git a/zh-cn/application-dev/quick-start/figures/04.png b/zh-cn/application-dev/quick-start/figures/04.png index 792837f2620a8c44dcf69ad7a56e8aed6693bf24..ac9dd6594d8d6d3673b0f713288f41dae5b60496 100644 Binary files a/zh-cn/application-dev/quick-start/figures/04.png and b/zh-cn/application-dev/quick-start/figures/04.png differ diff --git a/zh-cn/application-dev/quick-start/stage-structure.md b/zh-cn/application-dev/quick-start/stage-structure.md index 3c198b774f1090cd7d0d47597d21844fc3fb663b..238c3811cd6753995fa44badb92abad3378cb415 100755 --- a/zh-cn/application-dev/quick-start/stage-structure.md +++ b/zh-cn/application-dev/quick-start/stage-structure.md @@ -2,7 +2,7 @@ # 应用包结构配置文件的说明 -在开发FA模型下的应用程序时,需要在config.json文件中对应用的包结构进行申明;同样的,在开发stage模型下的应用程序时,需要在module.json和app.json配置文件中对应用的包结构进行声明。 +在开发FA模型下的应用程序时,需要在config.json文件中对应用的包结构进行申明;同样的,在开发stage模型下的应用程序时,需要在module.json5和app.json配置文件中对应用的包结构进行声明。 ## 配置文件内部结构 @@ -27,8 +27,8 @@ app.json示例: "versionCode": 1, "versionName": "1.0", "minCompatibleVersionCode": 1, - "apiCompatibleVersion": 7, - "apiTargetVersion": 8, + "minAPIVersion": 7, + "targetAPIVersion": 8, "apiReleaseType": "Release", "debug": false, "icon": "$media:app_icon", @@ -57,9 +57,9 @@ app.json示例: | vendor | 该标签是对应用开发厂商的描述。该标签的值是字符串类型(最大255个字节)。 | 字符串 | 该标签可以缺省,缺省为空。 | | versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。该标签不可缺省,versionCode 值应小于2的31方。 | 数值 | 该标签不可缺省 | | versionName | 该标签标识版本号的文字描述,用于向用户展示。
该标签仅由数字和点构成,推荐采用“A.B.C.D”四段式的形式。四段式推荐的含义如下所示。
第一段 :主版本号/Major,范围0-99,重大修改的版本,如实现新的大功能或重大变化。
第二段 :次版本号/Minor,范围0-99,表示实现较突出的特点,如新功能添加和大问题修复。
第三段 :特性版本号/Feature,范围0-99,标识规划的新版本特性。
第四段 :修订版本号/Patch,范围0-999,表示维护版本,修复bug。 | 字符串 | 该标签不可缺省 | -| minCompatibleVersionCode | 该标签标识该app pack能够兼容的最低历史版本号。 | 数值 | 该标签可缺省。缺省值等于versionCode标签值。 | -| minAPIVersion | 该标签标识应用运行需要的API最小版本。 | 数值 | 该标签不可缺省。 | -| targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 整形 | 该标签不可缺省。 | +| minCompatibleVersionCode | 该标签标识该app能够兼容的最低历史版本号,用于跨设备兼容性判断。 | 数值 | 该标签可缺省。缺省值等于versionCode标签值。| +| minAPIVersion | 该标签标识应用运行需要的API最小版本。 | 整形 | 该标签可缺省,缺省值为bundle-profile.json5中的compatibleSdkVersion。| +| targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 整形 | 该标签可缺省,缺省值为bundle-profile.json5中的compileSdkVersion。| | apiReleaseType | 该标签标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。
Canary :受限发布的版本。
Beta :公开发布的Beta版本。
Release :公开发布的正式版本。 | 字符串 | 该标签可缺省,缺省为“Release”。 | | distributedNotificationEnabled | 该标签标记该应用是否开启分布式通知。 | 布尔值 | 该标签可缺省,缺省值为true。 | | entityType | 该标签标记该应用的类别,具体有 :游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)。 | 字符串 | 该标签可以缺省,缺省为unspecified。 | @@ -73,7 +73,7 @@ app.json示例: ### module对象内部结构 -module.json示例: +module.json5示例: ```json { @@ -186,10 +186,10 @@ hap包的配置信息,该标签下的配置只对当前hap包生效。 | pages | 该标签是一个profile资源,用于列举JS Component中每个页面信息。pages使用参考pages示例。 | 对象 | 在有ability的场景下,该标签不可缺省。 | | metadata | 该标签标识Hap的自定义元信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。metadata参考[metadata对象内部结构](#metadata对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | | abilities | 描述元能力的配置信息,标签值为数组类型,该标签下的配置只对当前ability生效。abilities参考[abilities对象内部结构](#abilities对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | -| extensionAbilities | 描述extensionAbilities的配置信息,标签值为数组类型,该标签下的配置只对当前extensionAbility生效。extensionAbilities参考[extensionAbility对象的内部结构说明](#extensionAbility对象的内部结构说明)。 | 对象 | 该标签可缺省,缺省值为空。 | -| definePermissions | 标识hap定义的权限,仅支持系统应用配置,三方应用配置不生效。该应用的调用者必须申请这些权限才能正常调用该应用。definePermissions参考[definePermissions对象内部结构](#definePermissions对象内部结构) | 对象 | 该标签可缺省,缺省值为空,表示调用者无需任何权限即可调用该应用。 | -| requestPermissions | 该标签标识应用运行时需向系统申请的权限集合,标签值为数组类型。requestPermissions参考[requestPermissions对象内部结构](#requestPermissions对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | -| testRunner | 此标签用于支持对测试框架的配置,参考[testRunner对象内部结构说明](#testRunner对象内部结构)说明。 | 对象 | 可缺省,缺省值为空 | +| extensionAbilities | 描述extensionAbilities的配置信息,标签值为数组类型,该标签下的配置只对当前extensionAbility生效。extensionAbilities参考[extensionAbility对象的内部结构说明](#extensionability对象的内部结构说明)。 | 对象 | 该标签可缺省,缺省值为空。 | +| definePermissions | 标识hap定义的权限,仅支持系统应用配置,三方应用配置不生效。该应用的调用者必须申请这些权限才能正常调用该应用。definePermissions参考[definePermissions对象内部结构](#definepermissions对象内部结构) | 对象 | 该标签可缺省,缺省值为空,表示调用者无需任何权限即可调用该应用。 | +| requestPermissions | 该标签标识应用运行时需向系统申请的权限集合,标签值为数组类型。requestPermissions参考[requestPermissions对象内部结构](#requestpermissions对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | +| testRunner | 此标签用于支持对测试框架的配置,参考[testRunner对象内部结构说明](#testrunner对象内部结构)说明。 | 对象 | 可缺省,缺省值为空 | 表4 deviceTypes对象的系统预定义设备 @@ -606,7 +606,7 @@ form示例 : } ``` -在module.json的extension组件下面定义metadata信息 +在module.json5的extension组件下面定义metadata信息 ```json { @@ -654,7 +654,7 @@ metadata中指定shortcut信息,其中 : } ``` -在module.json的module下面定义metadata信息,如下 : +在module.json5的module下面定义metadata信息,如下 : ```json { @@ -714,7 +714,7 @@ metadata中指定commonEvent信息,其中 : } ``` -在module.json的extension组件下面定义metadata信息,如下 : +在module.json5的extension组件下面定义metadata信息,如下 : ```json "extensionAbilities": [ @@ -804,7 +804,7 @@ distroFilter示例 : ] ``` -在module.json的extensionAbilities组件下面定义metadata信息,如下 : +在module.json5的extensionAbilities组件下面定义metadata信息,如下 : ```json "extensionAbilities": [ diff --git a/zh-cn/application-dev/quick-start/start-with-ets-stage.md b/zh-cn/application-dev/quick-start/start-with-ets-stage.md index 555a455b4476b1fd027b8e0c4f64a285a25f0e79..ac491b177b2f39b33a9d8d85aed45aa4b8c2dce5 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-stage.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-stage.md @@ -13,7 +13,7 @@ ![01](figures/01.png) -2. 进入配置工程界面,**Compile SDK**选择“**9**”,**Model** 选择“**Stage**”,**Language** 选择“**eTS**”,其他参数保持默认设置即可。 +2. 进入配置工程界面,**Compile SDK**选择“**9**”,**Model** 选择“**Stage**”,其他参数保持默认设置即可。 ![07](figures/07.png) diff --git a/zh-cn/application-dev/quick-start/start-with-js-fa.md b/zh-cn/application-dev/quick-start/start-with-js-fa.md index 96ca0d33edaaae296dcfd6bf59325cecca3b5693..142a657f437f81e42b6724f4daa11a14db5632bb 100644 --- a/zh-cn/application-dev/quick-start/start-with-js-fa.md +++ b/zh-cn/application-dev/quick-start/start-with-js-fa.md @@ -233,3 +233,8 @@ ![zh-cn_image_0000001363934589](figures/zh-cn_image_0000001363934589.png) 恭喜您已经使用JS语言开发(FA模型)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 + +## 相关实例 + +针对使用JS语言开发(FA模型),有以下相关实例可供参考: +- [`JsHelloWorld`:你好世界(JS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/JsHelloWorld) diff --git a/zh-cn/application-dev/quick-start/syscap.md b/zh-cn/application-dev/quick-start/syscap.md index 202957bcc518d852301259ae3e3881a32bd6995a..0e46663afcdc2dc7e05300e63feb4caefadb2c0e 100644 --- a/zh-cn/application-dev/quick-start/syscap.md +++ b/zh-cn/application-dev/quick-start/syscap.md @@ -8,6 +8,8 @@ SysCap,全称SystemCapability,即系统能力,指操作系统中每一个 ![image-20220326064841782](figures/image-20220326064841782.png) +开发者可以在[SysCap列表](../reference/syscap-list.md)中查询OpenHarmony的能力集。 + ### 支持能力集,联想能力集与要求能力集 @@ -39,6 +41,12 @@ SDK 提供全量的 API 给 IDE,IDE 通过开发者的项目支持的设备, ## SysCap开发指导 +### PCID获取 + +PCID,全称 Product Compatibility ID,包含当前设备支持的 syscap 信息。获取所有设备 PCID 的认证中心正在建设中,目前需要找对应设备的厂商获取该设备的 PCID。 + + + ### PCID导入 DevEco Studio 工程支持 PCID 的导入。导入的 PCID 文件解码后输出的 syscap 会被写入 syscap.json 文件中。 @@ -55,34 +63,30 @@ IDE 会根据创建的工程所支持的设置自动配置联想能力集和要 对于联想能力集,开发者通过添加更多的系统能力,在 IDE 中可以使用更多的 API,但要注意这些 API 可能在设备上不支持,使用前需要判断。 对于要求能力集,开发者修改时要十分慎重,修改不当会导致应用无法分发到目标设备上。 -``` +```json /* syscap.json */ { - devices: { - general: [ /*每一个典型设备对应一个syscap支持能力集,可配置多个典型设备*/ + "devices": { + "general": [ /*每一个典型设备对应一个syscap支持能力集,可配置多个典型设备*/ "default", - "car, - ... + "car" ], - custom: [ /*厂家自定义设备*/ + "custom": [ /*厂家自定义设备*/ { "某自定义设备": [ - "SystemCapability.Communication.SoftBus.Core", - ... + "SystemCapability.Communication.SoftBus.Core" ] - }, - ... + } ] }, - development: { /*addedSysCaps内的sycap集合与devices中配置的各设备支持的syscap集合的并集共同构成联想能力集*/ - addedSysCaps: [ - "SystemCapability.Location.Location.Lite", - ... + "development": { /*addedSysCaps内的sycap集合与devices中配置的各设备支持的syscap集合的并集共同构成联想能力集*/ + "addedSysCaps": [ + "SystemCapability.Location.Location.Lite" ] }, - production: { /*用于生成rpcid,慎重添加,可能导致应用无法分发到目标设备上*/ - addedSysCaps: [], //devices中配置的各设备支持的syscap集合的交集,添加addedSysCaps集合再除去removedSysCaps集合,共同构成要求能力集 - removedSysCaps: [] //当该要求能力集为某设备的子集时,应用才可被分发到该设备上 + "production": { /*用于生成rpcid,慎重添加,可能导致应用无法分发到目标设备上*/ + "addedSysCaps": [], //devices中配置的各设备支持的syscap集合的交集,添加addedSysCaps集合再除去removedSysCaps集合,共同构成要求能力集 + "removedSysCaps": [] //当该要求能力集为某设备的子集时,应用才可被分发到该设备上 } } ``` diff --git a/zh-cn/application-dev/reference/Readme-CN.md b/zh-cn/application-dev/reference/Readme-CN.md index fb4b5ce23d9743a121f179a5ab6470713323e2c9..62258182f16f280828c947c9ed7173d1a4acdd5d 100644 --- a/zh-cn/application-dev/reference/Readme-CN.md +++ b/zh-cn/application-dev/reference/Readme-CN.md @@ -2,6 +2,7 @@ - [组件参考(基于TS扩展的声明式开发范式)](arkui-ts/Readme-CN.md) - [组件参考(基于JS扩展的类Web开发范式)](arkui-js/Readme-CN.md) +- [JS服务卡片UI组件参考](js-service-widget-ui/Readme-CN.md) - [接口参考(JS及TS API)](apis/Readme-CN.md) - 接口参考(Native API) - [OpenHarmony Native API](native-apis/Readme-CN.md) diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 1d269ce4c10b9506a11dc9e9e69291d5c37ad058..e50472864b141c4b9b17de3d7b9c49578228a443 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -137,6 +137,7 @@ - [@ohos.privacyManager (隐私管理)](js-apis-privacyManager.md) - [@ohos.security.huks (通用密钥库系统)](js-apis-huks.md) - [@ohos.userIAM.userAuth (用户认证)](js-apis-useriam-userauth.md) + - [@ohos.userIAM.faceAuth (人脸认证)](js-apis-useriam-faceauth.md) - [@system.cipher (加密算法)](js-apis-system-cipher.md) - 数据管理 @@ -182,6 +183,8 @@ - [@ohos.nfc.cardEmulation (标准NFC-cardEmulation)](js-apis-cardEmulation.md) - [@ohos.nfc.controller (标准NFC)](js-apis-nfcController.md) - [@ohos.nfc.tag (标准NFC-Tag)](js-apis-nfcTag.md) + - [@ohos.nfc.tag (标准NFC-Tag Nfc 技术)](js-apis-nfctech.md) + - [@ohos.nfc.tag (标准NFC-Tag TagSession)](js-apis-tagSession.md) - [@ohos.rpc (RPC通信)](js-apis-rpc.md) - [@ohos.wifi (WLAN)](js-apis-wifi.md) - [@ohos.wifiext (WLAN)](js-apis-wifiext.md) diff --git a/zh-cn/application-dev/reference/apis/development-intro.md b/zh-cn/application-dev/reference/apis/development-intro.md index d2e3b7ad38b4714ceced8bfae159de35d07e6406..b8ff2b41d4857406933513cf95b1138b27a8cada 100644 --- a/zh-cn/application-dev/reference/apis/development-intro.md +++ b/zh-cn/application-dev/reference/apis/development-intro.md @@ -21,6 +21,10 @@ Ability是系统调度应用的最小单元,是能够完成一个独立功能 OpenHarmony中提供的接口,部分是仅供OEM厂商使用的system api,普通应用无法使用。 +普通应用即应用APL等级为normal的应用。默认情况下,应用的等级都为normal应用。 + +APL等级的详细说明及如何将应用的APL等级声明为normal以上,请参考[访问控制开发概述-应用APL等级说明](../../security/accesstoken-overview.md#应用apl等级说明)。 + 针对这种情况,在文档中会进行系统接口的声明: - 如果某个模块的接口均为system api,会在文档开头说明:该模块接口为系统接口。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-Context.md b/zh-cn/application-dev/reference/apis/js-apis-Context.md index 1352981c55e13ae8451df234cb434a5f7bb4138c..2de7d3aa4e6ce916921035329f2d623df5ff4308 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Context.md @@ -195,6 +195,44 @@ context.requestPermissionsFromUser( ``` +## Context.requestPermissionsFromUser7+ + +requestPermissionsFromUser(permissions: Array\, requestCode: number): Promise\<[PermissionRequestResult](#permissionrequestresult7)> + +从系统请求某些权限(promise形式)。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| -------------- | ------------------- | ----- | -------------------------------------------- | +| permissions | Array\ | 是 | 指示要请求的权限列表。此参数不能为null。 | +| requestCode | number | 是 | 指示要传递给PermissionRequestResult的请求代码。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------- | ---------------- | +| Promise\<[PermissionRequestResult](#permissionrequestresult7)> | 返回授权结果信息。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.requestPermissionsFromUser( + ["com.example.permission1", + "com.example.permission2", + "com.example.permission3", + "com.example.permission4", + "com.example.permission5"], + 1).then((data)=>{ + console.info("====>requestdata====>" + JSON.stringify(data)); + }); +``` + + ## Context.getApplicationInfo7+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index 8f55340eb2cb325aaa413616cd1425903835dd35..ab80443932948e559e594158faff6b4339794398 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -5,8 +5,8 @@ AbilityContext是Ability的上下文环境,继承自Context。 AbilityContext模块提供允许访问特定于ability的资源的能力,包括对Ability的启动、停止的设置、获取caller通信接口、拉起弹窗请求用户授权等。 > **说明:** -> -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块接口仅可在Stage模型下使用。 ## 使用说明 @@ -78,7 +78,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& | callback | AsyncCallback<void> | 是 | callback形式返回启动结果。 | **示例:** - + ```js var want = { "deviceId": "", @@ -127,7 +127,7 @@ startAbility(want: Want, options?: StartOptions): Promise<void>; windowMode: 0, }; this.context.startAbility(want, options) - .then((data) => { + .then(() => { console.log('Operation successful.') }).catch((error) => { console.log('Operation failed.'); @@ -848,7 +848,7 @@ disconnectAbility(connection: number): Promise\; | Promise\ | 返回执行结果。 | **示例:** - + ```js var connectionNumber = 0; this.context.disconnectAbility(connectionNumber).then((data) => { @@ -888,7 +888,7 @@ disconnectAbility(connection: number, callback:AsyncCallback\): void; startAbilityByCall(want: Want): Promise<Caller>; -获取指定通用组件服务端的caller通信接口, 并且将指定通用组件服务端拉起并切换到后台。 +启动指定Ability至前台或后台,同时获取其Caller通信接口,调用方可使用Caller与被启动的Ability进行通信。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -896,7 +896,7 @@ startAbilityByCall(want: Want): Promise<Caller>; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | 是 | 传入需要启动的ability的信息,包含ability名称、包名、设备ID,设备ID缺省或为空表示启动本地ability。 | +| want | [Want](js-apis-application-Want.md) | 是 | 传入需要启动的Ability的信息,包含abilityName、moduleName、bundleName、deviceId(可选)、parameters(可选),其中deviceId缺省或为空表示启动本地Ability,parameters缺省或为空表示后台启动Ability。 | **返回值:** @@ -905,24 +905,42 @@ startAbilityByCall(want: Want): Promise<Caller>; | Promise<Caller> | 获取要通讯的caller对象。 | **示例:** - + ```js - import Ability from '@ohos.application.Ability'; - var caller; - export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" - }).then((obj) => { - caller = obj; - console.log('Caller GetCaller Get ' + caller); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); + let caller = undefined; + + // 后台启动Ability,不配置parameters + var wantBackground = { + bundleName: "com.example.myservice", + moduleName: "entry", + abilityName: "MainAbility", + deviceId: "" + }; + this.context.startAbilityByCall(wantBackground) + .then((obj) => { + caller = obj; + console.log('GetCaller success'); + }).catch((error) => { + console.log(`GetCaller failed with ${error}`); + }); + + // 前台启动Ability,将parameters中的"ohos.aafwk.param.callAbilityToForeground"配置为true + var wantForeground = { + bundleName: "com.example.myservice", + moduleName: "entry", + abilityName: "MainAbility", + deviceId: "", + parameters: { + "ohos.aafwk.param.callAbilityToForeground": true } - } + }; + this.context.startAbilityByCall(wantForeground) + .then((obj) => { + caller = obj; + console.log('GetCaller success'); + }).catch((error) => { + console.log(`GetCaller failed with ${error}`); + }); ``` ## AbilityContext.startAbilityWithAccount @@ -1056,13 +1074,13 @@ requestPermissionsFromUser(permissions: Array<string>, requestCallback: As | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | 是 | 回调函数,返回接口调用是否成功的结果。 | **示例:** - + ```js var permissions=['com.example.permission'] this.context.requestPermissionsFromUser(permissions,(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); }); - + ``` @@ -1087,7 +1105,7 @@ requestPermissionsFromUser(permissions: Array<string>) : Promise<Permis | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | 返回一个Promise,包含接口的结果。 | **示例:** - + ```js var permissions=['com.example.permission'] this.context.requestPermissionsFromUser(permissions).then((data) => { @@ -1115,7 +1133,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; | callback | AsyncCallback<void> | 是 | 回调函数,返回接口调用是否成功的结果。 | **示例:** - + ```js this.context.setMissionLabel("test",(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); @@ -1144,7 +1162,7 @@ setMissionLabel(label: string): Promise<void> | Promise<void> | 返回一个Promise,包含接口的结果。 | **示例:** - + ```js this.context.setMissionLabel("test").then((data) => { console.log('success:' + JSON.stringify(data)); @@ -1170,7 +1188,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\): void; | callback | AsyncCallback\ | 是 | 指定的回调函数的结果。 | **示例:** - + ```js import image from '@ohos.multimedia.image' var imagePixelMap; @@ -1217,7 +1235,7 @@ setMissionIcon(icon: image.PixelMap): Promise\; | Promise<void> | 返回一个Promise,包含接口的结果。 | **示例:** - + ```js import image from '@ohos.multimedia.image' var imagePixelMap; diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md new file mode 100644 index 0000000000000000000000000000000000000000..8ef198195d24b4bb0e52a89d1363d92bdff394d7 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md @@ -0,0 +1,362 @@ +# 系统辅助功能配置 + +本模块提供系统辅助功能的配置,包括辅助扩展的启用与关闭、高对比度文字显示、鼠标键、无障碍字幕配置等。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从 API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块接口为系统接口。 + +## 导入模块 + +```typescript +import config from "@ohos.accessibility.config"; +``` + +## 属性 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| highContrastText | [Config](#config)\| 是 | 是 | 表示高对比度文字功能启用状态。 | +| invertColor | [Config](#config)\| 是 | 是 | 表示颜色反转功能启用状态。 | +| daltonizationColorFilter | [Config](#config)<[DaltonizationColorFilter](#daltonizationcolorfilter)>| 是 | 是 | 表示颜色滤镜功能配置。 | +| contentTimeout | [Config](#config)\| 是 | 是 | 表示内容显示建议时长配置。取值 0~5000,单位为毫秒。 | +| animationOff | [Config](#config)\| 是 | 是 | 表示关闭动画功能启用状态。 | +| brightnessDiscount | [Config](#config)\| 是 | 是 | 表示亮度折扣系统配置。取值 0~1.0。 | +| mouseKey | [Config](#config)\| 是 | 是 | 表示鼠标键功能启用状态。 | +| mouseAutoClick | [Config](#config)\| 是 | 是 | 表示鼠标自动点击功能启用状态。取值 0~5000,单位为毫秒。 | +| shortkey | [Config](#config)\| 是 | 是 | 表示辅助扩展快捷键功能启用状态。 | +| shortkeyTarget | [Config](#config)\| 是 | 是 | 表示辅助扩展快捷键的目标配置。取值为辅助应用的名称,格式为:"bundleName/abilityName"。 | +| captions | [Config](#config)\| 是 | 是 | 表示辅助字幕功能启用状态。 | +| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](./js-apis-accessibility.md#captionsstyle8)>| 是 | 是 | 表示辅助字幕的配置。 | + +## enableAbility + +enableAbility(name: string, capability: Array<[accessibility.Capability](./js-apis-accessibility.md#capability)>): Promise<void>; + +启用辅助扩展。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | + | capability | Array<[accessibility.Capability](./js-apis-accessibility.md#capability)>) | 是 | 辅助应用的能力属性。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于返回方法执行结果。 | + +**示例:** + + ```typescript + config.enableAbility("com.ohos.example/axExtension", ['retrieve']) + .then(() => { + console.info('enable succeed'); + }).catch((error) => { + console.error('enable failed'); + }); + ``` + +## enableAbility + +enableAbility(name: string, capability: Array<[accessibility.Capability](./js-apis-accessibility.md#capability)>, callback: AsyncCallback<void>): void; + +启用辅助扩展。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | + | capability | Array<[accessibility.Capability](./js-apis-accessibility.md#capability)> | 是 | 辅助应用的能力属性。 | + | callback | AsyncCallback<void> | 是 | 回调函数,返回方法执行结果。 | + +**示例:** + + ```typescript + config.enableAbility("com.ohos.example/axExtension", ['retrieve'], (err, data) => { + if (err) { + console.error('enable failed'); + return; + } + console.info('enable succeed'); + }) + ``` + +## disableAbility + +disableAbility(name: string): Promise<void>; + +关闭辅助扩展。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于返回方法执行结果。 | + +**示例:** + + ```typescript + config.disableAbility("com.ohos.example/axExtension") + .then(() => { + console.info('disable succeed'); + }).catch((error) => { + console.error('disable failed'); + }); + ``` + +## disableAbility + +disableAbility(name: string, callback: AsyncCallback<void>): void; + +关闭辅助扩展。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | name | string | 是 | 辅助应用的名称,格式为:"bundleName/abilityName"。 | + | callback | AsyncCallback<void> | 是 | 回调函数,返回方法执行结果。 | + +**示例:** + + ```typescript + config.disableAbility("com.ohos.example/axExtension", (err, data) => { + if (err) { + console.error('disable failed'); + return; + } + console.info('disable succeed'); + }) + ``` + +## on('enableAbilityListsStateChanged') + +on(type: 'enableAbilityListsStateChanged', callback: Callback<void>): void; + +添加启用的辅助扩展的列表变化监听。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 参数固定为enableAbilityListsStateChanged,监听启用的辅助扩展的列表变化。 | + | callback | Callback<void> | 是 | 回调函数,在启用的辅助扩展的列表变化时通过此函数进行通知。 | + +**示例:** + + ```typescript + config.on('enableAbilityListsStateChanged',() => { + console.info('ax extension ability enable list changed'); + }); + ``` + +## off('enableAbilityListsStateChanged') + +off(type: 'enableAbilityListsStateChanged', callback?: Callback<void>): void; + +取消启用的辅助扩展的列表变化监听。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 否 | 参数固定为enableAbilityListsStateChanged,监听启用的辅助扩展的列表变化。 | + | callback | Callback<void> | 否 | 要取消的监听回调函数。 | + +**示例:** + + ```typescript + config.off('enableAbilityListsStateChanged'); + ``` + +## Config + +用于属性的设置、获取与监听。 + +### set + +set(value: T): Promise<void>; + +设置属性。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | value | T | 是 | 设置的属性值。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于返回方法执行结果。 | + +**示例:** + + ```typescript + config.highContrastText.set(true) + .then(() => { + console.info('highContrastText set succeed'); + }).catch((error) => { + console.error('highContrastText set failed'); + }); + ``` + +### set + +set(value: T, callback: AsyncCallback<void>): void; + +设置属性。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | value | T | 是 | 设置的属性值。 | + | callback | AsyncCallback<void> | 是 | 回调函数,返回方法执行结果。 | + +**示例:** + + ```typescript + config.highContrastText.set(true, (err, data) => { + if (err) { + console.error('highContrastText set failed'); + return; + } + console.info('highContrastText set succeed'); + }) + ``` + +### get + +get(): Promise<T>; + +获取属性。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<T> | Promise实例,用于返回属性值。 | + +**示例:** + + ```typescript + config.highContrastText.get() + .then((value) => { + console.info('highContrastText get succeed'); + }).catch((error) => { + console.error('highContrastText get failed'); + }); + ``` + +### get + +get(callback: AsyncCallback<T>): void; + +获取属性。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 是 | 回调函数,返回属性值。 | + +**示例:** + + ```typescript + config.highContrastText.get((err, data) => { + if (err) { + console.error('highContrastText get failed'); + return; + } + console.info('highContrastText get succeed'); + }) + ``` + +### on + +on(callback: Callback<T>): void; + +添加属性变化监听。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | Callback<T> | 是 | 回调函数,在属性变化时通过此函数进行通知。 | + +**示例:** + + ```typescript + config.highContrastText.on(() => { + console.info('highContrastText changed'); + }); + ``` + +### off + +off(callback?: Callback<T>): void; + +取消属性变化监听。 + +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core + +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | Callback<T> | 否 | 要取消的监听回调函数。 | + +**示例:** + + ```typescript + config.highContrastText.off(); + ``` + +## DaltonizationColorFilter + +用于不同弱视类型的校正颜色滤镜。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| Normal | 表示正常类型。 | +| Protanomaly | 表示红色弱视类型。 | +| Deuteranomaly | 表示绿色弱视类型。 | +| Tritanomaly | 表示蓝色弱视类型。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md index affa083e8924ad08aaf674be55f9acbaf455b1fe..d5bd800be9ab473969b593cd37a3a01aca8e749e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md @@ -9,10 +9,18 @@ AccessibilityExtensionContext模块提供扩展的上下文的能力,包括允 > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块接口仅可在Stage模型下使用。 -## 导入模块 +## 使用说明 + +在使用AccessibilityExtensionContext的功能前,需要通过AccessibilityExtensionAbility子类实例获取。 ```js import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' +class MainAbility extends AccessibilityExtensionAbility { + onConnect(): void { + console.log("AxExtensionAbility onConnect"); + let axContext = this.context; + } +} ``` ## FocusDirection @@ -203,9 +211,9 @@ this.context.getWindows().then(windows => { }) ``` -## AccessibilityExtensionContext.gestureInject +## AccessibilityExtensionContext.injectGesture -gestureInject(gesturePath: GesturePath, listener: Callback\): Promise\): Promise\ { + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('enableAppAccess Success'); }).catch((err) => { console.log("enableAppAccess err: " + JSON.stringify(err)); @@ -334,7 +335,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): 检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。 -**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC **系统能力:** SystemCapability.Account.AppAccount @@ -361,7 +362,7 @@ checkAppAccountSyncEnable(name: string): Promise<boolean> 检查指定应用帐号是否允许应用数据同步,使用Promise方式异步返回结果。 -**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC **系统能力:** SystemCapability.Account.AppAccount @@ -510,7 +511,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback 设置指定的应用程序帐号是否允许应用程序数据同步,使用callback回调异步返回结果。 -**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC **系统能力:** SystemCapability.Account.AppAccount @@ -537,7 +538,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> 设置指定的应用程序帐号是否允许应用程序数据同步,使用Promise方式异步返回结果。 -**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC **系统能力:** SystemCapability.Account.AppAccount @@ -585,7 +586,8 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb **示例:** ```js - app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => { console.log("setAssociatedData err: " + JSON.stringify(err)); }); ``` @@ -795,6 +797,35 @@ getAssociatedData(name: string, key: string): Promise<string> }); ``` +### getAssociatedDataSync9+ + +getAssociatedDataSync(name: string, key: string): string; + +获取与此应用程序帐号关联的数据,使用同步方式返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | --------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的键。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------- | +| string | 用于获取同步接口的返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + var backData = appAccountManager.getAssociatedDataSync("ZhangSan", "k001"); + console.info("getAssociatedDataSync backData:" + JSON.stringify(backData)); + ``` + ### getAllAccessibleAccounts getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void @@ -1010,7 +1041,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri } const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, { + appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, { onResult: onResultCallback, onRequestRedirected: onRequestRedirectedCallback }); @@ -1037,7 +1068,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { + appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", (err, data) => { console.log('getOAuthToken err: ' + JSON.stringify(err)); console.log('getOAuthToken token: ' + data); }); @@ -1069,7 +1100,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string& ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { + appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData").then((data) => { console.log('getOAuthToken token: ' + data); }).catch((err) => { console.log("getOAuthToken err: " + JSON.stringify(err)); @@ -1097,7 +1128,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { + appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (err) => { console.log('setOAuthToken err: ' + JSON.stringify(err)); }); ``` @@ -1128,7 +1159,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void> ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { + appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => { console.log('setOAuthToken successfully'); }).catch((err) => { console.log('setOAuthToken err: ' + JSON.stringify(err)); @@ -1157,7 +1188,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { + appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx", (err) => { console.log('deleteOAuthToken err: ' + JSON.stringify(err)); }); ``` @@ -1189,7 +1220,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { + appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx").then(() => { console.log('deleteOAuthToken successfully'); }).catch((err) => { console.log("deleteOAuthToken err: " + JSON.stringify(err)); @@ -1218,7 +1249,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { + appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true, (err) => { console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); }); ``` @@ -1250,7 +1281,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { + appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true).then(() => { console.log('setOAuthTokenVisibility successfully'); }).catch((err) => { console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1278,7 +1309,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { + appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", (err, data) => { console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('checkOAuthTokenVisibility isVisible: ' + data); }); @@ -1310,7 +1341,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { + appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo").then((data) => { console.log('checkOAuthTokenVisibility isVisible: ' + data); }).catch((err) => { console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1395,7 +1426,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array< ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { + appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData", (err, data) => { console.log('getOAuthList err: ' + JSON.stringify(err)); console.log('getOAuthList data: ' + JSON.stringify(data)); }); @@ -1426,7 +1457,7 @@ getOAuthList(name: string, authType: string): Promise<Array<string>> ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { + appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData").then((data) => { console.log('getOAuthList data: ' + JSON.stringify(data)); }).catch((err) => { console.log("getOAuthList err: " + JSON.stringify(err)); @@ -1462,7 +1493,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic } var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", - [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); }); @@ -1498,7 +1529,7 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", - [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); }).catch((err) => { @@ -1967,8 +1998,8 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---------- | | owner | string | 是 | 认证器的所有者包名。 | -| iconId | string | 是 | 认证器的图标标识。 | -| labelId | string | 是 | 认证器的标签标识。 | +| iconId | number | 是 | 认证器的图标标识。 | +| labelId | number | 是 | 认证器的标签标识。 | ## SelectAccountsOptions9+ @@ -2082,7 +2113,7 @@ onResult: (code: number, result: {[key: string]: any}) => void appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", - [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); }).catch((err) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md index 90037d0d882506a98d94d0a1c3e66e0b183ea4cd..f9a869d66f263dc29bb2e10cbf488785f5375f66 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md @@ -14,11 +14,19 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' ``` +## 属性 + +**系统能力:** SystemCapability.BarrierFree.Accessibility.Core + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | -------- | ---- | ---- | ------------------------- | +| context | [AccessibilityExtensionContext](js-apis-accessibility-extension-context.md) | 是 | 否 | 表示辅助扩展能力上下文。 | + ## AccessibilityEvent 辅助事件信息。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core ### 属性 @@ -32,7 +40,7 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens 表示手势路径信息。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core ### 属性 @@ -41,29 +49,11 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens | points | Array<[GesturePoint](gesturepoint)> | 是 | 是 | 手势。 | | durationTime | number | 是 | 是 | 手势总耗时。 | -### constructor - -constructor(durationTime: number) - -构造函数。 - -- **参数:** - - | 参数名 | 参数类型 | 必填 | 说明 | - | ------------ | ------ | ---- | ------ | - | durationTime | number | 是 | 手势总耗时。 | - -- **示例:** - - ```typescript - let gesturePath = new GesturePath(100); - ``` - ## GesturePoint 表示手势触摸点。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core ### 属性 @@ -72,30 +62,11 @@ constructor(durationTime: number) | positionX | number | 是 | 是 | 触摸点X坐标。 | | positionY | number | 是 | 是 | 触摸点Y坐标。 | -### constructor - -constructor(positionX: number, positionY: number) - -构造函数。 - -- **参数:** - - | 参数名 | 参数类型 | 必填 | 说明 | - | --------- | ------ | ---- | ------- | - | positionX | number | 是 | 触摸点X坐标。 | - | positionY | number | 是 | 触摸点Y坐标。 | - -- **示例:** - - ```typescript - let gesturePoint = new GesturePoint(100, 200); - ``` - ## GestureType 手势事件类型。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core | 名称 | 描述 | | ------------- | ------------ | @@ -120,7 +91,7 @@ constructor(positionX: number, positionY: number) 页面刷新类型。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core | 名称 | 描述 | | ----------------- | --------- | @@ -131,7 +102,7 @@ constructor(positionX: number, positionY: number) 触摸浏览事件类型。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core | 名称 | 描述 | | ---------- | ------------ | @@ -205,7 +176,7 @@ onAccessibilityEvent(event: AccessibilityEvent): void { ## AccessibilityExtensionAbility.onKeyEvent -onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; +onKeyEvent(keyEvent: KeyEvent): boolean; 在物理按键按下时回调此方法,可以在该方法中根据业务判断是否对事件进行拦截。 @@ -215,7 +186,7 @@ onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; | 参数名 | 参数类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------------- | -| keyEvent | [KeyEvent](js-apis-inputeventclient.md#KeyEvent) | 是 | 按键事件回调函数。返回true表示拦截此按键。 | +| keyEvent | [KeyEvent](js-apis-keyevent.md#KeyEvent) | 是 | 按键事件回调函数。返回true表示拦截此按键。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-Want.md b/zh-cn/application-dev/reference/apis/js-apis-application-Want.md index dad3709d38269be8150a3f6b045f91a155f473d5..e424d6ca7d06fb7c7ddb9222a291994b59647505 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-Want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-Want.md @@ -22,7 +22,7 @@ import Want from '@ohos.application.Want'; | bundleName | 只读 | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | | abilityName | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了package和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 | | uri | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | -| type | 只读 | string | 否 | 表示MIME type类型描述,比如:"text/plain" 、 "image/*"等。 | +| type | 只读 | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-featureAbility.md#flags说明)。 | | action | 只读 | string | 否 | 表示action选项描述。 | | parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:
ohos.aafwk.callerPid 表示拉起方的pid。
ohos.aafwk.param.callerToken 表示拉起方的token。
ohos.aafwk.param.callerUid 表示发起方的uid。[Bundle](js-apis-Bundle.md)模块中userId参数,可用于获取应用信息、包信息等,具体参考:[Bundle](js-apis-Bundle.md)。 | @@ -113,5 +113,6 @@ import Want from '@ohos.application.Want'; console.log("error.code = " + error.code) }) ``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md index ec0580c1d1038522e25dfe9b87ab1aa19656bf6a..fb6215a8fdd074658b4e9a7dd50fbc1d3040ec51 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -99,4 +99,4 @@ context: AbilityStageContext; | 属性名 | 类型 | 说明 | | ----------- | --------------------------- | ------------------------------------------------------------ | -| context | [AbilityStageContext](js-apis-featureAbility.md) | 在启动能力阶段进行初始化时回调。 | +| context | [AbilityStageContext](js-apis-abilitystagecontext.md) | 在启动能力阶段进行初始化时回调。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 5b3992e4556c3ac86289f9e745a3321c675b57cd..77d3a6aa5712f3212e37b29da7caebe000524610 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -13,10 +13,27 @@ ## 导入模块 -``` +```js import audio from '@ohos.multimedia.audio'; ``` +## 常量 + +**系统接口:** 该接口为系统接口 + +**系统能力:** SystemCapability.Multimedia.Audio.Device + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | -------------------------- | ---- | ---- | ------------------ | +| LOCAL_NETWORK_ID9+ | string | 是 | 否 | 本地设备网络id。 | + +**示例:** + +```js +import audio from '@ohos.multimedia.audio'; + +const localNetworkId = audio.LOCAL_NETWORK_ID; +``` ## audio.getAudioManager @@ -27,31 +44,68 @@ getAudioManager(): AudioManager **系统能力:** SystemCapability.Multimedia.Audio.Core **返回值:** + | 类型 | 说明 | | ----------------------------- | ------------ | | [AudioManager](#audiomanager) | 音频管理类。 | **示例:** -``` +```js var audioManager = audio.getAudioManager(); ``` ## audio.getStreamManager9+ -getStreamManager(): AudioStreamManager +getStreamManager(callback: AsyncCallback\): void -获取音频流管理器实例。 +获取音频流管理器实例。使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Core -**返回值:** -| 类型 | 说明 | -| -------------------------------------------------| ------------------------------- | -| [AudioStreamManager](#audiostreammanager9) | 返回音频流管理器实例。 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ---------------- | +| callback | AsyncCallback<[AudioStreamManager](#audiostreammanager9)> | 是 | 返回音频流管理器实例。 | **示例:** + +```js +audio.getStreamManager((err, data) => { + if (err) { + console.error(`getStreamManager : Error: ${err.message}`); + } else { + console.info('getStreamManager : Success : SUCCESS'); + let audioStreamManager = data; + } +}); ``` -var audioStreamManager = audio.getStreamManager(); + +## audio.getStreamManager9+ + +getStreamManager(): Promise + +获取音频流管理器实例。使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------------- | ---------------- | +| Promise<[AudioStreamManager](#audiostreammanager9)> | 返回音频流管理器实例。 | + +**示例:** + +```js +var audioStreamManager; +audio.getStreamManager().then((data) => { + audioStreamManager = data; + console.info('getStreamManager: Success!'); +}).catch((err) => { + console.error(`getStreamManager: ERROR : ${err.message}`); +}); + ``` ## audio.createAudioRenderer8+ @@ -62,7 +116,7 @@ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\ **示例:** -``` +```js import audio from '@ohos.multimedia.audio'; var audioStreamInfo = { @@ -170,7 +224,7 @@ createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback