diff --git a/en/application-dev/ability/context-userguide.md b/en/application-dev/ability/context-userguide.md index ba95ade27a3c7cb846be2d254fd3b75d65dd8701..d3e681244166cafecff86575dd1850db4ebf7f90 100644 --- a/en/application-dev/ability/context-userguide.md +++ b/en/application-dev/ability/context-userguide.md @@ -7,9 +7,11 @@ The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. **application/BaseContext** is a common context base class. It uses the **stageMode** attribute to specify whether the context is used for the stage model. - FA model + Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance. - Stage model + The stage model has the following types of contexts: **application/Context**, **application/ApplicationContext**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, and **application/FormExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model). ![contextIntroduction](figures/contextIntroduction.png) diff --git a/en/application-dev/ability/figures/contextIntroduction.png b/en/application-dev/ability/figures/contextIntroduction.png index 9f49f270750549a5326724dc0db1560dbda07c44..7345a1a5a6a3471782e9399129c98f3d529bbfd5 100644 Binary files a/en/application-dev/ability/figures/contextIntroduction.png and b/en/application-dev/ability/figures/contextIntroduction.png differ diff --git a/en/application-dev/database/database-datashare-guidelines.md b/en/application-dev/database/database-datashare-guidelines.md index c8cb5c503329f6dc49c66fe457eb0aa8e6debf78..495f3b538b48b22d2d97f213d0e32189be799560 100644 --- a/en/application-dev/database/database-datashare-guidelines.md +++ b/en/application-dev/database/database-datashare-guidelines.md @@ -13,7 +13,7 @@ The **DataShare** module allows an application to manage its own data and share |query?(uri: string, predicates: DataSharePredicates, columns: Array<string>, callback: AsyncCallback<Object>): void|Queries data from the database.| |delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<number>): void|Deletes data from the database.| -For more details, see [DataShareExtensionAbility](../reference/apis/js-apis-application-DataShareExtensionAbility.md). +For more information, see [DataShareExtensionAbility](../reference/apis/js-apis-application-DataShareExtensionAbility.md). **Table 2** APIs of the data consumer @@ -25,11 +25,11 @@ For more details, see [DataShareExtensionAbility](../reference/apis/js-apis-appl | query(uri: string, predicates: DataSharePredicates, columns: Array<string>, callback: AsyncCallback<DataShareResultSet>): void | Queries data from the database. | | delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<number>): void | Deletes one or more data records from the database.| -For more details, see [DataShareHelper](../reference/apis/js-apis-data-dataShare.md). +For more information, see [DataShareHelper](../reference/apis/js-apis-data-dataShare.md). ## When to Use -There are two roles in **DataShare**. +There are two roles in **DataShare**: - Data provider: adds, deletes, modifies, and queries data, opens files, and shares data. - Data consumer: accesses the data provided by the provider using **DataShareHelper**. @@ -41,10 +41,10 @@ Examples are given below. 1. Import the dependencies. ```ts - import Extension from '@ohos.application.DataShareExtensionAbility' + import Extension from '@ohos.application.DataShareExtensionAbility'; import rdb from '@ohos.data.rdb'; - import fileIo from '@ohos.fileio' - import dataSharePredicates from '@ohos.data.dataSharePredicates' + import fileIo from '@ohos.fileio'; + import dataSharePredicates from '@ohos.data.dataSharePredicates'; ``` 2. Override **DataShareExtensionAbility** APIs based on actual requirements. For example, if the data provider provides only data query, override only the **query()** API. @@ -80,7 +80,7 @@ Examples are given below. } // Override the query() API. - query(uri, predicates, columns, callback) { + query(uri, predicates, columns, callback) { if (predicates == null || predicates == undefined) { console.info('invalid predicates'); } @@ -144,48 +144,49 @@ Examples are given below. let dseUri = ("datashare:///com.samples.datasharetest.DataShare"); ``` -2. Create a **DataShareHelper** instance. +3. Create a **DataShareHelper** instance. ```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. Use the APIs provided by **DataShareHelper** to access the services provided by the provider, for example, adding, deleting, modifying, and querying data. +4. Use the APIs provided by **DataShareHelper** to access the services provided by the provider, for example, adding, deleting, modifying, and querying data. ```ts // Construct a piece of data. - 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 }); // Insert a piece of data. - dsHelper.insert(dseUri, valuesBucket, (err,data) => { - console.log("dsHelper insert result: " + data); + dsHelper.insert(dseUri, valuesBucket, (err, data) => { + console.log("dsHelper insert result: " + data); }); // Delete 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); }); // Update 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); }); // Query 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/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md index eca90200a0d711c91f64643f453ff1d22a3a367f..8cc0a8aca0a6b8f6fad3f1a03f452e8ea9d3eb97 100644 --- a/en/application-dev/database/database-distributedobject-guidelines.md +++ b/en/application-dev/database/database-distributedobject-guidelines.md @@ -2,14 +2,13 @@ ## When to Use -Distributed data objects allow data traversing across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for data changes and online and offline status changes of other devices. - -The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types. +The **distributedDataObject** module provides APIs to implement data collaboration of the same application across multiple devices. In addition, the devices that form a Super Device can listen for object status and data changes with each other. +For example, when the data of the a distributed data object is added, deleted, or modified for application A on device 1, application A on device 2 can obtain the updated data. In addition, device 2 can listen for data changes and online/offline of the data objects on device 1. ## Available APIs -For details about the APIs related to the distributed data object, see [Distributed Data Object](../reference/apis/js-apis-data-distributedobject.md). +For details about the APIs, see [Distributed Data Object](../reference/apis/js-apis-data-distributedobject.md). ### Creating a Distributed Data Object Instance @@ -17,7 +16,7 @@ Call **createDistributedObject()** to create a distributed data object instance. **Table 1** API for creating a distributed data object instance -| Package | API | Description | +| 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.| @@ -26,35 +25,36 @@ Call **createDistributedObject()** to create a distributed data object instance. Call **genSessionId()** to generate a session ID randomly. The generated session ID can be used to set the session ID of a distributed data object. **Table 2** API for generating a session ID randomly -| Package | API | Description | +| Package| API| Description| | -------- | -------- | -------- | | ohos.data.distributedDataObject| genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object.| -### Setting a SessionID for Distributed Data Objects +### Setting a SessionID for a Distributed Data Object Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID. **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 a distributed data object.
**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. In the case of data change, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the 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| 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.| +| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. **Callback**: specifies the data changes to unsubscribe from. If this parameter is not specified, all data changes of this distributed data object will be unsubscribed from.| ### Observing Online or Offline Status Call **on()** to subscribe to status changes of a distributed data object. The status can be online or offline. When the status changes, a callback will be invoked to return the status. You can use **off()** to unsubscribe from the status changes. **Table 5** APIs for observing status changes of a distributed data object -| Class | API | Description | +| Class| API| Description| | -------- | -------- | -------- | | DistributedDataObject| on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }>): void | Subscribes to the status changes of a distributed data object.| | DistributedDataObject| off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }>): void | Unsubscribes from status changes of a distributed data object.| @@ -63,7 +63,7 @@ Call **on()** to subscribe to status changes of a distributed data object. The s Call **save()** to save a distributed data object. When the application is active, the saved data will not be released. When the application exits and restarts, the data saved on the device will be restored. -Call **revokeSave()** to revoke a distributed data object that is no longer required. If the distributed data object is saved on the local device, **revokeSave()** will delete the data from all trusted devices. If the distributed data object is not saved on the local device, **revokeSave()** will delete the data from the local device. +Call **revokeSave()** to delete a distributed data object that is no longer required. If the distributed data object is saved on the local device, **revokeSave()** will delete the data from all trusted devices. If the distributed data object is not saved on the local device, **revokeSave()** will delete the data from the local device. The saved data will be released in the following cases: @@ -71,13 +71,11 @@ The saved data will be released in the following cases: - The application has been uninstalled. - Data is successfully restored. -**Table 6** APIs for saving a distributed data object and revoking the saving -| Class | API | Description | +**Table 6** APIs for saving a distributed data object and revoking the saving operation +| Class| API| Description| | -------- | -------- | -------- | -| DistributedDataObject | save(deviceId: string): Promise<SaveSuccessResponse> | Saves a distributed data object. This API uses a promise to return the result. | -| DistributedDataObject | save(deviceId: string, callback: AsyncCallback<SaveSuccessResponse>): void | Saves a distributed data object. This API uses an asynchronous callback to return the result. | -| DistributedDataObject | revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void | Revokes the data saving operation. This API uses an asynchronous callback to return the result. | -| DistributedDataObject | revokeSave(): Promise<RevokeSaveSuccessResponse> | Revokes the data saving operation. This API uses a promise to return the result. | +| DistributedDataObject | save(deviceId: string): Promise<SaveSuccessResponse> | Saves a distributed data object.| +| DistributedDataObject| revokeSave(): Promise<RevokeSaveSuccessResponse> | Revokes the data saving operation.| ## How to Develop @@ -89,12 +87,14 @@ The following example shows how to implement distributed data object synchroniza import distributedObject from '@ohos.data.distributedDataObject'; ``` -2. Request the permission. +2. Apply for the permission. + + Add the required permission (FA model) in the **config.json** file. + + The sample code is as follows: - Add the required permission in the **config.json** file. The sample code is as follows: - - ``` - { + ```json + { "module": { "reqPermissions": [ { @@ -103,106 +103,125 @@ The following example shows how to implement distributed data object synchroniza ] } } - ``` - 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: - - ``` + ``` + + For the apps based on the stage model, see [Declaring Permissions](../security/accesstoken-guidelines.md#stage-model). + + This permission must also be granted by the user when the application is started for the first time. The sample code is as follows: + + ```json import featureAbility from '@ohos.ability.featureAbility'; - - function grantPermission() { - console.info('grantPermission'); - let context = featureAbility.getContext(); - context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { - console.info(`result.requestCode=${result.requestCode}`) - - }) - console.info('end grantPermission'); - } - grantPermission(); - ``` - - - + + function grantPermission() { + console.info('grantPermission'); + let context = featureAbility.getContext(); + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { + console.info(`result.requestCode=${result.requestCode}`) + + }) + console.info('end grantPermission'); + } + + grantPermission(); + ``` + + + 3. Obtain a distributed data object instance. The sample code is as follows: ```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. Add the synchronization network. The data objects in the synchronization network include the local and remote objects. +4. Add the distributed data object instance to the synchronization network. - The sample code is as follows: + The data objects in the synchronization network include the local and remote objects. + The sample code is as follows: + ```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"}]}); + 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); // Remote object - 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 + }); // After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18. + remote_object.setSessionId(sessionId); ``` 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. - + You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes. + The sample code is as follows: - + ```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]); - }); - } - } + if (changeData != null && changeData != undefined) { + 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)); + // To refresh the page in changeCallback, correctly bind (this) to the changeCallback. + local_object.on("change", this.changeCallback.bind(this)); ``` - -6. Modify object attributes. + +6. Modify attributes of the distributed data object. 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.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) **NOTE** - > - > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. - - Example: + > **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"}; + local_object.parent = { mother: "mom", father: "dad" }; // Modification not supported. 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. + Obtain the distributed data object attributes, which are the latest data on the network. The sample code is as follows: + ```js console.info("name " + local_object["name"]); ``` @@ -221,7 +240,6 @@ The following example shows how to implement distributed data object synchroniza ``` 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 @@ -234,53 +252,29 @@ The following example shows how to implement distributed data object synchroniza 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."); - }); - ​``` - ``` - - + ```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. + You can specify the callback to unregister. If you do not specify the callback, this API unregisters all status change callbacks of this distributed data object. The sample code is as follows: + ```js // Unregister the specified status change callback. local_object.off("status", this.statusCallback); @@ -288,9 +282,12 @@ The following example shows how to implement distributed data object synchroniza 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. +12. Remove a distributed data object from the synchronization network. - The sample code is as follows: - ```js - local_object.setSessionId(""); - ``` + 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(""); + ``` diff --git a/en/application-dev/database/database-distributedobject-overview.md b/en/application-dev/database/database-distributedobject-overview.md index 618bc881d563c11c51c9012831f48357a79830b1..80985ed39b8c91a5c9635e0be8fd00f4be2da702 100644 --- a/en/application-dev/database/database-distributedobject-overview.md +++ b/en/application-dev/database/database-distributedobject-overview.md @@ -1,29 +1,29 @@ # Distributed Data Object Overview -The distributed data object management framework is an object-oriented in-memory data management framework. It provides application developers with basic data object management capabilities, such as creating, querying, deleting, modifying, and subscribing to in-memory objects. This management framework also provides distributed capabilities to implement data object collaboration for the same application between multiple devices that form a Super Device. +The distributed data object management framework provides object-oriented in-memory data management. It provides basic data management capabilities, such as creating, querying, deleting, and modifying distributed data objects, and observing data and status changes of the distributed data objects. This management framework also provides distributed capabilities to implement data object collaboration for the same application between multiple devices that form a Super Device. -## Key Concepts +## Basic Concepts - **Distributed in-memory database** - The distributed in-memory database caches data in the memory, so that applications can quickly access data. This database, however, does not store data persistently. If the database is closed, the data is not retained. + The distributed in-memory database caches data in the memory so that applications can quickly access data. This database, however, does not store data persistently. If the database is closed, the data is not retained. - **Distributed data object** - A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading or assigning values to distributed data objects is automatically mapped to the **put** or **get** operation of the corresponding database. + A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading data from and writing data to a distributed data object are mapped to the **put** and **get** operations in the corresponding database, respectively. The distributed data object can be in the following states in its lifecycle: - **Uninitialized**: The distributed data object is not instantiated or has been destroyed. - **Local**: The data table is created, but the data cannot be synchronized. - - **Distributed**: The data table is created, there are at least two online with the same session ID, and data can be synchronized across devices. If the device is offline or the session ID is empty, the distributed data object changes to the local state. + - **Distributed**: The data table is created, and there are at least two online devices with the same session ID. In this case, data can be synchronized across devices. If a device is offline or the session ID is empty, the distributed data object changes to the local state. ## Working Principles -The distributed data objects are encapsulated into JS objects in distributed in-memory databases, which allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization. +The distributed data objects are encapsulated into JS objects in distributed in-memory databases. This allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization. **Figure 1** Working mechanism @@ -34,7 +34,7 @@ The distributed data objects are encapsulated into JS objects in distributed in- ## Constraints -- Data synchronization can be implemented across devices only for the applications with the same bundleName. +- Data synchronization can be implemented across devices only for the applications with the same **bundleName**. - Each distributed data object occupies 100 KB to 150 KB of memory. Therefore, you are advised not to create too many distributed data objects. diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index dd1594215a10d1c93c9825444253484ed8956e05..2205df9ceffb51c3c6cb7816f6d11784ba532b20 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -6,113 +6,144 @@ 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). +For details about the APIs, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md). **Table 1** APIs provided by the DDS | 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. | - - - +| 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. | ## How to Develop The following uses a single KV store as an example to describe the development procedure. 1. Import the distributed data module. + ```js import distributedData from '@ohos.data.distributedData'; ``` +2. Apply for the required permission if data synchronization is required. -2. Create a **KvManager** instance based on the specified **KvManagerConfig** object. - - (1) Create a **KvManagerConfig** object based on the application context. + Add the permission required (FA model) in the **config.json** file. The sample code is as follows: + + ```json + { + "module": { + "reqPermissions": [ + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ] + } + } + ``` + For the apps based on the stage model, see [Declaring Permissions](../security/accesstoken-guidelines.md#stage-model). + + This permission must also be granted by the user when the application is started for the first time. The sample code is as follows: + + ```js + import featureAbility from '@ohos.ability.featureAbility'; + + function grantPermission() { + console.info('grantPermission'); + let context = featureAbility.getContext(); + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { + console.info(`result.requestCode=${result.requestCode}`) + + }) + console.info('end grantPermission'); + } + + grantPermission(); + ``` + +3. 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 = { - 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. Create and obtain a single KV store. - (1) Declare the ID of the single KV store to create. +4. Create and obtain a single KV store. - (2) Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required. + 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: + ```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); } ``` - > **NOTE** + > **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. + +5. Subscribe to changes in the distributed data. -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: + ```js kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { console.log("dataChange callback call data: " + JSON.stringify(data)); }); ``` -5. Write data to the single KV store. - - (1) Construct the key and value to be written into the single KV store. +6. Write data to the single KV store. - (2) Write key-value pairs into 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: @@ -120,52 +151,54 @@ The following uses a single KV store as an example to describe the development p 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. Query data in the single KV store. - - (1) Construct the key to be queried from the single KV store. +7. Query data in the single KV store. - (2) Query data from 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: + ```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. Synchronize data to other devices.
+8. Synchronize data to other devices. + Select the devices in the same network and the synchronization mode to synchronize data. - > **NOTE** + > **NOTE**
> > The APIs of the `deviceManager` module are system interfaces. + + The following is the example code for synchronizing data in a single KV store: - The following is the sample code for synchronizing data in a single KV store: ```js import deviceManager from '@ohos.distributedHardware.deviceManager'; @@ -185,8 +218,8 @@ 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); + } catch (e) { + console.log("An unexpected error occurred. Error: " + e); } } }); diff --git a/en/application-dev/database/database-preference-guidelines.md b/en/application-dev/database/database-preference-guidelines.md index fdb69297523057f5530ef2f885fbe3e0b5cbf5cf..61aa2294c3f8ee077241e347e47e7780f50c4359 100644 --- a/en/application-dev/database/database-preference-guidelines.md +++ b/en/application-dev/database/database-preference-guidelines.md @@ -2,7 +2,7 @@ > **NOTE** > -> This feature is supported since API Version 9. For the versions earlier than API version 9, use [Lightweight Storage](../reference/apis/js-apis-data-storage.md) APIs. +> This feature is supported since API version 9. For the versions earlier than API version 9, use [Lightweight Storage](../reference/apis/js-apis-data-storage.md) APIs. ## When to Use @@ -88,8 +88,30 @@ Use the following APIs to delete a **Preferences** instance or data file. 2. Obtain a **Preferences** instance. Read the specified file and load its data to the **Preferences** instance for data operations. + + FA model: + ```js - let promise = data_preferences.getPreferences(this.context, 'mystore'); + // Obtain the context. + import featureAbility from '@ohos.ability.featureAbility' + var context = featureAbility.getContext() + + let promise = data_preferences.getPreferences(context, 'mystore'); + ``` + + Stage model: + + ```ts + // Obtain the context. + import Ability from '@ohos.application.Ability' + var context + class MainAbility extends Ability{ + onWindowStageCreate(windowStage){ + context = this.context + } + } + + let promise = data_preferences.getPreferences(context, 'mystore'); ``` 3. Write data. @@ -115,12 +137,12 @@ Use the following APIs to delete a **Preferences** instance or data file. ```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 the preferences.") }); @@ -139,24 +161,24 @@ Use the following APIs to delete a **Preferences** instance or data file. Specify an observer as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and saved by **flush()**, the observer callback will be invoked to return the new data. ```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; - } + 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("Put the value of 'startup' successfully."); - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data. Cause: " + err); - return; - } + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data. Cause: " + err); + return; + } console.info("Flushed data successfully."); // The observer will be called. - }) - }) + }) + }) ``` 7. Delete the specified file. @@ -164,10 +186,10 @@ Use the following APIs to delete a **Preferences** instance or data file. Use the **deletePreferences** method to delete the **Preferences** instance and its persistent file and backup and corrupted files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will be caused. The deleted data and files cannot be restored. ```js - let proDelete = data_preferences.deletePreferences(context, 'mystore'); - proDelete.then(() => { + let proDelete = data_preferences.deletePreferences(context, 'mystore'); + proDelete.then(() => { console.info("Deleted data successfully."); - }).catch((err) => { + }).catch((err) => { console.info("Failed to delete data. Cause: " + err); - }) + }) ``` diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index f6c7395339d66cb1c79bf71d424c15072f77f1b6..a4acbd9a7b47dca4332c7f6a881939b1928abd78 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -30,9 +30,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th **Table 2** API for inserting data + | 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.| + | 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** @@ -40,9 +41,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th **Table 3** API for updating data - | Class | API | Description | + + | 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. | + | 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.
the number of rows updated.
- **values**: data to update, which is stored in **ValuesBucket**.
- **predicates**: conditions for updating data.| - **Deleting Data** @@ -50,11 +52,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th **Table 4** API 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. | - - + + | 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 number of rows updated.
- **predicates**: conditions for deleting data.| - **Querying Data** @@ -65,10 +66,11 @@ 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>):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 | 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 @@ -81,11 +83,11 @@ The following lists common predicates. For more information about predicates, se | 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.| +| 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 @@ -101,12 +103,12 @@ For details about how to use result set APIs, see [Result Set](../reference/apis | 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. | +| 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. | @@ -164,7 +166,7 @@ You can obtain the distributed table name for a remote device based on the local | 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.| +| 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** @@ -172,7 +174,7 @@ You can obtain the distributed table name for a remote device based on the local | 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.| +| 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** @@ -180,9 +182,9 @@ 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. | +| 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 @@ -200,10 +202,10 @@ 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.') + rdbStore.executeSql(CREATE_TABLE_TEST) + console.info('create table done.') }) ``` @@ -217,7 +219,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) ``` @@ -316,6 +318,7 @@ Table 15 Transaction APIs console.log('device=' + device[i] + 'data changed') } } + try { rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) } catch (err) { @@ -366,9 +369,7 @@ Table 15 Transaction APIs (1) Back up the current RDB store. - (2) Restore the RDB store using the backup file. - - The sample code is as follows: + The sample code is as follows: ```js let promiseBackup = rdbStore.backup("dbBackup.db") @@ -378,6 +379,10 @@ Table 15 Transaction APIs console.info('Backup failed, err: ' + err) }) ``` + (2) Restore the RDB store using the backup file. + + The sample code is as follows: + ```js let promiseRestore = rdbStore.restore("dbBackup.db") promiseRestore.then(() => { @@ -386,4 +391,3 @@ Table 15 Transaction APIs console.info('Restore failed, err: ' + err) }) ``` - diff --git a/en/application-dev/device/vibrator-overview.md b/en/application-dev/device/vibrator-overview.md index 889f6b823cc0bbff99cd9bc9cbb2dde641766420..62e0d0d7b99e8bc4eaf5c38b4fc3006a19264df2 100644 --- a/en/application-dev/device/vibrator-overview.md +++ b/en/application-dev/device/vibrator-overview.md @@ -23,4 +23,4 @@ The vibrator is a Misc device that consists of four modules: Vibrator API, Vibra ## Constraints -When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The sensitivity level of this permission is **system_grant**. +When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The authorization mode of this permission is **system_grant**. diff --git a/en/application-dev/media/camera.md b/en/application-dev/media/camera.md index 5af14112df2959acbcfc606c9cd2938860ad6f85..bdbccf975c64a6df4cef6845c850cc8de1b2de26 100644 --- a/en/application-dev/media/camera.md +++ b/en/application-dev/media/camera.md @@ -54,7 +54,7 @@ await cameraManager.getCameras((err, cameras) => { cameraArray = cameras }) -for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) { +for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) { console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID. console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position. console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type. diff --git a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md index 8a366b1e21bb988c608ba0a5e57251f2bd237d75..c48d33d59a701fb998f82316d5c70a0d86fc5ea1 100644 --- a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @@ -25,56 +25,25 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility'; ## WindowExtensionAbility.onConnect -onConnect(want: Want): rpc.RemoteObject +onConnect(want: Want): void Called when this Window Extension ability is connected to an ability for the first time. **System capability**: SystemCapability.WindowManager.WindowManager.Core +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. | - -**Return value** -| Type | Description | -| ----------------------------------------------- | -------------------- | -| [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Proxy of this Window Extension ability.| +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.| **Example** ```ts -import rpc from '@ohos.rpc'; - -class StubTest extends rpc.RemoteObject { - constructor(des) { - super(des); - } - onRemoteRequest(code, data, reply, option) { - return true; - } - queryLocalInterface(descriptor) { - return null; - } - getInterfaceDescriptor() { - return ""; - } - sendRequest(code, data, reply, options) { - return null; - } - getCallingPid() { - return 1; - } - getCallingUid() { - return 1; - } - attachLocalInterface(localInterface, descriptor){} -} - export default class MyWindowExtensionAbility extends WindowExtensionAbility { - onConnect(want): rpc.RemoteObject { + onConnect(want) { console.info('WindowExtAbility onConnect ' + want.abilityName); - return new StubTest("test"); } } @@ -88,9 +57,11 @@ Called when this Window Extension ability is disconnected from all connected abi **System capability**: SystemCapability.WindowManager.WindowManager.Core +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.| **Example** @@ -105,7 +76,6 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility { } ``` - ## WindowExtensionAbility.onWindowReady onWindowReady(window: Window): void @@ -114,6 +84,8 @@ Called when a window is ready. **System capability**: SystemCapability.WindowManager.WindowManager.Core +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | window | [Window](js-apis-window.md) | Yes| Current **Window** instance.| diff --git a/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md b/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md index 499dafec721fd280beee9e9ccfcab76ae895bd14..4c04dd7a835c647889d70dff754d6baf14730efb 100644 --- a/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md +++ b/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md @@ -119,6 +119,25 @@ Subscribes to device connection events. This API uses an asynchronous callback t > This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceconnect9) instead. +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| + | callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.| + +**Example** + + ```js + continuationManager.on("deviceConnect", (data) => { + console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); + console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); + console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name)); + }); + ``` + ## continuationManager.on("deviceDisconnect")(deprecated) on(type: "deviceDisconnect", callback: Callback\): void; @@ -127,6 +146,23 @@ Subscribes to device disconnection events. This API uses an asynchronous callbac > This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondevicedisconnect9) instead. +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| + | callback | Callback\ | Yes| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.| + +**Example** + + ```js + continuationManager.on("deviceDisconnect", (data) => { + console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); + }); + ``` + ## continuationManager.off("deviceConnect")(deprecated) off(type: "deviceConnect", callback?: Callback\): void; @@ -135,6 +171,25 @@ Unsubscribes from device connection events. This API uses an asynchronous callba > This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceconnect9) instead. +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| + | callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | No| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.| + +**Example** + + ```js + continuationManager.off("deviceConnect", (data) => { + console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); + console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); + console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name)); + }); + ``` + ## continuationManager.off("deviceDisconnect")(deprecated) off(type: "deviceDisconnect", callback?: Callback\): void; @@ -143,6 +198,23 @@ Unsubscribes from device disconnection events. This API uses an asynchronous cal > This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdevicedisconnect9) instead. +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| + | callback | Callback\ | No| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.| + +**Example** + + ```js + continuationManager.off("deviceDisconnect", (data) => { + console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); + }); + ``` + ## continuationManager.on("deviceConnect")9+ on(type: "deviceConnect", token: number, callback: Callback\>): void; diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md index 82941689b8d2d511ca1878b0b03fac2e1c32dafd..3a2f046c36b3c17bca7c87c71e18c69971b5683c 100644 --- a/en/application-dev/reference/apis/js-apis-convertxml.md +++ b/en/application-dev/reference/apis/js-apis-convertxml.md @@ -55,8 +55,8 @@ let options = {trim : false, declarationKey:"_declaration", commentKey : "_comment", parentKey : "_parent", typeKey : "_type", nameKey : "_name", elementsKey : "_elements"} let result = JSON.stringify(conv.convert(xml, options)); -console.log(result) -// Output(Non compact) +console.log(result); +// Output (non-compact) // {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]} ``` 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 296b8a58c2e89677eed23ee377c7568603429646..00f23561e5e00936a425c2fbb6070e361597a4aa 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -1529,9 +1529,9 @@ Queries data from the RDB store of a remote device based on specified conditions **Example** ```js -let predicates = new rdb.RdbPredicates('EPLOYEE') +let predicates = new rdb.RdbPredicates('EMPLOYEE') predicates.greaterThan("id", 0) -rdbStore.remoteQuery("deviceId", "EPLOYEE", predicates, function(err, resultSet){ +rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates, function(err, resultSet){ if (err) { console.info("Failed to remoteQuery, err: " + err) return @@ -1567,7 +1567,7 @@ Queries data from the RDB store of a remote device based on specified conditions **Example** ```js -let predicates = new rdb.RdbPredicates('EPLOYEE') +let predicates = new rdb.RdbPredicates('EMPLOYEE') predicates.greaterThan("id", 0) let promise = rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates) promise.then((resultSet) => { diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index cd1535b43bfe4e5d13a6460b066a082e31db8020..ff9f8d69e48847bd60741f174af4dbe92a19e2ee 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -55,7 +55,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); let storage = data_storage.getStorageSync(path + '/mystore'); @@ -88,7 +88,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); data_storage.getStorage(path + '/mystore', function (err, storage) { @@ -131,7 +131,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); let getPromise = data_storage.getStorage(path + '/mystore'); @@ -167,7 +167,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); data_storage.deleteStorageSync(path + '/mystore'); @@ -198,7 +198,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); data_storage.deleteStorage(path + '/mystore', function (err) { @@ -239,7 +239,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); let promisedelSt = data_storage.deleteStorage(path + '/mystore'); @@ -274,7 +274,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); data_storage.removeStorageFromCacheSync(path + '/mystore'); @@ -305,7 +305,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); data_storage.removeStorageFromCache(path + '/mystore', function (err) { @@ -347,7 +347,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); }); let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore') diff --git a/en/application-dev/reference/apis/js-apis-effectKit.md b/en/application-dev/reference/apis/js-apis-effectKit.md index 089bf96cb239204c4b52c3ce71848f15141d76a4..c5edd6538136499bfe2deb04450cefbda2d8f146 100644 --- a/en/application-dev/reference/apis/js-apis-effectKit.md +++ b/en/application-dev/reference/apis/js-apis-effectKit.md @@ -67,7 +67,7 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses a promi | Type | Description | | ---------------------- | -------------- | -| Promisse\<[ColorPicker](#colorpicker)> | Promise used to return the **ColorPicker** instance created.| +| Promise\<[ColorPicker](#colorpicker)> | Promise used to return the **ColorPicker** instance created.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-prompt.md b/en/application-dev/reference/apis/js-apis-prompt.md index 971b3408c9a9fdd616fe1133ca3cab3844ee7fd1..11ec375e987ab2312a93b5233bd4ecdd049bb79d 100644 --- a/en/application-dev/reference/apis/js-apis-prompt.md +++ b/en/application-dev/reference/apis/js-apis-prompt.md @@ -21,28 +21,31 @@ Shows a toast. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | Name | Type | Mandatory | Description | | ------- | ------------------------------------- | ---- | ------- | | options | [ShowToastOptions](#showtoastoptions) | Yes | Toast options.| **Example** - ```js + +```js prompt.showToast({ message: 'Message Info', duration: 2000, }); - ``` +``` + ## ShowToastOptions Describes the options for showing the toast. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ------ | ---------------------------------------- | -| message | string\| [Resource](.../ui/ts-types.md#resource-type)9+| Yes | Text to display. | -| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.| -| bottom | string\| number | No | Distance between the toast border and the bottom of the screen. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| message | string\| [Resource](.../ui/ts-types.md#resource-type)9+| Yes | Text to display. | +| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used. If the value greater than 10000 ms is set, the upper limit 10000 ms is used.| +| bottom | string\| number | No | Distance between the toast border and the bottom of the screen. | ## prompt.showDialog @@ -53,6 +56,7 @@ Shows a dialog box. This API uses a promise to return the result synchronously. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | Name | Type | Mandatory | Description | | ------- | --------------------------------------- | ---- | ------ | | options | [ShowDialogOptions](#showdialogoptions) | Yes | Dialog box options.| @@ -65,7 +69,7 @@ Shows a dialog box. This API uses a promise to return the result synchronously. **Example** - ```js +```js prompt.showDialog({ title: 'Title Info', message: 'Message Info', @@ -86,7 +90,7 @@ prompt.showDialog({ .catch(err => { console.info('showDialog error: ' + err); }) - ``` +``` ## prompt.showDialog @@ -96,15 +100,16 @@ Shows a dialog box. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.ArkUI.ArkUI.Full - **Parameters** + | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------ | | options | [ShowDialogOptions](#showdialogoptions) | Yes | Dialog box options.| | callback | AsyncCallback<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | Yes | Callback used to return the dialog box response result. | **Example** - ```js + +```js prompt.showDialog({ title: 'showDialog Title Info', message: 'Message Info', @@ -125,7 +130,7 @@ prompt.showDialog({ } console.info('showDialog success callback, click button: ' + data.index); }); - ``` +``` ## ShowDialogOptions @@ -159,6 +164,7 @@ Shows an action menu. This API uses a callback to return the result asynchronous **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | --------- | | options | [ActionMenuOptions](#actionmenuoptions) | Yes | Action menu options. | @@ -166,7 +172,8 @@ Shows an action menu. This API uses a callback to return the result asynchronous **Example** - ```js + +```js prompt.showActionMenu({ title: 'Title Info', buttons: [ @@ -186,7 +193,7 @@ prompt.showActionMenu({ } console.info('showActionMenu success callback, click button: ' + data.index); }) - ``` +``` ## prompt.showActionMenu @@ -197,17 +204,20 @@ Shows an action menu. This API uses a promise to return the result synchronously **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** + | Name | Type | Mandatory | Description | | ------- | --------------------------------------- | ---- | ------- | | options | [ActionMenuOptions](#actionmenuoptions) | Yes | Action menu options.| **Return value** + | Type | Description | | ---------------------------------------- | ------- | | Promise<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | Promise used to return the action menu response result.| **Example** - ```js + +```js prompt.showActionMenu({ title: 'showActionMenu Title Info', buttons: [ @@ -227,7 +237,7 @@ prompt.showActionMenu({ .catch(err => { console.info('showActionMenu error: ' + err); }) - ``` +``` ## ActionMenuOptions Describes the options for showing the action menu. diff --git a/en/application-dev/reference/apis/js-apis-screen.md b/en/application-dev/reference/apis/js-apis-screen.md index 94f5f3cb5e532f3e28f221addb164358589b1754..73ea5d3c915d2ba91c129ed8d7c8ed80efe8170d 100644 --- a/en/application-dev/reference/apis/js-apis-screen.md +++ b/en/application-dev/reference/apis/js-apis-screen.md @@ -99,7 +99,7 @@ Unsubscribes from events related to the screen state. **Example** ```js var callback = (data) => { - console.info('Unegister the callback for screen changes. Data: ' + JSON.stringify(data)) + console.info('Unregister the callback for screen changes. Data: ' + JSON.stringify(data)) }; screen.off("connect", callback); ``` diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index 4c716d142c2d773da09dec8e2c0d8b09d0d628aa..c30f11c4a06a5b80ae2f00f88a5baa8e071ffad3 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -3122,7 +3122,7 @@ let promise = windowClass.setForbidSplitMove(isForbidSplitMove); promise.then((data)=> { console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to forbidd window moving in split screen mode. Cause: ' + JSON.stringify(err)); + console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err)); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index c7d28fe1bf86073c4453ea9e2cf9cbcb3698062e..7544a074dd9261a349698e813ac1b82b77a6ab66 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -357,9 +357,9 @@ that.parse(options); console.log(str); // Output: // key:0 value:0key:2 value:1key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:3 value:1key:1 value:0 -// Notes: -// The key represents the current event type, and the value represents the depth of the current parsing. You can know the parsed event according to EVENTTYPE. For example, the result 'key: value' in this example means: -// 0(START_DOCUMENT):0(Parse to the START_DOCUMENT, and the depth is 0), 2(START_TAG):1(Parse to the START_TAG node, and the depth is 1), 10(WHITESPACE):1(Parse to the WHITESPACE space, and the depth is 1), 2(START_TAG):2(Parse to the START_TAG title, and the depth is 2), ... +// Note: +// key indicates the event type, and value indicates the parsing depth. You can learn the specific parsed event based on EVENTTYPE. In this example, key: value means: +// 0(START_DOCUMENT):0 (START_DOCUMENT is being parsed, and the depth is 0), 2(START_TAG):1 (START_TAG is being parsed, and the depth is 1), 10(WHITESPACE):1 (WHITESPACE is being parsed, and the depth is 1), 2(START_TAG):2 (START_TAG is being parsed, and the depth is 2), ... ``` diff --git a/en/application-dev/windowmanager/application-window-fa.md b/en/application-dev/windowmanager/application-window-fa.md index 8908173be47d0c3a8bcdb91c1fab623b4d153c9f..75b71275759c812aaf3c69707e07a4378ba7e333 100644 --- a/en/application-dev/windowmanager/application-window-fa.md +++ b/en/application-dev/windowmanager/application-window-fa.md @@ -182,7 +182,7 @@ To create a better video watching and gaming experience, you can use the immersi - Method 1: Call `setFullScreen` to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden. - Method 2: Call `setSystemBarEnable` to hide the navigation bar and status bar. - - Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemPropertites` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window. + - Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window. ```js // 2. Use method 1 to implement the immersive effect. diff --git a/en/application-dev/windowmanager/application-window-stage.md b/en/application-dev/windowmanager/application-window-stage.md index 10ea5f3476de69cd7fe9efa72a0a6bdd6a6a75d5..f0598cf8bfb90fe275f8fa45fb759b7093be21e2 100644 --- a/en/application-dev/windowmanager/application-window-stage.md +++ b/en/application-dev/windowmanager/application-window-stage.md @@ -216,7 +216,7 @@ To create a better video watching and gaming experience, you can use the immersi 2. Implement the immersive effect. You can use any of the following methods: - Method 1: Call `setFullScreen` to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden. - Method 2: Call `setSystemBarEnable` to hide the navigation bar and status bar. - - Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemPropertites` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window. + - Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window. 3. Load content for the immersive window and show it. diff --git a/en/device-dev/device-dev-guide.md b/en/device-dev/device-dev-guide.md index 65f1bdf8e5afcdaa4c8d092f68d87eb6ad406693..f0ececf4cb84370794b75de3a734e745664b7d48 100644 --- a/en/device-dev/device-dev-guide.md +++ b/en/device-dev/device-dev-guide.md @@ -34,7 +34,7 @@ In addition, OpenHarmony provides a wide array of system components that can be | About OpenHarmony| Getting familiar with OpenHarmony | - [About OpenHarmony](https://gitee.com/openharmony)
- [Glossary](../glossary.md)| | Development resources | Preparing for your development | - [Obtaining Source Code](get-code/sourcecode-acquire.md)
- [Obtaining Tools](get-code/gettools-acquire.md) | | Getting started | Getting started with setup, build, burning, debugging, and running of OpenHarmony | - [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md)| -| Basic capabilities | Using basic capabilities of OpenHarmony | - [Kernel for Mini System](kernel/kernel-mini-overview.md)
- [Kernel for Small System](kernel/kernel-small-overview.md)
- [HDF](driver/driver-hdf-overview.md)
- [Subsystems](subsystems/subsys-build-mini-lite.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- [Privacy Protection](security/security-privacy-protection.md)| +| Basic capabilities | Using basic capabilities of OpenHarmony | - [Kernel for Mini System](kernel/kernel-mini-overview.md)
- [Kernel for Small System](kernel/kernel-small-overview.md)
- [HDF](driver/driver-hdf-overview.md)
- [Subsystems](subsystems/subsys-build-all.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- [Privacy Protection](security/security-privacy-protection.md) | | Advanced development | Developing smart devices based on system capabilities | - [WLAN-connected Products](guide/device-wlan-led-control.md)
- [Cameras Without a Screen](guide/device-iotcamera-control-overview.md)
- [Cameras with a Screen](guide/device-camera-control-overview.md) | | Porting and adaptation | - Porting and adapting OpenHarmony to an SoC
- Porting and adapting OpenHarmony to a third-party library
- Third-party vendor porting cases
| - [Mini System SoC Porting Guide](porting/porting-minichip.md)
- [Small System SoC Porting Guide](porting/porting-smallchip-prepare-needs.md)
- [Third-Party Library Porting Guide for Mini and Small Systems](porting/porting-thirdparty-overview.md)
- [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md)
- [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md)
| | Contributing components | Contributing components to OpenHarmony | - [HPM Part Overview](hpm-part/hpm-part-about.md)
- [HPM Part Development](hpm-part/hpm-part-development.md)
- [HPM Part Reference](hpm-part/hpm-part-reference.md) | @@ -48,7 +48,7 @@ In addition, OpenHarmony provides a wide array of system components that can be | About OpenHarmony| Getting familiar with OpenHarmony| - [About OpenHarmony](https://gitee.com/openharmony)
- [Glossary](../glossary.md)| | Development resources| Preparing for your development| - [Obtaining Source Code](get-code/sourcecode-acquire.md)
- [Obtaining Tools](get-code/gettools-acquire.md)| | Getting started| Getting started with setup, build, burning, debugging, and running of OpenHarmony| - [Standard System Overview](quick-start/quickstart-ide-standard-overview.md) | -| Basic capabilities| Using basic capabilities of OpenHarmony| - [Kernel Development](kernel/kernel-standard.md)
- [HDF](driver/driver-hdf-overview.md)
- [Subsystems](subsystems/subsys-build-standard-large.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- [Privacy Protection](security/security-privacy-protection.md)| +| Basic capabilities| Using basic capabilities of OpenHarmony| - [Kernel Development](kernel/kernel-standard-overview.md)
- [HDF](driver/driver-hdf-overview.md)
- [Subsystems](subsystems/subsys-build-all.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- [Privacy Protection](security/security-privacy-protection.md) | | Advanced development| Developing smart devices based on system capabilities| - [Development Guidelines on Clock Apps](guide/device-clock-guide.md)
- [Development Example for Platform Drivers](guide/device-driver-demo.md)
- [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) | | Porting and adaptation| - Porting and adapting OpenHarmony to an SoC
- Rapidly porting the OpenHarmony Linux kernel| - [Standard System Porting Guide](porting/standard-system-porting-guide.md)
- [A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting/porting-linux-kernel.md) | | Contributing components| Contributing components to OpenHarmony| - [HPM Part Overview](hpm-part/hpm-part-about.md)
- [HPM Part Development](hpm-part/hpm-part-development.md)
- [HPM Part Reference](hpm-part/hpm-part-reference.md) | diff --git a/en/device-dev/driver/driver-peripherals-pinauth-des.md b/en/device-dev/driver/driver-peripherals-pinauth-des.md index 08a3ac84a224ca046bd7b2439199011f3d934da5..888e229cce93bf29bb78a9b156b180d8237850bd 100644 --- a/en/device-dev/driver/driver-peripherals-pinauth-des.md +++ b/en/device-dev/driver/driver-peripherals-pinauth-des.md @@ -25,11 +25,11 @@ The identity authentication consists of User_auth and basic authentication servi - Executor role - - ​ Executor: independently completes the entire process of credential registration and identity authentication. The executor can collect, process, store, and compare data to complete the authentication. + - Executor: independently completes the entire process of credential registration and identity authentication. The executor can collect, process, store, and compare data to complete the authentication. - - ​ Collector: only collects data during user authentication. It needs to work with the authenticator to complete user authentication. + - Collector: only collects data during user authentication. It needs to work with the authenticator to complete user authentication. - - ​ Authenticator: only processes data, obtains the stored credential template, and compares it with the authentication information generated. + - Authenticator: only processes data, obtains the stored credential template, and compares it with the authentication information generated. - Executor type @@ -56,7 +56,7 @@ The identity authentication consists of User_auth and basic authentication servi The Pin_auth driver provides basic PIN authentication capabilities for the upper-layer User_auth and Pin_auth service to ensure successful PIN authentication. You can develop drivers to call Hardware Device Interface (HDI) APIs based on the HDF and the chip you use. -**Figure 2** Pin_auth service and pin_auth driver APIs +**Figure 2** Pin_auth service and Pin_auth driver APIs ![image](figures/pin_auth_service_and_driver_interaction.png "interaction between the pin_auth service and driver") @@ -93,24 +93,32 @@ The Pin_auth driver provides basic PIN authentication capabilities for the User_ ### How to Develop -The following uses the RK3568 platform as an example to demonstrate how to develop the Pin_auth driver.
The directory structure is as follows: +The following uses the RK3568 platform as an example to demonstrate how to develop the Pin_auth driver. -``` +The directory structure is as follows: + +```text // drivers/peripheral/pin_auth ├── BUILD.gn # Build script ├── bundle.json # Module description file +├── test # Test cases └── hdi_service # Pin_auth driver implementation ├── BUILD.gn # Build script - ├── inc # Header files - └── src - ├── executor_impl.cpp # Implementation of authentication and enrollment APIs - ├── pin_auth_interface_driver.cpp # Pin_auth driver entry - └── pin_auth_interface_service.cpp # Implementation of the APIs for obtaining the executor list + ├── adaptor # Implementation of related algorithms + ├── common # Implementation of common interfaces + ├── database # Database implementation + ├── main # Entry for implementing PIN-related functions + └── service # Entry for implementing the Pin_auth driver + ├── inc # Header files + └── src + ├── executor_impl.cpp # Implementation of authentication and enrollment APIs + ├── pin_auth_interface_driver.cpp # Pin_auth driver entry + └── pin_auth_interface_service.cpp # Implementation of the APIs for obtaining the executor list ``` The development procedure is as follows: -1. Develop the Pin_auth driver based on the HDF. The **Bind()**, **Init()**, **Release()**, and **Dispatch()** functions are used. For details about the code, see [pin_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/src/pin_auth_interface_driver.cpp). +1. Develop the Pin_auth driver based on the HDF. The **Bind()**, **Init()**, **Release()**, and **Dispatch()** functions are used. For details about the code, see [pin_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/pin_auth_interface_driver.cpp). ```c++ // Create the PinAuthInterfaceService object by using the custom HdfPinAuthInterfaceHost object, which consists of the IoService object and HDI service. @@ -212,7 +220,7 @@ The development procedure is as follows: -1. Obtain the executor list. For details about the code, see [pin_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/src/pin_auth_interface_service.cpp). +1. Obtain the executor list. For details about the code, see [pin_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/pin_auth_interface_service.cpp). ```c++ // Executor implementation class @@ -285,7 +293,7 @@ The development procedure is as follows: -1. Implement each function of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/src/executor_impl.cpp). +1. Implement each function of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/executor_impl.cpp). ```c++ // Obtain executor information (example only). @@ -526,7 +534,8 @@ The development procedure is as follows: ### Verification Verify whether PIN authentication can be successfully performed on the RK3568 platform as follows: -1. Set a PIN.
+1. Set a PIN. + Touch **Settings** > **Biometrics & passwords** > **Password**, and enter your password. 2. Verify PIN authentication. diff --git a/en/device-dev/guide/device-driver-demo.md b/en/device-dev/guide/device-driver-demo.md index ceed4c96f66bb1387814c350dd7e75873d58f61c..69d160ee94d4c8bb258ea12df6fd0262f95c0420 100644 --- a/en/device-dev/guide/device-driver-demo.md +++ b/en/device-dev/guide/device-driver-demo.md @@ -430,6 +430,8 @@ Initialize the controller hardware, call core-layer APIs to add or delete device 2. Build source code and burn images to the development board. - For details, see the related sections in [Getting Started for Standard System](../quick-start/quickstart-standard.md). + - For details about the operations using the installation package, see [Building](../quick-start/quickstart-ide-standard-running-hi3516-build.md) and [Burning](../quick-start/quickstart-ide-standard-running-hi3516-burning.md). + + - For details about the operations in IDE mode, see [Building](../quick-start/quickstart-standard-running-hi3516-build.md) and [Burning](../quick-start/quickstart-standard-running-hi3516-burning.md). diff --git a/en/device-dev/guide/device-outerdriver-demo.md b/en/device-dev/guide/device-outerdriver-demo.md index b2238b6af22a247927421bec914b118dcbfe18e9..fae7c72d1f7772dc911d59626df099ea4ea1fb22 100644 --- a/en/device-dev/guide/device-outerdriver-demo.md +++ b/en/device-dev/guide/device-outerdriver-demo.md @@ -315,7 +315,7 @@ The input driver model consists of three parts of drivers. To develop a brand-ne **touch\_gt911.o** is the content added in this example. -2. Build source code and burn images. For details, see the related sections in [Getting Started for Standard System](../quick-start/quickstart-standard.md). +2. Build source code and burn images. For details, see the related sections in [Standard System Overview](../quick-start/quickstart-standard-overview.md). ## Debugging and Verification diff --git a/en/device-dev/kernel/kernel-small-start-user.md b/en/device-dev/kernel/kernel-small-start-user.md index fb34ba4194831b84c2683fd4ab11e2ee2cc2098c..64f0cf6dece3286be85e94b463c4b9549f534f94 100644 --- a/en/device-dev/kernel/kernel-small-start-user.md +++ b/en/device-dev/kernel/kernel-small-start-user.md @@ -32,8 +32,9 @@ During system startup, **OsUserInitProcess** is called to start the **init** - Starts key system programs or services, such as shell. - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >In OpenHarmony, the **init** process reads the **/etc/init.cfg** file and runs specified commands or starts specified processes based on configurations. For details, see [init Module](../subsystems/subsys-boot-init.md). + >![](../public_sys-resources/icon-note.gif) **NOTE** + > + >In OpenHarmony, the **init** process reads the **/etc/init.cfg** file and runs specified commands or starts specified processes based on configurations. For details, see [init Module](../subsystems/subsys-boot-init-cfg.md). - Monitors the process for reclaiming the orphan process and clears the zombie processes in child processes. diff --git a/en/device-dev/security/security-guidelines-overall.md b/en/device-dev/security/security-guidelines-overall.md index 45e1c2262d6c002e8d2bccfb24b317e5189c9796..76dbd5a075069416b1cdae8ca97d76248b9bb8d1 100644 --- a/en/device-dev/security/security-guidelines-overall.md +++ b/en/device-dev/security/security-guidelines-overall.md @@ -92,7 +92,7 @@ For devices with 128 KB to 128 MB of memory, the OpenHarmony lite kernel is reco ### Mechanism -Huawei Universal Keystore Service \(HUKS\) provides key and certificate management. For OpenHarmony, it mainly provides key management for HiChain \(the device identity authentication platform\). The following figure shows the functions of HUKS +OpenHarmony Universal Keystore Service \(HUKS\) provides key and certificate management. For OpenHarmony, it mainly provides key management for HiChain \(the device identity authentication platform\). The following figure shows the functions of HUKS **Figure 3** HUKS functions ![](figure/huks-functions.png "huks-functions") diff --git a/en/device-dev/subsystems/subsys-application-framework-guide.md b/en/device-dev/subsystems/subsys-application-framework-guide.md index a3f521760240dbb2fec330557a38ec094c0e2614..508677cb988fad38d7858583010b70e51b65dd3b 100644 --- a/en/device-dev/subsystems/subsys-application-framework-guide.md +++ b/en/device-dev/subsystems/subsys-application-framework-guide.md @@ -534,7 +534,7 @@ When uninstalling an application, you can specify whether to retain application ``` sem_init(&g_sem, 0, 0); const uint32_t WAIT_TIMEOUT = 30; - std::string BUNDLE_NAME = "com.huawei.demo"; // Bundle name of the application to be uninstalled + std::string BUNDLE_NAME = "com.example.demo"; // Bundle name of the application to be uninstalled Uninstall(BUNDLE_NAME.c_str(), &installParam, UninstallCallback); struct timespec ts = {}; clock_gettime(CLOCK_REALTIME, &ts); @@ -557,7 +557,7 @@ You can use the **GetBundleInfo** function provided by **BundleManager** to 2. Call **GetBundleInfo** to obtain bundle information about a specified application. The **bundleName** parameter indicates the pointer to the application bundle name, and the **flags** parameter specifies whether the obtained **BundleInfo** object can contain **AbilityInfo**. ``` - std::string BUNDLE_NAME = "com.huawei.demo"; + std::string BUNDLE_NAME = "com.example.demo"; uint8_t ret = GetBundleInfo(BUNDLE_NAME.c_str(), 1, &bundleInfo); // When flags is set to 1, the obtained BundleInfo object contains AbilityInfo. ``` diff --git a/en/device-dev/subsystems/subsys-boot-faqs.md b/en/device-dev/subsystems/subsys-boot-faqs.md index e0b72945a026eaf5dd487f76351cbcec85b38b5e..f4e3eb59371a2cf083f9169c2ae42795eaa0f808 100644 --- a/en/device-dev/subsystems/subsys-boot-faqs.md +++ b/en/device-dev/subsystems/subsys-boot-faqs.md @@ -1,6 +1,6 @@ -# FAQs +# FAQs -## System startup interrupted due to "parse failed!" error +## System startup interrupted due to "parse failed!" error **Problem** @@ -17,7 +17,7 @@ During the modification of the **init.cfg** file, required commas \(,\) or par Check the **init.cfg** file and ensure that its format meets the JSON specifications. -## System automatically restarted again and again +## System automatically restarted again and again **Problem** @@ -25,7 +25,7 @@ After the image burning is complete, the system keeps restarting. **Cause** -Each service started by the init process has the **importance** attribute, as described in Table 3 in [init Module](subsys-boot-init.md). +Each service started by the init process has the **importance** attribute, as described in Table 3 in [Job Management](../subsystems/subsys-boot-init-jobs.md). - If the attribute value is **0**, the init process does not need to restart the development board when the current service process exits. - If the attribute value is **1**, the init process needs to restart the development board when the current service process exits. @@ -37,7 +37,7 @@ During the startup of a service whose **importance** is **1**, if the service 1. View logs to identify the service that encounters a process crash or exits due to an error, rectify the issue, and then burn the image again. 2. Alternatively, change the value of **importance** to **0** for the service that exits due to a process crash or an error, and then burn the image again. In this way, the development board will not be restarted even if the service exits. -## Failed to call the **SetParameter** or **GetParameter** API with correct parameter values +## Failed to call the **SetParameter** or **GetParameter** API with correct parameter values **Problem** diff --git a/en/device-dev/subsystems/subsys-boot-overview.md b/en/device-dev/subsystems/subsys-boot-overview.md index c1adc013182349d0a93621bd84db02445cd5a40a..11cdf0f3a91eb965293dd8884a61dff2b9ec8d52 100644 --- a/en/device-dev/subsystems/subsys-boot-overview.md +++ b/en/device-dev/subsystems/subsys-boot-overview.md @@ -23,7 +23,7 @@ When the system is powered on, the kernel loads and starts services and applicat The Startup subsystem consists of the following modules: - init module
- This module corresponds to the init process, which is the first user-mode process started after the kernel is initialized. After the init process starts, it reads and parses the **init.cfg** file. Based on the parsing result, the init module executes the commands listed in [Table 2](../subsystems/subsys-boot-init.md) and starts the key system service processes in sequence with corresponding permissions granted. + This module corresponds to the init process, which is the first user-mode process started after the kernel is initialized. After the init process starts, it reads and parses the **init.cfg** file. Based on the parsing result, the init module executes the commands listed in Table 2 in [Job Management](../subsystems/subsys-boot-init-jobs.md) and starts the key system service processes in sequence with corresponding permissions granted. - ueventd module
This module listens for **netlink** events about hot swap of kernel device drivers and dynamically manages the **dev** node of the corresponding device based on the event type. diff --git a/en/device-dev/subsystems/subsys-security-overview.md b/en/device-dev/subsystems/subsys-security-overview.md index f4e17ed0818e37519cfe6c1b6a1cb8122af5666f..2ed46817e0066bed27c8f3be692451efb43a20b6 100644 --- a/en/device-dev/subsystems/subsys-security-overview.md +++ b/en/device-dev/subsystems/subsys-security-overview.md @@ -20,6 +20,10 @@ The OpenHarmony security subsystem provides security capabilities that make your The Device Security Level Management (DSLM) module is introduced to manage the security levels of OpenHarmony devices. When different types of user data are hopped or processed in OpenHarmony distributed services, the DSLM APIs can be called to obtain the security levels of related devices for subsequent processing. +- HUKS + + The OpenHarmony Universal Keystore (HUKS) provides system-level key management capabilities, ensuring secure management and use of keys throughout their entire lifecycle (generation, storage, use, and destruction). Applications can call the APIs provided by the HUKS module to perform operations on keys. In addition, the keys in plaintext must be used in a trusted execution environment (TEE). + ## Basic Concepts diff --git a/en/device-dev/subsystems/subsys-testguide-test.md b/en/device-dev/subsystems/subsys-testguide-test.md index bc145cf411b90da15ce9b9ac3f2f20a7ee9aad05..031361ae8970c62ef4e3063b8f605dff8dd4c2f0 100644 --- a/en/device-dev/subsystems/subsys-testguide-test.md +++ b/en/device-dev/subsystems/subsys-testguide-test.md @@ -4,7 +4,6 @@ OpenHarmony provides a comprehensive auto-test framework for designing test case This document describes how to use the OpenHarmony test framework. ## Setting Up the Environment The test framework depends on the Python running environment. Before using the test framework, set up the environment as follows: - - [Setting Up the Environment](subsys-testguide-envbuild.md) - [Obtaining Source Code](../get-code/sourcecode-acquire.md) @@ -419,21 +418,22 @@ The following provides templates for different languages for your reference. 1. Add comment information for the file header. - ``` + ``` # Copyright (c) 2021 XXXX Device Co., Ltd. ``` 2. Import the build template. - ``` + ``` import("//build/test.gni") ``` 3. Specify the file output path. - - ``` + + ``` module_output_path = "subsystem_examples/calculator" ``` + > **NOTE**
> The output path is ***Part name*/*Module name***. @@ -470,15 +470,15 @@ The following provides templates for different languages for your reference. } ``` - > **NOTE**
- > Set the test type based on actual requirements. The following test types are available: - > - **ohos_unittest**: unit test - > - **ohos_moduletest**: module test - > - **ohos_systemtest**: system test - > - **ohos_performancetest**: performance test - > - **ohos_securitytest**: security test - > - **ohos_reliabilitytest**: reliability test - > - **ohos_distributedtest**: distributed test + > **NOTE**
+ > Set the test type based on actual requirements. The following test types are available:
+ > - **ohos_unittest**: unit test
+ > - **ohos_moduletest**: module test
+ > - **ohos_systemtest**: system test
+ > - **ohos_performancetest**: performance test
+ > - **ohos_securitytest**: security test
+ > - **ohos_reliabilitytest**: reliability test
+ > - **ohos_distributedtest**: distributed test
7. Group the test case files by test type. @@ -490,7 +490,7 @@ The following provides templates for different languages for your reference. ``` > **NOTE**
> Grouping test cases by test type allows you to execute a specific type of test cases when required. - + - **Test case build file example (JavaScript)** ``` @@ -530,6 +530,7 @@ The following provides templates for different languages for your reference. ``` module_output_path = "subsystem_examples/app_info" ``` + > **NOTE**
> The output path is ***Part name*/*Module name***. @@ -539,9 +540,10 @@ The following provides templates for different languages for your reference. ohos_js_unittest("GetAppInfoJsTest") { } ``` - > **NOTE** - >- Use the **ohos\_js\_unittest** template to define the JavaScript test suite. Pay attention to the difference between JavaScript and C++. - >- The file generated for the JavaScript test suite must be in .hap format and named after the test suite name defined here. The test suite name must end with **JsTest**. + + > **NOTE**
+ > - Use the **ohos\_js\_unittest** template to define the JavaScript test suite. Pay attention to the difference between JavaScript and C++. + > - The file generated for the JavaScript test suite must be in .hap format and named after the test suite name defined here. The test suite name must end with **JsTest**. 5. Configure the **config.json** file and signature file, which are mandatory. @@ -623,6 +625,7 @@ The following provides templates for different languages for your reference. deps = [ ":GetAppInfoJsTest" ] } ``` + > **NOTE**
> Grouping test cases by test type allows you to execute a specific type of test cases when required. @@ -673,7 +676,7 @@ Perform the following steps: resource_config_file = "//system/subsystem/partA/test/resource/calculator/ohos_test.xml" } ``` - >**NOTE** + >**NOTE**
>- **target_name** indicates the test suite name defined in the **BUILD.gn** file in the **test** directory.**preparer** indicates the action to perform before the test suite is executed. >- **src="res"** indicates that the test resources are in the **resource** directory under the **test** directory. **src="out"** indicates that the test resources are in the **out/release/$(*part*)** directory. @@ -748,7 +751,7 @@ After the build is complete, the test cases are automatically saved in **out/his 2. Copy **developertest** and **xdevice** from the Linux environment to the **Test** directory on Windows, and copy the test cases to the **testcase** directory. > **NOTE**
- > Port the test framework and test cases from the Linux environment to the Windows environment for subsequent execution. + > Port the test framework and test cases from the Linux environment to the Windows environment for subsequent execution. 3. Modify the **user_config.xml** file. ``` @@ -761,9 +764,10 @@ After the build is complete, the test cases are automatically saved in **out/his D:\Test\testcase\tests ``` + > **NOTE**
> `` indicates whether to build test cases. `` indicates the path for searching for test cases. - + #### Executing Test Cases 1. Start the test framework. ``` @@ -796,16 +800,18 @@ To enable test cases to be executed on a remote Linux server or a Linux VM, map hdc_std kill hdc_std -m -s 0.0.0.0:8710 ``` + > **NOTE**
> The IP address and port number are default values. - + 2. On the HDC client, run the following command: ``` hdc_std -s xx.xx.xx.xx:8710 list targets ``` + > **NOTE**
> Enter the IP address of the device to test. - + #### Executing Test Cases 1. Start the test framework. ``` diff --git a/en/device-dev/website.md b/en/device-dev/website.md index 2fc22d58a52c259bd34f6fed15af21505ae4f945..9494abb5a5e2ea35d8db6a345a359ac95159735c 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -1,161 +1,249 @@ # OpenHarmony Device Development Documentation - [Device Development Guide](device-dev-guide.md) - - Getting Started - Getting Started with Mini and Small Systems (IDE Mode, Recommended) + - [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md) + - Environment Preparation + - [Setting Up the Windows+Ubuntu Hybrid Build Environment](quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md) + - [Obtaining Source Code](quick-start/quickstart-ide-lite-sourcecode-acquire.md) + - [Creating a Source Code Project](quick-start/quickstart-ide-lite-create-project.md) + - Running a Hello World Program + - Hi3861 Development Board + - [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md) + - [Building](quick-start/quickstart-ide-lite-steps-hi3861-building.md) + - [Burning](quick-start/quickstart-ide-lite-steps-hi3861-burn.md) + - [Networking](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md) + - [Debugging and Verification](quick-start/quickstart-ide-lite-steps-hi3861-debug.md) + - [Running](quick-start/quickstart-ide-lite-steps-hi3861-running.md) + - Hi3516 Development Board + - [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md) + - [Building](quick-start/quickstart-ide-lite-steps-hi3516-building.md) + - [Burning](quick-start/quickstart-ide-lite-steps-hi3516-burn.md) + - [Running](quick-start/quickstart-ide-lite-steps-hi3516-running.md) + - Appendix + - [Introduction to the Hi3861 Development Board](quick-start/quickstart-ide-lite-introduction-hi3861.md) + - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-lite-introduction-hi3516.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) + - Getting Started with Mini and Small Systems (Installation Package Mode) + - [Mini and Small System Overview](quick-start/quickstart-lite-overview.md) + - [Environment Preparation](quick-start/quickstart-lite-env-setup.md) + - Running a Hello World Program + - Hi3861 Development Board + - [Setting Up the Hi3861 Development Board Environment](quick-start/quickstart-lite-steps-hi3861-setting.md) + - [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3861-helloworld.md) + - [Building](quick-start/quickstart-lite-steps-hi3861-building.md) + - [Burning](quick-start/quickstart-lite-steps-hi3861-burn.md) + - [Networking](quick-start/quickstart-lite-steps-hi3861-netconfig.md) + - [Debugging and Verification](quick-start/quickstart-lite-steps-hi3861-debug.md) + - [Running](quick-start/quickstart-lite-steps-hi3861-running.md) + - Hi3516 Development Board + - [Setting Up the Hi3516 Development Board Environment](quick-start/quickstart-lite-steps-hi3516-setting.md) + - [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3516-helloworld.md) + - [Building](quick-start/quickstart-lite-steps-hi3516-building.md) + - [Burning](quick-start/quickstart-lite-steps-hi3516-burn.md) + - [Running](quick-start/quickstart-lite-steps-hi3516-running.md) + - FAQs + - [Fixing hb Installation Issues](quick-start/quickstart-lite-faq-hb.md) + - [Fixing Compilation Issues](quick-start/quickstart-lite-faq-compose.md) + - [Fixing Burning Issues](quick-start/quickstart-lite-faq-burning.md) + - Appendix + - Introduction to Development Boards + - [Introduction to the Hi3861 Development Board](quick-start/quickstart-lite-introduction-hi3861.md) + - [Introduction to the Hi3516 Development Board](quick-start/quickstart-lite-introduction-hi3516.md) + - [Reference](quick-start/quickstart-lite-reference.md) + - [Burning Code by Using HiTool](quick-start/quickstart-lite-hitool.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) + - Getting Started with Standard System (IDE Mode, Recommended) + - [Standard System Overview](quick-start/quickstart-ide-standard-overview.md) + - Environment Preparation + - [Setting Up the Windows+Ubuntu Hybrid Build Environment](quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md) + - [Obtaining Source Code](quick-start/quickstart-ide-standard-sourcecode-acquire.md) + - [Creating a Source Code Project](quick-start/quickstart-ide-standard-create-project.md) + - Running a Hello World Program + - Hi3516 Development Board + - [Writing a Hello World Program](quick-start/quickstart-ide-standard-running-hi3516-create.md) + - [Building](quick-start/quickstart-ide-standard-running-hi3516-build.md) + - [Burning](quick-start/quickstart-ide-standard-running-hi3516-burning.md) + - [Running](quick-start/quickstart-ide-standard-running-hi3516-running.md) + - RK3568 Development Board + - [Writing a Hello World Program](quick-start/quickstart-ide-standard-running-rk3568-create.md) + - [Building](quick-start/quickstart-ide-standard-running-rk3568-build.md) + - [Burning](quick-start/quickstart-ide-standard-running-rk3568-burning.md) + - [Running](quick-start/quickstart-ide-standard-running-rk3568-running.md) + - Appendix + - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) + - [Introduction to the RK3568 Development Board](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) + - Getting Started with Standard System (Installation Package Mode) + - [Standard System Overview](quick-start/quickstart-standard-overview.md) + - [Setting Up Environments for Standard System](quick-start/quickstart-standard-env-setup.md) + - Running a Hello World Program + - Hi3516 Development Board + - [Writing a Hello World Program](quick-start/quickstart-std-3516-create.md) + - [Building](quick-start/quickstart-standard-running-hi3516-build.md) + - [Burning](quick-start/quickstart-standard-running-hi3516-burning.md) + - [Running](quick-start/quickstart-standard-running-hi3516-running.md) + - RK3568 Development Board + - [Writing a Hello World Program](quick-start/quickstart-standard-running-rk3568-create.md) + - [Building](quick-start/quickstart-standard-running-rk3568-build.md) + - [Burning](quick-start/quickstart-standard-running-rk3568-burning.md) + - [Running](quick-start/quickstart-standard-running-rk3568-running.md) + - FAQs + - [Fixing hb Installation Issues](quick-start/quickstart-standard-faq-hb.md) + - [Fixing Compilation Issues](quick-start/quickstart-standard-faq-compose.md) + - [Fixing Burning Issues](quick-start/quickstart-standard-faq-burning.md) + - Appendix + - Introduction to Development Boards + - [Introduction to the Hi3516 Development Board](quick-start/quickstart-standard-board-introduction-hi3516.md) + - [Introduction to the RK3568 Development Board](quick-start/quickstart-standard-board-introduction-rk3568.md) + - [Reference](quick-start/quickstart-standard-reference.md) + - [Burning Code by Using HiTool](quick-start/quickstart-standard-hitool.md) - - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) - [Obtaining Source Code](get-code/sourcecode-acquire.md) - -- Compatibility and Security - - [Privacy Protection](security/security-privacy-protection.md) - [Security Guidelines](security/security-guidelines-overall.md) - Porting - - - Mini System SoC Porting Guide - - - Porting Preparations - - [Before You Start](porting/porting-chip-prepare-knows.md) - - [Building Adaptation Process](porting/porting-chip-prepare-process.md) - - Kernel Porting - - [Porting Overview](porting/porting-chip-kernel-overview.md) - - [Basic Kernel Adaptation](porting/porting-chip-kernel-adjustment.md) - - [Kernel Porting Verification](porting/porting-chip-kernel-verify.md) - - Board-Level OS Porting - - [Porting Overview](porting/porting-chip-board-overview.md) - - [Board-Level Driver Adaptation](porting/porting-chip-board-driver.md) - - [Implementation of APIs at the HAL](porting/porting-chip-board-hal.md) - - [System Modules](porting/porting-chip-board-component.md) - - [lwIP Module Adaptation](porting/porting-chip-board-lwip.md) - - [Third-party Module Adaptation](porting/porting-chip-board-bundle.md) - - [XTS](porting/porting-chip-board-xts.md) - - [FAQs](porting/porting-chip-faqs.md) - - Small System SoC Porting Guide - Porting Preparations + - [Before You Start](porting/porting-smallchip-prepare-needs.md) + - [Compilation and Building](porting/porting-smallchip-prepare-building.md) + - Kernel Porting + - [LiteOS Cortex-A](porting/porting-smallchip-kernel-a.md) + - [Linux Kernel](porting/porting-smallchip-kernel-linux.md) + - Driver Porting + - [Porting Overview](porting/porting-smallchip-driver-overview.md) + - [Platform Driver Porting](porting/porting-smallchip-driver-plat.md) + - [Device Driver Porting](porting/porting-smallchip-driver-oom.md) - Standard System SoC Porting Guide - [Standard System Porting Guide](porting/standard-system-porting-guide.md) + - [A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting/porting-linux-kernel.md) - Third-Party Library Porting Guide for Mini and Small Systems + - [Overview](porting/porting-thirdparty-overview.md) + - [Porting a Library Built Using CMake](porting/porting-thirdparty-cmake.md) + - [Porting a Library Built Using Makefile](porting/porting-thirdparty-makefile.md) - Mini System SoC Porting Cases + - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md) + - [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md) + - Subsystem Development - Kernel @@ -164,10 +252,7 @@ - Basic Kernel - [Interrupt Management](kernel/kernel-mini-basic-interrupt.md) - [Task Management](kernel/kernel-mini-basic-task.md) - - Memory Management - - [Basic Concepts](kernel/kernel-mini-basic-memory-basic.md) - - [Static Memory](kernel/kernel-mini-basic-memory-static.md) - - [Dynamic Memory](kernel/kernel-mini-basic-memory-dynamic.md) + - [Memory Management](kernel/kernel-mini-basic-memory.md) - Kernel Communication Mechanisms - [Event](kernel/kernel-mini-basic-ipc-event.md) - [Mutex](kernel/kernel-mini-basic-ipc-mutex.md) @@ -179,23 +264,16 @@ - [C++ Support](kernel/kernel-mini-extend-support.md) - [CPUP](kernel/kernel-mini-extend-cpup.md) - [Dynamic Loading](kernel/kernel-mini-extend-dynamic-loading.md) - - File System - - [FAT](kernel/kernel-mini-extend-file-fat.md) - - [LittleFS](kernel/kernel-mini-extend-file-lit.md) + - [File System](kernel/kernel-mini-extend-file.md) - Kernel Debugging - - Memory Debugging - - [Memory Information Statistics](kernel/kernel-mini-memory-debug-mes.md) - - [Memory Leak Check](kernel/kernel-mini-memory-debug-det.md) - - [Memory Corruption Check](kernel/kernel-mini-memory-debug-cet.md) + - [Memory Debugging](kernel/kernel-mini-memory-debug.md) - [Exception Debugging](kernel/kernel-mini-memory-exception.md) - [Trace](kernel/kernel-mini-memory-trace.md) - [LMS](kernel/kernel-mini-memory-lms.md) - Appendix - [Kernel Coding Specification](kernel/kernel-mini-appx-code.md) - [Doubly Linked List](kernel/kernel-mini-appx-data-list.md) - - Standard Libraries - - [CMSIS Support](kernel/kernel-mini-appx-lib-cmsis.md) - - [POSIX Support](kernel/kernel-mini-appx-lib-posix.md) + - [Standard Libraries](kernel/kernel-mini-appx-lib.md) - Kernel for Small Systems - [Kernel Overview](kernel/kernel-small-overview.md) - Kernel Startup @@ -230,12 +308,7 @@ - [LiteIPC](kernel/kernel-small-bundles-ipc.md) - File Systems - [Virtual File System](kernel/kernel-small-bundles-fs-virtual.md) - - Supported File Systems - - [FAT](kernel/kernel-small-bundles-fs-support-fat.md) - - [JFFS2](kernel/kernel-small-bundles-fs-support-jffs2.md) - - [NFS](kernel/kernel-small-bundles-fs-support-nfs.md) - - [Ramfs](kernel/kernel-small-bundles-fs-support-ramfs.md) - - [procfs](kernel/kernel-small-bundles-fs-support-procfs.md) + - [Supported File Systems](kernel/kernel-small-bundles-fs-support.md) - [File System Adaptation](kernel/kernel-small-bundles-fs-new.md) - Debugging and Tools - Shell @@ -313,15 +386,7 @@ - [Memory Information Statistics](kernel/kernel-small-debug-memory-info.md) - [Memory Leak Check](kernel/kernel-small-debug-memory-leak.md) - [Memory Corruption Check](kernel/kernel-small-debug-memory-corrupt.md) - - User-Mode Memory Debugging - - [Basic Concepts](kernel/kernel-small-debug-user-concept.md) - - [Working Principles](kernel/kernel-small-debug-user-function.md) - - Usage - - [API Description](kernel/kernel-small-debug-user-guide-api.md) - - How to Use - - [Calling APIs](kernel/kernel-small-debug-user-guide-use-api.md) - - [Using the CLI](kernel/kernel-small-debug-user-guide-use-cli.md) - - [Typical Memory Problems](kernel/kernel-small-debug-user-faqs.md) + - [User-Mode Memory Debugging](kernel/kernel-small-debug-user.md) - Other Kernel Debugging Methods - [Dying Gasp](kernel/kernel-small-debug-trace-other-lastwords.md) - [Common Fault Locating Methods](kernel/kernel-small-debug-trace-other-faqs.md) @@ -400,6 +465,21 @@ - [Compilation and Building Guide](subsystems/subsys-build-all.md) - [Build System Coding Specifications and Best Practices](subsystems/subsys-build-gn-coding-style-and-best-practice.md) - [Building the Kconfig Visual Configuration](subsystems/subsys-build-gn-kconfig-visual-config-guide.md) + - References + - [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md#configuration-rules) + - [Product Configuration Rules](subsystems/subsys-build-product.md#configuration-rules) + - [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md#configuration-rules) + - [Component Configuration Rules](subsystems/subsys-build-component.md#configuration-rules) + - [Module Configuration Rules](subsystems/subsys-build-module.md#configuration-rules) + - [Chipset Solution Configuration Rules](subsystems/subsys-build-chip_solution.md#configuration-rules) + - [Feature Configuration Rules](subsystems/subsys-build-feature.md#configuration-rules) + - [System Capabilities Configuration Rules](subsystems/subsys-build-syscap.md#configuring-system-capabilities-for-a-component) + - [deps and external_deps](subsystems/subsys-build-reference.md#deps-and-external_deps) + - [Information Collected by the Open Source Software Notice](subsystems/subsys-build-reference.md#information-collected-by-the-open-source-software-notice) + - [Parameters for Accelerating Local Build](subsystems/subsys-build-reference.md#parameters-for-accelerating-local-build) + - [Viewing Ninja Build Information](subsystems/subsys-build-reference.md#viewing-ninja-build-information) + - [HAP Build Guide](subsystems/subsys-build-gn-hap-compilation-guide.md) + - [FAQs](subsystems/subsys-build-FAQ.md) - [Distributed Remote Startup](subsystems/subsys-remote-start.md) - Graphics - [Graphics Overview](subsystems/subsys-graphics-overview.md) @@ -464,9 +544,9 @@ - [Security Overview](subsystems/subsys-security-overview.md) - [Development on Application Signature Verification](subsystems/subsys-security-sigverify.md) - [Development on Application Permission Management](subsystems/subsys-security-rightmanagement.md) - - [Development on IPC Authentication](subsystems/subsys-security-communicationverify.md) - [Development on Device Security Level Management](subsystems/subsys-security-devicesecuritylevel.md) + - Startup - [Startup](subsystems/subsys-boot-overview.md) - init Module @@ -500,9 +580,13 @@ - Featured Topics - HPM Part - [HPM Part Overview](hpm-part/hpm-part-about.md) + - [HPM Part Development](hpm-part/hpm-part-development.md) + - [HPM Part Reference](hpm-part/hpm-part-reference.md) + - Device Development Examples + - Mini- and Small-System Devices - WLAN-connected Products - [LED Peripheral Control](guide/device-wlan-led-control.md) @@ -535,8 +619,9 @@ - [Development Guidelines on Clock Apps](guide/device-clock-guide.md) - [Development Example for Platform Drivers](guide/device-driver-demo.md) - [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) -- Debugging + +- Debugging - [Test Case Development](subsystems/subsys-testguide-test.md) - Debugging Tools - [bytrace](subsystems/subsys-toolchain-bytrace-guide.md) @@ -558,3 +643,11 @@ - [Porting](faqs/faqs-porting.md) - [Startup](faqs/faqs-startup.md) - [System Applications](faqs/faqs-system-applications.md) + + + + + + + + diff --git a/en/readme/commonlibrary.md b/en/readme/commonlibrary.md new file mode 100644 index 0000000000000000000000000000000000000000..e2c21fe797d76e4d42a5347e68077945e742057c --- /dev/null +++ b/en/readme/commonlibrary.md @@ -0,0 +1,45 @@ +# commonlibrary + + +## Introduction + +The **commonlibrary** subsystem provides common enhanced APIs for development in C, C++ and JS. + +**c_utils** + +- Enhanced APIs for operations related to files, paths, and strings +- APIs related to the read-write lock, semaphore, timer, thread, and thread pool +- APIs related to the security data container and data serialization +- Error codes for each subsystem +- Safe functions in C + +**ets_utils** + +- JSAPIs for operation of URI, URL and xml +- JSAPIs for character encoder and decoder +- JSAPIs for operation of process +- Multithreading ability in JS + +**utils_lite** + +- Hardware Abstraction Layer (HAL) APIs for performing operations on standard files +- APIs for internal functions, such as the timer + +## Directory Structure + +``` +/commonlibrary + ├── c_utils # Enhanced basic C/C++ library for developers + ├── ets_utils # Enhanced basic JS library for developers + └── utils_lite # Basic tools for liteOS, including C and JS. +``` + +## Repositories Involved + +**commonlibrary subsystem** + +[commonlibrary\_c\_utils](https://gitee.com/openharmony/commonlibrary_c_utils) + +[commonlibrary\_ets\_utils](https://gitee.com/openharmony/commonlibrary_ets_utils) + +[commonlibrary\_utils\_lite](https://gitee.com/openharmony/commonlibrary_utils_lite) diff --git a/en/readme/utils.md b/en/readme/utils.md deleted file mode 100644 index a24dc67246c8aebd6a47144a23d502b59d7ae50c..0000000000000000000000000000000000000000 --- a/en/readme/utils.md +++ /dev/null @@ -1,37 +0,0 @@ -# utils - - -## Introduction - -The **utils** repository provides common enhanced APIs for development in C and C++. - -**C++** - -- Enhanced APIs for operations related to files, paths, and strings -- APIs related to the read-write lock, semaphore, timer, thread, and thread pool -- APIs related to the security data container and data serialization -- Error codes for each subsystem -- Safe functions in C - -**C** - -- Hardware Abstraction Layer (HAL) APIs for performing operations on standard files -- APIs for internal functions, such as the timer - -## Directory Structure - -``` -/utils - ├── native # Utility class implementation at the native layer - └── system # System-related predefined values and security policy configuration -``` - -## Repositories Involved - -**utils subsystem** - -[utils](https://gitee.com/openharmony/utils) - -[utils\_native](https://gitee.com/openharmony/utils_native) - -[utils\_native\_lite](https://gitee.com/openharmony/utils_native_lite) diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md index 92559d71cffbe3310e7736925a1dc5c88176bf07..bfe55e352658e49ec59d6c49903ee995c4cb50da 100644 --- a/zh-cn/application-dev/device/usb-guidelines.md +++ b/zh-cn/application-dev/device/usb-guidelines.md @@ -40,7 +40,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 1. 获取设备列表。 ```js - // 导入usb接口api包。 + // 导入USB接口api包。 import usb from '@ohos.usb'; // 获取设备列表。 var deviceList = usb.getDevices(); diff --git a/zh-cn/application-dev/media/Readme-CN.md b/zh-cn/application-dev/media/Readme-CN.md index d0793ffdd3396a75f81a3af585dd59d865078e3f..def905fc036cbbe5a3ac5ced05e4464b1768220d 100755 --- a/zh-cn/application-dev/media/Readme-CN.md +++ b/zh-cn/application-dev/media/Readme-CN.md @@ -19,4 +19,5 @@ - [图片开发指导](image.md) - 相机 - - [相机开发指导](camera.md) \ No newline at end of file + - [相机开发指导](camera.md) + - [分布式相机开发指导](remote-camera.md) \ No newline at end of file diff --git a/zh-cn/application-dev/napi/native-window-guidelines.md b/zh-cn/application-dev/napi/native-window-guidelines.md index 69299f3979c8c03c674157563aa93a7d0949524c..3a9d8c136d7005f3df5d4c0c6749e749d3877b2d 100644 --- a/zh-cn/application-dev/napi/native-window-guidelines.md +++ b/zh-cn/application-dev/napi/native-window-guidelines.md @@ -86,7 +86,7 @@ NativeWindow是`OpenHarmony`**本地平台化窗口**,包括从`Surface`构建 SkImageInfo imageInfo = ... bitmap.setInfo(imageInfo, bufferHandle->stride); bitmap.setPixels(bufferHandle->virAddr); - //创建 Skia Canvas 并将内容写入naitve window + //创建 Skia Canvas 并将内容写入native window ... //写入完成后,通过OH_NativeWindow_NativeWindowFlushBuffer 提交给消费者使用,例如:显示在屏幕上 @@ -101,7 +101,13 @@ NativeWindow是`OpenHarmony`**本地平台化窗口**,包括从`Surface`构建 OH_NativeXComponent_Callback &callback_; callback_->OnSurfaceCreated = OnSurfaceCreatedCB; callback_->OnSurfaceChanged = OnSurfaceChangedCB; - callback_->OnSurfaceDestoryed = OnSurfaceDestoryedCB; + callback_->OnSurfaceDestroyed = OnSurfaceDestroyedCB; callback_->DispatchTouchEvent = DispatchTouchEventCB; OH_NativeXComponent_RegisterCallback(nativeXComponent, callback_) ``` + +## 相关实例 + +针对NativeWindow的使用,有以下相关实例可供参考: + +- [使用NativeWindow接口获取Buffer](https://gitee.com/openharmony/graphic_graphic_2d/blob/master/rosen/samples/hello_native_window/hello_native_window.cpp) diff --git a/zh-cn/application-dev/quick-start/start-with-ets-fa.md b/zh-cn/application-dev/quick-start/start-with-ets-fa.md index cedecd088917475c8f1ecffb3dcc242be303c446..d76098deee7a4663cc1e83415b44fa760986e984 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-fa.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-fa.md @@ -13,7 +13,7 @@ ![01](figures/01.png) -2. 进入配置工程界面,**Compile SDK** 选择“**8**”(**Complie SDK**选择“**9**”时注意同步选择**Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**eTS**”,其他参数保持默认设置即可。 +2. 进入配置工程界面,**Compile SDK** 选择“**8**”(**Compile SDK**选择“**9**”时注意同步选择**Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**eTS**”,其他参数保持默认设置即可。 ![02](figures/02.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 6a34e376e912fbc0aaab8b403b99d786124196b8..e0f641910c490f7d2fbba95a399b4baf7a1fb002 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 @@ -11,7 +11,7 @@ ![01](figures/01.png) -2. 进入配置工程界面,**Compile SDK**选择“**8**”(**Complie SDK**选择“**9**”时注意同步选择 **Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**JS**”,其他参数保持默认设置即可。 +2. 进入配置工程界面,**Compile SDK**选择“**8**”(**Compile SDK**选择“**9**”时注意同步选择 **Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**JS**”,其他参数保持默认设置即可。 ![04](figures/04.png) diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index 112186af0920e6588a9bb9c7b5842f079993aaee..c6d58000ae2a06728fe8fcc463cc3bb558211d04 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -141,7 +141,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { ## bundle.getApplicationInfoSync9+ -getApplicationInfoSync(bundleName: string, bundleFlags: string, userId: number): ApplicationInfo; +getApplicationInfoSync(bundleName: string, bundleFlags: number, userId: number): ApplicationInfo; 以同步方法根据给定的包名获取ApplicationInfo,返回ApplicationInfo对象。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index d5549075d11ae8e723c1c462a2f55c8aa564c9f2..6f0790203a2dce9f574a00e62a91fa3d3c5ee270 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -282,6 +282,32 @@ promise.then(data => { }); ``` +### getVersion + +getVersion(): Promise<number> + +获取当前权限管理的数据版本,使用Promise方式异步返回结果。 + +此接口为系统接口。 + +**系统能力:** SystemCapability.Security.AccessToken + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回的版本号。 | + +**示例:** + +```js +var AtManager = abilityAccessCtrl.createAtManager(); +let promise = AtManager.getVersion(); +promise.then(data => { + console.log(`promise: data->${JSON.stringify(data)}`); +}); +``` + ### on9+ on(type: 'permissionStateChange', tokenIDList: Array<number>, permissionNameList: Array<string>, callback: Callback<PermissionStateChangeInfo>): void; @@ -381,7 +407,7 @@ catch(err){ | 名称 | 默认值 | 描述 | | ----------------------- | ------ | ----------------- | | PERMISSION_REVOKED_OPER | 0 | 表示权限取消操作。 | -| PERMISSION_GRANTED | 1 | 表示权限授予操作。 | +| PERMISSION_GRANTED_OPER | 1 | 表示权限授予操作。 | ### PermissionStateChangeInfo9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index c5c94802eb7ed7fb28a26c3c0f7ccfb9e3e457ac..2ecce44700157d0dd9c3b5f7aabd2eebfb42836b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -816,7 +816,7 @@ getAssociatedDataSync(name: string, key: string): string; | 类型 | 说明 | | :-------------------- | :-------------------- | -| string | 用于获取同步接口的返回结果。 | +| string | 目标关联数据的取值。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md index 8b57cc39c399c18415c4488bb37ec579aabe8021..3e283d2b9bee62f9c7145d02c13d5b85ecd93a9e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @@ -26,7 +26,7 @@ onReceiveEvent(event: CommonEventData): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | event | CommonEventData | 是 | 静态订阅者通用事件回调。 | + | event | [CommonEventData](js-apis-commonEvent.md#commoneventdata) | 是 | 静态订阅者通用事件回调。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md index 0bb9cf1c93ee5f3058366761ae0e2dd576b656f6..01c486e90e52e531bb75c8301f0df1bbbf6a47a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md @@ -224,7 +224,7 @@ getProcessRunningInformation(): Promise\>; | 类型 | 说明 | | -------- | -------- | -| Promise\> | 获取有关运行进程的信息。 | +| Promise\> | 获取有关运行进程的信息。 | **示例:** @@ -250,7 +250,7 @@ getProcessRunningInformation(callback: AsyncCallback\> | 否 | 获取有关运行进程的信息。 | +| callback | AsyncCallback\> | 否 | 获取有关运行进程的信息。 | **示例:** @@ -863,3 +863,16 @@ onProcessDied(processData: ProcessData): void; | [onAbilityStateChanged8+](#applicationstateobserveronabilitystatechanged8) | AsyncCallback\ | 是 | 否 | ability状态发生变化时执行的回调函数。 | | [onProcessCreated8+](#applicationstateobserveronprocesscreated8) | AsyncCallback\ | 是 | 否 | 进程创建时执行的回调函数。 | | [onProcessDied8+](#applicationstateobserveronprocessdied8) | AsyncCallback\ | 是 | 否 | 进程销毁时执行的回调函数。 | + +## ProcessRunningInformation + +进程的运行信息。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| pid9+ | 只读 | number | 否 | 进程ID。 | +| uid9+ | 只读 | number | 否 | 用户ID。 | +| processName9+ | 只读 | string | 否 | 进程的名称。 | +| bundleNames9+ | 只读 | Array\ | 否 | 进程中运行的bundleName数组。 | \ No newline at end of file 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 6b7fa6f55aaf5dcfec12e7f105cd9d82eefe3187..ee86ba501410a0de641839d578725ad8d8e3f4db 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -54,60 +54,6 @@ getAudioManager(): AudioManager var audioManager = audio.getAudioManager(); ``` -## audio.getStreamManager9+ - -getStreamManager(callback: AsyncCallback\): void - -获取音频流管理器实例。使用callback方式异步返回结果。 - -**系统能力:** SystemCapability.Multimedia.Audio.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------------- | ---- | ---------------- | -| callback | AsyncCallback<[AudioStreamManager](#audiostreammanager9)> | 是 | 返回音频流管理器实例。 | - -**示例:** - -```js -audio.getStreamManager((err, data) => { - if (err) { - console.error(`getStreamManager : Error: ${err}`); - } else { - console.info('getStreamManager : Success : SUCCESS'); - let audioStreamManager = data; - } -}); -``` - -## 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}`); -}); - -``` - ## audio.createAudioRenderer8+ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\): void @@ -667,6 +613,8 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { 枚举,设备连接类型。 +**系统接口:** 该接口为系统接口 + **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device | 名称 | 默认值 | 描述 | @@ -1950,6 +1898,7 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback\): void **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { if (err) { console.error(`Failed to set the audio scene mode.​ ${err}`); @@ -1984,6 +1933,7 @@ setAudioScene\(scene: AudioScene\): Promise **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { console.info('Promise returned to indicate a successful setting of the audio scene mode.'); }).catch ((err) => { @@ -2008,6 +1958,7 @@ getAudioScene\(callback: AsyncCallback\): void **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.getAudioScene((err, value) => { if (err) { console.error(`Failed to obtain the audio scene mode.​ ${err}`); @@ -2035,6 +1986,7 @@ getAudioScene\(\): Promise **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.getAudioScene().then((value) => { console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`); }).catch ((err) => { @@ -2061,6 +2013,7 @@ getVolumeGroups(networkId: string, callback: AsyncCallback\): **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID, (err, value) => { if (err) { console.error(`Failed to obtain the volume group infos list. ${err}`); @@ -2121,6 +2074,7 @@ getGroupManager(groupId: number, callback: AsyncCallback\): **示例:** ```js +var audioManager = audio.getAudioManager(); async function getGroupManager(){ let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); if (value.length > 0) { @@ -2150,7 +2104,7 @@ getGroupManager(groupId: number\): Promise **参数:** | 参数名 | 类型 | 必填 | 说明 | -| ---------- | ---------------------------------------- | ---- | -------------- -- | +| ---------- | ---------------------------------------- | ---- | ---------------- | | networkId | string | 是 | 设备的网络id。 | **返回值:** @@ -2162,6 +2116,7 @@ getGroupManager(groupId: number\): Promise **示例:** ```js +var audioManager = audio.getAudioManager(); async function getGroupManager(){ let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); if (value.length > 0) { @@ -2171,6 +2126,63 @@ async function getGroupManager(){ } } ``` + +### getStreamManager9+ + +getStreamManager(callback: AsyncCallback\): void + +获取音频流管理器实例。使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ---------------- | +| callback | AsyncCallback<[AudioStreamManager](#audiostreammanager9)> | 是 | 返回音频流管理器实例。 | + +**示例:** + +```js +var audioManager = audio.getAudioManager(); +audioManager.getStreamManager((err, data) => { + if (err) { + console.error(`getStreamManager : Error: ${err}`); + } else { + console.info('getStreamManager : Success : SUCCESS'); + let audioStreamManager = data; + } +}); +``` + +### getStreamManager9+ + +getStreamManager(): Promise + +获取音频流管理器实例。使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------------- | ---------------- | +| Promise<[AudioStreamManager](#audiostreammanager9)> | 返回音频流管理器实例。 | + +**示例:** + +```js +var audioManager = audio.getAudioManager(); +var audioStreamManager; +audioManager.getStreamManager().then((data) => { + audioStreamManager = data; + console.info('getStreamManager: Success!'); +}).catch((err) => { + console.error(`getStreamManager: ERROR : ${err}`); +}); + +``` + ### requestIndependentInterrupt9+ requestIndependentInterrupt(focusType: FocusType, callback: AsyncCallback\): void @@ -2202,7 +2214,7 @@ async function requestIndependentInterrupt(){ ``` ### requestIndependentInterrupt9+ -requestIndependentInterrupt(focusType: FocusType: Promise +requestIndependentInterrupt(focusType: FocusType): Promise 申请独立焦点,获取独立SessionID,使用promise方式异步返回结果。 @@ -2264,7 +2276,7 @@ async function abandonIndependentInterrupt(){ ``` ### abandonIndependentInterrupt9+ -abandonIndependentInterrupt(focusType: FocusType]: Promise +abandonIndependentInterrupt(focusType: FocusType): Promise 废除独立焦点,使用promise方式异步返回结果。 @@ -2312,6 +2324,8 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l 仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2344,6 +2358,8 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> 仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2373,6 +2389,8 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): v 获取指定流的音量,使用callback方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2400,6 +2418,8 @@ getVolume(volumeType: AudioVolumeType): Promise<number> 获取指定流的音量,使用Promise方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2428,6 +2448,8 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>) 获取指定流的最小音量,使用callback方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2455,6 +2477,8 @@ getMinVolume(volumeType: AudioVolumeType): Promise<number> 获取指定流的最小音量,使用Promise方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2483,6 +2507,8 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>) 获取指定流的最大音量,使用callback方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2510,6 +2536,8 @@ getMaxVolume(volumeType: AudioVolumeType): Promise<number> 获取指定流的最大音量,使用Promise方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2542,6 +2570,8 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void 仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2574,6 +2604,8 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> 仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2603,6 +2635,8 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): voi 获取指定音量流是否被静音,使用callback方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2630,6 +2664,8 @@ isMute(volumeType: AudioVolumeType): Promise<boolean> 获取指定音量流是否被静音,使用Promise方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** @@ -2654,7 +2690,7 @@ audioGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { ## AudioStreamManager9+ -管理音频流。在使用AudioStreamManager的API前,需要使用[getStreamManager](#audiogetstreammanager9)获取AudioStreamManager实例。 +管理音频流。在使用AudioStreamManager的API前,需要使用[getStreamManager](#getstreammanager9)获取AudioStreamManager实例。 ### getCurrentAudioRendererInfoArray9+ @@ -3528,13 +3564,11 @@ promise.then(function (value) { **系统接口:** 该接口为系统接口 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device - | 名称 | 类型 | 必填 | 说明 | | -------------| ---------------------------------------- | ---- | -------------- | -| uid | number | 是 | 表示应用ID。
系统能力:SystemCapability.Multimedia.Audio.Core| -| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 否 | 表示渲染器信息。
系统能力:SystemCapability.Multimedia.Audio.Renderer| -| rendererId | number | 否 | 音频流唯一id。
系统能力:SystemCapability.Multimedia.Audio.Renderer| +| uid | number | 是 | 表示应用ID。
**系统能力:** SystemCapability.Multimedia.Audio.Core| +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 否 | 表示渲染器信息。
**系统能力:** SystemCapability.Multimedia.Audio.Renderer| +| rendererId | number | 否 | 音频流唯一id。
**系统能力:** SystemCapability.Multimedia.Audio.Renderer| **示例:** @@ -4441,7 +4475,7 @@ audioRenderer.on('interrupt', async(interruptEvent) => { ### on('markReach')8+ -on(type: "markReach", frame: number, callback: Callback): void +on(type: "markReach", frame: number, callback: Callback<number>): void 订阅到达标记的事件。 当渲染的帧数达到 frame 参数的值时,回调被调用。 @@ -4488,7 +4522,7 @@ audioRenderer.off('markReach'); ### on('periodReach') 8+ -on(type: "periodReach", frame: number, callback: Callback): void +on(type: "periodReach", frame: number, callback: Callback<number>): void 订阅到达标记的事件。 当渲染的帧数达到 frame 参数的值时,回调被循环调用。 @@ -5067,7 +5101,7 @@ audioCapturer.getBufferSize().then((data) => { ### on('markReach')8+ -on(type: "markReach", frame: number, callback: Callback): void +on(type: "markReach", frame: number, callback: Callback<number>): void 订阅标记到达的事件。 当采集的帧数达到 frame 参数的值时,回调被触发。 @@ -5113,7 +5147,7 @@ audioCapturer.off('markReach'); ### on('periodReach')8+ -on(type: "periodReach", frame: number, callback: Callback): void +on(type: "periodReach", frame: number, callback: Callback<number>): void 订阅到达标记的事件。 当采集的帧数达到 frame 参数的值时,回调被循环调用。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md index c2ca416a6b9ee5a46f61672259d39951481abce6..6ce763330ed951f2aa3426c20048b9d74c826f7b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md @@ -13,6 +13,8 @@ LauncherAbilityInfo信息 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + **系统API:**此接口为系统接口,三方应用不支持调用 + | 名称 | 类型 | 可读 | 可写 | 说明 | | --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ | | applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | 否 | launcher ability的应用程序的配置信息 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index 4ae60bc17461f9648e366a93d5a918355a0558c6..c5bfbb5b4e0447b82999ce68f678d7c5c3d81d2e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -4513,7 +4513,7 @@ on(type: 'metadataObjectsAvailable', callback: AsyncCallback\> | 是 | 回调函数,用于获取错误信息。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md index 1be6efe3627e889d22dc4455b8368e9c150d1a10..12ebef741d683e4d2a34c5abe815f6bead169326 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -825,7 +825,7 @@ on(type: 'change', callback: Callback<{ key : string }>): void ```js data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { if (err) { - console.info("Failed to Gget preferences."); + console.info("Failed to get preferences."); return; } var observer = function (key) { @@ -871,7 +871,7 @@ off(type: 'change', callback?: Callback<{ key : string }>): void ```js data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { if (err) { - console.info("Failed to Gget preferences."); + console.info("Failed to get preferences."); return; } var observer = function (key) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md index b2dd0b7655f7cd5cb62c8f763a68dee0b7556d8d..2110b8065f4602a382bb1e1b339c9f968377239c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md @@ -57,7 +57,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); let storage = data_storage.getStorageSync(path + '/mystore'); storage.putSync('startup', 'auto'); @@ -90,7 +90,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); data_storage.getStorage(path + '/mystore', function (err, storage) { if (err) { @@ -133,7 +133,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); let getPromise = data_storage.getStorage(path + '/mystore'); getPromise.then((storage) => { @@ -169,7 +169,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); data_storage.deleteStorageSync(path + '/mystore'); }); @@ -199,7 +199,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); data_storage.deleteStorage(path + '/mystore', function (err) { if (err) { @@ -241,7 +241,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); let promisedelSt = data_storage.deleteStorage(path + '/mystore'); promisedelSt.then(() => { @@ -275,7 +275,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); data_storage.removeStorageFromCacheSync(path + '/mystore'); }); @@ -306,7 +306,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); data_storage.removeStorageFromCache(path + '/mystore', function (err) { if (err) { @@ -348,7 +348,7 @@ var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; - console.info("======================>getFilesDirPromsie====================>"); + console.info("======================>getFilesDirPromise====================>"); let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore') promiserevSt.then(() => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md b/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md index 2ea328f8452288a0bf4461c6704217f5323cb971..11ebc8aa8438efc8ec5681dbf6db58c221222267 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md @@ -13,8 +13,10 @@ **系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework +**系统API:**此接口为系统接口,三方应用不支持调用 + | 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | ------ | ---- | ---- | ------------------------ | -| verison | string | 是 | 否 | 包含dispatchInfo版本信息 | +| version | string | 是 | 否 | 包含dispatchInfo版本信息 | | dispatchAPI | string | 是 | 否 | 包含免安装接口版本号 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index d0c2b246541d3416a2aab075ee9bdf92e84592fb..bd76a602e2883da461243ea439e654acf7611a5a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -314,21 +314,21 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa let kvStore; let kvManager; const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, - } - try { + createIfMissing: true, + encrypt: false, + backup: false, + autoSync: true, + kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, + schema: '', + securityLevel: distributedData.SecurityLevel.S2, +} +try { kvManager.getKVStore('storeId', options, async function (err, store) { - console.log('getKVStore success'); - kvStore = store; - kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { - console.log('closeKVStore success'); - }); + console.log('getKVStore success'); + kvStore = store; + kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { + console.log('closeKVStore success'); + }); }); } catch (e) { console.log('closeKVStore e ' + e); @@ -364,29 +364,29 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void& let kvManager; let kvStore; const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, + createIfMissing: true, + encrypt: false, + backup: false, + autoSync: true, + kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, + schema: '', + securityLevel: distributedData.SecurityLevel.S2, } - try { +try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('getKVStore success'); - kvStore = store; - kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { - console.log('closeKVStore success'); - }).catch((err) => { - console.log('closeKVStore err ' + JSON.stringify(err)); - }); + console.log('getKVStore success'); + kvStore = store; + kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { + console.log('closeKVStore success'); + }).catch((err) => { + console.log('closeKVStore err ' + JSON.stringify(err)); + }); }).catch((err) => { console.log('CloseKVStore getKVStore err ' + JSON.stringify(err)); }); - } catch (e) { +} catch (e) { console.log('closeKVStore e ' + e); -} +} ``` @@ -576,7 +576,6 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi ```js let kvManager; try { - console.log('KVManagerOn'); const deathCallback = function () { console.log('death callback call'); diff --git a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md index cfa707255ee96189c9e872c52167da6691c7048d..0c6f2e1c6d0936f4171997219269628d80faa390 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md +++ b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md @@ -67,7 +67,7 @@ createColorPicker(source: image.PixelMap): Promise\ | 类型 | 说明 | | ---------------------- | -------------- | -| Promisse\<[ColorPicker](#colorpicker)> | Promise对象。返回创建的ColorPicker实例。 | +| Promise\<[ColorPicker](#colorpicker)> | Promise对象。返回创建的ColorPicker实例。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index e6b88c2c1675cd31cf05d76c2318628a6c433d29..087c112c3b0d96534528dd385d88bfd5a0517f5a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -405,7 +405,7 @@ resolvedOptions(): NumberOptions | currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol", "narrowSymbol", "code", "name"。 | | unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。 | | unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long", "short", "narrow"。 | -| unitUsage8+ | string | 是 | 是 | 单位的使用场景,取值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。 | +| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。 | | signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto", "never", "always", "expectZero"。 | | compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long", "short"。 | | notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard", "scientific", "engineering", "compact"。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-keycode.md b/zh-cn/application-dev/reference/apis/js-apis-keycode.md index ae30bf1186b06d7a034f219c5407f30becbcc01c..26f56165a23e232b68ac20f7d867a053a2631032 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keycode.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keycode.md @@ -96,7 +96,7 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode' | KEYCODE_EQUALS | number | 是 | 否 | 按键'=' | | KEYCODE_LEFT_BRACKET | number | 是 | 否 | 按键'[' | | KEYCODE_RIGHT_BRACKET | number | 是 | 否 | 按键']' | -| KEYCODE_BACKSLASH | number | 是 | 否 | 按键'\' | +| KEYCODE_BACKSLASH | number | 是 | 否 | 按键'\\' | | KEYCODE_SEMICOLON | number | 是 | 否 | 按键';' | | KEYCODE_APOSTROPHE | number | 是 | 否 | 按键''' (单引号) | | KEYCODE_SLASH | number | 是 | 否 | 按键'/' | @@ -346,4 +346,4 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode' | KEYCODE_BTN_6 | number | 是 | 否 | 按键6 | | KEYCODE_BTN_7 | number | 是 | 否 | 按键7 | | KEYCODE_BTN_8 | number | 是 | 否 | 按键8 | -| KEYCODE_BTN_9 | number | 是 | 否 | 按键9 | \ No newline at end of file +| KEYCODE_BTN_9 | number | 是 | 否 | 按键9 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen.md b/zh-cn/application-dev/reference/apis/js-apis-screen.md index 42475c74b7761fd32f73468efa545a209f15d63d..83ddfec6366a0e755b97eff377b99b62ebdd3276 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen.md @@ -112,7 +112,7 @@ off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback<numbe ```js var callback = (data) => { - console.info('Unegister the callback for screen changes. Data: ' + JSON.stringify(data)) + console.info('Unregister the callback for screen changes. Data: ' + JSON.stringify(data)) }; screen.off("connect", callback); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-settings.md b/zh-cn/application-dev/reference/apis/js-apis-settings.md index 276e4c39eb119c5d5257dc47c54057ee1bd39f13..d9dec4275b860bf3be3c81d6eb3fc29131ead9d9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-settings.md +++ b/zh-cn/application-dev/reference/apis/js-apis-settings.md @@ -303,6 +303,8 @@ setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, call 将数据项名称及数据项的值保存到数据库中。使用callback异步回调。 +**系统接口**:此接口为系统接口。 + **系统能力**:SystemCapability.Applications.settings.Core **参数**: @@ -333,6 +335,8 @@ setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Pro 将数据项名称及数据项的值保存到数据库中。使用Promise异步回调。 +**系统接口**:此接口为系统接口。 + **系统能力**:SystemCapability.Applications.settings.Core **参数**: @@ -392,7 +396,7 @@ enableAirplaneMode(enable: boolean, callback: AsyncCallback\): void ## settings.enableAirplaneMode -enableAirplaneMode(enable: boolean): Promise +enableAirplaneMode(enable: boolean): Promise\ 启用或禁用飞行模式。使用Promise异步回调。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index bad28cb7c96a05ef778a599da3972a19f4fbca5b..b5a91f3821e9dbf7913fc57368783f3424eda9d3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -92,7 +92,7 @@ getCurrentTime(isNano: boolean, callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| +| isNano | boolean | 是 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | **示例:** @@ -120,7 +120,6 @@ getCurrentTime(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | **示例:** @@ -148,7 +147,7 @@ getCurrentTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| +| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| **返回值:** @@ -179,7 +178,7 @@ getRealActiveTime(isNano: boolean, callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| +| isNano | boolean | 是 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来经过的时间,但不包括度睡眠时间。 | **示例:** @@ -207,7 +206,6 @@ getRealActiveTime(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来经过的时间,但不包括度睡眠时间。 | **示例:** @@ -235,7 +233,7 @@ getRealActiveTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| +| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| **返回值:** @@ -266,7 +264,7 @@ getRealTime(isNano: boolean, callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| +| isNano | boolean | 是 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来经过的时间,包括深度睡眠时间。 | **示例:** @@ -294,7 +292,6 @@ getRealTime(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来经过的时间,包括深度睡眠时间。 | **示例:** @@ -321,7 +318,7 @@ getRealTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| +| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。
- false:毫秒数。
| **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index e5474faec26b7596b2da697400e955f5deab9978..37f051e57ddd82ed09243a92ad4c38f8eaa12a61 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -3118,7 +3118,7 @@ let promise = windowClass.setForbidSplitMove(isForbidSplitMove); promise.then((data)=> { console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to forbidd window moving in split screen mode. Cause: ' + JSON.stringify(err)); + console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-xml.md b/zh-cn/application-dev/reference/apis/js-apis-xml.md index f33be6b32f53aa437164b8684ece4eef5861eed8..7d573cf82dd1203054dc4aaec9465ebfd003971f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-xml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-xml.md @@ -301,7 +301,7 @@ var strXml = ' Work' + ' Play' + ''; -var arrayBuffer = new ArrayBuffer(strXml.length*2); +var arrayBuffer = new ArrayBuffer(strXml.length); var bufView = new Uint8Array(arrayBuffer); var strLen = strXml.length; for (var i = 0; i < strLen; ++i) { @@ -335,7 +335,7 @@ var strXml = ' Work' + ' Play' + ''; -var arrayBuffer = new ArrayBuffer(strXml.length*2); +var arrayBuffer = new ArrayBuffer(strXml.length); var bufView = new Uint8Array(arrayBuffer); var strLen = strXml.length; for (var i = 0; i < strLen; ++i) { @@ -358,7 +358,7 @@ console.log(str); // key:0 value:0key:2 value:1key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:3 value:1key:1 value:0 // 解析: // key代表了当前事件类型,value为当前解析的深度。你可以根据EVENTTYPE来知道具体的解析事件。例如本示例结果key: value代表含义为: -// 0(START_DOCUMENT):0(起始深度为0), 2(START_TAG):1(解析到开始标签node, 对应深度为1), 10(WHITESPACE):1(解析到空白标签空格, 对应深度为1), 2(START_TAG):2(解析到开始标签title, 对应深度为1), ... +// 0(START_DOCUMENT):0(起始深度为0), 2(START_TAG):1(解析到开始标签node, 对应深度为1), 10(WHITESPACE):1(解析到空白标签空格, 对应深度为1), 2(START_TAG):2(解析到开始标签title, 对应深度为2), ... ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md index 7e3eba49fba43c4b99ceabfa66149ee776f6d6b3..de1a2c1f4141b09c543e04463f29d17f835243c6 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md @@ -10,24 +10,24 @@ 在非折行flex布局基础上,增加了显示优先级标记,可以调整组件内元素水平/垂直方向的显示优先级,根据当前组件容器的可用空间来显示内容。 -| 样式 | 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -------- | -| display-index | number | 0 | 适用于div等支持flex布局的容器组件中的子组件上,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏,默认值为0,表示隐藏。 | +| 样式 | 类型 | 说明 | +| -------- | -------- | -------- | +| display-index | number | 适用于div等支持flex布局的容器组件中的子组件,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏。
默认值:0(表示不隐藏) | ## 占比能力 -在非折行的flex布局中,定义了占比能力的组件,保证指定元素始终在容器的某一个比例空间中进行布局。 +在非折行的flex布局中,定义了占比能力的组件,保证指定组件始终在容器的某一个比例空间中进行布局。 -| 样式 | 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -------- | -| flex-weight | number | - | 指明当前元素在flex主轴方向上尺寸权值。如果容器组件中所有节点均设置此属性,当前元素尺寸为: 容器主轴尺寸 \* 当前权值 / 所有子元素权值和。如果容器组件中某几个节点设置此属性,则容器会对其他未设置此属性的节点进行布局,再将剩余空间分配给设置了此属性的节点。设置了此属性的节点的尺寸为:容器剩余空间 \* 该元素权值 / 所有子元素权值和。 | +| 样式 | 类型 | 说明 | +| -------- | -------- | -------- | +| flex-weight | number | 指明当前元素在flex主轴方向上尺寸权值。如果容器组件中所有节点均设置此属性,当前元素尺寸为: 容器主轴尺寸 \* 当前权值 / 所有子元素权值和。如果容器组件中某几个节点设置此属性,则容器会对其他未设置此属性的节点进行布局,再将剩余空间分配给设置了此属性的节点,如果未设置此属性的节点设置了超过父元素的宽度,那么将没有剩余空间分配给设置了此属性的节点。设置了此属性的节点的尺寸为:容器剩余空间 \* 该元素权值 / 所有子元素权值和。 | ## 固定比例 定义了组件固定比例调整尺寸的能力。 -| 样式 | 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -------- | -| aspect-ratio | number | - | 1. 接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。
2. 遵守最大值与最小值的限制。
3. 在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。 | +| 样式 | 类型 | 说明 | +| -------- | -------- | -------- | +| aspect-ratio | number | 1. 接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。
2. 遵守最大值与最小值的限制。
3. 在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。 | diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md index 93cb8d57eed7de341c47faa301c310f85b0c149e..1cfc116e21b7ebb1d68c37383abd0963ce0b361b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md @@ -20,9 +20,9 @@ 除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| label | Label | - | 否 | 自定义步骤导航器底部步骤提示文本按钮属性,不支持动态修改。如果没有定义该属性,步骤导航器在中文语言环境下,使用“返回”和“下一步”文本按钮,在非中文语言环境下,使用“BACK”和“NEXT”文本按钮。针对第一个步骤,没有回退文本按钮,针对最后一个步骤,下一步文本按钮文本使用“开始”(中文语言)或者“START”(非中文语言)。 | +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| label | Label |   否   | 自定义步骤导航器底部步骤提示文本按钮属性,不支持动态修改。如果没有定义该属性,步骤导航器在中文语言环境下,使用"返回"和"下一步"文本按钮,在非中文语言环境下,使用"BACK"和"NEXT"文本按钮。针对第一个步骤,没有"返回"文本按钮;针对最后一个步骤,"下一步"文本按钮文本使用"开始"(中文语言)或者"START"(非中文语言)。 | **表1** Label对象定义 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md index 0bde9e1f25bd4445a74c897d3a8bab1cf7f790da..1d80f62b21b550d043a24153720a5e9da190dc4d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md @@ -19,9 +19,9 @@ 除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| scrollable | boolean | true | 否 | 是否可以通过左右滑动进行页面切换。默认为true,设置为false后,页面的切换只能通过tab-bar的点击实现。 | +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| scrollable | boolean |   否   | 是否可以通过左右滑动进行页面切换。默认为true,设置为false后,页面的切换只能通过tab-bar的点击实现。 | ## 样式 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md index cf6779fb5069197f1913c192007e776a2070334d..6cdf54b6260fe21788ffe19365122d48da5a9b74 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md @@ -26,19 +26,19 @@ 支持以下表格中的属性。 -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------------- | ---------------------------------- | ----- | ---- | ---------------------------------------- | -| id | string | - | 否 | 组件的唯一标识。 | -| path | string | 0 | 是 | 设置路径的形状。
字母指令表示的意义如下:
- M = moveto
- L = lineto
- H = horizontal lineto
- V = vertical lineto
- C = curveto
- S = smooth curveto
- Q = quadratic Belzier curve
- T = smooth quadratic Belzier curveto
- A = elliptical Arc
- Z = closepath | -| startOffset | <length>\|<percentage> | 0 | 否 | 设置文本沿path绘制的起始偏移。 | -| font-size | <length> | 30px | 否 | 设置文本的尺寸。 | -| fill | <color> | black | 否 | 字体填充颜色 | -| by | number | - | 否 | 相对被指定动画的属性偏移值,from默认为原属性值。 | -| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。 | -| fill-opacity | number | 1.0 | 否 | 字体填充透明度 | -| stroke | <color> | black | 否 | 绘制字体边框并指定颜色 | -| stroke-width | number | 1px | 否 | 字体边框宽度 | -| stroke-opacity | number | 1.0 | 否 | 字体边框透明度 | +| 名称 | 类型 | 默认值 | 描述 | +| -------------- | ---------------------------------- | ------ | ------------------------------------------------------------ | +| id | string | - | 组件的唯一标识。 | +| path | string | 0 | 设置路径的形状。
字母指令表示的意义如下:
- M = moveto
- L = lineto
- H = horizontal lineto
- V = vertical lineto
- C = curveto
- S = smooth curveto
- Q = quadratic Belzier curve
- T = smooth quadratic Belzier curveto
- A = elliptical Arc
- Z = closepath
默认值:0 | +| startOffset | <length>\|<percentage> | 0 | 设置文本沿path绘制的起始偏移。
默认值:0 | +| font-size | <length> | 30px | 设置文本的尺寸。
默认值:30px | +| fill | <color> | black | 字体填充颜色。
默认值:black | +| by | number | - | 相对被指定动画的属性偏移值,from默认为原属性值。 | +| opacity | number | 1 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。
默认值:0 | +| fill-opacity | number | 1.0 | 字体填充透明度。
默认值:1.0 | +| stroke | <color> | black | 绘制字体边框并指定颜色。
默认值:balck | +| stroke-width | number | 1px | 字体边框宽度。
默认值:1px | +| stroke-opacity | number | 1.0 | 字体边框透明度。
默认值:1.0 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/image-effect.png b/zh-cn/application-dev/reference/arkui-ts/figures/image-effect.png new file mode 100644 index 0000000000000000000000000000000000000000..fc2c9b7d49f7d698aac11d2ede6b0cc58222c7ca Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/image-effect.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.jpg b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.jpg index e3d3e1023746c03c9ad426328de0114321ac3f66..51c86ceb26151f6aeb719ad5db5ee5c88218361b 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.jpg and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.jpg differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md index ea1c55e0a4878d7f963a93c9ed486807639c5ab9..5248b2902f2888429f4510a141a3ba8b2eb22846 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -1,6 +1,6 @@ # Progress -进度条,用于显示内容加载或操作处理进度。 +进度条组件,用于显示内容加载或操作处理等进度。 > **说明:** > @@ -24,27 +24,36 @@ Progress(options: {value: number, total?: number, type?: ProgressType}) | -------- | -------- | -------- | -------- | | value | number | 是 | 指定当前进度值。 | | total | number | 否 | 指定进度总长。
默认值:100 | -| type | ProgressType | 否 | 指定进度条样式。
默认值:ProgressType.Linear | +| type8+ | ProgressType | 否 | 指定进度条样式。
默认值:ProgressType.Linear | +| styledeprecated | ProgressStyle | 否 | 指定进度条类型。
该参数从API Version8开始废弃,建议使用type替代。
默认值:ProgressStyle.Linear | ## ProgressType枚举说明 | 名称 | 描述 | | -------- | -------- | -| Linear8+ | 线性样式。 | -| Ring8+ | 环形无刻度样式,环形圆环逐渐填充完成过程。 | -| Eclipse8+ | 圆形样式,展现类似月圆月缺的进度展示效果,从月牙逐渐到满月的这个过程代表了下载的进度。 | -| ScaleRing8+ | 环形有刻度样式,类似时钟刻度形式加载进度。 | -| Capsule8+ | 胶囊样式,头尾两端处,进度条由弧形变成直线和直线变成弧形的过程;中段处,进度条正常往右走的过程。 | +| Linear | 线性样式。 | +| Ring8+ | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。 | +| Eclipse8+ | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 | +| ScaleRing8+ | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。 | +| Capsule8+ | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 | + +## ProgressStyle枚举说明 + +| 名称 | 描述 | +| --------- | ------------------------------------------------------------ | +| Linear | 线性样式。 | +| Ring | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。 | +| Eclipse | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 | +| ScaleRing | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。 | +| Capsule | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 | ## 属性 -除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: - | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | value | number | 设置当前进度值。 | | color | [ResourceColor](../../ui/ts-types.md) | 设置进度条前景色。 | -| style8+ | {
strokeWidth?: [Length](../../ui/ts-types.md),
scaleCount?: number,
scaleWidth?: [Length](../../ui/ts-types.md)
} | 定义组件的样式。
strokeWidth: 设置进度条宽度。
scaleCount: 设置环形进度条总刻度数。
scaleWidth: 设置环形进度条刻度粗细。刻度粗细大于进度条宽度时,刻度粗细为系统默认粗细。 | +| style8+ | {
strokeWidth?: [Length](../../ui/ts-types.md#length),
scaleCount?: number,
scaleWidth?: [Length](../../ui/ts-types.md#length)
} | 定义组件的样式。
- strokeWidth: 设置进度条宽度。
- scaleCount: 设置环形进度条总刻度数。
- scaleWidth: 设置环形进度条刻度粗细,刻度粗细大于进度条宽度时,为系统默认粗细。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md index 72934461df0a20aee8797d34d390c8f08b160842..d214fffaf780f0f39efe8cb1f62f61f789a7dbea 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md @@ -3,12 +3,8 @@ 提供在给定范围内选择评分的组件。 > **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -16,24 +12,25 @@ 无 -## 接口说明 +## 接口 Rating(options?: { rating: number, indicator?: boolean }) -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | rating | number | 是 | 0 | 设置并接收评分值。 | - | indicator | boolean | 否 | false | 仅作为指示器使用,不可操作。 | +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| rating | number | 是 | 设置并接收评分值。
默认值:0 | +| indicator | boolean | 否 | 仅作为指示器使用,不可操作。
默认值:false | ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| stars | number | 5 | 设置评星总数。 | -| stepSize | number | 0.5 | 操作评级的步长。 | -| starStyle | {
backgroundUri: string,
foregroundUri: string,
secondaryUri?: string
} | - | backgroundSrc:未选中的星级的图片链接,可由用户自定义或使用系统默认图片,仅支持本地。
foregroundSrc:选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地。
secondarySrc:部分选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地。 | +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| stars | number | 设置评星总数。
默认值:5 | +| stepSize | number | 操作评级的步长。
默认值:0.5 | +| starStyle | {
backgroundUri: string,
foregroundUri: string,
secondaryUri?: string
} | backgroundUri:未选中的星级的图片链接,可由用户自定义或使用系统默认图片,仅支持本地图片。
foregroundUri:选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地图片。
secondaryUir:部分选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地图片。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md index af9d1d00d59ea0ba147cfcaabacac4cfc57642e6..3aa51016e0caf1597f5cd214dbdff9a909a3d169 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md @@ -1,15 +1,10 @@ # ScrollBar -> **说明:** -> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 滚动条组件ScrollBar,用于配合可滚动组件使用,如List、Grid、Scroll。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -21,23 +16,25 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: BarState }) -- ScrollBarOptions的参数描述 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | scroller | [Scroller](ts-container-scroll.md#scroller) | 是 | - | 可滚动组件的控制器。用于与可滚动组件进行绑定。 | - | direction | ScrollBarDirection | 否 | ScrollBarDirection.Vertical | 滚动条的方向,控制可滚动组件对应方向的滚动。 | - | state | [BarState](ts-appendix-enums.md#barstate) | 否 | BarState.Auto | 滚动条状态。 | - - > **说明:** - > ScrollBar组件负责定义可滚动区域的行为样式,ScrollBar的子节点负责定义滚动条的行为样式。 - > - > 滚动条组件与可滚动组件通过Scroller进行绑定,且只有当两者方向相同时,才能联动,ScrollBar与可滚动组件仅支持一对一绑定。 - -- ScrollBarDirection枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Vertical | 纵向滚动条。 | - | Horizontal | 横向滚动条。 | +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| scroller | [Scroller](ts-container-scroll.md#scroller) | 是 | 可滚动组件的控制器。用于与可滚动组件进行绑定。 | +| direction | ScrollBarDirection | 否 | 滚动条的方向,控制可滚动组件对应方向的滚动。
默认值:ScrollBarDirection.Vertical | +| state | [BarState](ts-appendix-enums.md#barstate) | 否 | 滚动条状态。
默认值:BarState.Auto | + +> **说明:** +> ScrollBar组件负责定义可滚动区域的行为样式,ScrollBar的子节点负责定义滚动条的行为样式。 +> +> 滚动条组件与可滚动组件通过Scroller进行绑定,且只有当两者方向相同时,才能联动,ScrollBar与可滚动组件仅支持一对一绑定。 + +## ScrollBarDirection枚举说明 + +| 名称 | 描述 | +| -------- | -------- | +| Vertical | 纵向滚动条。 | +| Horizontal | 横向滚动条。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md index ba7a356c549286ec40a10361c27ab8557505c3d7..d6b6e0cdbba6d7e2a1aaf23310525225a5eeaec8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -1,12 +1,10 @@ # Select -> **说明:** 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - 提供下拉选择菜单,可以让用户在多个选项之间选择。 -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -18,25 +16,25 @@ Select(options: Array\) **SelectOption对象说明:** - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ----- | ----------------------------------- | ---- | ---- | ------- | - | value | [ResourceStr](../../ui/ts-types.md) | 是 | - | 下拉选项内容。 | - | icon | [ResourceStr](../../ui/ts-types.md) | 否 | - | 下拉选项图片。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | ----------------------------------- | ---- | -------------- | +| value | [ResourceStr](../../ui/ts-types.md) | 是 | 下拉选项内容。 | +| icon | [ResourceStr](../../ui/ts-types.md) | 否 | 下拉选项图片。 | ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| ----------------------- | ------------------------------------- | ---- | ------------------------ | -| selected | number | - | 设置下拉菜单初始选择项的索引,第一项的索引为0。 | -| value | string | - | 设置下拉按钮本身的文本显示。 | -| font | [Font](../../ui/ts-types.md) | - | 设置下拉按钮本身的文本样式: | -| fontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉按钮本身的文本颜色。 | -| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单选中项的背景色。 | -| selectedOptionFont | [Font](../../ui/ts-types.md) | - | 设置下拉菜单选中项的文本样式: | -| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单选中项的文本颜色。 | -| optionBgColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单项的背景色。 | -| optionFont | [Font](../../ui/ts-types.md) | - | 设置下拉菜单项的文本样式: | -| optionFontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单项的文本颜色。 | +| 名称 | 参数类型 | 描述 | +| ----------------------- | ------------------------------------- | --------------------------------------------- | +| selected | number | 设置下拉菜单初始选项的索引,第一项的索引为0。 | +| value | string | 设置下拉按钮本身的文本显示。 | +| font | [Font](../../ui/ts-types.md) | 设置下拉按钮本身的文本样式。 | +| fontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉按钮本身的文本颜色。 | +| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单选中项的背景色。 | +| selectedOptionFont | [Font](../../ui/ts-types.md) | 设置下拉菜单选中项的文本样式。 | +| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单选中项的文本颜色。 | +| optionBgColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单项的背景色。 | +| optionFont | [Font](../../ui/ts-types.md) | 设置下拉菜单项的文本样式。 | +| optionFontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单项的文本颜色。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md index dfbabd005766ee3afaa7e10dd3d226d3732b9722..ef51de1cc1d89511764887f30c382f53bc3ba175 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md @@ -4,12 +4,8 @@ > **说明:** -> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 +> +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -24,19 +20,20 @@ StepperItem() ## 属性 -| 参数名 | 参数类型 | 默认值 | 参数描述 | -| -------- | -------- | -------- | -------- | -| prevLabel | string | - | 当步骤导航器大于一页,除第一页默认值都为"返回"。 | -| nextLabel | string | - | 步骤导航器大于一页时,最后一页默认值为"开始",其余页默认值为"下一步"。 | -| status | ItemState | ItemState.Normal | 步骤导航器元素的状态。 | - -- ItemState枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 | - | Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 | - | Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 | - | Skip | 跳过状态,表示跳过当前步骤, 进入下一个StepperItem。 | +| 参数名 | 参数类型 | 参数描述 | +| -------- | -------- | -------- | +| prevLabel | string | 当步骤导航器大于一页,除第一页默认值都为“返回”。 | +| nextLabel | string | 步骤导航器大于一页时,最后一页默认值为“开始”,其余页默认值为“下一步”。 | +| status | ItemState | 步骤导航器元素的状态。
默认值:ItemState.Normal | + +## ItemState枚举说明 + +| 名称 | 描述 | +| -------- | -------- | +| Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 | +| Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 | +| Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 | +| Skip | 跳过状态,表示跳过当前步骤, 进入下一个StepperItem。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md index 5d14a6be16867f484cad76501346a357eadb51d8..1cc48434594cdcb7c5e060fb7d3f581c97abbc4f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md @@ -42,7 +42,7 @@ TextClock(options?: { timeZoneOffset?: number, controller?: TextClockController ## TextClockController -TextClock容器组件的控制器,可以将此对象绑定到TextClock组件,再通过它控制文本时钟的启动与停止。 +TextClock容器组件的控制器,可以将此对象绑定到TextClock组件,再通过它控制文本时钟的启动与停止。一个TextClock组件仅支持绑定一个控制器。 ### 导入对象 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md index 9045b38cd0d6909c30625a4f4f824d2464e7ea69..5cbed372dd3e323e542e2d678ef4d73af406c5f6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md @@ -43,7 +43,7 @@ TextTimer(options: { isCountDown?: boolean, count?: number, controller?: TextTim ## TextTimerController -TextTimer组件的控制器,用于控制文本计时器。 +TextTimer组件的控制器,用于控制文本计时器。一个TextTimer组件仅支持绑定一个控制器。 ### 导入对象 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md index e74488c562835c6153ba7e8127e8f27a44cdb25d..1df79983e2e4560e438b22fe63e65952917e5fe8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md @@ -32,7 +32,7 @@ Canvas(context?: CanvasRenderingContext2D) | 名称 | 参数 | 描述 | | ----------------------------- | ---- | -------------------- | -| onReady(event: () => void) | 无 | 画布组件的事件回调,可以在此时进行绘制。 | +| onReady(event: () => void) | 无 | Canvas组件初始化完成时的事件回调,该事件之后Canvas组件宽高确定且可获取,可使用Canvas相关API进行绘制。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md index 15fbf6fc7b4d92416b90432087023ca0a44a6ed1..0c3bb859d8c7bca9980d46a47f2ab734671f4962 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md @@ -34,7 +34,7 @@ Grid(scroller?: Scroller) | scrollBar | [BarState](ts-appendix-enums.md#barstate) | BarState.Off | 设置滚动条状态。 | | scrollBarColor | string \| number \| [Color](ts-appendix-enums.md#color) | - | 设置滚动条的颜色。 | | scrollBarWidth | number \| string | - | 设置滚动条的宽度。 | -| cachedCount | number | 1 | 设置预加载的GridItem的数量。 | +| cachedCount | number | 1 | 设置预加载的GridItem的数量。具体使用可参考[减少应用白块说明](../../ui/ts-performance-improvement-recommendation.md#减少应用滑动白块)。 | | editMode 8+ | boolean | false | 是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部[GridItem](ts-container-griditem.md)。 | | layoutDirection8+ | [GridDirection](#griddirection8枚举说明) | GridDirection.Row | 设置布局的主轴方向。 | | maxCount8+ | number | 1 | 当layoutDirection是Row/RowReverse时,表示可显示的最大行数
当layoutDirection是Column/ColumnReverse时,表示可显示的最大列数。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md index afb9e9f838c658a155f87240c79fe4f05d0c10a5..92275ecbc18729262785b6a750095bc6ff9d720c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md @@ -34,7 +34,7 @@ List(value?: {initialIndex?: number, space?: number | string, scroller?: Scrolle | listDirection | [Axis](ts-appendix-enums.md#axis) | Axis.Vertical | 设置List组件排列方向参照Axis枚举说明。 | | divider | {
strokeWidth: Length,
color?:[ResourceColor](../../ui/ts-types.md),
startMargin?: Length,
endMargin?: Length
} | - | 用于设置ListItem分割线样式,默认无分割线。
strokeWidth: 分割线的线宽。
color: 分割线的颜色。
startMargin: 分割线距离列表侧边起始端的距离。
endMargin: 分割线距离列表侧边结束端的距离。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | BarState.Off | 设置滚动条状态。 | -| cachedCount | number | 1 | 设置预加载的ListItem的数量。 | +| cachedCount | number | 1 | 设置预加载的ListItem的数量。具体使用可参考[减少应用白块说明](../../ui/ts-performance-improvement-recommendation.md#减少应用滑动白块)。 | | editMode | boolean | false | 声明当前List组件是否处于可编辑模式。 | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | EdgeEffect.Spring | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。 | | chainAnimation | boolean | false | 用于设置当前list是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:List内的ListItem或ListItemGroup间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。其中ListItemGroup以一个整体参与链式联动动效,ListItemGroup内的ListITem不参与链式联动动效。
- false:不启用链式联动。
- true:启用链式联动。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md index 49ab62da5e1e98a2a83fc449e5c3c98a1c02b56f..24692f68638541162d8c3d023ef19b5dbb7bfc3d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -1,15 +1,10 @@ # Navigator -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 路由容器组件,提供路由跳转能力。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -21,28 +16,28 @@ Navigator(value?: {target: string, type?: NavigationType}) -创建路由组件。 +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | -------------- | ---- | ---------------------------------------------- | +| target | string | 是 | 指定跳转目标页面的路径。 | +| type | NavigationType | 否 | 指定路由方式。
默认值:NavigationType.Push | -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ------ | -------------- | ---- | ------------------- | ------------ | - | target | string | 是 | - | 指定跳转目标页面的路径。 | - | type | NavigationType | 否 | NavigationType.Push | 指定路由方式。 | +## NavigationType枚举说明 -- NavigationType枚举说明 - | 名称 | 描述 | - | ------- | -------------------------- | - | Push | 跳转到应用内的指定页面。 | - | Replace | 用应用内的某个页面替换当前页面,并销毁被替换的页面。 | - | Back | 返回上一页面或指定的页面。 | +| 名称 | 描述 | +| ------- | -------------------------- | +| Push | 跳转到应用内的指定页面。 | +| Replace | 用应用内的某个页面替换当前页面,并销毁被替换的页面。 | +| Back | 返回上一页面或指定的页面。 | ## 属性 -| 名称 | 参数 | 默认值 | 描述 | -| ------ | ------- | --------- | ---------------------------------------- | -| active | boolean | - | 当前路由组件是否处于激活状态,处于激活状态时,会生效相应的路由操作。 | -| params | Object | undefined | 跳转时要同时传递到目标页面的数据,可在目标页面使用router.getParams()获得。 | +| 名称 | 参数 | 描述 | +| ------ | ------- | ------------------------------------------------------------ | +| active | boolean | 当前路由组件是否处于激活状态,处于激活状态时,会生效相应的路由操作。 | +| params | Object | 跳转时要同时传递到目标页面的数据,可在目标页面使用router.getParams()获得。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md index 8bb8b3941407b4d87c412161d1b0453a75865348..cebd4995112ee15c038b72e4e1e08bbcb595b408 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md @@ -1,15 +1,10 @@ # Panel -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 可滑动面板,提供一种轻量的内容展示窗口,方便在不同尺寸中切换。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -19,47 +14,51 @@ ## 接口 -Panel(value:{show:boolean}) +Panel(show:boolean) -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | show | boolean | 是 | - | 控制Panel显示或隐藏。 | +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| show | boolean | 是 | 控制Panel显示或隐藏。 | ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| type | PanelType | PanelType.Foldable | 设置可滑动面板的类型。 | -| mode | PanelMode | - | 设置可滑动面板的初始状态。 | -| dragBar | boolean | true | 设置是否存在dragbar,true表示存在,false表示不存在。 | -| fullHeight | Length | - | 指定PanelMode.Full状态下的高度。 | -| halfHeight | Length | - | 指定PanelMode.Half状态下的高度,默认为屏幕尺寸的一半。 | -| miniHeight | Length | - | 指定PanelMode.Mini状态下的高度。 | -| backgroundMask9+|(color: ResourceColor)| - |指定Panel的背景蒙层。| - -- PanelType枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Minibar | 提供minibar和类全屏展示切换效果。 | - | Foldable | 内容永久展示类,提供大(类全屏)、中(类半屏)、小三种尺寸展示切换效果。 | - | Temporary | 内容临时展示区,提供大(类全屏)、中(类半屏)两种尺寸展示切换效果。 | - -- PanelMode枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Mini | 类型为minibar和foldable时,为最小状态;类型为temporary,则不生效。 | - | Half | 类型为foldable和temporary时,为类半屏状态;类型为minibar,则不生效。 | - | Full | 类全屏状态。 | +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| type | PanelType | 设置可滑动面板的类型。
默认值:PanelType.Foldable | +| mode | PanelMode | 设置可滑动面板的初始状态。 | +| dragBar | boolean | 设置是否存在dragbar,true表示存在,false表示不存在。
默认值:true | +| fullHeight | string \| number | 指定PanelMode.Full状态下的高度。 | +| halfHeight | string \| number | 指定PanelMode.Half状态下的高度,默认为屏幕尺寸的一半。 | +| miniHeight | string \| number | 指定PanelMode.Mini状态下的高度。 | +| show | boolean | 当滑动面板弹出时调用。 | +| backgroundMask9+|[ResourceColor](../../ui/ts-types.md#resourcecolor8)|指定Panel的背景蒙层。| + +## PanelType枚举说明 + +| 名称 | 描述 | +| -------- | -------- | +| Minibar | 提供minibar和类全屏展示切换效果。 | +| Foldable | 内容永久展示类,提供大(类全屏)、中(类半屏)、小三种尺寸展示切换效果。 | +| Temporary | 内容临时展示区,提供大(类全屏)、中(类半屏)两种尺寸展示切换效果。 | + +## PanelMode枚举说明 + +| 名称 | 描述 | +| -------- | -------- | +| Mini | 类型为minibar和foldable时,为最小状态;类型为temporary,则不生效。 | +| Half | 类型为foldable和temporary时,为类半屏状态;类型为minibar,则不生效。 | +| Full | 类全屏状态。 | ## 事件 -| 名称 | 功能描述 | +| 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (width: number, height: number, mode: PanelMode) => void) | 当可滑动面板发生状态变化时触发, 返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。 | -| onHeightChange(callback: (value: number) => void)9+ |当可滑动面板发生高度变化时触发,返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。因用户体验设计原因,panel最高只能滑到 fullHeight-8vp | +| onChange(event: (width: number, height: number, mode: PanelMode) => void) | 当可滑动面板发生状态变化时触发, 返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。 | +| onHeightChange(callback: (value: number) => void)9+ |当可滑动面板发生高度变化时触发,返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。因用户体验设计原因,panel最高只能滑到 fullHeight-8vp。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md index 8c5527430e504aeb5e6bd830db7de0ae43be51ad..d1849a00c4bf3ced1ec7d953c60303b16ea5bd09 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md @@ -3,11 +3,8 @@ 可以进行页面下拉操作并显示刷新动效的容器组件。 > **说明:** -> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - -## 权限列表 - -无 +> +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -15,15 +12,15 @@ ## 接口 -Refresh\(value: \{ refreshing: boolean, offset?: Length, friction?: number | string \}\) +Refresh\(value: \{ refreshing: boolean, offset?: number | string , friction?: number | string \}\) -- 参数 +**参数:** - | 参数 | 参数名 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | refreshing | boolean | 是 | - | 当前组件是否正在刷新。
该参数支持[$$](../../ui/ts-syntactic-sugar.md)双向绑定变量。 | - | offset | Length | 否 | 16 | 刷新组件静止时距离父组件顶部的距离。| - | friction | number \| string | 否 | 62 | 下拉摩擦系数,取值范围为0到100。
- 0表示下拉刷新容器不跟随手势下拉而下拉。
- 100表示下拉刷新容器紧紧跟随手势下拉而下拉。
- 数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 | +| 参数 | 参数名 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| refreshing | boolean | 是 | 当前组件是否正在刷新。
该参数支持[$$](../../ui/ts-syntactic-sugar.md)双向绑定变量。 | +| offset | string \| number | 否 | 刷新组件静止时距离父组件顶部的距离。
默认值:16,单位vp | +| friction | number \| string | 否 | 下拉摩擦系数,取值范围为0到100。
默认值:62
- 0表示下拉刷新容器不跟随手势下拉而下拉。
- 100表示下拉刷新容器紧紧跟随手势下拉而下拉。
- 数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 | @@ -32,18 +29,18 @@ Refresh\(value: \{ refreshing: boolean, offset?: Length, friction?: number | str | 名称 | 描述 | | -------- | -------- | -| onStateChange(callback: (state: RefreshStatus) => void)| 当前刷新状态变更时,触发回调。
state:刷新状态。 | +| onStateChange(callback: (state: RefreshStatus) => void)| 当前刷新状态变更时,触发回调。
- state:刷新状态。 | | onRefreshing(callback: () => void)| 进入刷新状态时触发回调。 | -- RefreshStatus枚举说明 +## RefreshStatus枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Inactive | 默认未下拉状态。 | - | Drag | 下拉中,下拉距离小于刷新距离。 | - | OverDrag | 下拉中,下拉距离超过刷新距离。 | - | Refresh | 下拉结束,回弹至刷新距离,进入刷新状态。 | - | Done | 刷新结束,返回初始状态(顶部)。 | +| 名称 | 描述 | +| -------- | -------- | +| Inactive | 默认未下拉状态。 | +| Drag | 下拉中,下拉距离小于刷新距离。 | +| OverDrag | 下拉中,下拉距离超过刷新距离。 | +| Refresh | 下拉结束,回弹至刷新距离,进入刷新状态。 | +| Done | 刷新结束,返回初始状态(顶部)。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md index 4179c135dec5b9e3c202039680a5edc361fb1356..8376694073445f0b52b7f283be3a7b44cc2cb1e2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md @@ -1,15 +1,10 @@ # Row -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 沿水平方向布局容器。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -19,20 +14,21 @@ ## 接口 -Row(value?:{space?: Length}) +Row(value?:{space?: number | string }) + +**参数:** -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | space | Length | 否 | 0 | 横向布局元素间距。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| space | string \| number | 否 | 横向布局元素间距。
默认值:0 | ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| alignItems | [VerticalAlign](ts-appendix-enums.md#verticalalign) | VerticalAlign.Center | 在垂直方向上子组件的对齐格式。 | -| justifyContent8+ | [FlexAlign](ts-appendix-enums.md#flexalign) | FlexAlign.Start | 设置子组件在水平方向上的对齐格式。 | +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| alignItems | [VerticalAlign](ts-appendix-enums.md#verticalalign) | 设置子组件在垂直方向上的对齐格式。
默认值:VerticalAlign.Center | +| justifyContent8+ | [FlexAlign](ts-appendix-enums.md#flexalign) | 设置子组件在水平方向上的对齐格式。
FlexAlign.Start | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index d6f3d8814bf8728ac4fdb48a48c8014d7b55d68a..92875f1243f788be7d71de89af0c66113fe6d141 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -1,15 +1,10 @@ # SideBarContainer -> **说明:** -> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 提供侧边栏可以显示和隐藏的侧边栏容器,通过子组件定义侧边栏和内容区,第一个子组件表示侧边栏,第二个子组件表示内容区。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -21,52 +16,56 @@ SideBarContainer( type?: SideBarContainerType ) -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | type | SideBarContainerType | 否 | SideBarContainerType.Embed | 设置侧边栏的显示类型。 | +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| type | SideBarContainerType | 否 | 设置侧边栏的显示类型。
默认值:SideBarContainerType.Embed | -- SideBarContainerType枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Embed | 侧边栏嵌入到组件内,侧边栏和内容区并列显示。 | - | Overlay | 侧边栏浮在内容区上面。 | +## SideBarContainerType枚举说明 + +| 名称 | 描述 | +| -------- | -------- | +| Embed | 侧边栏嵌入到组件内,和内容区并列显示。 | +| Overlay | 侧边栏浮在内容区上面。 | ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| showSideBar | boolean | 设置是否显示侧边栏。
默认值:true | +| controlButton | ButtonStyle | 设置侧边栏控制按钮的属性。 | +| showControlButton | boolean | 设置是否显示控制按钮。
默认值:true | +| sideBarWidth | number | 设置侧边栏的宽度。
默认值:200,单位vp | +| minSideBarWidth | number | 设置侧边栏最小宽度。
默认值:200,单位vp | +| maxSideBarWidth | number | 设置侧边栏最大宽度。
默认值:280,单位vp | +| autoHide9+ | boolean | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。
默认值:true | +| sideBarPosition9+ | SideBarPosition | 设置侧边栏显示位置。
默认值:SideBarPosition.Start | + +## ButtonStyle对象说明 + +| 名称 | 参数类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| showSideBar | boolean | true | 设置是否显示侧边栏。 | -| controlButton | ButtonStyle | - | 设置侧边栏控制按钮的属性。 | -| showControlButton | boolean | true | 设置是否显示控制按钮。 | -| sideBarWidth | number \| [Length9+](../../ui/ts-types.md#长度类型) | 200 | 设置侧边栏的宽度。 | -| minSideBarWidth | number \| [Length9+](../../ui/ts-types.md#长度类型) | 200 | 设置侧边栏最小宽度。 | -| maxSideBarWidth | number \| [Length9+](../../ui/ts-types.md#长度类型) | 280 | 设置侧边栏最大宽度。 | -| autoHide9+ | boolean | true | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。 | -| sideBarPosition9+ | SideBarPosition | SideBarPosition.Start | 设置侧边栏显示位置。 | - -- ButtonStyle对象说明 - | 名称 | 参数类型 | 必填 | 默认值 | 描述 | - | -------- | -------- | -------- | -------- | -------- | - | left | number | 否 | 16 | 设置侧边栏控制按钮距离容器左界限的间距。 | - | top | number | 否 | 48 | 设置侧边栏控制按钮距离容器上界限的间距。 | - | width | number | 否 | 32 | 设置侧边栏控制按钮的宽度。 | - | height | number | 否 | 32 | 设置侧边栏控制按钮的高度。 | - | icons | {
shown: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
hidden: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
switching?: string \| PixelMap \| [Resource](../../ui/ts-types.md)
} | 否 | - | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | - -- SideBarPosition9+枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Start | 侧边栏位于容器左侧。 | - | End | 侧边栏位于容器右侧。 | +| left | number | 否 | 设置侧边栏控制按钮距离容器左界限的间距。
默认值:16,单位vp | +| top | number | 否 | 设置侧边栏控制按钮距离容器上界限的间距。
默认值:48,单位vp | +| width | number | 否 | 设置侧边栏控制按钮的宽度。
默认值:32,单位vp | +| height | number | 否 | 设置侧边栏控制按钮的高度。
默认值:32,单位vp | +| icons | {
shown: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
hidden: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
switching?: string \| PixelMap \| [Resource](../../ui/ts-types.md)
} | 否 | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | + +## SideBarPosition9+枚举说明 + +| 名称 | 描述 | +| -------- | -------- | +| Start | 侧边栏位于容器左侧。 | +| End | 侧边栏位于容器右侧。 | ## 事件 -| 名称 | 功能描述 | +| 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (value: boolean) => void) | 当侧边栏的状态在显示和隐藏之间切换时触发回调。

value的true表示显示,false表示隐藏。| +| onChange(callback: (value: boolean) => void) | 当侧边栏的状态在显示和隐藏之间切换时触发回调。

true表示显示,false表示隐藏。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md index 6acbfc7449061d055a0d38148c8e4a164a21b7c9..52b6a255f541389741f8c49083a510203ee68496 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md @@ -1,15 +1,10 @@ # Stack -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 @@ -19,12 +14,13 @@ ## 接口 -Stack(value:{alignContent?: Alignment}) +Stack({ alignContent?: Alignment }) + +**参数:** -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | alignContent | [Alignment](ts-appendix-enums.md#alignment枚举说明) | 否 | Center | 设置子组件在容器内的对齐方式。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| alignContent | [Alignment](ts-appendix-enums.md#alignment) | 否 | 设置子组件在容器内的对齐方式。
默认值:Alignment.Center | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md index 4440a82f815fd8a3272a6ee562ab78e2bec3a935..5a523dd57d9a658b14a3dd6050d9cedd4123613a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -1,18 +1,12 @@ # Swiper + 滑块视图容器,提供子组件滑动轮播显示的能力。 + > **说明:** > > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -滑动容器,提供切换子组件显示的能力。 - - -## 权限列表 - -无 - - ## 子组件 可以包含子组件。 @@ -24,14 +18,14 @@ Swiper(value:{controller?: SwiperController}) **参数:** - | 参数名 | 参数类型 | 必填 | 参数描述 | - | ---------- | ------------------------------------- | ---- | -------------------- | - | controller | [SwiperController](#swipercontroller) | 否 | 给组件绑定一个控制器,用来控制组件翻页。
默认值:null | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ---------- | ------------------------------------- | ---- | -------------------- | +| controller | [SwiperController](#swipercontroller) | 否 | 给组件绑定一个控制器,用来控制组件翻页。 | ## 属性 -不支持[Menu控制](ts-universal-attributes-menu.md)。 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性,不支持[Menu控制](ts-universal-attributes-menu.md)。 | 名称 | 参数类型 | 描述 | | --------------------------- | ---------------------------------------- | ---------------------------------------- | @@ -42,29 +36,29 @@ Swiper(value:{controller?: SwiperController}) | loop | boolean | 是否开启循环。
设置为true时表示开启循环,在LazyForEach懒循环加载模式下,加载的组件数量建议大于5个。
默认值:true | | duration | number | 子组件切换的动画时长,单位为毫秒。
默认值:400 | | vertical | boolean | 是否为纵向滑动。
默认值:false | -| itemSpace | Length | 设置子组件与子组件之间间隙。
默认值:0 | +| itemSpace | number \| string | 设置子组件与子组件之间间隙。
默认值:0 | | displayMode | SwiperDisplayMode | 主轴方向上元素排列的模式,优先以displayCount设置的个数显示,displayCount未设置时本属性生效。
默认值:SwiperDisplayMode.Stretch | | cachedCount8+ | number | 设置预加载子组件个数。
默认值:1 | | disableSwipe8+ | boolean | 禁用组件滑动切换功能。
默认值:false | | curve8+ | [Curve](ts-appendix-enums.md#curve) \| string | 设置Swiper的动画曲线,默认为淡入淡出曲线,常用曲线参考[Curve枚举说明](ts-appendix-enums.md#curve),也可以通过插值计算模块提供的接口创建自定义的Curves([插值曲线对象](ts-interpolation-calculation.md))。
默认值:Curve.Ease | -| indicatorStyle8+ | {
left?: Length,
top?: Length,
right?: Length,
bottom?: Length,
size?: Length,
mask?: boolean,
color?: [ResourceColor](../../ui/ts-types.md),
selectedColor?: [ResourceColor](../../ui/ts-types.md)
} | - | 设置indicator样式:
- left: 设置导航点距离Swiper组件左边的距离。
- top: 设置导航点距离Swiper组件顶部的距离。
- right: 设置导航点距离Swiper组件右边的距离。
- bottom: 设置导航点距离Swiper组件底部的距离。
- size: 设置导航点的直径。
- mask: 设置是否显示导航点蒙层样式。
- color: 设置导航点的颜色。
- selectedColor: 设置选中的导航点的颜色。 | +| indicatorStyle8+ | {
left?: [Length](../../ui/ts-types.md#length),
top?: [Length](../../ui/ts-types.md#length),
right?: [Length](../../ui/ts-types.md#length),
bottom?: [Length](../../ui/ts-types.md#length),
size?: [Length](../../ui/ts-types.md#length),
mask?: boolean,
color?: [ResourceColor](../../ui/ts-types.md),
selectedColor?: [ResourceColor](../../ui/ts-types.md)
} | 设置导航点样式:
\- left: 设置导航点距离Swiper组件左边的距离。
\- top: 设置导航点距离Swiper组件顶部的距离。
\- right: 设置导航点距离Swiper组件右边的距离。
\- bottom: 设置导航点距离Swiper组件底部的距离。
\- size: 设置导航点的直径。
\- mask: 设置是否显示导航点蒙层样式。
\- color: 设置导航点的颜色。
\- selectedColor: 设置选中的导航点的颜色。 | | displayCount8+ | number\|string | 设置元素显示个数。
默认值:1 | | effectMode8+ | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。
默认值:EdgeEffect.Spring | ## SwiperDisplayMode枚举说明 - - | 名称 | 描述 | - | ----------- | ------------------------------------------ | - | Stretch | Swiper滑动一页的宽度为Swiper组件自身的宽度。| - | AutoLinear | Swiper滑动一页的宽度为子组件宽度中的最大值。| + +| 名称 | 描述 | +| ----------- | ------------------------------------------ | +| Stretch | Swiper滑动一页的宽度为Swiper组件自身的宽度。| +| AutoLinear | Swiper滑动一页的宽度为子组件宽度中的最大值。| ## EdgeEffect枚举说明 - - | 名称 | 描述 | - | ------ | ------------------------------------------------------------------------- | - | Spring | 弹性物理动效,滑动到边缘后可以通过触摸事件继续滑动一段距离,松手后回弹。 | - | Fade | 滑动到边缘后,可以通过触摸事件继续滑动一段阴影,松手后阴影回弹。 | - | None | 滑动到边缘后无效果。 | + +| 名称 | 描述 | +| ------ | ------------------------------------------------------------------------- | +| Spring | 弹性物理动效,滑动到边缘后可以通过触摸事件继续滑动一段距离,松手后回弹。 | +| Fade | 滑动到边缘后,可以通过触摸事件继续滑动一段阴影,松手后阴影回弹。 | +| None | 滑动到边缘后无效果。 | ## SwiperController diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md index fedc4b98f6c25374c1d001c342859e1a659022b1..b2b3785ce0ca51bba69401f9dec96793275cf2f7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -58,7 +58,8 @@ Line(options?: {width?: string | number, height?: string | number}) struct LineExample { build() { Column() { - Line({ width: 50, height: 100 }).startPoint([0, 0]).endPoint([50, 100]) + Line().startPoint([0, 0]).endPoint([50, 100]) + Line({ width: 50, height: 50 }).startPoint([0, 0]).endPoint([100, 100]) Line().width(200).height(200).startPoint([50, 50]).endPoint([150, 150]) }.margin({ top: 5 }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md index 365b8d7700b5ed877dd30a144e60fe017cb7cef3..f9f2674cbe0892bd983de4bd2b45a7f28ab76907 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -1,15 +1,10 @@ # Polygon -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 多边形绘制组件。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md index cc23910962ceb39f2f8c4f2d92bd6fab2651dc77..cf2d0ea085fb49e14aaa9d59ac909af218ef2ba9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -1,15 +1,10 @@ # Polyline -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 折线绘制组件。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md index 1200e32be5267376ec5f02d0e12a7acf203f2526..53ff413ddd1793b97d0fec303564b28aa85fa857 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -1,15 +1,10 @@ # Rect -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 矩形绘制组件。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index 0dd21b3fd1e4b733e923a3a4d489e8ec8bac8528..0d75477d8c16d9f8a7bc077977a849f874e93ff1 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -1,21 +1,15 @@ # Shape -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 绘制组件的父组件,父组件中会描述所有绘制组件均支持的通用属性。 1、绘制组件使用Shape作为父组件,实现类似SVG的效果。 - 2、绘制组件单独使用,用于在页面上绘制指定的图形。 - -## 权限列表 - -无 +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md index c3cedbcfe3b530df362567af6fcc6f1e153b349a..ec4a119e6bfbcdc5c1546a063a793cc051c7109c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md @@ -9,10 +9,10 @@ | 接口名称 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| animateTo(value: [AnimationOptions](#animationoptions对象说明), event: ()=> void) : void | 提供全局animateTo显式动画接口来指定由于闭包代码导致的状态变化插入过渡动效。
event指定显示动效的闭包函数,在闭包函数中导致的状态变化系统会自动插入过渡动画。 | +| animateTo(value: [AnimateParam](#animateparam对象说明), event: ()=> void) : void | 提供全局animateTo显式动画接口来指定由于闭包代码导致的状态变化插入过渡动效。
event指定显示动效的闭包函数,在闭包函数中导致的状态变化系统会自动插入过渡动画。 | -## AnimationOptions对象说明 +## AnimateParam对象说明 | 名称 | 类型 | 描述 | | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md index c9f180b3fbfe7d8d9b8af1156a0fb76ef1297bba..f1eea63ecb0523e02667525ff29a4fc0a6838d7e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md @@ -1,61 +1,51 @@ # 页面间转场 -页面转场通过在全局pageTransition方法内配置页面入场组件和页面退场组件来自定义页面转场动效。 +在全局pageTransition方法内配置页面入场和页面退场时的自定义转场动效。 > **说明:** +> > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -| 名称 | 参数 | 参数描述 | -| ------------------- | ------ | ------------------------------- | -| PageTransitionEnter | Object | 页面入场组件,用于自定义当前页面的入场效果,详见动效参数说明。 | -| PageTransitionExit | Object | 页面退场组件,用于自定义当前页面的退场效果,详见动效参数说明。 | +| 名称 | 参数 | 参数描述 | +| ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| PageTransitionEnter | {
type: RouteType,
duration: number,
curve: Curve \| Curves,
delay: number
} | 设置当前页面的自定义入场动效。
- type:不配置时表明pop为push时效果的逆播。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,有效值参见[Curve](ts-animatorproperty.md) 。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | +| PageTransitionExit | {
type: RouteType,
duration: number,
curve: Curve \| Curves,
delay: number
} | 设置当前页面的自定义退场动效。
- type:不配置时表明pop为push时效果的逆播
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,有效值参见[Curve](ts-animatorproperty.md) 。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | +## RouteType枚举说明 -- 动效参数说明 - | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | - | -------- | ------------------------- | ------ | ---- | ---------------------------------------- | - | type | RouteType | - | 否 | 不配置时表明pop为push时效果的逆播。 | - | duration | number | 1000 | 否 | 动画时长,单位为毫秒。 | - | curve | Curve \| Curves | Linear | 否 | 动画曲线,有效值参见[Curve](ts-animatorproperty.md) 说明。 | - | delay | number | 0 | 否 | 动画延迟时长,单位为毫秒,默认不延时播放。 | - - -- RouteType枚举说明 - | 名称 | 描述 | - | ---- | ---------------- | - | Pop | 重定向指定页面。PageA跳转到PageB时,PageA为Exit+Push,PageB为Enter+Push。 | - | Push | 跳转到下一页面。PageB返回至PageA时,PageA为Enter+Pop,PageB为Exit+Pop。 | +| 名称 | 描述 | +| ---- | ------------------------------------------------------------ | +| Pop | 重定向指定页面。PageA跳转到PageB时,PageA为Exit+Push,PageB为Enter+Push。 | +| Push | 跳转到下一页面。PageB返回至PageA时,PageA为Enter+Pop,PageB为Exit+Pop。 | +| None | 页面未重定向。 | ## 属性 -PageTransitionEnter和PageTransitionExit组件支持的属性: +| 参数名称 | 参数类型 | 必填 | 参数描述 | +| --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| slide | SlideEffect | 否 | 设置页面转场时的滑入滑出效果。
默认值:SlideEffect.Right | +| translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | 否 | 设置页面转场时的平移效果,为入场时起点和退场时终点的值,和slide同时设置时默认生效slide。
- x:横向的平移距离。
- y:纵向的平移距离。
- z:竖向的平移距离。 | +| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | 否 | 设置页面转场时的缩放效果,为入场时起点和退场时终点的值。
- x:横向放大倍数(或缩小比例)。
- y:纵向放大倍数(或缩小比例)。
- z:竖向放大倍数(或缩小比例)。
- centerX、centerY缩放中心点。
- 中心点为0时,默认的是组件的左上角。
| +| opacity | number | 否 | 设置入场的起点透明度值或者退场的终点透明度值。
默认值:1 | -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| --------- | ---------------------------------------- | ----------------- | ---- | ---------------------------------------- | -| slide | SlideEffect | SlideEffect.Right | 否 | 设置转场的滑入效果,有效值参见SlideEffect枚举说明。 | -| translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | - | 否 | 设置页面转场时的平移效果,为入场时起点和退场时终点的值,和slide同时设置时默认生效slide。 | -| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | - | 否 | 设置页面转场时的缩放效果,为入场时起点和退场时终点的值。 | -| opacity | number | 1 | 否 | 设置入场的起点透明度值或者退场的终点透明度值。 | +## SlideEffect枚举说明 -- SlideEffect枚举说明 - | 名称 | 描述 | - | ------ | ------------------------- | - | Left | 设置到入场时表示从左边滑入,出场时表示滑出到左边。 | - | Right | 设置到入场时表示从右边滑入,出场时表示滑出到右边。 | - | Top | 设置到入场时表示从上边滑入,出场时表示滑出到上边。 | - | Bottom | 设置到入场时表示从下边滑入,出场时表示滑出到下边。 | +| 名称 | 描述 | +| ------ | ------------------------- | +| Left | 设置到入场时表示从左边滑入,出场时表示滑出到左边。 | +| Right | 设置到入场时表示从右边滑入,出场时表示滑出到右边。 | +| Top | 设置到入场时表示从上边滑入,出场时表示滑出到上边。 | +| Bottom | 设置到入场时表示从下边滑入,出场时表示滑出到下边。 | ## 事件 -PageTransitionEnter和PageTransitionExit组件支持的事件: - -| 事件 | 功能描述 | -| ---------------------------------------- | ----------------------------------- | -| onEnter(type: RouteType, progress: number) => void | 回调入参为当前入场动画的归一化进度[0 - 1]。 | -| onExit(type: RouteType, progress: number) => void | 回调入参为当前退场动画的归一化进度[0 - 1]。 | +| 事件 | 功能描述 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| onEnter(event: (type: RouteType, progress: number) => void) | 回调入参为当前入场动画的归一化进度[0 - 1]。
- type:跳转方法。
- progress:当前进度。 | +| onExit(event: (type: RouteType, progress: number) => void) | 回调入参为当前退场动画的归一化进度[0 - 1]。
- type:跳转方法。
- progress:当前进度。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md index 3ed7aabe423694da748b107fad33179f3e22c857..73e24d762e8c7e72d8af223e99bca81afc0bede8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md @@ -1,26 +1,28 @@ # 组件内转场 -组件转场主要通过transition属性进行配置转场参数,在组件插入和删除时进行过渡动效,主要用于容器组件子组件插入删除时提升用户体验(需要配合animateTo才能生效,动效时长、曲线、延时跟随animateTo中的配置)。 +组件内转场主要通过transition属性配置转场参数,在组件插入和删除时显示过渡动效,主要用于容器组件中的子组件插入和删除时,提升用户体验(需要配合[animateTo](ts-explicit-animation.md)才能生效,动效时长、曲线、延时跟随animateTo中的配置)。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 属性 -| 名称 | 参数类型 | 默认值 | 参数描述 | +| 名称 | 参数类型 | 参数描述 | +| -------- | -------- | -------- | +| transition | TransitionOptions | 所有参数均为可选参数,详细描述见TransitionOptions参数说明。 | + +## TransitionOptions参数说明 + +| 参数名称 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| transition | Object | - | 所有参数均为可选参数,详细描述见transition入参说明。 | - -- transition入参说明 - | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | type | [TransitionType](ts-appendix-enums.md#transitiontype) | TransitionType.All | 否 | 默认包括组件新增和删除。
>  **说明:**
> 不指定Type时说明插入删除使用同一种效果。 | - | opacity | number | 1 | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。 | - | translate | {
x? : number,
y? : number,
z? : number
} | - | 否 | 设置组件转场时的平移效果,为插入时起点和删除时终点的值。
-x:横向的平移距离。
-y:纵向的平移距离。
-z:竖向的平移距离。 | - | scale | {
x? : number,
y? : number,
z? : number,
centerX? : number,
centerY? : number
} | - | 否 | 设置组件转场时的缩放效果,为插入时起点和删除时终点的值。
-x:横向放大倍数(或缩小比例)。
-y:纵向放大倍数(或缩小比例)。
-z:竖向放大倍数(或缩小比例)。
- centerX、centerY缩放中心点。
- 中心点为0时,默认的是组件的左上角。
| - | rotate | {
x?: number,
y?: number,
z?: number,
angle?: Angle,
centerX?: Length,
centerY?: Length
} | - | 否 | 设置组件转场时的旋转效果,为插入时起点和删除时终点的值。
-x:横向的旋转向量。
-y:纵向的旋转向量。
-z:竖向的旋转向量。
- centerX,centerY指旋转中心点。
- 中心点为(0,0)时,默认的是组件的左上角。 | +| type | [TransitionType](ts-appendix-enums.md#transitiontype) | 否 | 默认包括组件新增和删除。
默认值:TransitionType.All
**说明:**
不指定Type时说明插入删除使用同一种效果。 | +| opacity | number | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。
默认值:1 | +| translate | {
x? : number,
y? : number,
z? : number
} | 否 | 设置组件转场时的平移效果,为插入时起点和删除时终点的值。
-x:横向的平移距离。
-y:纵向的平移距离。
-z:竖向的平移距离。 | +| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number,
centerY? : number
} | 否 | 设置组件转场时的缩放效果,为插入时起点和删除时终点的值。
-x:横向放大倍数(或缩小比例)。
-y:纵向放大倍数(或缩小比例)。
-z:竖向放大倍数(或缩小比例)。
- centerX、centerY缩放中心点。
- 中心点为0时,默认的是组件的左上角。
| +| rotate | {
x?: number,
y?: number,
z?: number,
angle?: Angle,
centerX?: Length,
centerY?: Length
} | 否 | 设置组件转场时的旋转效果,为插入时起点和删除时终点的值。
-x:横向的旋转向量。
-y:纵向的旋转向量。
-z:竖向的旋转向量。
- centerX,centerY指旋转中心点。
- 中心点为(0,0)时,默认的是组件的左上角。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md index 98c94ba07fe153432bcbba1be13c0c41d0ca1265..62c664240b27b57982e3db85cfed4939589fb885 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md @@ -1,29 +1,23 @@ # 共享元素转场 -共享元素转场支持页面间的转场,如当前页面的图片转场至下一页面中。 +设置页面间转场时共享元素的转场动效。 > **说明:** +> > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 属性 -| 名称 | 参数 | 默认值 | 参数描述 | -| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| sharedTransition | id: string,
options?: Object | - | 两个页面的组件配置为同一个id,则转场过程中会进行共享元素转场,配置为空字符串时不会有共享元素转场效果。 | - -- options参数说明 - | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | - | -------- | ------------------------- | ------ | ---- | --------------------- | - | duration | number | 1000 | 否 | 单位为毫秒,默认动画时长为1000毫秒。 | - | curve | Curve \| Curves | Linear | 否 | 默认曲线为线性,有效值参见Curve说明。 | - | delay | number | 0 | 否 | 单位为毫秒,默认不延时播放。 | +| 名称 | 参数 | 参数描述 | +| ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| sharedTransition | id: string,
{
duration?: number,
curve?: Curve \| string,
delay?: number,
motionPath?:
{
path: string,
form?: number,
to?: number,
rotatable?: boolean
},
zIndex?: number,
type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)
} | 两个页面中id值相同且不为空字符串的组件即为共享元素,在页面转场时可显示共享元素转场动效。
-  id:设置组件的id。
-  duration:单位为毫秒,默认动画时长为1000毫秒。
- curve:默认曲线为Linear,有效值参见[Curve](ts-animatorproperty.md) 说明。
- delay:单位为毫秒,默认不延时播放。
- motionPath:运动路径信息。
- path:设置路径。
- from:设置起始值。
- to:设置终止值。
- rotatable:是否旋转。
- zIndex:设置Z轴。
- type:动画类型。 | ## 示例 -示例功能为两个页面,共享元素转场页面图片点击后转场至页面B的图片。 + 示例代码为点击图片跳转页面时,显示共享元素图片的自定义转场动效。 ```ts // xxx.ets diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md index bc6dbe171b151d5fa70693139f12fac733cb9ac8..0986e03f2b635f689bd5a699c095e34079edefb3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md @@ -1,25 +1,21 @@ # 背景设置 -设置组件的背景色。 +设置组件的背景样式。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 +> +> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| backgroundColor | [ResourceColor](../../ui/ts-types.md) | - | 设置组件的背景色。 | -| backgroundImage | src: [ResourceStr](../../ui/ts-types.md),
repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | - | src参数:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。
repeat参数:设置背景图片的重复样式,默认不重复。 | -| backgroundImageSize | {
width?: Length,
height?: Length
} \| [ImageSize](ts-appendix-enums.md#imagesize) | Auto | 设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。 | -| backgroundImagePosition | {
x?: Length,
y?: Length
} \| [Alignment](ts-appendix-enums.md#alignment) | {
x: 0,
y: 0
} | 设置背景图在组件中显示位置。 | +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| backgroundColor | [ResourceColor](../../ui/ts-types.md) | 设置组件的背景色。 | +| backgroundImage | - src: [ResourceStr](../../ui/ts-types.md),
- repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。
repeat:设置背景图片的重复样式,默认不重复。 | +| backgroundImageSize | {
width?: [Length](../../ui/ts-types.md#length),
height?: [Length](../../ui/ts-types.md#length)
} \| [ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。
默认值:ImageSize.Auto | +| backgroundImagePosition | {
x?: [Length](../../ui/ts-types.md#length),
y?: [Length](../../ui/ts-types.md#length)
} \| [Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。
默认值:
{
x: 0,
y: 0
} | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-click.md index bf3e92c02ec64393cf633b8861f68f15771e8447..6891a6f12b086f0a888e6cb17225d8fe140f43bd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-click.md @@ -3,12 +3,8 @@ 设置组件是否可以响应点击事件、触摸事件等手指交互事件。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 +> +> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md index d566eb04e49768ab3c54a3fd693e5364db21ce75..2aa5c67b0f1bb18376a486133bdc7d6aa607cca7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md @@ -3,23 +3,18 @@ > **说明:** > - 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > -> - 仅当父组件是Flex组件时生效。 - - -## 权限列表 - -无 +> - 仅当父组件是 Flex、Column、Row 时生效。 ## 属性 -| 名称 | 参数说明 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| flexBasis | 'auto' \| Length | 'auto' | 此属性所在的组件在Flex容器中主轴方向上基准尺寸。 | -| flexGrow | number | 0 | Flex容器的剩余空间分配给此属性所在组件的比例。 | -| flexShrink | number | 1 | Flex容器压缩尺寸分配给此属性所在组件的比例。 | -| alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign枚举说明) | Auto | 覆盖Flex布局容器中alignItems默认配置。 | +| 名称 | 参数说明 | 描述 | +| -------- | -------- | -------- | +| flexBasis | number \| string | 设置组件在父容器主轴方向上的基准尺寸。
默认值:'auto'(表示组件在主轴方向上的基准尺寸为组件原本的大小) | +| flexGrow | number | 设置父容器的剩余空间分配给此属性所在组件的比例。
默认值:0 | +| flexShrink | number | 设置父容器压缩尺寸分配给此属性所在组件的比例。
默认值:1 | +| alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign) | 子组件在父容器交叉轴的对齐格式,覆盖Flex布局容器中alignItems默认配置。
默认值:ItemAlign.Auto | ## 示例 @@ -34,7 +29,7 @@ struct FlexExample { Column({ space: 5 }) { Text('flexBasis').fontSize(9).fontColor(0xCCCCCC).width('90%') // 基于主轴基准尺寸 - // flexBasis()值可以是'auto'(默认值)元素本来的大小 ,如果是数字则类似于.width()/.height() ,基于主轴 + // flexBasis()值可以是'auto',表示基准尺寸是元素本来的大小 ,也可以是长度设置,相当于.width()/.height() Flex() { Text('flexBasis(100)') .flexBasis('100').height(100).lineHeight(70) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index d677e345712d41e2fd13f6d5b3517f5be8058a3a..b301bcb2f3dda328ceb909b2d70bfe1f3e14f636 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -76,3 +76,5 @@ struct ImageEffectsExample { } } ``` + +image-effect \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md index 2420c855d9ca1cc6c00ff298d718b1ec69e2f18b..739ce3e872594c160bd0aee9f52da360cb9960ad 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md @@ -3,24 +3,21 @@ 设置组件的对齐方式、布局方向和显示位置。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 +> +> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| align | [Alignment](ts-appendix-enums.md#alignment) | Center | 设置元素内容的对齐方式,只有当设置的width和height大小超过元素本身内容大小时生效。 | -| direction | [Direction](ts-appendix-enums.md#direction) | Auto | 设置元素水平方向的布局,可选值参照Direction枚举说明。 | -| position | {
x: Length,
y: Length
} | - | 使用绝对定位,设置元素锚点相对于父容器顶部起点偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 | -| markAnchor | {
x: Length,
y: Length
} | {
x: 0,
y: 0
} | 设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。 | -| offset | {
x: Length,
y: Length
} | {
x: 0,
y: 0
} | 相对布局完成位置坐标偏移量,设置该属性,不影响父容器布局,仅在绘制时进行位置调整。 | +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| align | [Alignment](ts-appendix-enums.md#alignment) | 设置元素内容的对齐方式,只有当设置的width和height大小超过元素本身内容大小时生效。
默认值:Alignment.Center | +| direction | [Direction](ts-appendix-enums.md#direction) | 设置元素水平方向的布局。
默认值:Direction.Auto | +| position | {
x: [Length](../../ui/ts-types.md#length),
y: [Length](../../ui/ts-types.md#length)
} | 使用绝对定位,设置元素锚点相对于父容器顶部起点偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 | +| markAnchor | {
x: [Length](../../ui/ts-types.md#length),
y: [Length](../../ui/ts-types.md#length)
} | 设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。
默认值:
{
x: 0,
y: 1
} | +| offset | {
x: [Length](../../ui/ts-types.md#length),
y: [Length](../../ui/ts-types.md#length)
} | 相对布局完成位置坐标偏移量,设置该属性,不影响父容器布局,仅在绘制时进行位置调整。
默认值:
{
x: 0,
y: 1
} | +| alignRules9+ | {
left?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
right?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
middle?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
top?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
bottom?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
center?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) }
} | 指定相对容器的对齐规则。
- left:设置左对齐参数。
- right:设置右对齐参数。
- middle:设置中间对齐的参数。
- top:设置顶部对齐的参数。
- bottom:设置底部对齐的参数。
- center:设置中心对齐的参数。
**说明:**
- anchor:设置作为锚点的组件的id值。
- align:设置相对于锚点组件的对齐方式。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index a5261c90b6ca33c821d856efd398b5d8311fd334..a9e87d40133f5cf24eb3768d15ff7c584654f01a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -3,28 +3,24 @@ 为组件绑定弹出式菜单,弹出式菜单以垂直列表形式显示菜单项,可通过长按、点击或鼠标右键触发。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 +> +> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| ---------------------------- | ---------------------------------------- | ---- | ---------------------------------- | -| bindMenu | Array8+ | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | -| bindContextMenu8+ | content: [CustomBuilder](../../ui/ts-types.md),
responseType: [ResponseType](ts-appendix-enums.md#responsetype8) | - | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | +| 名称 | 参数类型 | 描述 | +| ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| bindMenu | Array8+ | content: [CustomBuilder](../../ui/ts-types.md),
responseType: [ResponseType](ts-appendix-enums.md#responsetype8) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | +## MenuItem -- MenuItem - | 名称 | 类型 | 描述 | - | ------ | ----------------------- | ----------- | - | value | string | 菜单项文本。 | - | action | () => void | 点击菜单项的事件回调。 | +| 名称 | 类型 | 描述 | +| ------ | ----------------------- | ----------- | +| value | string | 菜单项文本。 | +| action | () => void | 点击菜单项的事件回调。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md index a0ae6d4562cbbe2a6bd508f8315d9ac0fd416338..eebd642335745d02b1f2ed25dd864901462278e7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md @@ -1,31 +1,27 @@ # 多态样式 -> **说明:** -> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 设置组件不同状态下的样式。 +> **说明:** +> +> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 -无 +## 属性 +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| stateStyles | StateStyles | 设置组件不同状态的样式。 | -## 属性 +## StateStyles接口说明 -| 名称 | 参数类型 | 默认值 | 描述 | +| 名称 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| stateStyles | StateStyles | - | 设置组件不同状态的样式。 | - -- StateStyles接口说明 - | 名称 | 类型 | 必填 | 默认值 | 描述 | - | -------- | -------- | -------- | -------- | -------- | - | normal | ()=>void | 否 | - | 组件无状态时的样式。 | - | pressed | ()=>void | 否 | - | 组件按下状态的样式。 | - | disabled | ()=>void | 否 | - | 组件禁用状态的样式。 | - | focused | ()=>void | 否 | - | 组件聚焦状态的样式。 | - | clicked | ()=>void | 否 | - | 组件点击状态的样式。 | +| normal | ()=>void | 否 | 组件无状态时的样式。 | +| pressed | ()=>void | 否 | 组件按下状态的样式。 | +| disabled | ()=>void | 否 | 组件禁用状态的样式。 | +| focused | ()=>void | 否 | 组件获焦状态的样式。 | +| clicked | ()=>void | 否 | 组件点击状态的样式。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 1d4e2cd67a266c57d8af58ed2a347b977b8a1d33..ba9251977c5df751622a77ea68a74cf015cf12e3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -3,43 +3,40 @@ 设置组件点击时弹出的气泡框状态。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 +## 接口 -无 +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| bindPopup | show: boolean,
popup: PopupOptions \| CustomPopupOptions8+ | 给组件绑定Popup,点击弹出弹窗。
show: 创建页面弹窗提示是否默认显示,默认值为false。
popup: 配置当前弹窗提示的参数。 | -## 属性 +## PopupOptions类型说明 +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| message | string | 是 | 弹窗信息内容。 | +| placementOnTop | boolean | 否 | 是否在组件上方显示,默认值为false。 | +| arrowOffset9+ | [Length](../../ui/ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | +| primaryButton | {
value: string,
action: () => void
} | 否 | 第一个按钮。
value: 弹窗里主按钮的文本。
action: 点击主按钮的回调函数。 | +| secondaryButton | {
value: string,
action: () => void
} | 否 | 第二个按钮。
value: 弹窗里辅助按钮的文本。
action: 点击辅助按钮的回调函数。 | +| onStateChange | (event: { isVisible: boolean }) => void | 否 | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 | + +## CustomPopupOptions8+类型说明 -| 名称 | 参数类型 | 默认值 | 描述 | +| 名称 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| bindPopup | show: boolean,
popup: PopupOptions \| CustomPopupOptions | - | 给组件绑定Popup,点击弹出弹窗。
show: 创建页面弹窗提示是否默认显示,默认值为false。
popup: 配置当前弹窗提示的参数。 | - - -- PopupOptions类型接口说明 - | 名称 | 类型 | 必填 | 默认值 | 描述 | - | -------- | -------- | -------- | -------- | -------- | - | message | string | 是 | - | 弹窗信息内容。 | - | placementOnTop | boolean | 否 | false | 是否在组件上方显示,默认值为false。 | - | arrowOffset9+ | Length | 否 | - | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧,默认居上。 | - | primaryButton | {
value: string,
action: () => void
} | 否 | - | 第一个按钮。
value: 弹窗里主按钮的文本。
action: 点击主按钮的回调函数。 | - | secondaryButton | {
value: string,
action: () => void
} | 否 | - | 第二个按钮。
value: 弹窗里辅助按钮的文本。
action: 点击辅助按钮的回调函数。 | - | onStateChange | (isVisible: boolean) => void | 否 | - | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 | - -- CustomPopupOptions8+类型接口说明 - | 名称 | 类型 | 必填 | 默认值 | 描述 | - | -------- | -------- | -------- | -------- | -------- | - | builder | () => any | 是 | - | 提示气泡内容的构造器。 | - | placement | [Placement](ts-appendix-enums.md#placement8) | 否 | Placement.Bottom | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。 | - | arrowOffset9+ | Length | 否 | - | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧,默认居上。 | - | maskColor | [ResourceColor](../../ui/ts-types.md) | 否 | - | 提示气泡遮障层的颜色。 | - | popupColor | [ResourceColor](../../ui/ts-types.md) | 否 | - | 提示气泡的颜色。 | - | enableArrow | boolean | 否 | true | 是否显示箭头。
从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。 | - | autoCancel | boolean | 否 | true | 页面有操作时,是否自动关闭气泡 | - | onStateChange | (isVisible: boolean) => void | 否 | - | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | +| builder | [CustomBuilder](../../ui/ts-types.md) | 是 | 提示气泡内容的构造器。 | +| placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。
默认值:Placement.Bottom | +| arrowOffset9+ | [Length](../../ui/ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | +| maskColor | [ResourceColor](../../ui/ts-types.md) | 否 | 提示气泡遮障层的颜色。 | +| popupColor | [ResourceColor](../../ui/ts-types.md) | 否 | 提示气泡的颜色。 | +| enableArrow | boolean | 否 | 是否显示箭头。
从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。
默认值:true | +| autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡
默认值:true | +| onStateChange | (event: { isVisible: boolean }) => void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index 6c807d77f2bd40fc776f5a13fe4e770af314c6b3..8b5da5f79d8e6cdbe91031d2dd6c4836763b7fb8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -3,12 +3,8 @@ 用于设置组件的宽高、边距等显示尺寸进行设置。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 +> +> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md index 80e147ef093935853d2e861b35ae63706917a050..25e644f73d8a6523b051bea972a7aeff328c7f82 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -6,16 +6,12 @@ > > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - ## 事件 -| 名称 | 支持冒泡 | 功能描述 | -| ---------------------------------------- | ---- | --------------------------------- | -| onClick(callback: (event?: ClickEvent) => void) | 否 | 点击动作触发该方法调用,event参数见ClickEvent介绍。 | +| 名称 | 支持冒泡 | 功能描述 | +| ------------------------------------------------------------ | -------- | --------------------------------------------------- | +| onClick(event: (event?: ClickEvent) => void) | 否 | 点击动作触发该方法调用,event参数见ClickEvent介绍。 | ## ClickEvent对象说明 | 属性名称 | 类型 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md index b84246cdf3008cac0dbeca2f383919588d76c68c..c7eed9da294e19d917e8669ff57176c385995cff 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md @@ -3,20 +3,16 @@ 挂载卸载事件指组件从组件树上挂载、卸载时触发的事件。 > **说明:** +> > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - - ## 事件 -| 名称 | 支持冒泡 | 功能描述 | -| ---------------------------------------- | ---- | ------------- | -| onAppear(callback: () => void) | 否 | 组件挂载显示时触发此回调。 | -| onDisappear(callback: () => void) | 否 | 组件卸载消失时触发此回调。 | +| 名称 | 支持冒泡 | 功能描述 | +| ------------------------------------------------ | -------- | -------------------------- | +| onAppear(event: () => void) | 否 | 组件挂载显示时触发此回调。 | +| onDisappear(event: () => void) | 否 | 组件卸载消失时触发此回调。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md index bb905ccfd64f4f12aa1744b0e962dfd7c686d8c8..1cc889bcd5323976abdca059e4dda68e163f0185 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md @@ -3,19 +3,15 @@ 当手指放在组件上、滑动或从组件上移开时触发。 > **说明:** +> > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - - ## 事件 -| 名称 | 是否冒泡 | 功能描述 | -| ---------------------------------------- | ---- | ---------------------------------------- | -| onTouch(callback: (event?: TouchEvent) => void) | 是 | 触摸动作触发该方法调用,event参数见[TouchEvent](#touchevent对象说明)介绍。 | +| 名称 | 是否冒泡 | 功能描述 | +| ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | +| onTouch(event: (event?: TouchEvent) => void) | 是 | 触摸动作触发该方法调用,event参数见[TouchEvent](#touchevent对象说明)介绍。 | ## TouchEvent对象说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md index 543ad156586473e1a9ca6fc79b2e172bb54f6811..e435dd497eb3bb95c80393e8073560406e97c765 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md @@ -8,17 +8,12 @@ > - 目前仅支持通过外接键盘的tab键、方向键触发。 -## 权限列表 - -无 - - ## 事件 | **名称** | **支持冒泡** | **功能描述** | | -------- | -------- | -------- | -| onFocus(callback: () => void) | 否 | 当前组件获取焦点时触发的回调。 | -| onBlur(callback:() => void) | 否 | 当前组件失去焦点时触发的回调。 | +| onFocus(event: () => void) | 否 | 当前组件获取焦点时触发的回调。 | +| onBlur(event:() => void) | 否 | 当前组件失去焦点时触发的回调。 | > **说明:** > 支持焦点事件的组件:Button、Text、Image、List、Grid。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md index 2446fe5eca34c0b185793bacdab7ea0fe752c25f..cd618184f538eede08735b458bcf9727e002dd69 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md @@ -3,20 +3,16 @@ 在单个动作触发多个事件时,事件的顺序是固定的,鼠标事件默认透传。 > **说明:** +> > 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - - ## 事件 -| 名称 | 支持冒泡 | 描述 | -| ---------------------------------------- | ---- | ---------------------------------------- | -| onHover(callback: (isHover?: boolean) => void) | 否 | 鼠标进入或退出组件时触发该回调。
isHover:表示鼠标是否悬浮在组件上,鼠标进入时为true, 退出时为false。 | -| onMouse(callback: (event?: MouseEvent) => void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上移动时,触发该回调,event参数包含触发事件时的时间戳、鼠标按键、动作、点击触点在整个屏幕上的坐标和点击触点相对于当前组件的坐标。 | +| 名称 | 支持冒泡 | 描述 | +| ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | +| onHover(event: (isHover?: boolean) => void) | 否 | 鼠标进入或退出组件时触发该回调。
isHover:表示鼠标是否悬浮在组件上,鼠标进入时为true, 退出时为false。 | +| onMouse(event: (event?: MouseEvent) => void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上移动时,触发该回调,event参数包含触发事件时的时间戳、鼠标按键、动作、点击触点在整个屏幕上的坐标和点击触点相对于当前组件的坐标。 | ## MouseEvent对象说明 diff --git a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-custom-props.md b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-custom-props.md index 9d3a1fbf02c4de67afe52a6172f7cf265c30e3f0..9fdfc043b87ecd5ee5e5ac497df7c7fb75e6335e 100644 --- a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-custom-props.md +++ b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-custom-props.md @@ -76,3 +76,5 @@ ## 数据单向性 父子组件之间数据的传递是单向的,只能从父组件传递给子组件,子组件不能直接修改父组件传递下来的值,可以将props传入的值用data接收后作为默认值,再对data的值进行修改。 + +更多说明请参考[props](../arkui-js/js-components-custom-props.md)。 \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-component-based-preview.md b/zh-cn/application-dev/ui/ts-component-based-preview.md index 574ba980deb2eb261fe82c40ddf06729b66f3bd6..56220940ef921472f0047526434bfba0e05c0259 100644 --- a/zh-cn/application-dev/ui/ts-component-based-preview.md +++ b/zh-cn/application-dev/ui/ts-component-based-preview.md @@ -1,10 +1,10 @@ # @Preview -用@Preview装饰的自定义组件可以在DevEco Studio的预览器上进行预览,加载页面时,将创建并呈现@Preview装饰的自定义组件。 +用@Preview装饰的自定义组件可以在DevEco Studio的预览器上进行实时预览,不支持动态图和动态预览,加载页面时,将创建并呈现@Preview装饰的自定义组件。 > **说明:** -> 在单个源文件中,最多可以使用10个@Preview装饰自定义组件。 +> 在单个源文件中,最多可以使用10个@Preview装饰自定义组件,更多说明请参考[@Preview]( https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-previewing-app-service-0000001218760596#section146052489820 )。 @Preview的用法如下: @@ -15,46 +15,47 @@ @Entry @Component struct MyComponent { - build() { - Column() { - Row() { - Text('Hello World!') - .fontSize("50lpx") - .fontWeight(FontWeight.Bold) - } - Row() { - Component1() - } - Row() { - Component2() - } - } + build() { + Column() { + Row() { + Text('Hello World!') + .fontSize("50lpx") + .fontWeight(FontWeight.Bold) + } + Row() { + Component1() + } + Row() { + Component2() + } } + } } + @Preview @Component struct Component1 { - build() { - Column() { - Row() { - Text('Hello Component1') - .fontSize("50lpx") - .fontWeight(FontWeight.Bold) - } - } + build() { + Column() { + Row() { + Text('Hello Component1') + .fontSize("50lpx") + .fontWeight(FontWeight.Bold) + } } + } } @Component struct Component2 { - build() { - Column() { - Row() { - Text('Hello Component2') - .fontSize("50lpx") - .fontWeight(FontWeight.Bold) - } - } + build() { + Column() { + Row() { + Text('Hello Component2') + .fontSize("50lpx") + .fontWeight(FontWeight.Bold) + } } + } } ``` diff --git a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index 7057e34756c738d113ba3e65bc67d51c86491a20..d048a2579e1835856250d2882361cdbb9b68dbda 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md +++ b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -5,10 +5,10 @@ ## 生命周期回调函数定义 -| 函数名 | 描述 | -| ---------------- | ---------------------------------------- | +| 函数名 | 描述 | +| ---------------- | ------------------------------------------------------------ | | aboutToAppear | 函数在创建自定义组件的新实例后,在执行其build函数之前执行。允许在aboutToAppear函数中改变状态变量,更改将在后续执行build函数中生效。 | -| aboutToDisappear | 函数在自定义组件析构消耗之前执行。不允许在aboutToDisappear函数中改变状态变量,特别是@Link变量的修改可能会导致应用程序行为不稳定。 | +| aboutToDisappear | 函数在自定义组件析构销毁之前执行。不允许在aboutToDisappear函数中改变状态变量,特别是@Link变量的修改可能会导致应用程序行为不稳定。 | | onPageShow | 页面显示时触发一次,包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。 | | onPageHide | 页面消失时触发一次,包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。 | | onBackPress | 当用户点击返回按钮时触发,仅\@Entry修饰的自定义组件生效。
- 返回true表示页面自己处理返回逻辑, 不进行页面路由。
- 返回false表示使用默认的返回逻辑。
- 不返回值会作为false处理。 | diff --git a/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md b/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md index b20f704d1150f8df495603794142d77bac6786b3..e37724ed2f5d44cf9557e36bcc072f7430a81658 100644 --- a/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md +++ b/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md @@ -257,4 +257,45 @@ struct MyComponent { }.backgroundColor(Color.Pink) } } -``` \ No newline at end of file +``` + +## 减少应用滑动白块 +应用通过增大List/Grid控件的cachedCount参数,调整UI的加载范围。cachedCount表示屏幕外List/Grid预加载item的个数。 +如果需要请求网络图片,可以在item滑动到屏幕显示之前,提前下载好内容,从而减少滑动白块。 +如下是使用cachedCount参数的例子: + +```ts +@Entry +@Component +struct MyComponent { + private source: MyDataSource = new MyDataSource(); + build() { + List() { + LazyForEach (this.source, item => { + ListItem() { + Text("Hello" + item) + .fontSize(100) + .onAppear(()=>{ + console.log("appear:" + item) + }) + } + }) + }.cachedCount(3) // 扩大数值appear日志范围会变大 + } +} +class MyDataSource implements IDataSource { + data: number[] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; + public totalCount(): number { + return this.data.length + } + public getData(index: number): any { + return this.data[index] + } + registerDataChangeListener(listener: DataChangeListener): void { + } + unregisterDataChangeListener(listener: DataChangeListener): void { + } +} +``` +**使用说明:** +cachedCount的增加会增大UI的cpu、内存开销。使用时需要根据实际情况,综合性能和用户体验进行调整。 \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-ts-local-storage.md b/zh-cn/application-dev/ui/ui-ts-local-storage.md index 2783deec24275cd83132049403ee8137ed22ae27..5330f574b0540c5613138558319e46fa155771d0 100644 --- a/zh-cn/application-dev/ui/ui-ts-local-storage.md +++ b/zh-cn/application-dev/ui/ui-ts-local-storage.md @@ -278,6 +278,8 @@ clear(): boolean ### 示例1(在一个Ability创建的LocalStorage) +LocalStorage通过loadContent接口加载,接口详见[loadContent](../reference/apis/js-apis-window.md#loadcontent9-1)。 + ```ts import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { @@ -291,6 +293,7 @@ export default class MainAbility extends Ability { console.log("[Demo MainAbility onDestroy]") } onWindowStageCreate(windowStage) { + // storage作为参数传递给loadContent接口。 windowStage.loadContent("pages/index",this.storage) } onWindowStageDestroy() { diff --git a/zh-cn/application-dev/windowmanager/application-window-fa.md b/zh-cn/application-dev/windowmanager/application-window-fa.md index 485b43fcb6ebbd6448d46245e23666830fdd5815..f8e762f4b3ac76f83f294f05d656eeb0d8c1c947 100644 --- a/zh-cn/application-dev/windowmanager/application-window-fa.md +++ b/zh-cn/application-dev/windowmanager/application-window-fa.md @@ -184,7 +184,7 @@ - 方式一:调用`setFullScreen`接口,设置应用主窗口为全屏显示,此时导航栏、状态栏将隐藏,从而达到沉浸式效果。 - 方式二:调用`setSystemBarEnable`接口,设置导航栏、状态栏不显示,从而达到沉浸式效果。 - - 方式三:调用`setLayoutFullScreen`接口,设置应用主窗口为全屏布局;然后调用`setSystemPropertites`接口,设置导航栏、状态栏的透明度、背景/文字颜色以及高亮图标等属性,使之保持与主窗口显示协调一致,从而达到沉浸式效果。 + - 方式三:调用`setLayoutFullScreen`接口,设置应用主窗口为全屏布局;然后调用`setSystemProperties`接口,设置导航栏、状态栏的透明度、背景/文字颜色以及高亮图标等属性,使之保持与主窗口显示协调一致,从而达到沉浸式效果。 ```js // 2.实现沉浸式效果。方式一:设置窗口全屏显示。 diff --git a/zh-cn/application-dev/windowmanager/application-window-stage.md b/zh-cn/application-dev/windowmanager/application-window-stage.md index 658f09d856f16779e255a303e92c4b9573a6b3a7..3fa18395aa66de772bcff1c225b16d2b4f4b6b29 100644 --- a/zh-cn/application-dev/windowmanager/application-window-stage.md +++ b/zh-cn/application-dev/windowmanager/application-window-stage.md @@ -208,7 +208,7 @@ class MainAbility extends Ability { 2. 实现沉浸式效果。有以下三种方式: - 方式一:调用`setFullScreen`接口,设置应用主窗口为全屏显示,此时导航栏、状态栏将隐藏,从而达到沉浸式效果。 - 方式二:调用`setSystemBarEnable`接口,设置导航栏、状态栏不显示,从而达到沉浸式效果。 - - 方式三:调用`setLayoutFullScreen`接口,设置应用主窗口为全屏布局;然后调用`setSystemPropertites`接口,设置导航栏、状态栏的透明度、背景/文字颜色以及高亮图标等属性,使之保持与主窗口显示协调一致,从而达到沉浸式效果。 + - 方式三:调用`setLayoutFullScreen`接口,设置应用主窗口为全屏布局;然后调用`setSystemProperties`接口,设置导航栏、状态栏的透明度、背景/文字颜色以及高亮图标等属性,使之保持与主窗口显示协调一致,从而达到沉浸式效果。 3. 加载显示沉浸式窗口的具体内容。 通过`loadContent`和`show`接口加载显示沉浸式窗口的具体内容。 diff --git a/zh-cn/device-dev/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index 51da362bd4425ecca22d32a9f365436bbf563259..5d292301578abdb62b5a3f809fa918507523b23e 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -38,7 +38,7 @@ - [图形图像](subsystems/subsys-graphics-overview.md) - [媒体](subsystems/subsys-multimedia-camera-overview.md) - [公共基础](subsystems/subsys-utils-overview.md) - - [AI框架](subsystems/subsys-aiframework-guide.md) + - [AI框架](subsystems/subsys-ai-aiframework-devguide.md) - [数据管理](subsystems/subsys-data-relational-database-overview.md) - [Sensor服务](subsystems/subsys-sensor-overview.md) - [USB服务](subsystems/subsys-usbservice-overview.md) diff --git a/zh-cn/device-dev/driver/Readme-CN.md b/zh-cn/device-dev/driver/Readme-CN.md index 795f2ff1defaf0672b1a8e8f8cef8210701ba53a..a809e96b62d744563e1570622efb68bab47fa835 100755 --- a/zh-cn/device-dev/driver/Readme-CN.md +++ b/zh-cn/device-dev/driver/Readme-CN.md @@ -1,5 +1,6 @@ # 驱动使用指南 +- [驱动概述](driver-overview-foundation.md) - HDF驱动框架 - [HDF开发概述](driver-hdf-overview.md) - [驱动开发](driver-hdf-development.md) diff --git a/zh-cn/device-dev/driver/driver-overview-foundation.md b/zh-cn/device-dev/driver/driver-overview-foundation.md new file mode 100644 index 0000000000000000000000000000000000000000..c7c7f10eb346f11ccccc5f758771d1ed6b8d745d --- /dev/null +++ b/zh-cn/device-dev/driver/driver-overview-foundation.md @@ -0,0 +1,94 @@ +# 概述 + + +## 简介 + +OpenHarmony采用多内核(Linux内核或者LiteOS)设计,支持系统在不同资源容量的设备部署。当相同的硬件部署不同内核时,如何能够让设备驱动程序在不同内核间平滑迁移,消除驱动代码移植适配和维护的负担,是OpenHarmony驱动子系统需要解决的重要问题。 + +为了缩减驱动开发者的驱动开发周期,降低三方设备驱动集成难度,OpenHarmony驱动子系统支持以下关键特性和能力。 + +- 弹性化的框架能力 + 在传统的驱动框架能力的基础上,OpenHarmony驱动子系统通过构建弹性化的框架能力,可支持在百K级别到百兆级容量的终端产品形态部署。 + +- 规范化的驱动接口 + 定义了常见驱动接口,为驱动开发者和使用者提供丰富、稳定接口,并和未来开放的面向手机、平板、智慧屏等设备驱动接口保持API兼容性。 + +- 组件化的驱动模型 + 支持组件化的驱动模型,为开发者提供更精细化的驱动管理,开发者可以对驱动进行组件化拆分,使得驱动开发者可以更多关注驱动与硬件交互部分。同时系统也预置了部分模板化的驱动模型组件,如网络设备模型等。 + +- 归一化的配置界面 + 提供统一的配置界面,构建跨平台的配置转换和生成工具,实现跨平台的无缝切换。 + + +## 驱动架构 + +HDF(Hardware Driver Foundation)驱动框架,为驱动开发者提供驱动框架能力,包括驱动加载、驱动服务管理和驱动消息机制。旨在构建统一的驱动架构平台,为驱动开发者提供更精准、更高效的开发环境,力求做到一次开发,多系统部署。 + +HDF驱动架构采用C语言面向对象编程模型构建,通过平台解耦、内核解耦,来达到兼容不同内核,统一平台底座的目的。HDF驱动框架架构如下图所示。 + + **图1** HDF驱动框架架构图   + +![zh-cn_image_0000001351387426](figures/zh-cn_image_0000001351387426.png) + +HDF驱动架构主要组成部分: + +- HDI(Hardware Device Interface,硬件设备统一接口)层:通过规范化的设备接口标准,为系统提供统一、稳定的硬件设备操作接口。 + +- HDF驱动框架:提供统一的硬件资源管理、驱动加载管理、设备节点管理、设备电源管理以及驱动服务模型等功能,需要包含设备管理、服务管理、DeviceHost、PnPManager等模块。 + +- 统一的配置界面:支持硬件资源的抽象描述,屏蔽硬件差异,可以支撑开发者开发出与配置信息不绑定的通用驱动代码,提升开发及迁移效率,并可通过HC-Gen等工具快捷生成配置文件。 + +- 操作系统抽象层(OSAL,Operating System Abstraction Layer):提供统一封装的内核操作相关接口,屏蔽不同系统操作差异,包含内存、锁、线程、信号量等接口。 + +- 平台驱动**:**为外设驱动提供Board硬件(如:I2C/SPI/UART总线等平台资源)操作统一接口,同时对Board硬件操作进行统一的适配接口抽象以便于不同平台迁移。 + +- 外设驱动模型:面向外设驱动,提供常见的驱动抽象模型,主要达成两个目的,提供标准化的器件驱动,开发者无需独立开发,通过配置即可完成驱动的部署;提供驱动模型抽象,屏蔽驱动与不同系统组件间的交互,使得驱动更具备通用性。 + + +## 驱动开发 + + +### 平台驱动 + +OpenHarmony平台驱动(Platform Driver),即平台设备(Platform Device)驱动,为系统及外设驱动提供访问接口。这里的平台设备,泛指I2C/UART等总线、以及GPIO/RTC等特定硬件资源。平台驱动框架是OpenHarmony驱动框架的重要组成部分,它基于HDF驱动框架、操作系统适配层以及驱动配置管理机制,为各类平台设备驱动的实现提供标准模型。平台驱动框架为外设提供了标准的平台设备访问接口,使其不必关注具体硬件;同时为平台设备驱动提供统一的适配接口,使其只关注自身硬件的控制。 + +平台驱动框架提供如下特性: + +- 统一的平台设备访问接口:对平台设备操作接口进行统一封装,屏蔽不同SoC平台硬件差异以及不同OS形态差异。 + +- 统一的平台驱动适配接口:为平台设备驱动提供统一的适配接口,使其只关注自身硬件的控制,而不必关注设备管理及公共业务流程。 + +- 提供设备注册、管理、访问控制等与SoC无关的公共能力。 + +平台驱动框架目前支持的设备类型包括但不限于:ADC、DAC、GPIO、HDMI、I2C、I3C、MIPI_CSI、MIPI_DSI、MMC、Pin、PWM、Regulator、RTC、SDIO、SPI、UART、WatchDog等。 + + +### 外设驱动 + +OpenHarmony在HDF驱动框架及平台驱动框架的基础上,面向外设器件驱动,提供常见的驱动抽象模型。它提供标准化的外设器件驱动,可以减少重复开发;同时提供统一的外设驱动模型抽象,屏蔽驱动与不同系统组件间的交互,使得驱动更具备通用性。 + +OpenHarmony当前支持的外设设备类型包括但不限于:Audio、Camera、Codec、Face_auth、Fingerprint_auth、LCD、Light、Motion、Pin_auth、Sensor、Touchscreen、USB、User_auth、Vibrator、WLAN等。 + + +### 驱动代码仓 + +HDF驱动架构实现根据功能和模块分为多个代码仓,如下表所示。 + + **表1** HDF驱动架构代码仓说明表 + +| 仓库路径 | 仓库内容 | +| -------- | -------- | +| drivers/hdf_core/framework | HDF框架、平台驱动框架、驱动模型等平台无关化的公共框架。
- framework/core目录:驱动框架
  - 提供驱动框架能力,主要完成驱动加载和启动功能。
  - 通过对象管理器方式可实现驱动框架的弹性化部署和扩展。
- framework/model目录:驱动模型
  提供了模型化驱动能力,如网络设备模型。
- framework/ability目录:驱动能力库
  提供基础驱动能力模型,如IO通信能力模型。
- framework/tools目录:驱动工具
  提供HDI接口转换、驱动配置编译等工具。
- framework/support目录:Support
  提供规范化的平台驱动接口和系统接口抽象能力。 | +| drivers/hdf_core/adapter | 包含所有LiteOS-M和LiteOS-A内核以及用户态接口库等相关适配代码以及编译脚本。 | +| drivers/hdf_core//adapter/khdf/linux | 包含所有Linux内核相关适配代码以及编译脚本。 | +| drivers/peripheral | Display、Input、Sensor、WLAN、Audio、Camera等外设模块硬件抽象层。 | +| drivers/interface | Display、Input、Sensor、WLAN、Audio、Camera等外设模块HDI接口定义。 | + + +### 使用指导 + +- 当您需要为新的平台设备适配OpenHarmony驱动时,可使用OpenHarmony平台驱动框架提供的标准模型和统一的适配接口,这样您只需要关注自身硬件的控制,而不必关注设备管理及公共业务流程。平台设备的驱动适配操作,可参考“平台驱动开发”章节。 + +- 平台驱动适配完成后,您可以使用OpenHarmony平台驱动框架为系统及外设驱动提供的统一访问接口进行进一步的服务和应用的开发,而不必关注具体硬件及OS平台的差异。平台驱动提供的访问接口的使用方法,可参考“平台驱动使用”章节。 + +- OpenHarmony驱动架构为用户提供了多种标准外设驱动模型。这些模型屏蔽硬件差异,为上层服务提供稳定、标准的接口。您可以基于这些模型进行外设驱动的开发,不同类型的外设采用不同的模型,详细的使用方法可参考“外设驱动使用”章节。 diff --git a/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md b/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md index b7e27914d9d268c4684e9d82bcaff0225951eeac..0134b7f8096875b6a83cb38d88e5938c13a491b4 100755 --- a/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md @@ -273,7 +273,7 @@ MIPI CSI模块适配的三个必选环节是配置属性文件、实例化驱动 return ret; } - // mipi_dsi_core.c核心层 + // mipi_csi_core.c核心层 int32_t MipiCsiRegisterCntlr(struct MipiCsiCntlr *cntlr, struct HdfDeviceObject *device) { ... diff --git a/zh-cn/device-dev/driver/figures/zh-cn_image_0000001351387426.png b/zh-cn/device-dev/driver/figures/zh-cn_image_0000001351387426.png new file mode 100644 index 0000000000000000000000000000000000000000..f5a9516d532f8668bf7468d471e235c93fcb6296 Binary files /dev/null and b/zh-cn/device-dev/driver/figures/zh-cn_image_0000001351387426.png differ diff --git a/zh-cn/device-dev/kernel/Readme-CN.md b/zh-cn/device-dev/kernel/Readme-CN.md index 4ba84361fe445c858c93fc7ae40e6c9ff4ba4ad8..fdf8a89b75fc4cf20e9a84fd61fd92976ae32740 100755 --- a/zh-cn/device-dev/kernel/Readme-CN.md +++ b/zh-cn/device-dev/kernel/Readme-CN.md @@ -1,6 +1,7 @@ # kernel - 内核 + - [内核概述](kernel-overview.md) - 轻量系统内核 - [内核概述](kernel-mini-overview.md) - 基础内核 diff --git a/zh-cn/device-dev/kernel/figures/1661308214897.png b/zh-cn/device-dev/kernel/figures/1661308214897.png new file mode 100644 index 0000000000000000000000000000000000000000..7910e33f0080418fa5c9a7bdfca21f17e0d1a250 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/1661308214897.png differ diff --git a/zh-cn/device-dev/kernel/figures/1_zh-cn_image_0000001128794202.png b/zh-cn/device-dev/kernel/figures/1_zh-cn_image_0000001128794202.png new file mode 100644 index 0000000000000000000000000000000000000000..2a836c5df257e6ea9a92c514a77dbeabfb95c890 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/1_zh-cn_image_0000001128794202.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001388170721.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001388170721.png new file mode 100644 index 0000000000000000000000000000000000000000..5298d0a120ed2c5c37c5d35f2b7da9fe9bbc5990 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001388170721.png differ diff --git "a/zh-cn/device-dev/kernel/figures/\345\206\205\346\240\270.png" "b/zh-cn/device-dev/kernel/figures/\345\206\205\346\240\270.png" new file mode 100644 index 0000000000000000000000000000000000000000..aab178cde608403d259af3cd10c11188e213de08 Binary files /dev/null and "b/zh-cn/device-dev/kernel/figures/\345\206\205\346\240\270.png" differ diff --git a/zh-cn/device-dev/kernel/kernel-overview.md b/zh-cn/device-dev/kernel/kernel-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..66b00c70b82c0d51e39776e120889629f0d3cadd --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-overview.md @@ -0,0 +1,177 @@ +# 内核概述 + + +### 内核简介 + +用户最常见到并与之交互的操作系统界面,其实只是操作系统最外面的一层。操作系统最重要的任务,包括管理硬件设备,分配系统资源等,我们称之为操作系统内在最重要的核心功能。而实现这些核心功能的操作系统模块,业界一般称之为操作系统“内核”。 + + +### 实现原理 + +操作系统是位于应用和硬件之间的系统软件,向上提供易用的程序接口和运行环境,向下管理硬件资源。内核位于操作系统的下层,为操作系统上层的程序框架提供硬件资源的并发管理。 + + **图1** 操作系统架构  +  + ![zh-cn_image_0000001388170721](figures/zh-cn_image_0000001388170721.png) + + +### 多内核架构和基本组成 + +业界的内核有很多,但无论是什么内核,基本上有几个最重要的组成单元是每个内核均要具备的,分别是: + +- 负责持久化数据,并让应用程序能够方便的访问持久化数据的“文件系统”。 + +- 负责管理进程地址空间的“内存管理”。 + +- 负责管理多个进程的“进程管理”或者“任务管理“。 + +- 负责本机操作系统和另外一个设备上操作系统通信的“网络”。 + +OpenHarmony采用了多内核结构,支持Linux和LiteOS,开发者可按不同产品规格进行选择使用。linux和LiteOS均具备上述组成单元,只是实现方式有所不同。多个内核通过KAL(Kernel Abstraction Layer)模块,向上提供统一的标准接口。 + +内核子系统位于OpenHarmony下层。需要特别注意的是,由于OpenHarmony面向多种设备类型,这些设备有着不同的CPU能力,存储大小等。为了更好的适配这些不同的设备类型,内核子系统支持针对不同资源等级的设备选用适合的OS内核,内核抽象层(KAL,Kernel Abstract Layer)通过屏蔽内核间差异,对上层提供基础的内核能力。 + + **图2** OpenHarmony架构图  + +  + ![1_zh-cn_image_0000001128794202](figures/1_zh-cn_image_0000001128794202.png) + + +### 不同内核适配的系统及设备类型 + +OpenHarmony按照支持的设备可分为如下几种系统类型: + +- 轻量系统(mini system) + 面向MCU类处理器例如Arm Cortex-M、RISC-V 32位的设备,硬件资源极其有限,支持的设备最小内存为128KiB,可以提供多种轻量级网络协议,轻量级的图形框架,以及丰富的IOT总线读写部件等。可支撑的产品如智能家居领域的连接类模组、传感器设备、穿戴类设备等。 + +- 小型系统(small system) + 面向应用处理器例如Arm Cortex-A的设备,支持的设备最小内存为1MiB,可以提供更高的安全能力、标准的图形框架、视频编解码的多媒体能力。可支撑的产品如智能家居领域的IP Camera、电子猫眼、路由器以及智慧出行域的行车记录仪等。 + +- 标准系统(standard system) + 面向应用处理器例如Arm Cortex-A的设备,支持的设备最小内存为128MiB,可以提供增强的交互能力、3D GPU以及硬件合成能力、更多控件以及动效更丰富的图形能力、完整的应用框架。可支撑的产品如高端的冰箱显示屏。 + +OpenHarmony针对不同量级的系统,使用了不同形态的内核。轻量系统、小型系统可以选用LiteOS;小型系统和标准系统可以选用Linux。其对应关系如下表: + + **表1** 系统关系对应表 + +| 系统级别 | 轻量系统 | 小型系统 | 标准系统 | +| -------- | -------- | -------- | -------- | +| LiteOS-M | √ | × | × | +| LiteOS-A | × | √ | √ | +| Linux | × | √ | √ | + + +## LiteOS-M + + +### 内核架构 + +OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系统内核,具有小体积、低功耗、高性能的特点,其代码结构简单,主要包括内核最小功能集、内核抽象层、可选组件以及工程目录等,分为硬件相关层以及硬件无关层,硬件相关层提供统一的HAL(Hardware Abstraction Layer)接口,提升硬件易适配性,不同编译工具链和芯片架构的组合分类,满足AIoT类型丰富的硬件和编译工具链的拓展。 + + **图3** LiteOS-M架构图   + + ![内核](figures/内核.png) + + +### 使用指导 + +LiteOS-M使用指导请参见LiteOS-M[内核概述](kernel-mini-overview.md)的“使用说明”章节。 + + +## LiteOS-A + + +### 内核架构 + +OpenHarmony 轻量级内核是基于IoT领域轻量级物联网操作系统Huawei LiteOS内核演进发展的新一代内核,包含LiteOS-M和LiteOS-A两类内核。LiteOS-M内核主要应用于轻量系统,面向的MCU(Microprocessor Unit)一般是百K级内存,可支持MPU(Memory Protection Unit)隔离,业界类似的内核有FreeRTOS或ThreadX等;LiteOS-A内核主要应用于小型系统,面向设备一般是M级内存,可支持MMU(Memory Management Unit)隔离,业界类似的内核有Zircon或Darwin等。 + +为适应IoT产业的高速发展,OpenHarmony 轻量级内核不断优化和扩展,能够带给开发者友好的开发体验和统一开放的生态系统能力。轻量级内核LiteOS-A重要的新特性如下: + +- 新增了丰富的内核机制: + - 新增虚拟内存、系统调用、多核、轻量级IPC(Inter-Process Communication,进程间通信)、DAC(Discretionary Access Control,自主访问控制)等机制,丰富了内核能力; + - 为了更好的兼容软件和开发者体验,新增支持多进程,使得应用之间内存隔离、相互不影响,提升系统的健壮性。 + +- 引入统一驱动框架HDF(Hardware Driver Foundation) + + 引入统一驱动框架HDF,统一驱动标准,为设备厂商提供了更统一的接入方式,使驱动更加容易移植,力求做到一次开发,多系统部署。 + +- 支持1200+标准POSIX接口 + + 更加全面的支持POSIX标准接口,使得应用软件易于开发和移植,给应用开发者提供了更友好的开发体验。 + +- 内核和硬件高解耦 + + 轻量级内核与硬件高度解耦,新增单板,内核代码不用修改。 + + **图4** OpenHarmony LiteOS-A内核架构图  + + ![1661308214897](figures/1661308214897.png) + + +### 使用指导 + +LiteOS-A使用指导请参见LiteOS-A[内核概述](kernel-small-overview.md)的“使用说明”章节。 + + +## Linux + + +### linux内核概述 + +OpenHarmony的Linux内核基于开源Linux内核LTS **4.19.y / 5.10.y** 分支演进,在此基线基础上,回合CVE补丁及OpenHarmony特性,作为OpenHarmony Common Kernel基线。针对不同的芯片,各厂商合入对应的板级驱动补丁,完成对OpenHarmony的基线适配。 + +- Linux社区LTS 4.19.y分支信息请查看[kernel官网](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/?h=linux-4.19.y)。 + +- Linux社区LTS 5.10.y分支信息请查看[kernel官网](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/?h=linux-5.10.y)。 + +内核的Patch组成模块,在编译构建流程中,针对具体芯片平台,合入对应的架构驱动代码,进行编译对应的内核镜像。所有补丁来源均遵守GPL-2.0协议。 + + +### 内核增强特性 + +OpenHarmony针对linux内核在ESwap(Enhanced Swap)、关联线程组调度和CPU轻量级隔离做了增强。 + +**Enhanced SWAP特性** + +ESwap提供了自定义新增存储分区作为内存交换分区的能力,并创建了一个常驻进程zswapd将[ZRAM](https://gitee.com/link?target=https%3A%2F%2Fwww.kernel.org%2Fdoc%2Fhtml%2Flatest%2Fadmin-guide%2Fblockdev%2Fzram.html)压缩后的匿名页加密换出到ESwap存储分区,从而能完全的空出一块可用内存,以此来达到维持Memavailable水线的目标。同时,配合这个回收机制,在整个内存框架上进行改进,优化匿名页和文件页的回收效率,并且使两者的回收比例更加合理以避免过度回收导致的refault问题造成卡顿现象。 + +**关联线程组调度** + +关联线程组(related thread group)提供了对一组关键线程调度优化的能力,支持对关键线程组单独进行负载统计和预测,并且设置优选CPU cluster功能,从而达到为组内线程选择最优CPU运行并且根据分组负载选择合适的CPU调频点运行。 + +**CPU轻量级隔离** + +CPU轻量级隔离特性提供了根据系统负载和用户配置来选择合适的CPU进行动态隔离的能力。内核会将被隔离CPU上的任务和中断迁移到其他合适的CPU上执行,被隔离的CPU会进入ilde状态,以此来达到功耗优化的目标。同时提供用户态的配置和查询接口来实现更好的系统调优。 + + +### 使用指导 + +1. 合入HDF补丁 + 在kernel/linux/build仓中,按照kernel.mk中HDF的补丁合入方法,合入不同内核版本对应的HDF内核补丁: + + ``` + $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) + ``` + +2. 合入芯片平台驱动补丁 + 以Hi3516DV300为例: + + 在kernel/linux/build仓中,按照kernel.mk中的芯片组件所对应的patch路径规则及命名规则,将对应的芯片组件patch放到对应路径下: + + ``` + DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch + DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch + ``` + +3. 修改自己所需要编译的config + 在kernel/linux/build仓中,按照kernel.mk中的芯片组件所对应的patch路径规则及命名规则,将对应的芯片组件config放到对应路径下: + + ``` + KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION}DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig + ``` + + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 由于OpenHarmony工程的编译构建流程中会拷贝kernel/linux/linux-\*.\*的代码环境后进行打补丁动作,在使用OpenHarmony的版本级编译命令前,需要kernel/linux/linux-\*.\*原代码环境。 + > + > 根据不同系统工程,编译完成后会在out目录下的kernel目录中生成对应实际编译的内核,基于此目录的内核,进行对应的config修改,将最后生成的.config文件cp到config仓对应的路径文件里,即可生效。 + diff --git a/zh-cn/device-dev/porting/porting-minichip-subsys-communication.md b/zh-cn/device-dev/porting/porting-minichip-subsys-communication.md index 39b8b91d48c10618e6ca6c4d33faaa515e9aa61a..f4bcb06e844dccb0a41732c02006d49dae391124 100644 --- a/zh-cn/device-dev/porting/porting-minichip-subsys-communication.md +++ b/zh-cn/device-dev/porting/porting-minichip-subsys-communication.md @@ -109,7 +109,7 @@ group("wifi") { ## 适配实例 -1. 在“config.json”中添加iot_hardware子系统。 +1. 在“config.json”中添加communication子系统。 路径:“vendor/MyVendorCompany/MyProduct/config.json” 修改如下: diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md index fe9c9c1a1facab4a854539c7ca6757ed20c09331..83a47bd474a7cd364e8365801c87c9c8cc54bd10 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md @@ -54,7 +54,7 @@ RK3568的镜像烧录通过Winodow环境进行烧录,开发者启动烧录操 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - > 如果开发板未处于烧录模式,屏幕会提示“The boad is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击RESET键,然后再过3秒放开音量+键,使开发板进入烧录模式。 + > 如果开发板未处于烧录模式,屏幕会提示“The board is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击RESET键,然后再过3秒放开音量+键,使开发板进入烧录模式。 等待开发板烧录完成,当屏幕提示如下信息时,表示烧录成功。 diff --git a/zh-cn/device-dev/security/security-guidelines-overall.md b/zh-cn/device-dev/security/security-guidelines-overall.md index 9eecdc9eb82ae88918ee1e21fe5afbb266c93015..09e0440bdcd0eb3e20505eef7724ae1c39e7ffc8 100644 --- a/zh-cn/device-dev/security/security-guidelines-overall.md +++ b/zh-cn/device-dev/security/security-guidelines-overall.md @@ -94,7 +94,7 @@ OpenHarmony操作系统是一个开放的系统,开发者可以通过OpenHarmo ### 安全机制 -HUKS(Huawei Universal Keystore Service),提供了密钥管理、证书管理服务,当前在OpenHarmony上主要提供密钥管理服务,用于支撑HiChain(设备身份认证平台)的基础设备认证。如下是HUKS的功能结构图: +HUKS(OpenHarmony Universal Keystore Service),提供了密钥管理、证书管理服务,当前在OpenHarmony上主要提供密钥管理服务,用于支撑HiChain(设备身份认证平台)的基础设备认证。如下是HUKS的功能结构图: **图3** HUKS功能结构图 ![zh-cn_image_0000001159520844](figures/zh-cn_image_0000001159520844.png) diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index 3fcac88fe7a7fc5e4781fadf0004d85c992eacaf..cd6ee0c774bbc1c9956116fa761904b8bcaae25f 100755 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -39,21 +39,7 @@ - [公共基础库概述](subsys-utils-overview.md) - [公共基础库开发指导](subsys-utils-guide.md) - [公共基础库常见问题](subsys-utils-faqs.md) -- AI框架 - - [概述](subsys-aiframework-guide.md) - - [搭建环境](subsys-aiframework-envbuild.md) - - 技术规范 - - [代码管理规范](subsys-aiframework-tech-codemanage.md) - - [命名规范](subsys-aiframework-tech-name.md) - - [接口开发规范](subsys-aiframework-tech-interface.md) - - 开发指导 - - [SDK开发过程](subsys-aiframework-devguide-sdk.md) - - [插件的开发过程](subsys-aiframework-devguide-plugin.md) - - [配置文件的开发过程](subsys-aiframework-devguide-conf.md) - - 开发示例 - - [唤醒词识别SDK的开发示例](subsys-aiframework-demo-sdk.md) - - [唤醒词识别插件的开发示例](subsys-aiframework-demo-plugin.md) - - [唤醒词识别配置文件的开发示例](subsys-aiframework-demo-conf.md) +- [AI框架开发指导](subsys-ai-aiframework-devguide.md) - 数据管理 - 关系型数据库 - [关系型数据库概述](subsys-data-relational-database-overview.md) diff --git a/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md b/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md new file mode 100644 index 0000000000000000000000000000000000000000..95590434713f2f5cdcbf08c280794bec6c2711ac --- /dev/null +++ b/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md @@ -0,0 +1,520 @@ +# AI框架开发指导 + +## 概述 + +### 功能简介 +AI业务子系统是OpenHarmony提供原生的分布式AI能力的子系统。AI业务子系统提供了统一的AI引擎框架,实现算法能力快速插件化集成。 +AI引擎框架主要包含插件管理、模块管理和通信管理模块,完成对AI算法能力的生命周期管理和按需部署。插件管理主要实现插件的生命周期管理及插件的按需部署,快速集成AI能力插件;模块管理主要实现任务的调度及管理客户端的实例;通信管理主要实现客户端和服务端之间的跨进程通信管理及AI服务与插件之间的数据传输。后续,会逐步定义统一的AI能力接口,便于AI能力的分布式调用。同时,框架提供适配不同推理框架层级的统一推理接口。 +AI引擎框架结构如下图所示。 + + + **图1** AI引擎框架 + ![zh-cn_image_0000001200128073](figures/zh-cn_image_0000001200128073.png) + +### 搭建环境 + + +1. 准备开发板:Hi3516DV300或Hi3518EV300 + +2. [下载源码](../get-code/sourcecode-acquire.md) + +## 技术规范 + +### 代码管理规范 + +AI引擎框架包含client、server和common三个主要模块,其中client提供server端连接管理功能,北向SDK在算法对外接口中需封装调用client提供的公共接口;server提供插件加载以及任务管理等功能,各Plugin实现由server提供的插件接口,完成插件接入;common提供与平台相关的操作方法、引擎协议以及相关工具类,供其他各模块调用。 + + +AI引擎框架各模块之间的代码依赖关系如下图所示: + + + **图1** AI引擎代码依赖关系 + + ![zh-cn_image_0000001151931738](figures/zh-cn_image_0000001151931738.jpg) + + +#### 建议:插件与北向SDK在AI引擎指定的路径下进行代码开发 + +在AI引擎框架的整体规划中,北向SDK属于client端的一部分,插件由server端调用,属于server端的一部分,因此AI引擎框架为接入的插件与北向SDK规划的路径: + +- SDK代码路径://foundation/ai/engine/services/client/algorithm_sdk + + 示例1://foundation/ai/engine/services/client/algorithm_sdk/cv + + 示例2://foundation/ai/engine/services/client/algorithm_sdk/nlu + +- 插件代码路径://foundation/ai/engine/services/server/plugin + + 示例1://foundation/ai/engine/services/server/plugin/cv + + 示例2://foundation/ai/engine/services/server/plugin/nlu + + +#### 规则:插件提供的全部对外接口,统一存放在AI业务子系统interfaces/kits目录 + +北向SDK对外接口是AI业务子系统提供能力的对外暴露方式,按照OpenHarmony的接口管理要求,需统一存放在各子系统的interfaces/kits目录中。当前AI业务子系统插件对外接口路径为//foundation/ai/engine/interfaces/kits,不同插件可在该路径下添加目录,比如增加cv插件,则在路径//foundation/ai/engine/interfaces/kits/cv下面存放接口文件。 + + +#### 规则:插件编译输出路径必须是在/usr/lib + +server端加载插件是采用dlopen方式,只支持在/usr/lib路径进行,因此插件在编译so时,需要在编译配置文件中指定输出路径为/usr/lib。 + +### 命名规范 + +#### SDK命名规则:领域_关键词<_其他信息1_其他信息2_…>_sdk.so + +关于领域,建议使用当前主流简称,比如图片视频相关的使用"cv",语音识别相关的使用“asr”,翻译相关的使用“translation”等,存在其他领域的可增加定义;关键词则需要恰当准确的描述所对应插件的算法能力,比如唤醒词识别,则使用keyword_spotting;对于其他信息,比如插件支持的芯片类型、国内海外等信息,可在关键词与“sdk”之间依次添加,信息之间以下划线连接;SDK命名,必须以“_sdk”结尾。 + +例如:唤醒词识别插件对应的SDK,只支持麒麟9000芯片,适用于中国国内地区适用,则对应的SDK命名为:asr_keyword_spotting_kirin9000_china_sdk.so + + +#### 插件命名规则:领域_关键词<_其他信息1_其他信息2_…>.so + +插件与SDK存在一一对应的关系,故插件命名的领域、关键词、其他信息等名词解释与要求,均与SDK命名要求保持一致。两者唯一的不同之处在于SDK命名多了个“_sdk”结尾;比如插件命名为“asr_keyword_spotting.so”,则对应SDK命名为“asr_keyword_spotting_sdk.so”。 + +例如:唤醒词识别插件对应的SDK,只支持麒麟9000芯片,适用于中国国内地区适用,则对应的插件命名为:asr_keyword_spotting_kirin9000_china.so + +### 接口开发规范 + +#### 规则:SDK需按算法调用顺序,封装client对外提供接口;对于异步插件对应的SDK,需要实现client提供的回调接口IClientCb + +AI引擎的client端对外提供的接口包括AieClientInit、AieClientPrepare、AieClientSyncProcess、AieClientAsyncProcess、AieClientRelease、AieClientDestroy、AieClientSetOption、AieClientGetOption,SDK需要根据插件的北向接口按照顺序至少封装AieClientInit、AieClientPrepare、AieClientSyncProcess/AieClientAsyncProcess、AieClientRelease、AieClientDestroy五个接口,否则会出现调用问题或者内存泄漏。比如封装过程遗漏了AieClientPrepare接口,则server端无法完成插件加载,故后面的接口都无法调用成功。 + +对于异步插件,SDK需要实现IClientCb接口,用于接收来自client端的算法推理结果,并将该结果返回给三方调用者。 + + +#### 规则:SDK接口实现中,需要保存与client交互的相关通用数据 + +AI引擎将的client端采用单例实现,对接多个SDK,因此各SDK需要保存与client交互的通用数据,用于连接server端进行任务推理、结果返回等;需保存数据包含clientInfo、algorithmInfo、configInfo三种数据类型,定义在SDK的成员变量里即可。 + + +#### 建议:SDK实现client定义的IServiceDeadCb接口 + +Server端是系统常驻进程,以系统能力的形式为多个client提供服务;client定义的IServiceDeadCb接口,是在server端异常死亡后,会被触发调用。这种异常场景,SDK可在死亡通知接口中,实现相关操作,比如停止调用或者再次拉起server端等。 + +IServiceDeadCb接口实现示例: + + +``` +class ServiceDeadCb : public IServiceDeadCb { +public: +ServiceDeadCb() = default; +~ServiceDeadCb() override = default; +void OnServiceDead() override +{ +printf("[ServiceDeadCb]OnServiceDead Callback happens"); +} +}; +``` + +如上示例,SDK可在OnServiceDead()方法中实现自己的操作,比如停止所有的接口调用等等。 + + +#### 规则:SDK与plugin需要使用编解码模块,将特定算法数据转换成AI引擎的通用数据类型 + +插件的推理数据,会由三方调用者通过client、server传递到插件中;不同的算法所需要的数据类型是不一致的,比如cv的需要图片数据、asr的需要语音数据;为了适配数据类型的差异,AI引擎对外提供了对基本数据类型的编解码能力,将不同数据类型转换为AI引擎可以使用的通用数据类型。 + +编码后的数据类型定义: + + +``` +struct DataInfo { +unsigned char *data; +int length; +} DataInfo; + +``` + +如上示例,DataInfo数据结构包括指向数据内存的指针和数据长度两个变量组成。 + +框架接口使用方法: + +1.添加依赖的头文件:"utils/encdec/include/encdec.h"。 + +2.添加build.gn中的依赖项: + +include_dirs添加"//foundation/ai/engine/services/common"。 + +deps添加"//foundation/ai/engine/services/common/utils/encdec:encdec" 。 + +3.编解码示例: + + +``` +// 编码调用函数示例:arg1,arg2,arg3等为需编码的变量,dataInfo为编码后的结果 +retCode = ProcessEncode(dataInfo, arg1, arg2, arg3) //可以接收任意多个参数 +// 解码调用函数示例:dataInfo为需要解码的信息,arg1,arg2,arg3等为解码后的结果 +retCode = ProcessDecode(dataInfo, arg1, arg2, arg3) //可以接收任意多个参数 +``` + +注意: + +- 编码和解码调用时的参数顺序需要保证一致。 + +- 编码后dataInfo的内存需要调用者手动进行释放。 + +- server端和client端的内存是分开管理和释放的。 + +- 如果包含共享内存的指针,不需要额外处理。 + +- 如果其他类型的指针,则需要解引用后使用ProcessEncode/ ProcessDecode。 + +- 该编解码模块未适配class数据类型,不建议使用。 + + +#### 规则:在SDK中,对以编解码返回的出参数据类型,需要进行内存释放,否则会出现内存泄漏 + +编码得到的通用数据,本质上是将不同类型数据封装在同一块内存中,然后将这块内存的首地址与长度封装到结构体中。通过编码返回到SDK中的出参数据,在插件中申请了内存,但插件无法释放;因此SDK在拿到数据之后,需要对内存进行释放,否则SDK将无法拿到数据。 + +内存释放示例: + + +``` +DataInfo outputInfo = { +.data = nullptr, +.length = 0, +}; +AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); +if (outputInfo.data != nullptr) { +free(outputInfo.data); +outputInfo.data = nullptr; +outputInfo.length = 0; +} +``` + + +#### 规则:plugin需要实现server定义的IPlugin接口,并使用宏PLUGIN_INTERFACE_IMPL对外提供插件函数指针 + +Server端管理的插件内部接口实现逻辑各不相同,为了统一插件的加载流程,AI引擎定义了插件接口IPlugin;在运行态,插件是以动态链接库的形式被AI引擎框架通过dlopen方式加载,各插件需要使用PLUGIN_INTERFACE_IMPL语句对外暴露函数指针,否则插件将无法被正常加载使用。 + + +#### 规则:plugin需要使用AI引擎提供的统一数据通道 + +AI引擎在server与插件之间,提供了一个统一的数据通道,用来处理来自SDK的推理请求和来自插件的结果返回;plugin在推理接口中,需按数据通道完成请求数据的获取以及推理结果的封装。 + +数据通道使用示例: + + +``` +int SyncProcess(IRequest *request, IResponse *&response) +{ +HILOGI("[IvpPlugin]Begin SyncProcess"); +if (request == nullptr) { +HILOGE("[IvpPlugin]SyncProcess request is nullptr"); +return RETCODE_NULL_PARAM; +} +DataInfo inputInfo = request->GetMsg(); +if (inputInfo.data == nullptr) { +HILOGE("[IvpPlugin]InputInfo data is nullptr"); +return RETCODE_NULL_PARAM; +} + +... + +response = IResponse::Create(request); +response->SetResult(outputInfo); +return RETCODE_SUCCESS; +} +``` + +示例中request和response是数据通道的内容主体。server端会将数据封装在request中,传递到插件,插件进行算法处理之后,则需要将结果封装成response进行返回。 + +## 开发指导 + +### 开发SDK + +SDK头文件的功能实现是基于对SDK的调用映射到对客户端的调用。Client端提供的接口如下表所示。 + + + **表1** Client端提供的接口 + +| 接口名 | 接口说明 | 参数要求 | +| -------- | -------- | -------- | +| int **AieClientInit**(const ConfigInfo &configInfo,
 ClientInfo &clientInfo, const AlgorithmInfo
 &algorithmInfo, IServiceDeadCb \*cb) | **作用**:链接并初始化引擎服务,激活跨进程调用。
**返回值**:0为成功,其他返回值失败。 | **configInfo**(不能为NULL):引擎相关初始化配置数据
**clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**cb**(可为NULL):死亡回调对象 | +| int **AieClientPrepare**(const ClientInfo &clientInfo
, const AlgorithmInfo &algorithmInfo, const DataInfo
 &inputInfo, DataInfo &outputInfo, IClientCb \*cb) | **作用**:加载算法插件。
**返回值**: 0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**inputInfo**(可为NULL):加载算法插件时输入所需信息
**outputInfo**(可为NULL):加载算法插件之后如需返回信息则通过此出参返回
**cb**:异步算法通过此回调返回运算结果,因此**异步算法此结构体不能为空** 若为同步算法,传入空值即可 | +| int **AieClientAsyncProcess**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const DataInfo
 &inputInfo) | **作用**:执行异步算法。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**inputInfo**(可为NULL):算法运算入参 | +| int **AieClientSyncProcess**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const
 DataInfo &inputInfo, DataInfo &outputInfo) | **作用**:执行同步算法。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**inputInfo**(可为NULL):算法运算入参
**outputInfo**(可为NULL):同步算法运算结果出参 | +| int **AieClientRelease**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const
 DataInfo &inputInfo) | **作用**:卸载算法插件。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):卸载算法插件的相关信息
**inputInfo**(可为NULL):调用卸载接口时的输入信息 | +| int **AieClientDestroy**(ClientInfo &clientInfo) | **作用**:断开与服务端的链接,释放相关缓存。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):所要销毁的引擎客户端信息 | +| int **AieClientSetOption**(const ClientInfo &clientInfo,
 int optionType, const DataInfo &inputInfo) | **作用**:设置配置项,可将一些算法的拓展信息通过此接口传入插件。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**optionType** (不能为NULL):算法配置项,算法插件可根据需要利用此状态位
**inputInfo**(可为NULL):插件可根据需要通过此入参设置算法参数信息 | +| int **AieClientGetOption**(const ClientInfo &clientInfo,
 int optionType, const DataInfo &inputInfo,
 DataInfo &outputInfo) | **作用**:给定特定的optionType和inputInfo,获取其对应的配置项信息。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**optionType**(不能为NULL):所获取配置项信息的对应算法状态位
**inputInfo**(可为NULL):所获取配置项信息的对应算法参数信息
**outputInfo**(可为NULL):所要获取的配置项信息返回结果 | + + +其中,ConfigInfo,ClientInfo,AlgorithmInfo,DataInfo的数据结构如下表所示。 + + + **表2** ConfigInfo,ClientInfo,AlgorithmInfo,DataInfo的数据结构 + +| 结构体名称 | 说明 | 属性 | +| -------- | -------- | -------- | +| ConfigInfo | 算法配置项信息。 | **const char \*description**:配置项信息主体 | +| ClientInfo | 客户端信息。 | **long long clientVersion**:客户端设备版本号(当前还未启用)
**int clientId**:客户端ID
**int sessionId**:会话ID
**uid_t serverUid**:server端UID
**uid_t clientUid**:client端UID
**int extendLen**:拓展信息(extendMsg)长度
**unsigned char \*extendMsg**:拓展信息主体 | +| AlgorithmInfo | 算法信息。 | **long long clientVersion**:客户端设备版本号(当前还未启用)
**bool isAsync**:是否为异步执行
**int algorithmType**:引擎框架根据插件加载顺序分配的算法类型ID
**long long algorithmVersion**:算法版本号
**bool isCloud**:是否上云(当前还未启用)
**int operateId**:执行ID(当前还未启用)
**int requestId**:请求ID,标识每次request,以对应执行结果
**int extendLen**:拓展信息(extendMsg)长度
**unsigned char \*extendMsg**:拓展信息主体 | +| DataInfo | 算法数据入参(inputInfo)、
接口调用结果出参(outputInfo)。 | **unsigned char \*data**:数据主体
**int length**:数据(data)长度 | + + +具体开发过程可参考[唤醒词识别SDK开发示例](#唤醒词识别sdk的开发示例)。 + +### 开发插件 +AI引擎框架规定了一套算法插件接入规范,各插件需实现规定接口以实现获取插件版本信息、算法推理类型、同步执行算法、异步执行算法、加载算法插件、卸载算法插件、设置算法配置信息、获取指定算法配置信息等功能。(同步算法实现SyncProcess接口,异步算法实现AsyncProcess接口)。 + + +算法插件类IPlugin接口设计如下表所示。 + + + **表1** 算法插件类IPlugin接口设计 + +| 接口名 | 接口说明 | 参数要求 | +| -------- | -------- | -------- | +| const long long GetVersion() const; | **作用**:获取插件版本信息。
**返回值**:版本号(long long) | - | +| const char \*GetInferMode() const; | **作用**:获取算法推理类型。
**返回值**:"SYNC" or "ASYNC"; | - | +| int SyncProcess(IRequest \*request,
IResponse \*&response); | **作用**:执行插件同步算法。
**返回值**:0为成功,其他返回值为失败。 | **request**(NOT NULL):用于向算法插件传递请求内容;引擎服务端与插件的数据通道。
**response**(NOT NULL):作为出参用于接收算法插件发回的同步算法执行结果,引擎服务端与插件的数据通道。 | +| int AsyncProcess(IRequest \*request,
IPluginAlgorithmCallback \*callback); | **作用**:执行异步算法。
**返回值**:0为成功,其他返回值为失败。 | **request**(NOT NULL):用于向算法插件传递请求内容;引擎服务端与插件的数据通道。
**callback**(NOT NULL):算法插件异步执行结果通过此回调返回引擎服务端。 | +| int Prepare(long long transactionId,
const DataInfo &inputInfo, DataInfo
&outputInfo); | **作用**:加载算法插件。
**返回值**:0为成功,其他返回值为失败。 | **transactionId**(NOT NULL):事务ID,用于标记客户端+会话信息。
**inputInfo**(可为NULL):加载算法插件传入的一些信息。
**outputInfo**(可为NULL):调用加载接口时的出参,返回相关执行结果。 | +| int Release(bool isFullUnload, long long
transactionId, const DataInfo &inputInfo); | **作用**:卸载相关算法插件。
**返回值**:0为成功,其他返回值为失败。 | **isFullUnload**(NOT NULL):表示此插件是否只剩一个client调用,否则不能直接卸载插件,需等最后一个client来进行卸载。
**transactionId**(NOT NULL):事务ID,用于标记客户端+会话信息。
**inputInfo**(可为NULL):卸载算法插件传入的一些信息。 | +| int SetOption(int optionType, const
DataInfo &inputInfo); | **作用**:设置配置项,可将一些算法的拓展信息通过此接口传入插件。
**返回值**:0为成功,其他返回值为失败。 | **optionType** (NOT NULL):算法配置项,算法插件可根据需要利用此状态位。
**inputInfo**(可为NULL):插件可根据需要通过此入参设置算法参数信息。 | +| int GetOption(int optionType, const
DataInfo &inputInfo, DataInfo
&outputInfo); | **作用**:给定特定的optionType和inputInfo,获取其对应的配置项信息。
**返回值**:0为成功,其他返回值为失败。 | **optionType**(NOT NULL):所获取配置项信息的对应算法状态位。
**inputInfo**(可为NULL):所获取配置项信息的对应算法参数信息。
**outputInfo**(可为NULL):所要获取的配置项信息返回结果。 | + + +算法插件类接口:Prepare、SyncProcess、AsyncProcess、Release、SetOption、GetOption分别于客户端接口AieClientPrepare、AieClientSyncProcess、AieClientAsyncProcess、AieClientRelease、AieClientSetOption、AieClientGetOption一一对应;GetInferMode接口用于返回算法执行类型——同步或异步。 + + +算法插件回调类IPluginCallback 接口设计如下表所示。 + + + **表2** 算法插件回调类IPluginCallback 接口设计 + +| 接口名 | 接口说明 | 参数要求 | +| -------- | -------- | -------- | +| void OnEvent(PluginEvent event,
IResponse \*response); | 作用:插件通过此回调返回异步算法执行结果。 | **event**:算法执行结果枚举,‘ON_PLUGIN_SUCCEED’或 ‘ON_PLUGIN_FAIL’(成功或者失败)。
**response**:算法执行结果封装。 | + + +Request、Response是AI引擎服务端与算法插件进行通信的对象。Request封装了调用方的请求、输入数据等,而插件主要通过Response将运算之后的结果返回给AI引擎服务端。 + + +Request类的属性如下表所示。 + + + **表3** Request类的属性 + +| 属性名称 | 属性说明 | 默认值 | +| -------- | -------- | -------- | +| innerSequenceId_ | 类型:long long
作用:暂未启用。 | 0 | +| requestId_ | 类型:int
作用:标识请求序列,用于绑定返回运算结果。 | 0 | +| operationId_ | 类型:int
作用:暂未启用。 | 0 | +| transactionId_ | 类型:long long
作用:事务ID,唯一标识clientId+sessionId。 | 0 | +| algoPluginType_ | 类型:int
作用:引擎框架根据插件加载顺序分配的算法类型的ID。 | 0 | +| msg_ | 类型:DataInfo
作用:存放调用算法接口的输入数据。 | .data = nullptr
.length = 0 | + + +Response类的属性如下表所示。 + + + **表4** Response类的属性 + +| 属性名称 | 属性说明 | 默认值 | +| -------- | -------- | -------- | +| innerSequenceId_ | 类型:long long
作用:暂未启用。 | 0 | +| requestId_ | 类型:int
作用:标识请求序列,用于绑定返回运算结果。 | 0 | +| retCode__ | 类型:int
作用:异步执行算法推理结果码。 | 0 | +| retDesc_ | 类型:string
作用:暂未启用。 | - | +| transactionId_ | 类型:long long
作用:事务ID,唯一标识clientId+sessionId。 | 0 | +| algoPluginType_ | 类型:int
作用:引擎框架根据插件加载顺序分配的算法类型的ID。 | INVALID_ALGO_PLUGIN_TYPE(-1) | +| result_ | 类型:DataInfo
作用:存放异步算法推理结果。 | .data = nullptr
.length = 0 | + + +具体开发过程可参考[唤醒词识别插件开发示例](#唤醒词识别插件的开发示例)。 + +### 开发配置文件 + +开发者开发的SDK通过AlgorithmInfo结构体中algorithmVersion以及algorithmType识别出具体的插件类型,实现插件能力的调用。因此开发者需完成以下步骤: + + +1. 代码路径//foundation/ai/engine/services/common/protocol/plugin_config/plugin_config_ini/中添加插件的配置文件。 + +2. 代码路径//foundation/ai/engine/services/common/protocol/plugin_config/中的aie_algorithm_type.h文件添加算法类型。 + +3. 代码路径//foundation/ai/engine/services/server/plugin_manager/include/中的aie_plugin_info.h文件添加唤醒词识别的算法名称及其在ALGORITHM_TYPE_ID_LIST中的序号。 + +具体开发过程可参考[唤醒词识别配置文件开发示例](#唤醒词识别配置文件的开发示例)。 + +## 开发实例 + +### 唤醒词识别SDK的开发示例 + + +1. 在//foundation/ai/engine /interfaces/kits目录中添加唤醒词识别SDK的API接口定义,该接口可用三方应用进行调用。如下代码片段即为唤醒词识别定义的API接口示例,其相关代码参考路径为://foundation/ai/engine/interfaces/kits/asr/keyword_spotting。 + + ``` + class KWSSdk { + public: + KWSSdk(); + virtual ~KWSSdk(); + + // 定义创建唤醒词检测工具包的方法 + int32_t Create(); + + // 定义同步执行唤醒词检测任务的方法 + int32_t SyncExecute(const Array &audioInput); + + // 定义设置唤醒词检测回调器的方法。 + int32_t SetCallback(const std::shared_ptr &callback); + + // 定义销毁唤醒词工具包的方法,释放与插件的会话信息 + int32_t Destroy(); + }; + ``` + +2. 在//foundation/ai/engine/services/client/algorithm_sdk目录中增加SDK中API接口的具体实现,调用client端提供的接口,实现算法插件能力的使用。如下代码片段即为唤醒词识别的API接口中create方法的具体实现示例,更多详细代码请参考://foundation/ai/engine/services/client/algorithm_sdk/asr/keyword_spotting。 + + ``` + int32_t KWSSdk::KWSSdkImpl::Create() + { + if (kwsHandle_ != INVALID_KWS_HANDLE) { + HILOGE("[KWSSdkImpl]The SDK has been created"); + return KWS_RETCODE_FAILURE; + } + if (InitComponents() != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]Fail to init sdk components"); + return KWS_RETCODE_FAILURE; + } + // 调用client端提供的AieClientInit接口,实现初始化引擎服务,激活跨进程调用 + int32_t retCode = AieClientInit(configInfo_, clientInfo_, algorithmInfo_, nullptr); + if (retCode != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]AieClientInit failed. Error code[%d]", retCode); + return KWS_RETCODE_FAILURE; + } + if (clientInfo_.clientId == INVALID_CLIENT_ID) { + HILOGE("[KWSSdkImpl]Fail to allocate client id"); + return KWS_RETCODE_FAILURE; + } + DataInfo inputInfo = { + .data = nullptr, + .length = 0, + }; + DataInfo outputInfo = { + .data = nullptr, + .length = 0, + }; + // 调用client端提供的AieClientPrepare接口,实现加载算法插件 + retCode = AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); + if (retCode != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]AieclientPrepare failed. Error code[%d]", retCode); + return KWS_RETCODE_FAILURE; + } + if (outputInfo.data == nullptr || outputInfo.length <= 0) { + HILOGE("[KWSSdkImpl]The data or length of output info is invalid"); + return KWS_RETCODE_FAILURE; + } + MallocPointerGuard pointerGuard(outputInfo.data); + retCode = PluginHelper::UnSerializeHandle(outputInfo, kwsHandle_); + if (retCode != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]Get handle from inputInfo failed"); + return KWS_RETCODE_FAILURE; + } + return KWS_RETCODE_SUCCESS; + } + ``` + + 上述代码为API接口的具体实现。在示例代码中,SDK中create接口的具体实现即为上述示例代码中create方法,该方法调用了AI引擎框架client端提供的AieClientInit及AieClientPrepare接口,从而实现与server端建立连接及加载算法模型的能力。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > + > SDK调用AI引擎client端接口应遵循AieClientInit->AieClientPrepare->AieClientSyncProcess/AieClientAsyncProcess->AieClientRelease->AieClientDestroy顺序,否则调用接口会返回错误码。 + +### 唤醒词识别插件的开发示例 +在代码路径//foundation/ai/engine/services/server/plugin中添加唤醒词识别插件的接口定义(IPlugin),并实现AI能力的调用。如下代码片段即实现唤醒词识别的算法插件的接口定义。更多插件开发的相关代码参考路径如下://foundation/ai/engine/services/server/plugin/asr/keyword_spotting + + ``` + #include "plugin/i_plugin.h + class KWSPlugin : public IPlugin { + public: + KWSPlugin(); + ~KWSPlugin(); + const long long GetVersion() const override; + const char* GetName() const override; + const char* GetInferMode() const override; + int32_t Prepare(long long transactionId, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; + int32_t SetOption(int optionType, const DataInfo &amp;inputInfo) override; + int32_t GetOption(int optionType, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; + int32_t SyncProcess(IRequest *request, IResponse *&amp;response) override; + int32_t AsyncProcess(IRequest *request, IPluginCallback*callback) override; + int32_t Release(bool isFullUnload, long long transactionId, const DataInfo &amp;inputInfo) override; + }; + ``` + + 上述代码实现server提供的IPlugin接口。唤醒词识别的sample中调用的client端接口与插件中的接口对应关系及其实现功能如下表所示。 + **表1** 唤醒词识别中client端接口与插件中的接口对应关系 + +| client端定义的接口 | 插件中定义的接口 | 功能 | +| -------- | -------- | -------- | +| AieClientPrepare | Prepare | 提供推理算法插件初始化功能,例如:加载唤醒词识别模型,将固定位置(/sdcard/wenwen_inst.wk)模型加载至内存。 | +| AieClientSyncProcess | SyncProcess | 提供同步执行推理算法的能力,例如:实现同步执行音频推理算法,判断音频中是否存在唤醒词。 | +| AieClientAsyncProcess | AsyncProcess | 提供异步执行推理算法的能力,当前唤醒词识别场景不涉及,但开发者可根据具体场景自行实现。 | +| AieClientSetOption | SetOption | 提供手动设置算法相关配置项,如置信度阈值、时延等超参数的能力。当前唤醒词识别场景未涉及,开发者可视具体场景自行实现。 | +| AieClientGetOption | GetOption | 提供获取算法相关配置项,以唤醒词识别为例:获取唤醒词模型中输入输出的规模,输入规模即为唤醒词识别模型要求输入的MFCC特征的维度(固定值:4000),输出规模即为结果的置信度得分维度(固定值:2)。 | +| AieClientRelease | Release | 提供卸载算法模型功能,以唤醒词识别为例:实现卸载相关模型,并清理特征处理器中的动态内存。 | + + 注意: + + 1.接口AieClientInit、AieClientDestroy分别用于与server端建立和断开连接,未调用到插件算法中,因此插件中无需定义与之对应的接口。 + + 2.唤醒词识别插件需要使用PLUGIN_INTERFACE_IMPL语句对外暴露函数指针,否则插件将无法被正常加载使用。 + + + ``` + PLUGIN_INTERFACE_IMPL(KWSPlugin); + ``` + +### 唤醒词识别配置文件的开发示例 + +1. 在代码路径//foundation/ai/engine/services/common/protocol/plugin_config/plugin_config_ini/中添加唤醒词识别的配置文件。 + + ``` + [base] + supported_boards = hi3516dv300 + related_sessions = asr_keyword_spotting+20001002 + + //[asr_keyword_spotting+20001002]的命名规则为[算法名称+算法version] + [asr_keyword_spotting+20001002] + AID = asr_keyword_spotting + VersionCode = 20001002 + VersionName = 2.00.01.002 + XPU = NNIE + District = China + // 编译出的插件so文件所在的位置 + FullPath = /usr/lib/libasr_keyword_spotting.so + Chipset = ALL + ChkSum = '' + Key = '' + ``` + +2. 在代码路径//foundation/ai/engine/services/common/protocol/plugin_config/中的aie_algorithm_type.h文件添加唤醒词识别算法类型id。 + + ``` + // 唤醒词识别的算法类型id与唤醒词识别在ALGORITHM_TYPE_ID_LIST中的序号一一对应 + const int ALGORITHM_TYPE_KWS = 3; + ``` + +3. 在代码路径//foundation/ai/engine/services/server/plugin_manager/include/中的aie_plugin_info.h文件添加唤醒词识别算法名称及在ALGORITHM_TYPE_ID_LIST中的序号。 + + ``` + const std::string ALGORITHM_ID_SAMPLE_1 = "sample_plugin_1"; + const std::string ALGORITHM_ID_SAMPLE_2 = "sample_plugin_2"; + const std::string ALGORITHM_ID_IVP = "cv_human_detect"; + // 添加唤醒词识别的算法名称asr_keyword_spotting + // 算法的变量名称与ALGORITHM_TYPE_ID_LIST中算法typeId命名相同,例如:ALGORITHM_ID_KWS + const std::string ALGORITHM_ID_KWS = "asr_keyword_spotting"; + const std::string ALGORITHM_ID_IC = "cv_image_classification"; + const std::string ALGORITHM_ID_INVALID = "invalid algorithm id"; + + const std::vector ALGORITHM_TYPE_ID_LIST = { + ALGORITHM_ID_SAMPLE_1, + ALGORITHM_ID_SAMPLE_2, + ALGORITHM_ID_IVP, + // 添加唤醒词识别在ALGORITHM_TYPE_ID_LIST中的序号,通过该序号可获得唤醒词识别的算法名称 + // 唤醒词识别的算法名称和唤醒词识别在ALGORITHM_TYPE_ID_LIST中的序号顺序需保持一致 + ALGORITHM_ID_KWS, + ALGORITHM_ID_IC, + }; + ``` diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-conf.md b/zh-cn/device-dev/subsystems/subsys-aiframework-demo-conf.md deleted file mode 100755 index 81074ff915c321e7d20dfaedacc2b0e5d5862de0..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-conf.md +++ /dev/null @@ -1,53 +0,0 @@ -# 唤醒词识别配置文件的开发示例 - - -1. 在代码路径//foundation/ai/engine/services/common/protocol/plugin_config/plugin_config_ini/中添加唤醒词识别的配置文件。 - - ``` - [base] - supported_boards = hi3516dv300 - related_sessions = asr_keyword_spotting+20001002 - - //[asr_keyword_spotting+20001002]的命名规则为[算法名称+算法version] - [asr_keyword_spotting+20001002] - AID = asr_keyword_spotting - VersionCode = 20001002 - VersionName = 2.00.01.002 - XPU = NNIE - District = China - // 编译出的插件so文件所在的位置 - FullPath = /usr/lib/libasr_keyword_spotting.so - Chipset = ALL - ChkSum = '' - Key = '' - ``` - -2. 在代码路径//foundation/ai/engine/services/common/protocol/plugin_config/中的aie_algorithm_type.h文件添加唤醒词识别算法类型id。 - - ``` - // 唤醒词识别的算法类型id与唤醒词识别在ALGORITHM_TYPE_ID_LIST中的序号一一对应 - const int ALGORITHM_TYPE_KWS = 3; - ``` - -3. 在代码路径//foundation/ai/engine/services/server/plugin_manager/include/中的aie_plugin_info.h文件添加唤醒词识别算法名称及在ALGORITHM_TYPE_ID_LIST中的序号。 - - ``` - const std::string ALGORITHM_ID_SAMPLE_1 = "sample_plugin_1"; - const std::string ALGORITHM_ID_SAMPLE_2 = "sample_plugin_2"; - const std::string ALGORITHM_ID_IVP = "cv_human_detect"; - // 添加唤醒词识别的算法名称asr_keyword_spotting - // 算法的变量名称与ALGORITHM_TYPE_ID_LIST中算法typeId命名相同,例如:ALGORITHM_ID_KWS - const std::string ALGORITHM_ID_KWS = "asr_keyword_spotting"; - const std::string ALGORITHM_ID_IC = "cv_image_classification"; - const std::string ALGORITHM_ID_INVALID = "invalid algorithm id"; - - const std::vector ALGORITHM_TYPE_ID_LIST = { - ALGORITHM_ID_SAMPLE_1, - ALGORITHM_ID_SAMPLE_2, - ALGORITHM_ID_IVP, - // 添加唤醒词识别在ALGORITHM_TYPE_ID_LIST中的序号,通过该序号可获得唤醒词识别的算法名称 - // 唤醒词识别的算法名称和唤醒词识别在ALGORITHM_TYPE_ID_LIST中的序号顺序需保持一致 - ALGORITHM_ID_KWS, - ALGORITHM_ID_IC, - }; - ``` diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-plugin.md b/zh-cn/device-dev/subsystems/subsys-aiframework-demo-plugin.md deleted file mode 100755 index ec514ab192c439bcae6f00198becc20eaaf7adff..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-plugin.md +++ /dev/null @@ -1,45 +0,0 @@ -# 唤醒词识别插件的开发示例 - - -在代码路径//foundation/ai/engine/services/server/plugin中添加唤醒词识别插件的接口定义(IPlugin),并实现AI能力的调用。如下代码片段即实现唤醒词识别的算法插件的接口定义。更多插件开发的相关代码参考路径如下://foundation/ai/engine/services/server/plugin/asr/keyword_spotting - - ``` - #include "plugin/i_plugin.h - class KWSPlugin : public IPlugin { - public: - KWSPlugin(); - ~KWSPlugin(); - const long long GetVersion() const override; - const char* GetName() const override; - const char* GetInferMode() const override; - int32_t Prepare(long long transactionId, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; - int32_t SetOption(int optionType, const DataInfo &amp;inputInfo) override; - int32_t GetOption(int optionType, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; - int32_t SyncProcess(IRequest *request, IResponse *&amp;response) override; - int32_t AsyncProcess(IRequest *request, IPluginCallback*callback) override; - int32_t Release(bool isFullUnload, long long transactionId, const DataInfo &amp;inputInfo) override; - }; - ``` - - 上述代码实现server提供的IPlugin接口。唤醒词识别的sample中调用的client端接口与插件中的接口对应关系及其实现功能如下表所示。 - **表1** 唤醒词识别中client端接口与插件中的接口对应关系 - - | client端定义的接口 | 插件中定义的接口 | 功能 | - | -------- | -------- | -------- | - | AieClientPrepare | Prepare | 提供推理算法插件初始化功能,例如:加载唤醒词识别模型,将固定位置(/sdcard/wenwen_inst.wk)模型加载至内存。 | - | AieClientSyncProcess | SyncProcess | 提供同步执行推理算法的能力,例如:实现同步执行音频推理算法,判断音频中是否存在唤醒词。 | - | AieClientAsyncProcess | AsyncProcess | 提供异步执行推理算法的能力,当前唤醒词识别场景不涉及,但开发者可根据具体场景自行实现。 | - | AieClientSetOption | SetOption | 提供手动设置算法相关配置项,如置信度阈值、时延等超参数的能力。当前唤醒词识别场景未涉及,开发者可视具体场景自行实现。 | - | AieClientGetOption | GetOption | 提供获取算法相关配置项,以唤醒词识别为例:获取唤醒词模型中输入输出的规模,输入规模即为唤醒词识别模型要求输入的MFCC特征的维度(固定值:4000),输出规模即为结果的置信度得分维度(固定值:2)。 | - | AieClientRelease | Release | 提供卸载算法模型功能,以唤醒词识别为例:实现卸载相关模型,并清理特征处理器中的动态内存。 | - - 注意: - - 1.接口AieClientInit、AieClientDestroy分别用于与server端建立和断开连接,未调用到插件算法中,因此插件中无需定义与之对应的接口。 - - 2.唤醒词识别插件需要使用PLUGIN_INTERFACE_IMPL语句对外暴露函数指针,否则插件将无法被正常加载使用。 - - - ``` - PLUGIN_INTERFACE_IMPL(KWSPlugin); - ``` diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md b/zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md deleted file mode 100644 index 87ce0460bb5d2966f2ab221ceb19a0801d0c54d0..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md +++ /dev/null @@ -1,81 +0,0 @@ -# 唤醒词识别SDK的开发示例 - - -1. 在//foundation/ai/engine /interfaces/kits目录中添加唤醒词识别SDK的API接口定义,该接口可用三方应用进行调用。如下代码片段即为唤醒词识别定义的API接口示例,其相关代码参考路径为://foundation/ai/engine/interfaces/kits/asr/keyword_spotting。 - - ``` - class KWSSdk { - public: - KWSSdk(); - virtual ~KWSSdk(); - - // 定义创建唤醒词检测工具包的方法 - int32_t Create(); - - // 定义同步执行唤醒词检测任务的方法 - int32_t SyncExecute(const Array &audioInput); - - // 定义设置唤醒词检测回调器的方法。 - int32_t SetCallback(const std::shared_ptr &callback); - - // 定义销毁唤醒词工具包的方法,释放与插件的会话信息 - int32_t Destroy(); - }; - ``` - -2. 在//foundation/ai/engine/services/client/algorithm_sdk目录中增加SDK中API接口的具体实现,调用client端提供的接口,实现算法插件能力的使用。如下代码片段即为唤醒词识别的API接口中create方法的具体实现示例,更多详细代码请参考://foundation/ai/engine/services/client/algorithm_sdk/asr/keyword_spotting。 - - ``` - int32_t KWSSdk::KWSSdkImpl::Create() - { - if (kwsHandle_ != INVALID_KWS_HANDLE) { - HILOGE("[KWSSdkImpl]The SDK has been created"); - return KWS_RETCODE_FAILURE; - } - if (InitComponents() != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]Fail to init sdk components"); - return KWS_RETCODE_FAILURE; - } - // 调用client端提供的AieClientInit接口,实现初始化引擎服务,激活跨进程调用 - int32_t retCode = AieClientInit(configInfo_, clientInfo_, algorithmInfo_, nullptr); - if (retCode != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]AieClientInit failed. Error code[%d]", retCode); - return KWS_RETCODE_FAILURE; - } - if (clientInfo_.clientId == INVALID_CLIENT_ID) { - HILOGE("[KWSSdkImpl]Fail to allocate client id"); - return KWS_RETCODE_FAILURE; - } - DataInfo inputInfo = { - .data = nullptr, - .length = 0, - }; - DataInfo outputInfo = { - .data = nullptr, - .length = 0, - }; - // 调用client端提供的AieClientPrepare接口,实现加载算法插件 - retCode = AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); - if (retCode != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]AieclientPrepare failed. Error code[%d]", retCode); - return KWS_RETCODE_FAILURE; - } - if (outputInfo.data == nullptr || outputInfo.length <= 0) { - HILOGE("[KWSSdkImpl]The data or length of output info is invalid"); - return KWS_RETCODE_FAILURE; - } - MallocPointerGuard pointerGuard(outputInfo.data); - retCode = PluginHelper::UnSerializeHandle(outputInfo, kwsHandle_); - if (retCode != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]Get handle from inputInfo failed"); - return KWS_RETCODE_FAILURE; - } - return KWS_RETCODE_SUCCESS; - } - ``` - - 上述代码为API接口的具体实现。在示例代码中,SDK中create接口的具体实现即为上述示例代码中create方法,该方法调用了AI引擎框架client端提供的AieClientInit及AieClientPrepare接口,从而实现与server端建立连接及加载算法模型的能力。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > SDK调用AI引擎client端接口应遵循AieClientInit->AieClientPrepare->AieClientSyncProcess/AieClientAsyncProcess->AieClientRelease->AieClientDestroy顺序,否则调用接口会返回错误码。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-demo.md b/zh-cn/device-dev/subsystems/subsys-aiframework-demo.md deleted file mode 100644 index 92d97285dd7bd8fcab65a90a50d2dd26909e1564..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-demo.md +++ /dev/null @@ -1,14 +0,0 @@ -# 开发示例 - - -以开发唤醒词识别为例,开发者可在Hi3516DV300开发板上,基于AI引擎框架开发唤醒词识别的SDK以及唤醒词识别的plugin,通过编译命令编出新的版本镜像并将其烧入版本。同时,开发者开发唤醒词识别的应用,该应用能够接收外部音频,将接收到的音频传入SDK中的接口。若音频中带有关键词,唤醒词识别的应用会识别出相应的词语,并打印在命令行中。 - - -本示例中唤醒词识别的场景中唤醒词是固定的,当开发者传入的音频包含“Hi,小问”,启动的应用就会打印"[Hi, xiaowen]",当不包含时,会打印"[UNKNOWN]"。 - - -- **[唤醒词识别SDK的开发示例](subsys-aiframework-demo-sdk.md)** - -- **[唤醒词识别插件的开发示例](subsys-aiframework-demo-plugin.md)** - -- **[唤醒词识别配置文件的开发示例](subsys-aiframework-demo-conf.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-conf.md b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-conf.md deleted file mode 100755 index 2add218e8e2a8a92f70effce393fb46d0443ed62..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-conf.md +++ /dev/null @@ -1,14 +0,0 @@ -# 配置文件的开发过程 - - -开发者开发的SDK通过AlgorithmInfo结构体中algorithmVersion以及algorithmType识别出具体的插件类型,实现插件能力的调用。因此开发者需完成以下步骤: - - -1. 代码路径//foundation/ai/engine/services/common/protocol/plugin_config/plugin_config_ini/中添加插件的配置文件。 - -2. 代码路径//foundation/ai/engine/services/common/protocol/plugin_config/中的aie_algorithm_type.h文件添加算法类型。 - -3. 代码路径//foundation/ai/engine/services/server/plugin_manager/include/中的aie_plugin_info.h文件添加唤醒词识别的算法名称及其在ALGORITHM_TYPE_ID_LIST中的序号。 - - -具体开发过程可参考[唤醒词识别配置文件开发示例](../subsystems/subsys-aiframework-demo-conf.md)。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md deleted file mode 100644 index d082cc359fab9b9cb72cc9f521192c6ad1c71ea0..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md +++ /dev/null @@ -1,71 +0,0 @@ -# 插件的开发过程 - - -AI引擎框架规定了一套算法插件接入规范,各插件需实现规定接口以实现获取插件版本信息、算法推理类型、同步执行算法、异步执行算法、加载算法插件、卸载算法插件、设置算法配置信息、获取指定算法配置信息等功能。(同步算法实现SyncProcess接口,异步算法实现AsyncProcess接口)。 - - -算法插件类IPlugin接口设计如下表所示。 - - - **表1** 算法插件类IPlugin接口设计 - -| 接口名 | 接口说明 | 参数要求 | -| -------- | -------- | -------- | -| const long long GetVersion() const; | **作用**:获取插件版本信息。
**返回值**:版本号(long long) | - | -| const char \*GetInferMode() const; | **作用**:获取算法推理类型。
**返回值**:"SYNC" or "ASYNC"; | - | -| int SyncProcess(IRequest \*request,
IResponse \*&response); | **作用**:执行插件同步算法。
**返回值**:0为成功,其他返回值为失败。 | **request**(NOT NULL):用于向算法插件传递请求内容;引擎服务端与插件的数据通道。
**response**(NOT NULL):作为出参用于接收算法插件发回的同步算法执行结果,引擎服务端与插件的数据通道。 | -| int AsyncProcess(IRequest \*request,
IPluginAlgorithmCallback \*callback); | **作用**:执行异步算法。
**返回值**:0为成功,其他返回值为失败。 | **request**(NOT NULL):用于向算法插件传递请求内容;引擎服务端与插件的数据通道。
**callback**(NOT NULL):算法插件异步执行结果通过此回调返回引擎服务端。 | -| int Prepare(long long transactionId,
const DataInfo &inputInfo, DataInfo
&outputInfo); | **作用**:加载算法插件。
**返回值**:0为成功,其他返回值为失败。 | **transactionId**(NOT NULL):事务ID,用于标记客户端+会话信息。
**inputInfo**(可为NULL):加载算法插件传入的一些信息。
**outputInfo**(可为NULL):调用加载接口时的出参,返回相关执行结果。 | -| int Release(bool isFullUnload, long long
transactionId, const DataInfo &inputInfo); | **作用**:卸载相关算法插件。
**返回值**:0为成功,其他返回值为失败。 | **isFullUnload**(NOT NULL):表示此插件是否只剩一个client调用,否则不能直接卸载插件,需等最后一个client来进行卸载。
**transactionId**(NOT NULL):事务ID,用于标记客户端+会话信息。
**inputInfo**(可为NULL):卸载算法插件传入的一些信息。 | -| int SetOption(int optionType, const
DataInfo &inputInfo); | **作用**:设置配置项,可将一些算法的拓展信息通过此接口传入插件。
**返回值**:0为成功,其他返回值为失败。 | **optionType** (NOT NULL):算法配置项,算法插件可根据需要利用此状态位。
**inputInfo**(可为NULL):插件可根据需要通过此入参设置算法参数信息。 | -| int GetOption(int optionType, const
DataInfo &inputInfo, DataInfo
&outputInfo); | **作用**:给定特定的optionType和inputInfo,获取其对应的配置项信息。
**返回值**:0为成功,其他返回值为失败。 | **optionType**(NOT NULL):所获取配置项信息的对应算法状态位。
**inputInfo**(可为NULL):所获取配置项信息的对应算法参数信息。
**outputInfo**(可为NULL):所要获取的配置项信息返回结果。 | - - -算法插件类接口:Prepare、SyncProcess、AsyncProcess、Release、SetOption、GetOption分别于客户端接口AieClientPrepare、AieClientSyncProcess、AieClientAsyncProcess、AieClientRelease、AieClientSetOption、AieClientGetOption一一对应;GetInferMode接口用于返回算法执行类型——同步或异步。 - - -算法插件回调类IPluginCallback 接口设计如下表所示。 - - - **表2** 算法插件回调类IPluginCallback 接口设计 - -| 接口名 | 接口说明 | 参数要求 | -| -------- | -------- | -------- | -| void OnEvent(PluginEvent event,
IResponse \*response); | 作用:插件通过此回调返回异步算法执行结果。 | **event**:算法执行结果枚举,‘ON_PLUGIN_SUCCEED’或 ‘ON_PLUGIN_FAIL’(成功或者失败)。
**response**:算法执行结果封装。 | - - -Request、Response是AI引擎服务端与算法插件进行通信的对象。Request封装了调用方的请求、输入数据等,而插件主要通过Response将运算之后的结果返回给AI引擎服务端。 - - -Request类的属性如下表所示。 - - - **表3** Request类的属性 - -| 属性名称 | 属性说明 | 默认值 | -| -------- | -------- | -------- | -| innerSequenceId_ | 类型:long long
作用:暂未启用。 | 0 | -| requestId_ | 类型:int
作用:标识请求序列,用于绑定返回运算结果。 | 0 | -| operationId_ | 类型:int
作用:暂未启用。 | 0 | -| transactionId_ | 类型:long long
作用:事务ID,唯一标识clientId+sessionId。 | 0 | -| algoPluginType_ | 类型:int
作用:引擎框架根据插件加载顺序分配的算法类型的ID。 | 0 | -| msg_ | 类型:DataInfo
作用:存放调用算法接口的输入数据。 | .data = nullptr
.length = 0 | - - -Response类的属性如下表所示。 - - - **表4** Response类的属性 - -| 属性名称 | 属性说明 | 默认值 | -| -------- | -------- | -------- | -| innerSequenceId_ | 类型:long long
作用:暂未启用。 | 0 | -| requestId_ | 类型:int
作用:标识请求序列,用于绑定返回运算结果。 | 0 | -| retCode__ | 类型:int
作用:异步执行算法推理结果码。 | 0 | -| retDesc_ | 类型:string
作用:暂未启用。 | - | -| transactionId_ | 类型:long long
作用:事务ID,唯一标识clientId+sessionId。 | 0 | -| algoPluginType_ | 类型:int
作用:引擎框架根据插件加载顺序分配的算法类型的ID。 | INVALID_ALGO_PLUGIN_TYPE(-1) | -| result_ | 类型:DataInfo
作用:存放异步算法推理结果。 | .data = nullptr
.length = 0 | - - -具体开发过程可参考[唤醒词识别插件开发示例](../subsystems/subsys-aiframework-demo-plugin.md)。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md deleted file mode 100644 index 83150d465bf78878ad6b1cabe6716d2c14c95cd6..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md +++ /dev/null @@ -1,34 +0,0 @@ -# SDK开发过程 - - -SDK头文件的功能实现是基于对SDK的调用映射到对客户端的调用。Client端提供的接口如下表所示。 - - - **表1** Client端提供的接口 - -| 接口名 | 接口说明 | 参数要求 | -| -------- | -------- | -------- | -| int **AieClientInit**(const ConfigInfo &configInfo,
 ClientInfo &clientInfo, const AlgorithmInfo
 &algorithmInfo, IServiceDeadCb \*cb) | **作用**:链接并初始化引擎服务,激活跨进程调用。
**返回值**:0为成功,其他返回值失败。 | **configInfo**(不能为NULL):引擎相关初始化配置数据
**clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**cb**(可为NULL):死亡回调对象 | -| int **AieClientPrepare**(const ClientInfo &clientInfo
, const AlgorithmInfo &algorithmInfo, const DataInfo
 &inputInfo, DataInfo &outputInfo, IClientCb \*cb) | **作用**:加载算法插件。
**返回值**: 0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**inputInfo**(可为NULL):加载算法插件时输入所需信息
**outputInfo**(可为NULL):加载算法插件之后如需返回信息则通过此出参返回
**cb**:异步算法通过此回调返回运算结果,因此**异步算法此结构体不能为空** 若为同步算法,传入空值即可 | -| int **AieClientAsyncProcess**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const DataInfo
 &inputInfo) | **作用**:执行异步算法。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**inputInfo**(可为NULL):算法运算入参 | -| int **AieClientSyncProcess**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const
 DataInfo &inputInfo, DataInfo &outputInfo) | **作用**:执行同步算法。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):调用算法信息
**inputInfo**(可为NULL):算法运算入参
**outputInfo**(可为NULL):同步算法运算结果出参 | -| int **AieClientRelease**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const
 DataInfo &inputInfo) | **作用**:卸载算法插件。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**algorithmInfo**(不能为NULL):卸载算法插件的相关信息
**inputInfo**(可为NULL):调用卸载接口时的输入信息 | -| int **AieClientDestroy**(ClientInfo &clientInfo) | **作用**:断开与服务端的链接,释放相关缓存。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):所要销毁的引擎客户端信息 | -| int **AieClientSetOption**(const ClientInfo &clientInfo,
 int optionType, const DataInfo &inputInfo) | **作用**:设置配置项,可将一些算法的拓展信息通过此接口传入插件。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**optionType** (不能为NULL):算法配置项,算法插件可根据需要利用此状态位
**inputInfo**(可为NULL):插件可根据需要通过此入参设置算法参数信息 | -| int **AieClientGetOption**(const ClientInfo &clientInfo,
 int optionType, const DataInfo &inputInfo,
 DataInfo &outputInfo) | **作用**:给定特定的optionType和inputInfo,获取其对应的配置项信息。
**返回值**:0为成功,其他返回值失败。 | **clientInfo**(不能为NULL):引擎客户端信息
**optionType**(不能为NULL):所获取配置项信息的对应算法状态位
**inputInfo**(可为NULL):所获取配置项信息的对应算法参数信息
**outputInfo**(可为NULL):所要获取的配置项信息返回结果 | - - -其中,ConfigInfo,ClientInfo,AlgorithmInfo,DataInfo的数据结构如下表所示。 - - - **表2** ConfigInfo,ClientInfo,AlgorithmInfo,DataInfo的数据结构 - -| 结构体名称 | 说明 | 属性 | -| -------- | -------- | -------- | -| ConfigInfo | 算法配置项信息。 | **const char \*description**:配置项信息主体 | -| ClientInfo | 客户端信息。 | **long long clientVersion**:客户端设备版本号(当前还未启用)
**int clientId**:客户端ID
**int sessionId**:会话ID
**uid_t serverUid**:server端UID
**uid_t clientUid**:client端UID
**int extendLen**:拓展信息(extendMsg)长度
**unsigned char \*extendMsg**:拓展信息主体 | -| AlgorithmInfo | 算法信息。 | **long long clientVersion**:客户端设备版本号(当前还未启用)
**bool isAsync**:是否为异步执行
**int algorithmType**:引擎框架根据插件加载顺序分配的算法类型ID
**long long algorithmVersion**:算法版本号
**bool isCloud**:是否上云(当前还未启用)
**int operateId**:执行ID(当前还未启用)
**int requestId**:请求ID,标识每次request,以对应执行结果
**int extendLen**:拓展信息(extendMsg)长度
**unsigned char \*extendMsg**:拓展信息主体 | -| DataInfo | 算法数据入参(inputInfo)、
接口调用结果出参(outputInfo)。 | **unsigned char \*data**:数据主体
**int length**:数据(data)长度 | - - -具体开发过程可参考[唤醒词识别SDK开发示例](../subsystems/subsys-aiframework-demo-sdk.md)。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide.md b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide.md deleted file mode 100644 index 2d2d91edecc9b54ce3dc2cad981fb5cb27f12953..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide.md +++ /dev/null @@ -1,11 +0,0 @@ -# 开发指导 - - -为实现AI 引擎框架的接入,开发者需开发上述图1中的SDK模块和Plugin模块,通过调用SDK提供的接口,基于AI引擎框架实现调用plugin中算法的能力,从而实现AI能力的生命周期管理和按需部署功能。 - - -- **[SDK开发过程](subsys-aiframework-devguide-sdk.md)** - -- **[插件的开发过程](subsys-aiframework-devguide-plugin.md)** - -- **[配置文件的开发过程](subsys-aiframework-devguide-conf.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md b/zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md deleted file mode 100644 index 6c9f583234ca9abe82f26db5949cc39f3fcad76f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md +++ /dev/null @@ -1,6 +0,0 @@ -# 搭建环境 - - -1. 准备开发板:Hi3516DV300或Hi3518EV300 - -2. [下载源码](../get-code/sourcecode-acquire.md) diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-guide.md b/zh-cn/device-dev/subsystems/subsys-aiframework-guide.md deleted file mode 100644 index 1cc85a265daa79558e6f90349d478e2cf4862e2e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-guide.md +++ /dev/null @@ -1,10 +0,0 @@ -# 概述 - - -AI业务子系统是OpenHarmony提供原生的分布式AI能力的子系统。AI业务子系统提供了统一的AI引擎框架,实现算法能力快速插件化集成。 -AI引擎框架主要包含插件管理、模块管理和通信管理模块,完成对AI算法能力的生命周期管理和按需部署。插件管理主要实现插件的生命周期管理及插件的按需部署,快速集成AI能力插件;模块管理主要实现任务的调度及管理客户端的实例;通信管理主要实现客户端和服务端之间的跨进程通信管理及AI服务与插件之间的数据传输。后续,会逐步定义统一的AI能力接口,便于AI能力的分布式调用。同时,框架提供适配不同推理框架层级的统一推理接口。 -AI引擎框架结构如下图所示。 - - - **图1** AI引擎框架 - ![zh-cn_image_0000001200128073](figures/zh-cn_image_0000001200128073.png) diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md b/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md deleted file mode 100644 index 8d0c3224f4dd2758f4b9479f998421414c56602e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md +++ /dev/null @@ -1,39 +0,0 @@ -# 代码管理规范 - - -AI引擎框架包含client、server和common三个主要模块,其中client提供server端连接管理功能,北向SDK在算法对外接口中需封装调用client提供的公共接口;server提供插件加载以及任务管理等功能,各Plugin实现由server提供的插件接口,完成插件接入;common提供与平台相关的操作方法、引擎协议以及相关工具类,供其他各模块调用。 - - -AI引擎框架各模块之间的代码依赖关系如下图所示: - - - **图1** AI引擎代码依赖关系 - - ![zh-cn_image_0000001151931738](figures/zh-cn_image_0000001151931738.jpg) - - -## 建议:插件与北向SDK在AI引擎指定的路径下进行代码开发 - -在AI引擎框架的整体规划中,北向SDK属于client端的一部分,插件由server端调用,属于server端的一部分,因此AI引擎框架为接入的插件与北向SDK规划的路径: - -- SDK代码路径://foundation/ai/engine/services/client/algorithm_sdk - - 示例1://foundation/ai/engine/services/client/algorithm_sdk/cv - - 示例2://foundation/ai/engine/services/client/algorithm_sdk/nlu - -- 插件代码路径://foundation/ai/engine/services/server/plugin - - 示例1://foundation/ai/engine/services/server/plugin/cv - - 示例2://foundation/ai/engine/services/server/plugin/nlu - - -## 规则:插件提供的全部对外接口,统一存放在AI业务子系统interfaces/kits目录 - -北向SDK对外接口是AI业务子系统提供能力的对外暴露方式,按照OpenHarmony的接口管理要求,需统一存放在各子系统的interfaces/kits目录中。当前AI业务子系统插件对外接口路径为//foundation/ai/engine/interfaces/kits,不同插件可在该路径下添加目录,比如增加cv插件,则在路径//foundation/ai/engine/interfaces/kits/cv下面存放接口文件。 - - -## 规则:插件编译输出路径必须是在/usr/lib - -server端加载插件是采用dlopen方式,只支持在/usr/lib路径进行,因此插件在编译so时,需要在编译配置文件中指定输出路径为/usr/lib。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-interface.md b/zh-cn/device-dev/subsystems/subsys-aiframework-tech-interface.md deleted file mode 100755 index 71b3005765f00e10ad0c39fdd24b777919de5d0d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-interface.md +++ /dev/null @@ -1,145 +0,0 @@ -# 接口开发规范 - - -## 规则:SDK需按算法调用顺序,封装client对外提供接口;对于异步插件对应的SDK,需要实现client提供的回调接口IClientCb - -AI引擎的client端对外提供的接口包括AieClientInit、AieClientPrepare、AieClientSyncProcess、AieClientAsyncProcess、AieClientRelease、AieClientDestroy、AieClientSetOption、AieClientGetOption,SDK需要根据插件的北向接口按照顺序至少封装AieClientInit、AieClientPrepare、AieClientSyncProcess/AieClientAsyncProcess、AieClientRelease、AieClientDestroy五个接口,否则会出现调用问题或者内存泄漏。比如封装过程遗漏了AieClientPrepare接口,则server端无法完成插件加载,故后面的接口都无法调用成功。 - -对于异步插件,SDK需要实现IClientCb接口,用于接收来自client端的算法推理结果,并将该结果返回给三方调用者。 - - -## 规则:SDK接口实现中,需要保存与client交互的相关通用数据 - -AI引擎将的client端采用单例实现,对接多个SDK,因此各SDK需要保存与client交互的通用数据,用于连接server端进行任务推理、结果返回等;需保存数据包含clientInfo、algorithmInfo、configInfo三种数据类型,定义在SDK的成员变量里即可。 - - -## 建议:SDK实现client定义的IServiceDeadCb接口 - -Server端是系统常驻进程,以系统能力的形式为多个client提供服务;client定义的IServiceDeadCb接口,是在server端异常死亡后,会被触发调用。这种异常场景,SDK可在死亡通知接口中,实现相关操作,比如停止调用或者再次拉起server端等。 - -IServiceDeadCb接口实现示例: - - -``` -class ServiceDeadCb : public IServiceDeadCb { -public: -ServiceDeadCb() = default; -~ServiceDeadCb() override = default; -void OnServiceDead() override -{ -printf("[ServiceDeadCb]OnServiceDead Callback happens"); -} -}; -``` - -如上示例,SDK可在OnServiceDead()方法中实现自己的操作,比如停止所有的接口调用等等。 - - -## 规则:SDK与plugin需要使用编解码模块,将特定算法数据转换成AI引擎的通用数据类型 - -插件的推理数据,会由三方调用者通过client、server传递到插件中;不同的算法所需要的数据类型是不一致的,比如cv的需要图片数据、asr的需要语音数据;为了适配数据类型的差异,AI引擎对外提供了对基本数据类型的编解码能力,将不同数据类型转换为AI引擎可以使用的通用数据类型。 - -编码后的数据类型定义: - - -``` -struct DataInfo { -unsigned char *data; -int length; -} DataInfo; - -``` - -如上示例,DataInfo数据结构包括指向数据内存的指针和数据长度两个变量组成。 - -框架接口使用方法: - -1.添加依赖的头文件:"utils/encdec/include/encdec.h"。 - -2.添加build.gn中的依赖项: - -include_dirs添加"//foundation/ai/engine/services/common"。 - -deps添加"//foundation/ai/engine/services/common/utils/encdec:encdec" 。 - -3.编解码示例: - - -``` -// 编码调用函数示例:arg1,arg2,arg3等为需编码的变量,dataInfo为编码后的结果 -retCode = ProcessEncode(dataInfo, arg1, arg2, arg3) //可以接收任意多个参数 -// 解码调用函数示例:dataInfo为需要解码的信息,arg1,arg2,arg3等为解码后的结果 -retCode = ProcessDecode(dataInfo, arg1, arg2, arg3) //可以接收任意多个参数 -``` - -注意: - -- 编码和解码调用时的参数顺序需要保证一致。 - -- 编码后dataInfo的内存需要调用者手动进行释放。 - -- server端和client端的内存是分开管理和释放的。 - -- 如果包含共享内存的指针,不需要额外处理。 - -- 如果其他类型的指针,则需要解引用后使用ProcessEncode/ ProcessDecode。 - -- 该编解码模块未适配class数据类型,不建议使用。 - - -## 规则:在SDK中,对以编解码返回的出参数据类型,需要进行内存释放,否则会出现内存泄漏 - -编码得到的通用数据,本质上是将不同类型数据封装在同一块内存中,然后将这块内存的首地址与长度封装到结构体中。通过编码返回到SDK中的出参数据,在插件中申请了内存,但插件无法释放;因此SDK在拿到数据之后,需要对内存进行释放,否则SDK将无法拿到数据。 - -内存释放示例: - - -``` -DataInfo outputInfo = { -.data = nullptr, -.length = 0, -}; -AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); -if (outputInfo.data != nullptr) { -free(outputInfo.data); -outputInfo.data = nullptr; -outputInfo.length = 0; -} -``` - - -## 规则:plugin需要实现server定义的IPlugin接口,并使用宏PLUGIN_INTERFACE_IMPL对外提供插件函数指针 - -Server端管理的插件内部接口实现逻辑各不相同,为了统一插件的加载流程,AI引擎定义了插件接口IPlugin;在运行态,插件是以动态链接库的形式被AI引擎框架通过dlopen方式加载,各插件需要使用PLUGIN_INTERFACE_IMPL语句对外暴露函数指针,否则插件将无法被正常加载使用。 - - -## 规则:plugin需要使用AI引擎提供的统一数据通道 - -AI引擎在server与插件之间,提供了一个统一的数据通道,用来处理来自SDK的推理请求和来自插件的结果返回;plugin在推理接口中,需按数据通道完成请求数据的获取以及推理结果的封装。 - -数据通道使用示例: - - -``` -int SyncProcess(IRequest *request, IResponse *&response) -{ -HILOGI("[IvpPlugin]Begin SyncProcess"); -if (request == nullptr) { -HILOGE("[IvpPlugin]SyncProcess request is nullptr"); -return RETCODE_NULL_PARAM; -} -DataInfo inputInfo = request->GetMsg(); -if (inputInfo.data == nullptr) { -HILOGE("[IvpPlugin]InputInfo data is nullptr"); -return RETCODE_NULL_PARAM; -} - -... - -response = IResponse::Create(request); -response->SetResult(outputInfo); -return RETCODE_SUCCESS; -} -``` - -示例中request和response是数据通道的内容主体。server端会将数据封装在request中,传递到插件,插件进行算法处理之后,则需要将结果封装成response进行返回。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-name.md b/zh-cn/device-dev/subsystems/subsys-aiframework-tech-name.md deleted file mode 100755 index b680d9ea5df4442281d72ede24601664bf5be31c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-name.md +++ /dev/null @@ -1,15 +0,0 @@ -# 命名规范 - - -## SDK命名规则:领域_关键词<_其他信息1_其他信息2_…>_sdk.so - -关于领域,建议使用当前主流简称,比如图片视频相关的使用"cv",语音识别相关的使用“asr”,翻译相关的使用“translation”等,存在其他领域的可增加定义;关键词则需要恰当准确的描述所对应插件的算法能力,比如唤醒词识别,则使用keyword_spotting;对于其他信息,比如插件支持的芯片类型、国内海外等信息,可在关键词与“sdk”之间依次添加,信息之间以下划线连接;SDK命名,必须以“_sdk”结尾。 - -例如:唤醒词识别插件对应的SDK,只支持麒麟9000芯片,适用于中国国内地区适用,则对应的SDK命名为:asr_keyword_spotting_kirin9000_china_sdk.so - - -## 插件命名规则:领域_关键词<_其他信息1_其他信息2_…>.so - -插件与SDK存在一一对应的关系,故插件命名的领域、关键词、其他信息等名词解释与要求,均与SDK命名要求保持一致。两者唯一的不同之处在于SDK命名多了个“_sdk”结尾;比如插件命名为“asr_keyword_spotting.so”,则对应SDK命名为“asr_keyword_spotting_sdk.so”。 - -例如:唤醒词识别插件对应的SDK,只支持麒麟9000芯片,适用于中国国内地区适用,则对应的插件命名为:asr_keyword_spotting_kirin9000_china.so diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-tech.md b/zh-cn/device-dev/subsystems/subsys-aiframework-tech.md deleted file mode 100644 index c591eef7a6927bd60249dbe7f2cd06ca0133a6d3..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-tech.md +++ /dev/null @@ -1,17 +0,0 @@ -# 技术规范 - - -**用词约定:** - - -**规则**:必须准守的约定 - - -**建议**:需要加以考虑的约定 - - -- **[代码管理规范](subsys-aiframework-tech-codemanage.md)** - -- **[命名规范](subsys-aiframework-tech-name.md)** - -- **[接口开发规范](subsys-aiframework-tech-interface.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework.md b/zh-cn/device-dev/subsystems/subsys-aiframework.md deleted file mode 100644 index aa8f2af29402dedaa8baf40495786d2bd52edd33..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-aiframework.md +++ /dev/null @@ -1,13 +0,0 @@ -# AI框架 - - - -- **[概述](subsys-aiframework-guide.md)** - -- **[搭建环境](subsys-aiframework-envbuild.md)** - -- **[技术规范](subsys-aiframework-tech.md)** - -- **[开发指导](subsys-aiframework-devguide.md)** - -- **[开发示例](subsys-aiframework-demo.md)** \ No newline at end of file diff --git "a/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" "b/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" index a2022d3765087cbf8f1cfc069da111aafa46bfb5..1b2609b9e4e62203b5a7301c2d2a86b27c76e9f1 100755 --- "a/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" +++ "b/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" @@ -6,17 +6,23 @@ ## 简介 -公共基础类库提供了一些常用的C、C++开发增强API。包括如下部分: +公共基础类库提供了一些常用的C、C++、JS开发增强API。包括如下部分: -**C++部分:** +**c_utils** - 文件、路径、字符串相关操作的能力增强接口; - 读写锁、信号量、定时器、线程增强及线程池等接口; - 安全数据容器、数据序列化等接口; - 各子系统的错误码相关定义; -- C语言安全函数接口。 -**C部分:** +**ets_utils** + +- JS中URI、URL、xml相关操作接口; +- JS中字符编解码接口; +- JS中进程相关操作接口; +- JS中多线程能力; + +**utils_lite** - 标准文件相关操作HAL接口; - 其它一些内部功能,如定时器等。 @@ -24,18 +30,19 @@ ## 目录 ``` -/utils - ├── native # 工具类的native层实现 - └── system # 系统相关的预定义值和安全策略配 +/commonlibrary + ├── c_utils # c/c++标准库之外方便开发者开发的基础工具库 + ├── ets_utils # js标准库之外的与语言强相关的基础库 + └── utils_lite # lite上使用的工具函数,涉及c和js语言 ``` ## 相关仓 **公共基础库子系统** -[utils](https://gitee.com/openharmony/utils) -[utils\_native](https://gitee.com/openharmony/utils_native) +[commonlibrary\_c\_utils](https://gitee.com/openharmony/commonlibrary_c_utils) -[utils\_native\_lite](https://gitee.com/openharmony/utils_native_lite) +[commonlibrary\_ets\_utils](https://gitee.com/openharmony/commonlibrary_ets_utils) +[commonlibrary\_utils\_lite](https://gitee.com/openharmony/commonlibrary_utils_lite)